-
-
Notifications
You must be signed in to change notification settings - Fork 742
Description
Hi, I'm reacting to #3488 (comment) which is about PHPStan 0.12.26.
Rector can take advantage of it, you should take these steps:
- Use ReflectionProvider interface instead of Broker class in places where you're obtaining class/function/constant reflections. They have the same API.
- I'm not sure how Rector's DI works. In PHPStan the current stable ReflectionProvider looks like this:
ChainReflectionProvider
- ClassBlacklistReflectionProvider
- RuntimeReflectionProvider
- BetterReflectionProvider
The class blacklist is there so that some certain classes are skipped for the runtime reflection and go straight to static reflection.
If you enable the experimental flag featureToggles.disableRuntimeReflectionProvider (set to true) then the reflection provider instance is just going to be the BetterReflectionProvider.
The most important thing about BetterReflectionProvider is the source locator chain it uses. In PHPStan it's created in this class: https://github.com/phpstan/phpstan-src/blob/master/src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php (you might want to write your own).
It's quite difficult to construct BetterReflectionProvider by hand but fortunately there's a Nette DI-generated factory based on this interface: https://github.com/phpstan/phpstan-src/blob/master/src/Reflection/BetterReflection/BetterReflectionProviderFactory.php
Here are the services definitions: https://github.com/phpstan/phpstan-src/blob/master/conf/config.neon#L1095-L1125
Let me know if you have any questions 👍