Skip to content

!array_key_exists() should imply array for PHP8+ - #4417

Merged
ondrejmirtes merged 14 commits into
phpstan:2.1.xfrom
staabm:arr-key
Oct 16, 2025
Merged

ondrejmirtes merged 14 commits into
phpstan:2.1.xfrom
staabm:arr-key

Conversation

@staabm

@staabm staabm commented Oct 7, 2025 •

Copy link
Copy Markdown
Contributor

@staabm
staabm marked this pull request as ready for review October 7, 2025 08:06
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

throw new \RuntimeException('Absolute URLs are prohibited for the redirectTo parameter.');
}

assertType('array{scheme?: string, host?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query?: string, fragment?: string}', $parsedUrl);

@staabm staabm Oct 7, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in this case we got more preicse, because we no longer have a union array{...}|false but just the plain array-shape.
but on the other hand we no longer know that the 'host' offset cannot exist at this point.

I tried several variants, but wasn't successfull in combining the specified types in a way which turns the mixed into array while also removing the offset.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I figured it out

@staabm
staabm force-pushed the arr-key branch 4 times, most recently from e479f0e to cebec02 Compare October 12, 2025 07:49
@staabm

staabm commented Oct 12, 2025 •

Copy link
Copy Markdown
Contributor Author

Memo for me: add test for the issue-bot report

Edit: ✅

@ondrejmirtes
ondrejmirtes merged commit bab0af7 into phpstan:2.1.x Oct 16, 2025
541 of 551 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you!

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_key_exists() should imply array for PHP8+ Creating new array on mixed[] should be allowed if key does not exist.

3 participants