@@ -89,28 +89,28 @@ protected function getCollectors(): array
8989 * @param string|non-empty-list<string> $files
9090 * @dataProvider provideFiles
9191 */
92- public function testDead ($ files , ? int $ lowestPhpVersion = null ): void
92+ public function testDead ($ files , bool $ requirementsMet = true ): void
9393 {
9494 $ this ->emitErrorsInGroups = false ;
95- $ this ->doTestDead ($ files , $ lowestPhpVersion );
95+ $ this ->doTestDead ($ files , $ requirementsMet );
9696 }
9797
9898 /**
9999 * @param string|non-empty-list<string> $files
100100 * @dataProvider provideFiles
101101 */
102- public function testDeadWithGroups ($ files , ? int $ lowestPhpVersion = null ): void
102+ public function testDeadWithGroups ($ files , bool $ requirementsMet = true ): void
103103 {
104- $ this ->doTestDead ($ files , $ lowestPhpVersion );
104+ $ this ->doTestDead ($ files , $ requirementsMet );
105105 }
106106
107107 /**
108108 * @param string|non-empty-list<string> $files
109109 */
110- private function doTestDead ($ files , ? int $ lowestPhpVersion = null ): void
110+ private function doTestDead ($ files , bool $ requirementsMet ): void
111111 {
112- if ($ lowestPhpVersion !== null && PHP_VERSION_ID < $ lowestPhpVersion ) {
113- self ::markTestSkipped ('Requires PHP ' . $ lowestPhpVersion );
112+ if (! $ requirementsMet ) {
113+ self ::markTestSkipped ('Requirements not met ' );
114114 }
115115
116116 $ this ->analyseFiles (is_array ($ files ) ? $ files : [$ files ]);
@@ -313,13 +313,13 @@ public static function provideGroupingFiles(): iterable
313313 }
314314
315315 /**
316- * @return array<string, array{0: string|list<string>, 1?: int }>
316+ * @return array<string, array{0: string|list<string>, 1?: bool }>
317317 */
318318 public static function provideFiles (): iterable
319319 {
320320 // methods
321321 yield 'method-anonym ' => [__DIR__ . '/data/methods/anonym.php ' ];
322- yield 'method-enum ' => [__DIR__ . '/data/methods/enum.php ' , 8_01_00 ];
322+ yield 'method-enum ' => [__DIR__ . '/data/methods/enum.php ' , self :: requiresPhp ( 8_01_00 ) ];
323323 yield 'method-callables ' => [__DIR__ . '/data/methods/callables.php ' ];
324324 yield 'method-code ' => [__DIR__ . '/data/methods/basic.php ' ];
325325 yield 'method-ctor ' => [__DIR__ . '/data/methods/ctor.php ' ];
@@ -391,15 +391,11 @@ public static function provideFiles(): iterable
391391
392392 // providers
393393 yield 'provider-vendor ' => [__DIR__ . '/data/providers/vendor.php ' ];
394- yield 'provider-reflection ' => [__DIR__ . '/data/providers/reflection.php ' , 8_01_00 ];
395- yield 'provider-symfony ' => [__DIR__ . '/data/providers/symfony.php ' , 8_00_00 ];
396-
397- if (InstalledVersions::satisfies (new VersionParser (), 'symfony/dependency-injection ' , '^7.1 ' )) {
398- yield 'provider-symfony-7.1 ' => [__DIR__ . '/data/providers/symfony-gte71.php ' , 8_00_00 ];
399- }
400-
401- yield 'provider-phpunit ' => [__DIR__ . '/data/providers/phpunit.php ' , 8_00_00 ];
402- yield 'provider-doctrine ' => [__DIR__ . '/data/providers/doctrine.php ' , 8_00_00 ];
394+ yield 'provider-reflection ' => [__DIR__ . '/data/providers/reflection.php ' , self ::requiresPhp (8_01_00 )];
395+ yield 'provider-symfony ' => [__DIR__ . '/data/providers/symfony.php ' , self ::requiresPhp (8_00_00 )];
396+ yield 'provider-symfony-7.1 ' => [__DIR__ . '/data/providers/symfony-gte71.php ' , self ::requiresPhp (8_00_00 ) && self ::requiresPackage ('symfony/dependency-injection ' , '>= 7.1 ' )];
397+ yield 'provider-phpunit ' => [__DIR__ . '/data/providers/phpunit.php ' , self ::requiresPhp (8_00_00 )];
398+ yield 'provider-doctrine ' => [__DIR__ . '/data/providers/doctrine.php ' , self ::requiresPhp (8_00_00 )];
403399 yield 'provider-phpstan ' => [__DIR__ . '/data/providers/phpstan.php ' ];
404400 yield 'provider-nette ' => [__DIR__ . '/data/providers/nette.php ' ];
405401
@@ -598,4 +594,14 @@ private function createContainerMockWithSymfonyConfig(): Container
598594 return $ mock ;
599595 }
600596
597+ private static function requiresPhp (int $ lowestPhpVersion ): bool
598+ {
599+ return PHP_VERSION_ID >= $ lowestPhpVersion ;
600+ }
601+
602+ private static function requiresPackage (string $ package , string $ constraint ): bool
603+ {
604+ return InstalledVersions::satisfies (new VersionParser (), $ package , $ constraint );
605+ }
606+
601607}
0 commit comments