File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 2222use function array_sum ;
2323use function count ;
2424use function defined ;
25+ use function ini_get ;
2526use function is_string ;
2627use function max ;
2728use function memory_get_usage ;
2829use function parse_url ;
2930use function sprintf ;
31+ use function str_contains ;
3032use const PHP_URL_PORT ;
3133
3234class ParallelAnalyser
@@ -204,7 +206,26 @@ public function analyse(
204206 return ;
205207 }
206208
207- $ internalErrors [] = sprintf ('Child process error (exit code %d): %s ' , $ exitCode , $ output );
209+ $ memoryLimitMessage = 'PHPStan process crashed because it reached configured PHP memory limit ' ;
210+ if (str_contains ($ output , $ memoryLimitMessage )) {
211+ foreach ($ internalErrors as $ internalError ) {
212+ if (!str_contains ($ internalError , $ memoryLimitMessage )) {
213+ continue ;
214+ }
215+
216+ return ;
217+ }
218+ $ internalErrors [] = sprintf (sprintf (
219+ "<error>Child process error</error>: %s: %s \n%s \n" ,
220+ $ memoryLimitMessage ,
221+ ini_get ('memory_limit ' ),
222+ 'Increase your memory limit in php.ini or run PHPStan with --memory-limit CLI option. ' ,
223+ ));
224+ $ internalErrorsCount ++;
225+ return ;
226+ }
227+
228+ $ internalErrors [] = sprintf ('<error>Child process error</error> (exit code %d): %s ' , $ exitCode , $ output );
208229 $ internalErrorsCount ++;
209230 });
210231 $ this ->processPool ->attachProcess ($ processIdentifier , $ process );
You can’t perform that action at this time.
0 commit comments