Merge branch 'master' into dev
This commit is contained in:
commit
a69e899f04
@ -1,9 +1 @@
|
||||
Issue Description
|
||||
|
||||
```php
|
||||
// PHP code trying to parse
|
||||
```
|
||||
|
||||
```
|
||||
// console output
|
||||
```
|
||||
|
@ -551,10 +551,18 @@ func (p *PrettyPrinter) printScalarEncapsedStringPart(n node.Node) {
|
||||
}
|
||||
|
||||
func (p *PrettyPrinter) printScalarEncapsed(n node.Node) {
|
||||
nn := n.(*scalar.Encapsed)
|
||||
io.WriteString(p.w, "\"")
|
||||
|
||||
for _, nn := range n.(*scalar.Encapsed).Parts {
|
||||
p.Print(nn)
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
case *scalar.EncapsedStringPart:
|
||||
p.Print(part)
|
||||
default:
|
||||
io.WriteString(p.w, "{")
|
||||
p.Print(part)
|
||||
io.WriteString(p.w, "}")
|
||||
}
|
||||
}
|
||||
|
||||
io.WriteString(p.w, "\"")
|
||||
@ -567,8 +575,15 @@ func (p *PrettyPrinter) printScalarHeredoc(n node.Node) {
|
||||
io.WriteString(p.w, nn.Label)
|
||||
io.WriteString(p.w, "\n")
|
||||
|
||||
for _, nn := range nn.Parts {
|
||||
p.Print(nn)
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
case *scalar.EncapsedStringPart:
|
||||
p.Print(part)
|
||||
default:
|
||||
io.WriteString(p.w, "{")
|
||||
p.Print(part)
|
||||
io.WriteString(p.w, "}")
|
||||
}
|
||||
}
|
||||
|
||||
io.WriteString(p.w, strings.Trim(nn.Label, "\"'"))
|
||||
@ -1232,7 +1247,14 @@ func (p *PrettyPrinter) printExprShellExec(n node.Node) {
|
||||
|
||||
io.WriteString(p.w, "`")
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
case *scalar.EncapsedStringPart:
|
||||
p.Print(part)
|
||||
default:
|
||||
io.WriteString(p.w, "{")
|
||||
p.Print(part)
|
||||
io.WriteString(p.w, "}")
|
||||
}
|
||||
}
|
||||
io.WriteString(p.w, "`")
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ func TestPrintScalarEncapsed(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
if o.String() != `"hello $var world"` {
|
||||
if o.String() != `"hello {$var} world"` {
|
||||
t.Errorf("TestPrintScalarEncapsed is failed\n")
|
||||
}
|
||||
}
|
||||
@ -365,7 +365,7 @@ func TestPrintScalarHeredoc(t *testing.T) {
|
||||
})
|
||||
|
||||
expected := `<<<LBL
|
||||
hello $var world
|
||||
hello {$var} world
|
||||
LBL`
|
||||
actual := o.String()
|
||||
|
||||
@ -1844,7 +1844,7 @@ func TestPrintShellExec(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
expected := "`hello $world!`"
|
||||
expected := "`hello {$world}!`"
|
||||
actual := o.String()
|
||||
|
||||
if expected != actual {
|
||||
|
@ -629,7 +629,15 @@ func (p *Printer) printScalarEncapsed(n node.Node) {
|
||||
io.WriteString(p.w, "\"")
|
||||
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
case *scalar.EncapsedStringPart:
|
||||
p.Print(part)
|
||||
default:
|
||||
io.WriteString(p.w, "{")
|
||||
p.Print(part)
|
||||
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
||||
io.WriteString(p.w, "}")
|
||||
}
|
||||
}
|
||||
|
||||
io.WriteString(p.w, "\"")
|
||||
@ -647,8 +655,16 @@ func (p *Printer) printScalarHeredoc(n node.Node) {
|
||||
io.WriteString(p.w, nn.Label)
|
||||
io.WriteString(p.w, "\n")
|
||||
|
||||
for _, nn := range nn.Parts {
|
||||
p.Print(nn)
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
case *scalar.EncapsedStringPart:
|
||||
p.Print(part)
|
||||
default:
|
||||
io.WriteString(p.w, "{")
|
||||
p.Print(part)
|
||||
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
||||
io.WriteString(p.w, "}")
|
||||
}
|
||||
}
|
||||
|
||||
io.WriteString(p.w, strings.Trim(nn.Label, "\"'"))
|
||||
@ -1681,7 +1697,15 @@ func (p *Printer) printExprShellExec(n node.Node) {
|
||||
p.printMeta(nn, meta.BackquoteToken)
|
||||
io.WriteString(p.w, "`")
|
||||
for _, part := range nn.Parts {
|
||||
switch part.(type) {
|
||||
case *scalar.EncapsedStringPart:
|
||||
p.Print(part)
|
||||
default:
|
||||
io.WriteString(p.w, "{")
|
||||
p.Print(part)
|
||||
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
||||
io.WriteString(p.w, "}")
|
||||
}
|
||||
}
|
||||
io.WriteString(p.w, "`")
|
||||
|
||||
|
@ -246,7 +246,7 @@ func TestParseAndPrintPropertyFetchPrint(t *testing.T) {
|
||||
func TestParseAndPrintForeachReferenceShellExec(t *testing.T) {
|
||||
src := `<?php
|
||||
foreach ( $a as $k => & $v ) {
|
||||
` + "` $v cmd `" + ` ;
|
||||
` + "` {$v} cmd `" + ` ;
|
||||
}`
|
||||
|
||||
actual := print(parse(src))
|
||||
@ -714,7 +714,7 @@ func TestParseAndPrintScalar(t *testing.T) {
|
||||
.2 ;
|
||||
0.2 ;
|
||||
'Hello' ;
|
||||
"Hello $world";
|
||||
"Hello {$world}";
|
||||
`
|
||||
|
||||
actual := print(parse(src))
|
||||
|
@ -555,7 +555,7 @@ func TestPrinterPrintScalarEncapsed(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
if o.String() != ` "hello $var world"` {
|
||||
if o.String() != ` "hello {$var} world"` {
|
||||
t.Errorf("TestPrintScalarEncapsed is failed\n")
|
||||
}
|
||||
}
|
||||
@ -580,7 +580,7 @@ func TestPrinterPrintScalarHeredoc(t *testing.T) {
|
||||
})
|
||||
|
||||
expected := ` <<<LBL
|
||||
hello $var world
|
||||
hello {$var} world
|
||||
LBL`
|
||||
actual := o.String()
|
||||
|
||||
@ -2764,7 +2764,7 @@ func TestPrinterPrintShellExec(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
expected := " `hello $world!`"
|
||||
expected := " `hello {$world}!`"
|
||||
actual := o.String()
|
||||
|
||||
if expected != actual {
|
||||
|
Loading…
Reference in New Issue
Block a user