File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
tests/PHPStan/Rules/Exceptions/data Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1209,6 +1209,7 @@ private function processStmtNode(
12091209
12101210 $ catchType = TypeCombinator::union (...array_map (static fn (Name $ name ): Type => new ObjectType ($ name ->toString ()), $ catchNode ->types ));
12111211 $ originalCatchType = $ catchType ;
1212+ $ isThrowable = $ originalCatchType instanceof TypeWithClassName && strtolower ($ originalCatchType ->getClassName ()) === 'throwable ' ;
12121213 $ catchType = TypeCombinator::remove ($ catchType , $ pastCatchTypes );
12131214 $ pastCatchTypes = TypeCombinator::union ($ pastCatchTypes , $ originalCatchType );
12141215 $ matchingThrowPoints = [];
@@ -1232,6 +1233,9 @@ private function processStmtNode(
12321233 if ($ isSuperType ->yes ()) {
12331234 continue ;
12341235 }
1236+ if ($ isThrowable ) {
1237+ continue ;
1238+ }
12351239 $ newThrowPoints [] = $ throwPoint ->subtractCatchType ($ catchType );
12361240 }
12371241 $ throwPoints = $ newThrowPoints ;
Original file line number Diff line number Diff line change @@ -57,4 +57,32 @@ public function doDolor(): void
5757 }
5858 }
5959
60+ public function doSit (): void
61+ {
62+ try {
63+ $ this ->throwsInterface ();
64+ } catch (\Throwable $ e ) {
65+
66+ }
67+ }
68+
69+ public function doSit2 (): void
70+ {
71+ try {
72+ $ this ->throwsInterface ();
73+ } catch (\InvalidArgumentException $ e ) {
74+
75+ } catch (\Throwable $ e ) {
76+
77+ }
78+ }
79+
80+ /**
81+ * @throws \ExtendsThrowable\ExtendsThrowable
82+ */
83+ private function throwsInterface (): void
84+ {
85+
86+ }
87+
6088}
You can’t perform that action at this time.
0 commit comments