From a593760569778bbd0a4f091e80288f78fd57bc98 Mon Sep 17 00:00:00 2001 From: Vadym Slizov Date: Sat, 26 Dec 2020 22:38:35 +0200 Subject: [PATCH] refactoring: remove ExprReference node --- internal/php5/php5.go | Bin 264719 -> 264709 bytes internal/php5/php5.y | 10 ++-- internal/php7/php7.go | Bin 219194 -> 219188 bytes internal/php7/php7.y | 6 +-- pkg/ast/ast.go | 1 - pkg/ast/node.go | 15 ------ pkg/ast/traverser/dfs.go | 12 ----- pkg/ast/visitor/dumper.go | 12 ----- pkg/ast/visitor/formatter.go | 5 -- pkg/ast/visitor/formatter_test.go | 25 ---------- pkg/ast/visitor/null.go | 4 -- pkg/ast/visitor/printer.go | 5 -- pkg/ast/visitor/printer_test.go | 75 +++++++++++++++++++----------- 13 files changed, 57 insertions(+), 113 deletions(-) diff --git a/internal/php5/php5.go b/internal/php5/php5.go index 392b1132d53396f555d692f1c4d9e96d9fca5d7f..f002d9350497d3cb23729743b41107726741b937 100644 GIT binary patch delta 87 zcmeC5BG5WTpkWK+_DRz%CNc6%e=&`5ADFd$;$%ioW;DU+K*7@Onll)CO{XVZWt5)& ap@mUpdV&a(dAr^@Mj&R|u6K_4p)~;XVj>0r delta 138 zcmZpjBG5lYpkWK+_DQ_16$M2>scET2sd>q%(;rS_+>a`>y=O9`7c;6D7G=|c%F4DY z&S2~{o&I486U+32l}r}X8{!%DrZ@008Bd>ohLLajgi$val):$d;endforeach;` + actual := o.String() + + if expected != actual { + t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual) + } +} + +func TestPrinterPrintAltForeach_Reference(t *testing.T) { + o := bytes.NewBufferString("") + + p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP) + n := &ast.StmtForeach{ + Expr: &ast.ExprVariable{ + VarName: &ast.Identifier{Value: []byte("$var")}, + }, + Key: &ast.ExprVariable{ + VarName: &ast.Identifier{Value: []byte("$key")}, + }, + AmpersandTkn: &token.Token{ + Value: []byte("&"), + }, + Var: &ast.ExprVariable{ + VarName: &ast.Identifier{Value: []byte("$val")}, + }, ColonTkn: &token.Token{ Value: []byte(":"), },