UNPKG

laravelphp

Version:

laravel2js and js2laravel converter laravel php resource utils

1,694 lines (1,476 loc) 338 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.laravelphp = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; Object.defineProperty(exports, "js2laravel", { enumerable: true, get: function get() { return _js2laravel.default; } }); Object.defineProperty(exports, "laravel2js", { enumerable: true, get: function get() { return _laravel2js.default; } }); var _laravel2js = _interopRequireDefault(require("./laravel2js.js")); var _js2laravel = _interopRequireDefault(require("./js2laravel.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _default = exports.default = { laravel2js: _laravel2js.default, js2laravel: _js2laravel.default }; },{"./js2laravel.js":2,"./laravel2js.js":3}],2:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = js2laravel; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var js2laravelClb = function js2laravelClb(resources, cb) { var result = "<?php\n return ["; var end = ' ];'; (function stringifyJs(obj, level) { if (obj) { var keys = Object.keys(obj); keys.forEach(function (key, index) { var value = obj[key] || ''; if (typeof value === 'string') { value = value.replace(/'/g, '\\\''); result += "\n ".concat(' '.repeat(level), "'").concat(key, "' => '").concat(value, "'"); } if (_typeof(value) === 'object') { result += "\n ".concat(' '.repeat(level), "'").concat(key, "' => ["); stringifyJs(value, level + 1); result += "\n ".concat(' '.repeat(level), "]"); } if (index + 1 < keys.length) { result += ','; } }); } })(resources, 1); result += "\n".concat(end); if (cb) return cb(null, result); return result; }; function js2laravel(resources, cb) { if (!cb) { return new Promise(function (resolve, reject) { return js2laravelClb(resources, function (err, ret) { return err ? reject(err) : resolve(ret); }); }); } return js2laravelClb(resources, cb); } module.exports = exports.default; },{}],3:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = laravel2js; var _phpParser = _interopRequireDefault(require("php-parser")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var laravel2jsClb = function laravel2jsClb(str, cb) { if (typeof str !== 'string') { var err = new Error('The first parameter was not a string'); if (!cb) throw err; return cb(err); } var parser = new _phpParser.default({ parser: { extractDoc: false, php7: true }, ast: { withPositions: false } }); try { var result = {}; var ast = parser.parseCode(str); if (ast && ast.children && ast.children.length > 0) { var returnElem = ast.children.find(function (ele) { return ele.kind === 'return'; }); if (returnElem && returnElem.expr && returnElem.expr.kind === 'array' && returnElem.expr.items) { ; (function parseArr(items, parent) { items.forEach(function (item) { if (item && item.kind === 'entry' && item.key && item.key.kind === 'string' && item.key.value && item.value) { if (item.value.kind === 'string') { parent[item.key.value] = item.value.value || ''; } if (item.value.kind === 'array' && item.value.items) { parent[item.key.value] = {}; parseArr(item.value.items, parent[item.key.value]); } } }); })(returnElem.expr.items, result); } } if (cb) return cb(null, result); return result; } catch (e) { if (cb) return cb(e); throw e; } }; function laravel2js(str, cb) { if (!cb) { return new Promise(function (resolve, reject) { return laravel2jsClb(str, function (err, ret) { return err ? reject(err) : resolve(ret); }); }); } return laravel2jsClb(str, cb); } module.exports = exports.default; },{"php-parser":4}],4:[function(require,module,exports){ (function (process){(function (){ /*! * * Package: php-parser * Parse PHP code from JS and returns its AST * Build: 966fc2556208046b400c - 6/7/2023 * 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__ = ({ /***/ 555: /***/ ((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__(1907); var Position = __webpack_require__(7724); /** * ## 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__(1538), __webpack_require__(4253), __webpack_require__(1997), __webpack_require__(1889), __webpack_require__(4923), __webpack_require__(9165), __webpack_require__(4230), __webpack_require__(2325), __webpack_require__(504), __webpack_require__(2271), __webpack_require__(5871), __webpack_require__(1578), __webpack_require__(7521), __webpack_require__(8212), __webpack_require__(1119), __webpack_require__(5178), __webpack_require__(4027), __webpack_require__(5436), __webpack_require__(5411), __webpack_require__(2001), __webpack_require__(6659), __webpack_require__(387), __webpack_require__(408), __webpack_require__(7224), __webpack_require__(6560), __webpack_require__(9036), __webpack_require__(4067), __webpack_require__(2514), __webpack_require__(8014), __webpack_require__(4395), __webpack_require__(4514), __webpack_require__(6129), __webpack_require__(3321), __webpack_require__(3689), __webpack_require__(4199), __webpack_require__(2045), __webpack_require__(4042), __webpack_require__(5886), __webpack_require__(6389), __webpack_require__(1530), __webpack_require__(9317), __webpack_require__(4607), __webpack_require__(358), __webpack_require__(1057), __webpack_require__(7887), __webpack_require__(7752), __webpack_require__(6547), __webpack_require__(6403), __webpack_require__(5851), __webpack_require__(8454), __webpack_require__(7133), __webpack_require__(7298), __webpack_require__(8323), __webpack_require__(9132), __webpack_require__(9522), __webpack_require__(298), __webpack_require__(6602), __webpack_require__(7592), __webpack_require__(679), __webpack_require__(7046), __webpack_require__(7920), __webpack_require__(3110), __webpack_require__(3174), __webpack_require__(8356), __webpack_require__(2633), __webpack_require__(3725), __webpack_require__(2730), __webpack_require__(2450), __webpack_require__(1358), __webpack_require__(8588), __webpack_require__(2895), __webpack_require__(1480), __webpack_require__(368), __webpack_require__(6210), __webpack_require__(9281), __webpack_require__(1771), __webpack_require__(8377), __webpack_require__(5003), __webpack_require__(6340), __webpack_require__(1558), __webpack_require__(3429), __webpack_require__(6966), __webpack_require__(2037), __webpack_require__(1211), __webpack_require__(4847), __webpack_require__(619), __webpack_require__(5182), __webpack_require__(7228), __webpack_require__(2898), __webpack_require__(5037), __webpack_require__(9732), __webpack_require__(8409), __webpack_require__(2941), __webpack_require__(7129), __webpack_require__(2589), __webpack_require__(5228), __webpack_require__(2523), __webpack_require__(8084), __webpack_require__(4398), __webpack_require__(3181), __webpack_require__(8466), __webpack_require__(8062), __webpack_require__(6178), __webpack_require__(7264), __webpack_require__(2379), __webpack_require__(3693), __webpack_require__(7880), __webpack_require__(6520), __webpack_require__(3656), __webpack_require__(7886), __webpack_require__(41), __webpack_require__(288), __webpack_require__(8789)].forEach(function (ctor) { AST.prototype[ctor.kind] = ctor; }); module.exports = AST; /***/ }), /***/ 1538: /***/ ((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__(1530); 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; }); /***/ }), /***/ 4253: /***/ ((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__(1530); 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; }); /***/ }), /***/ 1997: /***/ ((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__(1530); 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; }); /***/ }), /***/ 1889: /***/ ((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__(1530); 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; }); /***/ }), /***/ 9165: /***/ ((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__(2730); 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 || []; }); /***/ }), /***/ 4923: /***/ ((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__(2730); 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; }); /***/ }), /***/ 4230: /***/ ((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__(6210); 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; }); /***/ }), /***/ 2325: /***/ ((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__(2898); 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); }); /***/ }), /***/ 504: /***/ ((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__(6602); 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]); }); /***/ }), /***/ 2271: /***/ ((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__(2898); 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; }); /***/ }), /***/ 5871: /***/ ((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__(1530); 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; }); /***/ }), /***/ 1578: /***/ ((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__(1530); 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; }); /***/ }), /***/ 7521: /***/ ((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__(2898); 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; }); /***/ }), /***/ 8212: /***/ ((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__(6210); 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; }); /***/ }), /***/ 1119: /***/ ((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__(2898); 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; }); /***/ }), /***/ 5178: /***/ ((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__(9036); 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); }); /***/ }), /***/ 4027: /***/ ((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__(7224); 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 {bool} final * @property {AttrGroup[]} attrGroups */ var ClassConstant = ConstantStatement["extends"](KIND, function ClassConstant(kind, constants, flags, attrGroups, docs, location) { ConstantStatement.apply(this, [kind || KIND, constants, docs, location]); this.parseFlags(flags); 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; /***/ }), /***/ 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 Expression = __webpack_require__(1530); 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; }); /***/ }), /***/ 5411: /***/ ((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__(1530); 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 = []; }); /***/ }), /***/ 2001: /***/ ((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__(2730); /** * 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; }); /***/ }), /***/ 6659: /***/ ((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__(2001); 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]); }); /***/ }), /***/ 387: /***/ ((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__(2001); 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]); }); /***/ }), /***/ 408: /***/ ((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__(2730); 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; }); /***/ }), /***/ 7224: /***/ ((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__(2898); 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; }); /***/ }), /***/ 6560: /***/ ((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__(2898); 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; }); /***/ }), /***/ 9036: /***/ ((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__(2898); 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; /***/ }), /***/ 4067: /***/ ((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__(2325); 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; /***/ }), /***/ 2514: /***/ ((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__(2730); 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; }); /***/ }), /***/ 8014: /***/ ((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__(2898); 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; }); /***/ }), /***/ 4395: /***/ ((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__(2898); 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; }); /***/ }), /***/ 4514: /***/ ((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__(1530); 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__(6602); 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