Skip to content

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

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)

@ondrejmirtes
Copy link
Member

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

Development

Successfully merging this pull request may close these issues.

Classes aren't recognized when using a PHP extension as autoloader

2 participants