From f42e588de6df54d1f11a6f7e06d00c55a9e95df8 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Wed, 21 May 2014 15:15:17 +0200 Subject: [PATCH] [PropertyAccess] Fixed inverted logic --- src/Symfony/Component/PropertyAccess/PropertyAccessor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index cce3c6dd8412..f2a64a9ed0da 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -42,7 +42,7 @@ class PropertyAccessor implements PropertyAccessorInterface public function __construct($magicCall = false, $throwExceptionOnInvalidIndex = false) { $this->magicCall = $magicCall; - $this->ignoreInvalidIndices = $throwExceptionOnInvalidIndex; + $this->ignoreInvalidIndices = !$throwExceptionOnInvalidIndex; } /** @@ -116,7 +116,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value) * * @throws UnexpectedTypeException If a value within the path is neither object nor array. */ - private function &readPropertiesUntil(&$objectOrArray, PropertyPathInterface $propertyPath, $lastIndex, $ignoreInvalidIndices = false) + private function &readPropertiesUntil(&$objectOrArray, PropertyPathInterface $propertyPath, $lastIndex, $ignoreInvalidIndices = true) { $propertyValues = array(); @@ -131,7 +131,7 @@ private function &readPropertiesUntil(&$objectOrArray, PropertyPathInterface $pr // Create missing nested arrays on demand if ($isIndex && $isArrayAccess && !isset($objectOrArray[$property])) { - if ($ignoreInvalidIndices) { + if (!$ignoreInvalidIndices) { if (!is_array($objectOrArray)) { if (!$objectOrArray instanceof \Traversable) { throw new NoSuchIndexException(sprintf(