2
2
*
3
3
* Package: php-parser
4
4
* Parse PHP code from JS and returns its AST
5
- * Build: 6af20f43d0d6855ac0e0 - 2020-4-24
5
+ * Build: 6828de23c173b08ca739 - 2020-10-4
6
6
* Copyright (C) 2020 Glayzzle (BSD-3-Clause)
7
7
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
8
8
* @url http://glayzzle.com
@@ -3650,7 +3650,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
3650
3650
3651
3651
function _nonIterableRest ( ) { throw new TypeError ( "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ; }
3652
3652
3653
- function _unsupportedIterableToArray ( o , minLen ) { if ( ! o ) return ; if ( typeof o === "string" ) return _arrayLikeToArray ( o , minLen ) ; var n = Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ; if ( n === "Object" && o . constructor ) n = o . constructor . name ; if ( n === "Map" || n === "Set" ) return Array . from ( n ) ; if ( n === "Arguments" || / ^ (?: U i | I ) n t (?: 8 | 1 6 | 3 2 ) (?: C l a m p e d ) ? A r r a y $ / . test ( n ) ) return _arrayLikeToArray ( o , minLen ) ; }
3653
+ function _unsupportedIterableToArray ( o , minLen ) { if ( ! o ) return ; if ( typeof o === "string" ) return _arrayLikeToArray ( o , minLen ) ; var n = Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ; if ( n === "Object" && o . constructor ) n = o . constructor . name ; if ( n === "Map" || n === "Set" ) return Array . from ( o ) ; if ( n === "Arguments" || / ^ (?: U i | I ) n t (?: 8 | 1 6 | 3 2 ) (?: C l a m p e d ) ? A r r a y $ / . test ( n ) ) return _arrayLikeToArray ( o , minLen ) ; }
3654
3654
3655
3655
function _arrayLikeToArray ( arr , len ) { if ( len == null || len > arr . length ) len = arr . length ; for ( var i = 0 , arr2 = new Array ( len ) ; i < len ; i ++ ) { arr2 [ i ] = arr [ i ] ; } return arr2 ; }
3656
3656
@@ -4741,7 +4741,7 @@ module.exports = {
4741
4741
4742
4742
if ( expr . kind === "array" && expr . shortForm && this . token === "=" ) {
4743
4743
// list assign
4744
- var list = this . node ( "list" ) ( expr . items , true ) ;
4744
+ var list = this . convertToList ( expr ) ;
4745
4745
if ( expr . loc ) list . loc = expr . loc ;
4746
4746
var right = this . next ( ) . read_expr ( ) ;
4747
4747
return result ( "assign" , list , right , "=" ) ;
@@ -4761,6 +4761,26 @@ module.exports = {
4761
4761
return expr ;
4762
4762
} ,
4763
4763
4764
+ /**
4765
+ * Recursively convert nested array to nested list.
4766
+ */
4767
+ convertToList : function convertToList ( array ) {
4768
+ var _this = this ;
4769
+
4770
+ var convertedItems = array . items . map ( function ( entry ) {
4771
+ if ( entry . value && entry . value . kind === "array" && entry . value . shortForm ) {
4772
+ entry . value = _this . convertToList ( entry . value ) ;
4773
+ }
4774
+
4775
+ return entry ;
4776
+ } ) ;
4777
+ var node = this . node ( "list" ) ( convertedItems , true ) ;
4778
+ if ( array . loc ) node . loc = array . loc ;
4779
+ if ( array . leadingComments ) node . leadingComments = array . leadingComments ;
4780
+ if ( array . trailingComments ) node . trailingComments = array . trailingComments ;
4781
+ return node ;
4782
+ } ,
4783
+
4764
4784
/**
4765
4785
* Reads assignment
4766
4786
* @param {* } left
@@ -8024,7 +8044,7 @@ AST.prototype.resolvePrecedence = function (result, parser) {
8024
8044
lLevel = AST . precedence [ result . type ] ;
8025
8045
rLevel = AST . precedence [ result . right . type ] ;
8026
8046
8027
- if ( lLevel && rLevel && rLevel <= lLevel && ! this . isRightAssociative ( result . type ) ) {
8047
+ if ( lLevel && rLevel && rLevel <= lLevel && ( result . type !== result . right . type || ! this . isRightAssociative ( result . type ) ) ) {
8028
8048
// https://github.com/glayzzle/php-parser/issues/79
8029
8049
// shift precedence
8030
8050
buffer = result . right ;
0 commit comments