Fix Stmt_List pretty printing for nested list()s

This commit is contained in:
nikic 2011-10-16 14:11:23 +02:00
parent 527265cdf7
commit f30320b9b2

View File

@ -138,16 +138,7 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
}
public function pExpr_List(PHPParser_Node_Expr_List $node) {
$pAssignList = array();
foreach ($node->assignList as $element) {
if (null === $element) {
$pAssignList[] = '';
} else {
$pAssignList[] = $this->p($element);
}
}
return 'list(' . implode(', ', $pAssignList) . ') = ' . $this->p($node->expr);
return $this->pAssignList($node->assignList) . ' = ' . $this->p($node->expr);
}
// Binary expressions
@ -661,4 +652,19 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
return $return;
}
public function pAssignList(array $elements) {
$pAssignList = array();
foreach ($elements as $element) {
if (null === $element) {
$pAssignList[] = '';
} elseif (is_array($element)) {
$pAssignList[] = $this->pAssignList($element);
} else {
$pAssignList[] = $this->p($element);
}
}
return 'list(' . implode(', ', $pAssignList) . ')';
}
}