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

Internal error: Failed to find parent class of constant #4288

Closed
vworldat opened this issue Dec 29, 2020 · 6 comments
Closed

Internal error: Failed to find parent class of constant #4288

vworldat opened this issue Dec 29, 2020 · 6 comments
Labels
Milestone

Comments

@vworldat
Copy link

Bug report

Phpstan fails to find class constants when used as default argument value in a trait method. I have backtracked various phpstan versions. This has not been an issue up until phpstan 0.12.25, from 0.12.26 onwards it breaks on all versions i checked including the latest 0.12.58.

Code snippet that reproduces the problem

https://phpstan.org/r/c17faf82-5d21-4283-a324-b5976c6c1414

Things I have tried to make it pass:

  • constant visibility does not matter
  • method visibility does not matter
  • declaring class as final or not does not matter
  • the class extending a parent class does not matter
  • not declaring strict types does not matter
  • accessing the same constant from inside the method's body instead of the argument default value works fine: https://phpstan.org/r/2dd6fcf6-b07d-4ea6-9958-97c7393d24f0

Expected output

No errors.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Dec 29, 2020
@phpstan phpstan deleted a comment from phpstan-bot Mar 3, 2021
@phpstan phpstan deleted a comment from phpstan-bot Mar 3, 2021
@phpstan phpstan deleted a comment from phpstan-bot Mar 3, 2021
@phpstan-bot
Copy link
Contributor

@vworldat PHPStan now reports different result with your code snippet:

@@ @@
 -1: Internal error: Failed to find parent class of constant "DEFAULT_SIZE".
 Run PHPStan with --debug option and post the stack trace to:
-https://github.com/phpstan/phpstan/issues/new
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Full report
Line Error
-1 Internal error: Failed to find parent class of constant "DEFAULT_SIZE".
Run PHPStan with --debug option and post the stack trace to:
https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md

@ondrejmirtes
Copy link
Member

Realized this is duplicate of #4066

@ondrejmirtes
Copy link
Member

Actually isn't :)

@ondrejmirtes
Copy link
Member

Fixed by: ondrejmirtes/BetterReflection@4fafef2 + phpstan/phpstan-src@8babba3

@phpstan-bot
Copy link
Contributor

@vworldat After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
--1: Internal error: Failed to find parent class of constant "DEFAULT_SIZE".
-Run PHPStan with --debug option and post the stack trace to:
-https://github.com/phpstan/phpstan/issues/new
+No errors

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

No branches or pull requests

3 participants