-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to add custom PhpParser\NodeVisitor
to alter AST attributes
#1402
Comments
Would you mind going into more detail about what are you trying to achieve? Ideally with some example? It would help me out with designing the interface that you would need to solve your problem. |
I mean something like this: qossmic/deptrac-src#21 |
Ok, I understand what you want, I just don't understand why you want it. What is the use of a That's why I am asking what problem are you trying to solve. You are providing me with a solution, but I have no idea to what problem. |
I want some usages not to be treated as dependency. We have custom implementation of "friend methods": #[Friend([OnlyAllowed::class, 'caller'])]
public function method(): void
{
} And those references are just "backreferences" of allowed callers. Not a real dependency. So in order to exclude those, I wrapped your |
A PR (qossmic/deptrac-src#11) introduces I am wary of introducing more extension points, rather would better utilize the existing ones. As you have already alluded, you had to wrap |
"Occurred within an attribute" is not enough, I need to target that specific "Friend" one. |
But maybe my usecase is so edgecase it does not need to be supported with an easy way. Hard to guess though.. |
I would argue that the proposed qossmic/deptrac-src#21 is a sweet spot between introducing a public extension point in the Deptrac API, and overriding the internals (which is something we have to do right now - overriding the PhpParser implementation), or, at the extreme case, forking the repo. I'd say that @janedbal's use-case is a very special requirement, but at the same time, I see very little reason NOT TO allow the advanced users such customizations. It doesn't necessarily become a public API of deptrac, we're totally OK with taking the risk of internals changing. But it allows to easily add necessary customizations for large codebases with custom rules, that can later be converted to supported configuration options in deptrac :) |
Currently, we are using custom
ReferenceExtractorInterface
which needs some extra attributes to be present inPhpParser\Node
(similar to whatNodeConnectingVisitor
adds). Currently, there is no way to add it, so I was forced to copy most logic fromNikicPhpParser
in our customParserInterface
.It would be much better if I could just tag my visitor to be added automatically (similar to what PHPStan supports):
The text was updated successfully, but these errors were encountered: