@@ -30,6 +30,7 @@ final class TableErrorFormatter implements ErrorFormatter
3030{
3131
3232 private const ERRORS_LIMIT = 1000 ;
33+ private const string FORCE_SHOW_ALL_ERRORS = 'PHPSTAN_TABLE_ERROR_FORMATTER_FORCE_SHOW_ALL_ERRORS ' ;
3334
3435 public function __construct (
3536 private RelativePathHelper $ relativePathHelper ,
@@ -90,11 +91,11 @@ public function formatErrors(
9091 $ fileErrors [$ fileSpecificError ->getFile ()][] = $ fileSpecificError ;
9192 }
9293
93- $ forceShowAll = getenv (' PHPSTAN_TABLE_ERROR_FORMATTER_FORCE_SHOW_ALL_ERRORS ' );
94+ $ forceShowAll = getenv (self :: FORCE_SHOW_ALL_ERRORS );
9495 if (in_array ($ forceShowAll , [false , '0 ' ], true )) {
9596 $ errorsBudget = self ::ERRORS_LIMIT ;
9697 } else {
97- $ errorsBudget = 0 ;
98+ $ errorsBudget = null ;
9899 }
99100
100101 $ printedErrors = 0 ;
@@ -164,7 +165,7 @@ public function formatErrors(
164165 }
165166
166167 $ printedErrors += count ($ rows );
167- if ($ errorsBudget > 0 && $ printedErrors > $ errorsBudget ) {
168+ if ($ errorsBudget !== null && $ printedErrors > $ errorsBudget ) {
168169 $ rows = array_slice ($ rows , 0 , $ errorsBudget - ($ printedErrors - count ($ rows )));
169170
170171 $ style ->table (['Line ' , $ this ->relativePathHelper ->getRelativePath ($ file )], $ rows );
@@ -183,15 +184,15 @@ public function formatErrors(
183184 $ style ->table (['' , 'Warning ' ], array_map (static fn (string $ warning ): array => ['' , OutputFormatter::escape ($ warning )], $ analysisResult ->getWarnings ()));
184185 }
185186
186- if ($ errorsBudget > 0 && $ printedErrors > $ errorsBudget ) {
187+ if ($ errorsBudget !== null && $ printedErrors > $ errorsBudget ) {
187188 $ style ->error (sprintf ('Found %s+ errors ' , self ::ERRORS_LIMIT ));
188189
189190 $ note = [];
190191 $ note [] = sprintf ('Result is limited to the first %d errors ' , $ errorsBudget );
191192 if ($ this ->level > 0 ) {
192193 $ note [] = '- Consider lowering the PHPStan level ' ;
193194 }
194- $ note [] = '- Pass PHPSTAN_TABLE_ERROR_FORMATTER_FORCE_SHOW_ALL_ERRORS =1 environment variable to show all errors ' ;
195+ $ note [] = sprintf ( '- Pass %s =1 environment variable to show all errors ' , self :: FORCE_SHOW_ALL_ERRORS ) ;
195196 $ note [] = '- Consider using PHPStan Pro for more comfortable error browsing ' ;
196197 $ note [] = ' Learn more: https://phpstan.com ' ;
197198 $ style ->note (implode ("\n" , $ note ));
0 commit comments