Skip to content

Commit

Permalink
test for array_walk_recursive, see #621
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Feb 17, 2025
1 parent 1b99e64 commit 29d4474
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/DeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ function_exists('Safe\array_flip'),
);
}

public function testFunctionWhichBecameSafeWithReferences(): void
{
// array_walk_recursive is unsafe in 8.3 and safe in 8.4, and one of
// the parameters is a reference, which wasn't handled by the original
// no-op wrapper
$this->assertTrue(
function_exists('Safe\array_walk_recursive'),
"Safe\array_walk_recursive should exist, even in php 8.4 (where it ".
"is safe natively), because it was unsafe in 8.1"
);
$data = [
['foo', 'far'],
['bar', 'baz'],
];
array_walk_recursive($data, static function (&$item) {
$item = 111;
});
$this->assertEquals(
$data,
[[111, 111], [111, 111]]
);
}

public function testIntroducedFunction(): void
{
// This function was introduced in php 8.2, so we should only
Expand Down

0 comments on commit 29d4474

Please sign in to comment.