[NodeAnalyzer] Remove parent attribute on ScopeAnalyzer#4400
[NodeAnalyzer] Remove parent attribute on ScopeAnalyzer#4400samsonasik merged 10 commits intomainfrom
Conversation
|
All checks have passed 🎉 @TomasVotruba I am merging it to have faster feedback to test ;) |
|
Tested on CodeIgniter4 project, now got error: I will check check it. |
|
My unverified guess: I think Scope instances are way heavier in memory than Ast-Nodes. This would mean that this patch might even worse memory use, as we are trading references to Ast Nodes with references to Scope objects. After getting rid of the parent-AST-attribute we need to check these Scope attribute, as it is used so often. Maybe we can make use of WeakReference |
|
@staabm it maybe due to stack nodes on ParentConnectingVisitor, I create an RFC for that, see rectorphp/rector#8035 |
|
@staabm I will check if this can be reduced by using |
|
@TomasVotruba @staabm I am checking PHPStan source, and it seems I am wondering if we can just use that method instead of manually fill the Scope in every use finding cases, I will lookup if that possible. |
|
I don't know enough about the inner workings of rector to answer that question. |
|
@staabm if we can get rid of "scope" attribute, and get the scope from its PHPStan node scope context, that probably will be a real solution. PHPStan has "Virtual" node, that probably a way to resolve Scope from that. |
|
@TomasVotruba @staabm the most scope filling here is for rector-src/src/Application/ChangedNodeScopeRefresher.php Lines 130 to 139 in 77b0bb7 |
|
@staabm @TomasVotruba I created PR #4422 for it. |
No description provided.