php-collection
php-collection copied to clipboard
Warning: Illegal offset type in isset or empty in \vendor\phpcollection\phpcollection\src\PhpCollection\AbstractMap.php line 134
Warning: Illegal offset type in isset or empty in \vendor\phpcollection\phpcollection\src\PhpCollection\AbstractMap.php line 134
when trying do deserialize a prieviously serialized object with jms-serializer:
$json = $this->serializer->serialize($object, 'json', SerializationContext::create()->enableMaxDepthChecks());
$this->serializer->deserialize($json, 'json', SerializationContext::create()->enableMaxDepthChecks());
hello?
@JarJak I'm guessing jms-serializer is out of scope for this package. If you need this fixed, then you are going to have to dig into it yourself and report back with more details.
For future reference, your function arguments are not ok for deserialize: You need the jsonText, objectClassName, 'json' or 'xml' (type), DeserializationContext
@doofer you are probably right. Anyway it would be nice to check key type before using isset(). Like:
public function containsKey($key)
{
if (is_array($key) || is_object($key)) {
//throw...
}
return isset($this->elements[$key]);
}
@JarJak Which could be wrong for the object case in some cases, as we can provide a __toString().
@discordier so:
public function containsKey($key): bool
{
if (is_array($key) || (is_object($key) && !method_exists($key, '__toString')) ) {
//throw...
}
return isset($this->elements[$key]);
}