|
12 | 12 | use RecursiveRegexIterator; |
13 | 13 | use RegexIterator; |
14 | 14 |
|
15 | | -class SniffsAndTests |
16 | | -{ |
17 | | - /** |
18 | | - * @var array<string> |
19 | | - */ |
20 | | - protected static $orgs = [ |
21 | | - 'PSR2R', |
22 | | - ]; |
23 | | - |
24 | | - /** |
25 | | - * @param string $path Path |
26 | | - * |
27 | | - * @return array<string, array<string, mixed>> |
28 | | - */ |
29 | | - public function untested(string $path): array |
30 | | - { |
31 | | - $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
32 | | - |
33 | | - $sniffs = []; |
34 | | - |
35 | | - foreach (static::$orgs as $org) { |
36 | | - $directoryIterator = new RecursiveDirectoryIterator($path . $org); |
37 | | - $recursiveIterator = new RecursiveIteratorIterator($directoryIterator); |
38 | | - $regexIterator = new RegexIterator($recursiveIterator, '#^.+/(\w+)/Sniffs/(\w+)/(\w+)Sniff\.php$#', RecursiveRegexIterator::GET_MATCH); |
39 | | - |
40 | | - foreach ($regexIterator as $match) { |
41 | | - $org = $match[1]; |
42 | | - $type = $match[2]; |
43 | | - $name = $match[3]; |
44 | | - $testFile = $path . 'tests' . DIRECTORY_SEPARATOR . $org . 'Sniffs' . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $name . 'SniffTest.php'; |
45 | | - $hasTest = file_exists($testFile); |
46 | | - if ($hasTest) { |
47 | | - continue; |
48 | | - } |
49 | | - |
50 | | - $key = $org . '.' . $type . '.' . $name; |
51 | | - $sniffs[$key] = [ |
52 | | - 'hasTest' => $hasTest, |
53 | | - ]; |
54 | | - } |
55 | | - } |
56 | | - |
57 | | - return $sniffs; |
58 | | - } |
| 15 | +class SniffsAndTests { |
| 16 | + |
| 17 | + /** |
| 18 | + * @var array<string> |
| 19 | + */ |
| 20 | + protected static $orgs = [ |
| 21 | + 'PSR2R', |
| 22 | + ]; |
| 23 | + |
| 24 | + /** |
| 25 | + * @param string $path Path |
| 26 | + * |
| 27 | + * @return array<string, array<string, mixed>> |
| 28 | + */ |
| 29 | + public function untested(string $path): array { |
| 30 | + $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
| 31 | + |
| 32 | + $sniffs = []; |
| 33 | + |
| 34 | + foreach (static::$orgs as $org) { |
| 35 | + $directoryIterator = new RecursiveDirectoryIterator($path . $org); |
| 36 | + $recursiveIterator = new RecursiveIteratorIterator($directoryIterator); |
| 37 | + $regexIterator = new RegexIterator($recursiveIterator, '#^.+/(\w+)/Sniffs/(\w+)/(\w+)Sniff\.php$#', RecursiveRegexIterator::GET_MATCH); |
| 38 | + |
| 39 | + foreach ($regexIterator as $match) { |
| 40 | + $org = $match[1]; |
| 41 | + $type = $match[2]; |
| 42 | + $name = $match[3]; |
| 43 | + $testFile = $path . 'tests' . DIRECTORY_SEPARATOR . $org . 'Sniffs' . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $name . 'SniffTest.php'; |
| 44 | + $hasTest = file_exists($testFile); |
| 45 | + if ($hasTest) { |
| 46 | + continue; |
| 47 | + } |
| 48 | + |
| 49 | + $key = $org . '.' . $type . '.' . $name; |
| 50 | + $sniffs[$key] = [ |
| 51 | + 'hasTest' => $hasTest, |
| 52 | + ]; |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + return $sniffs; |
| 57 | + } |
| 58 | + |
59 | 59 | } |
0 commit comments