1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

#8330 - take into account that static type may have been unwrapped in ExistingAtomicStaticCallAnalyzer#hasStaticInType()

This commit is contained in:
someniatko 2022-07-29 12:31:37 +03:00
parent d7cd84c4eb
commit 0c652f72f6
2 changed files with 28 additions and 1 deletions

View File

@ -627,7 +627,7 @@ class ExistingAtomicStaticCallAnalyzer
*/
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;
}

View File

@ -3799,6 +3799,33 @@ class ClassTemplateTest extends TestCase
}
}',
],
'static is the return type of an analyzed static method' => [
'<?php
abstract class A
{
}
final class B extends A
{
public static function create(): static
{
return new self();
}
}
final class Service
{
public function do(): void
{
$this->acceptA(B::create());
}
private function acceptA(A $_a): void
{
}
}',
],
];
}