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:
parent
dc64d4b1ca
commit
a089d8bd58
@ -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) {
|
||||
|
@ -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();
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user