mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 15:18:17 +01:00
Move leading space out of pStmt_Else
Same as previous commit. Also add support for pStmt_If->else insertion.
This commit is contained in:
parent
e3888cbe02
commit
bb2ac91115
@ -717,7 +717,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
return 'if (' . $this->p($node->cond) . ') {'
|
||||
. $this->pStmts($node->stmts) . $this->nl . '}'
|
||||
. ($node->elseifs ? ' ' . $this->pImplode($node->elseifs, ' ') : '')
|
||||
. (null !== $node->else ? $this->p($node->else) : '');
|
||||
. (null !== $node->else ? ' ' . $this->p($node->else) : '');
|
||||
}
|
||||
|
||||
protected function pStmt_ElseIf(Stmt\ElseIf_ $node) {
|
||||
@ -726,7 +726,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
protected function pStmt_Else(Stmt\Else_ $node) {
|
||||
return ' else {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
||||
return 'else {' . $this->pStmts($node->stmts) . $this->nl . '}';
|
||||
}
|
||||
|
||||
protected function pStmt_For(Stmt\For_ $node) {
|
||||
|
@ -1052,7 +1052,7 @@ abstract class PrettyPrinterAbstract
|
||||
'Stmt_Continue->num' => [T_CONTINUE, ' ', null],
|
||||
'Stmt_Foreach->keyVar' => [T_AS, null, ' => '],
|
||||
'Stmt_Function->returnType' => [')', ' : ', null],
|
||||
//'Stmt_If->else' => [null, ' ', null], // TODO
|
||||
'Stmt_If->else' => [null, ' ', null],
|
||||
'Stmt_Namespace->name' => [T_NAMESPACE, ' ', null],
|
||||
'Stmt_PropertyProperty->default' => [null, ' = ', null],
|
||||
'Stmt_Return->expr' => [T_RETURN, ' ', null],
|
||||
|
@ -65,6 +65,10 @@ try {
|
||||
} catch (X
|
||||
$y) {
|
||||
}
|
||||
|
||||
if ($cond) { // Foo
|
||||
} elseif ($cond2) { // Bar
|
||||
}
|
||||
-----
|
||||
$stmts[0]->returnType = new Node\Name('Foo');
|
||||
$stmts[0]->params[0]->type = new Node\Identifier('int');
|
||||
@ -85,6 +89,7 @@ $stmts[10]->stmts[1]->props[0]->default = new Scalar\DNumber(42.0);
|
||||
$stmts[11]->keyVar = new Expr\Variable('z');
|
||||
$stmts[12]->vars[0]->default = new Scalar\String_('abc');
|
||||
$stmts[13]->finally = new Stmt\Finally_([]);
|
||||
$stmts[14]->else = new Stmt\Else_([]);
|
||||
-----
|
||||
<?php
|
||||
|
||||
@ -152,6 +157,11 @@ try {
|
||||
$y) {
|
||||
} finally {
|
||||
}
|
||||
|
||||
if ($cond) { // Foo
|
||||
} elseif ($cond2) { // Bar
|
||||
} else {
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user