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

Better support for autoloader edge cases #1503

merged 1 commit into from Sep 22, 2022


Copy link

@pprkut pprkut commented Jul 10, 2022

Support autoloaders that rely on the include path and don't check file existence before trying to include a file.

Autoloaders not checking file existence before trying to include the file need a proper response from stream_open. This is something that wouldn't happen with PHP based autoloaders, but C based autoloaders may rely on the return value of php_stream_open_for_zend_ex().

Autoloaders may not always know the exact physical location of the file they need to load, and instead rely on the availability of the file somewhere in the include path. In order for phpstan to also find those files, rather than just an is_file() check, it would also need to check availability in the include path with stream_resolve_include_path().

Fixes phpstan/phpstan#7526, which also contains more background info.

Copy link

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could really use a test first :)

It might be difficult to do it using a traditional unit test, so feel free to submit an integration test in this style instead: phpstan/phpstan@151140a (GitHub Actions make it really easy to install PHP extensions like that)

Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
2 participants