@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 = "attribute";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Attribute Value
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor Attribute
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
* @property {String} name
|
|
17
|
+
* @property {Parameter[]} args
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Node.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Attribute(name, args, docs, location) {
|
|
22
|
+
Node.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.name = name;
|
|
24
|
+
this.args = args;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/bin.js
ADDED
|
@@ -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 Operation = require("./operation");
|
|
9
|
+
const KIND = "bin";
|
|
10
|
+
/**
|
|
11
|
+
* Binary operations
|
|
12
|
+
* @constructor Bin
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @extends {Operation}
|
|
15
|
+
* @property {String} type
|
|
16
|
+
* @property {Expression} left
|
|
17
|
+
* @property {Expression} right
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Operation.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Bin(type, left, right, docs, location) {
|
|
22
|
+
Operation.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.type = type;
|
|
24
|
+
this.left = left;
|
|
25
|
+
this.right = right;
|
|
26
|
+
},
|
|
27
|
+
);
|
package/src/ast/block.js
ADDED
|
@@ -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 Statement = require("./statement");
|
|
9
|
+
const KIND = "block";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A block statement, i.e., a sequence of statements surrounded by braces.
|
|
13
|
+
* @constructor Block
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Node[]} children
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Block(kind, children, docs, location) {
|
|
21
|
+
Statement.apply(this, [kind || KIND, docs, location]);
|
|
22
|
+
this.children = children.filter(Boolean);
|
|
23
|
+
},
|
|
24
|
+
);
|
|
@@ -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 = "boolean";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a boolean value (true/false)
|
|
13
|
+
* @constructor Boolean
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Literal}
|
|
16
|
+
* @property {boolean} value
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Literal.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Boolean(value, raw, docs, location) {
|
|
21
|
+
Literal.apply(this, [KIND, value, raw, docs, location]);
|
|
22
|
+
},
|
|
23
|
+
);
|
package/src/ast/break.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 = "break";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A break statement
|
|
13
|
+
* @constructor Break
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Number|Null} level
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(KIND, function Break(level, docs, location) {
|
|
19
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
20
|
+
this.level = level;
|
|
21
|
+
});
|
package/src/ast/byref.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 Expression = require("./expression");
|
|
9
|
+
const KIND = "byref";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Passing by Reference - so the function can modify the variable
|
|
13
|
+
* @constructor ByRef
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {ExpressionStatement} what
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Expression.extends(KIND, function ByRef(what, docs, location) {
|
|
19
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
20
|
+
this.what = what;
|
|
21
|
+
});
|
package/src/ast/call.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 = "call";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Executes a call statement
|
|
13
|
+
* @constructor Call
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Identifier|Variable} what
|
|
17
|
+
* @property {Expression[]} arguments
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expression.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Call(what, args, docs, location) {
|
|
22
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.what = what;
|
|
24
|
+
this.arguments = args;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/case.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 Statement = require("./statement");
|
|
9
|
+
const KIND = "case";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A switch case statement
|
|
13
|
+
* @constructor Case
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Expression|null} test - if null, means that the default case
|
|
17
|
+
* @property {Block|null} body
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Statement.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Case(test, body, docs, location) {
|
|
22
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.test = test;
|
|
24
|
+
this.body = body;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/cast.js
ADDED
|
@@ -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 Operation = require("./operation");
|
|
9
|
+
const KIND = "cast";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Binary operations
|
|
13
|
+
* @constructor Cast
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Operation}
|
|
16
|
+
* @property {String} type
|
|
17
|
+
* @property {String} raw
|
|
18
|
+
* @property {Expression} expr
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Operation.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Cast(type, raw, expr, docs, location) {
|
|
23
|
+
Operation.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.type = type;
|
|
25
|
+
this.raw = raw;
|
|
26
|
+
this.expr = expr;
|
|
27
|
+
},
|
|
28
|
+
);
|
package/src/ast/catch.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 = "catch";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a catch statement
|
|
13
|
+
* @constructor Catch
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Name[]} what
|
|
17
|
+
* @property {Variable} variable
|
|
18
|
+
* @property {Block} body
|
|
19
|
+
* @see http://php.net/manual/en/language.exceptions.php
|
|
20
|
+
*/
|
|
21
|
+
module.exports = Statement.extends(
|
|
22
|
+
KIND,
|
|
23
|
+
function Catch(body, what, variable, docs, location) {
|
|
24
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
25
|
+
this.body = body;
|
|
26
|
+
this.what = what;
|
|
27
|
+
this.variable = variable;
|
|
28
|
+
},
|
|
29
|
+
);
|
package/src/ast/class.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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 = "class";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class definition
|
|
13
|
+
* @constructor Class
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Declaration}
|
|
16
|
+
* @property {Identifier|null} extends
|
|
17
|
+
* @property {Identifier[]|null} implements
|
|
18
|
+
* @property {Declaration[]} body
|
|
19
|
+
* @property {boolean} isAnonymous
|
|
20
|
+
* @property {boolean} isAbstract
|
|
21
|
+
* @property {boolean} isFinal
|
|
22
|
+
* @property {boolean} isReadonly
|
|
23
|
+
* @property {AttrGroup[]} attrGroups
|
|
24
|
+
*/
|
|
25
|
+
module.exports = Declaration.extends(
|
|
26
|
+
KIND,
|
|
27
|
+
function Class(name, ext, impl, body, flags, docs, location) {
|
|
28
|
+
Declaration.apply(this, [KIND, name, docs, location]);
|
|
29
|
+
this.isAnonymous = name ? false : true;
|
|
30
|
+
this.extends = ext;
|
|
31
|
+
this.implements = impl;
|
|
32
|
+
this.body = body;
|
|
33
|
+
this.attrGroups = [];
|
|
34
|
+
this.parseFlags(flags);
|
|
35
|
+
},
|
|
36
|
+
);
|
|
@@ -0,0 +1,71 @@
|
|
|
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 ConstantStatement = require("./constantstatement");
|
|
9
|
+
const KIND = "classconstant";
|
|
10
|
+
|
|
11
|
+
const IS_UNDEFINED = "";
|
|
12
|
+
const IS_PUBLIC = "public";
|
|
13
|
+
const IS_PROTECTED = "protected";
|
|
14
|
+
const IS_PRIVATE = "private";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Defines a class/interface/trait constant
|
|
18
|
+
* @constructor ClassConstant
|
|
19
|
+
* @memberOf module:php-parser
|
|
20
|
+
* @extends {ConstantStatement}
|
|
21
|
+
* @property {string} visibility
|
|
22
|
+
* @property {boolean} final
|
|
23
|
+
* @property {boolean} nullable
|
|
24
|
+
* @property {TypeReference|IntersectionType|UnionType|null} type
|
|
25
|
+
* @property {AttrGroup[]} attrGroups
|
|
26
|
+
*/
|
|
27
|
+
const ClassConstant = ConstantStatement.extends(
|
|
28
|
+
KIND,
|
|
29
|
+
function ClassConstant(
|
|
30
|
+
kind,
|
|
31
|
+
constants,
|
|
32
|
+
flags,
|
|
33
|
+
nullable,
|
|
34
|
+
type,
|
|
35
|
+
attrGroups,
|
|
36
|
+
docs,
|
|
37
|
+
location,
|
|
38
|
+
) {
|
|
39
|
+
ConstantStatement.apply(this, [kind || KIND, constants, docs, location]);
|
|
40
|
+
this.parseFlags(flags);
|
|
41
|
+
this.nullable = nullable;
|
|
42
|
+
this.type = type;
|
|
43
|
+
this.attrGroups = attrGroups;
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generic flags parser
|
|
49
|
+
* @function
|
|
50
|
+
* @name ClassConstant#parseFlags
|
|
51
|
+
* @memberOf module:php-parser
|
|
52
|
+
* @param {Array<number|null>} flags
|
|
53
|
+
* @return {void}
|
|
54
|
+
*/
|
|
55
|
+
ClassConstant.prototype.parseFlags = function (flags) {
|
|
56
|
+
if (flags[0] === -1) {
|
|
57
|
+
this.visibility = IS_UNDEFINED;
|
|
58
|
+
} else if (flags[0] === null) {
|
|
59
|
+
/* istanbul ignore next */
|
|
60
|
+
this.visibility = null;
|
|
61
|
+
} else if (flags[0] === 0) {
|
|
62
|
+
this.visibility = IS_PUBLIC;
|
|
63
|
+
} else if (flags[0] === 1) {
|
|
64
|
+
this.visibility = IS_PROTECTED;
|
|
65
|
+
} else if (flags[0] === 2) {
|
|
66
|
+
this.visibility = IS_PRIVATE;
|
|
67
|
+
}
|
|
68
|
+
this.final = flags[2] === 2;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = ClassConstant;
|
package/src/ast/clone.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 Expression = require("./expression");
|
|
9
|
+
const KIND = "clone";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a clone call
|
|
13
|
+
* @constructor Clone
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Expression} what
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Expression.extends(KIND, function Clone(what, docs, location) {
|
|
19
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
20
|
+
this.what = what;
|
|
21
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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 = "closure";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a closure
|
|
13
|
+
* @constructor Closure
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Parameter[]} arguments
|
|
17
|
+
* @property {Variable[]} uses
|
|
18
|
+
* @property {Identifier} type
|
|
19
|
+
* @property {Boolean} byref
|
|
20
|
+
* @property {boolean} nullable
|
|
21
|
+
* @property {Block|null} body
|
|
22
|
+
* @property {boolean} isStatic
|
|
23
|
+
* @property {AttrGroup[]} attrGroups
|
|
24
|
+
*/
|
|
25
|
+
module.exports = Expression.extends(
|
|
26
|
+
KIND,
|
|
27
|
+
function Closure(
|
|
28
|
+
args,
|
|
29
|
+
byref,
|
|
30
|
+
uses,
|
|
31
|
+
type,
|
|
32
|
+
nullable,
|
|
33
|
+
isStatic,
|
|
34
|
+
docs,
|
|
35
|
+
location,
|
|
36
|
+
) {
|
|
37
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
38
|
+
this.uses = uses;
|
|
39
|
+
this.arguments = args;
|
|
40
|
+
this.byref = byref;
|
|
41
|
+
this.type = type;
|
|
42
|
+
this.nullable = nullable;
|
|
43
|
+
this.isStatic = isStatic || false;
|
|
44
|
+
this.body = null;
|
|
45
|
+
this.attrGroups = [];
|
|
46
|
+
},
|
|
47
|
+
);
|
|
@@ -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 Node = require("./node");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Abstract documentation node (ComentLine or CommentBlock)
|
|
12
|
+
* @constructor Comment
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @extends {Node}
|
|
15
|
+
* @property {String} value
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Node.extends(
|
|
18
|
+
"comment",
|
|
19
|
+
function Comment(kind, value, docs, location) {
|
|
20
|
+
Node.apply(this, [kind, docs, location]);
|
|
21
|
+
this.value = value;
|
|
22
|
+
},
|
|
23
|
+
);
|
|
@@ -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 Comment = require("./comment");
|
|
9
|
+
const KIND = "commentblock";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A comment block (multiline)
|
|
13
|
+
* @constructor CommentBlock
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Comment}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Comment.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function CommentBlock(value, docs, location) {
|
|
20
|
+
Comment.apply(this, [KIND, value, docs, location]);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -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 Comment = require("./comment");
|
|
9
|
+
const KIND = "commentline";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A single line comment
|
|
13
|
+
* @constructor CommentLine
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Comment}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Comment.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function CommentLine(value, docs, location) {
|
|
20
|
+
Comment.apply(this, [KIND, value, docs, location]);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -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 = "constant";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a constant
|
|
13
|
+
* @constructor Constant
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
* @property {string} name
|
|
17
|
+
* @property {Node|string|number|boolean|null} value
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Node.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Constant(name, value, docs, location) {
|
|
22
|
+
Node.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.name = name;
|
|
24
|
+
this.value = value;
|
|
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 Statement = require("./statement");
|
|
9
|
+
const KIND = "constantstatement";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Declares a constants into the current scope
|
|
13
|
+
* @constructor ConstantStatement
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Constant[]} constants
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function ConstantStatement(kind, constants, docs, location) {
|
|
21
|
+
Statement.apply(this, [kind || KIND, docs, location]);
|
|
22
|
+
this.constants = constants;
|
|
23
|
+
},
|
|
24
|
+
);
|
|
@@ -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 Statement = require("./statement");
|
|
9
|
+
const KIND = "continue";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A continue statement
|
|
13
|
+
* @constructor Continue
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {number|null} level
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Continue(level, docs, location) {
|
|
21
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
22
|
+
this.level = level;
|
|
23
|
+
},
|
|
24
|
+
);
|
|
@@ -0,0 +1,60 @@
|
|
|
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 = "declaration";
|
|
10
|
+
|
|
11
|
+
const IS_UNDEFINED = "";
|
|
12
|
+
const IS_PUBLIC = "public";
|
|
13
|
+
const IS_PROTECTED = "protected";
|
|
14
|
+
const IS_PRIVATE = "private";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A declaration statement (function, class, interface...)
|
|
18
|
+
* @constructor Declaration
|
|
19
|
+
* @memberOf module:php-parser
|
|
20
|
+
* @extends {Statement}
|
|
21
|
+
* @property {Identifier|string} name
|
|
22
|
+
*/
|
|
23
|
+
const Declaration = Statement.extends(
|
|
24
|
+
KIND,
|
|
25
|
+
function Declaration(kind, name, docs, location) {
|
|
26
|
+
Statement.apply(this, [kind || KIND, docs, location]);
|
|
27
|
+
this.name = name;
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generic flags parser
|
|
33
|
+
* @function
|
|
34
|
+
* @name Declaration#parseFlags
|
|
35
|
+
* @memberOf module:php-parser
|
|
36
|
+
* @param {Array<number|null>} flags
|
|
37
|
+
* @return {void}
|
|
38
|
+
*/
|
|
39
|
+
Declaration.prototype.parseFlags = function (flags) {
|
|
40
|
+
this.isAbstract = flags[2] === 1;
|
|
41
|
+
this.isFinal = flags[2] === 2;
|
|
42
|
+
this.isReadonly = flags[3] === 1;
|
|
43
|
+
if (this.kind !== "class") {
|
|
44
|
+
if (flags[0] === -1) {
|
|
45
|
+
this.visibility = IS_UNDEFINED;
|
|
46
|
+
} else if (flags[0] === null) {
|
|
47
|
+
/* istanbul ignore next */
|
|
48
|
+
this.visibility = null;
|
|
49
|
+
} else if (flags[0] === 0) {
|
|
50
|
+
this.visibility = IS_PUBLIC;
|
|
51
|
+
} else if (flags[0] === 1) {
|
|
52
|
+
this.visibility = IS_PROTECTED;
|
|
53
|
+
} else if (flags[0] === 2) {
|
|
54
|
+
this.visibility = IS_PRIVATE;
|
|
55
|
+
}
|
|
56
|
+
this.isStatic = flags[1] === 1;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = Declaration;
|