@@ -124,31 +124,6 @@ public static function dataIsSuperTypeOf(): array
124124 ];
125125 }
126126
127- public function testIsSuperTypeOfClosureRespectsActivePhpVersion (): void
128- {
129- $ type = new HasPropertyType ('foo ' );
130-
131- // Whether a final class without the property is a possible subtype of
132- // hasProperty() depends on whether the PHP version still allows dynamic
133- // properties, so the result must follow the active container's PhpVersion
134- // rather than the global PHP_VERSION_ID constant. This coupling is what made
135- // the Closure data set above flaky when another test left a container
136- // configured with a different PhpVersion registered as the global static
137- // reflection provider. See https://github.com/phpstan/phpstan/issues/14860
138- // A fresh ObjectType is used each time because it caches its ClassReflection.
139- try {
140- self ::registerContainerWithPhpVersion (80100 );
141- $ this ->assertSame ('Maybe ' , $ type ->isSuperTypeOf (new ObjectType (Closure::class))->describe ());
142-
143- self ::registerContainerWithPhpVersion (80200 );
144- $ this ->assertSame ('No ' , $ type ->isSuperTypeOf (new ObjectType (Closure::class))->describe ());
145- } finally {
146- // Restore the default (runtime) container so this test does not leak its
147- // foreign container into other tests.
148- self ::getContainer ();
149- }
150- }
151-
152127 #[DataProvider('dataIsSuperTypeOf ' )]
153128 public function testIsSuperTypeOf (HasPropertyType $ type , Type $ otherType , TrinaryLogic $ expectedResult ): void
154129 {
@@ -215,25 +190,4 @@ public function testIsSubTypeOfInversed(HasPropertyType $type, Type $otherType,
215190 );
216191 }
217192
218- private static function registerContainerWithPhpVersion (int $ versionId ): void
219- {
220- $ fileHelper = new FileHelper (__DIR__ . '/../../../.. ' );
221- $ rootDir = $ fileHelper ->normalizePath (__DIR__ . '/../../../.. ' , '/ ' );
222-
223- // The directory is already created by self::getContainer() (called in setUp()).
224- $ tmpDir = sys_get_temp_dir () . '/phpstan-tests ' ;
225-
226- $ configFile = $ tmpDir . '/has-property-php-version- ' . $ versionId . '.neon ' ;
227- file_put_contents ($ configFile , sprintf ("parameters: \n\tphpVersion: %d \n" , $ versionId ));
228-
229- $ containerFactory = new ContainerFactory ($ rootDir );
230- $ container = $ containerFactory ->create ($ tmpDir , [
231- $ containerFactory ->getConfigDirectory () . '/config.level8.neon ' ,
232- __DIR__ . '/../../../../src/Testing/TestCase.neon ' ,
233- $ configFile ,
234- ], []);
235-
236- ContainerFactory::postInitializeContainer ($ container );
237- }
238-
239193}
0 commit comments