-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccess] [Bug] isReadable return true for an array index even if not set. #18969
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
Comments
If the bug is confirmed, I have a ready patch. |
When you call |
@sstok, for $array it gives NULL, for $object it throws an exception saying that no getter/isser/hasser found. |
OK, so it's directly confirmable. Hmm.. |
@sstok It seems that tests expect this behavior. That sounds strange to me, seems that for you too. |
After investigation, it's the expected behavior. The second argument of |
May I ask how this was decided? I find it a bit confusing that the exceptions differ from objects and arrays. |
There was nothing to change as this is the expected behaviour (accessing non-existing array keys just returns |
It can be useful with multidimensional array.
Because
|
Description
Let's take the following empty array:
And the following empty class:
Check if an undefined property is readable from the class:
Same check on the array:
As
$array['foo']
doesn't exist, I assume it's a bug, right?Possible solution
In
PropertyAccessor::readIndex
, in the following condition:Add an
else
statement like:Sort as
isReadable
properly returnsfalse
on unreadable index.The text was updated successfully, but these errors were encountered: