File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types = 1 );
3+
4+ namespace Spaze \PHPStan \Rules \Disallowed ;
5+
6+ use DirectoryIterator ;
7+ use PHPStan \Testing \PHPStanTestCase ;
8+
9+ class AllRulesRegisteredTest extends PHPStanTestCase
10+ {
11+
12+ private const RULES_DIRS = [
13+ 'Calls ' ,
14+ 'Usages ' ,
15+ 'HelperRules ' ,
16+ ];
17+
18+
19+ public function testAllRulesRegistered (): void
20+ {
21+ foreach (self ::RULES_DIRS as $ directory ) {
22+ foreach (new DirectoryIterator (__DIR__ . '/../src/ ' . $ directory ) as $ file ) {
23+ if ($ file ->getExtension () === 'php ' ) {
24+ $ class = sprintf ('Spaze\PHPStan\Rules\Disallowed\%s\%s ' , $ directory , $ file ->getBasename ('.php ' ));
25+ if (!class_exists ($ class )) {
26+ continue ;
27+ }
28+ $ services = self ::getContainer ()->findServiceNamesByType ($ class );
29+ self ::assertNotEmpty ($ services , "{$ class } is not a registered rule " );
30+ }
31+ }
32+ }
33+ }
34+
35+
36+ public static function getAdditionalConfigFiles (): array
37+ {
38+ return [
39+ __DIR__ . '/../extension.neon ' ,
40+ ];
41+ }
42+
43+ }
You can’t perform that action at this time.
0 commit comments