Closed boesing closed 1 year ago
You should be able to easily implement this with a visitor -- remember the name of the class currently visited, and then replace references to self
. However, note that this is not a behavior-preserving transform due to closure rebinding. self
in closures is subject to rebinding.
In any case, I don't think this needs any particular additional support from the side of PHP-Parser.
Hey there,
I do have the following example which is broadly used in the
mezzio
(laminas
) ecosystem as config-cache is passed to the filesystem while configuration is "provided" by one or multipleConfigProvider
instances .Given the following example:
Current output
Preferred output
I'd love to get either the constant value dereferenced, i.e.
'foo'
or using the FQCN instead ofself
.Is there already a way to achieve this or would this be a whole new feature? Do you think that this would make sense in this library or does implementing such a feature is quite complex?