Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 479dff4

Browse filesBrowse files
GregOriolfabpot
authored andcommitted
[PropertyAccess] Fixed PropertyPathBuilder remove that fails to reset internal indexes
1 parent 4203bef commit 479dff4
Copy full SHA for 479dff4

File tree

2 files changed

+23
-3
lines changed
Filter options

2 files changed

+23
-3
lines changed

‎src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,8 @@ private function resize($offset, $cutLength, $insertionLength)
257257
}
258258

259259
// All remaining elements should be removed
260-
for (; $i < $length; ++$i) {
261-
unset($this->elements[$i], $this->isIndex[$i]);
262-
}
260+
$this->elements = \array_slice($this->elements, 0, $i);
261+
$this->isIndex = \array_slice($this->isIndex, 0, $i);
263262
} else {
264263
$diff = $insertionLength - $cutLength;
265264

‎src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,25 @@ public function testRemoveDoesNotAllowNegativeOffsets()
285285
{
286286
$this->builder->remove(-1);
287287
}
288+
289+
public function testRemoveAndAppendAtTheEnd()
290+
{
291+
$this->builder->remove($this->builder->getLength() - 1);
292+
293+
$path = new PropertyPath('old1[old2].old3[old4][old5]');
294+
295+
$this->assertEquals($path, $this->builder->getPropertyPath());
296+
297+
$this->builder->appendProperty('old7');
298+
299+
$path = new PropertyPath('old1[old2].old3[old4][old5].old7');
300+
301+
$this->assertEquals($path, $this->builder->getPropertyPath());
302+
303+
$this->builder->remove($this->builder->getLength() - 1);
304+
305+
$path = new PropertyPath('old1[old2].old3[old4][old5]');
306+
307+
$this->assertEquals($path, $this->builder->getPropertyPath());
308+
}
288309
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.