示例#1
0
 /**
  * @param Assign $node
  * @param Expr   $leftNode
  * @param Expr   $rightNode
  * @param string $operatorString
  */
 private function arrayDimFetchCase($node, $leftNode, $rightNode, $operatorString, $precedence, $associativity)
 {
     $this->logger->trace(self::getType() . ' ' . __LINE__, $node, $this->dispatcher->getMetadata()->getFullQualifiedNameClass());
     $head = '';
     if ($leftNode instanceof ArrayDimFetch) {
         if (false === ($splitedArray = $this->arrayManipulator->arrayNeedToBeSplit($leftNode))) {
             $leftString = $this->dispatcher->pPrec($leftNode, $precedence, $associativity, 1);
         } else {
             $result = $this->dispatcher->pExpr_ArrayDimFetch($leftNode, true);
             $head .= $result['head'];
             $leftString = $result['lastExpr'];
         }
     } else {
         $leftString = $this->dispatcher->pPrec($leftNode, $precedence, $associativity, -1);
     }
     if ($rightNode instanceof ArrayDimFetch) {
         if (false === ($splitedArray = $this->arrayManipulator->arrayNeedToBeSplit($rightNode))) {
             $rightString = $this->dispatcher->pPrec($rightNode, $precedence, $associativity, 1);
         } else {
             $result = $this->dispatcher->pExpr_ArrayDimFetch($rightNode, true);
             $head .= $result['head'];
             $rightString = $result['lastExpr'];
         }
     } elseif ($this->isSomething($rightNode)) {
         $this->logger->trace(self::getType() . ' ' . __LINE__, $node, $this->dispatcher->getMetadata()->getFullQualifiedNameClass());
         // @TODO add test case for each
         $rightString = $this->dispatcher->pPrec($rightNode, $precedence, $associativity, 1);
     } else {
         $head .= $this->dispatcher->pPrec($rightNode, $precedence, $associativity, 1) . ";\n";
         $rightString = $this->dispatcher->p($rightNode->var);
     }
     return $head . 'let ' . $leftString . $operatorString . $rightString;
 }