Skip to content

Commit

Permalink
Collected PHP errors cannot be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 1, 2024
1 parent 3b6d061 commit 1d3f431
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Analyser/FileAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use const E_NOTICE;
use const E_PARSE;
use const E_STRICT;
use const E_USER_DEPRECATED;
use const E_USER_ERROR;
use const E_USER_NOTICE;
use const E_USER_WARNING;
Expand Down Expand Up @@ -322,7 +323,7 @@ private function collectErrors(array $analysedFiles): void

$errorMessage = sprintf('%s: %s', $this->getErrorLabel($errno), $errstr);

$this->allPhpErrors[] = (new Error($errorMessage, $errfile, $errline, true))->withIdentifier('phpstan.php');
$this->allPhpErrors[] = (new Error($errorMessage, $errfile, $errline, false))->withIdentifier('phpstan.php');

if ($errno === E_DEPRECATED) {
return true;
Expand All @@ -332,7 +333,7 @@ private function collectErrors(array $analysedFiles): void
return true;
}

$this->filteredPhpErrors[] = (new Error($errorMessage, $errfile, $errline, true))->withIdentifier('phpstan.php');
$this->filteredPhpErrors[] = (new Error($errorMessage, $errfile, $errline, $errno === E_USER_DEPRECATED))->withIdentifier('phpstan.php');

return true;
});
Expand All @@ -354,12 +355,16 @@ private function getErrorLabel(int $errno): string
return 'Parse error';
case E_NOTICE:
return 'Notice';
case E_DEPRECATED:
return 'Deprecated';
case E_USER_ERROR:
return 'User error (E_USER_ERROR)';
case E_USER_WARNING:
return 'User warning (E_USER_WARNING)';
case E_USER_NOTICE:
return 'User notice (E_USER_NOTICE)';
case E_USER_DEPRECATED:
return 'Deprecated (E_USER_DEPRECATED)';
case E_STRICT:
return 'Strict error (E_STRICT)';
}
Expand Down

0 comments on commit 1d3f431

Please sign in to comment.