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

Warning: Illegal offset type in isset or empty in \vendor\phpcollection\phpcollection\src\PhpCollection\AbstractMap.php line 134 #19

Open
JarJak opened this issue Jan 16, 2015 · 6 comments

Comments

@JarJak
Copy link

JarJak commented Jan 16, 2015

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());
@JarJak
Copy link
Author

JarJak commented Feb 10, 2015

hello?

@judgej
Copy link

judgej commented Jul 2, 2015

@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.

@doofer
Copy link

doofer commented Jan 12, 2017

For future reference, your function arguments are not ok for deserialize:
You need the jsonText, objectClassName, 'json' or 'xml' (type), DeserializationContext

@JarJak
Copy link
Author

JarJak commented Sep 11, 2018

@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]);
    }

@discordier
Copy link

@JarJak Which could be wrong for the object case in some cases, as we can provide a __toString().

@JarJak
Copy link
Author

JarJak commented May 28, 2021

@discordier so:

    public function containsKey($key): bool
    {
        if (is_array($key) || (is_object($key) && !method_exists($key, '__toString')) ) {
            //throw...
        }
        return isset($this->elements[$key]);
    }

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

4 participants