Skip to content

Commit 6b26f28

Browse files
authored
Merge branch refs/heads/2.1.x into 2.2.x
2 parents fc0e899 + e89f78e commit 6b26f28

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tests/PHPStan/Rules/Methods/CallToStaticMethodStatementWithoutSideEffectsRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ public function testBug10819(): void
121121
$this->analyse([__DIR__ . '/data/bug-10819.php'], $errors);
122122
}
123123

124+
public function testDynamicStaticCall(): void
125+
{
126+
$this->analyse([__DIR__ . '/data/dynamic-static-call.php'], []);
127+
}
128+
124129
#[RequiresPhp('>= 8.5')]
125130
public function testPipeOperator(): void
126131
{
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace DynamicStaticCall;
4+
5+
class Foo {
6+
/** @phpstan-pure */
7+
static public function doFoo():int
8+
{
9+
return 42;
10+
}
11+
}
12+
13+
final class FinalFoo {
14+
/** @phpstan-pure */
15+
static public function doFoo():int
16+
{
17+
return 42;
18+
}
19+
}
20+
21+
class Bar {
22+
/** @phpstan-pure */
23+
final static public function finalFoo():int
24+
{
25+
return 42;
26+
}
27+
}
28+
29+
30+
class Baz {
31+
function doBaz(Foo $foo, FinalFoo $finalFoo, Bar $bar):void {
32+
$foo::doFoo(); // no error, subclass could override static method with impure impl
33+
$finalFoo::doFoo(); // could be "Call to static method .. on a separate line has no effect", because final class
34+
$bar::finalFoo(); // could be "Call to static method .. on a separate line has no effect", because final method
35+
}
36+
}

0 commit comments

Comments
 (0)