[PropertyAccess] Fix TypeError discard#23333
Merged
fabpot merged 1 commit intosymfony:2.7from Jul 3, 2017
Merged
Conversation
beeab0d to
e0c5040
Compare
fabpot
approved these changes
Jul 3, 2017
Member
|
Thank you @dunglas. |
fabpot
added a commit
that referenced
this pull request
Jul 3, 2017
This PR was merged into the 2.7 branch.
Discussion
----------
[PropertyAccess] Fix TypeError discard
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? |no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Given the following code:
```php
class Bar
{
private $foos = [];
public function getFoos(): array
{
return 'It doesn\'t respect the return type';
}
public function addFoo(Foo $foo)
{
// ...
}
public function removeFoo(Foo $dateTime)
{
// ...
}
}
$object = new Bar();
$this->propertyAccessor->setValue($object, 'foos', array(new \DateTime()));
```
The `PropertyAccessor` will crash (`[Symfony\Component\Debug\Exception\ContextErrorException] Notice: Undefined offset: 0`) instead of displaying the (valid) PHP error.
This PR fixes the issue.
Commits
-------
e0c5040 [PropertyAccess] Fix TypeError discard
This was referenced Jul 3, 2017
Merged
Merged
7FB9
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Given the following code:
The
PropertyAccessorwill crash ([Symfony\Component\Debug\Exception\ContextErrorException] Notice: Undefined offset: 0) instead of displaying the (valid) PHP error.This PR fixes the issue.