UNPKG

php-parser

Version:

Parse PHP code from JS and returns its AST

45 lines (42 loc) 1.15 kB
/** * Copyright (C) 2018 Glayzzle (BSD3 License) * @authors https://github.com/glayzzle/php-parser/graphs/contributors * @url http://glayzzle.com */ "use strict"; const Expr = require("./expression"); const 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; }, );