-
-
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
PHPStan breaks custom autoloader from loading dependencies for anonymous classes #4836
Comments
This bug report is missing a link to reproduction on phpstan.org. It will most likely be closed after manual review. |
Thank you, this is a well done bug report. The problem is that your autoloader uses |
Hey @ondrejmirtes, I think I have a fix for this. If you're interested, I'm happy to submit a PR. I see that you were detecting the autoloaded file paths by overriding To make it work with If that sounds sensible, I'll submit a PR. |
I went ahead and made a PR; hope that is OK. |
phpstan/phpstan-src@161c383 Allow autoloaders to require/require_once for #4836 via a fake read
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
Version
Description
When using a custom autoloader, dependencies of anonymous classes that must be autoloaded will fail on
require
orrequire_once
with a file not found, despite the file existing and following a successful\file_exists()
check beforehand.This defect does not appear when an anonymous class's dependencies are discovered by scanning prior to analyzing the file in question, or if you explicitly import the symbols with
use
directives.Technical hunch
I'm guessing this has something to do with intercepting the stream read hooks inside of
BetterReflection
.Code snippet that reproduces the problem
See my sample repository that reproduces this error. I'm not sure it would be possible using only
phpstan.org
since it relies on filesystem operations.Expected output
PHPStan should allow anonymous class dependencies declared with fully qualified class names to autoload properly using a custom autoloader.
This works (from the linked repo above):
This doesn't:
The text was updated successfully, but these errors were encountered: