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 d0c0294

Browse filesBrowse files
committed
[PropertyAccess] Reorder elements array after PropertyPathBuilder::replace
| Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17102 | License | MIT | Doc PR |
1 parent d481dda commit d0c0294
Copy full SHA for d0c0294

File tree

2 files changed

+12
-0
lines changed
Filter options

2 files changed

+12
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public function replace($offset, $length, $path, $pathOffset = 0, $pathLength =
142142
$this->elements[$offset + $i] = $path->getElement($pathOffset + $i);
143143
$this->isIndex[$offset + $i] = $path->isIndex($pathOffset + $i);
144144
}
145+
ksort($this->elements);
145146
}
146147

147148
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ public function testReplaceWithLongerPath()
252252
$this->assertEquals($path, $builder->getPropertyPath());
253253
}
254254

255+
public function testReplaceWithLongerPathKeepsOrder()
256+
{
257+
$path = new PropertyPath('new1.new2.new3');
258+
$expected = new PropertyPath('new1.new2.new3.old2');
259+
260+
$builder = new PropertyPathBuilder(new PropertyPath('old1.old2'));
261+
$builder->replace(0, 1, $path);
262+
263+
$this->assertEquals($expected, $builder->getPropertyPath());
264+
}
265+
255266
public function testRemove()
256267
{
257268
$this->builder->remove(3);

0 commit comments

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