Skip to content

Commit a99ae87

Browse files
committed
release 2.0.6
1 parent 978126b commit a99ae87

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

RELEASE.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Releases
22

3-
## 2.0.5 : (2017-07-16)
3+
## 2.0.6 : (2017-07-16)
44

55
- Fix precedence between bin, retif, unary
6+
- Fix precedence with assign
67

78
## 2.0.4 : (2017-07-09)
89

dist/php-parser.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ var binOperatorsPrecedence = [
316316
['or'],
317317
['xor'],
318318
['and'],
319-
// TODO: assignment / not sure that PHP allows this with expressions
319+
['='],
320320
['?'],
321321
['??'],
322322
['||'],
@@ -395,6 +395,19 @@ AST.prototype.resolvePrecedence = function(result) {
395395
buffer.test = this.resolvePrecedence(result);
396396
result = buffer;
397397
}
398+
} else if (result.kind === 'assign') {
399+
// https://github.com/glayzzle/php-parser/issues/81
400+
if (result.right && result.right.kind === 'bin') {
401+
var lLevel = AST.precedence['='];
402+
var rLevel = AST.precedence[result.right.type];
403+
// only shifts with and, xor, or
404+
if (lLevel && rLevel && rLevel < lLevel) {
405+
buffer = result.right;
406+
result.right = result.right.left;
407+
buffer.left = result;
408+
result = buffer;
409+
}
410+
}
398411
}
399412
return result;
400413
};

dist/php-parser.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/php-parser.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "php-parser",
3-
"version": "2.0.5",
3+
"version": "2.0.6",
44
"description": "Parse PHP code and returns its AST",
55
"main": "src/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)