Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/DependencyInjection/ValidateIgnoredErrorsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
use function array_keys;
use function array_map;
use function count;
use function gettype;
use function implode;
use function is_array;
use function is_dir;
use function is_file;
use function is_string;
use function sprintf;
use const PHP_VERSION_ID;

Expand Down Expand Up @@ -167,8 +169,16 @@ public function getRegistry(): OperatorTypeSpecifyingExtensionRegistry
}

if (isset($ignoreError['path'])) {
if (!is_string($ignoreError['path'])) {
$errors[] = sprintf("Key 'path' of ignoreErrors expects a string, %s given. Did you mean 'paths'?", gettype($ignoreError['path']));
continue;
}
$ignorePaths = [$ignoreError['path']];
} elseif (isset($ignoreError['paths'])) {
if (!is_array($ignoreError['paths'])) {
$errors[] = sprintf("Key 'paths' of ignoreErrors expects an array, %s given. Did you mean 'path'?", gettype($ignoreError['paths']));
continue;
}
$ignorePaths = $ignoreError['paths'];
} else {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public static function dataValidateIgnoreErrors(): iterable
__DIR__ . '/invalidIgnoreErrors/count-without-path.neon',
'An ignoreErrors entry with count field must also contain path field.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/path-with-array-value.neon',
"Key 'path' of ignoreErrors expects a string, array given. Did you mean 'paths'?",
];
yield [
__DIR__ . '/invalidIgnoreErrors/paths-with-string-value.neon',
"Key 'paths' of ignoreErrors expects an array, string given. Did you mean 'path'?",
];
}

#[DataProvider('dataValidateIgnoreErrors')]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
identifier: some.identifier
path:
- tests/some-file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
ignoreErrors:
-
identifier: some.identifier
paths: tests/some-file.php
Loading