From 17ed440f2e8bfb2043c40ed8d85833d5fdf99dce Mon Sep 17 00:00:00 2001 From: Daniel Melchior Date: Tue, 18 Aug 2020 14:38:30 +0200 Subject: [PATCH] fix #4013: prevent exception when two mixins declare methods with same name (#4018) fixes #4013 --- .../Call/Method/AtomicMethodCallAnalyzer.php | 1 + tests/MixinAnnotationTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php index 77ea53d98..76ae394f3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php @@ -376,6 +376,7 @@ class AtomicMethodCallAnalyzer extends CallAnalyzer $mixin_class_storage = $codebase->classlike_storage_provider->get($mixin->value); $fq_class_name = $mixin_class_storage->name; + $mixin_class_storage->mixin_declaring_fqcln = $class_storage->mixin_declaring_fqcln; $class_storage = $mixin_class_storage; $naive_method_exists = true; $method_id = $new_method_id; diff --git a/tests/MixinAnnotationTest.php b/tests/MixinAnnotationTest.php index 25a9166ff..3f912496e 100644 --- a/tests/MixinAnnotationTest.php +++ b/tests/MixinAnnotationTest.php @@ -533,6 +533,38 @@ class MixinAnnotationTest extends TestCase return (new FooGrandChild)->other(); }' ], + 'multipleMixinsWithSameMethod' => [ + 'foo();' + ], ]; }