mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix erroneous complaint for str_replace
This commit is contained in:
parent
0468d11158
commit
55cfbdcd5f
@ -337,12 +337,12 @@ class Functions
|
||||
$args
|
||||
);
|
||||
|
||||
if (!$function_callable->params) {
|
||||
if (!$function_callable->params || !$args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($function_callable->params as $param) {
|
||||
if ($param->by_ref) {
|
||||
foreach ($function_callable->params as $i => $param) {
|
||||
if ($param->by_ref && isset($args[$i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,17 @@ class PureAnnotationTest extends TestCase
|
||||
return substr(strtolower($s), 0, 10);
|
||||
}',
|
||||
],
|
||||
'pureWithStrReplace' => [
|
||||
'<?php
|
||||
/** @psalm-pure */
|
||||
function highlight(string $needle, string $output) : string {
|
||||
$needle = preg_quote($needle, \'#\');
|
||||
$needles = str_replace([\'"\', \' \'], [\'\', \'|\'], $needle);
|
||||
$output = preg_replace("#({$needles})#im", "<mark>$1</mark>", $output);
|
||||
|
||||
return $output;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user