1--TEST-- 2Lazy objects: comparison initializes object 3--FILE-- 4<?php 5 6class C { 7 public int $a; 8 public $b; 9 10 public function __construct() { 11 var_dump(__METHOD__); 12 } 13 14 public function __toString() { 15 return 'C'; 16 } 17} 18 19$reflector = new ReflectionClass(C::class); 20 21$a = $reflector->newLazyGhost(function ($obj) { 22 $obj->__construct(); 23}); 24 25$b = $reflector->newLazyProxy(function ($obj) { 26 return new C(); 27}); 28 29var_dump($a > $b); 30 31$a = $reflector->newLazyGhost(function ($obj) { 32 $obj->__construct(); 33}); 34 35$b = $reflector->newLazyProxy(function ($obj) { 36 return new C(); 37}); 38 39var_dump($a == $b); 40 41$a = $reflector->newLazyGhost(function ($obj) { 42 $obj->__construct(); 43}); 44 45var_dump('A' < $a); 46?> 47--EXPECT-- 48string(14) "C::__construct" 49string(14) "C::__construct" 50bool(false) 51string(14) "C::__construct" 52string(14) "C::__construct" 53bool(true) 54bool(true) 55