[PropertyAccess] fix cs
This commit is contained in:
parent
8990968b01
commit
03a63dbc14
@ -78,8 +78,10 @@ class PropertyAccessor implements PropertyAccessorInterface
|
|||||||
self::IS_REF => true,
|
self::IS_REF => true,
|
||||||
self::IS_REF_CHAINED => true,
|
self::IS_REF_CHAINED => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$propertyMaxIndex = count($propertyValues) - 1;
|
||||||
|
|
||||||
for ($i = count($propertyValues) - 1; $i >= 0; --$i) {
|
for ($i = $propertyMaxIndex; $i >= 0; --$i) {
|
||||||
$objectOrArray = &$propertyValues[$i][self::VALUE];
|
$objectOrArray = &$propertyValues[$i][self::VALUE];
|
||||||
|
|
||||||
$property = $propertyPath->getElement($i);
|
$property = $propertyPath->getElement($i);
|
||||||
@ -95,7 +97,7 @@ class PropertyAccessor implements PropertyAccessorInterface
|
|||||||
// If you want to change its value to 'new-value',
|
// If you want to change its value to 'new-value',
|
||||||
// you only need set value for '[a][b][c]' and it's safe to ignore '[a][b]' and '[a]'
|
// you only need set value for '[a][b][c]' and it's safe to ignore '[a][b]' and '[a]'
|
||||||
//
|
//
|
||||||
if ($i === count($propertyValues) - 1 || !$propertyValues[$i + 1][self::IS_REF]) {
|
if ($i === $propertyMaxIndex || !$propertyValues[$i + 1][self::IS_REF]) {
|
||||||
if ($propertyPath->isIndex($i)) {
|
if ($propertyPath->isIndex($i)) {
|
||||||
$this->writeIndex($objectOrArray, $property, $value);
|
$this->writeIndex($objectOrArray, $property, $value);
|
||||||
} else {
|
} else {
|
||||||
@ -110,7 +112,6 @@ class PropertyAccessor implements PropertyAccessorInterface
|
|||||||
if (is_object($propertyValues[$i][self::VALUE]) || $propertyValues[$i][self::IS_REF_CHAINED]) {
|
if (is_object($propertyValues[$i][self::VALUE]) || $propertyValues[$i][self::IS_REF_CHAINED]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = &$objectOrArray;
|
$value = &$objectOrArray;
|
||||||
@ -259,7 +260,7 @@ class PropertyAccessor implements PropertyAccessorInterface
|
|||||||
// it is the first element in the property path or
|
// it is the first element in the property path or
|
||||||
// the IS_REF_CHAINED flag of its parent element is true
|
// the IS_REF_CHAINED flag of its parent element is true
|
||||||
// Basically, this flag is true only when the reference chain from the top element to current element is not broken
|
// Basically, this flag is true only when the reference chain from the top element to current element is not broken
|
||||||
$propertyValue[self::IS_REF_CHAINED] = $propertyValue[self::IS_REF] && ($i == 0 || $propertyValues[$i - 1][self::IS_REF_CHAINED]);
|
$propertyValue[self::IS_REF_CHAINED] = $propertyValue[self::IS_REF] && (0 === $i || $propertyValues[$i - 1][self::IS_REF_CHAINED]);
|
||||||
|
|
||||||
$propertyValues[] = &$propertyValue;
|
$propertyValues[] = &$propertyValue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user