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
8 changes: 8 additions & 0 deletions .github/workflows/php-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
dependencies-preference: " "
- php: '8.3'
dependencies-preference: "--prefer-lowest"
- php: '8.4'
dependencies-preference: " "
- php: '8.4'
dependencies-preference: "--prefer-lowest"
- php: '8.5'
dependencies-preference: " "
- php: '8.5'
dependencies-preference: "--prefer-lowest"
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down
38 changes: 28 additions & 10 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 || ~8.5",
"ext-json": "*",
"ext-openssl": "*",
"ext-reflection": "*",
Expand All @@ -28,14 +28,15 @@
"php-http/message-factory": "^1.0",
"phpdocumentor/reflection-docblock": "^5.0",
"psr/http-message": "^1.0 || ^2.0",
"symfony/options-resolver": "^7.4.0",
"symfony/property-access": "^7.4.4",
"symfony/property-info": "^7.4.0",
"symfony/serializer": "^7.3.0"
"symfony/options-resolver": "^7.4.8",
"symfony/property-access": "^7.4.8",
"symfony/property-info": "^7.4.8",
"symfony/serializer": "^7.4.8",
"guzzlehttp/promises": "^2.0.3"
},
"require-dev": {
"dms/phpunit-arraysubset-asserts": "^0.4.0",
"friendsofphp/php-cs-fixer": "^3.68",
"friendsofphp/php-cs-fixer": "^3.80",
"fzaninotto/faker": "^1.7",
"guzzlehttp/psr7": "^2.5",
"league/flysystem": "^1.0",
Expand All @@ -46,10 +47,27 @@
"phpmetrics/phpmetrics": "^2.7",
"phpunit/phpunit": "^9.6",
"sebastian/comparator": "^4.0.5",
"symfony/cache": "^7.3.0",
"symfony/type-info": "^7.3.0",
"symfony/var-exporter": "^7.3.0",
"vimeo/psalm": "^5.20"
"symfony/cache": "^7.4.8",
"symfony/type-info": "^7.4.8",
"symfony/var-exporter": "^7.4.8",
"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
38 changes: 15 additions & 23 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2018 Google LLC
~
Expand All @@ -15,17 +14,15 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.4/phpunit.xsd"
colors="true"
bootstrap="./vendor/autoload.php"
printerClass="LimeDeck\Testing\Printer"
verbose="true">
<php>
<!-- Apigee Edge credentials - uncomment and change these lines to change to an online test. -->
<!--
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" bootstrap="./vendor/autoload.php" printerClass="LimeDeck\Testing\Printer" verbose="true">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<!-- Apigee Edge credentials - uncomment and change these lines to change to an online test. -->
<!--
<env name="APIGEE_EDGE_PHP_CLIENT_API_CLIENT" value="\Apigee\Edge\Tests\Test\Client"/>
<env name="APIGEE_EDGE_PHP_CLIENT_HTTP_CLIENT" value="\Http\Adapter\Guzzle6\Client"/>
<env name="APIGEE_EDGE_PHP_CLIENT_ORGANIZATION" value="myorg"/>
Expand All @@ -34,15 +31,10 @@
<env name="APIGEE_EDGE_PHP_CLIENT_ENVIRONMENT" value="prod"/>
<env name="APIGEE_EDGE_ENDPOINT" value="https://api.enterprise.apigee.com/v1"/>
-->
</php>
<testsuites>
<testsuite name="All Apigee Edge PHP API Client Tests">
<directory>tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</php>
<testsuites>
<testsuite name="All Apigee Edge PHP API Client Tests">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 13 additions & 1 deletion psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
allowStringToStandInForClass="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config file:///var/www/html/vendor/vimeo/psalm/config.xsd"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
Expand Down 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>
2 changes: 1 addition & 1 deletion 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
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) (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
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
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, array $con
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, array $con
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) ?: []);
}
}
Loading
Loading