Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/php-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
dependencies-preference: " "
- php: '8.3'
dependencies-preference: "--prefer-lowest"
- php: '8.4'
dependencies-preference: " "
- php: '8.4'
dependencies-preference: "--prefer-lowest"
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down
21 changes: 19 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"homepage": "http://github.com/apigee/apigee-client-php",
"license": "Apache-2.0",
"require": {
"php": "~8.2 || ~8.3",
"php": "~8.2 || ~8.3 || ~8.4",
"ext-json": "*",
"ext-openssl": "*",
"ext-reflection": "*",
Expand Down Expand Up @@ -47,7 +47,24 @@
"phpunit/phpunit": "^9.6",
"sebastian/comparator": "^4.0.5",
"symfony/cache": "^6.4.9",
"vimeo/psalm": "^5.20"
"vimeo/psalm": "^6.14.0",
"amphp/amp": "^3.1.1",
"amphp/byte-stream": "^2.1.2",
"amphp/cache": "^2.0.1",
"amphp/dns": "^2.4.1",
"amphp/parallel": "^2.3.3",
"amphp/parser": "^1.1.1",
"amphp/socket": "^2.4.0",
"daverandom/libdns": "^2.1.0",
"symfony/console": "^6.4.36 || ^7.0",
"spatie/array-to-xml": "^3.4.4",
"nikic/php-parser": "^5.7.0",
"amphp/pipeline": "^1.2.3",
"amphp/process": "^2.0.3",
"amphp/serialization": "^1.1.0",
"amphp/sync": "^2.0",
"revolt/event-loop": "^1.1.0",
"symfony/filesystem": "^7.4.8"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 13 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,18 @@

<RiskyTruthyFalsyComparison errorLevel="info" />

<ClassMustBeFinal errorLevel="info" />
<MissingOverrideAttribute errorLevel="info" />
<PossiblyUnusedMethod errorLevel="info" />
<PossiblyUnusedReturnValue errorLevel="info" />
<PossiblyUnusedParam errorLevel="info" />
<UnusedProperty errorLevel="info" />
<UnusedClass errorLevel="info" />
<UnusedVariable errorLevel="info" />
<UnusedDocblockParam errorLevel="info" />
<UnnecessaryVarAnnotation errorLevel="info" />
<PossiblyUnusedProperty errorLevel="info" />
<UnusedParam errorLevel="info" />

</issueHandlers>
</psalm>
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Controller/AcceptedRatePlanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function acceptRatePlan(RatePlanInterface $ratePlan): AcceptedRatePlanInt

$tmp = json_decode($payload, true);

$payload = json_encode($tmp);
$payload = (string) json_encode($tmp);

$response = $this->client->post($this->getBaseEndpointUri(), $payload);
$this->getEntitySerializer()->setPropertiesFromResponse($response, $acceptedRatePlan);
Expand Down Expand Up @@ -144,7 +144,7 @@ protected function alterRequestPayload(array &$payload, AcceptedRatePlanInterfac
* @param array $query_params
* Additional query parameters.
*
* @return \Apigee\Edge\Api\ApigeeX\Entity\AcceptedRatePlanInterface[]
* @return AcceptedRatePlanInterface[]
*
* @psalm-suppress PossiblyNullArrayOffset - id() does not return null here.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface AcceptedRatePlanControllerInterface extends
/**
* Gets all accepted rate plans.
*
* @return \Apigee\Edge\Api\ApigeeX\Entity\AcceptedRatePlanInterface[]
* @return AcceptedRatePlanInterface[]
*/
public function getAllAcceptedRatePlans(): array;

Expand All @@ -45,7 +45,7 @@ public function getAllAcceptedRatePlans(): array;
* @param int|null $limit
* @param int $page
*
* @return \Apigee\Edge\Api\ApigeeX\Entity\AcceptedRatePlanInterface[]
* @return AcceptedRatePlanInterface[]
*/
public function getPaginatedAcceptedRatePlanList(?int $limit = null, int $page = 1): array;

Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/ApiProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private function getEligibleProducts(string $type, string $entityId): array
}
}

$current_ms = substr((string) (microtime(true) * 1000), 0);
$current_ms = substr((string) ((int) (microtime(true) * 1000.0)), 0);

foreach ($this->getAvailablexApiProducts($type, $entityId, true) as $item) {
// Create a new rate plan controller.
Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Controller/AppControllerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function listAppIds(?PagerInterface $pager = null): array;
* @param PagerInterface|null $pager
* Number of results to return.
*
* @return \Apigee\Edge\Api\Management\Entity\AppInterface[]
* @return AppInterface[]
* An array that can contain both developer- and appgroup app entities.
*/
public function listApps(bool $includeCredentials = false, ?PagerInterface $pager = null): array;
Expand Down Expand Up @@ -110,7 +110,7 @@ public function listAppIdsByStatus(string $status, ?PagerInterface $pager = null
* @param PagerInterface|null $pager
* Number of results to return.
*
* @return \Apigee\Edge\Api\Management\Entity\AppInterface[]
* @return AppInterface[]
* An array that can contain both developer- and appgroup app entities.
*/
public function listAppsByStatus(
Expand Down
77 changes: 38 additions & 39 deletions src/Api/ApigeeX/Controller/PaginationHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,46 +112,45 @@ protected function listEntities(?PagerInterface $pager = null, array $query_para
$responseArray = reset($responseArray);

return $this->responseArrayToArrayOfEntities($responseArray, $key_provider);
} else {
// Default page size set to 1000, because the AppGroupApps endpoint
// does not return nextPageToken unless a pageSize is specified
// in the request parameters.
$pageSize = 1000;
// Pass an empty pager to load all entities.
$responseArray = $this->getResultsInRange($this->createPager($pageSize), $query_params);
// Check flag 'nextPageToken' to get next items from the list.
$nextPageToken = array_key_exists('nextPageToken', $responseArray) ? $responseArray['nextPageToken'] : false;
// Ignore entity type key from response, ex.: developer, apiproduct,
// etc.
$responseArray = reset($responseArray);
// Appgroup can be empty.
if (empty($responseArray) || !is_array($responseArray)) {
return [];
}
$entities = $this->responseArrayToArrayOfEntities($responseArray, $key_provider);

if ($nextPageToken) {
do {
$tmp = $this->getResultsInRange($this->createPager($pageSize, $nextPageToken), $query_params);
// Check the flag 'nextPageToken' to get next items from the list.
$nextPageToken = array_key_exists('nextPageToken', $tmp) ? $tmp['nextPageToken'] : false;
// Ignore entity type key from response, ex.: developer,
// apiproduct, etc.
$tmp = reset($tmp);
// Remove the first item from the list because it is the same
// as the last item of $entities at this moment.
// Apigee X response always starts with the requested entity
// (pageToken).
array_shift($tmp);
$tmpEntities = $this->responseArrayToArrayOfEntities($tmp, $key_provider);
// The returned entity array is keyed by entity id which
// is unique so we can do this.
$entities += $tmpEntities;
} while ($nextPageToken);
}

return $entities;
}
// Default page size set to 1000, because the AppGroupApps endpoint
// does not return nextPageToken unless a pageSize is specified
// in the request parameters.
$pageSize = 1000;
// Pass an empty pager to load all entities.
$responseArray = $this->getResultsInRange($this->createPager($pageSize), $query_params);
// Check flag 'nextPageToken' to get next items from the list.
$nextPageToken = array_key_exists('nextPageToken', $responseArray) ? $responseArray['nextPageToken'] : false;
// Ignore entity type key from response, ex.: developer, apiproduct,
// etc.
$responseArray = reset($responseArray);
// Appgroup can be empty.
if (empty($responseArray) || !is_array($responseArray)) {
return [];
}
$entities = $this->responseArrayToArrayOfEntities($responseArray, $key_provider);

if ($nextPageToken) {
do {
$tmp = $this->getResultsInRange($this->createPager($pageSize, $nextPageToken), $query_params);
// Check the flag 'nextPageToken' to get next items from the list.
$nextPageToken = array_key_exists('nextPageToken', $tmp) ? $tmp['nextPageToken'] : false;
// Ignore entity type key from response, ex.: developer,
// apiproduct, etc.
$tmp = reset($tmp);
// Remove the first item from the list because it is the same
// as the last item of $entities at this moment.
// Apigee X response always starts with the requested entity
// (pageToken).
array_shift($tmp);
$tmpEntities = $this->responseArrayToArrayOfEntities($tmp, $key_provider);
// The returned entity array is keyed by entity id which
// is unique so we can do this.
$entities += $tmpEntities;
} while ($nextPageToken);
}

return $entities;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/PrepaidBalanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ abstract protected function getPrepaidBalanceEndpoint(): UriInterface;
*
* @param string|null $currencyCode
*
* @return \Apigee\Edge\Api\ApigeeX\Entity\PrepaidBalanceInterface[]
* @return PrepaidBalanceInterface[]
*
* @psalm-suppress PossiblyNullArrayOffset - id() does not return null here.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function topUpBalance($amount, $amountnano, string $currencyCode, string
/**
* Gets prepaid balances.
*
* @return \Apigee\Edge\Api\ApigeeX\Entity\PrepaidBalanceInterface[]
* @return PrepaidBalanceInterface[]
*/
public function getPrepaidBalance(): array;
}
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/RatePlanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getEntities(?bool $showCurrentOnly = null, ?bool $showPrivate =
public function createNewRevision(RatePlanRevisionInterface $entity): void
{
$payload = $this->getEntitySerializer()->serialize($entity, 'json');
$response = $this->getClient()->post($this->getEntityEndpointUri($entity->getPreviousRatePlanRevision()->id()) . '/revision', $payload);
$response = $this->getClient()->post((string) $this->getEntityEndpointUri($entity->getPreviousRatePlanRevision()->id()) . '/revision', $payload);
$this->getEntitySerializer()->setPropertiesFromResponse($response, $entity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public function supportsDenormalization($data, $type, $format = null)
return false;
}

return AcceptedRatePlanInterface::class === $type || $type instanceof AcceptedRatePlanInterface || in_array(AcceptedRatePlanInterface::class, class_implements($type));
return AcceptedRatePlanInterface::class === $type || $type instanceof AcceptedRatePlanInterface || in_array(AcceptedRatePlanInterface::class, class_implements($type) ?: []);
}
}
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Denormalizer/ApiProductDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ public function supportsDenormalization($data, $type, $format = null)
return false;
}

return ApiProductInterface::class === $type || $type instanceof ApiProductInterface || in_array(ApiProductInterface::class, class_implements($type));
return ApiProductInterface::class === $type || $type instanceof ApiProductInterface || in_array(ApiProductInterface::class, class_implements($type) ?: []);
}
}
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Denormalizer/AppDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function supportsDenormalization($data, $type, $format = null)
return false;
}

return AppInterface::class === $type || $type instanceof AppInterface || in_array(AppInterface::class, class_implements($type));
return AppInterface::class === $type || $type instanceof AppInterface || in_array(AppInterface::class, class_implements($type) ?: []);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Denormalizer/BillingTypeDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public function supportsDenormalization($data, $type, $format = null)
return false;
}

return BillingTypeInterface::class === $type || $type instanceof BillingTypeInterface || in_array(BillingTypeInterface::class, class_implements($type));
return BillingTypeInterface::class === $type || $type instanceof BillingTypeInterface || in_array(BillingTypeInterface::class, class_implements($type) ?: []);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ public function supportsDenormalization($data, $type, $format = null)
return false;
}

return PrepaidBalanceInterface::class === $type || $type instanceof PrepaidBalanceInterface || in_array(PrepaidBalanceInterface::class, class_implements($type));
return PrepaidBalanceInterface::class === $type || $type instanceof PrepaidBalanceInterface || in_array(PrepaidBalanceInterface::class, class_implements($type) ?: []);
}
}
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Denormalizer/RatePlanDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public function supportsDenormalization($data, $type, $format = null)
return false;
}

return RatePlanInterface::class === $type || $type instanceof RatePlanInterface || in_array(RatePlanInterface::class, class_implements($type));
return RatePlanInterface::class === $type || $type instanceof RatePlanInterface || in_array(RatePlanInterface::class, class_implements($type) ?: []);
}
}
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Denormalizer/RatePlanDenormalizerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class RatePlanDenormalizerFactory implements DenormalizerInterface, SerializerAw
setSerializer as private traitSetSerializer;
}

/** @var \Symfony\Component\Serializer\Normalizer\DenormalizerInterface[] */
/** @var DenormalizerInterface[] */
protected $denormalizers = [];

/**
* RatePlanDenormalizerFactory constructor.
*
* @param \Symfony\Component\Serializer\Normalizer\DenormalizerInterface[] $denormalizers
* @param DenormalizerInterface[] $denormalizers
*/
public function __construct(array $denormalizers = [])
{
Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Entity/Property/NanosPropertyAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ trait NanosPropertyAwareTrait
*/
public function getNanos(): ?float
{
$nanos = $this->nanos ?? 0;
$nanos = $this->nanos ?? 0.0;

return $nanos * pow(10, -9);
return $nanos * 1e-9;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Api/ApigeeX/Entity/RatePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ abstract class RatePlan extends Entity implements RatePlanInterface
*/
protected $package;

/** @var \Apigee\Edge\Api\ApigeeX\Structure\RatePlanXFee[] */
/** @var RatePlanXFee[] */
protected $ratePlanXFee = [];

/** @var \Apigee\Edge\Api\ApigeeX\Structure\FixedRecurringFee[] */
/** @var FixedRecurringFee[] */
protected $fixedRecurringFee = [];

/** @var \Apigee\Edge\Api\ApigeeX\Structure\ConsumptionPricingRate[] */
/** @var ConsumptionPricingRate[] */
protected $consumptionPricingRates = [];

/** @var \Apigee\Edge\Api\ApigeeX\Structure\RevenueShareRates[] */
/** @var RevenueShareRates[] */
protected $revenueShareRates = [];

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Api/ApigeeX/Entity/RatePlanInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getPackage(): ?ApiProductInterface;
public function setPackage(ApiProductInterface $package): void;

/**
* @return \Apigee\Edge\Api\ApigeeX\Structure\RatePlanXFee[]
* @return RatePlanXFee[]
*/
public function getRatePlanxFee(): array;

Expand All @@ -78,7 +78,7 @@ public function getRatePlanxFee(): array;
public function setRatePlanxFee(RatePlanXFee ...$ratePlanXFee): void;

/**
* @return \Apigee\Edge\Api\ApigeeX\Structure\FixedRecurringFee[]
* @return FixedRecurringFee[]
*/
public function getFixedRecurringFee(): array;

Expand All @@ -88,7 +88,7 @@ public function getFixedRecurringFee(): array;
public function setFixedRecurringFee(FixedRecurringFee ...$fixedRecurringFee): void;

/**
* @return \Apigee\Edge\Api\ApigeeX\Structure\ConsumptionPricingRate[]
* @return ConsumptionPricingRate[]
*/
public function getConsumptionPricingRates(): array;

Expand All @@ -98,7 +98,7 @@ public function getConsumptionPricingRates(): array;
public function setConsumptionPricingRates(ConsumptionPricingRate ...$consumptionPricingRates): void;

/**
* @return \Apigee\Edge\Api\ApigeeX\Structure\RevenueShareRates[]
* @return RevenueShareRates[]
*/
public function getRevenueShareRates(): array;

Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class RatePlanNormalizerFactory implements NormalizerInterface, SerializerAwareI
setSerializer as private traitSetSerializer;
}

/** @var \Symfony\Component\Serializer\Normalizer\NormalizerInterface[] */
/** @var NormalizerInterface[] */
protected $normalizers = [];

/**
* RatePlanDenormalizerFactory constructor.
*
* @param \Symfony\Component\Serializer\Normalizer\NormalizerInterface[] $normalizers
* @param NormalizerInterface[] $normalizers
*/
public function __construct(array $normalizers = [])
{
Expand Down
Loading
Loading