UNPKG

php-parser

Version:

Parse PHP code from JS and returns its AST

1,773 lines (1,516 loc) 327 kB
/*! * * Package: php-parser * Parse PHP code from JS and returns its AST * Build: 546cb0da384f6fc5d54c - 12/31/2024 * Copyright (C) 2021 Glayzzle (BSD-3-Clause) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com * */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["PhpParser"] = factory(); else root["PhpParser"] = factory(); })(self, () => { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ 8938: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Location = __webpack_require__(4778); var Position = __webpack_require__(8822); /** * ## Class hierarchy * * - [Location](#location) * - [Position](#position) * - [Node](#node) * - [Noop](#noop) * - [NullKeyword](#nullkeyword) * - [StaticVariable](#staticvariable) * - [EncapsedPart](#encapsedpart) * - [Constant](#constant) * - [Identifier](#identifier) * - [Reference](#reference) * - [TypeReference](#typereference) * - [ParentReference](#parentreference) * - [StaticReference](#staticreference) * - [SelfReference](#selfreference) * - [Name](#name) * - [TraitUse](#traituse) * - [TraitAlias](#traitalias) * - [TraitPrecedence](#traitprecedence) * - [Comment](#comment) * - [CommentLine](#commentline) * - [CommentBlock](#commentblock) * - [Error](#error) * - [Expression](#expression) * - [Entry](#entry) * - [ArrowFunc](#arrowfunc) * - [Closure](#closure) * - [ByRef](#byref) * - [Silent](#silent) * - [RetIf](#retif) * - [New](#new) * - [Include](#include) * - [Call](#call) * - [Eval](#eval) * - [Exit](#exit) * - [Clone](#clone) * - [Assign](#assign) * - [AssignRef](#assignref) * - [Array](#array) * - [List](#list) * - [Variable](#variable) * - [Variadic](#variadic) * - [Yield](#yield) * - [YieldFrom](#yieldfrom) * - [Print](#print) * - [Isset](#isset) * - [Empty](#empty) * - [Lookup](#lookup) * - [PropertyLookup](#propertylookup) * - [StaticLookup](#staticlookup) * - [OffsetLookup](#offsetlookup) * - [Operation](#operation) * - [Pre](#pre) * - [Post](#post) * - [Bin](#bin) * - [Unary](#unary) * - [Cast](#cast) * - [Literal](#literal) * - [Boolean](#boolean) * - [String](#string) * - [Number](#number) * - [Inline](#inline) * - [Magic](#magic) * - [Nowdoc](#nowdoc) * - [Encapsed](#encapsed) * - [Statement](#statement) * - [ConstantStatement](#constantstatement) * - [ClassConstant](#classconstant) * - [Return](#return) * - [Label](#label) * - [Continue](#continue) * - [Case](#case) * - [Break](#break) * - [Echo](#echo) * - [Unset](#unset) * - [Halt](#halt) * - [Declare](#declare) * - [Global](#global) * - [Static](#static) * - [If](#if) * - [Do](#do) * - [While](#while) * - [For](#for) * - [Foreach](#foreach) * - [Switch](#switch) * - [Goto](#goto) * - [Try](#try) * - [Catch](#catch) * - [Throw](#throw) * - [UseGroup](#usegroup) * - [UseItem](#useitem) * - [Block](#block) * - [Program](#program) * - [Namespace](#namespace) * - [PropertyStatement](#propertystatement) * - [Property](#property) * - [Declaration](#declaration) * - [Class](#class) * - [Interface](#interface) * - [Trait](#trait) * - [Function](#function) * - [Method](#method) * - [Parameter](#parameter) * --- */ /** * The AST builder class * @constructor AST * @memberOf module:php-parser * @tutorial AST * @property {Boolean} withPositions - Should locate any node (by default false) * @property {Boolean} withSource - Should extract the node original code (by default false) */ var AST = function AST(withPositions, withSource) { this.withPositions = withPositions; this.withSource = withSource; }; // operators in ascending order of precedence AST.precedence = {}; [["or"], ["xor"], ["and"], ["="], ["?"], ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "!=", "===", "!==", /* '<>', */"<=>"], ["<", "<=", ">", ">="], ["<<", ">>"], ["+", "-", "."], ["*", "/", "%"], ["!"], ["instanceof"], ["cast", "silent"], ["**"] // TODO: [ (array) // TODO: clone, new ].forEach(function (list, index) { list.forEach(function (operator) { AST.precedence[operator] = index + 1; }); }); /** * @private * @function AST#isRightAssociative * @memberOf module:php-parser * @param operator * @return {boolean} */ AST.prototype.isRightAssociative = function (operator) { return operator === "**" || operator === "??"; }; /** * Change parent node informations after swapping childs * @private * @function AST#swapLocations * @memberOf module:php-parser */ AST.prototype.swapLocations = function (target, first, last, parser) { if (this.withPositions) { target.loc.start = first.loc.start; target.loc.end = last.loc.end; if (this.withSource) { target.loc.source = parser.lexer._input.substring(target.loc.start.offset, target.loc.end.offset); } } }; /** * Includes locations from first & last into the target * @private * @function AST#resolveLocations * @memberOf module:php-parser */ AST.prototype.resolveLocations = function (target, first, last, parser) { if (this.withPositions) { if (target.loc.start.offset > first.loc.start.offset) { target.loc.start = first.loc.start; } /* istanbul ignore next */ if (target.loc.end.offset < last.loc.end.offset) { target.loc.end = last.loc.end; } if (this.withSource) { target.loc.source = parser.lexer._input.substring(target.loc.start.offset, target.loc.end.offset); } } }; /** * Check and fix precence, by default using right * @private * @function AST#resolvePrecedence * @memberOf module:php-parser */ AST.prototype.resolvePrecedence = function (result, parser) { var buffer, lLevel, rLevel; // handling precendence if (result.kind === "call") { // including what argument into location this.resolveLocations(result, result.what, result, parser); } else if (result.kind === "propertylookup" || result.kind === "staticlookup" || result.kind === "offsetlookup" && result.offset) { // including what argument into location this.resolveLocations(result, result.what, result.offset, parser); } else if (result.kind === "bin") { if (result.right && !result.right.parenthesizedExpression) { if (result.right.kind === "bin") { lLevel = AST.precedence[result.type]; rLevel = AST.precedence[result.right.type]; if (lLevel && rLevel && rLevel <= lLevel && (result.type !== result.right.type || !this.isRightAssociative(result.type))) { // https://github.com/glayzzle/php-parser/issues/79 // shift precedence buffer = result.right; result.right = result.right.left; this.swapLocations(result, result.left, result.right, parser); buffer.left = this.resolvePrecedence(result, parser); this.swapLocations(buffer, buffer.left, buffer.right, parser); result = buffer; } } else if (result.right.kind === "retif") { lLevel = AST.precedence[result.type]; rLevel = AST.precedence["?"]; if (lLevel && rLevel && rLevel <= lLevel) { buffer = result.right; result.right = result.right.test; this.swapLocations(result, result.left, result.right, parser); buffer.test = this.resolvePrecedence(result, parser); this.swapLocations(buffer, buffer.test, buffer.falseExpr, parser); result = buffer; } } } } else if ((result.kind === "silent" || result.kind === "cast") && result.expr && !result.expr.parenthesizedExpression) { // https://github.com/glayzzle/php-parser/issues/172 if (result.expr.kind === "bin") { buffer = result.expr; result.expr = result.expr.left; this.swapLocations(result, result, result.expr, parser); buffer.left = this.resolvePrecedence(result, parser); this.swapLocations(buffer, buffer.left, buffer.right, parser); result = buffer; } else if (result.expr.kind === "retif") { buffer = result.expr; result.expr = result.expr.test; this.swapLocations(result, result, result.expr, parser); buffer.test = this.resolvePrecedence(result, parser); this.swapLocations(buffer, buffer.test, buffer.falseExpr, parser); result = buffer; } } else if (result.kind === "unary") { // https://github.com/glayzzle/php-parser/issues/75 if (result.what && !result.what.parenthesizedExpression) { // unary precedence is always lower if (result.what.kind === "bin") { buffer = result.what; result.what = result.what.left; this.swapLocations(result, result, result.what, parser); buffer.left = this.resolvePrecedence(result, parser); this.swapLocations(buffer, buffer.left, buffer.right, parser); result = buffer; } else if (result.what.kind === "retif") { buffer = result.what; result.what = result.what.test; this.swapLocations(result, result, result.what, parser); buffer.test = this.resolvePrecedence(result, parser); this.swapLocations(buffer, buffer.test, buffer.falseExpr, parser); result = buffer; } } } else if (result.kind === "retif") { // https://github.com/glayzzle/php-parser/issues/77 if (result.falseExpr && result.falseExpr.kind === "retif" && !result.falseExpr.parenthesizedExpression) { buffer = result.falseExpr; result.falseExpr = buffer.test; this.swapLocations(result, result.test, result.falseExpr, parser); buffer.test = this.resolvePrecedence(result, parser); this.swapLocations(buffer, buffer.test, buffer.falseExpr, parser); result = buffer; } } else if (result.kind === "assign") { // https://github.com/glayzzle/php-parser/issues/81 if (result.right && result.right.kind === "bin" && !result.right.parenthesizedExpression) { lLevel = AST.precedence["="]; rLevel = AST.precedence[result.right.type]; // only shifts with and, xor, or if (lLevel && rLevel && rLevel < lLevel) { buffer = result.right; result.right = result.right.left; buffer.left = result; this.swapLocations(buffer, buffer.left, result.right, parser); result = buffer; } } } else if (result.kind === "expressionstatement") { this.swapLocations(result, result.expression, result, parser); } return result; }; /** * Prepares an AST node * @private * @function AST#prepare * @memberOf module:php-parser * @param {String|null} kind - Defines the node type * @param {*} docs - (if null, the kind must be passed at the function call) * @param {Parser} parser - The parser instance (use for extracting locations) * @return {Function} */ AST.prototype.prepare = function (kind, docs, parser) { var start = null; if (this.withPositions || this.withSource) { start = parser.position(); } var self = this; // returns the node var _result = function result() { var location = null; var args = Array.prototype.slice.call(arguments); args.push(docs); if (self.withPositions || self.withSource) { var src = null; if (self.withSource) { src = parser.lexer._input.substring(start.offset, parser.prev[2]); } // if with source, need location on swapLocations function location = new Location(src, start, new Position(parser.prev[0], parser.prev[1], parser.prev[2])); // last argument is always the location args.push(location); } // handle lazy kind definitions if (!kind) { kind = args.shift(); } // build the object var node = self[kind]; if (typeof node !== "function") { throw new Error('Undefined node "' + kind + '"'); } var astNode = Object.create(node.prototype); node.apply(astNode, args); _result.instance = astNode; /* istanbul ignore next */ if (_result.trailingComments) { // buffer of trailingComments astNode.trailingComments = _result.trailingComments; } if (typeof _result.postBuild === "function") { _result.postBuild(astNode); } if (parser.debug) { delete self.stack[_result.stackUid]; } return self.resolvePrecedence(astNode, parser); }; if (parser.debug) { if (!this.stack) { this.stack = {}; this.stackUid = 1; } this.stack[++this.stackUid] = { position: start, stack: new Error().stack.split("\n").slice(3, 5) }; _result.stackUid = this.stackUid; } /** * Sets a list of trailing comments * @private * @param {*} docs */ _result.setTrailingComments = function (docs) { if (_result.instance) { // already created _result.instance.setTrailingComments(docs); } else { _result.trailingComments = docs; } }; /** * Release a node without using it on the AST * @private * @param {*} target */ _result.destroy = function (target) { if (docs) { // release current docs stack if (target) { if (!target.leadingComments) { target.leadingComments = docs; } else { target.leadingComments = docs.concat(target.leadingComments); } } else { parser._docIndex = parser._docs.length - docs.length; } } if (parser.debug) { delete self.stack[_result.stackUid]; } }; return _result; }; AST.prototype.checkNodes = function () { var errors = []; for (var k in this.stack) { if (Object.prototype.hasOwnProperty.call(this.stack, k)) { this.stack[k].key = k; errors.push(this.stack[k]); } } this.stack = {}; return errors; }; // Define all AST nodes [__webpack_require__(3160), __webpack_require__(1654), __webpack_require__(1240), __webpack_require__(3979), __webpack_require__(5553), __webpack_require__(2207), __webpack_require__(2916), __webpack_require__(4628), __webpack_require__(7509), __webpack_require__(2906), __webpack_require__(5723), __webpack_require__(7561), __webpack_require__(6473), __webpack_require__(9626), __webpack_require__(4782), __webpack_require__(8477), __webpack_require__(5045), __webpack_require__(900), __webpack_require__(4824), __webpack_require__(1020), __webpack_require__(9847), __webpack_require__(2790), __webpack_require__(1333), __webpack_require__(2112), __webpack_require__(9960), __webpack_require__(8533), __webpack_require__(5947), __webpack_require__(7786), __webpack_require__(5436), __webpack_require__(1136), __webpack_require__(380), __webpack_require__(6129), __webpack_require__(9723), __webpack_require__(5125), __webpack_require__(9632), __webpack_require__(4300), __webpack_require__(1515), __webpack_require__(3411), __webpack_require__(9781), __webpack_require__(839), __webpack_require__(8374), __webpack_require__(9754), __webpack_require__(4251), __webpack_require__(6553), __webpack_require__(8630), __webpack_require__(9786), __webpack_require__(9742), __webpack_require__(1234), __webpack_require__(6), __webpack_require__(8861), __webpack_require__(7860), __webpack_require__(9834), __webpack_require__(2724), __webpack_require__(6025), __webpack_require__(2687), __webpack_require__(7633), __webpack_require__(5514), __webpack_require__(7427), __webpack_require__(1122), __webpack_require__(7256), __webpack_require__(7416), __webpack_require__(8140), __webpack_require__(6258), __webpack_require__(9474), __webpack_require__(6827), __webpack_require__(4427), __webpack_require__(4065), __webpack_require__(4297), __webpack_require__(5859), __webpack_require__(6985), __webpack_require__(9302), __webpack_require__(8212), __webpack_require__(864), __webpack_require__(8268), __webpack_require__(7190), __webpack_require__(8519), __webpack_require__(4835), __webpack_require__(2056), __webpack_require__(4838), __webpack_require__(7869), __webpack_require__(1908), __webpack_require__(170), __webpack_require__(1091), __webpack_require__(8276), __webpack_require__(1842), __webpack_require__(5739), __webpack_require__(1274), __webpack_require__(4352), __webpack_require__(9672), __webpack_require__(711), __webpack_require__(1231), __webpack_require__(1865), __webpack_require__(1102), __webpack_require__(7472), __webpack_require__(6133), __webpack_require__(1197), __webpack_require__(6649), __webpack_require__(1837), __webpack_require__(2277), __webpack_require__(8010), __webpack_require__(7579), __webpack_require__(3460), __webpack_require__(2702), __webpack_require__(514), __webpack_require__(5684), __webpack_require__(8019), __webpack_require__(7721), __webpack_require__(4369), __webpack_require__(40), __webpack_require__(4919), __webpack_require__(7676), __webpack_require__(2596), __webpack_require__(6744)].forEach(function (ctor) { AST.prototype[ctor.kind] = ctor; }); module.exports = AST; /***/ }), /***/ 3160: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expr = __webpack_require__(839); var KIND = "array"; /** * Defines an array structure * @constructor Array * @memberOf module:php-parser * @example * // PHP code : * [1, 'foo' => 'bar', 3] * * // AST structure : * { * "kind": "array", * "shortForm": true * "items": [ * {"kind": "number", "value": "1"}, * { * "kind": "entry", * "key": {"kind": "string", "value": "foo", "isDoubleQuote": false}, * "value": {"kind": "string", "value": "bar", "isDoubleQuote": false} * }, * {"kind": "number", "value": "3"} * ] * } * @extends {Expression} * @property {Array<Entry|Expression|Variable>} items List of array items * @property {boolean} shortForm Indicate if the short array syntax is used, ex `[]` instead `array()` */ module.exports = Expr["extends"](KIND, function Array(shortForm, items, docs, location) { Expr.apply(this, [KIND, docs, location]); this.items = items; this.shortForm = shortForm; }); /***/ }), /***/ 1654: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "arrowfunc"; /** * Defines an arrow function (it's like a closure) * @constructor ArrowFunc * @memberOf module:php-parser * @extends {Expression} * @property {Parameter[]} arguments * @property {Identifier} type * @property {Expression} body * @property {boolean} byref * @property {boolean} nullable * @property {boolean} isStatic */ module.exports = Expression["extends"](KIND, function Closure(args, byref, body, type, nullable, isStatic, docs, location) { Expression.apply(this, [KIND, docs, location]); this.arguments = args; this.byref = byref; this.body = body; this.type = type; this.nullable = nullable; this.isStatic = isStatic || false; }); /***/ }), /***/ 1240: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "assign"; /** * Assigns a value to the specified target * @constructor Assign * @memberOf module:php-parser * @extends {Expression} * @property {Expression} left * @property {Expression} right * @property {String} operator */ module.exports = Expression["extends"](KIND, function Assign(left, right, operator, docs, location) { Expression.apply(this, [KIND, docs, location]); this.left = left; this.right = right; this.operator = operator; }); /***/ }), /***/ 3979: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "assignref"; /** * Assigns a value to the specified target * @constructor AssignRef * @memberOf module:php-parser * @extends {Expression} * @property {Expression} left * @property {Expression} right * @property {String} operator */ module.exports = Expression["extends"](KIND, function AssignRef(left, right, docs, location) { Expression.apply(this, [KIND, docs, location]); this.left = left; this.right = right; }); /***/ }), /***/ 2207: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Node = __webpack_require__(4065); var KIND = "attrgroup"; /** * Attribute group * @memberOf module:php-parser * @constructor AttrGroup * @extends {Node} * @property {Attribute[]} attrs */ module.exports = Node["extends"](KIND, function AttrGroup(attrs, docs, location) { Node.apply(this, [KIND, docs, location]); this.attrs = attrs || []; }); /***/ }), /***/ 5553: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Node = __webpack_require__(4065); var KIND = "attribute"; /** * Attribute Value * @memberOf module:php-parser * @constructor Attribute * @extends {Node} * @property {String} name * @property {Parameter[]} args */ module.exports = Node["extends"](KIND, function Attribute(name, args, docs, location) { Node.apply(this, [KIND, docs, location]); this.name = name; this.args = args; }); /***/ }), /***/ 2916: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Operation = __webpack_require__(8268); var KIND = "bin"; /** * Binary operations * @constructor Bin * @memberOf module:php-parser * @extends {Operation} * @property {String} type * @property {Expression} left * @property {Expression} right */ module.exports = Operation["extends"](KIND, function Bin(type, left, right, docs, location) { Operation.apply(this, [KIND, docs, location]); this.type = type; this.left = left; this.right = right; }); /***/ }), /***/ 4628: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "block"; /** * A block statement, i.e., a sequence of statements surrounded by braces. * @constructor Block * @memberOf module:php-parser * @extends {Statement} * @property {Node[]} children */ module.exports = Statement["extends"](KIND, function Block(kind, children, docs, location) { Statement.apply(this, [kind || KIND, docs, location]); this.children = children.filter(Boolean); }); /***/ }), /***/ 7509: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Literal = __webpack_require__(5514); var KIND = "boolean"; /** * Defines a boolean value (true/false) * @constructor Boolean * @memberOf module:php-parser * @extends {Literal} * @property {boolean} value */ module.exports = Literal["extends"](KIND, function Boolean(value, raw, docs, location) { Literal.apply(this, [KIND, value, raw, docs, location]); }); /***/ }), /***/ 2906: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "break"; /** * A break statement * @constructor Break * @memberOf module:php-parser * @extends {Statement} * @property {Number|Null} level */ module.exports = Statement["extends"](KIND, function Break(level, docs, location) { Statement.apply(this, [KIND, docs, location]); this.level = level; }); /***/ }), /***/ 5723: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "byref"; /** * Passing by Reference - so the function can modify the variable * @constructor ByRef * @memberOf module:php-parser * @extends {Expression} * @property {ExpressionStatement} what */ module.exports = Expression["extends"](KIND, function ByRef(what, docs, location) { Expression.apply(this, [KIND, docs, location]); this.what = what; }); /***/ }), /***/ 7561: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "call"; /** * Executes a call statement * @constructor Call * @memberOf module:php-parser * @extends {Expression} * @property {Identifier|Variable} what * @property {Expression[]} arguments */ module.exports = Expression["extends"](KIND, function Call(what, args, docs, location) { Expression.apply(this, [KIND, docs, location]); this.what = what; this.arguments = args; }); /***/ }), /***/ 6473: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "case"; /** * A switch case statement * @constructor Case * @memberOf module:php-parser * @extends {Statement} * @property {Expression|null} test - if null, means that the default case * @property {Block|null} body */ module.exports = Statement["extends"](KIND, function Case(test, body, docs, location) { Statement.apply(this, [KIND, docs, location]); this.test = test; this.body = body; }); /***/ }), /***/ 9626: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Operation = __webpack_require__(8268); var KIND = "cast"; /** * Binary operations * @constructor Cast * @memberOf module:php-parser * @extends {Operation} * @property {String} type * @property {String} raw * @property {Expression} expr */ module.exports = Operation["extends"](KIND, function Cast(type, raw, expr, docs, location) { Operation.apply(this, [KIND, docs, location]); this.type = type; this.raw = raw; this.expr = expr; }); /***/ }), /***/ 4782: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "catch"; /** * Defines a catch statement * @constructor Catch * @memberOf module:php-parser * @extends {Statement} * @property {Name[]} what * @property {Variable} variable * @property {Block} body * @see http://php.net/manual/en/language.exceptions.php */ module.exports = Statement["extends"](KIND, function Catch(body, what, variable, docs, location) { Statement.apply(this, [KIND, docs, location]); this.body = body; this.what = what; this.variable = variable; }); /***/ }), /***/ 8477: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Declaration = __webpack_require__(8533); var KIND = "class"; /** * A class definition * @constructor Class * @memberOf module:php-parser * @extends {Declaration} * @property {Identifier|null} extends * @property {Identifier[]|null} implements * @property {Declaration[]} body * @property {boolean} isAnonymous * @property {boolean} isAbstract * @property {boolean} isFinal * @property {boolean} isReadonly * @property {AttrGroup[]} attrGroups */ module.exports = Declaration["extends"](KIND, function Class(name, ext, impl, body, flags, docs, location) { Declaration.apply(this, [KIND, name, docs, location]); this.isAnonymous = name ? false : true; this["extends"] = ext; this["implements"] = impl; this.body = body; this.attrGroups = []; this.parseFlags(flags); }); /***/ }), /***/ 5045: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var ConstantStatement = __webpack_require__(2112); var KIND = "classconstant"; var IS_UNDEFINED = ""; var IS_PUBLIC = "public"; var IS_PROTECTED = "protected"; var IS_PRIVATE = "private"; /** * Defines a class/interface/trait constant * @constructor ClassConstant * @memberOf module:php-parser * @extends {ConstantStatement} * @property {string} visibility * @property {boolean} final * @property {boolean} nullable * @property {TypeReference|IntersectionType|UnionType|null} type * @property {AttrGroup[]} attrGroups */ var ClassConstant = ConstantStatement["extends"](KIND, function ClassConstant(kind, constants, flags, nullable, type, attrGroups, docs, location) { ConstantStatement.apply(this, [kind || KIND, constants, docs, location]); this.parseFlags(flags); this.nullable = nullable; this.type = type; this.attrGroups = attrGroups; }); /** * Generic flags parser * @function * @name ClassConstant#parseFlags * @memberOf module:php-parser * @param {Array<number|null>} flags * @return {void} */ ClassConstant.prototype.parseFlags = function (flags) { if (flags[0] === -1) { this.visibility = IS_UNDEFINED; } else if (flags[0] === null) { /* istanbul ignore next */ this.visibility = null; } else if (flags[0] === 0) { this.visibility = IS_PUBLIC; } else if (flags[0] === 1) { this.visibility = IS_PROTECTED; } else if (flags[0] === 2) { this.visibility = IS_PRIVATE; } this["final"] = flags[2] === 2; }; module.exports = ClassConstant; /***/ }), /***/ 900: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "clone"; /** * Defines a clone call * @constructor Clone * @memberOf module:php-parser * @extends {Expression} * @property {Expression} what */ module.exports = Expression["extends"](KIND, function Clone(what, docs, location) { Expression.apply(this, [KIND, docs, location]); this.what = what; }); /***/ }), /***/ 4824: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "closure"; /** * Defines a closure * @constructor Closure * @memberOf module:php-parser * @extends {Expression} * @property {Parameter[]} arguments * @property {Variable[]} uses * @property {Identifier} type * @property {Boolean} byref * @property {boolean} nullable * @property {Block|null} body * @property {boolean} isStatic * @property {AttrGroup[]} attrGroups */ module.exports = Expression["extends"](KIND, function Closure(args, byref, uses, type, nullable, isStatic, docs, location) { Expression.apply(this, [KIND, docs, location]); this.uses = uses; this.arguments = args; this.byref = byref; this.type = type; this.nullable = nullable; this.isStatic = isStatic || false; this.body = null; this.attrGroups = []; }); /***/ }), /***/ 1020: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Node = __webpack_require__(4065); /** * Abstract documentation node (ComentLine or CommentBlock) * @constructor Comment * @memberOf module:php-parser * @extends {Node} * @property {String} value */ module.exports = Node["extends"]("comment", function Comment(kind, value, docs, location) { Node.apply(this, [kind, docs, location]); this.value = value; }); /***/ }), /***/ 9847: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Comment = __webpack_require__(1020); var KIND = "commentblock"; /** * A comment block (multiline) * @constructor CommentBlock * @memberOf module:php-parser * @extends {Comment} */ module.exports = Comment["extends"](KIND, function CommentBlock(value, docs, location) { Comment.apply(this, [KIND, value, docs, location]); }); /***/ }), /***/ 2790: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Comment = __webpack_require__(1020); var KIND = "commentline"; /** * A single line comment * @constructor CommentLine * @memberOf module:php-parser * @extends {Comment} */ module.exports = Comment["extends"](KIND, function CommentLine(value, docs, location) { Comment.apply(this, [KIND, value, docs, location]); }); /***/ }), /***/ 1333: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Node = __webpack_require__(4065); var KIND = "constant"; /** * Defines a constant * @constructor Constant * @memberOf module:php-parser * @extends {Node} * @property {string} name * @property {Node|string|number|boolean|null} value */ module.exports = Node["extends"](KIND, function Constant(name, value, docs, location) { Node.apply(this, [KIND, docs, location]); this.name = name; this.value = value; }); /***/ }), /***/ 2112: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "constantstatement"; /** * Declares a constants into the current scope * @constructor ConstantStatement * @memberOf module:php-parser * @extends {Statement} * @property {Constant[]} constants */ module.exports = Statement["extends"](KIND, function ConstantStatement(kind, constants, docs, location) { Statement.apply(this, [kind || KIND, docs, location]); this.constants = constants; }); /***/ }), /***/ 9960: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "continue"; /** * A continue statement * @constructor Continue * @memberOf module:php-parser * @extends {Statement} * @property {number|null} level */ module.exports = Statement["extends"](KIND, function Continue(level, docs, location) { Statement.apply(this, [KIND, docs, location]); this.level = level; }); /***/ }), /***/ 8533: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "declaration"; var IS_UNDEFINED = ""; var IS_PUBLIC = "public"; var IS_PROTECTED = "protected"; var IS_PRIVATE = "private"; /** * A declaration statement (function, class, interface...) * @constructor Declaration * @memberOf module:php-parser * @extends {Statement} * @property {Identifier|string} name */ var Declaration = Statement["extends"](KIND, function Declaration(kind, name, docs, location) { Statement.apply(this, [kind || KIND, docs, location]); this.name = name; }); /** * Generic flags parser * @function * @name Declaration#parseFlags * @memberOf module:php-parser * @param {Array<number|null>} flags * @return {void} */ Declaration.prototype.parseFlags = function (flags) { this.isAbstract = flags[2] === 1; this.isFinal = flags[2] === 2; this.isReadonly = flags[3] === 1; if (this.kind !== "class") { if (flags[0] === -1) { this.visibility = IS_UNDEFINED; } else if (flags[0] === null) { /* istanbul ignore next */ this.visibility = null; } else if (flags[0] === 0) { this.visibility = IS_PUBLIC; } else if (flags[0] === 1) { this.visibility = IS_PROTECTED; } else if (flags[0] === 2) { this.visibility = IS_PRIVATE; } this.isStatic = flags[1] === 1; } }; module.exports = Declaration; /***/ }), /***/ 5947: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Block = __webpack_require__(4628); var KIND = "declare"; /** * The declare construct is used to set execution directives for a block of code * @constructor Declare * @memberOf module:php-parser * @extends {Block} * @property {DeclareDirective[]} directives * @property {string} mode * @see http://php.net/manual/en/control-structures.declare.php */ var Declare = Block["extends"](KIND, function Declare(directives, body, mode, docs, location) { Block.apply(this, [KIND, body, docs, location]); this.directives = directives; this.mode = mode; }); /** * The node is declared as a short tag syntax : * ```php * <?php * declare(ticks=1): * // some statements * enddeclare; * ``` * @constant {String} Declare#MODE_SHORT * @memberOf module:php-parser */ Declare.MODE_SHORT = "short"; /** * The node is declared bracket enclosed code : * ```php * <?php * declare(ticks=1) { * // some statements * } * ``` * @constant {String} Declare#MODE_BLOCK * @memberOf module:php-parser */ Declare.MODE_BLOCK = "block"; /** * The node is declared as a simple statement. In order to make things simpler * children of the node are automatically collected until the next * declare statement. * ```php * <?php * declare(ticks=1); * // some statements * declare(ticks=2); * // some statements * ``` * @constant {String} Declare#MODE_NONE * @memberOf module:php-parser */ Declare.MODE_NONE = "none"; module.exports = Declare; /***/ }), /***/ 7786: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Node = __webpack_require__(4065); var KIND = "declaredirective"; /** * Defines a constant * @constructor DeclareDirective * @memberOf module:php-parser * @extends {Node} * @property {Identifier} key * @property {Node|string|number|boolean|null} value */ module.exports = Node["extends"](KIND, function DeclareDirective(key, value, docs, location) { Node.apply(this, [KIND, docs, location]); this.key = key; this.value = value; }); /***/ }), /***/ 5436: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "do"; /** * Defines a do/while statement * @constructor Do * @memberOf module:php-parser * @extends {Statement} * @property {Expression} test * @property {Block | null} body */ module.exports = Statement["extends"](KIND, function Do(test, body, docs, location) { Statement.apply(this, [KIND, docs, location]); this.test = test; this.body = body; }); /***/ }), /***/ 1136: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Statement = __webpack_require__(9672); var KIND = "echo"; /** * Defines system based call * @constructor Echo * @memberOf module:php-parser * @property {boolean} shortForm * @property {Expression[]} expressions * @extends {Statement} */ module.exports = Statement["extends"](KIND, function Echo(expressions, shortForm, docs, location) { Statement.apply(this, [KIND, docs, location]); this.shortForm = shortForm; this.expressions = expressions; }); /***/ }), /***/ 380: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "empty"; /** * Defines an empty check call * @constructor Empty * @memberOf module:php-parser * @extends {Expression} */ module.exports = Expression["extends"](KIND, function Empty(expression, docs, location) { Expression.apply(this, [KIND, docs, location]); this.expression = expression; }); /***/ }), /***/ 6129: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Literal = __webpack_require__(5514); var KIND = "encapsed"; /** * Defines an encapsed string (contains expressions) * @constructor Encapsed * @memberOf module:php-parser * @extends {Literal} * @property {String} type - Defines the type of encapsed string (shell, heredoc, string) * @property {String|Null} label - The heredoc label, defined only when the type is heredoc * @property {EncapsedPart[]} value */ var Encapsed = Literal["extends"](KIND, function Encapsed(value, raw, type, docs, location) { Literal.apply(this, [KIND, value, raw, docs, location]); this.type = type; }); /** * The node is a double quote string : * ```php * <?php * echo "hello $world"; * ``` * @constant {String} Encapsed#TYPE_STRING - `string` * @memberOf module:php-parser */ Encapsed.TYPE_STRING = "string"; /** * The node is a shell execute string : * ```php * <?php * echo `ls -larth $path`; * ``` * @constant {String} Encapsed#TYPE_SHELL - `shell` * @memberOf module:php-parser */ Encapsed.TYPE_SHELL = "shell"; /** * The node is a shell execute string : * ```php * <?php * echo <<<STR * Hello $world * STR * ; * ``` * @constant {String} Encapsed#TYPE_HEREDOC - `heredoc` * @memberOf module:php-parser */ Encapsed.TYPE_HEREDOC = "heredoc"; /** * The node contains a list of constref / variables / expr : * ```php * <?php * echo $foo->bar_$baz; * ``` * @constant {String} Encapsed#TYPE_OFFSET - `offset` * @memberOf module:php-parser */ Encapsed.TYPE_OFFSET = "offset"; module.exports = Encapsed; /***/ }), /***/ 9723: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "encapsedpart"; /** * Part of `Encapsed` node * @constructor EncapsedPart * @memberOf module:php-parser * @extends {Expression} * @property {Expression} expression * @property {String} syntax * @property {Boolean} curly */ module.exports = Expression["extends"](KIND, function EncapsedPart(expression, syntax, curly, docs, location) { Expression.apply(this, [KIND, docs, location]); this.expression = expression; this.syntax = syntax; this.curly = curly; }); /***/ }), /***/ 5125: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "entry"; /** * An array entry - see [Array](#array) * @memberOf module:php-parser * @constructor Entry * @extends {Expression} * @property {Node|null} key The entry key/offset * @property {Node} value The entry value * @property {Boolean} byRef By reference * @property {Boolean} unpack Argument unpacking */ module.exports = Expression["extends"](KIND, function Entry(key, value, byRef, unpack, docs, location) { Expression.apply(this, [KIND, docs, location]); this.key = key; this.value = value; this.byRef = byRef; this.unpack = unpack; }); /***/ }), /***/ 9632: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Declaration = __webpack_require__(8533); var KIND = "enum"; /** * A enum definition * @constructor Enum * @memberOf module:php-parser * @extends {Declaration} * @property {Identifier|null} valueType * @property {Identifier[]} implements * @property {Declaration[]} body * @property {AttrGroup[]} attrGroups */ module.exports = Declaration["extends"](KIND, function Enum(name, valueType, impl, body, docs, location) { Declaration.apply(this, [KIND, name, docs, location]); this.valueType = valueType; this["implements"] = impl; this.body = body; this.attrGroups = []; }); /***/ }), /***/ 4300: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Node = __webpack_require__(4065); var KIND = "enumcase"; /** * Declares a cases into the current scope * @constructor EnumCase * @memberOf module:php-parser * @extends {Node} * @property {string} name * @property {string|number|null} value */ module.exports = Node["extends"](KIND, function EnumCase(name, value, docs, location) { Node.apply(this, [KIND, docs, location]); this.name = name; this.value = value; }); /***/ }), /***/ 1515: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Node = __webpack_require__(4065); var KIND = "error"; /** * Defines an error node (used only on silentMode) * @constructor Error * @memberOf module:php-parser * @extends {Node} * @property {string} message * @property {number} line * @property {number|string} token * @property {string|array} expected */ module.exports = Node["extends"](KIND, function Error(message, token, line, expected, docs, location) { Node.apply(this, [KIND, docs, location]); this.message = message; this.token = token; this.line = line; this.expected = expected; }); /***/ }), /***/ 3411: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "eval"; /** * Defines an eval statement * @constructor Eval * @memberOf module:php-parser * @extends {Expression} * @property {Node} source */ module.exports = Expression["extends"](KIND, function Eval(source, docs, location) { Expression.apply(this, [KIND, docs, location]); this.source = source; }); /***/ }), /***/ 9781: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ var Expression = __webpack_require__(839); var KIND = "exit"; /** * Defines an exit / die call * @constructor Exit * @memberOf module:php-parser * @extends {Expression} * @property {Node|null} expression * @property {boolean} useDie */ module.exports = Expression["extends"](KIND, function Exit(expression, useDie, doc