1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Break out mismatching param/return type issues from InvalidDocblock

This commit is contained in:
Matt Brown 2018-01-05 12:11:12 -05:00
parent 45eaea1ed9
commit a76fde5b98
5 changed files with 21 additions and 6 deletions

View File

@ -134,6 +134,8 @@
<xs:element name="LoopInvalidation" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MethodSignatureMismatch" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MisplacedRequiredParam" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MismatchingDocblockParamType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MismatchingDocblockReturnType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingClosureReturnType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingConstructor" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingFile" type="IssueHandlerType" minOccurs="0" />

View File

@ -15,12 +15,13 @@ use Psalm\FileManipulation\FunctionDocblockManipulator;
use Psalm\FunctionLikeParameter;
use Psalm\Issue\FalsableInferredReturnType;
use Psalm\Issue\ImplementedReturnTypeMismatch;
use Psalm\Issue\InvalidDocblock;
use Psalm\Issue\InvalidParamDefault;
use Psalm\Issue\InvalidReturnType;
use Psalm\Issue\InvalidToString;
use Psalm\Issue\LessSpecificReturnType;
use Psalm\Issue\MethodSignatureMismatch;
use Psalm\Issue\MismatchingDocblockParamType;
use Psalm\Issue\MismatchingDocblockReturnType;
use Psalm\Issue\MissingClosureReturnType;
use Psalm\Issue\MissingReturnType;
use Psalm\Issue\MixedInferredReturnType;
@ -305,7 +306,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
)
) {
if (IssueBuffer::accepts(
new InvalidDocblock(
new MismatchingDocblockParamType(
'Parameter $' . $function_param->name . ' has wrong type \'' . $param_type .
'\', should be \'' . $signature_type . '\'',
$function_param->type_location
@ -412,7 +413,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
)
) {
if (IssueBuffer::accepts(
new InvalidDocblock(
new MismatchingDocblockReturnType(
'Docblock has incorrect return type \'' . $storage->return_type .
'\', should be \'' . $storage->signature_return_type . '\'',
$storage->return_type_location

View File

@ -0,0 +1,6 @@
<?php
namespace Psalm\Issue;
class MismatchingDocblockParamType extends CodeError
{
}

View File

@ -0,0 +1,6 @@
<?php
namespace Psalm\Issue;
class MismatchingDocblockReturnType extends CodeError
{
}

View File

@ -200,7 +200,7 @@ class AnnotationTest extends TestCase
'<?php
/**
* @param int $bar
* @psalm-suppress InvalidDocblock
* @psalm-suppress MismatchingDocblockParamType
*/
function fooFoo(array $bar) : void {
}',
@ -211,7 +211,7 @@ class AnnotationTest extends TestCase
/**
* @param B $bar
* @psalm-suppress InvalidDocblock
* @psalm-suppress MismatchingDocblockParamType
*/
function fooFoo(A $bar) : void {
}',
@ -429,7 +429,7 @@ class AnnotationTest extends TestCase
function fooFoo() : int {
return 5;
}',
'error_message' => 'InvalidDocblock',
'error_message' => 'MismatchingDocblockReturnType',
],
'propertyDocblockInvalidAssignment' => [
'<?php