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

Constant anotated with @var is resolved as StringType, not ConstantStringType anymore #5517

Closed
janedbal opened this issue Aug 23, 2021 · 4 comments

Comments

@janedbal
Copy link
Contributor

Bug report

See snippet, when you remove that var annotation, it properly finds the always-true condition. Imo broken by phpstan/phpstan-src@b932769

Found when upgrading from 0.12.94 to 0.12.96

Code snippet that reproduces the problem

https://phpstan.org/r/b5200efd-e999-4c12-9e7c-9ebc8eb3ee2a

Expected output

Original behaviour

@ondrejmirtes
Copy link
Member

I changed the behaviour because of #3530 and also so that static::CONSTANT has type of string and not mixed, but at the same time I also removed type lossy optimization of CONSTANT_SCALAR_UNION_THRESHOLD. Which means that we can afford self::CONSTANT not to look at the PHPDoc and have the precise type of the class constant value.

@ondrejmirtes
Copy link
Member

Implemented: phpstan/phpstan-src@5010ef4

@janedbal
Copy link
Contributor Author

Thank you!

@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 Sep 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants