Skip to content

Commit bd1bf2c

Browse files
committed
minor symfony#24006 [PropertyAccess] Update NoSuchPropertyException message for writeProperty (ScullWM)
This PR was merged into the 3.3 branch. Discussion ---------- [PropertyAccess] Update NoSuchPropertyException message for writeProperty | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | License | MIT Hi, I've get a NoSuchPropertyException error while creating REST API forms. Having the property name in the exception is great, but in some case, this property is available in many objects. Having more information about the object that generate this exception is better. I simply suggest to add a get_class of the current object in the error message. Before: `Could not determine access type for property "id".` After (edit) `Could not determine access type for property "id" in class "App\Command\UserUpdateCommand".` Commits ------- 7855748 Update NoSuchPropertyException message for writeProperty
2 parents ad78743 + 7855748 commit bd1bf2c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ private function writeProperty($zval, $property, $value)
649649
} elseif (self::ACCESS_TYPE_MAGIC === $access[self::ACCESS_TYPE]) {
650650
$object->{$access[self::ACCESS_NAME]}($value);
651651
} elseif (self::ACCESS_TYPE_NOT_FOUND === $access[self::ACCESS_TYPE]) {
652-
throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s".', $property));
652+
throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s" in class "%s".', $property, get_class($object)));
653653
} else {
654654
throw new NoSuchPropertyException($access[self::ACCESS_NAME]);
655655
}

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections()
148148

149149
/**
150150
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
151-
* @expectedExceptionMessage Could not determine access type for property "axes".
151+
* @expectedExceptionMessageRegExp /Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./
152152
*/
153153
public function testSetValueFailsIfNoAdderNorRemoverFound()
154154
{

0 commit comments

Comments
 (0)