-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
class not found on class-constants #7365
Comments
This bug report is missing a link to reproduction at phpstan.org/try. It will most likely be closed after manual review. |
I think this is your mistake. If you use your own autoloader to load a class, you need to make sure by yourself the definition isn't broken. |
I am not sure, because the class can only not be found when the class-constant is used within a property. it works in other classes of the same codebase when used within method bodies |
Try to create a simple PHP script, require just your own autoloader, and ask for |
But feel free to create the repo, I might work around it. |
when I change <?php
class DbhController
{
protected $warengruppenid = [
Fare_Warengruppen::WARENGRUPPE_STOCKSCHIRME,
Fare_Warengruppen::WARENGRUPPE_TASCHENSCHIRME,
];
} to <?php
class DbhController
{
private function isButtonViewAllowed(): bool
{
// nur auf Fare.de ist der Link grundsätzlich erlaubt
if (!Fare_Portal_ShopLayout::isFare()) {
return false;
}
if (!$this->isLoggedIn) {
return false;
}
$artMapper = new Application_Model_Mapper_Article();
// Warengruppen, die grundsätzlich für den VE-Button freigeschaltet sind.
return null !== $artMapper->fetchByWarengruppenIdVeFaehig($this->article->getArtid(), [
Fare_Warengruppen::WARENGRUPPE_STOCKSCHIRME,
Fare_Warengruppen::WARENGRUPPE_TASCHENSCHIRME,
Fare_Warengruppen::WARENGRUPPE_SONNENSCHIRME,
]);
} it no longer errors... I need to investigate the details |
That's not surprising if you actually look at what the stack trace tries to do. |
I feel its suprising, as the 2nd example seems to successfully autoload the at least I would assume that code like
also triggers the autoloader? |
No, it doesn't. |
hmm interessting.. as I tried reproducing it in https://github.com/staabm/phpstan-bug7365 (and intentionally do not provide a proper autoloader) I am getting proper errors instead of a internal fatal error:
|
Again, everything as expected :) My message still stands:
|
When your autoloader gets executed, it needs to be able to load |
But I have an idea, I just need your reproduction now :) |
It's gonna be solved by phpstan/phpstan-src#1373 |
I don't know what is different between my sample repo at https://github.com/staabm/phpstan-bug7365 and my local real world project. I have no idea what needs to be changed in the repro to make the internal error be thrown
I am not sure what you mean by that. AFAICT my autoloader is not throwing this exception |
This is the situation in your autoloader that makes it crash: afbe366 The |
Fixed by: phpstan/phpstan-src#1373 |
Thank you! |
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. |
Bug report
Stacktrace:
code in question looks like
Code snippet that reproduces the problem
I am in the process of creating a repro repo
Expected output
no error
The text was updated successfully, but these errors were encountered: