You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using custom patchers, there's currently no access to the fully resolved configuration, nor any of the utilities that PHP Scoper uses to determine if a function or class is exposed, internal, etc.
I recently implemented a basic DocblockPatcher (see #462 (comment)), in which I wanted to only prefix class names which are not internal.
Sure, I was able to create my own instance of Reflector, but it would have been nicer if I could just access the EnrichedReflector created by ScoperFactory.
Recently, I also ran into an issue with global function usages (same as #960), when expose-global-functions=false. I wanted to create a patcher that would access the list of functions that PHP Scoper determines should be aliased, and instead of aliasing them, prefix their usages in the patcher.
Unfortunately, it looks like there's no way to access this list, even though PHP Scoper does keep track of it (but only if expose-global-functions=true) inside an instance of SymbolsRegistry.
I'm not sure if PHP Scoper applies patchers after it has scoped all files, or one-by-one, ie scope a file, then patch it, scope another, then patch that - but I'm guessing it's the first?
If so, then perhaps it would be possible to expose some (or all?) of the state to patchers? I think this would make it possible to create more robust patchers with much less effort.
The text was updated successfully, but these errors were encountered:
Feature Request
When using custom patchers, there's currently no access to the fully resolved configuration, nor any of the utilities that PHP Scoper uses to determine if a function or class is exposed, internal, etc.
I recently implemented a basic DocblockPatcher (see #462 (comment)), in which I wanted to only prefix class names which are not internal.
Sure, I was able to create my own instance of
Reflector
, but it would have been nicer if I could just access theEnrichedReflector
created byScoperFactory
.Recently, I also ran into an issue with global function usages (same as #960), when
expose-global-functions=false
. I wanted to create a patcher that would access the list of functions that PHP Scoper determines should be aliased, and instead of aliasing them, prefix their usages in the patcher.Unfortunately, it looks like there's no way to access this list, even though PHP Scoper does keep track of it (but only if
expose-global-functions=true
) inside an instance ofSymbolsRegistry
.I'm not sure if PHP Scoper applies patchers after it has scoped all files, or one-by-one, ie scope a file, then patch it, scope another, then patch that - but I'm guessing it's the first?
If so, then perhaps it would be possible to expose some (or all?) of the state to patchers? I think this would make it possible to create more robust patchers with much less effort.
The text was updated successfully, but these errors were encountered: