@@ -340,7 +340,7 @@ public function testDumpAsFilesWithLazyFactoriesInlined()
340
340
if ('\\' === \DIRECTORY_SEPARATOR ) {
341
341
$ dump = str_replace ("'. \\DIRECTORY_SEPARATOR.' " , '/ ' , $ dump );
342
342
}
343
- $ this ->assertStringMatchesFormatFile (self ::$ fixturesPath .'/php/services9_lazy_inlined_factories.txt ' , $ dump );
343
+ $ this ->assertStringMatchesFormatFile (self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' services9_lazy_inlined_factories.txt ' , $ dump );
344
344
}
345
345
346
346
public function testServicesWithAnonymousFactories ()
@@ -794,18 +794,26 @@ public function testNonSharedLazy()
794
794
'inline_class_loader ' => false ,
795
795
]);
796
796
$ this ->assertStringEqualsFile (
797
- self ::$ fixturesPath .'/php/services_non_shared_lazy_public.php ' ,
797
+ self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' services_non_shared_lazy_public.php ' ,
798
798
'\\' === \DIRECTORY_SEPARATOR ? str_replace ("'. \\DIRECTORY_SEPARATOR.' " , '/ ' , $ dump ) : $ dump
799
799
);
800
800
eval ('?> ' .$ dump );
801
801
802
802
$ container = new \Symfony_DI_PhpDumper_Service_Non_Shared_Lazy ();
803
803
804
804
$ foo1 = $ container ->get ('foo ' );
805
- $ this ->assertTrue ($ foo1 ->resetLazyObject ());
805
+ if (\PHP_VERSION_ID >= 80400 ) {
806
+ $ this ->assertTrue ((new \ReflectionClass ($ foo1 ))->isUninitializedLazyObject ($ foo1 ));
807
+ } else {
808
+ $ this ->assertTrue ($ foo1 ->resetLazyObject ());
809
+ }
806
810
807
811
$ foo2 = $ container ->get ('foo ' );
808
- $ this ->assertTrue ($ foo2 ->resetLazyObject ());
812
+ if (\PHP_VERSION_ID >= 80400 ) {
813
+ $ this ->assertTrue ((new \ReflectionClass ($ foo2 ))->isUninitializedLazyObject ($ foo2 ));
814
+ } else {
815
+ $ this ->assertTrue ($ foo2 ->resetLazyObject ());
816
+ }
809
817
810
818
$ this ->assertNotSame ($ foo1 , $ foo2 );
811
819
}
@@ -832,7 +840,7 @@ public function testNonSharedLazyAsFiles()
832
840
833
841
$ stringDump = print_r ($ dumps , true );
834
842
$ this ->assertStringMatchesFormatFile (
835
- self ::$ fixturesPath .'/php/services_non_shared_lazy_as_files.txt ' ,
843
+ self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' services_non_shared_lazy_as_files.txt ' ,
836
844
'\\' === \DIRECTORY_SEPARATOR ? str_replace ("'. \\DIRECTORY_SEPARATOR.' " , '/ ' , $ stringDump ) : $ stringDump
837
845
);
838
846
@@ -844,10 +852,18 @@ public function testNonSharedLazyAsFiles()
844
852
$ container = eval ('?> ' .$ lastDump );
845
853
846
854
$ foo1 = $ container ->get ('non_shared_foo ' );
847
- $ this ->assertTrue ($ foo1 ->resetLazyObject ());
855
+ if (\PHP_VERSION_ID >= 80400 ) {
856
+ $ this ->assertTrue ((new \ReflectionClass ($ foo1 ))->isUninitializedLazyObject ($ foo1 ));
857
+ } else {
858
+ $ this ->assertTrue ($ foo1 ->resetLazyObject ());
859
+ }
848
860
849
861
$ foo2 = $ container ->get ('non_shared_foo ' );
850
- $ this ->assertTrue ($ foo2 ->resetLazyObject ());
862
+ if (\PHP_VERSION_ID >= 80400 ) {
863
+ $ this ->assertTrue ((new \ReflectionClass ($ foo2 ))->isUninitializedLazyObject ($ foo2 ));
864
+ } else {
865
+ $ this ->assertTrue ($ foo2 ->resetLazyObject ());
866
+ }
851
867
852
868
$ this ->assertNotSame ($ foo1 , $ foo2 );
853
869
}
@@ -869,7 +885,7 @@ public function testNonSharedLazyDefinitionReferences(bool $asGhostObject)
869
885
$ dumper ->setProxyDumper (new \DummyProxyDumper ());
870
886
}
871
887
872
- $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/services_non_shared_lazy ' .($ asGhostObject ? '_ghost ' : '' ).'.php ' , $ dumper ->dump ());
888
+ $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' services_non_shared_lazy ' .($ asGhostObject ? '_ghost ' : '' ).'.php ' , $ dumper ->dump ());
873
889
}
874
890
875
891
public function testNonSharedDuplicates ()
@@ -942,7 +958,7 @@ public function testDedupLazyProxy()
942
958
943
959
$ dumper = new PhpDumper ($ container );
944
960
945
- $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/services_dedup_lazy.php ' , $ dumper ->dump ());
961
+ $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' services_dedup_lazy.php ' , $ dumper ->dump ());
946
962
}
947
963
948
964
public function testLazyArgumentProvideGenerator ()
@@ -1607,14 +1623,18 @@ public function testLazyWither()
1607
1623
$ container ->compile ();
1608
1624
$ dumper = new PhpDumper ($ container );
1609
1625
$ dump = $ dumper ->dump (['class ' => 'Symfony_DI_PhpDumper_Service_Wither_Lazy ' ]);
1610
- $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/services_wither_lazy.php ' , $ dump );
1626
+ $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' services_wither_lazy.php ' , $ dump );
1611
1627
eval ('?> ' .$ dump );
1612
1628
1613
1629
$ container = new \Symfony_DI_PhpDumper_Service_Wither_Lazy ();
1614
1630
1615
1631
$ wither = $ container ->get ('wither ' );
1632
+ if (\PHP_VERSION_ID >= 80400 ) {
1633
+ $ this ->assertTrue ((new \ReflectionClass ($ wither ))->isUninitializedLazyObject ($ wither ));
1634
+ } else {
1635
+ $ this ->assertTrue ($ wither ->resetLazyObject ());
1636
+ }
1616
1637
$ this ->assertInstanceOf (Foo::class, $ wither ->foo );
1617
- $ this ->assertTrue ($ wither ->resetLazyObject ());
1618
1638
}
1619
1639
1620
1640
public function testLazyWitherNonShared ()
@@ -1632,18 +1652,26 @@ public function testLazyWitherNonShared()
1632
1652
$ container ->compile ();
1633
1653
$ dumper = new PhpDumper ($ container );
1634
1654
$ dump = $ dumper ->dump (['class ' => 'Symfony_DI_PhpDumper_Service_Wither_Lazy_Non_Shared ' ]);
1635
- $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/services_wither_lazy_non_shared.php ' , $ dump );
1655
+ $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' services_wither_lazy_non_shared.php ' , $ dump );
1636
1656
eval ('?> ' .$ dump );
1637
1657
1638
1658
$ container = new \Symfony_DI_PhpDumper_Service_Wither_Lazy_Non_Shared ();
1639
1659
1640
1660
$ wither1 = $ container ->get ('wither ' );
1661
+ if (\PHP_VERSION_ID >= 80400 ) {
1662
+ $ this ->assertTrue ((new \ReflectionClass ($ wither1 ))->isUninitializedLazyObject ($ wither1 ));
1663
+ } else {
1664
+ $ this ->assertTrue ($ wither1 ->resetLazyObject ());
1665
+ }
1641
1666
$ this ->assertInstanceOf (Foo::class, $ wither1 ->foo );
1642
- $ this ->assertTrue ($ wither1 ->resetLazyObject ());
1643
1667
1644
1668
$ wither2 = $ container ->get ('wither ' );
1669
+ if (\PHP_VERSION_ID >= 80400 ) {
1670
+ $ this ->assertTrue ((new \ReflectionClass ($ wither2 ))->isUninitializedLazyObject ($ wither2 ));
1671
+ } else {
1672
+ $ this ->assertTrue ($ wither2 ->resetLazyObject ());
1673
+ }
1645
1674
$ this ->assertInstanceOf (Foo::class, $ wither2 ->foo );
1646
- $ this ->assertTrue ($ wither2 ->resetLazyObject ());
1647
1675
1648
1676
$ this ->assertNotSame ($ wither1 , $ wither2 );
1649
1677
}
@@ -1971,15 +1999,21 @@ public function testLazyAutowireAttribute()
1971
1999
$ container ->compile ();
1972
2000
$ dumper = new PhpDumper ($ container );
1973
2001
1974
- $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/lazy_autowire_attribute.php ' , $ dumper ->dump (['class ' => 'Symfony_DI_PhpDumper_Test_Lazy_Autowire_Attribute ' ]));
2002
+ $ this ->assertStringEqualsFile (self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' lazy_autowire_attribute.php ' , $ dumper ->dump (['class ' => 'Symfony_DI_PhpDumper_Test_Lazy_Autowire_Attribute ' ]));
1975
2003
1976
- require self ::$ fixturesPath .'/php/lazy_autowire_attribute.php ' ;
2004
+ require self ::$ fixturesPath .'/php/ ' .(\ PHP_VERSION_ID < 80400 ? ' legacy_ ' : '' ). ' lazy_autowire_attribute.php ' ;
1977
2005
1978
2006
$ container = new \Symfony_DI_PhpDumper_Test_Lazy_Autowire_Attribute ();
1979
2007
1980
2008
$ this ->assertInstanceOf (Foo::class, $ container ->get ('bar ' )->foo );
1981
- $ this ->assertInstanceOf (LazyObjectInterface::class, $ container ->get ('bar ' )->foo );
1982
- $ this ->assertSame ($ container ->get ('foo ' ), $ container ->get ('bar ' )->foo ->initializeLazyObject ());
2009
+ if (\PHP_VERSION_ID >= 80400 ) {
2010
+ $ r = new \ReflectionClass (Foo::class);
2011
+ $ this ->assertTrue ($ r ->isUninitializedLazyObject ($ container ->get ('bar ' )->foo ));
2012
+ $ this ->assertSame ($ container ->get ('foo ' ), $ r ->initializeLazyObject ($ container ->get ('bar ' )->foo ));
2013
+ } else {
2014
+ $ this ->assertInstanceOf (LazyObjectInterface::class, $ container ->get ('bar ' )->foo );
2015
+ $ this ->assertSame ($ container ->get ('foo ' ), $ container ->get ('bar ' )->foo ->initializeLazyObject ());
2016
+ }
1983
2017
}
1984
2018
1985
2019
public function testLazyAutowireAttributeWithIntersection ()
0 commit comments