diff --git a/src/Analyser/IgnoredError.php b/src/Analyser/IgnoredError.php index bec912e37d..190342926c 100644 --- a/src/Analyser/IgnoredError.php +++ b/src/Analyser/IgnoredError.php @@ -48,12 +48,20 @@ public static function shouldIgnore( ?string $path ): bool { - // normalize newlines to allow working with ignore-patterns independent of used OS newline-format $errorMessage = $error->getMessage(); + $ignoredMessage = ltrim($ignoredErrorPattern, '#^'); + + // fast exit in case the first char of the error is different while making sure its not a regex meta char (wildcard or similar) + if ($ignoredMessage[0] !== $errorMessage[0] && preg_quote($ignoredMessage[0]) === $ignoredMessage[0]) { + return false; + } + + // normalize newlines to allow working with ignore-patterns independent of used OS newline-format $errorMessage = str_replace(['\r\n', '\r'], '\n', $errorMessage); $ignoredErrorPattern = str_replace([preg_quote('\r\n'), preg_quote('\r')], preg_quote('\n'), $ignoredErrorPattern); if ($path !== null) { + if (\Nette\Utils\Strings::match($errorMessage, $ignoredErrorPattern) === null) { return false; }