`PhpStormStubsSourceStubber` calls into application autoloader
staabm opened this issue · 5 comments
while debugging today, I realized that when BetterReflection is building up its reflection knowledge based on phpstorm stubs, it is invoking application autoloaders.
I found stacktraces like
in which you can see the top-level frame Rocket::autoload
. thats my application autoloader which is registered via phpstan bootstrap file.
my questions:
- should BetterReflection trigger autoloading while analyzing phpstorm stubs?
- if autoloading is really needed, should better reflection isolate the autoloading involved from side-effects like a application level autoloader?
I came to this question, because our application autoloading needs todo some gymnastics and it is invoked a lot for all kind of classes which BetterReflection
is locating while parsing stub files.
looking deeper it might even be the case this only happens from within PHPStan.. not sure yet
should BetterReflection trigger autoloading while analyzing phpstorm stubs?
if autoloading is really needed, should better reflection isolate the autoloading involved from side-effects like a application level autoloader?
The autoload is not intentional. It looks it's triggered by defined
.
We use updateConstantValue
because values in stubs are not actual or are different on different PHP versions or operating systems.
It looks it's triggered by
defined
.
I wasn't aware defined
can trigger autoloading, but you are right:
We can probably use get_defined_constants
: https://3v4l.org/r3O9o