[refactoring] keep $ in variable identifier

This commit is contained in:
Vadym Slizov
2020-06-30 00:45:15 +03:00
parent d7652b1c7f
commit ee3fe3b5c0
13 changed files with 2481 additions and 2619 deletions

View File

@@ -1,10 +1,11 @@
package printer
import (
"github.com/z7zmey/php-parser/pkg/ast"
"github.com/z7zmey/php-parser/pkg/token"
"io"
"strings"
"github.com/z7zmey/php-parser/pkg/ast"
"github.com/z7zmey/php-parser/pkg/token"
)
type printerState int
@@ -1860,7 +1861,7 @@ func (p *Printer) printExprVariable(n ast.Vertex) {
p.printFreeFloating(nn, token.Start)
p.printFreeFloating(nn, token.Dollar)
if nn.GetNode().Tokens.IsEmpty() {
if _, ok := nn.VarName.(*ast.Identifier); !ok {
io.WriteString(p.w, "$")
}

View File

@@ -1084,7 +1084,7 @@ func TestParseAndPrintPhp5Shebang(t *testing.T) {
<?php
$a;?>test<? `
actual := print(parse(src))
actual := printPhp5(parsePhp5(src))
if src != actual {
t.Errorf("\nexpected: %s\ngot: %s\n", src, actual)

File diff suppressed because it is too large Load Diff