mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Split UntypedParam into MissingParamType and MissingClosureParamType
This commit is contained in:
parent
1c34dbe289
commit
3482ee3b39
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
<PropertyNotSetInConstructor errorLevel="info" />
|
<PropertyNotSetInConstructor errorLevel="info" />
|
||||||
<MissingConstructor errorLevel="info" />
|
<MissingConstructor errorLevel="info" />
|
||||||
<UntypedParam errorLevel="info" />
|
<MissingClosureParamType errorLevel="info" />
|
||||||
|
<MissingParamType errorLevel="info" />
|
||||||
</issueHandlers>
|
</issueHandlers>
|
||||||
</psalm>
|
</psalm>
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
|
|
||||||
<PropertyNotSetInConstructor errorLevel="info" />
|
<PropertyNotSetInConstructor errorLevel="info" />
|
||||||
<MissingConstructor errorLevel="info" />
|
<MissingConstructor errorLevel="info" />
|
||||||
<UntypedParam errorLevel="info" />
|
<MissingClosureParamType errorLevel="info" />
|
||||||
|
<MissingParamType errorLevel="info" />
|
||||||
|
|
||||||
<!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->
|
<!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
|
|
||||||
<PropertyNotSetInConstructor errorLevel="info" />
|
<PropertyNotSetInConstructor errorLevel="info" />
|
||||||
<MissingConstructor errorLevel="info" />
|
<MissingConstructor errorLevel="info" />
|
||||||
<UntypedParam errorLevel="info" />
|
<MissingClosureParamType errorLevel="info" />
|
||||||
|
<MissingParamType errorLevel="info" />
|
||||||
|
|
||||||
<!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->
|
<!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->
|
||||||
|
|
||||||
|
@ -141,9 +141,11 @@
|
|||||||
<xs:element name="MisplacedRequiredParam" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MisplacedRequiredParam" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MismatchingDocblockParamType" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MismatchingDocblockParamType" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MismatchingDocblockReturnType" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MismatchingDocblockReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||||
|
<xs:element name="MissingClosureParamType" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MissingClosureReturnType" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MissingClosureReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MissingConstructor" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MissingConstructor" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MissingFile" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MissingFile" type="IssueHandlerType" minOccurs="0" />
|
||||||
|
<xs:element name="MissingParamType" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MissingPropertyType" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MissingPropertyType" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MissingReturnType" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MissingReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||||
<xs:element name="MissingDocblockType" type="IssueHandlerType" minOccurs="0" />
|
<xs:element name="MissingDocblockType" type="IssueHandlerType" minOccurs="0" />
|
||||||
|
@ -22,7 +22,9 @@ use Psalm\Issue\LessSpecificReturnType;
|
|||||||
use Psalm\Issue\MethodSignatureMismatch;
|
use Psalm\Issue\MethodSignatureMismatch;
|
||||||
use Psalm\Issue\MismatchingDocblockParamType;
|
use Psalm\Issue\MismatchingDocblockParamType;
|
||||||
use Psalm\Issue\MismatchingDocblockReturnType;
|
use Psalm\Issue\MismatchingDocblockReturnType;
|
||||||
|
use Psalm\Issue\MissingClosureParamType;
|
||||||
use Psalm\Issue\MissingClosureReturnType;
|
use Psalm\Issue\MissingClosureReturnType;
|
||||||
|
use Psalm\Issue\MissingParamType;
|
||||||
use Psalm\Issue\MissingReturnType;
|
use Psalm\Issue\MissingReturnType;
|
||||||
use Psalm\Issue\MixedInferredReturnType;
|
use Psalm\Issue\MixedInferredReturnType;
|
||||||
use Psalm\Issue\MoreSpecificImplementedParamType;
|
use Psalm\Issue\MoreSpecificImplementedParamType;
|
||||||
@ -30,7 +32,6 @@ use Psalm\Issue\MoreSpecificImplementedReturnType;
|
|||||||
use Psalm\Issue\MoreSpecificReturnType;
|
use Psalm\Issue\MoreSpecificReturnType;
|
||||||
use Psalm\Issue\OverriddenMethodAccess;
|
use Psalm\Issue\OverriddenMethodAccess;
|
||||||
use Psalm\Issue\ReservedWord;
|
use Psalm\Issue\ReservedWord;
|
||||||
use Psalm\Issue\UntypedParam;
|
|
||||||
use Psalm\Issue\UnusedParam;
|
use Psalm\Issue\UnusedParam;
|
||||||
use Psalm\IssueBuffer;
|
use Psalm\IssueBuffer;
|
||||||
use Psalm\StatementsSource;
|
use Psalm\StatementsSource;
|
||||||
@ -525,13 +526,23 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
|
|||||||
? ', ' . ($possible_type ? 'should be ' . $possible_type : 'could not infer type')
|
? ', ' . ($possible_type ? 'should be ' . $possible_type : 'could not infer type')
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
IssueBuffer::accepts(
|
if ($this->function instanceof Closure) {
|
||||||
new UntypedParam(
|
IssueBuffer::accepts(
|
||||||
'Parameter $' . $function_param->name . ' has no provided type' . $infer_text,
|
new MissingClosureParamType(
|
||||||
$function_param->location
|
'Parameter $' . $function_param->name . ' has no provided type' . $infer_text,
|
||||||
),
|
$function_param->location
|
||||||
$storage->suppressed_issues
|
),
|
||||||
);
|
$storage->suppressed_issues
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
IssueBuffer::accepts(
|
||||||
|
new MissingParamType(
|
||||||
|
'Parameter $' . $function_param->name . ' has no provided type' . $infer_text,
|
||||||
|
$function_param->location
|
||||||
|
),
|
||||||
|
$storage->suppressed_issues
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
src/Psalm/Issue/MissingClosureParamType.php
Normal file
6
src/Psalm/Issue/MissingClosureParamType.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace Psalm\Issue;
|
||||||
|
|
||||||
|
class MissingClosureParamType extends CodeIssue
|
||||||
|
{
|
||||||
|
}
|
6
src/Psalm/Issue/MissingParamType.php
Normal file
6
src/Psalm/Issue/MissingParamType.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace Psalm\Issue;
|
||||||
|
|
||||||
|
class MissingParamType extends CodeIssue
|
||||||
|
{
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Psalm\Issue;
|
|
||||||
|
|
||||||
class UntypedParam extends CodeIssue
|
|
||||||
{
|
|
||||||
}
|
|
@ -558,7 +558,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo substr($a, 4, 2);
|
echo substr($a, 4, 2);
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be string',
|
. ' should be string',
|
||||||
'error_levels' => ['MixedArgument'],
|
'error_levels' => ['MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -567,7 +567,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo $a . "foo";
|
echo $a . "foo";
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be string',
|
. ' should be string',
|
||||||
'error_levels' => ['MixedOperand'],
|
'error_levels' => ['MixedOperand'],
|
||||||
],
|
],
|
||||||
@ -576,7 +576,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo $a + 5;
|
echo $a + 5;
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be int|float',
|
. ' should be int|float',
|
||||||
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -585,7 +585,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo $a / 5;
|
echo $a / 5;
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be int|float',
|
. ' should be int|float',
|
||||||
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
'error_levels' => ['MixedOperand', 'MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -594,7 +594,7 @@ class AnnotationTest extends TestCase
|
|||||||
function fooFoo($a): void {
|
function fooFoo($a): void {
|
||||||
echo "$a";
|
echo "$a";
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be string',
|
. ' should be string',
|
||||||
'error_levels' => ['MixedOperand'],
|
'error_levels' => ['MixedOperand'],
|
||||||
],
|
],
|
||||||
@ -607,7 +607,7 @@ class AnnotationTest extends TestCase
|
|||||||
echo substr("hello", $a, 2);
|
echo substr("hello", $a, 2);
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:2 - Parameter $a has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:2 - Parameter $a has no provided type,'
|
||||||
. ' should be int|string',
|
. ' should be int|string',
|
||||||
'error_levels' => ['MixedArgument'],
|
'error_levels' => ['MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -620,7 +620,7 @@ class AnnotationTest extends TestCase
|
|||||||
class B extends A {
|
class B extends A {
|
||||||
public function foo($a): void {}
|
public function foo($a): void {}
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam',
|
'error_message' => 'MissingParamType',
|
||||||
'error_levels' => ['MethodSignatureMismatch'],
|
'error_levels' => ['MethodSignatureMismatch'],
|
||||||
],
|
],
|
||||||
'alreadyHasCheck' => [
|
'alreadyHasCheck' => [
|
||||||
@ -630,7 +630,7 @@ class AnnotationTest extends TestCase
|
|||||||
function shouldTakeString($s): void {
|
function shouldTakeString($s): void {
|
||||||
if (is_string($s)) takesString($s);
|
if (is_string($s)) takesString($s);
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:4 - Parameter $s has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:4 - Parameter $s has no provided type,'
|
||||||
. ' could not infer',
|
. ' could not infer',
|
||||||
'error_levels' => ['MixedArgument'],
|
'error_levels' => ['MixedArgument'],
|
||||||
],
|
],
|
||||||
@ -645,7 +645,7 @@ class AnnotationTest extends TestCase
|
|||||||
$s = returnsMixed();
|
$s = returnsMixed();
|
||||||
takesString($s);
|
takesString($s);
|
||||||
}',
|
}',
|
||||||
'error_message' => 'UntypedParam - src/somefile.php:7 - Parameter $s has no provided type,'
|
'error_message' => 'MissingParamType - src/somefile.php:7 - Parameter $s has no provided type,'
|
||||||
. ' could not infer',
|
. ' could not infer',
|
||||||
'error_levels' => ['MixedArgument', 'InvalidReturnType', 'MixedAssignment'],
|
'error_levels' => ['MixedArgument', 'InvalidReturnType', 'MixedAssignment'],
|
||||||
],
|
],
|
||||||
|
@ -195,7 +195,12 @@ class FunctionCallTest extends TestCase
|
|||||||
}
|
}
|
||||||
);',
|
);',
|
||||||
'assertions' => [],
|
'assertions' => [],
|
||||||
'error_levels' => ['MixedArrayAccess', 'MixedArgument', 'UntypedParam', 'MissingClosureReturnType'],
|
'error_levels' => [
|
||||||
|
'MixedArrayAccess',
|
||||||
|
'MixedArgument',
|
||||||
|
'MissingClosureParamType',
|
||||||
|
'MissingClosureReturnType',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'byRefAfterCallable' => [
|
'byRefAfterCallable' => [
|
||||||
'<?php
|
'<?php
|
||||||
@ -393,7 +398,7 @@ class FunctionCallTest extends TestCase
|
|||||||
'$a' => 'array<int, string>',
|
'$a' => 'array<int, string>',
|
||||||
],
|
],
|
||||||
'error_levels' => [
|
'error_levels' => [
|
||||||
'UntypedParam',
|
'MissingClosureParamType',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'arrayFilterUseKey' => [
|
'arrayFilterUseKey' => [
|
||||||
@ -535,7 +540,7 @@ class FunctionCallTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
function f($p, $p) {}',
|
function f($p, $p) {}',
|
||||||
'error_message' => 'DuplicateParam',
|
'error_message' => 'DuplicateParam',
|
||||||
'error_levels' => ['UntypedParam'],
|
'error_levels' => ['MissingParamType'],
|
||||||
],
|
],
|
||||||
'invalidParamDefault' => [
|
'invalidParamDefault' => [
|
||||||
'<?php
|
'<?php
|
||||||
|
Loading…
Reference in New Issue
Block a user