Skip to content

Commit 1cd63e7

Browse files
bug symfony#19141 Throw less misleading exception when property access not found (bramtweedegolf)
This PR was submitted for the master branch but it was merged into the 3.1 branch instead (closes symfony#19141). Discussion ---------- Throw less misleading exception when property access not found Prevent throwing a NoSuchPropertyException with a somewhat misleading message "Neither the property "X" nor one of the methods "addX()"/"removeX()", "setX()", "x()", "__set()" or "__call()" exist and have public access in class when the access cannot be determined, for instance if the doctrine schema is not up to date. | Q | A | | --- | --- | | Branch? | 3.1 for fixes | | Bug fix? | no | | New feature? | no | | BC breaks? | no | | Deprecations? | no | | Tests pass? | yes | | License | MIT | Commits ------- ec28da4 Throw less misleading exception when property access not found
2 parents 73099f3 + ec28da4 commit 1cd63e7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ private function writeProperty($zval, $property, $value)
610610
$object->$property = $value;
611611
} elseif (self::ACCESS_TYPE_MAGIC === $access[self::ACCESS_TYPE]) {
612612
$object->{$access[self::ACCESS_NAME]}($value);
613+
} elseif (self::ACCESS_TYPE_NOT_FOUND === $access[self::ACCESS_TYPE]) {
614+
throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s".', $property));
613615
} else {
614616
throw new NoSuchPropertyException($access[self::ACCESS_NAME]);
615617
}

0 commit comments

Comments
 (0)