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
merged 1 commit into from Sep 22, 2022
Merged

Conversation

pprkut
Copy link
Contributor

@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
Member

@ondrejmirtes ondrejmirtes left a comment

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)

@ondrejmirtes ondrejmirtes merged commit b0babd0 into phpstan:1.8.x Sep 22, 2022
193 of 195 checks passed
@ondrejmirtes
Copy link
Member

ondrejmirtes commented Sep 22, 2022

Thank you!

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