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

PHPStan changed the way that a constant type is detected #5504

Closed
natanfelles opened this issue Aug 21, 2021 · 2 comments
Closed

PHPStan changed the way that a constant type is detected #5504

natanfelles opened this issue Aug 21, 2021 · 2 comments

Comments

@natanfelles
Copy link

Bug report

After last release 0.12.96, PHPStan stopped to auto-detect constant type when get from a variable.

Code snippet that reproduces the problem

https://phpstan.org/r/58f32d4f-e85d-4f43-9b09-89d6e7235c39

Expected output

I am not sure if it is detected incorrectly.

Note that, if add PHPDoc on the constant no error is reported.

 /**
  * @var string
  */
 public const SS = 'ss';

But is strange because when accessed directly from the class it passes, but not from a variable.

Did PHPStan help you today? Did it make you happy in any way?

Yes! PHPStan is awesome. I love you.

@ondrejmirtes
Copy link
Member

Thank you for your kind words! :)

This change is intended as part of a bugfix for this issue: #2959

Yeah, to use the PHPDoc is the correct approach. That way PHPStan will also enforce the same type in child classes as part of bleeding edge. There are new rules around that in 0.12.95.

@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 23, 2021
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