From 9152e1ef46cf4f03f97194ec3ad641e31e1fd987 Mon Sep 17 00:00:00 2001 From: David Roe Date: Thu, 28 Sep 2023 16:25:00 +0100 Subject: [PATCH] fix: lookup variables in dynamic variables --- internal/languages/php/analyzer/analyzer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/languages/php/analyzer/analyzer.go b/internal/languages/php/analyzer/analyzer.go index 7949b3cdd..95af2e610 100644 --- a/internal/languages/php/analyzer/analyzer.go +++ b/internal/languages/php/analyzer/analyzer.go @@ -45,6 +45,8 @@ func (analyzer *analyzer) Analyze(node *sitter.Node, visitChildren func() error) return analyzer.analyzeGenericConstruct(node, visitChildren) case "switch_label": return visitChildren() + case "dynamic_variable_name": + return analyzer.analyzeDynamicVariableName(node, visitChildren) case "binary_expression", "unary_op_expression", "argument", @@ -168,6 +170,12 @@ func (analyzer *analyzer) analyzeSwitch(node *sitter.Node, visitChildren func() return visitChildren() } +func (analyzer *analyzer) analyzeDynamicVariableName(node *sitter.Node, visitChildren func() error) error { + analyzer.lookupVariable(node.NamedChild(0)) + + return visitChildren() +} + // default analysis, where the children are assumed to be aliases func (analyzer *analyzer) analyzeGenericConstruct(node *sitter.Node, visitChildren func() error) error { analyzer.builder.Alias(node, analyzer.builder.ChildrenFor(node)...)