@@ -210,6 +210,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
210
210
$ configuration ,
211
211
$ input ,
212
212
function (array $ errors , array $ locallyIgnoredErrors , array $ analysedFiles ) use ($ out , $ ignoredErrorHelperResult , $ isOnlyFiles , $ inceptionFiles ): void {
213
+ $ internalErrors = [];
214
+ foreach ($ errors as $ fileSpecificError ) {
215
+ if (!$ fileSpecificError ->hasNonIgnorableException ()) {
216
+ continue ;
217
+ }
218
+
219
+ $ internalErrors [] = $ this ->transformErrorIntoInternalError ($ fileSpecificError );
220
+ }
221
+
222
+ if (count ($ internalErrors ) > 0 ) {
223
+ $ out ->write (['action ' => 'analysisCrash ' , 'data ' => [
224
+ 'internalErrors ' => $ internalErrors ,
225
+ ]]);
226
+ return ;
227
+ }
228
+
213
229
[$ errors , $ ignoredErrors ] = $ this ->filterErrors ($ errors , $ ignoredErrorHelperResult , $ isOnlyFiles , $ inceptionFiles , false );
214
230
foreach ($ locallyIgnoredErrors as $ locallyIgnoredError ) {
215
231
$ ignoredErrors [] = [$ locallyIgnoredError , null ];
@@ -249,22 +265,7 @@ function (array $errors, array $locallyIgnoredErrors, array $analysedFiles) use
249
265
continue ;
250
266
}
251
267
252
- $ message = $ fileSpecificError ->getMessage ();
253
- $ metadata = $ fileSpecificError ->getMetadata ();
254
- if (
255
- $ fileSpecificError ->getIdentifier () === 'phpstan.internal '
256
- && array_key_exists (InternalError::STACK_TRACE_AS_STRING_METADATA_KEY , $ metadata )
257
- ) {
258
- $ message = sprintf ('Internal error: %s ' , $ message );
259
- }
260
-
261
- $ internalErrors [] = new InternalError (
262
- $ message ,
263
- sprintf ('analysing file %s ' , $ fileSpecificError ->getTraitFilePath () ?? $ fileSpecificError ->getFilePath ()),
264
- $ metadata [InternalError::STACK_TRACE_METADATA_KEY ] ?? [],
265
- $ metadata [InternalError::STACK_TRACE_AS_STRING_METADATA_KEY ] ?? null ,
266
- true ,
267
- );
268
+ $ internalErrors [] = $ this ->transformErrorIntoInternalError ($ fileSpecificError );
268
269
}
269
270
270
271
$ hasInternalErrors = count ($ internalErrors ) > 0 || $ finalizerResult ->getAnalyserResult ()->hasReachedInternalErrorsCountLimit ();
@@ -327,6 +328,26 @@ function (array $errors, array $locallyIgnoredErrors, array $analysedFiles) use
327
328
return 0 ;
328
329
}
329
330
331
+ private function transformErrorIntoInternalError (Error $ error ): InternalError
332
+ {
333
+ $ message = $ error ->getMessage ();
334
+ $ metadata = $ error ->getMetadata ();
335
+ if (
336
+ $ error ->getIdentifier () === 'phpstan.internal '
337
+ && array_key_exists (InternalError::STACK_TRACE_AS_STRING_METADATA_KEY , $ metadata )
338
+ ) {
339
+ $ message = sprintf ('Internal error: %s ' , $ message );
340
+ }
341
+
342
+ return new InternalError (
343
+ $ message ,
344
+ sprintf ('analysing file %s ' , $ error ->getTraitFilePath () ?? $ error ->getFilePath ()),
345
+ $ metadata [InternalError::STACK_TRACE_METADATA_KEY ] ?? [],
346
+ $ metadata [InternalError::STACK_TRACE_AS_STRING_METADATA_KEY ] ?? null ,
347
+ true ,
348
+ );
349
+ }
350
+
330
351
/**
331
352
* @param string[] $inceptionFiles
332
353
* @param array<Error> $errors
0 commit comments