2525use PHPStan \PhpDocParser \Ast \Type \UnionTypeNode ;
2626use PHPStan \PhpDocParser \Parser \TokenIterator ;
2727use TypePHP \Internal \Ast \Elimination \StaticTypeEvaluator ;
28+ use TypePHP \Internal \Diagnostic \DebugLog ;
2829use TypePHP \Internal \Docblock \DocblockExtractor ;
2930use TypePHP \Internal \Docblock \DocblockNormalizer ;
3031use TypePHP \Internal \Docblock \DocblockParser ;
@@ -540,7 +541,8 @@ private function collectUnprovenClassConstantChecks(Node\Stmt\Class_ $node, stri
540541 $ checkStmt ->setAttribute ('typephp_injected ' , true );
541542 $ injectedStmts [] = $ checkStmt ;
542543 }
543- } catch (\Throwable ) {
544+ } catch (\Throwable $ e ) {
545+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
544546 }
545547 }
546548
@@ -603,7 +605,8 @@ private function collectUnprovenGlobalConstantChecks(Node\Stmt\Const_ $node): ar
603605 $ checkStmt ->setAttribute ('typephp_injected ' , true );
604606 $ injectedStmts [] = $ checkStmt ;
605607 }
606- } catch (\Throwable ) {
608+ } catch (\Throwable $ e ) {
609+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
607610 }
608611
609612 return $ injectedStmts ;
@@ -901,7 +904,8 @@ private function processClassPropertyDefaults(Node\Stmt\Class_ $node): void
901904 if ($ classTemplates !== [] && DocblockParser ::typeReferencesTemplate ($ propTypeNode , $ classTemplates )) {
902905 continue ;
903906 }
904- } catch (\Throwable ) {
907+ } catch (\Throwable $ e ) {
908+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
905909 }
906910 }
907911
@@ -984,7 +988,8 @@ private function resolveClassTemplatesForDefaults(Node\Stmt\Class_ $node): array
984988 try {
985989 $ phpDocNode = DocblockExtractor ::parseDocString ($ nodeDoc ->getText ());
986990 $ classTemplates = DocblockExtractor ::extractTemplates ($ phpDocNode );
987- } catch (\Throwable ) {
991+ } catch (\Throwable $ e ) {
992+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
988993 }
989994 }
990995
@@ -994,7 +999,8 @@ private function resolveClassTemplatesForDefaults(Node\Stmt\Class_ $node): array
994999 try {
9951000 $ loadedTemplates = DocblockParser ::parseClassTemplates ($ className );
9961001 $ classTemplates = [...$ classTemplates , ...$ loadedTemplates ];
997- } catch (\Throwable ) {
1002+ } catch (\Throwable $ e ) {
1003+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
9981004 }
9991005 }
10001006 }
@@ -1006,7 +1012,8 @@ private function resolveClassTemplatesForDefaults(Node\Stmt\Class_ $node): array
10061012 try {
10071013 $ parentTemplates = DocblockParser ::parseClassTemplates ($ parentClass );
10081014 $ classTemplates = [...$ classTemplates , ...$ parentTemplates ];
1009- } catch (\Throwable ) {
1015+ } catch (\Throwable $ e ) {
1016+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
10101017 }
10111018 } else {
10121019 $ parentFile = self ::findClassFileWithoutAutoload ($ parentClass );
@@ -1022,7 +1029,8 @@ private function resolveClassTemplatesForDefaults(Node\Stmt\Class_ $node): array
10221029 $ classTemplates = [...$ classTemplates , ...DocblockExtractor ::extractTemplates ($ phpDocNode )];
10231030 }
10241031 }
1025- } catch (\Throwable ) {
1032+ } catch (\Throwable $ e ) {
1033+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
10261034 }
10271035 }
10281036 }
@@ -1104,7 +1112,8 @@ private function enterClassLike(Node\Stmt\Class_|Node\Stmt\Interface_|Node\Stmt\
11041112 try {
11051113 $ phpDocNode = DocblockExtractor ::parseDocString ($ doc ->getText ());
11061114 $ templates = DocblockExtractor ::extractTemplates ($ phpDocNode );
1107- } catch (\Throwable ) {
1115+ } catch (\Throwable $ e ) {
1116+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
11081117 }
11091118 }
11101119 $ hasTemplates = $ templates !== [];
@@ -1194,7 +1203,8 @@ private function enterClassLike(Node\Stmt\Class_|Node\Stmt\Interface_|Node\Stmt\
11941203 try {
11951204 $ methodPhpDoc = DocblockExtractor ::parseDocString ($ methodDoc ->getText ());
11961205 $ methodParamTags = DocblockExtractor ::getParamTags ($ methodPhpDoc );
1197- } catch (\Throwable ) {
1206+ } catch (\Throwable $ e ) {
1207+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
11981208 }
11991209 }
12001210
@@ -1261,7 +1271,8 @@ private function extractClassLikeAliases(
12611271 try {
12621272 $ phpDocNode = DocblockExtractor ::parseDocString ($ doc ->getText ());
12631273 $ this ->collectAliasesFromPhpDocInFile ($ phpDocNode , $ aliases , $ this ->currentFile , $ this ->currentNamespace , $ visited );
1264- } catch (\Throwable ) {
1274+ } catch (\Throwable $ e ) {
1275+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
12651276 }
12661277 }
12671278
@@ -1412,7 +1423,9 @@ class_exists($fqcn, false)
14121423 self ::collectRawAliasesFromAstDoc ($ phpDocNode , $ aliases , '' , '' , [], $ localClassAliases , $ visited );
14131424
14141425 return self ::$ astClassAliasesCache [$ fqcn ] = $ aliases ;
1415- } catch (\Throwable ) {
1426+ } catch (\Throwable $ e ) {
1427+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
1428+
14161429 return self ::$ astClassAliasesCache [$ fqcn ] = [];
14171430 }
14181431 }
@@ -1443,7 +1456,8 @@ class_exists($fqcn, false)
14431456 }
14441457
14451458 $ aliases = self ::extractTargetClassAliasesFromStmts ($ stmts , $ fqcn , $ filePath , $ localClassAliases , $ visited );
1446- } catch (\Throwable ) {
1459+ } catch (\Throwable $ e ) {
1460+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
14471461 $ aliases = [];
14481462 }
14491463
@@ -1545,7 +1559,8 @@ private static function scanClassLikesForAliases(
15451559 try {
15461560 $ phpDocNode = DocblockExtractor ::parseDocString ($ doc ->getText ());
15471561 self ::collectRawAliasesFromAstDoc ($ phpDocNode , $ aliases , $ filePath , $ namespace , $ imports , $ localClassAliases , $ visited );
1548- } catch (\Throwable ) {
1562+ } catch (\Throwable $ e ) {
1563+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
15491564 }
15501565 }
15511566
@@ -1893,6 +1908,7 @@ private function propagateShapeTypesToDestructuring(Node\Expr\List_|Node\Expr\Ar
18931908 }
18941909 }
18951910 } catch (\Throwable $ e ) {
1911+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
18961912 }
18971913 }
18981914
@@ -1940,7 +1956,8 @@ private function handleAssign(Node\Expr\Assign $node): ?Node
19401956 [$ typeParser , $ lexer ] = DocblockExtractor ::getTypeParserComponents ();
19411957 $ tokens = new TokenIterator ($ lexer ->tokenize (DocblockNormalizer ::normalize ($ typeString )));
19421958 $ parsedType = $ typeParser ->parse ($ tokens );
1943- } catch (\Throwable ) {
1959+ } catch (\Throwable $ e ) {
1960+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
19441961 }
19451962
19461963 if ($ expr instanceof Node \Expr \New_ && $ parsedType !== null ) {
@@ -2758,7 +2775,8 @@ private function registerParamInferredTypes(array $params, ?string $docText = nu
27582775 foreach (DocblockExtractor ::getParamTags ($ phpDocNode ) as $ pName => $ pTag ) {
27592776 $ docParamTypes [$ pName ] = (string ) $ pTag ->type ;
27602777 }
2761- } catch (\Throwable ) {
2778+ } catch (\Throwable $ e ) {
2779+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
27622780 }
27632781 }
27642782
@@ -3286,7 +3304,8 @@ private function parseUnsetTypeCached(string $typeString): ?TypeNode
32863304 self ::$ parsedUnsetTypeCache [$ typeString ] = $ parsed ;
32873305
32883306 return $ parsed ;
3289- } catch (\Throwable ) {
3307+ } catch (\Throwable $ e ) {
3308+ DebugLog ::swallowed ($ e ); // @codeCoverageIgnore
32903309 self ::$ parsedUnsetTypeCache [$ typeString ] = false ;
32913310
32923311 return null ;
0 commit comments