Skip to content

Conversation

@takaram
Copy link
Contributor

@takaram takaram commented Feb 1, 2026

if ($isIntegerKey->yes()) {
$keyType = IntegerRangeType::createAllGreaterThanOrEqualTo(0);
} elseif ($isIntegerKey->maybe()) {
$keyType = TypeCombinator::union(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all the existing 'non-empty-array' are transformed into non-empty-array<int<0, max>|string, mixed> because of now benevolent union (array key) is transformed into a real union.

I dunno if we want to keep a benevolent union here...

*/
function splice(array $a): void {
array_splice($a, 0, 0);
assertType("array<'a'|int<0, max>, mixed>", $a);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 'a'|int<0, 2>

You're doing $keyType = IntegerRangeType::createAllGreaterThanOrEqualTo(0);

but maybe you should check getConstantScalarTypes.
and if if (count($constantScalars) > 0), you're doing $keyType = IntegerRangeType::fromInterval(0, $count -1); ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

array_splice resets int keys of the input array

2 participants