From 52f9225356774accce656af9bd9210b5444019b9 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Thu, 30 Nov 2017 00:01:41 -0500 Subject: [PATCH] Add separate issues for implemented return type mismatch --- config.xsd | 2 ++ src/Psalm/Checker/FunctionLikeChecker.php | 6 ++++-- src/Psalm/Issue/ImplementedReturnTypeMismatch.php | 6 ++++++ src/Psalm/Issue/MoreSpecificImplementedReturnType.php | 6 ++++++ tests/InterfaceTest.php | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 src/Psalm/Issue/ImplementedReturnTypeMismatch.php create mode 100644 src/Psalm/Issue/MoreSpecificImplementedReturnType.php diff --git a/config.xsd b/config.xsd index bd74acd5e..e9f11d92c 100644 --- a/config.xsd +++ b/config.xsd @@ -95,6 +95,7 @@ + @@ -144,6 +145,7 @@ + diff --git a/src/Psalm/Checker/FunctionLikeChecker.php b/src/Psalm/Checker/FunctionLikeChecker.php index 8fffa4eeb..d6056817e 100644 --- a/src/Psalm/Checker/FunctionLikeChecker.php +++ b/src/Psalm/Checker/FunctionLikeChecker.php @@ -13,6 +13,7 @@ use Psalm\Context; use Psalm\EffectsAnalyser; use Psalm\FileManipulation\FunctionDocblockManipulator; use Psalm\FunctionLikeParameter; +use Psalm\Issue\ImplementedReturnTypeMismatch; use Psalm\Issue\InvalidDocblock; use Psalm\Issue\InvalidParamDefault; use Psalm\Issue\InvalidReturnType; @@ -22,6 +23,7 @@ use Psalm\Issue\MethodSignatureMismatch; use Psalm\Issue\MissingClosureReturnType; use Psalm\Issue\MissingReturnType; use Psalm\Issue\MixedInferredReturnType; +use Psalm\Issue\MoreSpecificImplementedReturnType; use Psalm\Issue\MoreSpecificReturnType; use Psalm\Issue\OverriddenMethodAccess; use Psalm\Issue\PossiblyUnusedVariable; @@ -643,7 +645,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo // is the declared return type more specific than the inferred one? if ($type_coerced) { if (IssueBuffer::accepts( - new MoreSpecificReturnType( + new MoreSpecificImplementedReturnType( 'The return type \'' . $guide_method_storage->return_type . '\' for ' . $cased_guide_method_id . ' is more specific than the implemented ' . 'return type for ' . $implementer_declaring_method_id . ' \'' @@ -656,7 +658,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo } } else { if (IssueBuffer::accepts( - new InvalidReturnType( + new ImplementedReturnTypeMismatch( 'The return type \'' . $guide_method_storage->return_type . '\' for ' . $cased_guide_method_id . ' is different to the implemented ' . 'return type for ' . $implementer_declaring_method_id . ' \'' diff --git a/src/Psalm/Issue/ImplementedReturnTypeMismatch.php b/src/Psalm/Issue/ImplementedReturnTypeMismatch.php new file mode 100644 index 000000000..5d7d9fea7 --- /dev/null +++ b/src/Psalm/Issue/ImplementedReturnTypeMismatch.php @@ -0,0 +1,6 @@ + 'InvalidReturnType', + 'error_message' => 'ImplementedReturnTypeMismatch', ], 'abstractInterfaceImplementsButCallUndefinedMethod' => [ '