File tree Expand file tree Collapse file tree
tests/PHPStan/Rules/Variables/data Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1878,7 +1878,6 @@ public function processStmtNode(
18781878
18791879 // explicit only
18801880 $ onlyExplicitIsThrow = true ;
1881- $ hasDirectExplicitNonThrowMatch = false ;
18821881 if (count ($ matchingThrowPoints ) === 0 ) {
18831882 foreach ($ throwPoints as $ throwPointIndex => $ throwPoint ) {
18841883 foreach ($ catchTypes as $ catchTypeIndex => $ catchTypeItem ) {
@@ -1896,22 +1895,15 @@ public function processStmtNode(
18961895 && !($ throwNode instanceof Node \Stmt \Expression && $ throwNode ->expr instanceof Expr \Throw_)
18971896 ) {
18981897 $ onlyExplicitIsThrow = false ;
1899- $ throwType = $ throwPoint ->getType ();
1900- $ innerTypes = $ throwType instanceof UnionType ? $ throwType ->getTypes () : [$ throwType ];
1901- foreach ($ innerTypes as $ innerThrowType ) {
1902- if ($ catchTypeItem ->isSuperTypeOf ($ innerThrowType )->yes ()) {
1903- $ hasDirectExplicitNonThrowMatch = true ;
1904- break ;
1905- }
1906- }
19071898 }
1899+
19081900 $ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
19091901 }
19101902 }
19111903 }
19121904
19131905 // implicit only
1914- if (count ($ matchingThrowPoints ) === 0 || $ onlyExplicitIsThrow || ! $ hasDirectExplicitNonThrowMatch ) {
1906+ if (count ($ matchingThrowPoints ) === 0 || $ onlyExplicitIsThrow ) {
19151907 foreach ($ throwPoints as $ throwPointIndex => $ throwPoint ) {
19161908 if ($ throwPoint ->isExplicit ()) {
19171909 continue ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class HelloWorld
66{
77 public function test (): void
88 {
9- global $ pdo ;
9+ $ pdo = new \ PDO ( ' 123 ' ) ;
1010
1111 try {
1212 $ this ->maybeThrows ();
@@ -36,7 +36,7 @@ class HelloWorld2
3636{
3737 public function test2 (): void
3838 {
39- global $ pdo ;
39+ $ pdo = new \ PDO ( ' 123 ' ) ;
4040
4141 try {
4242 $ this ->maybeThrows2 ();
@@ -65,7 +65,7 @@ class HelloWorld3
6565{
6666 public function test3 (): void
6767 {
68- global $ pdo ;
68+ $ pdo = new \ PDO ( ' 123 ' ) ;
6969
7070 try {
7171 $ this ->maybeThrows3 ();
You can’t perform that action at this time.
0 commit comments