@jorgsowa/php-parser 3.2.5-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/README.md +108 -0
- package/dist/@jorgsowa/php-parser.js +11239 -0
- package/dist/@jorgsowa/php-parser.min.js +2 -0
- package/dist/@jorgsowa/php-parser.min.js.LICENSE.txt +10 -0
- package/package.json +86 -0
- package/src/ast/array.js +44 -0
- package/src/ast/arrowfunc.js +43 -0
- package/src/ast/assign.js +28 -0
- package/src/ast/assignref.js +27 -0
- package/src/ast/attrgroup.js +21 -0
- package/src/ast/attribute.js +26 -0
- package/src/ast/bin.js +27 -0
- package/src/ast/block.js +24 -0
- package/src/ast/boolean.js +23 -0
- package/src/ast/break.js +21 -0
- package/src/ast/byref.js +21 -0
- package/src/ast/call.js +26 -0
- package/src/ast/case.js +26 -0
- package/src/ast/cast.js +28 -0
- package/src/ast/catch.js +29 -0
- package/src/ast/class.js +36 -0
- package/src/ast/classconstant.js +71 -0
- package/src/ast/clone.js +21 -0
- package/src/ast/closure.js +47 -0
- package/src/ast/comment.js +23 -0
- package/src/ast/commentblock.js +22 -0
- package/src/ast/commentline.js +22 -0
- package/src/ast/constant.js +26 -0
- package/src/ast/constantstatement.js +24 -0
- package/src/ast/continue.js +24 -0
- package/src/ast/declaration.js +60 -0
- package/src/ast/declare.js +71 -0
- package/src/ast/declaredirective.js +26 -0
- package/src/ast/do.js +26 -0
- package/src/ast/echo.js +26 -0
- package/src/ast/empty.js +23 -0
- package/src/ast/encapsed.js +75 -0
- package/src/ast/encapsedpart.js +28 -0
- package/src/ast/entry.js +30 -0
- package/src/ast/enum.js +30 -0
- package/src/ast/enumcase.js +26 -0
- package/src/ast/error.js +30 -0
- package/src/ast/eval.js +24 -0
- package/src/ast/exit.js +26 -0
- package/src/ast/expression.js +20 -0
- package/src/ast/expressionstatement.js +24 -0
- package/src/ast/for.js +33 -0
- package/src/ast/foreach.js +33 -0
- package/src/ast/function.js +34 -0
- package/src/ast/global.js +24 -0
- package/src/ast/goto.js +22 -0
- package/src/ast/halt.js +22 -0
- package/src/ast/identifier.js +26 -0
- package/src/ast/if.js +30 -0
- package/src/ast/include.js +28 -0
- package/src/ast/inline.js +23 -0
- package/src/ast/interface.js +28 -0
- package/src/ast/intersectiontype.js +24 -0
- package/src/ast/isset.js +23 -0
- package/src/ast/label.js +21 -0
- package/src/ast/list.js +26 -0
- package/src/ast/literal.js +28 -0
- package/src/ast/location.js +22 -0
- package/src/ast/lookup.js +26 -0
- package/src/ast/magic.js +22 -0
- package/src/ast/match.js +26 -0
- package/src/ast/matcharm.js +26 -0
- package/src/ast/method.js +24 -0
- package/src/ast/name.js +55 -0
- package/src/ast/namedargument.js +27 -0
- package/src/ast/namespace.js +26 -0
- package/src/ast/new.js +26 -0
- package/src/ast/node.js +111 -0
- package/src/ast/noop.js +20 -0
- package/src/ast/nowdoc.js +26 -0
- package/src/ast/nullkeyword.js +20 -0
- package/src/ast/nullsafepropertylookup.js +22 -0
- package/src/ast/number.js +23 -0
- package/src/ast/offsetlookup.js +22 -0
- package/src/ast/operation.js +19 -0
- package/src/ast/parameter.js +61 -0
- package/src/ast/parentreference.js +24 -0
- package/src/ast/position.js +22 -0
- package/src/ast/post.js +26 -0
- package/src/ast/pre.js +26 -0
- package/src/ast/print.js +23 -0
- package/src/ast/program.js +32 -0
- package/src/ast/property.js +46 -0
- package/src/ast/propertyhook.js +33 -0
- package/src/ast/propertylookup.js +22 -0
- package/src/ast/propertystatement.js +59 -0
- package/src/ast/reference.js +21 -0
- package/src/ast/retif.js +28 -0
- package/src/ast/return.js +21 -0
- package/src/ast/selfreference.js +24 -0
- package/src/ast/silent.js +24 -0
- package/src/ast/statement.js +19 -0
- package/src/ast/static.js +24 -0
- package/src/ast/staticlookup.js +22 -0
- package/src/ast/staticreference.js +24 -0
- package/src/ast/staticvariable.js +26 -0
- package/src/ast/string.js +28 -0
- package/src/ast/switch.js +28 -0
- package/src/ast/throw.js +21 -0
- package/src/ast/trait.js +24 -0
- package/src/ast/traitalias.js +44 -0
- package/src/ast/traitprecedence.js +28 -0
- package/src/ast/traituse.js +26 -0
- package/src/ast/try.js +28 -0
- package/src/ast/typereference.js +40 -0
- package/src/ast/unary.js +26 -0
- package/src/ast/uniontype.js +24 -0
- package/src/ast/unset.js +23 -0
- package/src/ast/usegroup.js +30 -0
- package/src/ast/useitem.js +45 -0
- package/src/ast/variable.js +36 -0
- package/src/ast/variadic.js +25 -0
- package/src/ast/variadicplaceholder.js +24 -0
- package/src/ast/while.js +28 -0
- package/src/ast/yield.js +27 -0
- package/src/ast/yieldfrom.js +25 -0
- package/src/ast.js +593 -0
- package/src/index.js +239 -0
- package/src/lexer/attribute.js +85 -0
- package/src/lexer/comments.js +63 -0
- package/src/lexer/initial.js +64 -0
- package/src/lexer/numbers.js +171 -0
- package/src/lexer/property.js +96 -0
- package/src/lexer/scripting.js +114 -0
- package/src/lexer/strings.js +524 -0
- package/src/lexer/tokens.js +356 -0
- package/src/lexer/utils.js +112 -0
- package/src/lexer.js +561 -0
- package/src/parser/array.js +113 -0
- package/src/parser/class.js +718 -0
- package/src/parser/comment.js +52 -0
- package/src/parser/enum.js +56 -0
- package/src/parser/expr.js +848 -0
- package/src/parser/function.js +507 -0
- package/src/parser/if.js +94 -0
- package/src/parser/loops.js +168 -0
- package/src/parser/main.js +21 -0
- package/src/parser/namespace.js +231 -0
- package/src/parser/scalar.js +492 -0
- package/src/parser/statement.js +444 -0
- package/src/parser/switch.js +99 -0
- package/src/parser/try.js +43 -0
- package/src/parser/utils.js +203 -0
- package/src/parser/variable.js +363 -0
- package/src/parser.js +748 -0
- package/src/tokens.js +177 -0
- package/types.d.ts +1457 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Node = require("./node");
|
|
9
|
+
const KIND = "identifier";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines an identifier node
|
|
13
|
+
* @constructor Identifier
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
* @property {string} name
|
|
17
|
+
*/
|
|
18
|
+
const Identifier = Node.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Identifier(name, docs, location) {
|
|
21
|
+
Node.apply(this, [KIND, docs, location]);
|
|
22
|
+
this.name = name;
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
module.exports = Identifier;
|
package/src/ast/if.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Statement = require("./statement");
|
|
9
|
+
const KIND = "if";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a if statement
|
|
13
|
+
* @constructor If
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Expression} test
|
|
17
|
+
* @property {Block} body
|
|
18
|
+
* @property {Block|If|null} alternate
|
|
19
|
+
* @property {boolean} shortForm
|
|
20
|
+
*/
|
|
21
|
+
module.exports = Statement.extends(
|
|
22
|
+
KIND,
|
|
23
|
+
function If(test, body, alternate, shortForm, docs, location) {
|
|
24
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
25
|
+
this.test = test;
|
|
26
|
+
this.body = body;
|
|
27
|
+
this.alternate = alternate;
|
|
28
|
+
this.shortForm = shortForm;
|
|
29
|
+
},
|
|
30
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "include";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines system include call
|
|
13
|
+
* @constructor Include
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Node} target
|
|
17
|
+
* @property {boolean} once
|
|
18
|
+
* @property {boolean} require
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Expression.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Include(once, require, target, docs, location) {
|
|
23
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.once = once;
|
|
25
|
+
this.require = require;
|
|
26
|
+
this.target = target;
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Literal = require("./literal");
|
|
9
|
+
const KIND = "inline";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines inline html output (treated as echo output)
|
|
13
|
+
* @constructor Inline
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Literal}
|
|
16
|
+
* @property {string} value
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Literal.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Inline(value, raw, docs, location) {
|
|
21
|
+
Literal.apply(this, [KIND, value, raw, docs, location]);
|
|
22
|
+
},
|
|
23
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Declaration = require("./declaration");
|
|
9
|
+
const KIND = "interface";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An interface definition
|
|
13
|
+
* @constructor Interface
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Declaration}
|
|
16
|
+
* @property {Identifier[]} extends
|
|
17
|
+
* @property {Declaration[]} body
|
|
18
|
+
* @property {AttrGroup[]} attrGroups
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Declaration.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Interface(name, ext, body, attrGroups, docs, location) {
|
|
23
|
+
Declaration.apply(this, [KIND, name, docs, location]);
|
|
24
|
+
this.extends = ext;
|
|
25
|
+
this.body = body;
|
|
26
|
+
this.attrGroups = attrGroups;
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Declaration = require("./declaration");
|
|
9
|
+
const KIND = "intersectiontype";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A union of types
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor IntersectionType
|
|
15
|
+
* @extends {Declaration}
|
|
16
|
+
* @property {TypeReference[]} types
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Declaration.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function IntersectionType(types, docs, location) {
|
|
21
|
+
Declaration.apply(this, [KIND, null, docs, location]);
|
|
22
|
+
this.types = types;
|
|
23
|
+
},
|
|
24
|
+
);
|
package/src/ast/isset.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "isset";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines an isset call
|
|
13
|
+
* @constructor Isset
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Expression.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function Isset(variables, docs, location) {
|
|
20
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
21
|
+
this.variables = variables;
|
|
22
|
+
},
|
|
23
|
+
);
|
package/src/ast/label.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Statement = require("./statement");
|
|
9
|
+
const KIND = "label";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A label statement (referenced by goto)
|
|
13
|
+
* @constructor Label
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {String} name
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(KIND, function Label(name, docs, location) {
|
|
19
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
20
|
+
this.name = name;
|
|
21
|
+
});
|
package/src/ast/list.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "list";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines list assignment
|
|
13
|
+
* @constructor List
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {boolean} shortForm
|
|
17
|
+
* @property {Entry[]} items
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expression.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function List(items, shortForm, docs, location) {
|
|
22
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.items = items;
|
|
24
|
+
this.shortForm = shortForm;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "literal";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines an array structure
|
|
13
|
+
* @constructor Literal
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {string} raw
|
|
17
|
+
* @property {EncapsedPart[]|Node|string|number|boolean|null} value
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expression.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Literal(kind, value, raw, docs, location) {
|
|
22
|
+
Expression.apply(this, [kind || KIND, docs, location]);
|
|
23
|
+
this.value = value;
|
|
24
|
+
if (raw) {
|
|
25
|
+
this.raw = raw;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Defines the location of the node (with it's source contents as string)
|
|
10
|
+
* @constructor Location
|
|
11
|
+
* @memberOf module:php-parser
|
|
12
|
+
* @property {string|null} source
|
|
13
|
+
* @property {Position} start
|
|
14
|
+
* @property {Position} end
|
|
15
|
+
*/
|
|
16
|
+
const Location = function (source, start, end) {
|
|
17
|
+
this.source = source;
|
|
18
|
+
this.start = start;
|
|
19
|
+
this.end = end;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = Location;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expr = require("./expression");
|
|
9
|
+
const KIND = "lookup";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lookup on an offset in the specified object
|
|
13
|
+
* @constructor Lookup
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Expression} what
|
|
17
|
+
* @property {Expression} offset
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expr.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Lookup(kind, what, offset, docs, location) {
|
|
22
|
+
Expr.apply(this, [kind || KIND, docs, location]);
|
|
23
|
+
this.what = what;
|
|
24
|
+
this.offset = offset;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/magic.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Literal = require("./literal");
|
|
9
|
+
const KIND = "magic";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines magic constant
|
|
13
|
+
* @constructor Magic
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Literal}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Literal.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function Magic(value, raw, docs, location) {
|
|
20
|
+
Literal.apply(this, [KIND, value, raw, docs, location]);
|
|
21
|
+
},
|
|
22
|
+
);
|
package/src/ast/match.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "match";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a match expression
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor Match
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Expression} cond Condition expression to match against
|
|
17
|
+
* @property {MatchArm[]} arms Arms for comparison
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expression.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Match(cond, arms, docs, location) {
|
|
22
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.cond = cond;
|
|
24
|
+
this.arms = arms;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "matcharm";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An array entry - see [Array](#array)
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor MatchArm
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Expression[]|null} conds The match condition expression list - null indicates default arm
|
|
17
|
+
* @property {Expression} body The return value expression
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expression.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function MatchArm(conds, body, docs, location) {
|
|
22
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.conds = conds;
|
|
24
|
+
this.body = body;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Function_ = require("./function");
|
|
9
|
+
const KIND = "method";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class/interface/trait method
|
|
13
|
+
* @constructor Method
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Function}
|
|
16
|
+
* @property {boolean} isAbstract
|
|
17
|
+
* @property {boolean} isFinal
|
|
18
|
+
* @property {boolean} isStatic
|
|
19
|
+
* @property {string} visibility
|
|
20
|
+
*/
|
|
21
|
+
module.exports = Function_.extends(KIND, function Method() {
|
|
22
|
+
Function_.apply(this, arguments);
|
|
23
|
+
this.kind = KIND;
|
|
24
|
+
});
|
package/src/ast/name.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Reference = require("./reference");
|
|
9
|
+
const KIND = "name";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class reference node
|
|
13
|
+
* @constructor Name
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Reference}
|
|
16
|
+
* @property {string} name
|
|
17
|
+
* @property {string} resolution
|
|
18
|
+
*/
|
|
19
|
+
const Name = Reference.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Name(name, resolution, docs, location) {
|
|
22
|
+
Reference.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.name = name.replace(/\\$/, "");
|
|
24
|
+
this.resolution = resolution;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This is an identifier without a namespace separator, such as Foo
|
|
30
|
+
* @constant {String} Name#UNQUALIFIED_NAME
|
|
31
|
+
* @memberOf module:php-parser
|
|
32
|
+
*/
|
|
33
|
+
Name.UNQUALIFIED_NAME = "uqn";
|
|
34
|
+
/**
|
|
35
|
+
* This is an identifier with a namespace separator, such as Foo\Bar
|
|
36
|
+
* @constant {String} Name#QUALIFIED_NAME
|
|
37
|
+
* @memberOf module:php-parser
|
|
38
|
+
*/
|
|
39
|
+
Name.QUALIFIED_NAME = "qn";
|
|
40
|
+
/**
|
|
41
|
+
* This is an identifier with a namespace separator that begins with
|
|
42
|
+
* a namespace separator, such as \Foo\Bar. The namespace \Foo is also
|
|
43
|
+
* a fully qualified name.
|
|
44
|
+
* @constant {String} Name#FULL_QUALIFIED_NAME
|
|
45
|
+
* @memberOf module:php-parser
|
|
46
|
+
*/
|
|
47
|
+
Name.FULL_QUALIFIED_NAME = "fqn";
|
|
48
|
+
/**
|
|
49
|
+
* This is an identifier starting with namespace, such as namespace\Foo\Bar.
|
|
50
|
+
* @constant {String} Name#RELATIVE_NAME
|
|
51
|
+
* @memberOf module:php-parser
|
|
52
|
+
*/
|
|
53
|
+
Name.RELATIVE_NAME = "rn";
|
|
54
|
+
|
|
55
|
+
module.exports = Name;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "namedargument";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Named arguments.
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor namedargument
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {String} name
|
|
17
|
+
* @property {Expression} value
|
|
18
|
+
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Expression.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function namedargument(name, value, docs, location) {
|
|
23
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.value = value;
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Block = require("./block");
|
|
9
|
+
const KIND = "namespace";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The main program node
|
|
13
|
+
* @constructor Namespace
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Block}
|
|
16
|
+
* @property {string} name
|
|
17
|
+
* @property {boolean} withBrackets
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Block.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Namespace(name, children, withBrackets, docs, location) {
|
|
22
|
+
Block.apply(this, [KIND, children, docs, location]);
|
|
23
|
+
this.name = name;
|
|
24
|
+
this.withBrackets = withBrackets || false;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/new.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Expression = require("./expression");
|
|
9
|
+
const KIND = "new";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new instance of the specified class
|
|
13
|
+
* @constructor New
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Identifier|Variable|Class} what
|
|
17
|
+
* @property {Variable[]} arguments
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expression.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function New(what, args, docs, location) {
|
|
22
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.what = what;
|
|
24
|
+
this.arguments = args;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/node.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A generic AST node
|
|
10
|
+
* @constructor Node
|
|
11
|
+
* @memberOf module:php-parser
|
|
12
|
+
* @property {Location|null} loc
|
|
13
|
+
* @property {CommentBlock[]|Comment[]|null} leadingComments
|
|
14
|
+
* @property {CommentBlock[]|Comment[]|null} trailingComments
|
|
15
|
+
* @property {string} kind
|
|
16
|
+
*/
|
|
17
|
+
const Node = function Node(kind, docs, location) {
|
|
18
|
+
this.kind = kind;
|
|
19
|
+
if (docs) {
|
|
20
|
+
this.leadingComments = docs;
|
|
21
|
+
}
|
|
22
|
+
if (location) {
|
|
23
|
+
this.loc = location;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Attach comments to current node
|
|
29
|
+
* @function Node#setTrailingComments
|
|
30
|
+
* @memberOf module:php-parser
|
|
31
|
+
* @param {*} docs
|
|
32
|
+
*/
|
|
33
|
+
Node.prototype.setTrailingComments = function (docs) {
|
|
34
|
+
this.trailingComments = docs;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Destroying an unused node
|
|
39
|
+
* @function Node#destroy
|
|
40
|
+
* @memberOf module:php-parser
|
|
41
|
+
*/
|
|
42
|
+
Node.prototype.destroy = function (node) {
|
|
43
|
+
if (!node) {
|
|
44
|
+
/* istanbul ignore next */
|
|
45
|
+
throw new Error(
|
|
46
|
+
"Node already initialized, you must swap with another node",
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (this.leadingComments) {
|
|
50
|
+
if (node.leadingComments) {
|
|
51
|
+
node.leadingComments = Array.concat(
|
|
52
|
+
this.leadingComments,
|
|
53
|
+
node.leadingComments,
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
node.leadingComments = this.leadingComments;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (this.trailingComments) {
|
|
60
|
+
if (node.trailingComments) {
|
|
61
|
+
node.trailingComments = Array.concat(
|
|
62
|
+
this.trailingComments,
|
|
63
|
+
node.trailingComments,
|
|
64
|
+
);
|
|
65
|
+
} else {
|
|
66
|
+
node.trailingComments = this.trailingComments;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return node;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Includes current token position of the parser
|
|
74
|
+
* @function Node#includeToken
|
|
75
|
+
* @memberOf module:php-parser
|
|
76
|
+
* @param {*} parser
|
|
77
|
+
*/
|
|
78
|
+
Node.prototype.includeToken = function (parser) {
|
|
79
|
+
if (this.loc) {
|
|
80
|
+
if (this.loc.end) {
|
|
81
|
+
this.loc.end.line = parser.lexer.yylloc.last_line;
|
|
82
|
+
this.loc.end.column = parser.lexer.yylloc.last_column;
|
|
83
|
+
this.loc.end.offset = parser.lexer.offset;
|
|
84
|
+
}
|
|
85
|
+
if (parser.ast.withSource) {
|
|
86
|
+
this.loc.source = parser.lexer._input.substring(
|
|
87
|
+
this.loc.start.offset,
|
|
88
|
+
parser.lexer.offset,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return this;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Helper for extending the Node class
|
|
97
|
+
* @function Node.extends
|
|
98
|
+
* @memberOf module:php-parser
|
|
99
|
+
* @param {string} type
|
|
100
|
+
* @param {Function} constructor
|
|
101
|
+
* @return {Function}
|
|
102
|
+
*/
|
|
103
|
+
Node.extends = function (type, constructor) {
|
|
104
|
+
constructor.prototype = Object.create(this.prototype);
|
|
105
|
+
constructor.extends = this.extends;
|
|
106
|
+
constructor.prototype.constructor = constructor;
|
|
107
|
+
constructor.kind = type;
|
|
108
|
+
return constructor;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
module.exports = Node;
|
package/src/ast/noop.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Node = require("./node");
|
|
9
|
+
const KIND = "noop";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Ignore this node, it implies a no operation block, for example :
|
|
13
|
+
* [$foo, $bar, /* here a noop node * /]
|
|
14
|
+
* @constructor Noop
|
|
15
|
+
* @memberOf module:php-parser
|
|
16
|
+
* @extends {Node}
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Node.extends(KIND, function Noop(docs, location) {
|
|
19
|
+
Node.apply(this, [KIND, docs, location]);
|
|
20
|
+
});
|