2626use function count ;
2727use function error_reporting ;
2828use function get_class ;
29+ use function hash ;
2930use function is_dir ;
3031use function is_file ;
3132use function restore_error_handler ;
4950final class FileAnalyser
5051{
5152
52- /** @var list< Error> */
53+ /** @var array<string, Error> */
5354 private array $ allPhpErrors = [];
5455
55- /** @var list< Error> */
56+ /** @var array<string, Error> */
5657 private array $ filteredPhpErrors = [];
5758
5859 public function __construct (
@@ -326,8 +327,8 @@ public function analyseFile(
326327
327328 return new FileAnalyserResult (
328329 $ fileErrors ,
329- $ this ->filteredPhpErrors ,
330- $ this ->allPhpErrors ,
330+ array_values ( $ this ->filteredPhpErrors ) ,
331+ array_values ( $ this ->allPhpErrors ) ,
331332 $ locallyIgnoredErrors ,
332333 $ fileCollectedData ,
333334 array_values (array_unique ($ fileDependencies )),
@@ -366,8 +367,9 @@ private function collectErrors(array $analysedFiles): void
366367 }
367368
368369 $ errorMessage = sprintf ('%s: %s ' , $ this ->getErrorLabel ($ errno ), $ errstr );
370+ $ errorSignature = hash ('sha256 ' , sprintf ('%s:%s::%s ' , $ errfile , $ errline , $ errorMessage ));
369371
370- $ this ->allPhpErrors [] = (new Error ($ errorMessage , $ errfile , $ errline , false ))->withIdentifier ('phpstan.php ' );
372+ $ this ->allPhpErrors [$ errorSignature ] = (new Error ($ errorMessage , $ errfile , $ errline , false ))->withIdentifier ('phpstan.php ' );
371373
372374 if ($ errno === E_DEPRECATED ) {
373375 return true ;
@@ -377,7 +379,7 @@ private function collectErrors(array $analysedFiles): void
377379 return true ;
378380 }
379381
380- $ this ->filteredPhpErrors [] = (new Error ($ errorMessage , $ errfile , $ errline , $ errno === E_USER_DEPRECATED ))->withIdentifier ('phpstan.php ' );
382+ $ this ->filteredPhpErrors [$ errorSignature ] = (new Error ($ errorMessage , $ errfile , $ errline , $ errno === E_USER_DEPRECATED ))->withIdentifier ('phpstan.php ' );
381383
382384 return true ;
383385 });
0 commit comments