diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php index d7ac4ef16ff..3785023e269 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php @@ -627,7 +627,7 @@ private static function getMethodReturnType( */ private static function hasStaticInType(Type\TypeNode $type): bool { - if ($type instanceof TNamedObject && $type->value === 'static') { + if ($type instanceof TNamedObject && ($type->value === 'static' || $type->was_static)) { return true; } diff --git a/tests/Template/ClassTemplateTest.php b/tests/Template/ClassTemplateTest.php index 413f13add1f..afe14f81132 100644 --- a/tests/Template/ClassTemplateTest.php +++ b/tests/Template/ClassTemplateTest.php @@ -3799,6 +3799,33 @@ final public static function create(): static } }', ], + 'static is the return type of an analyzed static method' => [ + 'acceptA(B::create()); + } + + private function acceptA(A $_a): void + { + } + }', + ], ]; }