Skip to content

Commit 38141ce

Browse files
committed
refactoring: create "ScalarEncapsedStringVar" node
1 parent e4321b5 commit 38141ce

File tree

14 files changed

+361
-327
lines changed

14 files changed

+361
-327
lines changed

internal/php5/parser_test.go

Lines changed: 48 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4335,14 +4335,14 @@ func TestScalarEncapsed_DollarOpenCurlyBraces(t *testing.T) {
43354335
},
43364336
Value: []byte("test "),
43374337
},
4338-
&ast.ParserBrackets{
4338+
&ast.ScalarEncapsedStringVar{
43394339
Position: &position.Position{
43404340
StartLine: 1,
43414341
EndLine: 1,
43424342
StartPos: 9,
43434343
EndPos: 15,
43444344
},
4345-
OpenBracketTkn: &token.Token{
4345+
DollarOpenCurlyBracketTkn: &token.Token{
43464346
ID: token.T_DOLLAR_OPEN_CURLY_BRACES,
43474347
Value: []byte("${"),
43484348
Position: &position.Position{
@@ -4352,34 +4352,26 @@ func TestScalarEncapsed_DollarOpenCurlyBraces(t *testing.T) {
43524352
EndPos: 11,
43534353
},
43544354
},
4355-
Child: &ast.ExprVariable{
4355+
VarName: &ast.Identifier{
43564356
Position: &position.Position{
43574357
StartLine: 1,
43584358
EndLine: 1,
43594359
StartPos: 11,
43604360
EndPos: 14,
43614361
},
4362-
VarName: &ast.Identifier{
4362+
IdentifierTkn: &token.Token{
4363+
ID: token.T_STRING_VARNAME,
4364+
Value: []byte("foo"),
43634365
Position: &position.Position{
43644366
StartLine: 1,
43654367
EndLine: 1,
43664368
StartPos: 11,
43674369
EndPos: 14,
43684370
},
4369-
IdentifierTkn: &token.Token{
4370-
ID: token.T_STRING_VARNAME,
4371-
Value: []byte("foo"),
4372-
Position: &position.Position{
4373-
StartLine: 1,
4374-
EndLine: 1,
4375-
StartPos: 11,
4376-
EndPos: 14,
4377-
},
4378-
},
4379-
Value: []byte("foo"),
43804371
},
4372+
Value: []byte("foo"),
43814373
},
4382-
CloseBracketTkn: &token.Token{
4374+
CloseCurlyBracketTkn: &token.Token{
43834375
ID: token.ID(125),
43844376
Value: []byte("}"),
43854377
Position: &position.Position{
@@ -4501,14 +4493,14 @@ func TestScalarEncapsed_DollarOpenCurlyBracesDimNumber(t *testing.T) {
45014493
},
45024494
Value: []byte("test "),
45034495
},
4504-
&ast.ParserBrackets{
4496+
&ast.ScalarEncapsedStringVar{
45054497
Position: &position.Position{
45064498
StartLine: 1,
45074499
EndLine: 1,
45084500
StartPos: 9,
4509-
EndPos: 18,
4501+
EndPos: 15,
45104502
},
4511-
OpenBracketTkn: &token.Token{
4503+
DollarOpenCurlyBracketTkn: &token.Token{
45124504
ID: token.T_DOLLAR_OPEN_CURLY_BRACES,
45134505
Value: []byte("${"),
45144506
Position: &position.Position{
@@ -4518,81 +4510,65 @@ func TestScalarEncapsed_DollarOpenCurlyBracesDimNumber(t *testing.T) {
45184510
EndPos: 11,
45194511
},
45204512
},
4521-
Child: &ast.ExprArrayDimFetch{
4513+
VarName: &ast.Identifier{
45224514
Position: &position.Position{
45234515
StartLine: 1,
45244516
EndLine: 1,
45254517
StartPos: 11,
4526-
EndPos: 17,
4518+
EndPos: 14,
45274519
},
4528-
Var: &ast.ExprVariable{
4520+
IdentifierTkn: &token.Token{
4521+
ID: token.T_STRING_VARNAME,
4522+
Value: []byte("foo"),
45294523
Position: &position.Position{
45304524
StartLine: 1,
45314525
EndLine: 1,
45324526
StartPos: 11,
45334527
EndPos: 14,
45344528
},
4535-
VarName: &ast.Identifier{
4536-
Position: &position.Position{
4537-
StartLine: 1,
4538-
EndLine: 1,
4539-
StartPos: 11,
4540-
EndPos: 14,
4541-
},
4542-
IdentifierTkn: &token.Token{
4543-
ID: token.T_STRING_VARNAME,
4544-
Value: []byte("foo"),
4545-
Position: &position.Position{
4546-
StartLine: 1,
4547-
EndLine: 1,
4548-
StartPos: 11,
4549-
EndPos: 14,
4550-
},
4551-
},
4552-
Value: []byte("foo"),
4553-
},
45544529
},
4555-
OpenBracketTkn: &token.Token{
4556-
ID: token.ID(91),
4557-
Value: []byte("["),
4558-
Position: &position.Position{
4559-
StartLine: 1,
4560-
EndLine: 1,
4561-
StartPos: 14,
4562-
EndPos: 15,
4563-
},
4530+
Value: []byte("foo"),
4531+
},
4532+
OpenSquareBracketTkn: &token.Token{
4533+
ID: token.ID(91),
4534+
Value: []byte("["),
4535+
Position: &position.Position{
4536+
StartLine: 1,
4537+
EndLine: 1,
4538+
StartPos: 14,
4539+
EndPos: 15,
45644540
},
4565-
Dim: &ast.ScalarLnumber{
4541+
},
4542+
Dim: &ast.ScalarLnumber{
4543+
Position: &position.Position{
4544+
StartLine: 1,
4545+
EndLine: 1,
4546+
StartPos: 15,
4547+
EndPos: 16,
4548+
},
4549+
NumberTkn: &token.Token{
4550+
ID: token.T_LNUMBER,
4551+
Value: []byte("0"),
45664552
Position: &position.Position{
45674553
StartLine: 1,
45684554
EndLine: 1,
45694555
StartPos: 15,
45704556
EndPos: 16,
45714557
},
4572-
NumberTkn: &token.Token{
4573-
ID: token.T_LNUMBER,
4574-
Value: []byte("0"),
4575-
Position: &position.Position{
4576-
StartLine: 1,
4577-
EndLine: 1,
4578-
StartPos: 15,
4579-
EndPos: 16,
4580-
},
4581-
},
4582-
Value: []byte("0"),
45834558
},
4584-
CloseBracketTkn: &token.Token{
4585-
ID: token.ID(93),
4586-
Value: []byte("]"),
4587-
Position: &position.Position{
4588-
StartLine: 1,
4589-
EndLine: 1,
4590-
StartPos: 16,
4591-
EndPos: 17,
4592-
},
4559+
Value: []byte("0"),
4560+
},
4561+
CloseSquareBracketTkn: &token.Token{
4562+
ID: token.ID(93),
4563+
Value: []byte("]"),
4564+
Position: &position.Position{
4565+
StartLine: 1,
4566+
EndLine: 1,
4567+
StartPos: 16,
4568+
EndPos: 17,
45934569
},
45944570
},
4595-
CloseBracketTkn: &token.Token{
4571+
CloseCurlyBracketTkn: &token.Token{
45964572
ID: token.ID(125),
45974573
Value: []byte("}"),
45984574
Position: &position.Position{

0 commit comments

Comments
 (0)