|
11 | 11 | * the LICENSE file that was distributed with this source code. |
12 | 12 | */ |
13 | 13 |
|
| 14 | +namespace Utils; |
| 15 | + |
14 | 16 | require __DIR__ . '/../system/Test/bootstrap.php'; |
15 | 17 |
|
16 | 18 | use CodeIgniter\CLI\CLI; |
17 | 19 |
|
18 | 20 | $rstFilesWithTabs = (string) shell_exec('git grep -EIPn "\t" -- "*.rst"'); |
19 | 21 | $rstFilesWithTabs = explode("\n", $rstFilesWithTabs); |
20 | 22 | $rstFilesWithTabs = array_map(static function (string $line): array { |
21 | | - preg_match('/^(?P<file>[^:]+):(?P<line>[0-9]+):(?P<code>.+)$/', $line, $matches); |
| 23 | + preg_match('/^(?P<file>[^:]+):(?P<line>\d+):(?P<code>.+)$/', $line, $matches); |
22 | 24 |
|
23 | 25 | return [ |
24 | 26 | 'file' => $matches['file'], |
|
44 | 46 | "%s\n\n%s\n", |
45 | 47 | CLI::color('Tabs in RST files were detected:', 'light_gray', 'red'), |
46 | 48 | implode("\n", array_map( |
47 | | - static function (string $file, array $parts): string { |
48 | | - return sprintf( |
49 | | - "%s%s\n%s\n", |
50 | | - CLI::color('* in ', 'light_red'), |
51 | | - CLI::color($file, 'yellow'), |
52 | | - implode("\n", array_map(static function (array $line): string { |
53 | | - return sprintf( |
54 | | - '%s | %s', |
55 | | - str_pad($line['line'], 4, ' ', STR_PAD_LEFT), |
56 | | - str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']), |
57 | | - ); |
58 | | - }, $parts)), |
59 | | - ); |
60 | | - }, |
| 49 | + static fn (string $file, array $parts): string => sprintf( |
| 50 | + "%s%s\n%s\n", |
| 51 | + CLI::color('* in ', 'light_red'), |
| 52 | + CLI::color($file, 'yellow'), |
| 53 | + implode("\n", array_map(static fn (array $line): string => sprintf( |
| 54 | + '%s | %s', |
| 55 | + str_pad($line['line'], 4, ' ', STR_PAD_LEFT), |
| 56 | + str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']), |
| 57 | + ), $parts)), |
| 58 | + ), |
61 | 59 | array_keys($normalizedRstFilesWithTabs), |
62 | 60 | array_values($normalizedRstFilesWithTabs), |
63 | 61 | )), |
|
0 commit comments