schmittjoh / serializer

Library for (de-)serializing data of any complexity (supports JSON, and XML)
http://jmsyst.com/libs/serializer
MIT License
2.32k stars 589 forks source link

Type Error in XmlDeserializationVisitor.php when switching to PHP 8 #1479

Closed masterheavy closed 1 year ago

masterheavy commented 1 year ago

Hey Johannes,

we recently updated to PHP 8 and now we are getting a TYPE ERROR in XmlDeserializationVisitor.php

TypeError count(): Argument #1 ($value) must be of type Countable|array, null given at vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php:179 175▕ } else { 176▕ $nodes = $data->xpath($entryName); 177▕ } 178▕ ➜ 179▕ if (!\count($nodes)) { 180▕ if (null === $this->result) { 181▕ return $this->result = array(); 182▕ } 183▕ [2m+9 vendor frames [22m 10 afterbuy-sdk/src/Ns/Afterbuy/Client/Request.php:383 JMS\Serializer\Serializer::deserialize() 11 afterbuy-sdk/src/Ns/Afterbuy/Client/Request.php:265 Ns\Afterbuy\Client\Request::serializeAndSubmitRequest()

everything worked with php 7

I know that the count() function was way less restricted in former PHP versions but now we have to use 8 and I am stuck...

ohh and btw. in the composer it sais our installed serializer is 1.1 so may be an update can fix this, but I am not sure - eventually it's something completely different...

someone can help or guide ?

scyzoryck commented 1 year ago

Hi @masterheavy! Serializer in version 1.1 is no longer supported for 3 years. Please migrate to version 3.x. For migration see: https://github.com/schmittjoh/serializer/blob/master/UPGRADING.md

masterheavy commented 1 year ago

Thx @scyzoryck but I am not sure if we can do this so easily - because it is part of the afterbuy sdk - https://github.com/next-sentence/afterbuy-sdk and i think the afterbuy git needs to be updated....

but i am not sure - the only thing I really know is - if the update fails or give more errors we are skrewed so it would be good to know if this error on the datastream is fixed in later versions

scyzoryck commented 1 year ago

Yes, it is fixed in new versions of serializer. I would suggest you to contribute the the SDK to update serializer versions there if needed. :) Closing the issue then.