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

Serialization of private parent variables #16

Open
gnat42 opened this issue Nov 16, 2016 · 0 comments
Open

Serialization of private parent variables #16

gnat42 opened this issue Nov 16, 2016 · 0 comments

Comments

@gnat42
Copy link

gnat42 commented Nov 16, 2016

So recently I've spent a few hours trying to figure out why I was having issues unserializing data that was serialized properly. It took awhile to figure it out. Here's an example.

``
class AbstractCommand
{
private $someVar;
public function getSomeVar(){ return $this->someVar; }
}

class ChildCommand extends AbstractCommand
{
}
``

If you serialize ChildCommand you get
{"@type":"ChildCommand","someVar":{"@scalar":"integer","@value":19}}

but if you unserialize it, you get a ChildCommand object with a null someVar. The issue is that then on line 405 of your Serializer class, you get an exception because that var doesn't exist. Because the variable is private to AbstractCommand. So I'm not sure how to solve this, however it took hours to track down what's going on. So either the situation needs to be detected, or some other type of solution that I'm not aware of.

I don't know why it can get the variable but not set it.

If you need a PR of a failing test case I can probably do that as well.

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

1 participant