|
8 | 8 | use PHPStan\File\RelativePathHelper;
|
9 | 9 | use function array_keys;
|
10 | 10 | use function count;
|
11 |
| -use function implode; |
12 | 11 | use function ksort;
|
13 | 12 | use function preg_quote;
|
14 | 13 | use function sort;
|
@@ -74,22 +73,24 @@ public function formatErrors(
|
74 | 73 | foreach ($fileErrorsByMessage as $message => [$count, $identifiersInKeys]) {
|
75 | 74 | $identifiers = array_keys($identifiersInKeys);
|
76 | 75 | sort($identifiers);
|
77 |
| - $identifiersComment = ''; |
78 | 76 | if (count($identifiers) > 0) {
|
79 |
| - if (count($identifiers) === 1) { |
80 |
| - $identifiersComment = "\n\t// identifier: " . $identifiers[0]; |
81 |
| - } else { |
82 |
| - $identifiersComment = "\n\t// identifiers: " . implode(', ', $identifiers); |
| 77 | + foreach ($identifiers as $identifier) { |
| 78 | + $php .= sprintf( |
| 79 | + "\$ignoreErrors[] = [\n\t'message' => %s,\n\t'identifier' => %s,\n\t'count' => %d,\n\t'path' => __DIR__ . %s,\n];\n", |
| 80 | + var_export(Helpers::escape('#^' . preg_quote($message, '#') . '$#'), true), |
| 81 | + var_export(Helpers::escape($identifier), true), |
| 82 | + var_export($count, true), |
| 83 | + var_export(Helpers::escape($file), true), |
| 84 | + ); |
83 | 85 | }
|
| 86 | + } else { |
| 87 | + $php .= sprintf( |
| 88 | + "\$ignoreErrors[] = [\n\t'message' => %s,\n\t'count' => %d,\n\t'path' => __DIR__ . %s,\n];\n", |
| 89 | + var_export(Helpers::escape('#^' . preg_quote($message, '#') . '$#'), true), |
| 90 | + var_export($count, true), |
| 91 | + var_export(Helpers::escape($file), true), |
| 92 | + ); |
84 | 93 | }
|
85 |
| - |
86 |
| - $php .= sprintf( |
87 |
| - "\$ignoreErrors[] = [%s\n\t'message' => %s,\n\t'count' => %d,\n\t'path' => __DIR__ . %s,\n];\n", |
88 |
| - $identifiersComment, |
89 |
| - var_export(Helpers::escape('#^' . preg_quote($message, '#') . '$#'), true), |
90 |
| - var_export($count, true), |
91 |
| - var_export(Helpers::escape($file), true), |
92 |
| - ); |
93 | 94 | }
|
94 | 95 | }
|
95 | 96 |
|
|
0 commit comments