php-src/Zend/tests/lazy_objects/init_exception_001.phpt
Arnaud Le Blanc 58aa6fc830
Lazy objects
RFC: https://wiki.php.net/rfc/lazy-objects

Closes GH-15019
2024-08-30 17:30:03 +02:00

29 lines
509 B
PHP

--TEST--
Lazy objects: init exception 001
--FILE--
<?php
#[AllowDynamicProperties]
class C {
public int $a;
public $b;
}
$reflector = new ReflectionClass(C::class);
for ($i = 0; $i < 2; $i++) {
$obj = $reflector->newLazyGhost(function ($obj) use ($i) {
if ($i === 1) {
throw new \Exception();
}
});
$obj->c = 1;
}
?>
--EXPECTF--
Fatal error: Uncaught Exception in %s:%d
Stack trace:
#0 %s(%d): {closure:%s:%d}(Object(C))
#1 {main}
thrown in %s on line %d