Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api/Normalizer/JaneObjectNormalizer.php is out of sync with Symfony\Component\Serializer\Normalizer\DenormalizerInterface #31

Open
bickart opened this issue Jun 27, 2024 · 10 comments

Comments

@bickart
Copy link

bickart commented Jun 27, 2024

Multiple functions within JaneObjectNormalizer are out of sync.

denormalize() as well as denormalize() are defined in multiple classes within this php file. All functions need to be updated to work correctly.

@bickart
Copy link
Author

bickart commented Jun 27, 2024

Error Messages

PHP Fatal error: Declaration of ShipStream\Ups\Api\Normalizer\JaneObjectNormalizer::denormalize($data, $type, $format = null, array $context = []) must be compatible with Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed in /Users/jeff.bickart/Sites/claimspay4/App/custom/vendor/shipstream/ups-rest-php-sdk/src/Api/Normalizer/JaneObjectNormalizer.php on line 87

PHP Fatal error: Declaration of ShipStream\Ups\Api\Normalizer\JaneObjectNormalizer::normalize($object, $format = null, array $context = []) must be compatible with Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize(mixed $object, ?string $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null in /var/www/html/claimspay4_onebase_uat/custom/vendor/shipstream/ups-rest-php-sdk/src/Api/Normalizer/JaneObjectNormalizer.php on line 79

@bickart
Copy link
Author

bickart commented Jun 27, 2024

The generated code appears to generate the correct functions if you have a newer version of "symfony/http-kernel" .

Our version is "symfony/http-kernel" : "v5.4.25",

@szabobgabor
Copy link

szabobgabor commented Jun 28, 2024

The main problem is that implementation is using the http kernel to determine whether typehint should be supported or not..

if (!class_exists(Kernel::class) or (Kernel::MAJOR_VERSION >= 7 or Kernel::MAJOR_VERSION === 6 and Kernel::MINOR_VERSION === 4)) {

shouldn't it be better to use PHP_(MAJOR|MINOR)_VERSION constants in the implementation?

@elidrissidev
Copy link
Collaborator

elidrissidev commented Jun 28, 2024

@bickart Which version of PHP and the SDK are you using?

shouldn't it be better to use PHP_(MAJOR|MINOR)_VERSION constants in the implementation?

@szabobgabor That is because the symfony/serializer interfaces have different signatures in different versions, so including only one implementation with types will break it for older versions. This same issue was already reported but is yet to receive any reply: janephp/janephp#785

@bickart
Copy link
Author

bickart commented Jun 28, 2024

@elidrissidev at the current moment our server is running PHP Version 8.2.x. Specifically PHP Version 8.2.12. We will be migrating to PHP 8.3.x in the next quarter or so.

"shipstream/ups-rest-php-sdk": 2.3.1

@elidrissidev
Copy link
Collaborator

elidrissidev commented Jul 1, 2024

@bickart I think the solution here would be to add symfony/serializer to your composer.json and lock it to ^5, that way it matches the kernel version. Let me know if that fixes it.

@bickart
Copy link
Author

bickart commented Jul 1, 2024

We can not change the version of http-kernel. It's used by another library in our application

@elidrissidev
Copy link
Collaborator

We can not change the version of http-kernel

Not http-kernel, symfony/serializer is the one you need to downgrade to v5 as by default it will use any compatible version up to v7 which causes the error.

@elidrissidev
Copy link
Collaborator

@bickart Did my above comment solve this issue for you?

@bickart
Copy link
Author

bickart commented Aug 30, 2024

@elidrissidev I will have to discuss this with our developer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants