From 39d00d42e0c2365ca6e7e28a85866d91fdf91dca Mon Sep 17 00:00:00 2001 From: divyajose Date: Tue, 5 Dec 2023 14:40:37 +0530 Subject: [PATCH 1/2] Fix for InvalidPropertyFetch error --- src/Api/Monetization/Normalizer/EntityNormalizer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Api/Monetization/Normalizer/EntityNormalizer.php b/src/Api/Monetization/Normalizer/EntityNormalizer.php index f3124a9b..ae76292b 100644 --- a/src/Api/Monetization/Normalizer/EntityNormalizer.php +++ b/src/Api/Monetization/Normalizer/EntityNormalizer.php @@ -60,6 +60,7 @@ public function __construct(?ClassMetadataFactoryInterface $classMetadataFactory * {@inheritdoc} * * @psalm-suppress InvalidReturnType stdClass is also an object. + * @psalm-suppress InvalidPropertyFetch. */ public function normalize($object, $format = null, array $context = []) { From 8516b89f72a1e40760484b31af4f8c66a449a075 Mon Sep 17 00:00:00 2001 From: divyajose Date: Tue, 5 Dec 2023 15:06:50 +0530 Subject: [PATCH 2/2] phpcs fix --- .php-cs-fixer.dist.php | 1 + src/Api/Monetization/Normalizer/EntityNormalizer.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 224654df..e39b5d80 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -39,6 +39,7 @@ // Disabled because multiple lines allow code clarity. 'single_line_throw' => false, 'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true], + 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true] ]) ->setFinder($finder); diff --git a/src/Api/Monetization/Normalizer/EntityNormalizer.php b/src/Api/Monetization/Normalizer/EntityNormalizer.php index ae76292b..d90bc7ed 100644 --- a/src/Api/Monetization/Normalizer/EntityNormalizer.php +++ b/src/Api/Monetization/Normalizer/EntityNormalizer.php @@ -20,6 +20,7 @@ use Apigee\Edge\Api\Monetization\Structure\NestedObjectReferenceInterface; use Apigee\Edge\Normalizer\ObjectNormalizer; +use ReflectionObject; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; @@ -124,7 +125,7 @@ public function normalize($object, $format = null, array $context = []) protected function getNestedObjectProperties($object): array { $entityReferenceProperties = []; - $ro = new \ReflectionObject($object); + $ro = new ReflectionObject($object); foreach ($ro->getProperties() as $property) { $property->setAccessible(true); $value = $property->getValue($object);