Skip to content

Fix false positive on static calls on classes where both static and dynamic calls are possible #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 2 additions & 1 deletion src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleLevelHelper;
use PHPStan\TrinaryLogic;
use PHPStan\Type\ErrorType;
use PHPStan\Type\Type;
use function sprintf;
Expand Down Expand Up @@ -52,7 +53,7 @@ static function (Type $type) use ($name): bool {
}

$methodReflection = $type->getMethod($name, $scope);
if ($methodReflection->isStatic()) {
if ($methodReflection->isStatic() && $type->hasMethod('__callStatic') !== TrinaryLogic::createYes()) {
return [sprintf(
'Dynamic call to static method %s::%s().',
$methodReflection->getDeclaringClass()->getDisplayName(),
Expand Down