File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,30 @@ function_exists('Safe\array_flip'),
27
27
);
28
28
}
29
29
30
+ public function testFunctionWhichBecameSafeWithReferences (): void
31
+ {
32
+ // array_walk_recursive is unsafe in 8.3 and safe in 8.4, and one of
33
+ // the parameters is a reference, which wasn't handled by the original
34
+ // no-op wrapper
35
+ // See https://github.com/thecodingmachine/safe/issues/621
36
+ $ this ->assertTrue (
37
+ function_exists ('Safe\array_walk_recursive ' ),
38
+ "Safe\array_walk_recursive should exist, even in php 8.4 (where it " .
39
+ "is safe natively), because it was unsafe in 8.1 "
40
+ );
41
+ $ data = [
42
+ ['foo ' , 'far ' ],
43
+ ['bar ' , 'baz ' ],
44
+ ];
45
+ array_walk_recursive ($ data , static function (&$ item ) {
46
+ $ item = 111 ;
47
+ });
48
+ $ this ->assertEquals (
49
+ $ data ,
50
+ [[111 , 111 ], [111 , 111 ]]
51
+ );
52
+ }
53
+
30
54
public function testIntroducedFunction (): void
31
55
{
32
56
// This function was introduced in php 8.2, so we should only
You can’t perform that action at this time.
0 commit comments