Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[PropertyAccess] Throw an InvalidArgumentException when the type do not match #17738

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

Closed
wants to merge 10 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes some edge cases...
  • Loading branch information
dunglas committed Feb 16, 2016
commit 90e7953cb31349d78ad4af645d347df5269fc6f0
19 changes: 15 additions & 4 deletions 19 src/Symfony/Component/PropertyAccess/PropertyAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,9 @@ private function writeIndex(&$array, $index, $value)
* @param string $property The property to write
* @param mixed $value The value to write
*
* @throws NoSuchPropertyException If the property does not exist or is not
* public.
* @throws NoSuchPropertyException If the property does not exist or is not
* public.
* @throws InvalidArgumentException
*/
private function writeProperty(&$object, $property, $value)
{
Expand Down Expand Up @@ -580,9 +581,13 @@ private function writeProperty(&$object, $property, $value)
* @param object $object
* @param string $method
* @param mixed $value
*
* @throws InvalidArgumentException
* @throws \Exception
*/
private function callMethod($object, $method, $value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ should be on the next line

if (class_exists('TypeError')) {
// Cannot use class_exists because the PHP 7 polyfill defines \TypeError
if (PHP_MAJOR_VERSION >= 7) {
// PHP 7
try {
$object->{$method}($value);
Expand All @@ -600,8 +605,12 @@ private function callMethod($object, $method, $value) {

try {
$object->{$method}($value);
} finally {
restore_error_handler();
} catch (\Exception $e) {
// Cannot use finally in 5.5 because of https://bugs.php.net/bug.php?id=67047
restore_error_handler();

throw $e;
}
}

Expand All @@ -614,6 +623,8 @@ private function callMethod($object, $method, $value) {
* @param array|\Traversable $collection The collection to write
* @param string $addMethod The add*() method
* @param string $removeMethod The remove*() method
*
* @throws InvalidArgumentException
*/
private function writeCollection($object, $property, $collection, $addMethod, $removeMethod)
{
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.