1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/Zend/tests/lazy_objects/array_walk.phpt
Arnaud Le Blanc c65e042c0b Fix zend_get_property_info_for_slot() for lazy objects (#15855)
zend_get_property_info_for_slot(obj, slot) assumes that 'slot' belongs to 'obj', but that may not be the case for lazy proxies.

Fortunately, the property info is often already available in path when it is needed.

For other cases, I make zend_get_property_info_for_slot() aware of lazy objects, and add zend_get_property_info_for_slot_self() for cases where the 'slot' is known to belong to the object itself.

Fixes oss-fuzz #71446
2024-09-16 16:58:12 +02:00

37 lines
603 B
PHP

--TEST--
Lazy Objects: array_walk()
--FILE--
<?php
class C {
public int $a = 1;
}
$reflector = new ReflectionClass(C::class);
$obj = $reflector->newLazyProxy(function () {
return new C();
});
array_walk($obj, function (&$value, $key) {
try {
$value = 'string';
} catch (Error $e) {
printf("%s: %s\n", $e::class, $e->getMessage());
}
$value = 2;
});
var_dump($obj);
?>
--EXPECTF--
TypeError: Cannot assign string to reference held by property C::$a of type int
lazy proxy object(C)#%d (1) {
["instance"]=>
object(C)#%d (1) {
["a"]=>
int(2)
}
}