Skip to content
Closed
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
4 changes: 2 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,7 @@
"phpunit/phpunit": "^9.6",
"sebastian/comparator": "^4.0.5",
"symfony/cache": "^6.4.9",
"vimeo/psalm": "^5.20"
"vimeo/psalm": "^6.14.0"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 12 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@
<DeprecatedInterface errorLevel="info" />

<RiskyTruthyFalsyComparison 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
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Controller/ApiProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use Apigee\Edge\Serializer\EntitySerializerInterface;
use Psr\Http\Message\UriInterface;

class ApiProductController extends OrganizationAwareEntityController implements ApiProductControllerInterface
final class ApiProductController extends OrganizationAwareEntityController implements ApiProductControllerInterface
{
use EntityCreateOperationControllerTrait;
use EntityDeleteOperationControllerTrait;
Expand Down 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
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* Class AppController.
*/
class AppController extends PaginatedEntityController implements AppControllerInterface
final class AppController extends PaginatedEntityController implements AppControllerInterface
{
use EntityListingControllerTrait;
use PaginationHelperTrait {
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
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/AppGroupAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Class AppGroupAppController.
*/
class AppGroupAppController extends AppByOwnerController implements AppGroupAppControllerInterface
final class AppGroupAppController extends AppByOwnerController implements AppGroupAppControllerInterface
{
use AppGroupAwareControllerTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* Class AppGroupAppCredentialController.
*/
class AppGroupAppCredentialController extends CompanyAppCredentialController
final class AppGroupAppCredentialController extends CompanyAppCredentialController
{
/** @var string appgroup name. */
protected $appGroup;
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/AppGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* Class AppGroupController.
*/
class AppGroupController extends PaginatedEntityController implements AppGroupControllerInterface
final class AppGroupController extends PaginatedEntityController implements AppGroupControllerInterface
{
use AttributesAwareEntityControllerTrait;
use EntityCrudOperationsControllerTrait;
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/AppGroupMembersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Allows to manage appgroup memberships.
*/
class AppGroupMembersController extends AbstractController implements AppGroupMembersControllerInterface
final class AppGroupMembersController extends AbstractController implements AppGroupMembersControllerInterface
{
use AppGroupAwareControllerTrait;
use OrganizationAwareControllerTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Apigee\Edge\Serializer\EntitySerializerInterface;
use Psr\Http\Message\UriInterface;

class DeveloperAcceptedRatePlanController extends AcceptedRatePlanController
final class DeveloperAcceptedRatePlanController extends AcceptedRatePlanController
{
/**
* UUID or email address of a developer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Apigee\Edge\Serializer\EntitySerializerInterface;
use Psr\Http\Message\UriInterface;

class DeveloperBillingTypeController extends BillingTypeController
final class DeveloperBillingTypeController extends BillingTypeController
{
/**
* Email address of a developer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Apigee\Edge\Serializer\EntitySerializerInterface;
use Psr\Http\Message\UriInterface;

class DeveloperPrepaidBalanceController extends PrepaidBalanceController implements DeveloperPrepaidBalanceControllerInterface
final class DeveloperPrepaidBalanceController extends PrepaidBalanceController implements DeveloperPrepaidBalanceControllerInterface
{
/**
* Email address of a developer.
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;
}
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Controller/RatePlanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use Apigee\Edge\Serializer\EntitySerializerInterface;
use Psr\Http\Message\UriInterface;

class RatePlanController extends OrganizationAwareEntityController implements RatePlanControllerInterface
final class RatePlanController extends OrganizationAwareEntityController implements RatePlanControllerInterface
{
use EntityCrudOperationsControllerTrait {
buildEntityCreatePayload as private traitBuildContextForEntityTransformerInCreate;
Expand Down 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
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Controller/SupportedCurrencyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Apigee\Edge\Controller\EntityListingControllerTrait;
use Psr\Http\Message\UriInterface;

class SupportedCurrencyController extends EntityController implements SupportedCurrencyControllerInterface
final class SupportedCurrencyController extends EntityController implements SupportedCurrencyControllerInterface
{
use EntityListingControllerTrait;

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) ?: []);
}
}
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Denormalizer/ApiProductDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

class ApiProductDenormalizer extends ObjectDenormalizer
final class ApiProductDenormalizer extends ObjectDenormalizer
{
/**
* ApiProductDenormalizer constructor.
Expand All @@ -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) ?: []);
}
}
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Denormalizer/AppDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* Dynamically denormalizes apps to developer- or appgroup apps.
*/
class AppDenormalizer extends ObjectDenormalizer
final class AppDenormalizer extends ObjectDenormalizer
{
/**
* Fully qualified class name of the developer app entity.
Expand Down 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Denormalizes appgroup membership data.
*/
class AppGroupMembershipDenormalizer implements DenormalizerInterface
final class AppGroupMembershipDenormalizer implements DenormalizerInterface
{
/**
* {@inheritdoc}
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 @@ -20,7 +20,7 @@

use Apigee\Edge\Api\ApigeeX\Entity\DeveloperAcceptedRatePlan;

class DeveloperAcceptedRatePlanDenormalizer extends AcceptedRatePlanDenormalizer
final class DeveloperAcceptedRatePlanDenormalizer extends AcceptedRatePlanDenormalizer
{
/**
* Fully qualified class name of the developer accepted rate plan entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

use Apigee\Edge\Api\ApigeeX\Entity\DeveloperBillingType;

class DeveloperBillingTypeDenormalizer extends BillingTypeDenormalizer
final class DeveloperBillingTypeDenormalizer extends BillingTypeDenormalizer
{
/**
* Fully qualified class name of the developer billing type.
Expand Down
Loading
Loading