1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #1766 - interpret interface parent extends properly

This commit is contained in:
Brown 2019-06-11 10:49:39 -04:00
parent 010f911d22
commit 7cf8c362f0
2 changed files with 43 additions and 0 deletions

View File

@ -701,6 +701,11 @@ class Populator
}
}
}
} elseif ($implemented_interface_storage->template_type_extends) {
$storage->template_type_extends = array_merge(
$storage->template_type_extends ?: [],
$implemented_interface_storage->template_type_extends
);
}
$extra_interfaces = array_merge($extra_interfaces, $implemented_interface_storage->parent_interfaces);

View File

@ -1937,6 +1937,44 @@ class TemplateExtendsTest extends TestCase
}
}'
],
'interfaceParentExtends' => [
'<?php
/** @template T */
interface Foo {
/** @return T */
public function getValue();
}
/** @extends Foo<int> */
interface FooChild extends Foo {}
class F implements FooChild {
public function getValue() {
return 10;
}
}
echo (new F())->getValue();'
],
'classParentExtends' => [
'<?php
/** @template T */
abstract class Foo {
/** @return T */
abstract public function getValue();
}
/** @extends Foo<int> */
abstract class FooChild extends Foo {}
class F extends FooChild {
public function getValue() {
return 10;
}
}
echo (new F())->getValue();'
],
];
}