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:
parent
2665b7ec33
commit
e8b3f55013
@ -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
|
||||
|
@ -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;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user