rename meta to freefloating; refactoring

This commit is contained in:
z7zmey
2019-02-13 22:18:07 +02:00
parent a7082117d9
commit b3800a2595
309 changed files with 9671 additions and 10115 deletions

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Assign node
type Assign struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewAssign node constructor
func NewAssign(Variable node.Node, Expression node.Node) *Assign {
return &Assign{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Assign) GetPosition() *position.Position {
return n.Position
}
func (n *Assign) GetMeta() *meta.Collection {
return &n.Meta
func (n *Assign) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Reference node
type Reference struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewReference node constructor
func NewReference(Variable node.Node, Expression node.Node) *Reference {
return &Reference{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Reference) GetPosition() *position.Position {
return n.Position
}
func (n *Reference) GetMeta() *meta.Collection {
return &n.Meta
func (n *Reference) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseAnd node
type BitwiseAnd struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewBitwiseAnd node constructor
func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd {
return &BitwiseAnd{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseAnd) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseAnd) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseOr node
type BitwiseOr struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewBitwiseOr node constructor
func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr {
return &BitwiseOr{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseOr) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseOr) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseOr) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseXor node
type BitwiseXor struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewBitwiseXor node constructor
func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor {
return &BitwiseXor{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseXor) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseXor) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseXor) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Concat node
type Concat struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewConcat node constructor
func NewConcat(Variable node.Node, Expression node.Node) *Concat {
return &Concat{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Concat) GetPosition() *position.Position {
return n.Position
}
func (n *Concat) GetMeta() *meta.Collection {
return &n.Meta
func (n *Concat) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Div node
type Div struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewDiv node constructor
func NewDiv(Variable node.Node, Expression node.Node) *Div {
return &Div{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Div) GetPosition() *position.Position {
return n.Position
}
func (n *Div) GetMeta() *meta.Collection {
return &n.Meta
func (n *Div) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Minus node
type Minus struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewMinus node constructor
func NewMinus(Variable node.Node, Expression node.Node) *Minus {
return &Minus{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Minus) GetPosition() *position.Position {
return n.Position
}
func (n *Minus) GetMeta() *meta.Collection {
return &n.Meta
func (n *Minus) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Mod node
type Mod struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewMod node constructor
func NewMod(Variable node.Node, Expression node.Node) *Mod {
return &Mod{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Mod) GetPosition() *position.Position {
return n.Position
}
func (n *Mod) GetMeta() *meta.Collection {
return &n.Meta
func (n *Mod) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Mul node
type Mul struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewMul node constructor
func NewMul(Variable node.Node, Expression node.Node) *Mul {
return &Mul{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Mul) GetPosition() *position.Position {
return n.Position
}
func (n *Mul) GetMeta() *meta.Collection {
return &n.Meta
func (n *Mul) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Plus node
type Plus struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewPlus node constructor
func NewPlus(Variable node.Node, Expression node.Node) *Plus {
return &Plus{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Plus) GetPosition() *position.Position {
return n.Position
}
func (n *Plus) GetMeta() *meta.Collection {
return &n.Meta
func (n *Plus) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Pow node
type Pow struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewPow node constructor
func NewPow(Variable node.Node, Expression node.Node) *Pow {
return &Pow{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Pow) GetPosition() *position.Position {
return n.Position
}
func (n *Pow) GetMeta() *meta.Collection {
return &n.Meta
func (n *Pow) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ShiftLeft node
type ShiftLeft struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewShiftLeft node constructor
func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft {
return &ShiftLeft{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *ShiftLeft) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftLeft) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShiftLeft) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package assign
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ShiftRight node
type ShiftRight struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expression node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expression node.Node
}
// NewShiftRight node constructor
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
return &ShiftRight{
Variable: Variable,
Expression: Expression,
FreeFloating: nil,
Variable: Variable,
Expression: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *ShiftRight) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftRight) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShiftRight) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -2,14 +2,13 @@ package assign_test
import (
"bytes"
"reflect"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr/assign"
"github.com/z7zmey/php-parser/position"
"github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/name"
@@ -18,18 +17,6 @@ import (
"github.com/z7zmey/php-parser/php7"
)
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("diff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("expected and actual are not equal\n")
}
}
}
func TestReference(t *testing.T) {
src := `<? $a =& $b;`
@@ -97,12 +84,12 @@ func TestReference(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestReferenceNew(t *testing.T) {
@@ -182,12 +169,12 @@ func TestReferenceNew(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestReferenceArgs(t *testing.T) {
@@ -304,12 +291,12 @@ func TestReferenceArgs(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAssign(t *testing.T) {
@@ -379,12 +366,12 @@ func TestAssign(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBitwiseAnd(t *testing.T) {
@@ -454,12 +441,12 @@ func TestBitwiseAnd(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBitwiseOr(t *testing.T) {
@@ -529,12 +516,12 @@ func TestBitwiseOr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBitwiseXor(t *testing.T) {
@@ -604,12 +591,12 @@ func TestBitwiseXor(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestConcat(t *testing.T) {
@@ -679,12 +666,12 @@ func TestConcat(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestDiv(t *testing.T) {
@@ -754,12 +741,12 @@ func TestDiv(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMinus(t *testing.T) {
@@ -829,12 +816,12 @@ func TestMinus(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMod(t *testing.T) {
@@ -904,12 +891,12 @@ func TestMod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMul(t *testing.T) {
@@ -979,12 +966,12 @@ func TestMul(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPlus(t *testing.T) {
@@ -1054,12 +1041,12 @@ func TestPlus(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPow(t *testing.T) {
@@ -1129,12 +1116,12 @@ func TestPow(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestShiftLeft(t *testing.T) {
@@ -1204,12 +1191,12 @@ func TestShiftLeft(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestShiftRight(t *testing.T) {
@@ -1279,10 +1266,10 @@ func TestShiftRight(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -0,0 +1,81 @@
package assign_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr/assign"
)
var expected freefloating.Collection = freefloating.Collection{
freefloating.Start: []freefloating.String{
{
StringType: freefloating.WhiteSpaceType,
Value: " ",
Position: nil,
},
{
StringType: freefloating.CommentType,
Value: "//comment\n",
Position: nil,
},
},
}
var nodes = []node.Node{
&assign.Reference{
FreeFloating: expected,
},
&assign.Assign{
FreeFloating: expected,
},
&assign.BitwiseAnd{
FreeFloating: expected,
},
&assign.BitwiseOr{
FreeFloating: expected,
},
&assign.BitwiseXor{
FreeFloating: expected,
},
&assign.Concat{
FreeFloating: expected,
},
&assign.Div{
FreeFloating: expected,
},
&assign.Minus{
FreeFloating: expected,
},
&assign.Mod{
FreeFloating: expected,
},
&assign.Mul{
FreeFloating: expected,
},
&assign.Plus{
FreeFloating: expected,
},
&assign.Pow{
FreeFloating: expected,
},
&assign.ShiftLeft{
FreeFloating: expected,
},
&assign.ShiftRight{
FreeFloating: expected,
},
&assign.ShiftRight{
FreeFloating: expected,
},
}
func TestMeta(t *testing.T) {
for _, n := range nodes {
actual := *n.GetFreeFloating()
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,49 +0,0 @@
package assign_test
import (
"testing"
"github.com/z7zmey/php-parser/node/expr/assign"
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/node"
)
var nodes = []node.Node{
&assign.Reference{},
&assign.Assign{},
&assign.BitwiseAnd{},
&assign.BitwiseOr{},
&assign.BitwiseXor{},
&assign.Concat{},
&assign.Div{},
&assign.Minus{},
&assign.Mod{},
&assign.Mul{},
&assign.Plus{},
&assign.Pow{},
&assign.ShiftLeft{},
&assign.ShiftRight{},
&assign.ShiftRight{},
}
func TestMeta(t *testing.T) {
expected := &meta.Collection{
&meta.Data{
Value: "//comment\n",
Type: meta.CommentType,
Position: nil,
},
&meta.Data{
Value: " ",
Type: meta.WhiteSpaceType,
Position: nil,
},
}
for _, n := range nodes {
n.GetMeta().Push(*expected...)
actual := n.GetMeta()
assertEqual(t, expected, actual)
}
}

View File

@@ -3,6 +3,8 @@ package assign_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/position"
)
@@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
for _, n := range nodes {
n.SetPosition(expected)
actual := n.GetPosition()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,15 +1,13 @@
package assign_test
import (
"reflect"
"testing"
"github.com/z7zmey/php-parser/node/expr/assign"
"github.com/kylelemons/godebug/pretty"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/expr/assign"
"github.com/z7zmey/php-parser/walker"
)
@@ -24,7 +22,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Assign{
@@ -32,7 +30,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.BitwiseAnd{
@@ -40,7 +38,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.BitwiseOr{
@@ -48,7 +46,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.BitwiseXor{
@@ -56,7 +54,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Concat{
@@ -64,7 +62,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Div{
@@ -72,7 +70,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Minus{
@@ -80,7 +78,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Mod{
@@ -88,7 +86,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Mul{
@@ -96,7 +94,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Plus{
@@ -104,7 +102,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.Pow{
@@ -112,7 +110,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.ShiftLeft{
@@ -120,7 +118,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
{
&assign.ShiftRight{
@@ -128,7 +126,7 @@ var nodesToTest = []struct {
Expression: &expr.Variable{},
},
[]string{"Variable", "Expression"},
map[string]interface{}{},
nil,
},
}
@@ -150,31 +148,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
func TestVisitorDisableChildren(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{false, nil}
v := &visitorMock{false, []string{}}
tt.node.Walk(v)
expected := []string{}
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
func TestVisitor(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{true, nil}
v := &visitorMock{true, []string{}}
tt.node.Walk(v)
expected := tt.expectedVisitedKeys
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
@@ -185,9 +177,6 @@ func TestNameAttributes(t *testing.T) {
expected := tt.expectedAttributes
actual := tt.node.Attributes()
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseAnd node
type BitwiseAnd struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBitwiseAnd node constructor
func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd {
return &BitwiseAnd{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseAnd) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseAnd) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseOr node
type BitwiseOr struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBitwiseOr node constructor
func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr {
return &BitwiseOr{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseOr) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseOr) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseOr) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseXor node
type BitwiseXor struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBitwiseXor node constructor
func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor {
return &BitwiseXor{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseXor) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseXor) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseXor) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BooleanAnd node
type BooleanAnd struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBooleanAnd node constructor
func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd {
return &BooleanAnd{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BooleanAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BooleanAnd) GetMeta() *meta.Collection {
return &n.Meta
func (n *BooleanAnd) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BooleanOr node
type BooleanOr struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBooleanOr node constructor
func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr {
return &BooleanOr{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BooleanOr) GetPosition() *position.Position {
return n.Position
}
func (n *BooleanOr) GetMeta() *meta.Collection {
return &n.Meta
func (n *BooleanOr) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Coalesce node
type Coalesce struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewCoalesce node constructor
func NewCoalesce(Variable node.Node, Expression node.Node) *Coalesce {
return &Coalesce{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Coalesce) GetPosition() *position.Position {
return n.Position
}
func (n *Coalesce) GetMeta() *meta.Collection {
return &n.Meta
func (n *Coalesce) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Concat node
type Concat struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewConcat node constructor
func NewConcat(Variable node.Node, Expression node.Node) *Concat {
return &Concat{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Concat) GetPosition() *position.Position {
return n.Position
}
func (n *Concat) GetMeta() *meta.Collection {
return &n.Meta
func (n *Concat) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Div node
type Div struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewDiv node constructor
func NewDiv(Variable node.Node, Expression node.Node) *Div {
return &Div{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Div) GetPosition() *position.Position {
return n.Position
}
func (n *Div) GetMeta() *meta.Collection {
return &n.Meta
func (n *Div) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Equal node
type Equal struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewEqual node constructor
func NewEqual(Variable node.Node, Expression node.Node) *Equal {
return &Equal{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Equal) GetPosition() *position.Position {
return n.Position
}
func (n *Equal) GetMeta() *meta.Collection {
return &n.Meta
func (n *Equal) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Greater node
type Greater struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewGreater node constructor
func NewGreater(Variable node.Node, Expression node.Node) *Greater {
return &Greater{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Greater) GetPosition() *position.Position {
return n.Position
}
func (n *Greater) GetMeta() *meta.Collection {
return &n.Meta
func (n *Greater) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// GreaterOrEqual node
type GreaterOrEqual struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewGreaterOrEqual node constructor
func NewGreaterOrEqual(Variable node.Node, Expression node.Node) *GreaterOrEqual {
return &GreaterOrEqual{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *GreaterOrEqual) GetPosition() *position.Position {
return n.Position
}
func (n *GreaterOrEqual) GetMeta() *meta.Collection {
return &n.Meta
func (n *GreaterOrEqual) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Identical node
type Identical struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewIdentical node constructor
func NewIdentical(Variable node.Node, Expression node.Node) *Identical {
return &Identical{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Identical) GetPosition() *position.Position {
return n.Position
}
func (n *Identical) GetMeta() *meta.Collection {
return &n.Meta
func (n *Identical) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// LogicalAnd node
type LogicalAnd struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewLogicalAnd node constructor
func NewLogicalAnd(Variable node.Node, Expression node.Node) *LogicalAnd {
return &LogicalAnd{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *LogicalAnd) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalAnd) GetMeta() *meta.Collection {
return &n.Meta
func (n *LogicalAnd) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// LogicalOr node
type LogicalOr struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewLogicalOr node constructor
func NewLogicalOr(Variable node.Node, Expression node.Node) *LogicalOr {
return &LogicalOr{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *LogicalOr) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalOr) GetMeta() *meta.Collection {
return &n.Meta
func (n *LogicalOr) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// LogicalXor node
type LogicalXor struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewLogicalXor node constructor
func NewLogicalXor(Variable node.Node, Expression node.Node) *LogicalXor {
return &LogicalXor{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *LogicalXor) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalXor) GetMeta() *meta.Collection {
return &n.Meta
func (n *LogicalXor) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Minus node
type Minus struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewMinus node constructor
func NewMinus(Variable node.Node, Expression node.Node) *Minus {
return &Minus{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Minus) GetPosition() *position.Position {
return n.Position
}
func (n *Minus) GetMeta() *meta.Collection {
return &n.Meta
func (n *Minus) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Mod node
type Mod struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewMod node constructor
func NewMod(Variable node.Node, Expression node.Node) *Mod {
return &Mod{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Mod) GetPosition() *position.Position {
return n.Position
}
func (n *Mod) GetMeta() *meta.Collection {
return &n.Meta
func (n *Mod) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Mul node
type Mul struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewMul node constructor
func NewMul(Variable node.Node, Expression node.Node) *Mul {
return &Mul{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Mul) GetPosition() *position.Position {
return n.Position
}
func (n *Mul) GetMeta() *meta.Collection {
return &n.Meta
func (n *Mul) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// NotEqual node
type NotEqual struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewNotEqual node constructor
func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual {
return &NotEqual{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *NotEqual) GetPosition() *position.Position {
return n.Position
}
func (n *NotEqual) GetMeta() *meta.Collection {
return &n.Meta
func (n *NotEqual) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// NotIdentical node
type NotIdentical struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewNotIdentical node constructor
func NewNotIdentical(Variable node.Node, Expression node.Node) *NotIdentical {
return &NotIdentical{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *NotIdentical) GetPosition() *position.Position {
return n.Position
}
func (n *NotIdentical) GetMeta() *meta.Collection {
return &n.Meta
func (n *NotIdentical) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Plus node
type Plus struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewPlus node constructor
func NewPlus(Variable node.Node, Expression node.Node) *Plus {
return &Plus{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Plus) GetPosition() *position.Position {
return n.Position
}
func (n *Plus) GetMeta() *meta.Collection {
return &n.Meta
func (n *Plus) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Pow node
type Pow struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewPow node constructor
func NewPow(Variable node.Node, Expression node.Node) *Pow {
return &Pow{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Pow) GetPosition() *position.Position {
return n.Position
}
func (n *Pow) GetMeta() *meta.Collection {
return &n.Meta
func (n *Pow) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ShiftLeft node
type ShiftLeft struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewShiftLeft node constructor
func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft {
return &ShiftLeft{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *ShiftLeft) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftLeft) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShiftLeft) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ShiftRight node
type ShiftRight struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewShiftRight node constructor
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
return &ShiftRight{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *ShiftRight) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftRight) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShiftRight) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Smaller node
type Smaller struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewSmaller node constructor
func NewSmaller(Variable node.Node, Expression node.Node) *Smaller {
return &Smaller{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Smaller) GetPosition() *position.Position {
return n.Position
}
func (n *Smaller) GetMeta() *meta.Collection {
return &n.Meta
func (n *Smaller) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// SmallerOrEqual node
type SmallerOrEqual struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewSmallerOrEqual node constructor
func NewSmallerOrEqual(Variable node.Node, Expression node.Node) *SmallerOrEqual {
return &SmallerOrEqual{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *SmallerOrEqual) GetPosition() *position.Position {
return n.Position
}
func (n *SmallerOrEqual) GetMeta() *meta.Collection {
return &n.Meta
func (n *SmallerOrEqual) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Spaceship node
type Spaceship struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewSpaceship node constructor
func NewSpaceship(Variable node.Node, Expression node.Node) *Spaceship {
return &Spaceship{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Spaceship) GetPosition() *position.Position {
return n.Position
}
func (n *Spaceship) GetMeta() *meta.Collection {
return &n.Meta
func (n *Spaceship) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -2,10 +2,9 @@ package binary_test
import (
"bytes"
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
@@ -16,18 +15,6 @@ import (
"github.com/z7zmey/php-parser/position"
)
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("diff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("expected and actual are not equal\n")
}
}
}
func TestBitwiseAnd(t *testing.T) {
src := `<? $a & $b;`
@@ -95,12 +82,12 @@ func TestBitwiseAnd(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBitwiseOr(t *testing.T) {
@@ -170,12 +157,12 @@ func TestBitwiseOr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBitwiseXor(t *testing.T) {
@@ -245,12 +232,12 @@ func TestBitwiseXor(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBooleanAnd(t *testing.T) {
@@ -320,12 +307,12 @@ func TestBooleanAnd(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBooleanOr(t *testing.T) {
@@ -395,12 +382,12 @@ func TestBooleanOr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestCoalesce(t *testing.T) {
@@ -470,7 +457,7 @@ func TestCoalesce(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestConcat(t *testing.T) {
@@ -540,12 +527,12 @@ func TestConcat(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestDiv(t *testing.T) {
@@ -615,12 +602,12 @@ func TestDiv(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestEqual(t *testing.T) {
@@ -690,12 +677,12 @@ func TestEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestGreaterOrEqual(t *testing.T) {
@@ -765,12 +752,12 @@ func TestGreaterOrEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestGreater(t *testing.T) {
@@ -840,12 +827,12 @@ func TestGreater(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestIdentical(t *testing.T) {
@@ -915,12 +902,12 @@ func TestIdentical(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestLogicalAnd(t *testing.T) {
@@ -990,12 +977,12 @@ func TestLogicalAnd(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestLogicalOr(t *testing.T) {
@@ -1065,12 +1052,12 @@ func TestLogicalOr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestLogicalXor(t *testing.T) {
@@ -1140,12 +1127,12 @@ func TestLogicalXor(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMinus(t *testing.T) {
@@ -1215,12 +1202,12 @@ func TestMinus(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMod(t *testing.T) {
@@ -1290,12 +1277,12 @@ func TestMod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMul(t *testing.T) {
@@ -1365,12 +1352,12 @@ func TestMul(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestNotEqual(t *testing.T) {
@@ -1440,12 +1427,12 @@ func TestNotEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestNotIdentical(t *testing.T) {
@@ -1515,12 +1502,12 @@ func TestNotIdentical(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPlus(t *testing.T) {
@@ -1590,12 +1577,12 @@ func TestPlus(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPow(t *testing.T) {
@@ -1665,12 +1652,12 @@ func TestPow(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestShiftLeft(t *testing.T) {
@@ -1740,12 +1727,12 @@ func TestShiftLeft(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestShiftRight(t *testing.T) {
@@ -1815,12 +1802,12 @@ func TestShiftRight(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSmallerOrEqual(t *testing.T) {
@@ -1890,12 +1877,12 @@ func TestSmallerOrEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSmaller(t *testing.T) {
@@ -1965,12 +1952,12 @@ func TestSmaller(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSpaceship(t *testing.T) {
@@ -2040,5 +2027,5 @@ func TestSpaceship(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -0,0 +1,117 @@
package binary_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr/binary"
)
var expected freefloating.Collection = freefloating.Collection{
freefloating.Start: []freefloating.String{
{
StringType: freefloating.WhiteSpaceType,
Value: " ",
Position: nil,
},
{
StringType: freefloating.CommentType,
Value: "//comment\n",
Position: nil,
},
},
}
var nodes = []node.Node{
&binary.BitwiseAnd{
FreeFloating: expected,
},
&binary.BitwiseOr{
FreeFloating: expected,
},
&binary.BitwiseXor{
FreeFloating: expected,
},
&binary.BooleanAnd{
FreeFloating: expected,
},
&binary.BooleanOr{
FreeFloating: expected,
},
&binary.Coalesce{
FreeFloating: expected,
},
&binary.Concat{
FreeFloating: expected,
},
&binary.Div{
FreeFloating: expected,
},
&binary.Equal{
FreeFloating: expected,
},
&binary.GreaterOrEqual{
FreeFloating: expected,
},
&binary.Greater{
FreeFloating: expected,
},
&binary.Identical{
FreeFloating: expected,
},
&binary.LogicalAnd{
FreeFloating: expected,
},
&binary.LogicalOr{
FreeFloating: expected,
},
&binary.LogicalXor{
FreeFloating: expected,
},
&binary.Minus{
FreeFloating: expected,
},
&binary.Mod{
FreeFloating: expected,
},
&binary.Mul{
FreeFloating: expected,
},
&binary.NotEqual{
FreeFloating: expected,
},
&binary.NotIdentical{
FreeFloating: expected,
},
&binary.Plus{
FreeFloating: expected,
},
&binary.Pow{
FreeFloating: expected,
},
&binary.ShiftLeft{
FreeFloating: expected,
},
&binary.ShiftRight{
FreeFloating: expected,
},
&binary.SmallerOrEqual{
FreeFloating: expected,
},
&binary.Smaller{
FreeFloating: expected,
},
&binary.Spaceship{
FreeFloating: expected,
},
}
func TestMeta(t *testing.T) {
for _, n := range nodes {
actual := *n.GetFreeFloating()
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,61 +0,0 @@
package binary_test
import (
"testing"
"github.com/z7zmey/php-parser/node/expr/binary"
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/node"
)
var nodes = []node.Node{
&binary.BitwiseAnd{},
&binary.BitwiseOr{},
&binary.BitwiseXor{},
&binary.BooleanAnd{},
&binary.BooleanOr{},
&binary.Coalesce{},
&binary.Concat{},
&binary.Div{},
&binary.Equal{},
&binary.GreaterOrEqual{},
&binary.Greater{},
&binary.Identical{},
&binary.LogicalAnd{},
&binary.LogicalOr{},
&binary.LogicalXor{},
&binary.Minus{},
&binary.Mod{},
&binary.Mul{},
&binary.NotEqual{},
&binary.NotIdentical{},
&binary.Plus{},
&binary.Pow{},
&binary.ShiftLeft{},
&binary.ShiftRight{},
&binary.SmallerOrEqual{},
&binary.Smaller{},
&binary.Spaceship{},
}
func TestMeta(t *testing.T) {
expected := &meta.Collection{
&meta.Data{
Value: "//comment\n",
Type: meta.CommentType,
Position: nil,
},
&meta.Data{
Value: " ",
Type: meta.WhiteSpaceType,
Position: nil,
},
}
for _, n := range nodes {
n.GetMeta().Push(*expected...)
actual := n.GetMeta()
assertEqual(t, expected, actual)
}
}

View File

@@ -3,6 +3,8 @@ package binary_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/position"
)
@@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
for _, n := range nodes {
n.SetPosition(expected)
actual := n.GetPosition()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,15 +1,13 @@
package binary_test
import (
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/expr/binary"
"github.com/z7zmey/php-parser/walker"
"gotest.tools/assert"
)
var nodesToTest = []struct {
@@ -23,7 +21,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BitwiseOr{
@@ -31,7 +29,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BitwiseXor{
@@ -39,7 +37,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BooleanAnd{
@@ -47,7 +45,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BooleanOr{
@@ -55,7 +53,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Coalesce{
@@ -63,7 +61,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Concat{
@@ -71,7 +69,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Div{
@@ -79,7 +77,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Equal{
@@ -87,7 +85,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.GreaterOrEqual{
@@ -95,7 +93,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Greater{
@@ -103,7 +101,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Identical{
@@ -111,7 +109,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.LogicalAnd{
@@ -119,7 +117,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.LogicalOr{
@@ -127,7 +125,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.LogicalXor{
@@ -135,7 +133,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Minus{
@@ -143,7 +141,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Mod{
@@ -151,7 +149,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Mul{
@@ -159,7 +157,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.NotEqual{
@@ -167,7 +165,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.NotIdentical{
@@ -175,7 +173,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Plus{
@@ -183,7 +181,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Pow{
@@ -191,7 +189,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.ShiftLeft{
@@ -199,7 +197,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.ShiftRight{
@@ -207,7 +205,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.SmallerOrEqual{
@@ -215,7 +213,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Smaller{
@@ -223,7 +221,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Spaceship{
@@ -231,7 +229,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
}
@@ -253,31 +251,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
func TestVisitorDisableChildren(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{false, nil}
v := &visitorMock{false, []string{}}
tt.node.Walk(v)
expected := []string{}
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
func TestVisitor(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{true, nil}
v := &visitorMock{true, []string{}}
tt.node.Walk(v)
expected := tt.expectedVisitedKeys
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
@@ -288,9 +280,6 @@ func TestNameAttributes(t *testing.T) {
expected := tt.expectedAttributes
actual := tt.node.Attributes()
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,7 +1,7 @@
package cast
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Array node
type Array struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewArray node constructor
func NewArray(Expr node.Node) *Array {
return &Array{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Array) GetPosition() *position.Position {
return n.Position
}
func (n *Array) GetMeta() *meta.Collection {
return &n.Meta
func (n *Array) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package cast
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Bool node
type Bool struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewBool node constructor
func NewBool(Expr node.Node) *Bool {
return &Bool{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Bool) GetPosition() *position.Position {
return n.Position
}
func (n *Bool) GetMeta() *meta.Collection {
return &n.Meta
func (n *Bool) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package cast
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Double node
type Double struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewDouble node constructor
func NewDouble(Expr node.Node) *Double {
return &Double{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Double) GetPosition() *position.Position {
return n.Position
}
func (n *Double) GetMeta() *meta.Collection {
return &n.Meta
func (n *Double) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package cast
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Int node
type Int struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewInt node constructor
func NewInt(Expr node.Node) *Int {
return &Int{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Int) GetPosition() *position.Position {
return n.Position
}
func (n *Int) GetMeta() *meta.Collection {
return &n.Meta
func (n *Int) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package cast
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Object node
type Object struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewObject node constructor
func NewObject(Expr node.Node) *Object {
return &Object{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Object) GetPosition() *position.Position {
return n.Position
}
func (n *Object) GetMeta() *meta.Collection {
return &n.Meta
func (n *Object) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package cast
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// String node
type String struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewString node constructor
func NewString(Expr node.Node) *String {
return &String{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *String) GetPosition() *position.Position {
return n.Position
}
func (n *String) GetMeta() *meta.Collection {
return &n.Meta
func (n *String) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package cast
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Unset node
type Unset struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewUnset node constructor
func NewUnset(Expr node.Node) *Unset {
return &Unset{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Unset) GetPosition() *position.Position {
return n.Position
}
func (n *Unset) GetMeta() *meta.Collection {
return &n.Meta
func (n *Unset) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -2,10 +2,9 @@ package cast_test
import (
"bytes"
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
@@ -16,18 +15,6 @@ import (
"github.com/z7zmey/php-parser/position"
)
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("diff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("expected and actual are not equal\n")
}
}
}
func TestArray(t *testing.T) {
src := `<? (array)$a;`
@@ -78,12 +65,12 @@ func TestArray(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBool(t *testing.T) {
@@ -136,12 +123,12 @@ func TestBool(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBoolShort(t *testing.T) {
@@ -194,12 +181,12 @@ func TestBoolShort(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestDouble(t *testing.T) {
@@ -252,12 +239,12 @@ func TestDouble(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestCastFloat(t *testing.T) {
@@ -310,12 +297,12 @@ func TestCastFloat(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestInt(t *testing.T) {
@@ -368,12 +355,12 @@ func TestInt(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestIntShort(t *testing.T) {
@@ -426,12 +413,12 @@ func TestIntShort(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestObject(t *testing.T) {
@@ -484,12 +471,12 @@ func TestObject(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestString(t *testing.T) {
@@ -542,12 +529,12 @@ func TestString(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBinaryString(t *testing.T) {
@@ -600,12 +587,12 @@ func TestBinaryString(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUnset(t *testing.T) {
@@ -658,10 +645,10 @@ func TestUnset(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -0,0 +1,57 @@
package cast_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr/cast"
)
var expected freefloating.Collection = freefloating.Collection{
freefloating.Start: []freefloating.String{
{
StringType: freefloating.WhiteSpaceType,
Value: " ",
Position: nil,
},
{
StringType: freefloating.CommentType,
Value: "//comment\n",
Position: nil,
},
},
}
var nodes = []node.Node{
&cast.Array{
FreeFloating: expected,
},
&cast.Bool{
FreeFloating: expected,
},
&cast.Double{
FreeFloating: expected,
},
&cast.Int{
FreeFloating: expected,
},
&cast.Object{
FreeFloating: expected,
},
&cast.String{
FreeFloating: expected,
},
&cast.Unset{
FreeFloating: expected,
},
}
func TestMeta(t *testing.T) {
for _, n := range nodes {
actual := *n.GetFreeFloating()
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,41 +0,0 @@
package cast_test
import (
"testing"
"github.com/z7zmey/php-parser/node/expr/cast"
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/node"
)
var nodes = []node.Node{
&cast.Array{},
&cast.Bool{},
&cast.Double{},
&cast.Int{},
&cast.Object{},
&cast.String{},
&cast.Unset{},
}
func TestMeta(t *testing.T) {
expected := &meta.Collection{
&meta.Data{
Value: "//comment\n",
Type: meta.CommentType,
Position: nil,
},
&meta.Data{
Value: " ",
Type: meta.WhiteSpaceType,
Position: nil,
},
}
for _, n := range nodes {
n.GetMeta().Push(*expected...)
actual := n.GetMeta()
assertEqual(t, expected, actual)
}
}

View File

@@ -3,6 +3,8 @@ package cast_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/position"
)
@@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
for _, n := range nodes {
n.SetPosition(expected)
actual := n.GetPosition()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,10 +1,9 @@
package cast_test
import (
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
@@ -22,49 +21,49 @@ var nodesToTest = []struct {
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&cast.Bool{
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&cast.Double{
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&cast.Int{
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&cast.Object{
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&cast.String{
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&cast.Unset{
Expr: &expr.Variable{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
}
@@ -86,31 +85,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
func TestVisitorDisableChildren(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{false, nil}
v := &visitorMock{false, []string{}}
tt.node.Walk(v)
expected := []string{}
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
func TestVisitor(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{true, nil}
v := &visitorMock{true, []string{}}
tt.node.Walk(v)
expected := tt.expectedVisitedKeys
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
@@ -121,9 +114,6 @@ func TestNameAttributes(t *testing.T) {
expected := tt.expectedAttributes
actual := tt.node.Attributes()
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Array node
type Array struct {
Meta meta.Collection
Position *position.Position
Items []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Items []node.Node
}
// NewArray node constructor
func NewArray(Items []node.Node) *Array {
return &Array{
Items: Items,
FreeFloating: nil,
Items: Items,
}
}
@@ -31,8 +32,8 @@ func (n *Array) GetPosition() *position.Position {
return n.Position
}
func (n *Array) GetMeta() *meta.Collection {
return &n.Meta
func (n *Array) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ArrayDimFetch node
type ArrayDimFetch struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Dim node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Dim node.Node
}
// NewArrayDimFetch node constructor
func NewArrayDimFetch(Variable node.Node, Dim node.Node) *ArrayDimFetch {
return &ArrayDimFetch{
Variable: Variable,
Dim: Dim,
FreeFloating: nil,
Variable: Variable,
Dim: Dim,
}
}
@@ -33,8 +34,8 @@ func (n *ArrayDimFetch) GetPosition() *position.Position {
return n.Position
}
func (n *ArrayDimFetch) GetMeta() *meta.Collection {
return &n.Meta
func (n *ArrayDimFetch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ArrayItem node
type ArrayItem struct {
Meta meta.Collection
Position *position.Position
Key node.Node
Val node.Node
FreeFloating freefloating.Collection
Position *position.Position
Key node.Node
Val node.Node
}
// NewArrayItem node constructor
func NewArrayItem(Key node.Node, Val node.Node) *ArrayItem {
return &ArrayItem{
Key: Key,
Val: Val,
FreeFloating: nil,
Key: Key,
Val: Val,
}
}
@@ -33,8 +34,8 @@ func (n *ArrayItem) GetPosition() *position.Position {
return n.Position
}
func (n *ArrayItem) GetMeta() *meta.Collection {
return &n.Meta
func (n *ArrayItem) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// BitwiseNot node
type BitwiseNot struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewBitwiseNot node constructor
func NewBitwiseNot(Expression node.Node) *BitwiseNot {
return &BitwiseNot{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *BitwiseNot) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseNot) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseNot) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// BooleanNot node
type BooleanNot struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewBooleanNot node constructor
func NewBooleanNot(Expression node.Node) *BooleanNot {
return &BooleanNot{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *BooleanNot) GetPosition() *position.Position {
return n.Position
}
func (n *BooleanNot) GetMeta() *meta.Collection {
return &n.Meta
func (n *BooleanNot) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// ClassConstFetch node
type ClassConstFetch struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
Class node.Node
ConstantName node.Node
@@ -18,6 +18,7 @@ type ClassConstFetch struct {
// NewClassConstFetch node constructor
func NewClassConstFetch(Class node.Node, ConstantName node.Node) *ClassConstFetch {
return &ClassConstFetch{
FreeFloating: nil,
Class: Class,
ConstantName: ConstantName,
}
@@ -33,8 +34,8 @@ func (n *ClassConstFetch) GetPosition() *position.Position {
return n.Position
}
func (n *ClassConstFetch) GetMeta() *meta.Collection {
return &n.Meta
func (n *ClassConstFetch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Clone node
type Clone struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewClone node constructor
func NewClone(Expression node.Node) *Clone {
return &Clone{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *Clone) GetPosition() *position.Position {
return n.Position
}
func (n *Clone) GetMeta() *meta.Collection {
return &n.Meta
func (n *Clone) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Closure node
type Closure struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
ReturnsRef bool
Static bool
@@ -23,6 +23,7 @@ type Closure struct {
// NewClosure node constructor
func NewClosure(Params []node.Node, ClosureUse *ClosureUse, ReturnType node.Node, Stmts []node.Node, Static bool, ReturnsRef bool, PhpDocComment string) *Closure {
return &Closure{
FreeFloating: nil,
ReturnsRef: ReturnsRef,
Static: Static,
PhpDocComment: PhpDocComment,
@@ -43,8 +44,8 @@ func (n *Closure) GetPosition() *position.Position {
return n.Position
}
func (n *Closure) GetMeta() *meta.Collection {
return &n.Meta
func (n *Closure) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ClosureUse node
type ClosureUse struct {
Meta meta.Collection
Position *position.Position
Uses []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Uses []node.Node
}
// NewClosureUse node constructor
func NewClosureUse(Uses []node.Node) *ClosureUse {
return &ClosureUse{
Uses: Uses,
FreeFloating: nil,
Uses: Uses,
}
}
@@ -31,8 +32,8 @@ func (n *ClosureUse) GetPosition() *position.Position {
return n.Position
}
func (n *ClosureUse) GetMeta() *meta.Collection {
return &n.Meta
func (n *ClosureUse) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ConstFetch node
type ConstFetch struct {
Meta meta.Collection
Position *position.Position
Constant node.Node
FreeFloating freefloating.Collection
Position *position.Position
Constant node.Node
}
// NewConstFetch node constructor
func NewConstFetch(Constant node.Node) *ConstFetch {
return &ConstFetch{
Constant: Constant,
FreeFloating: nil,
Constant: Constant,
}
}
@@ -31,8 +32,8 @@ func (n *ConstFetch) GetPosition() *position.Position {
return n.Position
}
func (n *ConstFetch) GetMeta() *meta.Collection {
return &n.Meta
func (n *ConstFetch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Empty node
type Empty struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewEmpty node constructor
func NewEmpty(Expression node.Node) *Empty {
return &Empty{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *Empty) GetPosition() *position.Position {
return n.Position
}
func (n *Empty) GetMeta() *meta.Collection {
return &n.Meta
func (n *Empty) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ErrorSuppress node
type ErrorSuppress struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewErrorSuppress node constructor
func NewErrorSuppress(Expression node.Node) *ErrorSuppress {
return &ErrorSuppress{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *ErrorSuppress) GetPosition() *position.Position {
return n.Position
}
func (n *ErrorSuppress) GetMeta() *meta.Collection {
return &n.Meta
func (n *ErrorSuppress) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Eval node
type Eval struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewEval node constructor
func NewEval(Expression node.Node) *Eval {
return &Eval{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *Eval) GetPosition() *position.Position {
return n.Position
}
func (n *Eval) GetMeta() *meta.Collection {
return &n.Meta
func (n *Eval) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,16 +9,17 @@ import (
// Exit node
type Exit struct {
Meta meta.Collection
Die bool
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Die bool
Position *position.Position
Expr node.Node
}
// NewExit node constructor
func NewExit(Expr node.Node) *Exit {
return &Exit{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -32,8 +33,8 @@ func (n *Exit) GetPosition() *position.Position {
return n.Position
}
func (n *Exit) GetMeta() *meta.Collection {
return &n.Meta
func (n *Exit) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// FunctionCall node
type FunctionCall struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
Function node.Node
ArgumentList *node.ArgumentList
@@ -18,6 +18,7 @@ type FunctionCall struct {
// NewFunctionCall node constructor
func NewFunctionCall(Function node.Node, ArgumentList *node.ArgumentList) *FunctionCall {
return &FunctionCall{
FreeFloating: nil,
Function: Function,
ArgumentList: ArgumentList,
}
@@ -33,8 +34,8 @@ func (n *FunctionCall) GetPosition() *position.Position {
return n.Position
}
func (n *FunctionCall) GetMeta() *meta.Collection {
return &n.Meta
func (n *FunctionCall) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Include node
type Include struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewInclude node constructor
func NewInclude(Expression node.Node) *Include {
return &Include{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *Include) GetPosition() *position.Position {
return n.Position
}
func (n *Include) GetMeta() *meta.Collection {
return &n.Meta
func (n *Include) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// IncludeOnce node
type IncludeOnce struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewIncludeOnce node constructor
func NewIncludeOnce(Expression node.Node) *IncludeOnce {
return &IncludeOnce{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *IncludeOnce) GetPosition() *position.Position {
return n.Position
}
func (n *IncludeOnce) GetMeta() *meta.Collection {
return &n.Meta
func (n *IncludeOnce) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// InstanceOf node
type InstanceOf struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
Class node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
Class node.Node
}
// NewInstanceOf node constructor
func NewInstanceOf(Expr node.Node, Class node.Node) *InstanceOf {
return &InstanceOf{
Expr: Expr,
Class: Class,
FreeFloating: nil,
Expr: Expr,
Class: Class,
}
}
@@ -33,8 +34,8 @@ func (n *InstanceOf) GetPosition() *position.Position {
return n.Position
}
func (n *InstanceOf) GetMeta() *meta.Collection {
return &n.Meta
func (n *InstanceOf) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Isset node
type Isset struct {
Meta meta.Collection
Position *position.Position
Variables []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variables []node.Node
}
// NewIsset node constructor
func NewIsset(Variables []node.Node) *Isset {
return &Isset{
Variables: Variables,
FreeFloating: nil,
Variables: Variables,
}
}
@@ -31,8 +32,8 @@ func (n *Isset) GetPosition() *position.Position {
return n.Position
}
func (n *Isset) GetMeta() *meta.Collection {
return &n.Meta
func (n *Isset) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// List node
type List struct {
Meta meta.Collection
Position *position.Position
Items []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Items []node.Node
}
// NewList node constructor
func NewList(Items []node.Node) *List {
return &List{
Items: Items,
FreeFloating: nil,
Items: Items,
}
}
@@ -31,8 +32,8 @@ func (n *List) GetPosition() *position.Position {
return n.Position
}
func (n *List) GetMeta() *meta.Collection {
return &n.Meta
func (n *List) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// MethodCall node
type MethodCall struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Method node.Node
@@ -19,6 +19,7 @@ type MethodCall struct {
// NewMethodCall node constructor
func NewMethodCall(Variable node.Node, Method node.Node, ArgumentList *node.ArgumentList) *MethodCall {
return &MethodCall{
FreeFloating: nil,
Variable: Variable,
Method: Method,
ArgumentList: ArgumentList,
@@ -35,8 +36,8 @@ func (n *MethodCall) GetPosition() *position.Position {
return n.Position
}
func (n *MethodCall) GetMeta() *meta.Collection {
return &n.Meta
func (n *MethodCall) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// New node
type New struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
Class node.Node
ArgumentList *node.ArgumentList
@@ -18,6 +18,7 @@ type New struct {
// NewNew node constructor
func NewNew(Class node.Node, ArgumentList *node.ArgumentList) *New {
return &New{
FreeFloating: nil,
Class: Class,
ArgumentList: ArgumentList,
}
@@ -33,8 +34,8 @@ func (n *New) GetPosition() *position.Position {
return n.Position
}
func (n *New) GetMeta() *meta.Collection {
return &n.Meta
func (n *New) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// PostDec node
type PostDec struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
}
// NewPostDec node constructor
func NewPostDec(Variable node.Node) *PostDec {
return &PostDec{
Variable: Variable,
FreeFloating: nil,
Variable: Variable,
}
}
@@ -31,8 +32,8 @@ func (n *PostDec) GetPosition() *position.Position {
return n.Position
}
func (n *PostDec) GetMeta() *meta.Collection {
return &n.Meta
func (n *PostDec) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// PostInc node
type PostInc struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
}
// NewPostInc node constructor
func NewPostInc(Variable node.Node) *PostInc {
return &PostInc{
Variable: Variable,
FreeFloating: nil,
Variable: Variable,
}
}
@@ -31,8 +32,8 @@ func (n *PostInc) GetPosition() *position.Position {
return n.Position
}
func (n *PostInc) GetMeta() *meta.Collection {
return &n.Meta
func (n *PostInc) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// PreDec node
type PreDec struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
}
// NewPreDec node constructor
func NewPreDec(Variable node.Node) *PreDec {
return &PreDec{
Variable: Variable,
FreeFloating: nil,
Variable: Variable,
}
}
@@ -31,8 +32,8 @@ func (n *PreDec) GetPosition() *position.Position {
return n.Position
}
func (n *PreDec) GetMeta() *meta.Collection {
return &n.Meta
func (n *PreDec) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// PreInc node
type PreInc struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
}
// NewPreInc node constructor
func NewPreInc(Variable node.Node) *PreInc {
return &PreInc{
Variable: Variable,
FreeFloating: nil,
Variable: Variable,
}
}
@@ -31,8 +32,8 @@ func (n *PreInc) GetPosition() *position.Position {
return n.Position
}
func (n *PreInc) GetMeta() *meta.Collection {
return &n.Meta
func (n *PreInc) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Print node
type Print struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewPrint node constructor
func NewPrint(Expression node.Node) *Print {
return &Print{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *Print) GetPosition() *position.Position {
return n.Position
}
func (n *Print) GetMeta() *meta.Collection {
return &n.Meta
func (n *Print) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// PropertyFetch node
type PropertyFetch struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Property node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Property node.Node
}
// NewPropertyFetch node constructor
func NewPropertyFetch(Variable node.Node, Property node.Node) *PropertyFetch {
return &PropertyFetch{
Variable: Variable,
Property: Property,
FreeFloating: nil,
Variable: Variable,
Property: Property,
}
}
@@ -33,8 +34,8 @@ func (n *PropertyFetch) GetPosition() *position.Position {
return n.Position
}
func (n *PropertyFetch) GetMeta() *meta.Collection {
return &n.Meta
func (n *PropertyFetch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Reference node
type Reference struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
}
// NewReference node constructor
func NewReference(Variable node.Node) *Reference {
return &Reference{
Variable: Variable,
FreeFloating: nil,
Variable: Variable,
}
}
@@ -31,8 +32,8 @@ func (n *Reference) GetPosition() *position.Position {
return n.Position
}
func (n *Reference) GetMeta() *meta.Collection {
return &n.Meta
func (n *Reference) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Require node
type Require struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewRequire node constructor
func NewRequire(Expression node.Node) *Require {
return &Require{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *Require) GetPosition() *position.Position {
return n.Position
}
func (n *Require) GetMeta() *meta.Collection {
return &n.Meta
func (n *Require) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// RequireOnce node
type RequireOnce struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewRequireOnce node constructor
func NewRequireOnce(Expression node.Node) *RequireOnce {
return &RequireOnce{
Expr: Expression,
FreeFloating: nil,
Expr: Expression,
}
}
@@ -31,8 +32,8 @@ func (n *RequireOnce) GetPosition() *position.Position {
return n.Position
}
func (n *RequireOnce) GetMeta() *meta.Collection {
return &n.Meta
func (n *RequireOnce) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ShellExec node
type ShellExec struct {
Meta meta.Collection
Position *position.Position
Parts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Parts []node.Node
}
// NewShellExec node constructor
func NewShellExec(Parts []node.Node) *ShellExec {
return &ShellExec{
Parts: Parts,
FreeFloating: nil,
Parts: Parts,
}
}
@@ -31,8 +32,8 @@ func (n *ShellExec) GetPosition() *position.Position {
return n.Position
}
func (n *ShellExec) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShellExec) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ShortArray node
type ShortArray struct {
Meta meta.Collection
Position *position.Position
Items []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Items []node.Node
}
// NewShortArray node constructor
func NewShortArray(Items []node.Node) *ShortArray {
return &ShortArray{
Items: Items,
FreeFloating: nil,
Items: Items,
}
}
@@ -31,8 +32,8 @@ func (n *ShortArray) GetPosition() *position.Position {
return n.Position
}
func (n *ShortArray) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShortArray) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ShortList node
type ShortList struct {
Meta meta.Collection
Position *position.Position
Items []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Items []node.Node
}
// NewShortList node constructor
func NewShortList(Items []node.Node) *ShortList {
return &ShortList{
Items: Items,
FreeFloating: nil,
Items: Items,
}
}
@@ -31,8 +32,8 @@ func (n *ShortList) GetPosition() *position.Position {
return n.Position
}
func (n *ShortList) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShortList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// StaticCall node
type StaticCall struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
Class node.Node
Call node.Node
@@ -19,6 +19,7 @@ type StaticCall struct {
// NewStaticCall node constructor
func NewStaticCall(Class node.Node, Call node.Node, ArgumentList *node.ArgumentList) *StaticCall {
return &StaticCall{
FreeFloating: nil,
Class: Class,
Call: Call,
ArgumentList: ArgumentList,
@@ -35,8 +36,8 @@ func (n *StaticCall) GetPosition() *position.Position {
return n.Position
}
func (n *StaticCall) GetMeta() *meta.Collection {
return &n.Meta
func (n *StaticCall) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// StaticPropertyFetch node
type StaticPropertyFetch struct {
Meta meta.Collection
Position *position.Position
Class node.Node
Property node.Node
FreeFloating freefloating.Collection
Position *position.Position
Class node.Node
Property node.Node
}
// NewStaticPropertyFetch node constructor
func NewStaticPropertyFetch(Class node.Node, Property node.Node) *StaticPropertyFetch {
return &StaticPropertyFetch{
Class: Class,
Property: Property,
FreeFloating: nil,
Class: Class,
Property: Property,
}
}
@@ -33,8 +34,8 @@ func (n *StaticPropertyFetch) GetPosition() *position.Position {
return n.Position
}
func (n *StaticPropertyFetch) GetMeta() *meta.Collection {
return &n.Meta
func (n *StaticPropertyFetch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package expr
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,19 +9,20 @@ import (
// Ternary node
type Ternary struct {
Meta meta.Collection
Position *position.Position
Condition node.Node
IfTrue node.Node
IfFalse node.Node
FreeFloating freefloating.Collection
Position *position.Position
Condition node.Node
IfTrue node.Node
IfFalse node.Node
}
// NewTernary node constructor
func NewTernary(Condition node.Node, IfTrue node.Node, IfFalse node.Node) *Ternary {
return &Ternary{
Condition: Condition,
IfTrue: IfTrue,
IfFalse: IfFalse,
FreeFloating: nil,
Condition: Condition,
IfTrue: IfTrue,
IfFalse: IfFalse,
}
}
@@ -35,8 +36,8 @@ func (n *Ternary) GetPosition() *position.Position {
return n.Position
}
func (n *Ternary) GetMeta() *meta.Collection {
return &n.Meta
func (n *Ternary) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

Some files were not shown because too many files have changed in this diff Show More