1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix #3296 - propagate final flag to static calls in return types

This commit is contained in:
Brown 2020-05-03 20:42:00 -04:00
parent dc64d4b1ca
commit a089d8bd58
2 changed files with 35 additions and 1 deletions

View File

@ -173,7 +173,11 @@ class MethodCallReturnTypeFetcher
$return_type_candidate,
$self_fq_class_name,
$static_type,
$class_storage->parent_class
$class_storage->parent_class,
true,
false,
$static_type instanceof Type\Atomic\TNamedObject
&& $codebase->classlike_storage_provider->get($static_type->value)->final
);
if ($codebase->taint) {

View File

@ -4001,6 +4001,36 @@ class ClassTemplateExtendsTest extends TestCase
}
}'
],
'finalOverridesStatic' => [
'<?php
/**
* @template T
*/
class Collection {
/**
* @param T $item
*/
public function __construct($item) {}
}
abstract class Food {
/**
* @return Collection<static>
*/
public function getTypes() {
return new Collection(new static);
}
}
final class Cheese extends Food {}
/**
* @return Collection<Cheese>
*/
function test(Cheese $cheese): Collection {
return $cheese->getTypes();
}'
],
];
}