@@ -89,28 +89,28 @@ protected function getCollectors(): array
89
89
* @param string|non-empty-list<string> $files
90
90
* @dataProvider provideFiles
91
91
*/
92
- public function testDead ($ files , ? int $ lowestPhpVersion = null ): void
92
+ public function testDead ($ files , bool $ requirementsMet = true ): void
93
93
{
94
94
$ this ->emitErrorsInGroups = false ;
95
- $ this ->doTestDead ($ files , $ lowestPhpVersion );
95
+ $ this ->doTestDead ($ files , $ requirementsMet );
96
96
}
97
97
98
98
/**
99
99
* @param string|non-empty-list<string> $files
100
100
* @dataProvider provideFiles
101
101
*/
102
- public function testDeadWithGroups ($ files , ? int $ lowestPhpVersion = null ): void
102
+ public function testDeadWithGroups ($ files , bool $ requirementsMet = true ): void
103
103
{
104
- $ this ->doTestDead ($ files , $ lowestPhpVersion );
104
+ $ this ->doTestDead ($ files , $ requirementsMet );
105
105
}
106
106
107
107
/**
108
108
* @param string|non-empty-list<string> $files
109
109
*/
110
- private function doTestDead ($ files , ? int $ lowestPhpVersion = null ): void
110
+ private function doTestDead ($ files , bool $ requirementsMet ): void
111
111
{
112
- if ($ lowestPhpVersion !== null && PHP_VERSION_ID < $ lowestPhpVersion ) {
113
- self ::markTestSkipped ('Requires PHP ' . $ lowestPhpVersion );
112
+ if (! $ requirementsMet ) {
113
+ self ::markTestSkipped ('Requirements not met ' );
114
114
}
115
115
116
116
$ this ->analyseFiles (is_array ($ files ) ? $ files : [$ files ]);
@@ -313,13 +313,13 @@ public static function provideGroupingFiles(): iterable
313
313
}
314
314
315
315
/**
316
- * @return array<string, array{0: string|list<string>, 1?: int }>
316
+ * @return array<string, array{0: string|list<string>, 1?: bool }>
317
317
*/
318
318
public static function provideFiles (): iterable
319
319
{
320
320
// methods
321
321
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 ) ];
323
323
yield 'method-callables ' => [__DIR__ . '/data/methods/callables.php ' ];
324
324
yield 'method-code ' => [__DIR__ . '/data/methods/basic.php ' ];
325
325
yield 'method-ctor ' => [__DIR__ . '/data/methods/ctor.php ' ];
@@ -391,15 +391,11 @@ public static function provideFiles(): iterable
391
391
392
392
// providers
393
393
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 )];
403
399
yield 'provider-phpstan ' => [__DIR__ . '/data/providers/phpstan.php ' ];
404
400
yield 'provider-nette ' => [__DIR__ . '/data/providers/nette.php ' ];
405
401
@@ -598,4 +594,14 @@ private function createContainerMockWithSymfonyConfig(): Container
598
594
return $ mock ;
599
595
}
600
596
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
+
601
607
}
0 commit comments