55namespace Jbtronics \SettingsBundle \Tests \Proxy ;
66
77use ReflectionClass ;
8- use Symfony \Component \VarExporter \LazyObjectInterface ;
98
109final class LazyObjectTestHelper
1110{
@@ -16,7 +15,13 @@ final class LazyObjectTestHelper
1615 */
1716 public static function isLazyObject (object $ obj ): bool
1817 {
19- if ($ obj instanceof LazyObjectInterface){
18+ if (interface_exists (\Symfony \Component \VarExporter \LazyObjectInterface::class)
19+ && $ obj instanceof \Symfony \Component \VarExporter \LazyObjectInterface
20+ ) {
21+ return true ;
22+ }
23+
24+ if (method_exists ($ obj , 'isLazyObjectInitialized ' )) {
2025 return true ;
2126 }
2227
@@ -36,8 +41,13 @@ public static function isLazyObject(object $obj): bool
3641 */
3742 public static function isLazyObjectInitialized (object $ obj , bool $ partial = false ): bool
3843 {
39- if ($ obj instanceof LazyObjectInterface){
40- return $ obj ->isLazyObjectInitialized ($ partial );
44+ if (method_exists ($ obj , 'isLazyObjectInitialized ' )) {
45+ $ method = new \ReflectionMethod ($ obj , 'isLazyObjectInitialized ' );
46+ if ($ method ->getNumberOfParameters () >= 1 ) {
47+ return $ obj ->isLazyObjectInitialized ($ partial );
48+ }
49+
50+ return $ obj ->isLazyObjectInitialized ();
4151 }
4252
4353 if (PHP_VERSION_ID >= 80400 ) {
@@ -47,4 +57,4 @@ public static function isLazyObjectInitialized(object $obj, bool $partial = fals
4757 //If we reach here, the object is not a lazy object, so it is considered initialized
4858 return true ;
4959 }
50- }
60+ }
0 commit comments