Skip to content

Commit 1cf1ae7

Browse files
committed
feature symfony#25450 [PropertyAccess] add more information to NoSuchPropertyException Message (Simperfit)
This PR was merged into the 4.1-dev branch. Discussion ---------- [PropertyAccess] add more information to NoSuchPropertyException Message | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | no | Fixed tickets | symfony#24742 | License | MIT | Doc PR | Add more context to NoSuchPropertyException as discussed in the issue. Commits ------- dee00f8 [PropertyAccess] add more information to NoSuchPropertyException Message
2 parents 28bf816 + dee00f8 commit 1cf1ae7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private static function throwInvalidArgumentException($message, $trace, $i)
167167
$type = $trace[$i]['args'][0];
168168
$type = is_object($type) ? get_class($type) : gettype($type);
169169

170-
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given', substr($message, $pos, strpos($message, ',', $pos) - $pos), $type));
170+
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.', substr($message, $pos, strpos($message, ',', $pos) - $pos), $type));
171171
}
172172
}
173173

@@ -500,7 +500,7 @@ private function getReadAccessInfo($class, $property)
500500
private function writeIndex($zval, $index, $value)
501501
{
502502
if (!$zval[self::VALUE] instanceof \ArrayAccess && !is_array($zval[self::VALUE])) {
503-
throw new NoSuchIndexException(sprintf('Cannot modify index "%s" in object of type "%s" because it doesn\'t implement \ArrayAccess', $index, get_class($zval[self::VALUE])));
503+
throw new NoSuchIndexException(sprintf('Cannot modify index "%s" in object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, get_class($zval[self::VALUE])));
504504
}
505505

506506
$zval[self::REF][$index] = $value;
@@ -541,7 +541,7 @@ private function writeProperty($zval, $property, $value)
541541
} elseif (self::ACCESS_TYPE_MAGIC === $access[self::ACCESS_TYPE]) {
542542
$object->{$access[self::ACCESS_NAME]}($value);
543543
} elseif (self::ACCESS_TYPE_NOT_FOUND === $access[self::ACCESS_TYPE]) {
544-
throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s" in class "%s".', $property, get_class($object)));
544+
throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s" in class "%s"%s.', $property, get_class($object), isset($access[self::ACCESS_NAME]) ? ': '.$access[self::ACCESS_NAME] : ''));
545545
} else {
546546
throw new NoSuchPropertyException($access[self::ACCESS_NAME]);
547547
}
@@ -589,7 +589,7 @@ private function writeCollection($zval, $property, $collection, $addMethod, $rem
589589
/**
590590
* Guesses how to write the property value.
591591
*
592-
* @param mixed $value
592+
* @param mixed $value
593593
*/
594594
private function getWriteAccessInfo(string $class, string $property, $value): array
595595
{

0 commit comments

Comments
 (0)