From 86f503ab8273d834cce64ac311f0912df0fc6e0e Mon Sep 17 00:00:00 2001 From: robchett Date: Wed, 8 Nov 2023 10:40:53 +0000 Subject: [PATCH] Docblock psudo methods can be inherited via @mixin Fixes #3556 --- .../Call/Method/MissingMethodCallHandler.php | 6 +++++ tests/MixinAnnotationTest.php | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php index 6241127b5..14026d3d1 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php @@ -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); diff --git a/tests/MixinAnnotationTest.php b/tests/MixinAnnotationTest.php index f4f0372cd..807fc4a57 100644 --- a/tests/MixinAnnotationTest.php +++ b/tests/MixinAnnotationTest.php @@ -596,6 +596,28 @@ class MixinAnnotationTest extends TestCase '$g' => 'list', ], ], + 'mixinInheritMagicMethods' => [ + 'code' => 'active();', + 'assertions' => [ + '$c' => 'B', + ], + ], ]; }