Skip to content

Commit

Permalink
fix: lookup variables in dynamic variables
Browse files Browse the repository at this point in the history
  • Loading branch information
didroe committed Sep 28, 2023
1 parent a838f39 commit 9152e1e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/languages/php/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)...)
Expand Down

0 comments on commit 9152e1e

Please sign in to comment.