1
0
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:
Brown 2020-09-10 18:28:34 -04:00 committed by Daniil Gentili
parent c291b93bbe
commit ca0608d92a
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 8 additions and 1 deletions

View File

@ -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(

View File

@ -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',
],
];
}
}