Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
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
[PropertyAccess] add more information to NoSuchPropertyException Message
  • Loading branch information
Amrouche Hamza committed Dec 11, 2017
commit dee00f839381ea21924701cd846a36328716fae9
8 changes: 4 additions & 4 deletions src/Symfony/Component/PropertyAccess/PropertyAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static function throwInvalidArgumentException($message, $trace, $i)
$type = $trace[$i]['args'][0];
$type = is_object($type) ? get_class($type) : gettype($type);

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

Expand Down Expand Up @@ -500,7 +500,7 @@ private function getReadAccessInfo($class, $property)
private function writeIndex($zval, $index, $value)
{
if (!$zval[self::VALUE] instanceof \ArrayAccess && !is_array($zval[self::VALUE])) {
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])));
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])));
}

$zval[self::REF][$index] = $value;
Expand Down Expand Up @@ -541,7 +541,7 @@ private function writeProperty($zval, $property, $value)
} elseif (self::ACCESS_TYPE_MAGIC === $access[self::ACCESS_TYPE]) {
$object->{$access[self::ACCESS_NAME]}($value);
} elseif (self::ACCESS_TYPE_NOT_FOUND === $access[self::ACCESS_TYPE]) {
throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s" in class "%s".', $property, get_class($object)));
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] : ''));
} else {
throw new NoSuchPropertyException($access[self::ACCESS_NAME]);
}
Expand Down Expand Up @@ -589,7 +589,7 @@ private function writeCollection($zval, $property, $collection, $addMethod, $rem
/**
* Guesses how to write the property value.
*
* @param mixed $value
* @param mixed $value
*/
private function getWriteAccessInfo(string $class, string $property, $value): array
{
Expand Down