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:
parent
45eaea1ed9
commit
a76fde5b98
@ -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" />
|
||||
|
@ -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
|
||||
|
6
src/Psalm/Issue/MismatchingDocblockParamType.php
Normal file
6
src/Psalm/Issue/MismatchingDocblockParamType.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class MismatchingDocblockParamType extends CodeError
|
||||
{
|
||||
}
|
6
src/Psalm/Issue/MismatchingDocblockReturnType.php
Normal file
6
src/Psalm/Issue/MismatchingDocblockReturnType.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class MismatchingDocblockReturnType extends CodeError
|
||||
{
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user