Skip to content

Commit

Permalink
Merge pull request #8335 from someniatko/issue-8330
Browse files Browse the repository at this point in the history
#8330 - take into account that `static` type may have been unwrapped in `hasStaticInType()`
  • Loading branch information
AndrolGenhald committed Jul 29, 2022
2 parents d7cd84c + 0c652f7 commit 489706b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Expand Up @@ -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;
}

Expand Down
27 changes: 27 additions & 0 deletions tests/Template/ClassTemplateTest.php
Expand Up @@ -3799,6 +3799,33 @@ final public static function create(): static
}
}',
],
'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
{
}
}',
],
];
}

Expand Down

0 comments on commit 489706b

Please sign in to comment.