@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 Literal = require("./literal");
|
|
9
|
+
const KIND = "nowdoc";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a nowdoc string
|
|
13
|
+
* @constructor NowDoc
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Literal}
|
|
16
|
+
* @property {string} label
|
|
17
|
+
* @property {string} raw
|
|
18
|
+
* @property {string} value
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Literal.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Nowdoc(value, raw, label, docs, location) {
|
|
23
|
+
Literal.apply(this, [KIND, value, raw, docs, location]);
|
|
24
|
+
this.label = label;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
@@ -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 = "nullkeyword";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents the null keyword
|
|
13
|
+
* @constructor NullKeyword
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Node.extends(KIND, function NullKeyword(raw, docs, location) {
|
|
18
|
+
Node.apply(this, [KIND, docs, location]);
|
|
19
|
+
this.raw = raw;
|
|
20
|
+
});
|
|
@@ -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 Lookup = require("./lookup");
|
|
9
|
+
const KIND = "nullsafepropertylookup";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lookup to an object property
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor NullSafePropertyLookup
|
|
15
|
+
* @extends {Lookup}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Lookup.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function NullSafePropertyLookup(what, offset, docs, location) {
|
|
20
|
+
Lookup.apply(this, [KIND, what, offset, docs, location]);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -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 = "number";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a numeric value
|
|
13
|
+
* @constructor Number
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Literal}
|
|
16
|
+
* @property {number} value
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Literal.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Number(value, raw, docs, location) {
|
|
21
|
+
Literal.apply(this, [KIND, value, raw, docs, location]);
|
|
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 Lookup = require("./lookup");
|
|
9
|
+
const KIND = "offsetlookup";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lookup on an offset in an array
|
|
13
|
+
* @constructor OffsetLookup
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Lookup}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Lookup.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function OffsetLookup(what, offset, docs, location) {
|
|
20
|
+
Lookup.apply(this, [KIND, what, offset, docs, location]);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 = "operation";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines binary operations
|
|
13
|
+
* @constructor Operation
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Expr.extends(KIND, function Operation(kind, docs, location) {
|
|
18
|
+
Expr.apply(this, [kind || KIND, docs, location]);
|
|
19
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
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 = "parameter";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @memberOf module:php-parser
|
|
13
|
+
* @typedef {1} MODIFIER_PUBLIC
|
|
14
|
+
**/
|
|
15
|
+
/**
|
|
16
|
+
* @memberOf module:php-parser
|
|
17
|
+
* @typedef {2} MODIFIER_PROTECTED
|
|
18
|
+
**/
|
|
19
|
+
/**
|
|
20
|
+
* @memberOf module:php-parser
|
|
21
|
+
* @typedef {4} MODIFIER_PRIVATE
|
|
22
|
+
**/
|
|
23
|
+
/**
|
|
24
|
+
* Defines a function parameter
|
|
25
|
+
* @constructor Parameter
|
|
26
|
+
* @memberOf module:php-parser
|
|
27
|
+
* @extends {Declaration}
|
|
28
|
+
* @property {Identifier|null} type
|
|
29
|
+
* @property {Node|null} value
|
|
30
|
+
* @property {boolean} byref
|
|
31
|
+
* @property {boolean} variadic
|
|
32
|
+
* @property {boolean} readonly
|
|
33
|
+
* @property {boolean} nullable
|
|
34
|
+
* @property {AttrGroup[]} attrGroups
|
|
35
|
+
* @property {MODIFIER_PUBLIC|MODIFIER_PROTECTED|MODIFIER_PRIVATE} flags
|
|
36
|
+
*/
|
|
37
|
+
module.exports = Declaration.extends(
|
|
38
|
+
KIND,
|
|
39
|
+
function Parameter(
|
|
40
|
+
name,
|
|
41
|
+
type,
|
|
42
|
+
value,
|
|
43
|
+
isRef,
|
|
44
|
+
isVariadic,
|
|
45
|
+
readonly,
|
|
46
|
+
nullable,
|
|
47
|
+
flags,
|
|
48
|
+
docs,
|
|
49
|
+
location,
|
|
50
|
+
) {
|
|
51
|
+
Declaration.apply(this, [KIND, name, docs, location]);
|
|
52
|
+
this.value = value;
|
|
53
|
+
this.type = type;
|
|
54
|
+
this.byref = isRef;
|
|
55
|
+
this.variadic = isVariadic;
|
|
56
|
+
this.readonly = readonly;
|
|
57
|
+
this.nullable = nullable;
|
|
58
|
+
this.flags = flags || 0;
|
|
59
|
+
this.attrGroups = [];
|
|
60
|
+
},
|
|
61
|
+
);
|
|
@@ -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 Reference = require("./reference");
|
|
9
|
+
const KIND = "parentreference";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class reference node
|
|
13
|
+
* @constructor ParentReference
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Reference}
|
|
16
|
+
*/
|
|
17
|
+
const ParentReference = Reference.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function ParentReference(raw, docs, location) {
|
|
20
|
+
Reference.apply(this, [KIND, docs, location]);
|
|
21
|
+
this.raw = raw;
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
module.exports = ParentReference;
|
|
@@ -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
|
+
* Each Position object consists of a line number (1-indexed) and a column number (0-indexed):
|
|
10
|
+
* @constructor Position
|
|
11
|
+
* @memberOf module:php-parser
|
|
12
|
+
* @property {number} line
|
|
13
|
+
* @property {number} column
|
|
14
|
+
* @property {number} offset
|
|
15
|
+
*/
|
|
16
|
+
const Position = function (line, column, offset) {
|
|
17
|
+
this.line = line;
|
|
18
|
+
this.column = column;
|
|
19
|
+
this.offset = offset;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = Position;
|
package/src/ast/post.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 Operation = require("./operation");
|
|
9
|
+
const KIND = "post";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a post operation `$i++` or `$i--`
|
|
13
|
+
* @constructor Post
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Operation}
|
|
16
|
+
* @property {String} type
|
|
17
|
+
* @property {Variable} what
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Operation.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Post(type, what, docs, location) {
|
|
22
|
+
Operation.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.type = type;
|
|
24
|
+
this.what = what;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/pre.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 Operation = require("./operation");
|
|
9
|
+
const KIND = "pre";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a pre operation `++$i` or `--$i`
|
|
13
|
+
* @constructor Pre
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Operation}
|
|
16
|
+
* @property {String} type
|
|
17
|
+
* @property {Variable} what
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Operation.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Pre(type, what, docs, location) {
|
|
22
|
+
Operation.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.type = type;
|
|
24
|
+
this.what = what;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/print.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 = "print";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Outputs
|
|
13
|
+
* @constructor Print
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Expression.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function Print(expression, docs, location) {
|
|
20
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
21
|
+
this.expression = expression;
|
|
22
|
+
},
|
|
23
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
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 = "program";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The main program node
|
|
13
|
+
* @constructor Program
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Block}
|
|
16
|
+
* @property {Error[]} errors
|
|
17
|
+
* @property {Comment[]|null} comments
|
|
18
|
+
* @property {String[]|null} tokens
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Block.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Program(children, errors, comments, tokens, docs, location) {
|
|
23
|
+
Block.apply(this, [KIND, children, docs, location]);
|
|
24
|
+
this.errors = errors;
|
|
25
|
+
if (comments) {
|
|
26
|
+
this.comments = comments;
|
|
27
|
+
}
|
|
28
|
+
if (tokens) {
|
|
29
|
+
this.tokens = tokens;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
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 = "property";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class property
|
|
13
|
+
* @constructor Property
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {string} name
|
|
17
|
+
* @property {Node|null} value
|
|
18
|
+
* @property {boolean} readonly
|
|
19
|
+
* @property {boolean} nullable
|
|
20
|
+
* @property {Identifier|Array<Identifier>|null} type
|
|
21
|
+
* @property {PropertyHook[]} hooks
|
|
22
|
+
* @property {AttrGroup[]} attrGroups
|
|
23
|
+
*/
|
|
24
|
+
module.exports = Statement.extends(
|
|
25
|
+
KIND,
|
|
26
|
+
function Property(
|
|
27
|
+
name,
|
|
28
|
+
value,
|
|
29
|
+
readonly,
|
|
30
|
+
nullable,
|
|
31
|
+
type,
|
|
32
|
+
hooks,
|
|
33
|
+
attrGroups,
|
|
34
|
+
docs,
|
|
35
|
+
location,
|
|
36
|
+
) {
|
|
37
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
38
|
+
this.name = name;
|
|
39
|
+
this.value = value;
|
|
40
|
+
this.readonly = readonly;
|
|
41
|
+
this.nullable = nullable;
|
|
42
|
+
this.type = type;
|
|
43
|
+
this.hooks = hooks;
|
|
44
|
+
this.attrGroups = attrGroups;
|
|
45
|
+
},
|
|
46
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2024 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 = "propertyhook";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class property hook getter & setter
|
|
13
|
+
*
|
|
14
|
+
* @constructor PropertyHook
|
|
15
|
+
* @memberOf module:php-parser
|
|
16
|
+
* @extends {Node}
|
|
17
|
+
* @property {string} name
|
|
18
|
+
* @property {Boolean} isFinal
|
|
19
|
+
* @property {Boolean} byref
|
|
20
|
+
* @property {Parameter|null} parameter
|
|
21
|
+
* @property {Block|Statement} body
|
|
22
|
+
*/
|
|
23
|
+
module.exports = Node.extends(
|
|
24
|
+
KIND,
|
|
25
|
+
function PropertyHook(name, isFinal, byref, parameter, body, docs, location) {
|
|
26
|
+
Node.apply(this, [KIND, docs, location]);
|
|
27
|
+
this.name = name;
|
|
28
|
+
this.byref = byref;
|
|
29
|
+
this.parameter = parameter;
|
|
30
|
+
this.body = body;
|
|
31
|
+
this.isFinal = isFinal;
|
|
32
|
+
},
|
|
33
|
+
);
|
|
@@ -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 Lookup = require("./lookup");
|
|
9
|
+
const KIND = "propertylookup";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lookup to an object property
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor PropertyLookup
|
|
15
|
+
* @extends {Lookup}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Lookup.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function PropertyLookup(what, offset, docs, location) {
|
|
20
|
+
Lookup.apply(this, [KIND, what, offset, docs, location]);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -0,0 +1,59 @@
|
|
|
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 = "propertystatement";
|
|
10
|
+
|
|
11
|
+
const IS_UNDEFINED = "";
|
|
12
|
+
const IS_PUBLIC = "public";
|
|
13
|
+
const IS_PROTECTED = "protected";
|
|
14
|
+
const IS_PRIVATE = "private";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Declares a properties into the current scope
|
|
18
|
+
* @constructor PropertyStatement
|
|
19
|
+
* @memberOf module:php-parser
|
|
20
|
+
* @extends {Statement}
|
|
21
|
+
* @property {Property[]} properties
|
|
22
|
+
* @property {string|null} visibility
|
|
23
|
+
* @property {boolean} isStatic
|
|
24
|
+
*/
|
|
25
|
+
const PropertyStatement = Statement.extends(
|
|
26
|
+
KIND,
|
|
27
|
+
function PropertyStatement(kind, properties, flags, docs, location) {
|
|
28
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
29
|
+
this.properties = properties;
|
|
30
|
+
this.parseFlags(flags);
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Generic flags parser
|
|
36
|
+
* @function PropertyStatement#parseFlags
|
|
37
|
+
* @memberOf module:php-parser
|
|
38
|
+
* @param {Array<number|null>} flags
|
|
39
|
+
* @return {void}
|
|
40
|
+
*/
|
|
41
|
+
PropertyStatement.prototype.parseFlags = function (flags) {
|
|
42
|
+
if (flags[0] === -1) {
|
|
43
|
+
this.visibility = IS_UNDEFINED;
|
|
44
|
+
} else if (flags[0] === null) {
|
|
45
|
+
this.visibility = null;
|
|
46
|
+
} else if (flags[0] === 0) {
|
|
47
|
+
this.visibility = IS_PUBLIC;
|
|
48
|
+
} else if (flags[0] === 1) {
|
|
49
|
+
this.visibility = IS_PROTECTED;
|
|
50
|
+
} else if (flags[0] === 2) {
|
|
51
|
+
this.visibility = IS_PRIVATE;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.isStatic = flags[1] === 1;
|
|
55
|
+
this.isAbstract = flags[2] === 1;
|
|
56
|
+
this.isFinal = flags[2] === 2;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
module.exports = PropertyStatement;
|
|
@@ -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 Node = require("./node");
|
|
9
|
+
const KIND = "reference";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a reference node
|
|
13
|
+
* @constructor Reference
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
*/
|
|
17
|
+
const Reference = Node.extends(KIND, function Reference(kind, docs, location) {
|
|
18
|
+
Node.apply(this, [kind || KIND, docs, location]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = Reference;
|
package/src/ast/retif.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 Expression = require("./expression");
|
|
9
|
+
const KIND = "retif";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a short if statement that returns a value
|
|
13
|
+
* @constructor RetIf
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Expression} test
|
|
17
|
+
* @property {Expression} trueExpr
|
|
18
|
+
* @property {Expression} falseExpr
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Expression.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function RetIf(test, trueExpr, falseExpr, docs, location) {
|
|
23
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.test = test;
|
|
25
|
+
this.trueExpr = trueExpr;
|
|
26
|
+
this.falseExpr = falseExpr;
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -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 = "return";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A continue statement
|
|
13
|
+
* @constructor Return
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Expression|null} expr
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(KIND, function Return(expr, docs, location) {
|
|
19
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
20
|
+
this.expr = expr;
|
|
21
|
+
});
|
|
@@ -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 Reference = require("./reference");
|
|
9
|
+
const KIND = "selfreference";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class reference node
|
|
13
|
+
* @constructor SelfReference
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Reference}
|
|
16
|
+
*/
|
|
17
|
+
const SelfReference = Reference.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function SelfReference(raw, docs, location) {
|
|
20
|
+
Reference.apply(this, [KIND, docs, location]);
|
|
21
|
+
this.raw = raw;
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
module.exports = SelfReference;
|
|
@@ -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 Expression = require("./expression");
|
|
9
|
+
const KIND = "silent";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Avoids to show/log warnings & notices from the inner expression
|
|
13
|
+
* @constructor Silent
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Expression} expr
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Expression.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Silent(expr, docs, location) {
|
|
21
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
22
|
+
this.expr = expr;
|
|
23
|
+
},
|
|
24
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 = "statement";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Any statement.
|
|
13
|
+
* @constructor Statement
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Node.extends(KIND, function Statement(kind, docs, location) {
|
|
18
|
+
Node.apply(this, [kind || KIND, docs, location]);
|
|
19
|
+
});
|