This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/PropertyAccess
Fabien Potencier 48f05ecad2 feature #17738 [PropertyAccess] Throw an InvalidArgumentException when the type do not match (dunglas)
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
-------

e70fdbc [PropertyAccess] Throw an InvalidArgumentException when the type do not match
2016-02-26 07:20:42 +01:00
..
Exception [2.7] Fix unsilenced deprecation notices 2015-06-16 15:26:24 +02:00
Tests feature #17738 [PropertyAccess] Throw an InvalidArgumentException when the type do not match (dunglas) 2016-02-26 07:20:42 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [PropertyAccess] Show property path in all exception messages 2015-02-04 17:34:04 +01:00
composer.json [PropertyAccess] Throw an InvalidArgumentException when the type do not match 2016-02-26 07:20:38 +01:00
LICENSE Update copyright year 2016-01-01 23:53:47 -03:00
phpunit.xml.dist Add missing exclusions from phpunit.xml.dist 2015-11-18 09:19:46 +01:00
PropertyAccess.php Silence invasive deprecation warnings, opt-in for warnings 2015-06-08 10:37:21 +01:00
PropertyAccessor.php [PropertyAccess] Throw an InvalidArgumentException when the type do not match 2016-02-26 07:20:38 +01:00
PropertyAccessorBuilder.php [PropertyAccess] unify and fix doc 2015-02-21 16:36:02 +01:00
PropertyAccessorInterface.php [PropertyAccess] Throw an InvalidArgumentException when the type do not match 2016-02-26 07:20:38 +01:00
PropertyPath.php Merge branch '2.3' into 2.7 2015-10-23 16:47:27 +02:00
PropertyPathBuilder.php [PropertyAccess] Reorder elements array after PropertyPathBuilder::replace 2015-12-22 18:06:45 +01:00
PropertyPathInterface.php [2.3] CS And DocBlock Fixes 2014-12-22 16:58:09 +01:00
PropertyPathIterator.php [2.3] CS And DocBlock Fixes 2014-12-22 16:58:09 +01:00
PropertyPathIteratorInterface.php fixed types in phpdocs 2014-04-16 12:30:19 +02:00
README.md renamed composer.phar to composer to be consistent with the Symfony docs 2015-02-08 08:41:14 +01:00
StringUtil.php Added more exceptions to singularify method 2016-02-09 22:08:46 +01:00

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