Add goto support to pretty printer

This commit is contained in:
nikic 2011-05-31 16:43:46 +02:00
parent 4f3260f670
commit d1f1fb9877
4 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,8 @@
<?php <?php
/**
* @property string $name Name
*/
class Node_Stmt_Goto extends Node_Stmt class Node_Stmt_Goto extends Node_Stmt
{ {
} }

View File

@ -1,5 +1,8 @@
<?php <?php
/**
* @property string $name Name
*/
class Node_Stmt_Label extends Node_Stmt class Node_Stmt_Label extends Node_Stmt
{ {
} }

View File

@ -574,6 +574,14 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
return 'throw' . (null !== $node->expr ? ' ' . $this->p($node->expr) : ''); return 'throw' . (null !== $node->expr ? ' ' . $this->p($node->expr) : '');
} }
public function pStmt_Label(Node_Stmt_Label $node) {
return $node->name . ':';
}
public function pStmt_Goto(Node_Stmt_Goto $node) {
return 'goto ' . $node->name;
}
// Other // Other
public function pStmt_Echo(Node_Stmt_Echo $node) { public function pStmt_Echo(Node_Stmt_Echo $node) {

View File

@ -82,6 +82,7 @@ abstract class PrettyPrinterAbstract
|| $node instanceof Node_Stmt_Switch || $node instanceof Node_Stmt_Switch
|| $node instanceof Node_Stmt_While || $node instanceof Node_Stmt_While
|| $node instanceof Node_Stmt_TryCatch || $node instanceof Node_Stmt_TryCatch
|| $node instanceof Node_Stmt_Label
) { ) {
$return .= "\n"; $return .= "\n";
} else { } else {