Skip to content

Commit

Permalink
Fixes for ParamNameMismatch error on composer analyze
Browse files Browse the repository at this point in the history
  • Loading branch information
kedarkhaire committed Jan 17, 2025
1 parent 5644ce4 commit 129cb72
Show file tree
Hide file tree
Showing 36 changed files with 120 additions and 120 deletions.
6 changes: 3 additions & 3 deletions src/Api/ApigeeX/Normalizer/AcceptedRatePlanNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class AcceptedRatePlanNormalizer extends EntityNormalizer
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null

Check failure on line 35 in src/Api/ApigeeX/Normalizer/AcceptedRatePlanNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.1, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AcceptedRatePlanNormalizer.php:35:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AcceptedRatePlanNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 35 in src/Api/ApigeeX/Normalizer/AcceptedRatePlanNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.2, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AcceptedRatePlanNormalizer.php:35:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AcceptedRatePlanNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 35 in src/Api/ApigeeX/Normalizer/AcceptedRatePlanNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.3, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AcceptedRatePlanNormalizer.php:35:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AcceptedRatePlanNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)
{
/** @var AcceptedRatePlanInterface $object */
/** @var AcceptedRatePlanInterface $data */
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);

return $normalized;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null

Check failure on line 51 in src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.1, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php:51:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\ApiProductNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 51 in src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.2, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php:51:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\ApiProductNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 51 in src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.3, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/ApiProductNormalizer.php:51:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\ApiProductNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)
{
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);

return $normalized;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Api/ApigeeX/Normalizer/AppGroupMembershipNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class AppGroupMembershipNormalizer implements NormalizerInterface
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null

Check failure on line 32 in src/Api/ApigeeX/Normalizer/AppGroupMembershipNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.1, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AppGroupMembershipNormalizer.php:32:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AppGroupMembershipNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 32 in src/Api/ApigeeX/Normalizer/AppGroupMembershipNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.2, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AppGroupMembershipNormalizer.php:32:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AppGroupMembershipNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 32 in src/Api/ApigeeX/Normalizer/AppGroupMembershipNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.3, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AppGroupMembershipNormalizer.php:32:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AppGroupMembershipNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)
{
$normalized = [];

/** @var AppGroupMembership $object */
foreach ($object->getMembers() as $member => $role) {
/** @var AppGroupMembership $data */
foreach ($data->getMembers() as $member => $role) {
$normalized[] = ['developer' => $member, 'roles' => $role];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Normalizer/AppNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function supportsNormalization($data, $format = null, array $context = []
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null

Check failure on line 44 in src/Api/ApigeeX/Normalizer/AppNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.1, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AppNormalizer.php:44:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AppNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 44 in src/Api/ApigeeX/Normalizer/AppNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.2, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AppNormalizer.php:44:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AppNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 44 in src/Api/ApigeeX/Normalizer/AppNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.3, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/AppNormalizer.php:44:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\AppNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);
// Remove properties that saved to attributes on apps.
unset($normalized->displayName);
unset($normalized->description);
Expand Down
6 changes: 3 additions & 3 deletions src/Api/ApigeeX/Normalizer/BillingTypeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class BillingTypeNormalizer extends EntityNormalizer
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null

Check failure on line 32 in src/Api/ApigeeX/Normalizer/BillingTypeNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.1, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/BillingTypeNormalizer.php:32:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\BillingTypeNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 32 in src/Api/ApigeeX/Normalizer/BillingTypeNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.2, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/BillingTypeNormalizer.php:32:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\BillingTypeNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 32 in src/Api/ApigeeX/Normalizer/BillingTypeNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.3, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/BillingTypeNormalizer.php:32:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\BillingTypeNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)
{
/** @var BillingTypeInterface $object */
/** @var BillingTypeInterface $data */
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);

return $normalized;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null

Check failure on line 55 in src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.1, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php:55:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\RatePlanNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 55 in src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.2, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php:55:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\RatePlanNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 55 in src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.3, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/RatePlanNormalizer.php:55:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\RatePlanNormalizer::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);

// Fix the start- and end date of the rate plan if the organization's
// timezone is different from the default PHP timezone.
/** @var RatePlanInterface $object */
if (null === $object->getPackage()) {
throw new UninitializedPropertyException($object, 'package', 'Apigee\Edge\Api\ApigeeX\Entity\ApiProductInterface');
/** @var RatePlanInterface $data */
if (null === $data->getPackage()) {
throw new UninitializedPropertyException($data, 'package', 'Apigee\Edge\Api\ApigeeX\Entity\ApiProductInterface');
}

return $normalized;
Expand Down
6 changes: 3 additions & 3 deletions src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public function __construct(array $normalizers = [])
* @psalm-suppress InvalidNullableReturnType - There are going to be at
* least one normalizer always that can normalize data here.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null

Check failure on line 59 in src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.1, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php:59:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\RatePlanNormalizerFactory::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 59 in src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.2, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php:59:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\RatePlanNormalizerFactory::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)

Check failure on line 59 in src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php

View workflow job for this annotation

GitHub Actions / test_and_lint (8.3, --prefer-lowest)

ParamNameMismatch

src/Api/ApigeeX/Normalizer/RatePlanNormalizerFactory.php:59:31: ParamNameMismatch: Argument 1 of Apigee\Edge\Api\ApigeeX\Normalizer\RatePlanNormalizerFactory::normalize has wrong name $data, expecting $object as defined by Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize (see https://psalm.dev/230)
{
foreach ($this->normalizers as $normalizer) {
// Return the result from the first denormalizer that can
// denormalize this.
if ($normalizer->supportsNormalization($object, $format)) {
return $normalizer->normalize($object, $format, $context);
if ($normalizer->supportsNormalization($data, $format)) {
return $normalizer->normalize($data, $format, $context);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Api/ApigeeX/Normalizer/RatePlanRateNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class RatePlanRateNormalizer extends ObjectNormalizer
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
if ($object instanceof RatePlanRateRevShare) {
$normalized = parent::normalize($data, $format, $context);
if ($data instanceof RatePlanRateRevShare) {
$normalized->type = RatePlanRate::TYPE_REVSHARE;
} else {
$normalized->type = RatePlanRate::TYPE_RATECARD;
Expand Down
4 changes: 2 additions & 2 deletions src/Api/ApigeeX/Normalizer/StandardRatePlanNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class StandardRatePlanNormalizer extends RatePlanNormalizer
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);
$normalized->type = RatePlanInterface::TYPE_STANDARD;

return $normalized;
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Management/Normalizer/AppCredentialNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function supportsNormalization($data, $format = null, array $context = []
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);
// Taking special care of null as a credential's expiresAt property value.
// @see \Apigee\Edge\Api\Management\Entity\AppCredential::$expiresAt
if (!isset($normalized->expiresAt)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Management/Normalizer/AppNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function supportsNormalization($data, $format = null, array $context = []
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);
// Remove properties that saved to attributes on apps.
unset($normalized->displayName);
unset($normalized->description);
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Management/Normalizer/CompanyMembershipNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class CompanyMembershipNormalizer implements NormalizerInterface
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
$normalized = [
'developer' => [],
];
/** @var CompanyMembership $object */
foreach ($object->getMembers() as $member => $role) {
/** @var CompanyMembership $data */
foreach ($data->getMembers() as $member => $role) {
$normalized['developer'][] = (object) ['email' => $member, 'role' => $role];
}

Expand Down
36 changes: 18 additions & 18 deletions src/Api/Management/Query/StatsQueryNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,41 @@ public function __construct()
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var StatsQueryInterface $object */
/** @var StatsQueryInterface $data */
// Transform the object to JSON and back to an array to keep boolean values as boolean.
$json = $this->serializer->serialize($object, 'json', [AbstractNormalizer::IGNORED_ATTRIBUTES => ['timeRange']]);
$data = $this->serializer->decode($json, 'json');
$json = $this->serializer->serialize($data, 'json', [AbstractNormalizer::IGNORED_ATTRIBUTES => ['timeRange']]);
$decodedData = $this->serializer->decode($json, 'json');
// Replace metrics with the required query parameter name and value.
$data['select'] = implode(',', $data['metrics']);
unset($data['metrics']);
$decodedData['select'] = implode(',', $decodedData['metrics']);
unset($decodedData['metrics']);
// Transform timeRange to the required format and time zone.
$utc = new DateTimeZone('UTC');
$data['timeRange'] = $object->getTimeRange()->startDate->setTimezone($utc)->format(self::DATE_FORMAT) . '~' .
$object->getTimeRange()->endDate->setTimezone($utc)->format(self::DATE_FORMAT);
$decodedData['timeRange'] = $data->getTimeRange()->startDate->setTimezone($utc)->format(self::DATE_FORMAT) . '~' .
$data->getTimeRange()->endDate->setTimezone($utc)->format(self::DATE_FORMAT);
// Remove null values.
$data = array_filter($data, function ($value) {
$decodedData = array_filter($decodedData, function ($value) {
return !is_null($value);
});
// Fix boolean values.
foreach ($data as $key => $value) {
foreach ($decodedData as $key => $value) {
if (is_bool($value)) {
$data[$key] = $value ? 'true' : 'false';
$decodedData[$key] = $value ? 'true' : 'false';
}
}
// Following parameter names should be passed in lowercase format.
// (We solve this problem in place instead of creating a name converter.)
if (isset($data['sortBy'])) {
$data['sortby'] = $data['sortBy'];
unset($data['sortBy']);
if (isset($decodedData['sortBy'])) {
$decodedData['sortby'] = $decodedData['sortBy'];
unset($decodedData['sortBy']);
}
if (isset($data['topK'])) {
$data['topk'] = $data['topK'];
unset($data['topK']);
if (isset($decodedData['topK'])) {
$decodedData['topk'] = $decodedData['topK'];
unset($decodedData['topK']);
}

return $data;
return $decodedData;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class AcceptedRatePlanNormalizer extends EntityNormalizer
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var AcceptedRatePlanInterface $object */
/** @var AcceptedRatePlanInterface $data */
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$this->fixTimeZoneOnNormalization($object, $normalized, $object->getRatePlan()->getPackage()->getOrganization()->getTimezone());
$normalized = parent::normalize($data, $format, $context);
$this->fixTimeZoneOnNormalization($data, $normalized, $data->getRatePlan()->getPackage()->getOrganization()->getTimezone());

return $normalized;
}
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 @@ -47,9 +47,9 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
$normalized = (array) parent::normalize($object, $format, $context);
$normalized = (array) parent::normalize($data, $format, $context);

// Do not send redundant API product information to Apigee Edge, the
// id of a referenced API product is enough.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);
$normalized->developer->isCompany = true;

return $normalized;
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Monetization/Normalizer/DateTimeZoneNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class DateTimeZoneNormalizer implements NormalizerInterface
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
return $object->getName();
return $data->getName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class DeveloperCategoryRatePlanNormalizer extends RatePlanNormalizer
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);
$normalized->type = RatePlanInterface::TYPE_DEVELOPER_CATEGORY;

return $normalized;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class DeveloperPaymentTransactionNormalizer extends PaymentTransactionNormalizer
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);
$normalized->developer->isCompany = false;

return $normalized;
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Monetization/Normalizer/EntityNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory
* @psalm-suppress InvalidReturnType stdClass is also an object.
* @psalm-suppress InvalidPropertyFetch.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
$normalized = (array) parent::normalize($object, $format, $context);
$normalized = (array) parent::normalize($data, $format, $context);

$entityReferenceProperties = $this->getNestedObjectProperties($object);
$entityReferenceProperties = $this->getNestedObjectProperties($data);

if (!empty($entityReferenceProperties)) {
foreach ($entityReferenceProperties as $entityProperty => $normalizedProperty) {
Expand Down
8 changes: 4 additions & 4 deletions src/Api/Monetization/Normalizer/LegalEntityNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory
* @psalm-suppress InvalidReturnType Returning an object here is required
* for creating a valid Apigee Edge request.
*/
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
public function normalize($data, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
/** @var object $normalized */
$normalized = parent::normalize($object, $format, $context);
$normalized = parent::normalize($data, $format, $context);

if ($object instanceof DeveloperInterface) {
if ($data instanceof DeveloperInterface) {
$normalized->isCompany = false;
} elseif ($object instanceof CompanyInterface) {
} elseif ($data instanceof CompanyInterface) {
$normalized->isCompany = true;
}

Expand Down
Loading

0 comments on commit 129cb72

Please sign in to comment.