Skip to content

Rework ArrayReplaceFunctionReturnTypeExtension #3958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 1.12.x
Choose a base branch
from

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Apr 21, 2025

Close phpstan/phpstan#12828

I basically copy the ArrayMergeFunctionReturnTypeExtension with the following change

$keyType instanceof ConstantIntegerType ? null : $keyType,

$keyType instanceof ConstantIntegerType ? null : $keyType, is replaced by $keyType because

  • array_merge reindex numeric keys
  • array_replace keep all the existing keys

if (!(new IntegerType())->isSuperTypeOf($keyType)->yes()) {

if (!(new IntegerType())->isSuperTypeOf($keyType)->yes()) { is replaced by if (!$argType->isList()->yes()) { because of the same reason.

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.

1 participant