mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 13:51:54 +01:00
Fix #4070 - prevent literal strpos argument
This commit is contained in:
parent
c291b93bbe
commit
ca0608d92a
@ -122,7 +122,7 @@ class ArgumentAnalyzer
|
||||
|
||||
if ($function_param->expect_variable
|
||||
&& $arg_value_type->isSingleStringLiteral()
|
||||
&& !$arg->value instanceof PhpParser\Node\Scalar
|
||||
&& !$arg->value instanceof PhpParser\Node\Scalar\MagicConst
|
||||
&& !$arg->value instanceof PhpParser\Node\Expr\ConstFetch
|
||||
) {
|
||||
if (IssueBuffer::accepts(
|
||||
|
@ -1819,6 +1819,13 @@ class FunctionCallTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'RedundantCondition',
|
||||
],
|
||||
'strposNoSetFirstParam' => [
|
||||
'<?php
|
||||
function sayHello(string $format): void {
|
||||
if (strpos("u", $format)) {}
|
||||
}',
|
||||
'error_message' => 'InvalidArgument',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user