Skip to content

Commit 336500c

Browse files
committed
test all variants
1 parent 133a54f commit 336500c

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,9 +1659,11 @@ public function testBug13945Two(): void
16591659
public function testBug12246(): void
16601660
{
16611661
$errors = $this->runAnalyse(__DIR__ . '/data/bug-12246.php');
1662-
$this->assertCount(1, $errors);
1662+
$this->assertCount(4, $errors);
16631663
$this->assertSame('Do-while loop condition is always true.', $errors[0]->getMessage());
1664-
$this->assertSame(11, $errors[0]->getLine());
1664+
$this->assertSame('Do-while loop condition is always true.', $errors[1]->getMessage());
1665+
$this->assertSame('Do-while loop condition is always true.', $errors[2]->getMessage());
1666+
$this->assertSame('Cannot create callable from the new operator.', $errors[3]->getMessage());
16651667
}
16661668

16671669
public function testBigPhpdocArrayShape(): void

tests/PHPStan/Analyser/data/bug-12246.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Bug12246;
44

5-
final class SkipFirstClassCallableInDo
5+
final class FirstClassCallableInDo
66
{
77
public function getSubscribedEvents(): void
88
{
@@ -16,3 +16,44 @@ public function textElement(): int
1616
return 1;
1717
}
1818
}
19+
20+
final class StaticFirstClassCallableInDo
21+
{
22+
public function getSubscribedEvents(): void
23+
{
24+
do {
25+
26+
} while (self::textElement(...));
27+
}
28+
29+
static public function textElement(): int
30+
{
31+
return 1;
32+
}
33+
}
34+
35+
final class FunctionFirstClassCallableInDo
36+
{
37+
public function getSubscribedEvents(): void
38+
{
39+
do {
40+
41+
} while (doFoo(...));
42+
}
43+
}
44+
45+
function doFoo():int {
46+
return 1;
47+
}
48+
49+
final class InstationFirstClassCallableInDo
50+
{
51+
public function getSubscribedEvents(): void
52+
{
53+
do {
54+
55+
} while (new Foo(...));
56+
}
57+
}
58+
59+
class Foo {}

0 commit comments

Comments
 (0)