mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #1903 - inherit @method from parent interfaces
This commit is contained in:
parent
457781bb02
commit
422d9944d8
@ -640,6 +640,8 @@ class Populator
|
||||
$parent_interfaces = array_merge($parent_interfaces, $parent_interface_storage->parent_interfaces);
|
||||
|
||||
$this->inheritMethodsFromParent($storage, $parent_interface_storage);
|
||||
|
||||
$storage->pseudo_methods += $parent_interface_storage->pseudo_methods;
|
||||
}
|
||||
|
||||
$storage->parent_interfaces = array_merge($parent_interfaces, $storage->parent_interfaces);
|
||||
|
@ -414,6 +414,37 @@ class MagicMethodAnnotationTest extends TestCase
|
||||
|
||||
echo makeConcrete()->sayHello();'
|
||||
],
|
||||
'inheritInterfacePseudoMethodsFromParent' => [
|
||||
'<?php
|
||||
interface ClassMetadata {}
|
||||
interface ORMClassMetadata extends ClassMetadata {}
|
||||
|
||||
interface EntityManagerInterface {
|
||||
public function getClassMetadata() : ClassMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method ORMClassMetadata getClassMetadata()
|
||||
* @method int getOtherMetadata()
|
||||
*/
|
||||
interface ORMEntityManagerInterface extends EntityManagerInterface{}
|
||||
|
||||
interface ConcreteEntityManagerInterface extends ORMEntityManagerInterface {}
|
||||
|
||||
/** @psalm-suppress InvalidReturnType */
|
||||
function em(): ORMEntityManagerInterface {}
|
||||
/** @psalm-suppress InvalidReturnType */
|
||||
function concreteEm(): ConcreteEntityManagerInterface {}
|
||||
|
||||
function test(ORMClassMetadata $metadata): void {}
|
||||
function test2(int $metadata): void {}
|
||||
|
||||
test(em()->getClassMetadata());
|
||||
test(concreteEm()->getClassMetadata());
|
||||
|
||||
test2(em()->getOtherMetadata());
|
||||
test2(concreteEm()->getOtherMetadata());'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user