diff --git a/src/Analyser/IgnoredErrorHelper.php b/src/Analyser/IgnoredErrorHelper.php index cf57521f3b..f9159dd61e 100644 --- a/src/Analyser/IgnoredErrorHelper.php +++ b/src/Analyser/IgnoredErrorHelper.php @@ -41,7 +41,6 @@ public function initialize(): IgnoredErrorHelperResult { $otherIgnoreErrors = []; $ignoreErrorsByFile = []; - $warnings = []; $errors = []; foreach ($this->ignoreErrors as $i => $ignoreError) { try { @@ -89,11 +88,11 @@ public function initialize(): IgnoredErrorHelperResult $validationResult = $this->ignoredRegexValidator->validate($ignoreMessage); $ignoredTypes = $validationResult->getIgnoredTypes(); if (count($ignoredTypes) > 0) { - $warnings[] = $this->createIgnoredTypesWarning($ignoreMessage, $ignoredTypes); + $errors[] = $this->createIgnoredTypesError($ignoreMessage, $ignoredTypes); } if ($validationResult->hasAnchorsInTheMiddle()) { - $warnings[] = $this->createAnchorInTheMiddleWarning($ignoreMessage); + $errors[] = $this->createAnchorInTheMiddleError($ignoreMessage); } if ($validationResult->areAllErrorsIgnored()) { @@ -109,11 +108,11 @@ public function initialize(): IgnoredErrorHelperResult $validationResult = $this->ignoredRegexValidator->validate($ignoreMessage); $ignoredTypes = $validationResult->getIgnoredTypes(); if (count($ignoredTypes) > 0) { - $warnings[] = $this->createIgnoredTypesWarning($ignoreMessage, $ignoredTypes); + $errors[] = $this->createIgnoredTypesError($ignoreMessage, $ignoredTypes); } if ($validationResult->hasAnchorsInTheMiddle()) { - $warnings[] = $this->createAnchorInTheMiddleWarning($ignoreMessage); + $errors[] = $this->createAnchorInTheMiddleError($ignoreMessage); } if ($validationResult->areAllErrorsIgnored()) { @@ -127,7 +126,7 @@ public function initialize(): IgnoredErrorHelperResult } } - return new IgnoredErrorHelperResult($this->fileHelper, $errors, $warnings, $otherIgnoreErrors, $ignoreErrorsByFile, $this->ignoreErrors, $this->reportUnmatchedIgnoredErrors); + return new IgnoredErrorHelperResult($this->fileHelper, $errors, $otherIgnoreErrors, $ignoreErrorsByFile, $this->ignoreErrors, $this->reportUnmatchedIgnoredErrors); } /** @@ -135,7 +134,7 @@ public function initialize(): IgnoredErrorHelperResult * @param array $ignoredTypes * @return string */ - private function createIgnoredTypesWarning(string $regex, array $ignoredTypes): string + private function createIgnoredTypesError(string $regex, array $ignoredTypes): string { return sprintf( "Ignored error %s has an unescaped '|' which leads to ignoring more errors than intended. Use '\\|' instead.\n%s", @@ -149,7 +148,7 @@ private function createIgnoredTypesWarning(string $regex, array $ignoredTypes): ); } - private function createAnchorInTheMiddleWarning(string $regex): string + private function createAnchorInTheMiddleError(string $regex): string { return sprintf("Ignored error %s has an unescaped anchor '$' in the middle. This leads to unintended behavior. Use '\\$' instead.", $regex); } diff --git a/src/Analyser/IgnoredErrorHelperResult.php b/src/Analyser/IgnoredErrorHelperResult.php index 4aa7b42bf1..df9eaa2ff2 100644 --- a/src/Analyser/IgnoredErrorHelperResult.php +++ b/src/Analyser/IgnoredErrorHelperResult.php @@ -12,9 +12,6 @@ class IgnoredErrorHelperResult /** @var string[] */ private array $errors; - /** @var string[] */ - private array $warnings; - /** @var array> */ private array $otherIgnoreErrors; @@ -29,7 +26,6 @@ class IgnoredErrorHelperResult /** * @param FileHelper $fileHelper * @param string[] $errors - * @param string[] $warnings * @param array> $otherIgnoreErrors * @param array>> $ignoreErrorsByFile * @param (string|mixed[])[] $ignoreErrors @@ -38,7 +34,6 @@ class IgnoredErrorHelperResult public function __construct( FileHelper $fileHelper, array $errors, - array $warnings, array $otherIgnoreErrors, array $ignoreErrorsByFile, array $ignoreErrors, @@ -47,7 +42,6 @@ public function __construct( { $this->fileHelper = $fileHelper; $this->errors = $errors; - $this->warnings = $warnings; $this->otherIgnoreErrors = $otherIgnoreErrors; $this->ignoreErrorsByFile = $ignoreErrorsByFile; $this->ignoreErrors = $ignoreErrors; @@ -62,14 +56,6 @@ public function getErrors(): array return $this->errors; } - /** - * @return string[] - */ - public function getWarnings(): array - { - return $this->warnings; - } - /** * @param Error[] $errors * @param string[] $analysedFiles diff --git a/src/Command/AnalyseApplication.php b/src/Command/AnalyseApplication.php index 4d1656b0c6..1618d2eb28 100644 --- a/src/Command/AnalyseApplication.php +++ b/src/Command/AnalyseApplication.php @@ -92,7 +92,6 @@ public function analyse( $ignoredErrorHelperResult = $this->ignoredErrorHelper->initialize(); if (count($ignoredErrorHelperResult->getErrors()) > 0) { $errors = $ignoredErrorHelperResult->getErrors(); - $warnings = []; $internalErrors = []; $savedResultCache = false; if ($errorOutput->isDebug()) { @@ -113,7 +112,6 @@ public function analyse( $analyserResult = $resultCacheResult->getAnalyserResult(); $internalErrors = $analyserResult->getInternalErrors(); $errors = $ignoredErrorHelperResult->process($analyserResult->getErrors(), $onlyFiles, $files, count($internalErrors) > 0 || $analyserResult->hasReachedInternalErrorsCountLimit()); - $warnings = $ignoredErrorHelperResult->getWarnings(); $savedResultCache = $resultCacheResult->isSaved(); if ($analyserResult->hasReachedInternalErrorsCountLimit()) { $errors[] = sprintf('Reached internal errors count limit of %d, exiting...', $this->internalErrorsCountLimit); @@ -138,7 +136,7 @@ public function analyse( $fileSpecificErrors, $notFileSpecificErrors, $internalErrors, - $warnings, + [], $defaultLevelUsed, $projectConfigFile, $savedResultCache diff --git a/tests/PHPStan/Analyser/AnalyserTest.php b/tests/PHPStan/Analyser/AnalyserTest.php index 81fbeccb53..22e953852b 100644 --- a/tests/PHPStan/Analyser/AnalyserTest.php +++ b/tests/PHPStan/Analyser/AnalyserTest.php @@ -472,7 +472,6 @@ private function runAnalyser( return array_merge( $errors, - $ignoredErrorHelperResult->getWarnings(), $analyserResult->getInternalErrors() ); }