Skip to content

More precise intval and floatval signature #4152

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

Open
wants to merge 2 commits into
base: 2.1.x
Choose a base branch
from

Conversation

VincentLanglet
Copy link
Contributor

Closes #1005
Closes phpstan/phpstan#6560

This will give the same behavior for cast vs intval/floatval functions in
https://phpstan.org/r/850196c1-5f6c-479d-a25a-dd303e9cd047

Not sure if it's worth a non-regression test... should I write a test to expect all the [argument.type](https://phpstan.org/error-identifiers/argument.type) errors ?

@@ -5614,7 +5614,7 @@
'intltz_to_date_time_zone' => ['DateTimeZone|false', 'obj'=>''],
'intltz_use_daylight_time' => ['bool', 'obj'=>''],
'intlz_create_default' => ['IntlTimeZone'],
'intval' => ['int', 'var'=>'scalar|array|resource|null', 'base='=>'int'],
'intval' => ['int', 'var'=>'scalar|array|null', 'base='=>'int'],
Copy link
Contributor

@staabm staabm Jul 24, 2025

Choose a reason for hiding this comment

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

should we reflect a similar signature in boolval() and strval()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you play with https://phpstan.org/r/850196c1-5f6c-479d-a25a-dd303e9cd047 you'll see that

  • (string) resource
  • (bool) resource

Is not reported.

So strval and boolval shouldn't too.

@VincentLanglet VincentLanglet requested a review from staabm July 24, 2025 15:31
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.

Handle different ways to cast the same
2 participants