Fix #20634: Fix PHPDoc annotations in yii\db namespace. Add PHPStan/Psalm annotations for yii\db\SqlTokenizer::startsWithAnyLongest()

This commit is contained in:
Maksim Spirkov
2025-10-25 22:19:58 +03:00
committed by GitHub
parent 122e95216f
commit dd4c091e66
7 changed files with 11 additions and 5 deletions

View File

@@ -176,12 +176,15 @@ abstract class SqlTokenizer extends Component
/**
* Returns whether the longest common prefix equals to the SQL code of the same length at the current offset.
* @param string[] $with strings to be tested.
* @param array $with strings to be tested.
* The method **will** modify this parameter to speed up lookups.
* @param bool $caseSensitive whether to perform a case sensitive comparison.
* @param int|null $length length of the matched string.
* @param string|null $content matched string.
* @return bool whether a match is found.
*
* @phpstan-param array<int, string>|array<int, array<string, mixed>> $with
* @psalm-param array<int, string>|array<int, array<string, mixed>> $with
*/
protected function startsWithAnyLongest(array &$with, $caseSensitive, &$length = null, &$content = null)
{
@@ -194,6 +197,7 @@ abstract class SqlTokenizer extends Component
return mb_strlen($string2, 'UTF-8') - mb_strlen($string1, 'UTF-8');
});
$map = [];
/** @var string $string */
foreach ($with as $string) {
$map[mb_strlen($string, 'UTF-8')][$caseSensitive ? $string : mb_strtoupper($string, 'UTF-8')] = true;
}