-
-
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
AutoloadSourceLocator should restore pre-existing stream handlers #3854
Comments
I don't think it's possible in PHP to do that. I'd rather make an option to disable AutoloadSourceLocator. |
I have a suggestion to handle it. If you make an option to disable |
It wouldn't allow you to use autoloader-based symbols discovering. Which is a fine trade-off IMHO, using hack like bypass-finals is already an edge-case, autoloader-based symbols discovering is another edge-case so not supporting an intersection of these two edge cases is fine by me. |
This is what would stop working: https://phpstan.org/user-guide/discovering-symbols#custom-autoloader |
If I understand correctly it won't affect a codebase running a standard psr-4 autoloader? That seems acceptable. |
Yeah if you define autoload in composer.json you could disable AutoloadSourceLocator 😊 |
Just realized there's a much easier way to handle this:
|
This may work, but this is kind of weird... you are not fixing the compatibility issue, you are reimplementing the functionality in PHPStan codebase. Also this would still break when using 'setWhitelist' method of bypass-final. For the moment I'm working around the issue by preloading all the classes during bootstrap. This way they go through bypass-final before the analysis start and the stream wrapper conflict arise. I'm using this classfinder lib to do this https://packagist.org/packages/haydenpierce/class-finder This is a bit 'brute-force' but I think it's a decent (and safe) fix. |
I'm unlikely to work on a fix for this myself, I guess many people already found their own workaround for this (or stopped using bypass-finals). |
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. |
Feature request
AutoloadSourceLocator uses stream handlers black magic internally.
This conflict with stream-handler defined by the user. Most notably it breaks db/bypass-finals.
Related issues
User failing to make bypass-final works despite bootstrapping it
#3179
Reproducible setup (issue is mislocated, it's not related to the Symfony plugin)
phpstan/phpstan-symfony#96
The text was updated successfully, but these errors were encountered: