diff --git a/src/ast.js b/src/ast.js index 115c274f2..8d5851603 100644 --- a/src/ast.js +++ b/src/ast.js @@ -14,7 +14,7 @@ const Position = require("./ast/position"); * - [Location](#location) * - [Position](#position) * - [Node](#node) - * - [DeclareDirective](#declaredirective) + * - [StaticVariable](#staticvariable) * - [EncapsedPart](#encapsedpart) * - [Constant](#constant) * - [Identifier](#identifier) @@ -472,6 +472,7 @@ AST.prototype.prepare = function(kind, docs, parser) { require("./ast/silent"), require("./ast/statement"), require("./ast/static"), + require("./ast/staticvariable"), require("./ast/staticlookup"), require("./ast/staticreference"), require("./ast/string"), diff --git a/src/ast/static.js b/src/ast/static.js index fe6557ab1..7c456b2a0 100644 --- a/src/ast/static.js +++ b/src/ast/static.js @@ -12,13 +12,13 @@ const KIND = "static"; * Declares a static variable into the current scope * @constructor Static * @extends {Statement} - * @property {Variable[]|Assign[]} items + * @property {StaticVariable[]} variables */ module.exports = Statement.extends(KIND, function Static( - items, + variables, docs, location ) { Statement.apply(this, [KIND, docs, location]); - this.items = items; + this.variables = variables; }); diff --git a/src/ast/staticvariable.js b/src/ast/staticvariable.js new file mode 100644 index 000000000..6fc4b9ace --- /dev/null +++ b/src/ast/staticvariable.js @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018 Glayzzle (BSD3 License) + * @authors https://github.com/glayzzle/php-parser/graphs/contributors + * @url http://glayzzle.com + */ +"use strict"; + +const Node = require("./node"); +const KIND = "staticvariable"; + +/** + * Defines a constant + * @constructor StaticVariable + * @extends {Node} + * @property {Variable} variable + * @property {Node|string|number|boolean|null} defaultValue + */ +module.exports = Node.extends(KIND, function StaticVariable( + variable, + defaultValue, + docs, + location +) { + Node.apply(this, [KIND, docs, location]); + this.variable = variable; + this.defaultValue = defaultValue; +}); diff --git a/src/parser/utils.js b/src/parser/utils.js index 8607a3578..4f4f52229 100644 --- a/src/parser/utils.js +++ b/src/parser/utils.js @@ -89,14 +89,14 @@ module.exports = { * * Sample code : * ```php - *