Skip to content

Commit d41f4f8

Browse files
committed
Cover dynamic static calls in tests
1 parent 2295fee commit d41f4f8

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace DynamicStaticCall;
4+
5+
class SomeClass {}
6+
7+
class Foo {
8+
/** @phpstan-pure */
9+
static public function doFoo():int
10+
{
11+
return 42;
12+
}
13+
}
14+
15+
final class FinalFoo {
16+
/** @phpstan-pure */
17+
static public function doFoo():int
18+
{
19+
return 42;
20+
}
21+
}
22+
23+
class Bar {
24+
/** @phpstan-pure */
25+
final static public function finalFoo():int
26+
{
27+
return 42;
28+
}
29+
}
30+
31+
32+
class Baz {
33+
function doBaz(Foo $foo, FinalFoo $finalFoo, Bar $bar):void {
34+
$foo::doFoo();
35+
$finalFoo::doFoo();
36+
$bar::finalFoo();
37+
}
38+
}

0 commit comments

Comments
 (0)