File tree Expand file tree Collapse file tree 4 files changed +46
-16
lines changed
tests/PHPStan/Rules/Exceptions Expand file tree Collapse file tree 4 files changed +46
-16
lines changed Original file line number Diff line number Diff line change @@ -433,11 +433,6 @@ parameters:
433433 count : 6
434434 path : src/Reflection/InitializerExprTypeResolver.php
435435
436- -
437- message : " #^Dead catch \\ - PHPStan\\\\ BetterReflection\\\\ Identifier\\\\ Exception\\\\ InvalidIdentifierName is never thrown in the try block\\ .$#"
438- count : 1
439- path : src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php
440-
441436 -
442437 message : " #^Creating new PHPStan\\\\ Php8StubsMap is not covered by backward compatibility promise\\ . The class might change in a minor PHPStan version\\ .$#"
443438 count : 1
@@ -1772,11 +1767,6 @@ parameters:
17721767 count : 1
17731768 path : tests/PHPStan/Reflection/SignatureMap/Php8SignatureMapProviderTest.php
17741769
1775- -
1776- message : " #^Dead catch \\ - OutOfBoundsException is never thrown in the try block\\ .$#"
1777- count : 1
1778- path : tests/PHPStan/Reflection/SignatureMap/SignatureMapParserTest.php
1779-
17801770 -
17811771 message : """
17821772 #^Instantiation of deprecated class PHPStan\\\\Rules\\\\Arrays\\\\AppendedArrayItemTypeRule\\:
Original file line number Diff line number Diff line change @@ -1294,17 +1294,16 @@ private function processStmtNode(
12941294 // explicit only
12951295 if (count ($ matchingThrowPoints ) === 0 ) {
12961296 foreach ($ throwPoints as $ throwPointIndex => $ throwPoint ) {
1297- if (!$ throwPoint ->isExplicit ()) {
1298- continue ;
1299- }
1300-
13011297 foreach ($ catchTypes as $ catchTypeIndex => $ catchTypeItem ) {
13021298 if ($ catchTypeItem ->isSuperTypeOf ($ throwPoint ->getType ())->no ()) {
13031299 continue ;
13041300 }
13051301
1306- $ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
13071302 $ matchingCatchTypes [$ catchTypeIndex ] = true ;
1303+ if (!$ throwPoint ->isExplicit ()) {
1304+ continue ;
1305+ }
1306+ $ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
13081307 }
13091308 }
13101309 }
@@ -1322,7 +1321,6 @@ private function processStmtNode(
13221321 }
13231322
13241323 $ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
1325- $ matchingCatchTypes [$ catchTypeIndex ] = true ;
13261324 }
13271325 }
13281326 }
Original file line number Diff line number Diff line change @@ -475,4 +475,9 @@ public function testMagicMethods(): void
475475 ]);
476476 }
477477
478+ public function testBug9406 (): void
479+ {
480+ $ this ->analyse ([__DIR__ . '/data/bug-9406.php ' ], []);
481+ }
482+
478483}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug9406 ;
4+
5+ function foo (): void
6+ {
7+ if ($ _POST ['foo ' ] === null ) {
8+ throw new \InvalidArgumentException ('Foo ' );
9+ }
10+ }
11+
12+
13+ function app (): void
14+ {
15+ try {
16+ foo ();
17+
18+ if ($ _POST ['bar ' ] === null ) {
19+ throw new \RuntimeException ('Bar ' );
20+ }
21+ } catch (\RuntimeException |\InvalidArgumentException $ e ) {
22+
23+ }
24+ }
25+
26+ function app2 (): void
27+ {
28+ try {
29+ foo ();
30+
31+ if ($ _POST ['bar ' ] === null ) {
32+ throw new \RuntimeException ('Bar ' );
33+ }
34+ } catch (\InvalidArgumentException $ e ) {
35+
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments