xref: /PHP-8.1/ext/standard/tests/array/bug79839.phpt (revision d65d3f52)
1--TEST--
2Bug #79839: array_walk() does not respect property types
3--FILE--
4<?php
5
6class Test {
7    public int $prop = 42;
8}
9
10$test = new Test;
11try {
12    array_walk($test, function(&$ref) {
13        $ref = []; // Should throw
14    });
15} catch (TypeError $e) {
16    echo $e->getMessage(), "\n";
17}
18var_dump($test);
19
20?>
21--EXPECT--
22Cannot assign array to reference held by property Test::$prop of type int
23object(Test)#1 (1) {
24  ["prop"]=>
25  int(42)
26}
27