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 'Hoa\Event\Bucket' not found #3907
Comments
This bug report is missing a link to reproduction on phpstan.org. |
Full error output:
|
Hi, the registered CodeIgniter autoloader does something invasive - it prepends itself before the PHPStan-registered autoloader and so when PHPStan tries to load some class it uses itself, it fails. This method in /**
* Register the loader with the SPL autoloader stack.
*/
public function register()
{
// Since the default file extensions are searched
// in order of .inc then .php, but we always use .php,
// put the .php extension first to eek out a bit
// better performance.
// http://php.net/manual/en/function.spl-autoload.php#78053
spl_autoload_extensions('.php,.inc');
// Prepend the PSR4 autoloader for maximum performance.
spl_autoload_register([$this, 'loadClass'], true, true); // @phpstan-ignore-line
// Now prepend another loader for the files in our class map.
$config = $this->classmap;
// @phpstan-ignore-next-line
spl_autoload_register(function ($class) use ($config) {
if (empty($config[$class]))
{
return false;
}
include_once $config[$class];
}, true, // Throw exception
false // Prepend
);
} When I change |
Thanks for the fast response! Really great too by the way; I'm was very glad to see you launch a paid version. I will start a conversation with the framework devs about how important it is for the Autoloader to prepend. I must say I have been using PHPStan with CodeIgniter 4 for weeks and this is the first issue I have had - is there something particular about that file, or the setup, that makes it crash? I've used plenty of other traits, during testing, crossing namespaces, etc... can't think of why this would be any different. |
I might have a solution up my sleeve for this problem, so don't ask CI devs yet, I'll give it a try first. Stay tuned :) |
Yeah, so I was able to get rid of the Hoa error by removing But the problem still persists:
And we could get rid of the error. The CI devs don't need to change anything about prepending the autoloader, that can stay, but the reason why this ends up in fatal error is because the autoloader uses So you could persuade the devs to use Why |
Thanks so much! I'm actually one of the CI devs so I will definitely lobby for this, assuming there is not some strange reason for the require. Also glad to see you got that bystander issue fixed :) |
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
PHPStan is crashing during analysis that includes a controller trait from the framework. PHPUnit tests pass fine using the trait and I can see nothing else about the trait that would cause an issue.
Code snippet that reproduces the problem
Because of the framework dependency I cannot recreate on PHPStan.org, but I have created a new repo that has a barebones setup and still causes the issue: https://github.com/MGatner/phpstan-error
Expected output
Expected not to crash :)
Possible other occurrences of this "missing class" issue:
The text was updated successfully, but these errors were encountered: