Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public function testBug10819(): void
$this->analyse([__DIR__ . '/data/bug-10819.php'], $errors);
}

public function testDynamicStaticCall(): void
{
$this->analyse([__DIR__ . '/data/dynamic-static-call.php'], []);
}

#[RequiresPhp('>= 8.5')]
public function testPipeOperator(): void
{
Expand Down
36 changes: 36 additions & 0 deletions tests/PHPStan/Rules/Methods/data/dynamic-static-call.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace DynamicStaticCall;

class Foo {
/** @phpstan-pure */
static public function doFoo():int
{
return 42;
}
}

final class FinalFoo {
/** @phpstan-pure */
static public function doFoo():int
{
return 42;
}
}

class Bar {
/** @phpstan-pure */
final static public function finalFoo():int
{
return 42;
}
}


class Baz {
function doBaz(Foo $foo, FinalFoo $finalFoo, Bar $bar):void {
$foo::doFoo(); // no error, subclass could override static method with impure impl
$finalFoo::doFoo(); // could be "Call to static method .. on a separate line has no effect", because final class
$bar::finalFoo(); // could be "Call to static method .. on a separate line has no effect", because final method
Comment on lines +33 to +34
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand the PR.
Is it worth covering this with a test with missing expectation ?

Or do you plan fixing this in the next PR ? (Then should it fix in the same ?)

Copy link
Copy Markdown
Contributor Author

@staabm staabm Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR is asserting the current state of things so we see when we change existing behaviour.

I think the possible

"Call to static method .. on a separate line has no effect"

are hardly useful, but they would not be wrong when they start to appear. (for 2 of the 3 examples)

}
}
Loading