1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

Fix #4767 - rescan directly-affected class-interface relationships

This commit is contained in:
Matt Brown 2020-12-04 01:19:51 -05:00 committed by Daniil Gentili
parent 48f55f3c3b
commit 73fc7d9491
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 52 additions and 3 deletions

View File

@ -603,7 +603,7 @@ class Populator
): void {
$parent_interfaces = [];
foreach ($storage->parent_interfaces as $parent_interface_lc => $_) {
foreach ($storage->direct_interface_parents as $parent_interface_lc => $_) {
try {
$parent_interface_lc = strtolower(
$this->classlikes->getUnAliasedName(
@ -696,7 +696,7 @@ class Populator
): void {
$extra_interfaces = [];
foreach ($storage->class_implements as $implemented_interface_lc => $_) {
foreach ($storage->direct_class_interfaces as $implemented_interface_lc => $_) {
try {
$implemented_interface_lc = strtolower(
$this->classlikes->getUnAliasedName(

View File

@ -102,7 +102,7 @@ class ClassLikeStorage
/**
* Interfaces this class implements directly
*
* @var array<string, string>
* @var array<lowercase-string, string>
*/
public $direct_class_interfaces = [];

View File

@ -1556,8 +1556,14 @@ class ClassTemplateExtendsTest extends TestCase
$this->elements = $elements;
}
/**
* @psalm-suppress InvalidReturnType
*/
public function getIterator()
{
/**
* @psalm-suppress InvalidReturnStatement
*/
return new ArrayIterator($this->elements);
}
@ -4173,6 +4179,49 @@ class ClassTemplateExtendsTest extends TestCase
return $foo->map($function);
}'
],
'extendStubbedInterfaceTwice' => [
'<?php
/**
* @template Tk of array-key
* @template Tv
*/
interface AA {}
/**
* @template Tk of array-key
* @template Tv
* @extends ArrayAccess<Tk, Tv>
*/
interface A extends ArrayAccess {
/**
* @psalm-param Tk $k
* @psalm-return Tv
*/
public function at($k);
}
/**
* @template Tk of array-key
* @template Tv
*
* @extends A<Tk, Tv>
*/
interface B extends A {}
/**
* @template Tk of array-key
* @template Tv
*
* @implements B<Tk, Tv>
*/
abstract class C implements B
{
/**
* @psalm-param Tk $k
* @psalm-return Tv
*/
public function at($k) { /** @var Tv */ return 1; }
}'
],
];
}