Skip to content

Commit ef85fc8

Browse files
committed
Fix testBug6791 test file to not execute code
1 parent e52e32e commit ef85fc8

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

tests/PHPStan/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,15 @@ public function testBug6791(): void
276276
$this->analyse([__DIR__ . '/data/bug-6791.php'], [
277277
[
278278
'Dead catch - TypeError is never thrown in the try block.',
279-
17,
279+
22,
280280
],
281281
[
282282
'Dead catch - TypeError is never thrown in the try block.',
283-
29,
283+
34,
284284
],
285285
[
286286
'Dead catch - TypeError is never thrown in the try block.',
287-
33,
287+
38,
288288
],
289289
]);
290290
}

tests/PHPStan/Rules/Exceptions/data/bug-6791.php

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,33 @@ class Foo {
1111
public $array;
1212
}
1313

14-
$foo = new Foo();
15-
try {
16-
$foo->intArray = ["a"];
17-
} catch (\TypeError $e) {}
18-
19-
try {
20-
$foo->set = ["a"];
21-
} catch (\TypeError $e) {}
22-
23-
try {
24-
$foo->set = new \Ds\Set;
25-
} catch (\TypeError $e) {}
26-
27-
try {
28-
$foo->array = ["a"];
29-
} catch (\TypeError $e) {}
30-
31-
try {
32-
$foo->array = "non-array";
33-
} catch (\TypeError $e) {}
14+
class Bar
15+
{
16+
17+
public function doFoo()
18+
{
19+
$foo = new Foo();
20+
try {
21+
$foo->intArray = ["a"];
22+
} catch (\TypeError $e) {}
23+
24+
try {
25+
$foo->set = ["a"];
26+
} catch (\TypeError $e) {}
27+
28+
try {
29+
$foo->set = new \Ds\Set;
30+
} catch (\TypeError $e) {}
31+
32+
try {
33+
$foo->array = ["a"];
34+
} catch (\TypeError $e) {}
35+
36+
try {
37+
$foo->array = "non-array";
38+
} catch (\TypeError $e) {}
39+
}
40+
41+
}
42+
3443

0 commit comments

Comments
 (0)