mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
parent
0116284d16
commit
307790fbac
@ -231,6 +231,7 @@
|
||||
<xs:element name="InvalidFunctionCall" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InvalidGlobal" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InvalidIterator" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InvalidLiteralArgument" type="ArgumentIssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InvalidMethodCall" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InvalidNullableReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="InvalidOperand" type="IssueHandlerType" minOccurs="0" />
|
||||
|
11
docs/running_psalm/issues/InvalidLiteralArgument.md
Normal file
11
docs/running_psalm/issues/InvalidLiteralArgument.md
Normal file
@ -0,0 +1,11 @@
|
||||
# InvalidLiteralArgument
|
||||
|
||||
Emitted when a scalar value is passed to a method that expected another scalar type
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
function foo(string $s) : void {
|
||||
echo strpos(".", $s);
|
||||
}
|
||||
```
|
@ -1505,6 +1505,10 @@ class Config
|
||||
return 'InvalidOperand';
|
||||
}
|
||||
|
||||
if ($issue_type === 'InvalidLiteralArgument') {
|
||||
return 'InvalidArgument';
|
||||
}
|
||||
|
||||
if ($issue_type === 'TraitMethodSignatureMismatch') {
|
||||
return 'MethodSignatureMismatch';
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ use Psalm\Context;
|
||||
use Psalm\Issue\ImplicitToStringCast;
|
||||
use Psalm\Issue\InvalidArgument;
|
||||
use Psalm\Issue\InvalidScalarArgument;
|
||||
use Psalm\Issue\InvalidLiteralArgument;
|
||||
use Psalm\Issue\MixedArgument;
|
||||
use Psalm\Issue\MixedArgumentTypeCoercion;
|
||||
use Psalm\Issue\NoValue;
|
||||
@ -126,7 +127,7 @@ class ArgumentAnalyzer
|
||||
&& !$arg->value instanceof PhpParser\Node\Expr\ConstFetch
|
||||
) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidArgument(
|
||||
new InvalidLiteralArgument(
|
||||
'Argument ' . ($argument_offset + 1) . ' of ' . $cased_method_id
|
||||
. ' expects a non-literal value, ' . $arg_value_type->getId() . ' provided',
|
||||
new CodeLocation($statements_analyzer->getSource(), $arg->value),
|
||||
|
8
src/Psalm/Issue/InvalidLiteralArgument.php
Normal file
8
src/Psalm/Issue/InvalidLiteralArgument.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class InvalidLiteralArgument extends ArgumentIssue
|
||||
{
|
||||
const ERROR_LEVEL = 4;
|
||||
const SHORTCODE = 237;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user