Skip to content
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

PHP_INT_MAX isn't positive-int, but int #6968

Closed
kelunik opened this issue Nov 22, 2021 · 6 comments · Fixed by #7070
Closed

PHP_INT_MAX isn't positive-int, but int #6968

kelunik opened this issue Nov 22, 2021 · 6 comments · Fixed by #7070
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm good first issue Help wanted

Comments

@kelunik
Copy link
Contributor

kelunik commented Nov 22, 2021

https://psalm.dev/r/6c3860181f

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/6c3860181f
<?php

usleep(PHP_INT_MAX);
Psalm output (using commit 9943efb):

ERROR: ArgumentTypeCoercion - 3:8 - Argument 1 of usleep expects 0|positive-int, parent type int provided

@kelunik
Copy link
Contributor Author

kelunik commented Nov 22, 2021

See

case 'PHP_INT_MAX':
case 'PHP_INT_MIN':
case 'PHP_INT_SIZE':
case 'PHP_MAXPATHLEN':
case 'PHP_VERSION_ID':
case 'PHP_ZTS':
return Type::getInt();
.

@orklah
Copy link
Collaborator

orklah commented Nov 22, 2021

Good catch. Care to provide a PR?

(I'm really curious about the use case if this is a legit piece of code :D)

@orklah orklah added bug easy problems Issues that can be fixed without background knowledge of Psalm Help wanted labels Nov 22, 2021
@kkmuffme
Copy link
Contributor

(I'm really curious about the use case if this is a legit piece of code :D)

It's probably not, but (u)sleep is the most convenient function to reproduce psalm false positives with positive-int/int type, see #6966 :)

@kelunik
Copy link
Contributor Author

kelunik commented Nov 22, 2021

It's a legit piece of code, yeah: revoltphp/event-loop@dc9fbe7

ricardoboss added a commit to ricardoboss/psalm that referenced this issue Dec 5, 2021
@ricardoboss
Copy link
Contributor

I opened a PR that may fix this: #7070

@orklah orklah linked a pull request Dec 5, 2021 that will close this issue
orklah added a commit that referenced this issue Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm good first issue Help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants