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

ctype_digit false positive after casted parameters #8736

Closed
staabm opened this issue Jan 19, 2023 · 3 comments
Closed

ctype_digit false positive after casted parameters #8736

staabm opened this issue Jan 19, 2023 · 3 comments

Comments

@staabm
Copy link
Contributor

staabm commented Jan 19, 2023

          With the code below, PHPStan says `Strict comparison using === between int<48, 57>|int<256, max>|numeric-string and 1 will always evaluate to false.`, but that is not true.

$mixed should be typed as int<0, max>|numeric-string, isn't it?

if (ctype_digit((string) $mixed)) {
	if ($mixed === 1) {
		echo '$mixed is 1';
	}
}

https://3v4l.org/AWVMB
https://phpstan.org/r/fff69d60-d579-44fa-bb1c-33f9eee4f2a9

Originally posted by @takaram in #8714 (comment)

@staabm
Copy link
Contributor Author

staabm commented Jan 19, 2023

here a few more interessting examples: https://3v4l.org/YA4ri

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2189

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants