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_trigger_compare.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

55 lines
897 B
PHP

--TEST--
Lazy objects: comparison initializes object
--FILE--
<?php
class C {
public int $a;
public $b;
public function __construct() {
var_dump(__METHOD__);
}
public function __toString() {
return 'C';
}
}
$reflector = new ReflectionClass(C::class);
$a = $reflector->newLazyGhost(function ($obj) {
$obj->__construct();
});
$b = $reflector->newLazyProxy(function ($obj) {
return new C();
});
var_dump($a > $b);
$a = $reflector->newLazyGhost(function ($obj) {
$obj->__construct();
});
$b = $reflector->newLazyProxy(function ($obj) {
return new C();
});
var_dump($a == $b);
$a = $reflector->newLazyGhost(function ($obj) {
$obj->__construct();
});
var_dump('A' < $a);
?>
--EXPECT--
string(14) "C::__construct"
string(14) "C::__construct"
bool(false)
string(14) "C::__construct"
string(14) "C::__construct"
bool(true)
bool(true)