|
162 | 162 | use function ltrim; |
163 | 163 | use function md5; |
164 | 164 | use function sprintf; |
| 165 | +use function str_contains; |
165 | 166 | use function str_decrement; |
166 | 167 | use function str_increment; |
167 | 168 | use function str_starts_with; |
168 | 169 | use function strlen; |
169 | 170 | use function strtolower; |
170 | 171 | use function substr; |
| 172 | +use function uksort; |
171 | 173 | use function usort; |
172 | 174 | use const PHP_INT_MAX; |
173 | 175 | use const PHP_INT_MIN; |
@@ -5296,30 +5298,28 @@ private function generalizeVariableTypeHolders( |
5296 | 5298 | array $otherVariableTypeHolders, |
5297 | 5299 | ): array |
5298 | 5300 | { |
5299 | | - $sortByExprStringLength = static function (string $exprA, string $exprB): int { |
5300 | | - return strlen($exprA) <=> strlen($exprB); |
5301 | | - }; |
5302 | | - |
5303 | | - uksort($variableTypeHolders, $sortByExprStringLength); |
5304 | | - uksort($otherVariableTypeHolders, $sortByExprStringLength); |
| 5301 | + uksort($variableTypeHolders, static fn (string $exprA, string $exprB): int => strlen($exprA) <=> strlen($exprB)); |
5305 | 5302 |
|
5306 | 5303 | $changedArrays = []; |
5307 | 5304 | foreach ($variableTypeHolders as $variableExprString => $variableTypeHolder) { |
5308 | 5305 | if (!isset($otherVariableTypeHolders[$variableExprString])) { |
5309 | 5306 | continue; |
5310 | 5307 | } |
5311 | 5308 |
|
5312 | | - foreach($changedArrays as $changedExpr) { |
5313 | | - if (str_starts_with($variableExprString, $changedExpr)) { |
| 5309 | + foreach ($changedArrays as $changedExpr) { |
| 5310 | + if ( |
| 5311 | + str_contains($variableExprString, $changedExpr . '[') |
| 5312 | + || str_contains($variableExprString, '[' . $changedExpr . ']') |
| 5313 | + ) { |
| 5314 | + unset($variableTypeHolders[$variableExprString]); |
5314 | 5315 | continue 2; |
5315 | 5316 | } |
5316 | 5317 | } |
5317 | 5318 |
|
5318 | 5319 | $generalizedType = $this->generalizeType($variableTypeHolder->getType(), $otherVariableTypeHolders[$variableExprString]->getType(), 0); |
5319 | 5320 | if ( |
5320 | | - $generalizedType->isArray()->yes() && |
5321 | | - !$generalizedType->equals($variableTypeHolder->getType())) |
5322 | | - { |
| 5321 | + !$generalizedType->equals($variableTypeHolder->getType()) |
| 5322 | + ) { |
5323 | 5323 | $changedArrays[] = $variableExprString; |
5324 | 5324 | } |
5325 | 5325 | $variableTypeHolders[$variableExprString] = new ExpressionTypeHolder( |
|
0 commit comments