Skip to content

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

@SMillerDev

Description

@SMillerDev

Bug report

When using https://github.com/pprkut/autoload-psr PHPStan fails to load any non-project classes. Instead returning:

Could not read file: Lunr/Gravity/Database/DatabaseAccessObject.php

This is apparently because the php_stream_open_for_zend_ex calls in the extension do not trigger the code in:
https://github.com/phpstan/phpstan-src/blob/HEAD/src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator.php

This does however still work on 1.6.9.

Code snippet that reproduces the problem

If you have the extension installed and run the code in https://phpstan.org/r/232ef63b-c3a0-45ba-b8f3-e58df73c9a44 with https://github.com/M2mobi/lunr in the Lunr-0.7 directory it should load the expected class, but doesn't.

Expected output

PHPStan can use the autoloader to find classes. Or, alternatively, the autoloader learns how to trigger the correct functions in PHPStan here.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan has been a gamechanger to improve our code, it's simple, powerful and I love to use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions