Skip to content
Permalink
Browse files

Fix #1903 - inherit @method from parent interfaces

  • Loading branch information...
muglug committed Jul 5, 2019
1 parent 457781b commit 422d9944d88e01ae67235e65346b30faa9cf7e3b
Showing with 33 additions and 0 deletions.
  1. +2 −0 src/Psalm/Internal/Codebase/Populator.php
  2. +31 −0 tests/MagicMethodAnnotationTest.php
@@ -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);
@@ -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());'
],
];
}

0 comments on commit 422d994

Please sign in to comment.
You can’t perform that action at this time.