Skip to content

Commit

Permalink
[#165] Support PHP 7.4 and deprecate 7.1 and 7.2 (#166)
Browse files Browse the repository at this point in the history
Support PHP 7.4 and deprecate 7.1 and 7.2
  • Loading branch information
phdhiren authored Aug 3, 2021
1 parent b13284c commit a883c12
Show file tree
Hide file tree
Showing 63 changed files with 140 additions and 107 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ addons:
- git

php:
- 7.1
- 7.2
- 7.3
- 7.4

jobs:
fast_finish: true
Expand All @@ -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
Expand All @@ -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
16 changes: 7 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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(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.
Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Denormalizer/AcceptedRatePlanDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Denormalizer/RatePlanDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Api/ApigeeX/Denormalizer/RatePlanDenormalizerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Api/ApigeeX/Denormalizer/RatePlanRateDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/Api/ApigeeX/Entity/AcceptedRatePlanInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,7 @@ interface AcceptedRatePlanInterface extends
EntityInterface,
EndTimePropertyInterface,
StartTimePropertyInterface,
ApiProductPropertyInterface,
NamePropertyInterface
{
/**
Expand Down
2 changes: 2 additions & 0 deletions src/Api/ApigeeX/Entity/RatePlanInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +34,7 @@ interface RatePlanInterface extends
DescriptionPropertyInterface,
DisplayNamePropertyInterface,
ApiProductPropertyInterface,
EndTimePropertyInterface,
NamePropertyInterface
{
public const FREQUENCY_DURATION_DAY = 'DAY';
Expand Down
6 changes: 0 additions & 6 deletions src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Management/Denormalizer/AppDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ trait EntityListingControllerAwareTrait

/**
* {@inheritdoc}
*
* @return \Apigee\Edge\Entity\EntityInterface[]
*/
public function getEntities(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class LegalEntityTermsAndConditionsController extends OrganizationAware
{
use EntityListingControllerTrait;
use ListingHelperTrait {
responseArrayToArrayOfEntities as private traitResponseArrayToArrayOfEntities;
EntityListingControllerTrait::responseArrayToArrayOfEntities as private traitResponseArrayToArrayOfEntities;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ trait PaginatedEntityListingControllerAwareTrait

/**
* {@inheritdoc}
*
* @return \Apigee\Edge\Entity\EntityInterface[]
*/
public function getEntities(): array
{
Expand All @@ -39,6 +41,8 @@ public function getEntities(): array

/**
* {@inheritdoc}
*
* @return \Apigee\Edge\Entity\EntityInterface[]
*/
public function getPaginatedEntityList(int $limit = null, int $page = 1): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit a883c12

Please sign in to comment.