1
0
mirror of https://github.com/php/php-src.git synced 2026-04-08 08:33:06 +02:00
Files
archived-php-src/ext/standard/tests/array/bug79839.phpt
Nikita Popov 0c28b47154 Fixed bug #79839
Add reference type sources in array_walk.
2020-07-17 14:50:22 +02:00

27 lines
445 B
PHP

--TEST--
Bug #79839: array_walk() does not respect property types
--FILE--
<?php
class Test {
public int $prop = 42;
}
$test = new Test;
try {
array_walk($test, function(&$ref) {
$ref = []; // Should throw
});
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
var_dump($test);
?>
--EXPECT--
Cannot assign array to reference held by property Test::$prop of type int
object(Test)#1 (1) {
["prop"]=>
&int(42)
}