-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.5][PropertyAccess] Fixed getValue() when accessing non-existing indices of ArrayAccess implementations #10946
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
Conversation
throw new NoSuchIndexException(sprintf( | ||
'Cannot read property "%s". Available properties are "%s"', | ||
$property, | ||
print_r(array_keys($objectOrArray), true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you sould keep it on 1 line, like previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@webmozart why use print_r? It prints way more than the available keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoudln't this one be closed in favor of #10947 ? |
@stof No, one of the PRs is for 2.4, the other for master. Applying the 2.4 version to master is non-trivial, which is why I created separate PRs. |
…existing indices of ArrayAccess implementations (webmozart) This PR was merged into the 2.4 branch. Discussion ---------- [2.4][PropertyAccess] Fixed getValue() when accessing non-existing indices of ArrayAccess implementations | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR backports two test refactoring commits from the master branch. The third commit is basically the same as #10946. Commits ------- 5b5a6b6 [PropertyAccess] Fixed getValue() when accessing non-existing indices of ArrayAccess implementations 91ee821 [PropertyAccess] Refactored PropertyAccessorCollectionTest 5614303 [PropertyAccess] Refactored PropertyAccessorTest
… of ArrayAccess implementations
Updated, removed the "return null" statement. |
…existing indices of ArrayAccess implementations (webmozart) This PR was merged into the 2.5-dev branch. Discussion ---------- [2.5][PropertyAccess] Fixed getValue() when accessing non-existing indices of ArrayAccess implementations | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Previously, when the following code was executed: ```php $object = new ImplOfArrayAccess(); $propertyAccessor->setValue($object, '[index]', 'Value'); ``` and that index did not exist, a fatal error would be generated because `array_keys()` was executed on `$object`. This error is fixed now. Commits ------- fef698e [PropertyAccess] Fixed getValue() when accessing non-existing indices of ArrayAccess implementations
Previously, when the following code was executed:
and that index did not exist, a fatal error would be generated because
array_keys()
was executed on$object
. This error is fixed now.