1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

Merge pull request #10356 from robchett/inherit_magic_methods_from_mixin

Inherit magic methods from @mixin
This commit is contained in:
orklah 2023-11-13 21:30:39 +01:00 committed by GitHub
commit e85413dd54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -435,6 +435,12 @@ final class MissingMethodCallHandler
}
$ancestors = $static_class_storage->class_implements;
foreach ($static_class_storage->namedMixins as $namedObject) {
$type = $namedObject->value;
if ($type) {
$ancestors[$type] = true;
}
}
foreach ($ancestors as $fq_class_name => $_) {
$class_storage = $codebase->classlikes->getStorageFor($fq_class_name);

View File

@ -596,6 +596,28 @@ class MixinAnnotationTest extends TestCase
'$g' => 'list<FooModel>',
],
],
'mixinInheritMagicMethods' => [
'code' => '<?php
/**
* @method $this active()
*/
class A {
public function __call(string $name, array $arguments) {}
}
/**
* @mixin A
*/
class B {
public function __call(string $name, array $arguments) {}
}
$b = new B;
$c = $b->active();',
'assertions' => [
'$c' => 'B',
],
],
];
}