Skip to content

Commit

Permalink
Fix #3296 - propagate final flag to static calls in return types
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed May 4, 2020
1 parent dc64d4b commit a089d8b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Expand Up @@ -173,7 +173,11 @@ public static function fetch(
$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) {
Expand Down
30 changes: 30 additions & 0 deletions tests/Template/ClassTemplateExtendsTest.php
Expand Up @@ -4001,6 +4001,36 @@ public function foo($b): bool {
}
}'
],
'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();
}'
],
];
}

Expand Down

0 comments on commit a089d8b

Please sign in to comment.