Skip to content

Commit

Permalink
Fix #1903 - inherit @method from parent interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jul 5, 2019
1 parent 457781b commit 422d994
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Psalm/Internal/Codebase/Populator.php
Expand Up @@ -640,6 +640,8 @@ private function populateInterfaceDataFromParentInterfaces(
$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);
Expand Down
31 changes: 31 additions & 0 deletions tests/MagicMethodAnnotationTest.php
Expand Up @@ -414,6 +414,37 @@ function sayHello() : string {
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());'
],
];
}

Expand Down

0 comments on commit 422d994

Please sign in to comment.