From d068f1535db404eff822ddf8f95bb638b4b6302b Mon Sep 17 00:00:00 2001 From: Brown Date: Wed, 16 Jan 2019 15:08:11 -0500 Subject: [PATCH] Fix issue with implemented class interface in subclass --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 3 +++ .../Internal/Analyzer/FunctionLikeAnalyzer.php | 1 + src/Psalm/Internal/Analyzer/MethodAnalyzer.php | 5 +++-- tests/MethodSignatureTest.php | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 26ee7e9f1..5da273a61 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -346,6 +346,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer $interface_storage, $implementer_method_storage, $interface_method_storage, + $this->fq_class_name, $implementer_visibility, $code_location, $implementer_method_storage->suppressed_issues, @@ -577,6 +578,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer $parent_storage, $pseudo_method_storage, $parent_method_storage, + $this->fq_class_name, $pseudo_method_storage->visibility ?: 0, $pseudo_method_storage->location, $storage->suppressed_issues, @@ -1078,6 +1080,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer $appearing_storage, $implementer_method_storage, $declaring_method_storage, + $this->fq_class_name, $implementer_method_storage->visibility, new CodeLocation($source, $stmt), $implementer_method_storage->suppressed_issues, diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index f93955483..700969cb2 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -224,6 +224,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer implements Statements $parent_storage, $storage, $parent_method_storage, + $fq_class_name, $implementer_visibility, $codeLocation, $storage->suppressed_issues diff --git a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php index 4117f808c..837e9c100 100644 --- a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php @@ -436,6 +436,7 @@ class MethodAnalyzer extends FunctionLikeAnalyzer ClassLikeStorage $guide_classlike_storage, MethodStorage $implementer_method_storage, MethodStorage $guide_method_storage, + string $implementer_called_class_name, int $implementer_visibility, CodeLocation $code_location, array $suppressed_issues, @@ -539,7 +540,7 @@ class MethodAnalyzer extends FunctionLikeAnalyzer $codebase, $implementer_method_storage->return_type, $implementer_classlike_storage->name, - $implementer_classlike_storage->name + $implementer_called_class_name ); $guide_method_storage_return_type = ExpressionAnalyzer::fleshOutType( @@ -669,7 +670,7 @@ class MethodAnalyzer extends FunctionLikeAnalyzer $codebase, $implementer_param->type, $implementer_classlike_storage->name, - $implementer_classlike_storage->name + $implementer_called_class_name ); $guide_method_storage_param_type = ExpressionAnalyzer::fleshOutType( diff --git a/tests/MethodSignatureTest.php b/tests/MethodSignatureTest.php index 6e293c20e..e3420044d 100644 --- a/tests/MethodSignatureTest.php +++ b/tests/MethodSignatureTest.php @@ -350,6 +350,22 @@ class MethodSignatureTest extends TestCase } }' ], + 'allowInterfaceImplementation' => [ + '