Skip to content

Commit 154a83e

Browse files
More
1 parent c3da32a commit 154a83e

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

src/Analyser/RuleErrorTransformer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@ public static function getStartLineFromNode(Node $node): int
172172
{
173173
if (
174174
$node instanceof Node\Expr\PropertyFetch
175+
|| $node instanceof Node\Expr\StaticPropertyFetch
175176
|| $node instanceof Node\Expr\NullsafePropertyFetch
176177
|| $node instanceof Node\Expr\MethodCall
177178
|| $node instanceof Node\Expr\NullsafeMethodCall
179+
|| $node instanceof Node\Expr\StaticCall
178180
) {
179181
$line = $node->name->getStartLine();
180182
} elseif ($node instanceof PropertyAssignNode) {

tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,19 @@ public function testRestrictedInternalClassNameUsage(): void
909909
]);
910910
}
911911

912+
public function testBug14150(): void
913+
{
914+
$this->checkThisOnly = false;
915+
$this->checkExplicitMixed = true;
916+
$this->checkImplicitMixed = true;
917+
$this->analyse([__DIR__ . '/data/bug-14150-static.php'], [
918+
[
919+
'Call to an undefined static method Bug14150MethodStatic\HelloWorld::y().',
920+
21,
921+
],
922+
]);
923+
}
924+
912925
public function testBug13556(): void
913926
{
914927
$this->checkThisOnly = false;

tests/PHPStan/Rules/Methods/data/bug-14150-nullsafe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class HelloWorld
99
/**
1010
* @return $this
1111
*/
12-
public function x(): static
12+
public function x()
1313
{
1414
return $this;
1515
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Bug14150MethodStatic;
4+
5+
final class HelloWorld
6+
{
7+
public int $x = 5;
8+
9+
/**
10+
* @return $this
11+
*/
12+
public static function x()
13+
{
14+
return new self();
15+
}
16+
17+
public function testUnknownMethod(): void
18+
{
19+
(new HelloWorld())
20+
::x()
21+
::y();
22+
}
23+
}

tests/PHPStan/Rules/Methods/data/bug-14150.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class HelloWorld
99
/**
1010
* @return $this
1111
*/
12-
public function x(): static
12+
public function x()
1313
{
1414
return $this;
1515
}

0 commit comments

Comments
 (0)