Closed staabm closed 7 months ago
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
@kukulich I found a way on how it could work, please have a look: https://github.com/Roave/BetterReflection/pull/1416
@staabm I think it's very nice solution 👍
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:
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