nikic / PHP-Parser

A PHP parser written in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

utilize static closures to improve performance

staabm opened this issue · comments

looking at rector profiles one can see node-traversal as a bottleneck.

I wonder whether we can/should use some assumptions to improve performance, e.g. don't traverse into static closures when searching for a MethodCall with var='this' .

do you think such things are acceptable as a PR?

PhpParser only allows finding nodes by class (or generic callback), so it sounds like you're talking about some utility implemented in Rector here?

hmm you are right. to make this work we would need e.g. a new class representing method-calls on $this.

Closing this as I believe it's out of scope for this library, it needs to be solved on a higher level. E.g. a custom visitor that returns DONT_TRAVERSE_CHILDREN for static closures would work.