/** * @param Assign $node * * @return string */ private function convertListStmtToAssign($node) { $type = 'Expr_Assign'; $rightNode = $node->expr; $pList = array(); $listVarName = 'tmpList'; list($precedence, $associativity) = $this->dispatcher->getPrecedenceMap($type); foreach ($node->var->vars as $count => $var) { if (null === $var) { $pList[] = ''; } else { $listVarName .= ucfirst($this->dispatcher->p($var)); } } $listVarName = str_replace(array('[', ']', '"'), '', $listVarName); $pList[] = 'let ' . $listVarName . ' = ' . $this->dispatcher->pPrec($rightNode, $precedence, $associativity, 1) . ''; foreach ($node->var->vars as $count => $var) { if (null === $var) { $pList[] = ''; } else { $pList[] = 'let ' . $this->dispatcher->p($var) . ' = ' . $listVarName . '[' . $count . ']'; } } return implode(";\n", $pList); }
/** * @param Assign $node * * @return string */ private function convertListStmtToAssign($node) { $type = 'Expr_Assign'; $rightNode = $node->expr; $vars = array(); $pList = array(); list($precedence, $associativity) = $this->dispatcher->getPrecedenceMap($type); foreach ($node->var->vars as $count => $var) { if (null === $var) { $pList[] = ''; } else { $vars[] = $this->dispatcher->p($var); $pList[] = 'let ' . $this->dispatcher->p($var) . ' = ' . $this->dispatcher->pPrec($rightNode, $precedence, $associativity, 1) . '[' . $count . '];'; } } return 'var ' . implode(", ", $vars) . ";\n" . implode("\n", $pList); }