@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,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 = "static";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Declares a static variable into the current scope
|
|
13
|
+
* @constructor Static
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {StaticVariable[]} variables
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Static(variables, docs, location) {
|
|
21
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
22
|
+
this.variables = variables;
|
|
23
|
+
},
|
|
24
|
+
);
|
|
@@ -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 = "staticlookup";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lookup to a static property
|
|
13
|
+
* @constructor StaticLookup
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Lookup}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Lookup.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function StaticLookup(what, offset, docs, location) {
|
|
20
|
+
Lookup.apply(this, [KIND, what, offset, docs, location]);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
@@ -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 = "staticreference";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class reference node
|
|
13
|
+
* @constructor StaticReference
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Reference}
|
|
16
|
+
*/
|
|
17
|
+
const StaticReference = Reference.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function StaticReference(raw, docs, location) {
|
|
20
|
+
Reference.apply(this, [KIND, docs, location]);
|
|
21
|
+
this.raw = raw;
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
module.exports = StaticReference;
|
|
@@ -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 = "staticvariable";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a constant
|
|
13
|
+
* @constructor StaticVariable
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
* @property {Variable} variable
|
|
17
|
+
* @property {Node|string|number|boolean|null} defaultValue
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Node.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function StaticVariable(variable, defaultValue, docs, location) {
|
|
22
|
+
Node.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.variable = variable;
|
|
24
|
+
this.defaultValue = defaultValue;
|
|
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 Literal = require("./literal");
|
|
9
|
+
const KIND = "string";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a string (simple or double quoted) - chars are already escaped
|
|
13
|
+
* @constructor String
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Literal}
|
|
16
|
+
* @property {boolean} unicode
|
|
17
|
+
* @property {boolean} isDoubleQuote
|
|
18
|
+
* @see {Encapsed}
|
|
19
|
+
* @property {string} value
|
|
20
|
+
*/
|
|
21
|
+
module.exports = Literal.extends(
|
|
22
|
+
KIND,
|
|
23
|
+
function String(isDoubleQuote, value, unicode, raw, docs, location) {
|
|
24
|
+
Literal.apply(this, [KIND, value, raw, docs, location]);
|
|
25
|
+
this.unicode = unicode;
|
|
26
|
+
this.isDoubleQuote = isDoubleQuote;
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -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 Statement = require("./statement");
|
|
9
|
+
const KIND = "switch";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a switch statement
|
|
13
|
+
* @constructor Switch
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Expression} test
|
|
17
|
+
* @property {Block} body
|
|
18
|
+
* @property {boolean} shortForm
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Statement.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Switch(test, body, shortForm, docs, location) {
|
|
23
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.test = test;
|
|
25
|
+
this.body = body;
|
|
26
|
+
this.shortForm = shortForm;
|
|
27
|
+
},
|
|
28
|
+
);
|
package/src/ast/throw.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 = "throw";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a throw statement
|
|
13
|
+
* @constructor Throw
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Expression} what
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Statement.extends(KIND, function Throw(what, docs, location) {
|
|
19
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
20
|
+
this.what = what;
|
|
21
|
+
});
|
package/src/ast/trait.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 Declaration = require("./declaration");
|
|
9
|
+
const KIND = "trait";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A trait definition
|
|
13
|
+
* @constructor Trait
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Declaration}
|
|
16
|
+
* @property {Declaration[]} body
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Declaration.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function Trait(name, body, docs, location) {
|
|
21
|
+
Declaration.apply(this, [KIND, name, docs, location]);
|
|
22
|
+
this.body = body;
|
|
23
|
+
},
|
|
24
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
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 = "traitalias";
|
|
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 trait alias
|
|
18
|
+
* @constructor TraitAlias
|
|
19
|
+
* @memberOf module:php-parser
|
|
20
|
+
* @extends {Node}
|
|
21
|
+
* @property {Identifier|null} trait
|
|
22
|
+
* @property {Identifier} method
|
|
23
|
+
* @property {Identifier|null} as
|
|
24
|
+
* @property {string|null} visibility
|
|
25
|
+
*/
|
|
26
|
+
module.exports = Node.extends(
|
|
27
|
+
KIND,
|
|
28
|
+
function TraitAlias(trait, method, as, flags, docs, location) {
|
|
29
|
+
Node.apply(this, [KIND, docs, location]);
|
|
30
|
+
this.trait = trait;
|
|
31
|
+
this.method = method;
|
|
32
|
+
this.as = as;
|
|
33
|
+
this.visibility = IS_UNDEFINED;
|
|
34
|
+
if (flags) {
|
|
35
|
+
if (flags[0] === 0) {
|
|
36
|
+
this.visibility = IS_PUBLIC;
|
|
37
|
+
} else if (flags[0] === 1) {
|
|
38
|
+
this.visibility = IS_PROTECTED;
|
|
39
|
+
} else if (flags[0] === 2) {
|
|
40
|
+
this.visibility = IS_PRIVATE;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
);
|
|
@@ -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 Node = require("./node");
|
|
9
|
+
const KIND = "traitprecedence";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a trait alias
|
|
13
|
+
* @constructor TraitPrecedence
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
* @property {Identifier|null} trait
|
|
17
|
+
* @property {Identifier} method
|
|
18
|
+
* @property {Identifier[]} instead
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Node.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function TraitPrecedence(trait, method, instead, docs, location) {
|
|
23
|
+
Node.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.trait = trait;
|
|
25
|
+
this.method = method;
|
|
26
|
+
this.instead = instead;
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -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 = "traituse";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a trait usage
|
|
13
|
+
* @constructor TraitUse
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
* @property {Identifier[]} traits
|
|
17
|
+
* @property {Node[]|null} adaptations
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Node.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function TraitUse(traits, adaptations, docs, location) {
|
|
22
|
+
Node.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.traits = traits;
|
|
24
|
+
this.adaptations = adaptations;
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/ast/try.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 Statement = require("./statement");
|
|
9
|
+
const KIND = "try";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a try statement
|
|
13
|
+
* @constructor Try
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Block} body
|
|
17
|
+
* @property {Catch[]} catches
|
|
18
|
+
* @property {Block} always
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Statement.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Try(body, catches, always, docs, location) {
|
|
23
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.body = body;
|
|
25
|
+
this.catches = catches;
|
|
26
|
+
this.always = always;
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
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 = "typereference";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class reference node
|
|
13
|
+
* @constructor TypeReference
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Reference}
|
|
16
|
+
* @property {string} name
|
|
17
|
+
*/
|
|
18
|
+
const TypeReference = Reference.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function TypeReference(name, raw, docs, location) {
|
|
21
|
+
Reference.apply(this, [KIND, docs, location]);
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.raw = raw;
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
TypeReference.types = [
|
|
28
|
+
"int",
|
|
29
|
+
"float",
|
|
30
|
+
"string",
|
|
31
|
+
"bool",
|
|
32
|
+
"object",
|
|
33
|
+
"array",
|
|
34
|
+
"callable",
|
|
35
|
+
"iterable",
|
|
36
|
+
"void",
|
|
37
|
+
"static",
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
module.exports = TypeReference;
|
package/src/ast/unary.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 = "unary";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Unary operations
|
|
13
|
+
* @constructor Unary
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Operation}
|
|
16
|
+
* @property {string} type
|
|
17
|
+
* @property {Expression} what
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Operation.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function Unary(type, what, docs, location) {
|
|
22
|
+
Operation.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.type = type;
|
|
24
|
+
this.what = what;
|
|
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 Declaration = require("./declaration");
|
|
9
|
+
const KIND = "uniontype";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A union of types
|
|
13
|
+
* @memberOf module:php-parser
|
|
14
|
+
* @constructor UnionType
|
|
15
|
+
* @extends {Declaration}
|
|
16
|
+
* @property {TypeReference[]} types
|
|
17
|
+
*/
|
|
18
|
+
module.exports = Declaration.extends(
|
|
19
|
+
KIND,
|
|
20
|
+
function UnionType(types, docs, location) {
|
|
21
|
+
Declaration.apply(this, [KIND, null, docs, location]);
|
|
22
|
+
this.types = types;
|
|
23
|
+
},
|
|
24
|
+
);
|
package/src/ast/unset.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 Statement = require("./statement");
|
|
9
|
+
const KIND = "unset";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Deletes references to a list of variables
|
|
13
|
+
* @constructor Unset
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = Statement.extends(
|
|
18
|
+
KIND,
|
|
19
|
+
function Unset(variables, docs, location) {
|
|
20
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
21
|
+
this.variables = variables;
|
|
22
|
+
},
|
|
23
|
+
);
|
|
@@ -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 = "usegroup";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a use statement (with a list of use items)
|
|
13
|
+
* @constructor UseGroup
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {string|null} name
|
|
17
|
+
* @property {string|null} type - Possible value : function, const
|
|
18
|
+
* @property {UseItem[]} item
|
|
19
|
+
* @see {Namespace}
|
|
20
|
+
* @see http://php.net/manual/en/language.namespaces.importing.php
|
|
21
|
+
*/
|
|
22
|
+
module.exports = Statement.extends(
|
|
23
|
+
KIND,
|
|
24
|
+
function UseGroup(name, type, items, docs, location) {
|
|
25
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
26
|
+
this.name = name;
|
|
27
|
+
this.type = type;
|
|
28
|
+
this.items = items;
|
|
29
|
+
},
|
|
30
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
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 = "useitem";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a use statement (from namespace)
|
|
13
|
+
* @constructor UseItem
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {string} name
|
|
17
|
+
* @property {string|null} type - Possible value : function, const
|
|
18
|
+
* @property {Identifier|null} alias
|
|
19
|
+
* @see {Namespace}
|
|
20
|
+
* @see http://php.net/manual/en/language.namespaces.importing.php
|
|
21
|
+
*/
|
|
22
|
+
const UseItem = Statement.extends(
|
|
23
|
+
KIND,
|
|
24
|
+
function UseItem(name, alias, type, docs, location) {
|
|
25
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
26
|
+
this.name = name;
|
|
27
|
+
this.alias = alias;
|
|
28
|
+
this.type = type;
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Importing a constant
|
|
34
|
+
* @constant {string} UseItem#TYPE_CONST
|
|
35
|
+
* @memberOf module:php-parser
|
|
36
|
+
*/
|
|
37
|
+
UseItem.TYPE_CONST = "const";
|
|
38
|
+
/**
|
|
39
|
+
* Importing a function
|
|
40
|
+
* @constant {string} UseItem#TYPE_FUNC
|
|
41
|
+
* @memberOf module:php-parser
|
|
42
|
+
*/
|
|
43
|
+
UseItem.TYPE_FUNCTION = "function";
|
|
44
|
+
|
|
45
|
+
module.exports = UseItem;
|
|
@@ -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 Expression = require("./expression");
|
|
9
|
+
const KIND = "variable";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Any expression node. Since the left-hand side of an assignment may
|
|
13
|
+
* be any expression in general, an expression can also be a pattern.
|
|
14
|
+
* @constructor Variable
|
|
15
|
+
* @memberOf module:php-parser
|
|
16
|
+
* @extends {Expression}
|
|
17
|
+
* @example
|
|
18
|
+
* // PHP code :
|
|
19
|
+
* $foo
|
|
20
|
+
* // AST output
|
|
21
|
+
* {
|
|
22
|
+
* "kind": "variable",
|
|
23
|
+
* "name": "foo",
|
|
24
|
+
* "curly": false
|
|
25
|
+
* }
|
|
26
|
+
* @property {string|Node} name The variable name (can be a complex expression when the name is resolved dynamically)
|
|
27
|
+
* @property {boolean} curly Indicate if the name is defined between curlies, ex `${foo}`
|
|
28
|
+
*/
|
|
29
|
+
module.exports = Expression.extends(
|
|
30
|
+
KIND,
|
|
31
|
+
function Variable(name, curly, docs, location) {
|
|
32
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
33
|
+
this.name = name;
|
|
34
|
+
this.curly = curly || false;
|
|
35
|
+
},
|
|
36
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
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 = "variadic";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Introduce a list of items into the arguments of the call
|
|
13
|
+
* @constructor Variadic
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Array|Expression} what
|
|
17
|
+
* @see https://wiki.php.net/rfc/argument_unpacking
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Expression.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function variadic(what, docs, location) {
|
|
22
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
23
|
+
this.what = what;
|
|
24
|
+
},
|
|
25
|
+
);
|
|
@@ -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 Node = require("./node");
|
|
9
|
+
const KIND = "variadicplaceholder";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a variadic placeholder (the ellipsis in PHP 8.1+'s first-class callable syntax)
|
|
13
|
+
* @constructor VariadicPlaceholder
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Node}
|
|
16
|
+
* @see {Namespace}
|
|
17
|
+
* @see http://php.net/manual/en/language.namespaces.importing.php
|
|
18
|
+
*/
|
|
19
|
+
module.exports = Node.extends(
|
|
20
|
+
KIND,
|
|
21
|
+
function VariadicPlaceholder(docs, location) {
|
|
22
|
+
Node.apply(this, [KIND, docs, location]);
|
|
23
|
+
},
|
|
24
|
+
);
|
package/src/ast/while.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 Statement = require("./statement");
|
|
9
|
+
const KIND = "while";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a while statement
|
|
13
|
+
* @constructor While
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Statement}
|
|
16
|
+
* @property {Expression} test
|
|
17
|
+
* @property {Block | null} body
|
|
18
|
+
* @property {boolean} shortForm
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Statement.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function While(test, body, shortForm, docs, location) {
|
|
23
|
+
Statement.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.test = test;
|
|
25
|
+
this.body = body;
|
|
26
|
+
this.shortForm = shortForm;
|
|
27
|
+
},
|
|
28
|
+
);
|
package/src/ast/yield.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 Expression = require("./expression");
|
|
9
|
+
const KIND = "yield";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Defines a yield generator statement
|
|
13
|
+
* @constructor Yield
|
|
14
|
+
* @memberOf module:php-parser
|
|
15
|
+
* @extends {Expression}
|
|
16
|
+
* @property {Expression|null} value
|
|
17
|
+
* @property {Expression|null} key
|
|
18
|
+
* @see http://php.net/manual/en/language.generators.syntax.php
|
|
19
|
+
*/
|
|
20
|
+
module.exports = Expression.extends(
|
|
21
|
+
KIND,
|
|
22
|
+
function Yield(value, key, docs, location) {
|
|
23
|
+
Expression.apply(this, [KIND, docs, location]);
|
|
24
|
+
this.value = value;
|
|
25
|
+
this.key = key;
|
|
26
|
+
},
|
|
27
|
+
);
|