minor #10957 [PropertyAccess] Fixed inverted logic (webmozart)

This PR was merged into the 2.4 branch.

Discussion
----------

[PropertyAccess] Fixed inverted logic

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Made the logic of the property "ignoreInvalidIndices" consistent with the master branch.

Commits
-------

f42e588 [PropertyAccess] Fixed inverted logic
This commit is contained in:
Fabien Potencier 2014-05-21 17:42:13 +02:00
commit 4255df61d0

View File

@ -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 @@ class PropertyAccessor implements PropertyAccessorInterface
*
* @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 @@ class PropertyAccessor implements PropertyAccessorInterface
// 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(