1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

Track final-ness of class when evaluating trait returns

This commit is contained in:
Matt Brown 2020-10-25 12:20:18 -04:00 committed by Daniil Gentili
parent 2665b7ec33
commit e8b3f55013
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 16 additions and 0 deletions

View File

@ -361,6 +361,8 @@ class ReturnTypeAnalyzer
$parent_class = null;
$classlike_storage = null;
if ($self_fq_class_name) {
$classlike_storage = $codebase->classlike_storage_provider->get($self_fq_class_name);
$parent_class = $classlike_storage->parent_class;
@ -376,6 +378,7 @@ class ReturnTypeAnalyzer
true,
true,
$function_like_storage instanceof MethodStorage && $function_like_storage->final
|| ($classlike_storage && $classlike_storage->final)
);
if (!$inferred_return_type_parts

View File

@ -973,6 +973,19 @@ class TraitTest extends TestCase
use Foo;
}'
],
'staticReturnWithFinal' => [
'<?php
trait T {
/** @return static */
public function instance() {
return new static();
}
}
final class A {
use T;
}'
],
];
}