Skip to content

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented May 24, 2025

Closes phpstan/phpstan#12589
Closes phpstan/phpstan#7884
Closes phpstan/phpstan#7864

Naming is opened to discussion.

I think we could enable this in phpstan-strict-rules.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Also would be nice if it observed rule levels. Always wrong type like null to be always reported, but a partially wrong type like string|stdClass only on level 7+...

This is achieved with RuleLevelHelper::findTypeToCheck.

@VincentLanglet VincentLanglet force-pushed the reportCastedArrayKey branch 2 times, most recently from 692ddc0 to a5aea3c Compare July 17, 2025 20:08
@VincentLanglet
Copy link
Contributor Author

Seems like the RuleLevelHelper::findTypeToCheck was not used at all (or wrongly used) on theses rules.

So I fixed it and added tests with and without the reportArrayKeyCast option.

@VincentLanglet
Copy link
Contributor Author

Current status, waiting #4166 first

@VincentLanglet VincentLanglet changed the title Introduce reportCastedArrayKey parameter Introduce reportArrayKeyCast parameter Sep 10, 2025
@VincentLanglet VincentLanglet marked this pull request as ready for review September 10, 2025 18:00
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet
Copy link
Contributor Author

This is finally ready to be reviewed @ondrejmirtes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants