Skip to content

Updated: Use static when calling deserializationCallback() #12

Open
karpilin wants to merge 2 commits intomatthiasnoback:masterfrom
karpilin:use-static-when-deserializing
Open

Updated: Use static when calling deserializationCallback() #12
karpilin wants to merge 2 commits intomatthiasnoback:masterfrom
karpilin:use-static-when-deserializing

Conversation

@karpilin
Copy link
Copy Markdown
Contributor

@karpilin karpilin commented Feb 3, 2020

An old PR from @MarkRedeman has been rebased on latest master.

@matthiasnoback This is both a proof of a problem and an actual fix. I'd very much like to see this merged.

MarkRedeman and others added 2 commits February 3, 2020 21:32
This enables us to serialize objects that inherit from an parent using
the Serializable trait.
This does not work when the parent or child class have a private
property that needs to be serialized, as can be seen from the provided
tests.
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling fd5316f on karpilin:use-static-when-deserializing into 31497c1 on matthiasnoback:master.

@matthiasnoback
Copy link
Copy Markdown
Owner

Thanks for bringing this up. However, as I stated in the original PR, I wonder if you couldn't just use the trait in the child classes instead of the parent class. The result of using the trait in the parent class is predictable according to the properties of the PHP language, but will surely be a big surprise to many people. Also, there's no way to warn a user about the fact that private properties will be skipped. The warning is in the test, but not in production code, and when a user encounters this issue, they will probably spend quite some time debugging it.

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

Successfully merging this pull request may close these issues.

4 participants