Skip to content

Commit

Permalink
Sort during normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Dec 1, 2024
1 parent 1d45aa8 commit bb092f7
Show file tree
Hide file tree
Showing 13 changed files with 57,713 additions and 57,709 deletions.
2 changes: 1 addition & 1 deletion bin/gen_base_callmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
}

$callmap = normalizeCallMap($callmap);
var_dump($callmap);
writeCallMap(__DIR__.'/../dictionaries/CallMap.php', $callmap);
8 changes: 6 additions & 2 deletions bin/gen_callmap_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
use Psalm\Tests\TestConfig;
use Psalm\Type;

function internalNormalizeCallMap(array|string $callMap): array|string {
function internalNormalizeCallMap(array|string $callMap, string|int $key = 0): array|string {
if (is_string($callMap)) {
return Type::parseString($callMap === '' ? 'mixed' : $callMap)->getId(true);
}

$new = [];

$value = null;
foreach ($callMap as $key => $value) {
$new[is_string($key) && is_array($value) ? strtolower($key) : $key] = internalNormalizeCallMap($value);
$new[is_string($key) && is_array($value) ? strtolower($key) : $key] = internalNormalizeCallMap($value, $key);
}
if (is_array($value) && $key !== 'old' && $key !== 'new') {
ksort($new);
}

return $new;
Expand Down
Loading

0 comments on commit bb092f7

Please sign in to comment.