mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Add separate issues for implemented return type mismatch
This commit is contained in:
parent
0ea6540018
commit
52f9225356
@ -95,6 +95,7 @@
|
||||
<xs:element name="DuplicateClass" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="EmptyArrayAccess" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="ForbiddenCode" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="ImplementedReturnTypeMismatch" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="ImplicitToStringCast" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InaccessibleClassConstant" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InaccessibleMethod" type="IssueHandlerType" minOccurs="0" />
|
||||
@ -144,6 +145,7 @@
|
||||
<xs:element name="MixedStringOffsetAssignment" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MixedTypeCoercion" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MoreSpecificReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MoreSpecificImplementedReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="NoInterfaceProperties" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="NonStaticSelfCall" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="NullArgument" type="IssueHandlerType" minOccurs="0" />
|
||||
|
@ -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 . ' \''
|
||||
|
6
src/Psalm/Issue/ImplementedReturnTypeMismatch.php
Normal file
6
src/Psalm/Issue/ImplementedReturnTypeMismatch.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class ImplementedReturnTypeMismatch extends CodeError
|
||||
{
|
||||
}
|
6
src/Psalm/Issue/MoreSpecificImplementedReturnType.php
Normal file
6
src/Psalm/Issue/MoreSpecificImplementedReturnType.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class MoreSpecificImplementedReturnType extends CodeError
|
||||
{
|
||||
}
|
@ -416,7 +416,7 @@ class InterfaceTest extends TestCase
|
||||
return "hello";
|
||||
}
|
||||
}',
|
||||
'error_message' => 'InvalidReturnType',
|
||||
'error_message' => 'ImplementedReturnTypeMismatch',
|
||||
],
|
||||
'abstractInterfaceImplementsButCallUndefinedMethod' => [
|
||||
'<?php
|
||||
|
Loading…
Reference in New Issue
Block a user