48f05ecad2
This PR was squashed before being merged into the 3.1-dev branch (closes #17738).
Discussion
----------
[PropertyAccess] Throw an InvalidArgumentException when the type do not match
| Q | A
| ------------- | ---
| Bug fix? | no (?)
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Currently, when the Property Access Component call a setter with a value not matching its typehint, a `\TypeError` is thrown with PHP 7 and a `PHP Catchable fatal error` with PHP 5.
This PR make the component returning an `InvalidArgumentException` with both version. It's a (better) alternative to #17660 (the hardening part) to make the Symfony Serializer (and probably many other pieces of code) more robust when types do not match.
/cc @csarrazi @mRoca @blazarecki
Commits
-------
|
||
---|---|---|
.. | ||
Exception | ||
Tests | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
LICENSE | ||
phpunit.xml.dist | ||
PropertyAccess.php | ||
PropertyAccessor.php | ||
PropertyAccessorBuilder.php | ||
PropertyAccessorInterface.php | ||
PropertyPath.php | ||
PropertyPathBuilder.php | ||
PropertyPathInterface.php | ||
PropertyPathIterator.php | ||
PropertyPathIteratorInterface.php | ||
README.md | ||
StringUtil.php |
PropertyAccess Component
PropertyAccess reads/writes values from/to object/array graphs using a simple string notation.
Resources
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/PropertyAccess/
$ composer install
$ phpunit