diff --git a/.travis.yml b/.travis.yml index 81e01afa..24d343a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,8 @@ addons: - git php: - - 7.1 - - 7.2 - 7.3 + - 7.4 jobs: fast_finish: true @@ -34,13 +33,13 @@ install: # Disable xDebug (but do not remove its configuration, because we need that for code coverage calculation). # Clear the default 6 minutes max execution time limit otherwise test suite fails in case of online tests. - echo -en "max_execution_time = 0\nxdebug.default_enable = 0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - composer self-update --1 - - if [[ $(phpenv version-name) = "7.1" ]] || [[ $(phpenv version-name) = "7.2" ]]; then composer global require hirak/prestissimo:^0.3.7; fi - travis_retry composer update $COMPOSER_OPTIONS $DEPENDENCIES + + - if [[ $(phpenv version-name) = "7.3" ]]; then composer require symfony/polyfill-mbstring:1.19.0 --update-with-dependencies $DEPENDENCIES; fi + # Fix PHPUnit tests on PHP >= 7.2 by upgrading Guzzle to >= 6.3.0. # https://github.com/guzzle/guzzle/issues/1973 - - if [[ $(phpenv version-name) = "7.2" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then composer require guzzlehttp/guzzle:^6.3.0 --update-with-dependencies $DEPENDENCIES; fi - if [[ $(phpenv version-name) = "7.3" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then composer require guzzlehttp/guzzle:^6.3.0 --update-with-dependencies $DEPENDENCIES; fi - if [[ $(phpenv version-name) = "7.4" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then composer require guzzlehttp/guzzle:^6.3.0 --update-with-dependencies $DEPENDENCIES; fi - composer show @@ -55,8 +54,8 @@ script: - composer check-style -- --using-cache=no "${EXTRA_ARGS[@]}" - composer analyze # Only calculate metrics data for this specific build. - - if [[ $(phpenv version-name) = "7.1" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then composer test -- --coverage-clover=clover.xml; else composer test; fi - - if [[ $(phpenv version-name) = "7.1" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then composer metrics; fi + - if [[ $(phpenv version-name) = "7.4" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then composer test; fi + - if [[ $(phpenv version-name) = "7.4" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then composer metrics; fi after_success: - - if [[ $(phpenv version-name) = "7.1" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then bash <(curl -s https://codecov.io/bash) -f ./clover.xml; fi + - if [[ $(phpenv version-name) = "7.4" ]] && [[ "$DEPENDENCIES" = "--prefer-lowest" ]]; then bash <(curl -s https://codecov.io/bash) -f ./clover.xml; fi diff --git a/composer.json b/composer.json index 814d93ab..2bca72ea 100644 --- a/composer.json +++ b/composer.json @@ -31,29 +31,27 @@ "symfony/options-resolver": "^3.4 || ^4.0", "symfony/property-access": "^3.4.41 || ^4.4.9", "symfony/property-info": "^3.4 || ^4.0", - "symfony/serializer": "^3.4 || ^4.0" + "symfony/serializer": "^4.4" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", + "friendsofphp/php-cs-fixer": "^2.19", "fzaninotto/faker": "^1.7", "guzzlehttp/psr7": "^1.0", "league/flysystem": "^1.0", - "limedeck/phpunit-detailed-printer": "^3.2", + "limedeck/phpunit-detailed-printer": "^4", "monolog/monolog": "^1.23", "php-http/guzzle6-adapter": "^2.0", "php-http/mock-client": "^1.1.0", "phpmetrics/phpmetrics": "^2.3", - "phpunit/phpunit": "^6.4.0", - "sebastian/comparator": "^2.1", + "phpunit/phpunit": "^7.5.20", + "sebastian/comparator": "^3.0.3", "symfony/cache": "~3.4 || ~4.0", - "vimeo/psalm": "^2.0.0" + "vimeo/psalm": "^3.18.2" }, "conflict": { "guzzlehttp/guzzle": "<6.1.0", "guzzlehttp/psr7": "<1.4.1", - "phpdocumentor/type-resolver": "<0.2.1", - "vimeo/psalm": ">2.0.13", - "symfony/polyfill-mbstring": ">1.20.0" + "phpdocumentor/type-resolver": "<0.2.1" }, "autoload": { "psr-4": { diff --git a/psalm.xml.dist b/psalm.xml.dist index 11e2e816..0c31e235 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -3,6 +3,8 @@ name="Apigee Edge PHP API client default configuration" totallyTyped="false" useDocblockTypes="true" + memoizeMethodCallResults="true" + 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" diff --git a/src/Api/ApigeeX/Controller/ApiProductController.php b/src/Api/ApigeeX/Controller/ApiProductController.php index bc01500e..ad51b2c3 100755 --- a/src/Api/ApigeeX/Controller/ApiProductController.php +++ b/src/Api/ApigeeX/Controller/ApiProductController.php @@ -134,7 +134,7 @@ private function getEligibleProducts(string $type, string $entityId): array } } - $current_ms = substr(microtime(true) * 1000, 0); + $current_ms = substr((string) (microtime(true) * 1000), 0); foreach ($this->getAvailablexApiProducts($type, $entityId, true) as $item) { // Create a new rate plan controller. diff --git a/src/Api/ApigeeX/Denormalizer/AcceptedRatePlanDenormalizer.php b/src/Api/ApigeeX/Denormalizer/AcceptedRatePlanDenormalizer.php index 2267b386..4157aca0 100755 --- a/src/Api/ApigeeX/Denormalizer/AcceptedRatePlanDenormalizer.php +++ b/src/Api/ApigeeX/Denormalizer/AcceptedRatePlanDenormalizer.php @@ -32,10 +32,10 @@ abstract class AcceptedRatePlanDenormalizer extends ObjectDenormalizer * @psalm-suppress PossiblyNullReference - getPackage() can only return * null when a rate plan is created. It does not return null here. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { /** @var \Apigee\Edge\Api\ApigeeX\Entity\AcceptedRatePlanInterface $denormalized */ - $denormalized = parent::denormalize($data, $class, $format, $context); + $denormalized = parent::denormalize($data, $type, $format, $context); return $denormalized; } diff --git a/src/Api/ApigeeX/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php b/src/Api/ApigeeX/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php index 171f04f6..d76f95fd 100755 --- a/src/Api/ApigeeX/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php +++ b/src/Api/ApigeeX/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php @@ -32,7 +32,7 @@ class DeveloperAcceptedRatePlanDenormalizer extends AcceptedRatePlanDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return parent::denormalize($data, $this->developerAcceptedRatePlanClass, $format, $context); } diff --git a/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizer.php b/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizer.php index a7a0acd3..93d3dc5b 100755 --- a/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizer.php +++ b/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizer.php @@ -54,10 +54,10 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory * @psalm-suppress PossiblyNullReference - Organization should not be null * here. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { /** @var \Apigee\Edge\Api\ApigeeX\Entity\RatePlanInterface $entity */ - $entity = parent::denormalize($data, $class, $format, $context); + $entity = parent::denormalize($data, $type, $format, $context); return $entity; } diff --git a/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizerFactory.php b/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizerFactory.php index ffad4dd2..066f3a8d 100755 --- a/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizerFactory.php +++ b/src/Api/ApigeeX/Denormalizer/RatePlanDenormalizerFactory.php @@ -56,13 +56,13 @@ public function __construct(array $denormalizers = []) * @psalm-suppress InvalidNullableReturnType - There are going to be at * least one denormalizer always that can denormalize data here. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { foreach ($this->denormalizers as $denormalizer) { // Return the result from the first denormalizer that can // denormalize this. - if ($denormalizer->supportsDenormalization($data, $class, $format)) { - return $denormalizer->denormalize($data, $class, $format, $context); + if ($denormalizer->supportsDenormalization($data, $type, $format)) { + return $denormalizer->denormalize($data, $type, $format, $context); } } } diff --git a/src/Api/ApigeeX/Denormalizer/RatePlanRateDenormalizer.php b/src/Api/ApigeeX/Denormalizer/RatePlanRateDenormalizer.php index 2a18296e..434a60e5 100755 --- a/src/Api/ApigeeX/Denormalizer/RatePlanRateDenormalizer.php +++ b/src/Api/ApigeeX/Denormalizer/RatePlanRateDenormalizer.php @@ -33,7 +33,7 @@ class RatePlanRateDenormalizer extends ObjectDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { $denormalized = (array) $data; if (RatePlanRate::TYPE_REVSHARE === $data->type) { diff --git a/src/Api/ApigeeX/Denormalizer/StandardRatePlanDenormalizer.php b/src/Api/ApigeeX/Denormalizer/StandardRatePlanDenormalizer.php index 063985cc..0437fe1f 100755 --- a/src/Api/ApigeeX/Denormalizer/StandardRatePlanDenormalizer.php +++ b/src/Api/ApigeeX/Denormalizer/StandardRatePlanDenormalizer.php @@ -41,7 +41,7 @@ class StandardRatePlanDenormalizer extends RatePlanDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if (isset($data->parentRatePlan)) { return parent::denormalize($data, $this->standardRatePlanRevisionClass, $format, $context); diff --git a/src/Api/ApigeeX/Entity/AcceptedRatePlanInterface.php b/src/Api/ApigeeX/Entity/AcceptedRatePlanInterface.php index 35e4ecbc..4b863d6e 100755 --- a/src/Api/ApigeeX/Entity/AcceptedRatePlanInterface.php +++ b/src/Api/ApigeeX/Entity/AcceptedRatePlanInterface.php @@ -18,6 +18,7 @@ namespace Apigee\Edge\Api\ApigeeX\Entity; +use Apigee\Edge\Api\ApigeeX\Entity\Property\ApiProductPropertyInterface; use Apigee\Edge\Api\ApigeeX\Entity\Property\EndTimePropertyInterface; use Apigee\Edge\Api\ApigeeX\Entity\Property\StartTimePropertyInterface; use Apigee\Edge\Api\Monetization\Entity\EntityInterface; @@ -27,6 +28,7 @@ interface AcceptedRatePlanInterface extends EntityInterface, EndTimePropertyInterface, StartTimePropertyInterface, + ApiProductPropertyInterface, NamePropertyInterface { /** diff --git a/src/Api/ApigeeX/Entity/RatePlanInterface.php b/src/Api/ApigeeX/Entity/RatePlanInterface.php index 177144a7..03ff093f 100755 --- a/src/Api/ApigeeX/Entity/RatePlanInterface.php +++ b/src/Api/ApigeeX/Entity/RatePlanInterface.php @@ -19,6 +19,7 @@ namespace Apigee\Edge\Api\ApigeeX\Entity; use Apigee\Edge\Api\ApigeeX\Entity\Property\ApiProductPropertyInterface; +use Apigee\Edge\Api\ApigeeX\Entity\Property\EndTimePropertyInterface; use Apigee\Edge\Api\ApigeeX\Structure\ConsumptionPricingRate; use Apigee\Edge\Api\ApigeeX\Structure\FixedRecurringFee; use Apigee\Edge\Api\ApigeeX\Structure\RatePlanXFee; @@ -33,6 +34,7 @@ interface RatePlanInterface extends DescriptionPropertyInterface, DisplayNamePropertyInterface, ApiProductPropertyInterface, + EndTimePropertyInterface, NamePropertyInterface { public const FREQUENCY_DURATION_DAY = 'DAY'; diff --git a/src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php b/src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php index 3fcac97d..c369fe0f 100755 --- a/src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php +++ b/src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php @@ -64,12 +64,6 @@ public function normalize($object, $format = null, array $context = []) throw new UninitializedPropertyException($object, 'package', 'Apigee\Edge\Api\ApigeeX\Entity\ApiProductInterface'); } - if (null === $object->getPackage()->getOrganization()) { - throw new UninitializedPropertyException($object->getPackage(), 'organization', 'Apigee\Edge\Api\Monetization\Entity\OrganizationProfileInterface'); - } - - //$this->fixTimeZoneOnNormalization($object, $normalized, $object->getPackage()->getOrganization()->getTimezone()); - return $normalized; } diff --git a/src/Api/Management/Controller/AppCredentialControllerInterface.php b/src/Api/Management/Controller/AppCredentialControllerInterface.php index 345d1429..78a80838 100644 --- a/src/Api/Management/Controller/AppCredentialControllerInterface.php +++ b/src/Api/Management/Controller/AppCredentialControllerInterface.php @@ -104,10 +104,11 @@ public function addProducts(string $consumerKey, array $apiProducts): AppCredent * * @see https://docs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/developers/%7Bdeveloper_email_or_id%7D/apps/%7Bapp_name%7D/keys/%7Bconsumer_key%7D-0 * - * @param string $consumerKey + * @param string $entityId + * The consumer key * @param string $status */ - public function setStatus(string $consumerKey, string $status): void; + public function setStatus(string $entityId, string $status): void; /** * Approve or revoke API product for an API key. diff --git a/src/Api/Management/Denormalizer/AppDenormalizer.php b/src/Api/Management/Denormalizer/AppDenormalizer.php index ce9c287f..8d8c95ff 100644 --- a/src/Api/Management/Denormalizer/AppDenormalizer.php +++ b/src/Api/Management/Denormalizer/AppDenormalizer.php @@ -46,7 +46,7 @@ class AppDenormalizer extends ObjectDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if (isset($data->developerId)) { return parent::denormalize($data, $this->developerAppClass, $format, $context); diff --git a/src/Api/Management/Denormalizer/CompanyMembershipDenormalizer.php b/src/Api/Management/Denormalizer/CompanyMembershipDenormalizer.php index 8fa5cf0a..42b3f38a 100755 --- a/src/Api/Management/Denormalizer/CompanyMembershipDenormalizer.php +++ b/src/Api/Management/Denormalizer/CompanyMembershipDenormalizer.php @@ -29,7 +29,7 @@ class CompanyMembershipDenormalizer implements DenormalizerInterface /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { $denormalized = []; // Ignore parent "developer" key. diff --git a/src/Api/Monetization/Controller/EntityListingControllerAwareTrait.php b/src/Api/Monetization/Controller/EntityListingControllerAwareTrait.php index 194c2764..0838245f 100644 --- a/src/Api/Monetization/Controller/EntityListingControllerAwareTrait.php +++ b/src/Api/Monetization/Controller/EntityListingControllerAwareTrait.php @@ -32,6 +32,8 @@ trait EntityListingControllerAwareTrait /** * {@inheritdoc} + * + * @return \Apigee\Edge\Entity\EntityInterface[] */ public function getEntities(): array { diff --git a/src/Api/Monetization/Controller/FilteredReportDefinitionsTrait.php b/src/Api/Monetization/Controller/FilteredReportDefinitionsTrait.php index c282650e..b7ebfe8a 100644 --- a/src/Api/Monetization/Controller/FilteredReportDefinitionsTrait.php +++ b/src/Api/Monetization/Controller/FilteredReportDefinitionsTrait.php @@ -27,6 +27,8 @@ trait FilteredReportDefinitionsTrait /** * {@inheritdoc} + * + * @return \Apigee\Edge\Api\Monetization\Entity\ReportDefinitionInterface[] */ public function getFilteredEntities(int $limit = null, int $page = 1, string $sort = null): array { diff --git a/src/Api/Monetization/Controller/LegalEntityTermsAndConditionsController.php b/src/Api/Monetization/Controller/LegalEntityTermsAndConditionsController.php index 7ba94a57..9bf9642b 100644 --- a/src/Api/Monetization/Controller/LegalEntityTermsAndConditionsController.php +++ b/src/Api/Monetization/Controller/LegalEntityTermsAndConditionsController.php @@ -33,7 +33,7 @@ abstract class LegalEntityTermsAndConditionsController extends OrganizationAware { use EntityListingControllerTrait; use ListingHelperTrait { - responseArrayToArrayOfEntities as private traitResponseArrayToArrayOfEntities; + EntityListingControllerTrait::responseArrayToArrayOfEntities as private traitResponseArrayToArrayOfEntities; } /** diff --git a/src/Api/Monetization/Controller/PaginatedEntityListingControllerAwareTrait.php b/src/Api/Monetization/Controller/PaginatedEntityListingControllerAwareTrait.php index d8311122..f47e2871 100644 --- a/src/Api/Monetization/Controller/PaginatedEntityListingControllerAwareTrait.php +++ b/src/Api/Monetization/Controller/PaginatedEntityListingControllerAwareTrait.php @@ -31,6 +31,8 @@ trait PaginatedEntityListingControllerAwareTrait /** * {@inheritdoc} + * + * @return \Apigee\Edge\Entity\EntityInterface[] */ public function getEntities(): array { @@ -39,6 +41,8 @@ public function getEntities(): array /** * {@inheritdoc} + * + * @return \Apigee\Edge\Entity\EntityInterface[] */ public function getPaginatedEntityList(int $limit = null, int $page = 1): array { diff --git a/src/Api/Monetization/Denormalizer/AcceptedRatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/AcceptedRatePlanDenormalizer.php index 8dbe865a..7945c138 100644 --- a/src/Api/Monetization/Denormalizer/AcceptedRatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/AcceptedRatePlanDenormalizer.php @@ -32,10 +32,10 @@ abstract class AcceptedRatePlanDenormalizer extends ObjectDenormalizer * @psalm-suppress PossiblyNullReference - getPackage() can only return * null when a rate plan is created. It does not return null here. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { /** @var \Apigee\Edge\Api\Monetization\Entity\AcceptedRatePlanInterface $denormalized */ - $denormalized = parent::denormalize($data, $class, $format, $context); + $denormalized = parent::denormalize($data, $type, $format, $context); $this->fixTimeZoneOnDenormalization($data, $denormalized, $denormalized->getRatePlan()->getPackage()->getOrganization()->getTimezone()); diff --git a/src/Api/Monetization/Denormalizer/CompanyAcceptedRatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/CompanyAcceptedRatePlanDenormalizer.php index 0d5745b6..42e1e2da 100644 --- a/src/Api/Monetization/Denormalizer/CompanyAcceptedRatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/CompanyAcceptedRatePlanDenormalizer.php @@ -51,7 +51,7 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return parent::denormalize($data, $this->companyAcceptedRatePlanClass, $format, $context); } diff --git a/src/Api/Monetization/Denormalizer/CompanyPaymentTransactionDenormalizer.php b/src/Api/Monetization/Denormalizer/CompanyPaymentTransactionDenormalizer.php index 8c47558f..7339a7d8 100644 --- a/src/Api/Monetization/Denormalizer/CompanyPaymentTransactionDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/CompanyPaymentTransactionDenormalizer.php @@ -51,7 +51,7 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return parent::denormalize($data, $this->companyPaymentTransactionClass, $format, $context); } diff --git a/src/Api/Monetization/Denormalizer/CompanyRatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/CompanyRatePlanDenormalizer.php index 7153b374..2f624b8a 100644 --- a/src/Api/Monetization/Denormalizer/CompanyRatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/CompanyRatePlanDenormalizer.php @@ -56,7 +56,7 @@ public function __construct(?\Symfony\Component\Serializer\Mapping\Factory\Class /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if (isset($data->parentRatePlan)) { return parent::denormalize($data, $this->companyRatePlanRevisionClass, $format, $context); diff --git a/src/Api/Monetization/Denormalizer/CompanyReportDefinitionDenormalizer.php b/src/Api/Monetization/Denormalizer/CompanyReportDefinitionDenormalizer.php index acf2e555..9c52f55d 100644 --- a/src/Api/Monetization/Denormalizer/CompanyReportDefinitionDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/CompanyReportDefinitionDenormalizer.php @@ -51,7 +51,7 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return parent::denormalize($data, $this->companyReportDefinitionClass, $format, $context); } diff --git a/src/Api/Monetization/Denormalizer/DateTimeZoneDenormalizer.php b/src/Api/Monetization/Denormalizer/DateTimeZoneDenormalizer.php index 6d326928..3f91ed78 100644 --- a/src/Api/Monetization/Denormalizer/DateTimeZoneDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/DateTimeZoneDenormalizer.php @@ -27,12 +27,12 @@ class DateTimeZoneDenormalizer implements DenormalizerInterface /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { try { return new DateTimeZone($data); } catch (\Exception $e) { - throw new UnexpectedValueException(sprintf('"%s" is not a valid timezone.', $data), $e->getCode(), $e); + throw new UnexpectedValueException(sprintf('"%s" is not a valid timezone.', $data), (int) $e->getCode(), $e); } } diff --git a/src/Api/Monetization/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php index 73f6503c..186a4e84 100644 --- a/src/Api/Monetization/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/DeveloperAcceptedRatePlanDenormalizer.php @@ -32,7 +32,7 @@ class DeveloperAcceptedRatePlanDenormalizer extends AcceptedRatePlanDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return parent::denormalize($data, $this->developerAcceptedRatePlanClass, $format, $context); } diff --git a/src/Api/Monetization/Denormalizer/DeveloperCategoryRatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/DeveloperCategoryRatePlanDenormalizer.php index 7a5b2df2..a6214ad1 100644 --- a/src/Api/Monetization/Denormalizer/DeveloperCategoryRatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/DeveloperCategoryRatePlanDenormalizer.php @@ -41,7 +41,7 @@ class DeveloperCategoryRatePlanDenormalizer extends RatePlanDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if (isset($data->parentRatePlan)) { return parent::denormalize($data, $this->developerCategoryRatePlanRevisionClass, $format, $context); diff --git a/src/Api/Monetization/Denormalizer/DeveloperPaymentTransactionDenormalizer.php b/src/Api/Monetization/Denormalizer/DeveloperPaymentTransactionDenormalizer.php index 13b434c1..e0bdcb5a 100644 --- a/src/Api/Monetization/Denormalizer/DeveloperPaymentTransactionDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/DeveloperPaymentTransactionDenormalizer.php @@ -32,7 +32,7 @@ class DeveloperPaymentTransactionDenormalizer extends PaymentTransactionDenormal /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return parent::denormalize($data, $this->developerPaymentTransactionClass, $format, $context); } diff --git a/src/Api/Monetization/Denormalizer/DeveloperRatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/DeveloperRatePlanDenormalizer.php index 2fcbe70b..2607fb88 100644 --- a/src/Api/Monetization/Denormalizer/DeveloperRatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/DeveloperRatePlanDenormalizer.php @@ -41,7 +41,7 @@ class DeveloperRatePlanDenormalizer extends RatePlanDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if (isset($data->parentRatePlan)) { return parent::denormalize($data, $this->developerRatePlanRevisionClass, $format, $context); diff --git a/src/Api/Monetization/Denormalizer/DeveloperReportDefinitionDenormalizer.php b/src/Api/Monetization/Denormalizer/DeveloperReportDefinitionDenormalizer.php index 44467328..dc039b49 100644 --- a/src/Api/Monetization/Denormalizer/DeveloperReportDefinitionDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/DeveloperReportDefinitionDenormalizer.php @@ -32,7 +32,7 @@ class DeveloperReportDefinitionDenormalizer extends ReportDefinitionDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return parent::denormalize($data, $this->developerReportDefinitionClass, $format, $context); } diff --git a/src/Api/Monetization/Denormalizer/LegalEntityDenormalizer.php b/src/Api/Monetization/Denormalizer/LegalEntityDenormalizer.php index b0dd33e2..db7257b5 100644 --- a/src/Api/Monetization/Denormalizer/LegalEntityDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/LegalEntityDenormalizer.php @@ -64,7 +64,7 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if ($data->isCompany) { return parent::denormalize($data, $this->companyClass, $format, $context); diff --git a/src/Api/Monetization/Denormalizer/RatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/RatePlanDenormalizer.php index 73b6123e..cd8a15e0 100644 --- a/src/Api/Monetization/Denormalizer/RatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/RatePlanDenormalizer.php @@ -54,10 +54,10 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory * @psalm-suppress PossiblyNullReference - Organization should not be null * here. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { /** @var \Apigee\Edge\Api\Monetization\Entity\RatePlanInterface $entity */ - $entity = parent::denormalize($data, $class, $format, $context); + $entity = parent::denormalize($data, $type, $format, $context); $this->fixTimeZoneOnDenormalization($data, $entity, $entity->getOrganization()->getTimezone()); diff --git a/src/Api/Monetization/Denormalizer/RatePlanDenormalizerFactory.php b/src/Api/Monetization/Denormalizer/RatePlanDenormalizerFactory.php index 8d34995c..035e97c8 100644 --- a/src/Api/Monetization/Denormalizer/RatePlanDenormalizerFactory.php +++ b/src/Api/Monetization/Denormalizer/RatePlanDenormalizerFactory.php @@ -53,13 +53,13 @@ public function __construct(array $denormalizers = []) * @psalm-suppress InvalidNullableReturnType - There are going to be at * least one denormalizer always that can denormalize data here. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { foreach ($this->denormalizers as $denormalizer) { // Return the result from the first denormalizer that can // denormalize this. - if ($denormalizer->supportsDenormalization($data, $class, $format)) { - return $denormalizer->denormalize($data, $class, $format, $context); + if ($denormalizer->supportsDenormalization($data, $type, $format)) { + return $denormalizer->denormalize($data, $type, $format, $context); } } } diff --git a/src/Api/Monetization/Denormalizer/RatePlanRateDenormalizer.php b/src/Api/Monetization/Denormalizer/RatePlanRateDenormalizer.php index 6cf0d38e..5030afa4 100644 --- a/src/Api/Monetization/Denormalizer/RatePlanRateDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/RatePlanRateDenormalizer.php @@ -33,7 +33,7 @@ class RatePlanRateDenormalizer extends ObjectDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { $denormalized = (array) $data; if (RatePlanRate::TYPE_REVSHARE === $data->type) { diff --git a/src/Api/Monetization/Denormalizer/ReportCriteriaDenormalizer.php b/src/Api/Monetization/Denormalizer/ReportCriteriaDenormalizer.php index 5f45dc50..f79f7661 100644 --- a/src/Api/Monetization/Denormalizer/ReportCriteriaDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/ReportCriteriaDenormalizer.php @@ -60,7 +60,7 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory * * @psalm-suppress PossiblyInvalidArgument We are sure of the return type of denormalize(). */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { // This is what is in the type-hint on the $criteria property of the // ReportDefinition object. @@ -68,16 +68,16 @@ public function denormalize($data, $class, $format = null, array $context = []) // available in symfony/serializer > 4.1 therefore we have to use a // workaround here. // https://symfony.com/doc/master/components/serializer.html#serializing-interfaces-and-abstract-classes - if (AbstractCriteria::class === $class && isset($context[static::CONTEXT_REPORT_DEFINITION_TYPE])) { + if (AbstractCriteria::class === $type && isset($context[static::CONTEXT_REPORT_DEFINITION_TYPE])) { switch ($context[static::CONTEXT_REPORT_DEFINITION_TYPE]) { case ReportDefinitionInterface::TYPE_BILLING: - $class = BillingReportCriteria::class; + $type = BillingReportCriteria::class; break; case ReportDefinitionInterface::TYPE_PREPAID_BALANCE: - $class = PrepaidBalanceReportCriteria::class; + $type = PrepaidBalanceReportCriteria::class; break; case ReportDefinitionInterface::TYPE_REVENUE: - $class = RevenueReportCriteria::class; + $type = RevenueReportCriteria::class; break; default: @@ -115,7 +115,7 @@ public function denormalize($data, $class, $format = null, array $context = []) $data->productIds = array_unique($data->productIds); } - $denormalized = parent::denormalize($data, $class, $format, $context); + $denormalized = parent::denormalize($data, $type, $format, $context); // According to the API documentation it is always UTC. // https://docs.apigee.com/api-platform/monetization/create-reports#createreportdefapi diff --git a/src/Api/Monetization/Denormalizer/StandardRatePlanDenormalizer.php b/src/Api/Monetization/Denormalizer/StandardRatePlanDenormalizer.php index aad55091..44ebdb87 100644 --- a/src/Api/Monetization/Denormalizer/StandardRatePlanDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/StandardRatePlanDenormalizer.php @@ -41,7 +41,7 @@ class StandardRatePlanDenormalizer extends RatePlanDenormalizer /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if (isset($data->parentRatePlan)) { return parent::denormalize($data, $this->standardRatePlanRevisionClass, $format, $context); diff --git a/src/Api/Monetization/Denormalizer/TermsAndConditionsDenormalizer.php b/src/Api/Monetization/Denormalizer/TermsAndConditionsDenormalizer.php index 84235a3b..c12eff05 100644 --- a/src/Api/Monetization/Denormalizer/TermsAndConditionsDenormalizer.php +++ b/src/Api/Monetization/Denormalizer/TermsAndConditionsDenormalizer.php @@ -51,10 +51,10 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory * @psalm-suppress PossiblyNullReference - Organization should not be null * here. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { /** @var \Apigee\Edge\Api\Monetization\Entity\TermsAndConditionsInterface $entity */ - $entity = parent::denormalize($data, $class, $format, $context); + $entity = parent::denormalize($data, $type, $format, $context); $this->fixTimeZoneOnDenormalization($data, $entity, $entity->getOrganization()->getTimezone()); diff --git a/src/Api/Monetization/Entity/Property/AddressesPropertyAwareTrait.php b/src/Api/Monetization/Entity/Property/AddressesPropertyAwareTrait.php index 7b9c6715..472abd2e 100644 --- a/src/Api/Monetization/Entity/Property/AddressesPropertyAwareTrait.php +++ b/src/Api/Monetization/Entity/Property/AddressesPropertyAwareTrait.php @@ -31,7 +31,9 @@ trait AddressesPropertyAwareTrait protected $addresses = []; /** - * @@inheritdoc + * {@inheritdoc} + * + * @return \Apigee\Edge\Api\Monetization\Structure\Address[] */ public function getAddresses(): array { @@ -39,7 +41,7 @@ public function getAddresses(): array } /** - * @@inheritdoc + * {@inheritdoc} */ public function setAddresses(Address ...$addresses): void { diff --git a/src/Api/Monetization/Entity/Property/ApiProductsPropertyAwareTrait.php b/src/Api/Monetization/Entity/Property/ApiProductsPropertyAwareTrait.php index 31cd172c..b03dd283 100644 --- a/src/Api/Monetization/Entity/Property/ApiProductsPropertyAwareTrait.php +++ b/src/Api/Monetization/Entity/Property/ApiProductsPropertyAwareTrait.php @@ -32,6 +32,8 @@ trait ApiProductsPropertyAwareTrait /** * {@inheritdoc} + * + * @return \Apigee\Edge\Api\Monetization\Entity\ApiProductInterface[] */ public function getApiProducts(): array { diff --git a/src/Api/Monetization/Serializer/ReportDefinitionSerializer.php b/src/Api/Monetization/Serializer/ReportDefinitionSerializer.php index 4617f7bd..d04d17e7 100644 --- a/src/Api/Monetization/Serializer/ReportDefinitionSerializer.php +++ b/src/Api/Monetization/Serializer/ReportDefinitionSerializer.php @@ -84,11 +84,11 @@ public function deserialize($data, $type, $format, array $context = []) /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { $this->addReportDefinitionTypeToContext($data, $context); - return parent::denormalize($data, $class, $format, $context); + return parent::denormalize($data, $type, $format, $context); } /** diff --git a/src/Client.php b/src/Client.php index d3344666..18e8e2c5 100644 --- a/src/Client.php +++ b/src/Client.php @@ -169,7 +169,7 @@ public function getEndpoint(): string /** * {@inheritdoc} */ - public function getUserAgent(): string + public function getUserAgent(): ?string { if (null !== $this->userAgentPrefix) { return sprintf("{$this->userAgentPrefix} ({$this->getClientVersion()})"); diff --git a/src/Controller/NonPaginatedEntityListingControllerTrait.php b/src/Controller/NonPaginatedEntityListingControllerTrait.php index 993a0001..807302b5 100644 --- a/src/Controller/NonPaginatedEntityListingControllerTrait.php +++ b/src/Controller/NonPaginatedEntityListingControllerTrait.php @@ -32,6 +32,8 @@ trait NonPaginatedEntityListingControllerTrait /** * {@inheritdoc} + * + * @return \Apigee\Edge\Entity\EntityInterface[] */ public function getEntities(): array { diff --git a/src/Controller/PaginatedEntityListingControllerTrait.php b/src/Controller/PaginatedEntityListingControllerTrait.php index 3d7d95be..bba35ed2 100644 --- a/src/Controller/PaginatedEntityListingControllerTrait.php +++ b/src/Controller/PaginatedEntityListingControllerTrait.php @@ -29,6 +29,8 @@ trait PaginatedEntityListingControllerTrait { /** * {@inheritdoc} + * + * @return \Apigee\Edge\Entity\EntityInterface[] */ public function getEntities(PagerInterface $pager = null, string $key_provider = 'id'): array { diff --git a/src/Denormalizer/AttributesPropertyDenormalizer.php b/src/Denormalizer/AttributesPropertyDenormalizer.php index 94b86888..90299901 100644 --- a/src/Denormalizer/AttributesPropertyDenormalizer.php +++ b/src/Denormalizer/AttributesPropertyDenormalizer.php @@ -48,7 +48,7 @@ public function supportsDenormalization($data, $type, $format = null) * * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { $flatten = []; foreach ($data as $key => $item) { @@ -61,6 +61,6 @@ public function denormalize($data, $class, $format = null, array $context = []) } $data = $flatten; - return parent::denormalize($data, $class, $format, $context); + return parent::denormalize($data, $type, $format, $context); } } diff --git a/src/Denormalizer/CredentialProductDenormalizer.php b/src/Denormalizer/CredentialProductDenormalizer.php index 4777bc83..34dd0440 100644 --- a/src/Denormalizer/CredentialProductDenormalizer.php +++ b/src/Denormalizer/CredentialProductDenormalizer.php @@ -43,7 +43,7 @@ public function supportsDenormalization($data, $type, $format = null) /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { return new CredentialProduct($data->apiproduct, $data->status); } diff --git a/src/Denormalizer/EdgeDateDenormalizer.php b/src/Denormalizer/EdgeDateDenormalizer.php index 5f6e4591..3a5ae6df 100644 --- a/src/Denormalizer/EdgeDateDenormalizer.php +++ b/src/Denormalizer/EdgeDateDenormalizer.php @@ -51,7 +51,7 @@ public function __construct() * @psalm-suppress ImplementedReturnTypeMismatch - We have to return null, * even if it not officially supported by the overridden class. */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { // Handle -1 in expiresAt property of AppCredential. if ($data < 0) { @@ -60,7 +60,7 @@ public function denormalize($data, $class, $format = null, array $context = []) $context[$this->normalizer::FORMAT_KEY] = 'U'; $context[$this->normalizer::TIMEZONE_KEY] = new \DateTimeZone('UTC'); - return $this->normalizer->denormalize(intval($data / 1000), $class, $format, $context); + return $this->normalizer->denormalize(intval($data / 1000), $type, $format, $context); } /** diff --git a/src/Denormalizer/KeyValueMapDenormalizer.php b/src/Denormalizer/KeyValueMapDenormalizer.php index 0213ccd1..af17052b 100644 --- a/src/Denormalizer/KeyValueMapDenormalizer.php +++ b/src/Denormalizer/KeyValueMapDenormalizer.php @@ -29,9 +29,9 @@ class KeyValueMapDenormalizer implements DenormalizerInterface /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { - return new $class($data); + return new $type($data); } /** diff --git a/src/Denormalizer/ObjectDenormalizer.php b/src/Denormalizer/ObjectDenormalizer.php index e1cc87c9..43acb4b4 100644 --- a/src/Denormalizer/ObjectDenormalizer.php +++ b/src/Denormalizer/ObjectDenormalizer.php @@ -90,7 +90,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { // The original input should not be altered. if (is_object($data)) { @@ -108,7 +108,7 @@ public function denormalize($data, $class, $format = null, array $context = []) } } - return $this->objectNormalizer->denormalize($cleanData, $class, $this->format, $context); + return $this->objectNormalizer->denormalize($cleanData, $type, $this->format, $context); } /** diff --git a/src/Denormalizer/PropertiesPropertyDenormalizer.php b/src/Denormalizer/PropertiesPropertyDenormalizer.php index fc1e088c..9910d712 100644 --- a/src/Denormalizer/PropertiesPropertyDenormalizer.php +++ b/src/Denormalizer/PropertiesPropertyDenormalizer.php @@ -41,7 +41,7 @@ public function supportsDenormalization($data, $type, $format = null) /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { if (is_object($data) && property_exists($data, 'property') && is_array($data->property)) { $flatten = []; @@ -51,6 +51,6 @@ public function denormalize($data, $class, $format = null, array $context = []) $data = $flatten; } - return parent::denormalize($data, $class, $format, $context); + return parent::denormalize($data, $type, $format, $context); } } diff --git a/src/Entity/Property/AppsPropertyAwareTrait.php b/src/Entity/Property/AppsPropertyAwareTrait.php index 929fa3fe..94991636 100644 --- a/src/Entity/Property/AppsPropertyAwareTrait.php +++ b/src/Entity/Property/AppsPropertyAwareTrait.php @@ -30,6 +30,8 @@ trait AppsPropertyAwareTrait /** * {@inheritdoc} + * + * @return string[] Names of apps that this developer owns. */ public function getApps(): array { diff --git a/src/Entity/Property/EnvironmentsPropertyAwareTrait.php b/src/Entity/Property/EnvironmentsPropertyAwareTrait.php index 8c2cbf26..22eb7103 100644 --- a/src/Entity/Property/EnvironmentsPropertyAwareTrait.php +++ b/src/Entity/Property/EnvironmentsPropertyAwareTrait.php @@ -28,6 +28,8 @@ trait EnvironmentsPropertyAwareTrait /** * {@inheritdoc} + * + * @return string[] */ public function getEnvironments(): array { diff --git a/src/Entity/Property/ScopesPropertyAwareTrait.php b/src/Entity/Property/ScopesPropertyAwareTrait.php index c4ce45ef..3f8b1a28 100644 --- a/src/Entity/Property/ScopesPropertyAwareTrait.php +++ b/src/Entity/Property/ScopesPropertyAwareTrait.php @@ -30,6 +30,8 @@ trait ScopesPropertyAwareTrait /** * {@inheritdoc} + * + * @return string[] */ public function getScopes(): array { diff --git a/src/HttpClient/Plugin/Authentication/ApigeeOnGcpOauth2.php b/src/HttpClient/Plugin/Authentication/ApigeeOnGcpOauth2.php index 15b57fae..39c7634c 100644 --- a/src/HttpClient/Plugin/Authentication/ApigeeOnGcpOauth2.php +++ b/src/HttpClient/Plugin/Authentication/ApigeeOnGcpOauth2.php @@ -116,7 +116,7 @@ protected function getAccessToken(): void try { $jwt = JWT::encode($token, $this->privateKey, 'RS256'); } catch (DomainException $e) { - throw new ApigeeOnGcpOauth2AuthenticationException($e->getMessage(), $e->getCode(), $e); + throw new ApigeeOnGcpOauth2AuthenticationException($e->getMessage(), (int) $e->getCode(), $e); } $body = [ @@ -129,7 +129,7 @@ protected function getAccessToken(): void $decodedResponse = json_decode((string) $response->getBody(), true); $this->tokenStorage->saveToken($decodedResponse); } catch (Exception $e) { - throw new ApigeeOnGcpOauth2AuthenticationException($e->getMessage(), $e->getCode(), $e); + throw new ApigeeOnGcpOauth2AuthenticationException($e->getMessage(), (int) $e->getCode(), $e); } } } diff --git a/src/HttpClient/Plugin/Authentication/GceServiceAccount.php b/src/HttpClient/Plugin/Authentication/GceServiceAccount.php index f23c9044..7a93f8f0 100644 --- a/src/HttpClient/Plugin/Authentication/GceServiceAccount.php +++ b/src/HttpClient/Plugin/Authentication/GceServiceAccount.php @@ -86,7 +86,7 @@ protected function getAccessToken(): void $decoded_token = json_decode((string) $response->getBody(), true); $this->tokenStorage->saveToken($decoded_token); } catch (Exception $e) { - throw new ApigeeOnGcpOauth2AuthenticationException($e->getMessage(), $e->getCode(), $e); + throw new ApigeeOnGcpOauth2AuthenticationException($e->getMessage(), (int) $e->getCode(), $e); } } diff --git a/src/HttpClient/Plugin/Authentication/HybridOauth2.php b/src/HttpClient/Plugin/Authentication/HybridOauth2.php index 7e0cc34c..3b54ef10 100644 --- a/src/HttpClient/Plugin/Authentication/HybridOauth2.php +++ b/src/HttpClient/Plugin/Authentication/HybridOauth2.php @@ -118,7 +118,7 @@ protected function getAccessToken(): void try { $jwt = JWT::encode($token, $this->privateKey, 'RS256'); } catch (DomainException $e) { - throw new HybridOauth2AuthenticationException($e->getMessage(), $e->getCode(), $e); + throw new HybridOauth2AuthenticationException($e->getMessage(), (int) $e->getCode(), $e); } $body = [ @@ -131,7 +131,7 @@ protected function getAccessToken(): void $decodedResponse = json_decode((string) $response->getBody(), true); $this->tokenStorage->saveToken($decodedResponse); } catch (Exception $e) { - throw new HybridOauth2AuthenticationException($e->getMessage(), $e->getCode(), $e); + throw new HybridOauth2AuthenticationException($e->getMessage(), (int) $e->getCode(), $e); } } } diff --git a/src/HttpClient/Plugin/Authentication/Oauth.php b/src/HttpClient/Plugin/Authentication/Oauth.php index 3a41a8c7..099ed4ce 100644 --- a/src/HttpClient/Plugin/Authentication/Oauth.php +++ b/src/HttpClient/Plugin/Authentication/Oauth.php @@ -143,7 +143,7 @@ protected function getAccessToken(): void // id and secret. $this->getAccessToken(); } catch (Exception $e) { - throw new OauthAuthenticationException($e->getMessage(), $e->getCode(), $e); + throw new OauthAuthenticationException($e->getMessage(), (int) $e->getCode(), $e); } } } diff --git a/src/HttpClient/Plugin/ResponseHandlerPlugin.php b/src/HttpClient/Plugin/ResponseHandlerPlugin.php index 7209c902..41fcb154 100644 --- a/src/HttpClient/Plugin/ResponseHandlerPlugin.php +++ b/src/HttpClient/Plugin/ResponseHandlerPlugin.php @@ -70,10 +70,10 @@ public function handleRequest(RequestInterface $request, callable $next, callabl if (is_a($e, HttpException::class)) { $this->decodeResponse($e->getResponse(), $request); } elseif (is_a($e, RequestException::class) || is_a($e, NetworkException::class)) { - throw new ApiRequestException($request, $e->getMessage(), $e->getCode(), $e); + throw new ApiRequestException($request, $e->getMessage(), (int) $e->getCode(), $e); } - throw new ApiException($e->getMessage(), $e->getCode(), $e); + throw new ApiException($e->getMessage(), (int) $e->getCode(), $e); }); } diff --git a/src/PropertyAccess/PropertyAccessorDecorator.php b/src/PropertyAccess/PropertyAccessorDecorator.php index 7593b28e..e8b86ea3 100644 --- a/src/PropertyAccess/PropertyAccessorDecorator.php +++ b/src/PropertyAccess/PropertyAccessorDecorator.php @@ -76,7 +76,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value): void $objectOrArray->{$setter}(...$value); } } catch (\TypeError $typeError) { - self::processTypeErrorOnSetValue($typeError->getMessage(), $typeError->getTrace(), 0); + self::processTypeErrorOnSetValue($typeError->getMessage(), $typeError->getTrace(), 0, $typeError); // Rethrow the exception if it could not be transformed // to an invalid argument exception. @@ -174,24 +174,37 @@ private static function processTypeErrorOnGetValue($object, string $property, \T * @param $message * @param $trace * @param $i + * @param $previous * * @see \Symfony\Component\PropertyAccess\PropertyAccessor::throwInvalidArgumentException() + * + * @psalm-suppress PossiblyFalseOperand + * @psalm-suppress PossiblyFalseArgument */ - private static function processTypeErrorOnSetValue($message, $trace, $i): void + private static function processTypeErrorOnSetValue($message, $trace, $i, $previous = null): void { - if (0 !== strpos($message, 'Argument ')) { + if (!isset($trace[$i]['file']) || __FILE__ !== $trace[$i]['file']) { return; } - if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file'] && array_key_exists(0, $trace[$i]['args'])) { + if (\PHP_VERSION_ID < 80000) { + if (0 !== strpos($message, 'Argument ')) { + return; + } + $pos = strpos($message, $delim = 'must be of the type ') ?: (strpos($message, $delim = 'must be an instance of ') ?: strpos($message, $delim = 'must implement interface ')); - if (false !== $pos) { - $pos += \strlen($delim); - $type = $trace[$i]['args'][0]; - $type = \is_object($type) ? \get_class($type) : \gettype($type); + $pos += \strlen($delim); + $j = strpos($message, ',', $pos); + $type = substr($message, 2 + $j, strpos($message, ' given', $j) - $j - 2); + $message = substr($message, $pos, $j - $pos); - throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.', substr($message, $pos, (int) strpos($message, ',', $pos) - $pos), $type)); - } + throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.', $message, 'NULL' === $type ? 'null' : $type), 0, $previous); + } + + if (preg_match('/^\S+::\S+\(\): Argument #\d+ \(\$\S+\) must be of type (\S+), (\S+) given/', $message, $matches)) { + list(, $expectedType, $actualType) = $matches; + + throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.', $expectedType, 'NULL' === $actualType ? 'null' : $actualType), 0, $previous); } } } diff --git a/src/Serializer/EntitySerializer.php b/src/Serializer/EntitySerializer.php index 9bece79b..b9643d64 100755 --- a/src/Serializer/EntitySerializer.php +++ b/src/Serializer/EntitySerializer.php @@ -71,9 +71,9 @@ public function __construct(array $normalizers = []) /** * {@inheritdoc} */ - public function denormalize($data, $class, $format = null, array $context = []) + public function denormalize($data, $type, $format = null, array $context = []) { - return $this->serializer->denormalize($data, $class, $format, $context); + return $this->serializer->denormalize($data, $type, $format, $context); } /** diff --git a/tests/PropertyAccess/PropertyAccessorDecoratorTest.php b/tests/PropertyAccess/PropertyAccessorDecoratorTest.php index e4da1aaf..3e61eb12 100644 --- a/tests/PropertyAccess/PropertyAccessorDecoratorTest.php +++ b/tests/PropertyAccess/PropertyAccessorDecoratorTest.php @@ -189,7 +189,7 @@ public function exceptionsToGetOnGetValue(): array public function exceptionsToGetOnSetValue(): array { return [ - ['shouldBeAStringArray', [null], InvalidArgumentException::class, '/^Expected argument of type "string", "NULL" given/'], + ['shouldBeAStringArray', [null], InvalidArgumentException::class, '/^Expected argument of type "string", "null" given/'], ]; } } diff --git a/tests/Serializer/EntitySerializerTest.php b/tests/Serializer/EntitySerializerTest.php index b2b4920b..25ae48d7 100644 --- a/tests/Serializer/EntitySerializerTest.php +++ b/tests/Serializer/EntitySerializerTest.php @@ -181,7 +181,7 @@ public function testSetPropertiesFromResponseWithValidValues(): void /** * @expectedException \Symfony\Component\Serializer\Exception\NotNormalizableValueException - * @expectedExceptionMessage Expected argument of type "string", "stdClass" given. + * @expectedExceptionMessage Expected argument of type "string", "object" given. */ public function testSetPropertiesFromResponseWithInvalidValue(): void { diff --git a/tests/Test/TestClientFactory.php b/tests/Test/TestClientFactory.php index 570ac627..fe99bef7 100644 --- a/tests/Test/TestClientFactory.php +++ b/tests/Test/TestClientFactory.php @@ -47,7 +47,7 @@ private function __clone() { } - private function __wakeup(): void + public function __wakeup(): void { }