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

False-positive "will always evaluate to true" on context-dependent types #7914

Closed
fluffycondor opened this issue Sep 2, 2022 · 1 comment · Fixed by phpstan/phpstan-src#1706
Labels
Milestone

Comments

@fluffycondor
Copy link
Contributor

Bug report

There are assertions that prove something is X, but doesn't prove otherwise. That means not all X pass this assertion.
If one passes an already known X to that kind of assertion, PHPStan yields false-positive will always evaluate to true. The analyzer doesn't check the context.

Code snippet that reproduces the problem

https://phpstan.org/r/1912878d-c976-4619-88a5-7d59f226a00d

Expected output

No errors.
ctype_digit proves it's a numeric-string, but doesn't prove otherwise.
https://github.com/phpstan/phpstan-src/blob/1.8.x/src/Type/Php/CtypeDigitFunctionTypeSpecifyingExtension.php#L46

@github-actions
Copy link

github-actions bot commented Oct 8, 2022

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 Oct 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants