Skip to content

Commit

Permalink
Merge drupal10-prep changes into 3.x (#276)
Browse files Browse the repository at this point in the history
* Http\Client\HttpClient deprecated used Psr\Http\Client\ClientInterface (#261) (#263)

Co-authored-by: Shishir <75600200+shishir-intelli@users.noreply.github.com>

* Fix for setIgnoredAttributes() method is deprecated (#238)

* Changes for symfony 6.2 upgrade (#262)

* Bumped minimum symfony/serializer version to 6.2 (#272)

* bump symfony/serializer

* typo fix

---------

Co-authored-by: Gitesh Koli <giteshk@users.noreply.github.com>
Co-authored-by: Shishir <75600200+shishir-intelli@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 22, 2023
1 parent 9ef9915 commit 5a6fed1
Show file tree
Hide file tree
Showing 51 changed files with 154 additions and 143 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/php-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ jobs:
strategy:
matrix:
include:
- php: '8.0'
dependencies-preference: " "
- php: '8.0'
dependencies-preference: "--prefer-lowest"
- php: '8.1'
dependencies-preference: " "
- php: '8.1'
Expand Down Expand Up @@ -44,10 +40,7 @@ jobs:
- name: Install dependencies
run: |
composer config --no-plugins allow-plugins.php-http/discovery true
COMPOSER_PROCESS_TIMEOUT=0 composer install --dev --no-suggest --no-interaction
- name: Install Guzzle
run: composer require guzzlehttp/guzzle:^6.3.0 ${{ matrix.dependencies-preference }} --no-progress;
COMPOSER_PROCESS_TIMEOUT=0 composer update --dev --no-interaction --with-all-dependencies ${{ matrix.dependencies-preference}}
- run: composer show

Expand Down
29 changes: 12 additions & 17 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.0.0 || ~8.1.0",
"php": "~8.1",
"ext-json": "*",
"ext-openssl": "*",
"ext-reflection": "*",
Expand All @@ -22,37 +22,32 @@
"league/period": "^4.12",
"php-http/client-common": "^2.0",
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.6.0",
"php-http/discovery": "^1.18",
"php-http/httplug": "^2.0",
"php-http/message": "^1.13",
"php-http/message-factory": "^1.0",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0",
"phpdocumentor/reflection-docblock": "^5.0",
"psr/http-message": "^1.0",
"symfony/options-resolver": "^4.0",
"symfony/property-access": "^4.4.9",
"symfony/property-info": "^4.0",
"symfony/serializer": "^4.4"
"symfony/options-resolver": "^5.4",
"symfony/property-access": "^6.2",
"symfony/property-info": "^6.2",
"symfony/serializer": "^6.2"
},
"require-dev": {
"dms/phpunit-arraysubset-asserts": "^0.4.0",
"friendsofphp/php-cs-fixer": "^2.19",
"fzaninotto/faker": "^1.7",
"guzzlehttp/psr7": "^1.0",
"guzzlehttp/psr7": "^2.5",
"league/flysystem": "^1.0",
"limedeck/phpunit-detailed-printer": "^6",
"monolog/monolog": "^1.23",
"php-http/guzzle6-adapter": "^2.0",
"php-http/guzzle7-adapter": "^1.0",
"php-http/mock-client": "^1.1.0",
"phpmetrics/phpmetrics": "^2.7",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6",
"sebastian/comparator": "^4.0.5",
"symfony/cache": "~3.4 || ~4.0",
"vimeo/psalm": "^3.18.2"
},
"conflict": {
"guzzlehttp/guzzle": "<6.1.0",
"guzzlehttp/psr7": "<1.4.1",
"phpdocumentor/type-resolver": "<0.2.1"
"symfony/cache": "~5.0",
"vimeo/psalm": "^5.12"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 7 additions & 2 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<!-- Added because of inherited/overridden Symfony functions. -->
<LessSpecificReturnStatement errorLevel="info" />
<!-- Disable errors caused by using class typehinting on variables and interfaces on setter's param types. -->
<TypeCoercion errorLevel="info" />
<ArgumentTypeCoercion errorLevel="info" />
<PropertyTypeCoercion errorLevel="info"/>

<!-- Disable errors caused by interfaces declaring a generic object/array return type and implementations using specific classes. -->
<InvalidReturnType errorLevel="info" />
<InvalidReturnStatement errorLevel="info" />
Expand All @@ -34,7 +36,7 @@
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />
<TypeDoesNotContainType errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
Expand All @@ -47,5 +49,8 @@
<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<!-- Disable error caused by deprecated interface-->
<DeprecatedInterface errorLevel="info" />
</issueHandlers>
</psalm>
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function getStartTime(): ?string
/**
* {@inheritdoc}
*/
public function setStartTime(string $startTime): void
public function setStartTime(string $startDate): void
{
$this->startTime = $startTime;
$this->startTime = $startDate;
}
}
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory
*/
public function normalize($object, $format = null, array $context = [])
{
$normalized = (array) parent::normalize($object, $format, $context);
$normalized = parent::normalize($object, $format, $context);

return (object) $normalized;
return $normalized;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Api/Management/Controller/AppCredentialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ public function overrideScopes(string $consumerKey, array $scopes): AppCredentia
/**
* {@inheritdoc}
*/
public function load(string $entityId): AppCredentialInterface
public function load(string $consumerKey): AppCredentialInterface
{
$response = $this->client->get($this->getEntityEndpointUri($entityId));
$response = $this->client->get($this->getEntityEndpointUri($consumerKey));

return $this->entitySerializer->deserialize(
(string) $response->getBody(),
Expand All @@ -181,9 +181,9 @@ public function load(string $entityId): AppCredentialInterface
/**
* {@inheritdoc}
*/
public function delete(string $entityId): AppCredentialInterface
public function delete(string $consumerKey): AppCredentialInterface
{
$response = $this->client->delete($this->getEntityEndpointUri($entityId));
$response = $this->client->delete($this->getEntityEndpointUri($consumerKey));

return $this->entitySerializer->deserialize(
(string) $response->getBody(),
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Management/Entity/ApiProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public function getProxies(): array
/**
* {@inheritdoc}
*/
public function setProxies(string ...$proxies): void
public function setProxies(string ...$proxy): void
{
$this->proxies = $proxies;
$this->proxies = $proxy;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function normalize($object, $format = null, array $context = [])
$normalized['developer'][] = (object) ['email' => $member, 'role' => $role];
}

return (object) $normalized;
//convert to ArrayObject as symfony normalizer throws error for std object.
//set ARRAY_AS_PROPS flag as we need entries to be accessed as properties.
return new \ArrayObject($normalized, \ArrayObject::ARRAY_AS_PROPS);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Api/Monetization/Builder/RatePlanRevisionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public static function buildRatePlanRevision(RatePlanInterface $ratePlan, DateTi
unset($normalized->id);
// Remove the end date inherited from the parent rate plan because
// it may overlap with the new start date.
unset($normalized->endDate);
if (isset($normalized->endDate)) {
unset($normalized->endDate);
}
// Create a new rate plan revision from the "copy" of parent rate plan.
// We have to disable the type enforcement because an empty "addresses"
// array is being passed to the organization which causes failures.
Expand Down
12 changes: 6 additions & 6 deletions src/Api/Monetization/Entity/OrganizationProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ public function getCurrencyCode(): ?string
/**
* {@inheritdoc}
*/
public function setCurrencyCode(string $currencyCode): void
public function setCurrencyCode(string $currency): void
{
$this->currencyCode = $currencyCode;
$this->currencyCode = $currency;
}

/**
Expand All @@ -216,9 +216,9 @@ public function hasBillingAdjustment(): bool
/**
* {@inheritdoc}
*/
public function setBillingAdjustment(bool $billingAdjustment): void
public function setBillingAdjustment(bool $hasBillingAdjustment): void
{
$this->billingAdjustment = $billingAdjustment;
$this->billingAdjustment = $hasBillingAdjustment;
}

/**
Expand All @@ -240,9 +240,9 @@ public function hasSeparateInvoiceForProduct(): bool
/**
* {@inheritdoc}
*/
public function setSeparateInvoiceForProduct(bool $separateInvoiceForProduct): void
public function setSeparateInvoiceForProduct(bool $hasSeparateInvoiceForProduct): void
{
$this->separateInvoiceForProduct = $separateInvoiceForProduct;
$this->separateInvoiceForProduct = $hasSeparateInvoiceForProduct;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Monetization/NameConverter/NameConverterBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class NameConverterBase implements NameConverterInterface
/**
* {@inheritdoc}
*/
public function normalize($propertyName)
public function normalize($propertyName): string
{
if ($externalPropertyName = array_search($propertyName, $this->getExternalToLocalMapping())) {
return $externalPropertyName;
Expand All @@ -37,7 +37,7 @@ public function normalize($propertyName)
/**
* {@inheritdoc}
*/
public function denormalize($propertyName)
public function denormalize($propertyName): string
{
if (array_key_exists($propertyName, $this->getExternalToLocalMapping())) {
return $this->getExternalToLocalMapping()[$propertyName];
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Monetization/Normalizer/ApiPackageNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public function normalize($object, $format = null, array $context = [])
// Do not send redundant API product information to Apigee Edge, the
// id of a referenced API product is enough.
foreach ($normalized['product'] as $id => $data) {
$normalized['product'][$id] = (object) ['id' => $data->id];
$normalized['product'][$id] = (object) ['id' => $data['id']];
}

return (object) $normalized;
return $this->convertToArrayObject($normalized);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Monetization/Normalizer/EntityNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function normalize($object, $format = null, array $context = [])
}
}

return (object) $normalized;
return $this->convertToArrayObject($normalized);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Api/Monetization/Normalizer/ReportCriteriaNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@ public function normalize($object, $format = null, array $context = [])
// According to the API documentation it is always UTC.
// https://docs.apigee.com/api-platform/monetization/create-reports#createreportdefapi
$this->fixTimeZoneOnNormalization($object, $normalized, new \DateTimeZone('UTC'));

$arr_empty = [];
// Just in case, do not send empty array values either to this API.
foreach ($normalized as $property => $value) {
if (is_array($value) && empty($value)) {
unset($normalized->{$property});
//Get all the array which is empty
$arr_empty[] = $property;
}
}

foreach ($arr_empty as $val) {
unset($normalized->{$val});
}

return $normalized;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ public static function getEntityTypeSpecificDefaultNormalizers(): array
/**
* {@inheritdoc}
*/
public function deserialize($data, $type, $format, array $context = [])
public function deserialize($data, $type, $format, array $context = []): mixed
{
$context['json_decode_associative'] = false;
// Because of the decorator pattern in the EntitySerializer we have to
// repeat this in here as well.
if ($this->supportsDecoding($format)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
use Http\Client\Common\Plugin\HistoryPlugin;
use Http\Client\Common\Plugin\RetryPlugin;
use Http\Client\Exception;
use Http\Client\HttpClient;
use Http\Discovery\MessageFactoryDiscovery;
use Http\Discovery\UriFactoryDiscovery;
use Http\Message\Authentication;
use Http\Message\UriFactory;
use Psr\Http\Client\ClientInterface as HttpClient;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
namespace Apigee\Edge;

use Apigee\Edge\HttpClient\Utility\JournalInterface;
use Http\Client\HttpClient;
use Http\Message\UriFactory;
use Psr\Http\Client\ClientInterface as HttpClient;
use Psr\Http\Message\ResponseInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PaginationHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private function listEntitiesWithCps(PagerInterface $pager = null, array $query_
// Apigee Edge response always starts with the requested entity
// (startKey).
array_shift($tmp);
$tmpEntities = $this->responseArrayToArrayOfEntities($tmp, $key_provider);
$tmpEntities = $this->responseArrayToArrayOfEntities((array) $tmp, $key_provider);

if (count($tmpEntities) > 0) {
// The returned entity array is keyed by entity id which
Expand Down
5 changes: 4 additions & 1 deletion src/Denormalizer/EdgeDateDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public function denormalize($data, $type, $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), $type, $format, $context);
//convert data in string format for denormalizer.
$data = (string) intval($data / 1000);

return $this->normalizer->denormalize($data, $type, $format, $context);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Denormalizer/ObjectDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
$propertyTypeExtractor = new PropertyInfoExtractor(
[
$reflectionExtractor,
$phpDocExtractor,
],
// Type extractors
[
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ApiException extends RuntimeException implements Exception
/**
* {@inheritdoc}
*/
public function __toString()
public function __toString(): string
{
// This is just a wrapper around the base class and if it contains a reference to the previous
// exception we should display that as a string.
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ApiRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function __toString()
public function __toString(): string
{
$output = [
get_called_class() . PHP_EOL,
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ApiResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function __toString()
public function __toString(): string
{
$output = [
get_called_class() . PHP_EOL,
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CpsNotEnabledException.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(string $organization, $code = 0, Throwable $previous
$this->organization = $organization;
}

public function __toString()
public function __toString(): string
{
return "Core Persistence Services is not enabled on {$this->organization} organization.";
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidJsonException.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function __toString()
public function __toString(): string
{
return sprintf("%s\n%s", $this->jsonErrorMessage, parent::__toString());
}
Expand Down
Loading

0 comments on commit 5a6fed1

Please sign in to comment.