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:
433
433
count : 6
434
434
path : src/Reflection/InitializerExprTypeResolver.php
435
435
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
-
441
436
-
442
437
message : " #^Creating new PHPStan\\\\ Php8StubsMap is not covered by backward compatibility promise\\ . The class might change in a minor PHPStan version\\ .$#"
443
438
count : 1
@@ -1772,11 +1767,6 @@ parameters:
1772
1767
count : 1
1773
1768
path : tests/PHPStan/Reflection/SignatureMap/Php8SignatureMapProviderTest.php
1774
1769
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
-
1780
1770
-
1781
1771
message : """
1782
1772
#^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(
1294
1294
// explicit only
1295
1295
if (count ($ matchingThrowPoints ) === 0 ) {
1296
1296
foreach ($ throwPoints as $ throwPointIndex => $ throwPoint ) {
1297
- if (!$ throwPoint ->isExplicit ()) {
1298
- continue ;
1299
- }
1300
-
1301
1297
foreach ($ catchTypes as $ catchTypeIndex => $ catchTypeItem ) {
1302
1298
if ($ catchTypeItem ->isSuperTypeOf ($ throwPoint ->getType ())->no ()) {
1303
1299
continue ;
1304
1300
}
1305
1301
1306
- $ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
1307
1302
$ matchingCatchTypes [$ catchTypeIndex ] = true ;
1303
+ if (!$ throwPoint ->isExplicit ()) {
1304
+ continue ;
1305
+ }
1306
+ $ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
1308
1307
}
1309
1308
}
1310
1309
}
@@ -1322,7 +1321,6 @@ private function processStmtNode(
1322
1321
}
1323
1322
1324
1323
$ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
1325
- $ matchingCatchTypes [$ catchTypeIndex ] = true ;
1326
1324
}
1327
1325
}
1328
1326
}
Original file line number Diff line number Diff line change @@ -475,4 +475,9 @@ public function testMagicMethods(): void
475
475
]);
476
476
}
477
477
478
+ public function testBug9406 (): void
479
+ {
480
+ $ this ->analyse ([__DIR__ . '/data/bug-9406.php ' ], []);
481
+ }
482
+
478
483
}
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