Skip to content

Commit cf6dcf8

Browse files
committed
release 3.0.0-alpha.3
1 parent 0943af7 commit cf6dcf8

File tree

2 files changed

+43
-46
lines changed

2 files changed

+43
-46
lines changed

dist/php-parser.js

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* Package: php-parser
44
* Parse PHP code and returns its AST
5-
* Build: 638e56ff062f9db65357 - 2018-7-29
5+
* Build: 65fd01ae827233e0f643 - 2018-8-15
66
* License: BSD-3-Clause
77
* Author: Ioan CHIRIAC
88
*
@@ -4702,7 +4702,9 @@ module.exports = {
47024702
}
47034703

47044704
// ARRAYS
4705-
case this.tok.T_ARRAY: // array parser
4705+
case this.tok.T_ARRAY:
4706+
// array parser
4707+
return this.read_array();
47064708
case "[":
47074709
// short array format
47084710
return this.read_array();
@@ -5701,68 +5703,48 @@ module.exports = {
57015703
return this.next().read_encapsed_string("`");
57025704
}
57035705

5704-
if (this.token === this.tok.T_LIST || this.token === "[") {
5706+
if (this.token === this.tok.T_LIST) {
57055707
var assign = null;
5706-
var isShort = this.token === "[";
57075708
var isInner = this.innerList;
57085709
result = this.node("list");
57095710
if (!isInner) {
5710-
this.innerListForm = isShort;
57115711
assign = this.node("assign");
5712-
} else if (this.innerListForm !== isShort) {
5713-
// Both due to implementation issues,
5714-
// and for consistency's sake, list()
5715-
// cannot be nested inside [], nor vice-versa
5716-
this.expect(isShort ? "list" : "[");
57175712
}
5718-
this.next();
5719-
if (!isShort && this.expect("(")) {
5713+
if (this.next().expect("(")) {
57205714
this.next();
57215715
}
57225716

57235717
if (!this.innerList) this.innerList = true;
57245718

57255719
// reads inner items
5726-
var assignList = this.read_array_pair_list(isShort);
5727-
if (this.expect(isShort ? "]" : ")")) {
5720+
var assignList = this.read_array_pair_list(false);
5721+
if (this.expect(")")) {
57285722
this.next();
57295723
}
57305724

57315725
// check if contains at least one assignment statement
5732-
if (!isShort) {
5733-
var hasItem = false;
5734-
for (var i = 0; i < assignList.length; i++) {
5735-
if (assignList[i] !== null) {
5736-
hasItem = true;
5737-
break;
5738-
}
5739-
}
5740-
if (!hasItem) {
5741-
this.raiseError("Fatal Error : Cannot use empty list on line " + this.lexer.yylloc.first_line);
5726+
var hasItem = false;
5727+
for (var i = 0; i < assignList.length; i++) {
5728+
if (assignList[i] !== null) {
5729+
hasItem = true;
5730+
break;
57425731
}
57435732
}
5733+
if (!hasItem) {
5734+
this.raiseError("Fatal Error : Cannot use empty list on line " + this.lexer.yylloc.first_line);
5735+
}
57445736

57455737
// handles the node resolution
57465738
if (!isInner) {
57475739
this.innerList = false;
5748-
if (isShort) {
5749-
if (this.token === "=") {
5750-
return assign(result(assignList, isShort), this.next().read_expr(), "=");
5751-
} else {
5752-
// handles as an array declaration
5753-
result.setKind("array");
5754-
return this.handleDereferencable(result(isShort, assignList));
5755-
}
5740+
if (this.expect("=")) {
5741+
return assign(result(assignList, false), this.next().read_expr(), "=");
57565742
} else {
5757-
if (this.expect("=")) {
5758-
return assign(result(assignList, isShort), this.next().read_expr(), "=");
5759-
} else {
5760-
// error fallback : list($a, $b);
5761-
return result(assignList, isShort);
5762-
}
5743+
// error fallback : list($a, $b);
5744+
return result(assignList, false);
57635745
}
57645746
} else {
5765-
return result(assignList, isShort);
5747+
return result(assignList, false);
57665748
}
57675749
}
57685750

@@ -5994,7 +5976,16 @@ module.exports = {
59945976
return result("post", "-", expr);
59955977
}
59965978
} else if (this.is("SCALAR")) {
5979+
result = this.node();
59975980
expr = this.read_scalar();
5981+
if (expr.kind === "array" && expr.shortForm && this.token === "=") {
5982+
// list assign
5983+
var list = this.node("list")(expr.items, true);
5984+
if (expr.loc) list.loc = expr.loc;
5985+
var _right = this.next().read_expr();
5986+
return result("assign", list, _right, "=");
5987+
}
5988+
// classic array
59985989
return this.handleDereferencable(expr);
59995990
} else {
60005991
this.error("EXPR");
@@ -6603,11 +6594,13 @@ module.exports = {
66036594
items = this.read_array_pair_list(shortForm);
66046595
}
66056596
// check non empty entries
6606-
items.forEach(function (item) {
6607-
if (item === null) {
6608-
this.raiseError("Cannot use empty array elements in arrays");
6597+
/*for(let i = 0, size = items.length - 1; i < size; i++) {
6598+
if (items[i] === null) {
6599+
this.raiseError(
6600+
"Cannot use empty array elements in arrays"
6601+
);
66096602
}
6610-
}.bind(this));
6603+
}*/
66116604
this.expect(expect);
66126605
this.next();
66136606
return result(shortForm, items);
@@ -6918,7 +6911,11 @@ parser.prototype.text = function () {
69186911
/** consume the next token **/
69196912
parser.prototype.next = function () {
69206913
// prepare the back command
6921-
this.prev = [this.lexer.yylloc.last_line, this.lexer.yylloc.last_column, this.lexer.offset];
6914+
if (this.token !== ";" || this.lexer.yytext === ";") {
6915+
// ignore '?>' from automated resolution
6916+
// https://github.com/glayzzle/php-parser/issues/168
6917+
this.prev = [this.lexer.yylloc.last_line, this.lexer.yylloc.last_column, this.lexer.offset];
6918+
}
69226919

69236920
// eating the token
69246921
this.lex();

dist/php-parser.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)