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

[5.x] Fix emptiness check on Value properties #11402

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from

Conversation

godismyjudge95
Copy link
Contributor

Tricky behavior ran into by Erin - https://discord.com/channels/489818810157891584/489830535565148169/1333967156861468694

This won't directly solve what he was dealing with (as he had a custom class), but it will fix it for future devs checking if a property on a Value is empty.

Currently, if you have an object wrapped by a Value and then check the emptiness of a property on that object it returns true no matter what:

image

This is due to https://www.php.net/manual/en/function.empty.php#99959

Calling non existing object property, empty($object->prop), will trigger __isset(), the same way as isset($object->prop) does, but there is one difference. If __isset() returns TRUE, another call to __get() will be made and actual return value will be result of empty() and result of __get().

In other words, since Value doesn't have the __isset() method on it every single empty() check on a property inside of it will fail.

This PR fixes that and adds a test :)

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.

1 participant