You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Possibly related to changes to Psalm's handling of functions with alternates
<?phpfunctionf(array &$configs, string$value) {
// NOTE: Adding a return type would fix the InvalidArgument error// Observed: InvalidArgument - Argument 3 of preg_replace_callback expects array<array-key, string>, string provided// Expected: Should take closest match for callable and not emit InvalidArgument$value = preg_replace_callback('/{{{(\w*)}}}/', function (array$match) use ($configs) {
$key = $match[1];
return$configs[$key];
}, $value, -1, $count);
}
<?php
/** @param int[]|string[]|bool[] $params */
function test($params) {
// Related:
// ERROR: InvalidScalarArgument - src/match.php:4:77 - Argument 2 of preg_match expects string, int|string|bool provided
// ERROR: InvalidArgument - src/match.php:4:108 - Argument 4 of preg_match expects int(0), int(256) provided
// Expected: Should warn about InvalidScalarArgument but not InvalidArgument. All 3 alternate signatures have 'subject' => 'string'
// Observed: Warns about both
if (!array_key_exists('x', $params) || preg_match('/\/ab\d+\//', $params['x'], $matches, PREG_OFFSET_CAPTURE) == 0 || !empty($params['is'])) {
}
}
The text was updated successfully, but these errors were encountered:
TysonAndre
changed the title
False positive InvalidArgument for preg_replace_callback
False positive InvalidArgument for preg_replace_callback and preg_match
Sep 11, 2019
Possibly related to changes to Psalm's handling of functions with alternates
The text was updated successfully, but these errors were encountered: