1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/Zend/tests/lazy_objects/init_preserves_proxy_class.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

34 lines
512 B
PHP

--TEST--
Lazy objects: initialization of proxy does not change the class of the object
--FILE--
<?php
class A {
public string $s;
}
class B extends A {
public function foo() {
var_dump(__METHOD__);
}
}
$reflector = new ReflectionClass(B::class);
$o = $reflector->newLazyProxy(function (B $o) {
return new A();
});
var_dump(get_class($o));
$o->foo();
$o->s = 'init';
var_dump(get_class($o));
$o->foo();
?>
--EXPECT--
string(1) "B"
string(6) "B::foo"
string(1) "B"
string(6) "B::foo"