Skip to content

Commit 5546ea5

Browse files
Simplify tests
1 parent c9bd900 commit 5546ea5

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,19 @@ public function testBug14328(): void
380380
$this->analyse([__DIR__ . '/data/bug-14328.php'], [
381381
[
382382
'Unreachable statement - code above always terminates.',
383-
25,
383+
20,
384384
],
385385
[
386386
'Unreachable statement - code above always terminates.',
387-
31,
387+
26,
388388
],
389389
[
390390
'Unreachable statement - code above always terminates.',
391-
37,
391+
32,
392392
],
393393
[
394394
'Unreachable statement - code above always terminates.',
395-
43,
395+
38,
396396
],
397397
]);
398398
}

tests/PHPStan/Rules/DeadCode/data/bug-14328.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,31 @@ public function returnThis(mixed $value): self {
99
return $this;
1010
}
1111

12-
public static function staticReturnSelf(mixed $value): self {
12+
public static function returnSelf(mixed $value): self {
1313
return new self();
1414
}
1515
}
1616

17-
class Bar {
18-
public static function doSomething(mixed $value): void {
19-
}
20-
}
21-
22-
function testMethodCall(): void {
17+
function testMethodCallChainedWithMethodCall(): void {
2318
$callback = fn (): never => throw new \Exception();
2419
$x = (new Foo())->returnThis($callback())->returnThis('x');
2520
$y = 'this will never run';
2621
}
2722

28-
function testStaticCall(): void {
23+
function testMethodCallChainedWithStaticCall(): void {
2924
$callback = fn (): never => throw new \Exception();
30-
Bar::doSomething($callback());
31-
$b = 'this will never run';
25+
$x = (new Foo())->returnThis($callback())::returnSelf('x');
26+
$y = 'this will never run';
3227
}
3328

3429
function testStaticCallChainedWithMethodCall(): void {
3530
$callback = fn (): never => throw new \Exception();
36-
$a = Foo::staticReturnSelf($callback())->returnThis('x');
31+
$a = Foo::returnSelf($callback())->returnThis('x');
3732
$b = 'this will never run either';
3833
}
3934

4035
function testStaticCallChainedWithStaticCall(): void {
4136
$callback = fn (): never => throw new \Exception();
42-
$a = Foo::staticReturnSelf($callback())::staticReturnSelf('x');
37+
$a = Foo::returnSelf($callback())::returnSelf('x');
4338
$b = 'this will never run either';
4439
}

0 commit comments

Comments
 (0)