mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #8425 from grimpirate/grimpirate-patch-1
fix: [Validation] DotArrayFilter returns incorrect array when numeric index array is passed
This commit is contained in:
commit
0788018f2c
@ -44,7 +44,7 @@ final class DotArrayFilter
|
||||
$segments
|
||||
);
|
||||
|
||||
$result = array_merge_recursive($result, self::filter($segments, $array));
|
||||
$result = array_replace_recursive($result, self::filter($segments, $array));
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -180,4 +180,19 @@ final class DotArrayFilterTest extends CIUnitTestCase
|
||||
];
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function testRunReturnOrderedIndices()
|
||||
{
|
||||
$data = [
|
||||
'foo' => [
|
||||
2 => 'bar',
|
||||
0 => 'baz',
|
||||
1 => 'biz',
|
||||
],
|
||||
];
|
||||
|
||||
$result = DotArrayFilter::run(['foo.2', 'foo.0', 'foo.1'], $data);
|
||||
|
||||
$this->assertSame($data, $result);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user