Compare commits
13 Commits
33d9423421
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d2a9e423a | |||
| 966682546c | |||
| 65868e812d | |||
| aa809cad77 | |||
|
|
59da1fe671 | ||
|
|
deeda4f6a7 | ||
|
|
87718f9993 | ||
|
|
e3aaf7bd13 | ||
|
|
9281143091 | ||
|
|
6855357aaa | ||
|
|
3c45afd848 | ||
|
|
5baa28bb27 | ||
|
|
6d1eee5a79 |
@@ -1,4 +1,4 @@
|
||||
> This is a fork of the [VKCOM php-parse](https://github.com/VKCOM/php-parser), which in itself is a fork of [z7zmey](https://github.com/z7zmey) [parser](https://github.com/z7zmey/php-parser) that adds PHP 8 support.
|
||||
> This is a merge of [laytan/php-parser](https://github.com/laytan/php-parser) and [jeremybobbin/php-parser](https://github.com/jeremybobbin/php-parser), fixing some crashes in [VKCOM php-parse](https://github.com/VKCOM/php-parser), which in itself is a fork of [z7zmey](https://github.com/z7zmey) [parser](https://github.com/z7zmey/php-parser) that adds PHP 8 support.
|
||||
|
||||
PHP Parser written in Go
|
||||
========================
|
||||
@@ -111,7 +111,7 @@ php-parser [flags] <path> ...
|
||||
Namespace resolver
|
||||
------------------
|
||||
|
||||
Namespace resolver is a visitor that resolves nodes fully qualified name and saves into `map[node.Node]string` structure
|
||||
Namespace resolver is a visitor that resolves nodes fully qualified name and saves into `map[ast.Vertex]string` structure
|
||||
|
||||
- For `Class`, `Interface`, `Trait`, `Function`, `Constant` nodes it saves name with current namespace.
|
||||
- For `Class`, `Interface`, `Trait`, `Enum`, `Function`, `Constant` nodes it saves name with current namespace.
|
||||
- For `Name`, `Relative`, `FullyQualified` nodes it resolves `use` aliases and saves a fully qualified name.
|
||||
|
||||
@@ -16,15 +16,15 @@ import (
|
||||
"github.com/pkg/profile"
|
||||
"github.com/yookoala/realpath"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/parser"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"github.com/laytan/php-parser/pkg/visitor/dumper"
|
||||
"github.com/laytan/php-parser/pkg/visitor/nsresolver"
|
||||
"github.com/laytan/php-parser/pkg/visitor/printer"
|
||||
"github.com/laytan/php-parser/pkg/visitor/traverser"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/parser"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/dumper"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/nsresolver"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/printer"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/traverser"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
13
go.mod
13
go.mod
@@ -1,15 +1,18 @@
|
||||
module github.com/laytan/php-parser
|
||||
module git.maride.cc/maride/php-parser
|
||||
|
||||
go 1.13
|
||||
go 1.21.1
|
||||
|
||||
require (
|
||||
github.com/pkg/profile v1.4.0
|
||||
github.com/pkg/profile v1.7.0
|
||||
github.com/yookoala/realpath v1.0.0
|
||||
golang.org/x/tools v0.16.0
|
||||
gotest.tools v2.2.0+incompatible
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/google/go-cmp v0.4.0 // indirect
|
||||
github.com/felixge/fgprof v0.9.3 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
golang.org/x/tools v0.7.0
|
||||
golang.org/x/mod v0.14.0 // indirect
|
||||
)
|
||||
|
||||
79
go.sum
79
go.sum
@@ -1,52 +1,39 @@
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.4.0 h1:uCmaf4vVbWAOZz36k1hrQD7ijGRzLwaME8Am/7a4jZI=
|
||||
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
|
||||
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
|
||||
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/yookoala/realpath v1.0.0 h1:7OA9pj4FZd+oZDsyvXWQvjn5oBdcHRTV44PpdMSuImQ=
|
||||
github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
|
||||
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
|
||||
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
||||
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
|
||||
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM=
|
||||
golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"bytes"
|
||||
"strings"
|
||||
|
||||
pos "github.com/laytan/php-parser/internal/position"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
pos "git.maride.cc/maride/php-parser/internal/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
type Lexer struct {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package php7
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
type ParserBrackets struct {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package php7
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/internal/position"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/internal/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
// Parser structure
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
4
internal/php7/php7.go
generated
4
internal/php7/php7.go
generated
@@ -11,8 +11,8 @@ import __yyfmt__ "fmt"
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
// line internal/php7/php7.y:13
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func BenchmarkPhp7(b *testing.B) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
// line internal/php7/scanner.go:15
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"gotest.tools/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func TestTokens(t *testing.T) {
|
||||
|
||||
@@ -3,10 +3,10 @@ package php8
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/laytan/php-parser/internal/position"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
position2 "github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/internal/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
position2 "git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
// Builder is responsible for creating nodes inside grammar rules.
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"bytes"
|
||||
"strings"
|
||||
|
||||
pos "github.com/laytan/php-parser/internal/position"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
pos "git.maride.cc/maride/php-parser/internal/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
type Lexer struct {
|
||||
@@ -67,6 +67,24 @@ func (lex *Lexer) setTokenPosition(token *token.Token) {
|
||||
token.Position = pos
|
||||
}
|
||||
|
||||
func (lex *Lexer) setTokenPrefixPosition(token *token.Token, n int) {
|
||||
pos := lex.positionPool.Get()
|
||||
|
||||
endPos := lex.ts + n
|
||||
|
||||
sl, slb := lex.newLines.GetLine(lex.ts)
|
||||
el, elb := lex.newLines.GetLine(endPos)
|
||||
|
||||
pos.StartLine = sl
|
||||
pos.EndLine = el
|
||||
pos.StartPos = lex.ts
|
||||
pos.EndPos = endPos
|
||||
pos.StartCol = lex.ts - slb
|
||||
pos.EndCol = endPos - elb
|
||||
|
||||
token.Position = pos
|
||||
}
|
||||
|
||||
func (lex *Lexer) addFreeFloatingToken(t *token.Token, id token.ID, ps, pe int) {
|
||||
skippedTkn := lex.tokenPool.Get()
|
||||
skippedTkn.ID = id
|
||||
@@ -198,6 +216,11 @@ func (lex *Lexer) ungetStr(s string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (lex *Lexer) ungetFromStart(n int) {
|
||||
tokenLength := lex.te - lex.ts
|
||||
lex.ungetCnt(tokenLength - n)
|
||||
}
|
||||
|
||||
func (lex *Lexer) ungetCnt(n int) {
|
||||
lex.p = lex.p - n
|
||||
lex.te = lex.te - n
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package php8
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
type ParserBrackets struct {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package php8
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/internal/position"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/internal/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
// Parser structure
|
||||
|
||||
@@ -3,7 +3,7 @@ package php8_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/tester"
|
||||
"git.maride.cc/maride/php-parser/internal/tester"
|
||||
)
|
||||
|
||||
func TestReadonlyModifier(t *testing.T) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package php8_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/tester"
|
||||
"git.maride.cc/maride/php-parser/internal/tester"
|
||||
)
|
||||
|
||||
func TestClassReadonlyModifier(t *testing.T) {
|
||||
|
||||
@@ -3,14 +3,14 @@ package php8_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/tester"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/parser"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/tester"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/parser"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ package php8_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
@@ -10,8 +10,8 @@ import __yyfmt__ "fmt"
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
// line internal/php8/php8.y:13
|
||||
|
||||
@@ -4,8 +4,8 @@ package php8
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/VKCOM/php-parser/pkg/ast"
|
||||
"github.com/VKCOM/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
%}
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func BenchmarkPhp8(b *testing.B) {
|
||||
|
||||
46118
internal/php8/scanner.go
46118
internal/php8/scanner.go
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/VKCOM/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
%%{
|
||||
@@ -240,7 +240,8 @@ func (lex *Lexer) Lex() *token.Token {
|
||||
'endif'i => {lex.setTokenPosition(tkn); tok = token.T_ENDIF; fbreak;};
|
||||
'endswitch'i => {lex.setTokenPosition(tkn); tok = token.T_ENDSWITCH; fbreak;};
|
||||
'endwhile'i => {lex.setTokenPosition(tkn); tok = token.T_ENDWHILE; fbreak;};
|
||||
'enum'i => {lex.setTokenPosition(tkn); tok = token.T_ENUM; fbreak;};
|
||||
'enum'i whitespace+ varname_first => {lex.setTokenPrefixPosition(tkn, 4); tok = token.T_ENUM; lex.ungetFromStart(4); fbreak;};
|
||||
'enum'i whitespace+ ('extends'i | 'implements'i) => {lex.setTokenPrefixPosition(tkn, 4); tok = token.T_STRING; lex.ungetFromStart(4); fbreak;};
|
||||
'eval'i => {lex.setTokenPosition(tkn); tok = token.T_EVAL; fbreak;};
|
||||
'exit'i | 'die'i => {lex.setTokenPosition(tkn); tok = token.T_EXIT; fbreak;};
|
||||
'extends'i => {lex.setTokenPosition(tkn); tok = token.T_EXTENDS; fbreak;};
|
||||
|
||||
@@ -3,8 +3,8 @@ package php8_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/tester"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/internal/tester"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
func TestReadonlyTokens(t *testing.T) {
|
||||
@@ -181,6 +181,31 @@ func TestEnumTokens(t *testing.T) {
|
||||
suite.Run()
|
||||
}
|
||||
|
||||
func TestClassNameEnum(t *testing.T) {
|
||||
suite := tester.NewLexerTokenStructTestSuite(t)
|
||||
suite.UsePHP8()
|
||||
suite.Code = "<?php class Enum {}"
|
||||
suite.Expected = []*token.Token{
|
||||
{
|
||||
ID: token.T_CLASS,
|
||||
Value: []byte("class"),
|
||||
},
|
||||
{
|
||||
ID: token.T_STRING,
|
||||
Value: []byte("Enum"),
|
||||
},
|
||||
{
|
||||
ID: '{',
|
||||
Value: []byte("{"),
|
||||
},
|
||||
{
|
||||
ID: '}',
|
||||
Value: []byte("}"),
|
||||
},
|
||||
}
|
||||
suite.Run()
|
||||
}
|
||||
|
||||
func TestAmpersandFollowedByEllipsisTokens(t *testing.T) {
|
||||
suite := tester.NewLexerTokenStructTestSuite(t)
|
||||
suite.UsePHP8()
|
||||
|
||||
@@ -3,11 +3,11 @@ package php8_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/internal/tester"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/internal/tester"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func TestTokens(t *testing.T) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/position"
|
||||
"git.maride.cc/maride/php-parser/internal/position"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package position
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
type startPos struct {
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
builder "github.com/laytan/php-parser/internal/position"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
builder "git.maride.cc/maride/php-parser/internal/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
func TestNewTokenPosition(t *testing.T) {
|
||||
|
||||
@@ -3,11 +3,11 @@ package tester
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package tester
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package tester
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/parser"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"github.com/laytan/php-parser/pkg/visitor/printer"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/parser"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/printer"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package tester
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/parser"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/parser"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/parser"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"github.com/laytan/php-parser/pkg/visitor/dumper"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/parser"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/dumper"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package tester
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/parser"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/parser"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ast
|
||||
|
||||
import "github.com/laytan/php-parser/pkg/position"
|
||||
import "git.maride.cc/maride/php-parser/pkg/position"
|
||||
|
||||
// The edge-case/overwrites, from node type name to their visitor function name.
|
||||
var TypeToVisitorNameMap = map[string]string{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
//go:generate go run node_funcs_gen.go
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package ast
|
||||
|
||||
import "github.com/laytan/php-parser/pkg/position"
|
||||
import "git.maride.cc/maride/php-parser/pkg/position"
|
||||
|
||||
type Type int
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"regexp"
|
||||
"text/template"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
type templData struct {
|
||||
@@ -27,7 +27,7 @@ var fileTempl = template.Must(
|
||||
|
||||
package ast
|
||||
|
||||
import "github.com/laytan/php-parser/pkg/position"
|
||||
import "git.maride.cc/maride/php-parser/pkg/position"
|
||||
|
||||
type Type int
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package errors
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
)
|
||||
|
||||
// Error parsing error
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
)
|
||||
|
||||
func TestConstructor(t *testing.T) {
|
||||
|
||||
@@ -3,10 +3,10 @@ package lexer
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
var ErrVersionOutOfRange = errors.New("the version is out of supported range")
|
||||
|
||||
@@ -9,11 +9,11 @@ Package usage example:
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/errors"
|
||||
"github.com/laytan/php-parser/pkg/parser"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"github.com/laytan/php-parser/pkg/visitor/dumper"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/errors"
|
||||
"git.maride.cc/maride/php-parser/pkg/parser"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/dumper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -3,11 +3,11 @@ package parser
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
// ErrVersionOutOfRange is returned if the version is not supported
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package token
|
||||
|
||||
import "github.com/laytan/php-parser/pkg/position"
|
||||
import "git.maride.cc/maride/php-parser/pkg/position"
|
||||
|
||||
//go:generate stringer -type=ID -output ./token_string.go
|
||||
type ID int
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) {
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
type Dumper struct {
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/position"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/visitor/dumper"
|
||||
"git.maride.cc/maride/php-parser/pkg/position"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/dumper"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
func TestDumper_root(t *testing.T) {
|
||||
|
||||
@@ -3,8 +3,8 @@ package formatter
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
type formatterState int
|
||||
|
||||
@@ -2,12 +2,12 @@ package formatter_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/visitor/formatter"
|
||||
"github.com/laytan/php-parser/pkg/visitor/printer"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/formatter"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/printer"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
func TestFormatter_Root(t *testing.T) {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/visitor"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor"
|
||||
)
|
||||
|
||||
// NamespaceResolver visitor
|
||||
@@ -89,6 +89,22 @@ func (nsr *NamespaceResolver) StmtClass(n *ast.StmtClass) {
|
||||
}
|
||||
}
|
||||
|
||||
func (nsr *NamespaceResolver) StmtEnum(n *ast.StmtEnum) {
|
||||
if n.Type != nil {
|
||||
nsr.ResolveName(n.Type, "")
|
||||
}
|
||||
|
||||
if n.Implements != nil {
|
||||
for _, interfaceName := range n.Implements {
|
||||
nsr.ResolveName(interfaceName, "")
|
||||
}
|
||||
}
|
||||
|
||||
if n.Name != nil {
|
||||
nsr.AddNamespacedName(n, string(n.Name.(*ast.Identifier).Value))
|
||||
}
|
||||
}
|
||||
|
||||
func (nsr *NamespaceResolver) StmtInterface(n *ast.StmtInterface) {
|
||||
if n.Extends != nil {
|
||||
for _, interfaceName := range n.Extends {
|
||||
@@ -206,6 +222,10 @@ func (nsr *NamespaceResolver) StmtTraitUse(n *ast.StmtTraitUse) {
|
||||
}
|
||||
}
|
||||
|
||||
func (nsr *NamespaceResolver) Attribute(n *ast.Attribute) {
|
||||
nsr.ResolveName(n.Name, "")
|
||||
}
|
||||
|
||||
// LeaveNode is invoked after node process
|
||||
func (nsr *NamespaceResolver) LeaveNode(n ast.Vertex) {
|
||||
switch nn := n.(type) {
|
||||
@@ -258,6 +278,16 @@ func (nsr *NamespaceResolver) ResolveType(n ast.Vertex) {
|
||||
switch nn := n.(type) {
|
||||
case *ast.Nullable:
|
||||
nsr.ResolveType(nn.Expr)
|
||||
|
||||
case *ast.Union:
|
||||
for _, nnn := range nn.Types {
|
||||
nsr.ResolveType(nnn)
|
||||
}
|
||||
case *ast.Intersection:
|
||||
for _, nnn := range nn.Types {
|
||||
nsr.ResolveType(nnn)
|
||||
}
|
||||
|
||||
case *ast.Name:
|
||||
nsr.ResolveName(n, "")
|
||||
case *ast.NameRelative:
|
||||
@@ -340,6 +370,12 @@ func (ns *Namespace) ResolveName(nameNode ast.Vertex, aliasType string) (string,
|
||||
case "iterable":
|
||||
fallthrough
|
||||
case "object":
|
||||
fallthrough
|
||||
case "mixed": // 8.0
|
||||
fallthrough
|
||||
case "never": // 8.1
|
||||
fallthrough
|
||||
case "true", "false", "null": // 8.2
|
||||
return part, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package nsresolver_test
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/visitor/nsresolver"
|
||||
"github.com/laytan/php-parser/pkg/visitor/traverser"
|
||||
"testing"
|
||||
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/nsresolver"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/traverser"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
func TestResolveStaticCall(t *testing.T) {
|
||||
@@ -384,6 +385,7 @@ func TestResolveTraitUse(t *testing.T) {
|
||||
func TestResolveClassName(t *testing.T) {
|
||||
nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}}
|
||||
nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}}
|
||||
nameCD := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("D")}}}
|
||||
|
||||
class := &ast.StmtClass{
|
||||
Name: &ast.Identifier{Value: []byte("A")},
|
||||
@@ -391,6 +393,13 @@ func TestResolveClassName(t *testing.T) {
|
||||
Implements: []ast.Vertex{
|
||||
nameBC,
|
||||
},
|
||||
AttrGroups: []ast.Vertex{
|
||||
&ast.AttributeGroup{
|
||||
Attrs: []ast.Vertex{
|
||||
&ast.Attribute{Name: nameCD},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
@@ -403,6 +412,7 @@ func TestResolveClassName(t *testing.T) {
|
||||
class: "A",
|
||||
nameAB: "A\\B",
|
||||
nameBC: "B\\C",
|
||||
nameCD: "C\\D",
|
||||
}
|
||||
|
||||
nsResolver := nsresolver.NewNamespaceResolver()
|
||||
@@ -463,6 +473,36 @@ func TestResolveTraitName(t *testing.T) {
|
||||
assert.DeepEqual(t, expected, nsResolver.ResolvedNames)
|
||||
}
|
||||
|
||||
func TestResolveEnumName(t *testing.T) {
|
||||
nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}}
|
||||
nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}}
|
||||
|
||||
enum := &ast.StmtEnum{
|
||||
Name: &ast.Identifier{Value: []byte("A")},
|
||||
Type: nameAB,
|
||||
Implements: []ast.Vertex{
|
||||
nameBC,
|
||||
},
|
||||
}
|
||||
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
enum,
|
||||
},
|
||||
}
|
||||
|
||||
expected := map[ast.Vertex]string{
|
||||
enum: "A",
|
||||
nameAB: "A\\B",
|
||||
nameBC: "B\\C",
|
||||
}
|
||||
|
||||
nsResolver := nsresolver.NewNamespaceResolver()
|
||||
traverser.NewTraverser(nsResolver).Traverse(stxTree)
|
||||
|
||||
assert.DeepEqual(t, expected, nsResolver.ResolvedNames)
|
||||
}
|
||||
|
||||
func TestResolveFunctionName(t *testing.T) {
|
||||
nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}}
|
||||
nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}}
|
||||
@@ -500,6 +540,10 @@ func TestResolveFunctionName(t *testing.T) {
|
||||
func TestResolveMethodName(t *testing.T) {
|
||||
nameAB := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("A")}, &ast.NamePart{Value: []byte("B")}}}
|
||||
nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}}
|
||||
nameCD := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("D")}}}
|
||||
nameDE := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("D")}, &ast.NamePart{Value: []byte("E")}}}
|
||||
nameEF := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("E")}, &ast.NamePart{Value: []byte("F")}}}
|
||||
nameFG := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("F")}, &ast.NamePart{Value: []byte("G")}}}
|
||||
|
||||
methodNode := &ast.StmtClassMethod{
|
||||
Name: &ast.Identifier{Value: []byte("A")},
|
||||
@@ -508,6 +552,14 @@ func TestResolveMethodName(t *testing.T) {
|
||||
Type: nameAB,
|
||||
Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("foo")}},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: &ast.Union{Types: []ast.Vertex{nameCD, nameDE}},
|
||||
Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("all")}},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: &ast.Intersection{Types: []ast.Vertex{nameEF, nameFG}},
|
||||
Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("any")}},
|
||||
},
|
||||
},
|
||||
ReturnType: &ast.Nullable{Expr: nameBC},
|
||||
Stmt: &ast.StmtStmtList{
|
||||
@@ -518,6 +570,10 @@ func TestResolveMethodName(t *testing.T) {
|
||||
expected := map[ast.Vertex]string{
|
||||
nameAB: "A\\B",
|
||||
nameBC: "B\\C",
|
||||
nameCD: "C\\D",
|
||||
nameDE: "D\\E",
|
||||
nameEF: "E\\F",
|
||||
nameFG: "F\\G",
|
||||
}
|
||||
|
||||
nsResolver := nsresolver.NewNamespaceResolver()
|
||||
@@ -598,6 +654,19 @@ func TestResolveNamespaces(t *testing.T) {
|
||||
nameFG := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("F")}, &ast.NamePart{Value: []byte("G")}}}
|
||||
relativeNameCE := &ast.NameRelative{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("E")}}}
|
||||
|
||||
relativeNameCA := &ast.NameRelative{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("A")}}}
|
||||
|
||||
classA := &ast.StmtClass{
|
||||
Name: &ast.Identifier{Value: []byte("A")},
|
||||
AttrGroups: []ast.Vertex{
|
||||
&ast.AttributeGroup{
|
||||
Attrs: []ast.Vertex{
|
||||
&ast.Attribute{Name: relativeNameCA},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
constantB := &ast.StmtConstant{
|
||||
Name: &ast.Identifier{Value: []byte("B")},
|
||||
Expr: &ast.ScalarLnumber{Value: []byte("1")},
|
||||
@@ -612,6 +681,9 @@ func TestResolveNamespaces(t *testing.T) {
|
||||
&ast.StmtNamespace{
|
||||
Name: namespaceAB,
|
||||
},
|
||||
|
||||
classA,
|
||||
|
||||
&ast.StmtConstList{
|
||||
Consts: []ast.Vertex{
|
||||
constantB,
|
||||
@@ -622,6 +694,7 @@ func TestResolveNamespaces(t *testing.T) {
|
||||
Class: nameFG,
|
||||
Call: &ast.Identifier{Value: []byte("foo")},
|
||||
},
|
||||
|
||||
&ast.StmtNamespace{
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
@@ -649,6 +722,8 @@ func TestResolveNamespaces(t *testing.T) {
|
||||
}
|
||||
|
||||
expected := map[ast.Vertex]string{
|
||||
classA: "A\\B\\A",
|
||||
relativeNameCA: "A\\B\\C\\A",
|
||||
constantB: "A\\B\\B",
|
||||
constantC: "A\\B\\C",
|
||||
nameFG: "A\\B\\F\\G",
|
||||
@@ -780,6 +855,36 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
nameMixed := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("mixed")},
|
||||
},
|
||||
}
|
||||
|
||||
nameNever := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("never")},
|
||||
},
|
||||
}
|
||||
|
||||
nameTrue := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("true")},
|
||||
},
|
||||
}
|
||||
|
||||
nameFalse := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("false")},
|
||||
},
|
||||
}
|
||||
|
||||
nameNull := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("null")},
|
||||
},
|
||||
}
|
||||
|
||||
function := &ast.StmtFunction{
|
||||
Name: &ast.Identifier{Value: []byte("bar")},
|
||||
Params: []ast.Vertex{
|
||||
@@ -825,6 +930,36 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
||||
Name: &ast.Identifier{Value: []byte("Object")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameMixed,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("Mixed")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameNever,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("Never")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameTrue,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("True")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameFalse,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("False")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameNull,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("Null")},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -850,6 +985,11 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
||||
nameVoid: "void",
|
||||
nameIterable: "iterable",
|
||||
nameObject: "object",
|
||||
nameMixed: "mixed",
|
||||
nameNever: "never",
|
||||
nameTrue: "true",
|
||||
nameFalse: "false",
|
||||
nameNull: "null",
|
||||
}
|
||||
|
||||
nsResolver := nsresolver.NewNamespaceResolver()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package visitor
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
type Null struct{}
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
)
|
||||
|
||||
type printerState int
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php7"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"github.com/laytan/php-parser/pkg/visitor/printer"
|
||||
"git.maride.cc/maride/php-parser/internal/php7"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/printer"
|
||||
)
|
||||
|
||||
func ExamplePrinter() {
|
||||
@@ -957,6 +957,7 @@ func TestParseAndPrintBreak(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseAndPrintClassMethod(t *testing.T) {
|
||||
t.Skip("TODO: there should not be a blank line between the comment and method.")
|
||||
src := `<?php
|
||||
class Foo {
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@ package printer_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/tester"
|
||||
"git.maride.cc/maride/php-parser/internal/tester"
|
||||
)
|
||||
|
||||
func TestParseAndPrintReadonlyModifierPHP81(t *testing.T) {
|
||||
|
||||
@@ -5,12 +5,12 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/internal/php8"
|
||||
"github.com/laytan/php-parser/internal/tester"
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/conf"
|
||||
"github.com/laytan/php-parser/pkg/version"
|
||||
"github.com/laytan/php-parser/pkg/visitor/printer"
|
||||
"git.maride.cc/maride/php-parser/internal/php8"
|
||||
"git.maride.cc/maride/php-parser/internal/tester"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/conf"
|
||||
"git.maride.cc/maride/php-parser/pkg/version"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/printer"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
@@ -965,6 +965,7 @@ func TestParseAndPrintBreakPHP8(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseAndPrintClassMethodPHP8(t *testing.T) {
|
||||
t.Skip("TODO: there should not be a blank line between the comment and method.")
|
||||
src := `<?php
|
||||
class Foo {
|
||||
/**
|
||||
|
||||
@@ -2,11 +2,11 @@ package printer_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/laytan/php-parser/pkg/token"
|
||||
"github.com/laytan/php-parser/pkg/visitor/printer"
|
||||
"git.maride.cc/maride/php-parser/pkg/token"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/printer"
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
func TestPrinterPrintFile(t *testing.T) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package traverser
|
||||
|
||||
import (
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
)
|
||||
|
||||
//go:generate go run traverser_gen.go
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
|
||||
phpast "github.com/laytan/php-parser/pkg/ast"
|
||||
phpast "git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"golang.org/x/tools/go/packages"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ var fileTempl = template.Must(
|
||||
|
||||
package traverser
|
||||
|
||||
import "github.com/laytan/php-parser/pkg/ast"
|
||||
import "git.maride.cc/maride/php-parser/pkg/ast"
|
||||
{{range $typ := .Types}}
|
||||
func (t *Traverser) {{$typ.FuncName}}(n *ast.{{$typ.Name}}) {
|
||||
if !t.checkEntrance(n) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package traverser
|
||||
|
||||
import "github.com/laytan/php-parser/pkg/ast"
|
||||
import "git.maride.cc/maride/php-parser/pkg/ast"
|
||||
|
||||
func (t *Traverser) Root(n *ast.Root) {
|
||||
if !t.checkEntrance(n) {
|
||||
|
||||
@@ -3,9 +3,9 @@ package traverser_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/laytan/php-parser/pkg/ast"
|
||||
"github.com/laytan/php-parser/pkg/visitor"
|
||||
"github.com/laytan/php-parser/pkg/visitor/traverser"
|
||||
"git.maride.cc/maride/php-parser/pkg/ast"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor"
|
||||
"git.maride.cc/maride/php-parser/pkg/visitor/traverser"
|
||||
)
|
||||
|
||||
// testCase is a traverser that does not go into any class statement or its children.
|
||||
|
||||
Reference in New Issue
Block a user