Skip to content

Commit 0788018

Browse files
authored
Merge pull request #8425 from grimpirate/grimpirate-patch-1
fix: [Validation] DotArrayFilter returns incorrect array when numeric index array is passed
2 parents 1e61ebd + 75d5400 commit 0788018

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

system/Validation/DotArrayFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function run(array $indexes, array $array): array
4444
$segments
4545
);
4646

47-
$result = array_merge_recursive($result, self::filter($segments, $array));
47+
$result = array_replace_recursive($result, self::filter($segments, $array));
4848
}
4949

5050
return $result;

tests/system/Validation/DotArrayFilterTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,19 @@ public function testRunNestedArray()
180180
];
181181
$this->assertSame($expected, $result);
182182
}
183+
184+
public function testRunReturnOrderedIndices()
185+
{
186+
$data = [
187+
'foo' => [
188+
2 => 'bar',
189+
0 => 'baz',
190+
1 => 'biz',
191+
],
192+
];
193+
194+
$result = DotArrayFilter::run(['foo.2', 'foo.0', 'foo.1'], $data);
195+
196+
$this->assertSame($data, $result);
197+
}
183198
}

0 commit comments

Comments
 (0)