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

Incorrect instance of ReflectionProperty created for public typed properties #102

Closed
joaojacome opened this issue Mar 31, 2020 · 0 comments · Fixed by #103
Closed

Incorrect instance of ReflectionProperty created for public typed properties #102

joaojacome opened this issue Mar 31, 2020 · 0 comments · Fixed by #103

Comments

@joaojacome
Copy link
Contributor

joaojacome commented Mar 31, 2020

Related to: doctrine/orm#7999

The issue was fixed for private properties, but public properties are still falling in the first condition, and being set as null when deleting an entity.

joaojacome added a commit to joaojacome/persistence that referenced this issue Jun 15, 2021
… untyped ones

Due to how PHP 7.4 works, if you have a typed public property that does not support null values, whenever Doctrine tries to delete an entity with such properties,
it raises a TypeError. This happens because of the new default "uninitialized" value for typed properties. In previous versions of PHP, the default uninitialized value was null.

My fist idea was to just reverse the order, and while that worked, it introduced a BC break.
Now, as per @guilliamxavier suggestion, I've moved the methods from the class TypedNoDefaultRuntimePublicReflectionProperty to
a trait, then I proceeded to create a new class extending RuntimePublicReflectionProperty, that uses the new trait.

With this, whenever Doctrine tries to access a public property with no default value set, it will properly unset the property instead of setting it as null getting a PHP TypeError.
Reordered property type resolution so typed properties get resolved first, added tests for covering multiple scenarios

Fixes doctrine#102
Fixes doctrine/orm#7999

Co-authored-by: Guilliam Xavier <guilliamxavier@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant