Skip to content
Permalink
Browse files

bug #30392 [PropertyAccess] Fixed PropertyPathBuilder remove that fai…

…ls to reset internal indexes (GregOriol)

This PR was squashed before being merged into the 3.4 branch (closes #30392).

Discussion
----------

[PropertyAccess] Fixed PropertyPathBuilder remove that fails to reset internal indexes

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

In addition to the fix (first commit), this PR adds \ to all not-yet-prefixed native functions in the PropertyPathBuilder (second commit).

NB: the behavior fixed here actually appeared in 2.2

Commits
-------

479dff4 [PropertyAccess] Fixed PropertyPathBuilder remove that fails to reset internal indexes
  • Loading branch information...
fabpot committed Mar 4, 2019
2 parents 4203bef + 479dff4 commit 897ecb7fb89d27c42da672c9779726fef5f2e7c4
@@ -257,9 +257,8 @@ private function resize($offset, $cutLength, $insertionLength)
}
// All remaining elements should be removed
for (; $i < $length; ++$i) {
unset($this->elements[$i], $this->isIndex[$i]);
}
$this->elements = \array_slice($this->elements, 0, $i);
$this->isIndex = \array_slice($this->isIndex, 0, $i);
} else {
$diff = $insertionLength - $cutLength;
@@ -285,4 +285,25 @@ public function testRemoveDoesNotAllowNegativeOffsets()
{
$this->builder->remove(-1);
}
public function testRemoveAndAppendAtTheEnd()
{
$this->builder->remove($this->builder->getLength() - 1);
$path = new PropertyPath('old1[old2].old3[old4][old5]');
$this->assertEquals($path, $this->builder->getPropertyPath());
$this->builder->appendProperty('old7');
$path = new PropertyPath('old1[old2].old3[old4][old5].old7');
$this->assertEquals($path, $this->builder->getPropertyPath());
$this->builder->remove($this->builder->getLength() - 1);
$path = new PropertyPath('old1[old2].old3[old4][old5]');
$this->assertEquals($path, $this->builder->getPropertyPath());
}
}

0 comments on commit 897ecb7

Please sign in to comment.
You can’t perform that action at this time.