diff --git a/grammar/zend_language_parser.phpy b/grammar/zend_language_parser.phpy index 222e783..fb7b2ba 100644 --- a/grammar/zend_language_parser.phpy +++ b/grammar/zend_language_parser.phpy @@ -206,7 +206,7 @@ catches: catch: T_CATCH '(' name T_VARIABLE ')' '{' inner_statement_list '}' - { $$ = Stmt_Catch[type: $3, var: parseVar($4), stmts: $7]; } + { $$ = Stmt_Catch[$3, parseVar($4), $7]; } ; variables_list: @@ -287,9 +287,9 @@ switch_case_list: case_list: /* empty */ { init(); } | case_list T_CASE expr case_separator inner_statement_list - { push($1, Stmt_Case[cond: $3, stmts: $5]); } + { push($1, Stmt_Case[$5, $3]); } | case_list T_DEFAULT case_separator inner_statement_list - { push($1, Stmt_Case[cond: null, stmts: $4]); } + { push($1, Stmt_Case[$4, null]); } ; case_separator: diff --git a/lib/PHPParser/Node/Expr/LambdaFunc.php b/lib/PHPParser/Node/Expr/LambdaFunc.php index 0952da1..8b9e4ed 100644 --- a/lib/PHPParser/Node/Expr/LambdaFunc.php +++ b/lib/PHPParser/Node/Expr/LambdaFunc.php @@ -1,7 +1,7 @@ $stmts, + 'cond' => $cond, + ), + $line, $docComment + ); + } } \ No newline at end of file diff --git a/lib/PHPParser/Node/Stmt/Catch.php b/lib/PHPParser/Node/Stmt/Catch.php index 47ebf9b..513063f 100644 --- a/lib/PHPParser/Node/Stmt/Catch.php +++ b/lib/PHPParser/Node/Stmt/Catch.php @@ -2,9 +2,28 @@ /** * @property PHPParser_Node_Name $type Class of exception - * @property string $var Variable for exception - * @property array $stmts Statements + * @property string $var Variable for exception + * @property PHPParser_Node[] $stmts Statements */ class PHPParser_Node_Stmt_Catch extends PHPParser_Node_Stmt { + /** + * Constructs a catch node. + * + * @param PHPParser_Node_Name $type Class of exception + * @param string $var Variable for exception + * @param PHPParser_Node[] $stmts Statements + * @param int $line Line + * @param null|string $docComment Nearest doc comment + */ + public function __construct(PHPParser_Node_Name $type, $var, array $stmts, $line = -1, $docComment = null) { + parent::__construct( + array( + 'type' => $type, + 'var' => $var, + 'stmts' => $stmts, + ), + $line, $docComment + ); + } } \ No newline at end of file diff --git a/lib/PHPParser/Parser.php b/lib/PHPParser/Parser.php index c936570..8248711 100644 --- a/lib/PHPParser/Parser.php +++ b/lib/PHPParser/Parser.php @@ -1220,7 +1220,7 @@ class PHPParser_Parser } protected function yyn60($line, $docComment) { - $this->yyval = new PHPParser_Node_Stmt_Catch(array('type' => $this->yyastk[$this->yysp-(8-3)], 'var' => substr($this->yyastk[$this->yysp-(8-4)], 1), 'stmts' => $this->yyastk[$this->yysp-(8-7)]), $line, $docComment); + $this->yyval = new PHPParser_Node_Stmt_Catch($this->yyastk[$this->yysp-(8-3)], substr($this->yyastk[$this->yysp-(8-4)], 1), $this->yyastk[$this->yysp-(8-7)], $line, $docComment); } protected function yyn61($line, $docComment) { @@ -1348,11 +1348,11 @@ class PHPParser_Parser } protected function yyn92($line, $docComment) { - $this->yyastk[$this->yysp-(5-1)][] = new PHPParser_Node_Stmt_Case(array('cond' => $this->yyastk[$this->yysp-(5-3)], 'stmts' => $this->yyastk[$this->yysp-(5-5)]), $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(5-1)]; + $this->yyastk[$this->yysp-(5-1)][] = new PHPParser_Node_Stmt_Case($this->yyastk[$this->yysp-(5-5)], $this->yyastk[$this->yysp-(5-3)], $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(5-1)]; } protected function yyn93($line, $docComment) { - $this->yyastk[$this->yysp-(4-1)][] = new PHPParser_Node_Stmt_Case(array('cond' => null, 'stmts' => $this->yyastk[$this->yysp-(4-4)]), $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(4-1)]; + $this->yyastk[$this->yysp-(4-1)][] = new PHPParser_Node_Stmt_Case($this->yyastk[$this->yysp-(4-4)], null, $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(4-1)]; } protected function yyn94() { diff --git a/lib/PHPParser/PrettyPrinterAbstract.php b/lib/PHPParser/PrettyPrinterAbstract.php index 86fe5a1..8183fe6 100644 --- a/lib/PHPParser/PrettyPrinterAbstract.php +++ b/lib/PHPParser/PrettyPrinterAbstract.php @@ -71,7 +71,7 @@ abstract class PHPParser_PrettyPrinterAbstract /** * Pretty prints an array of nodes (statements). * - * @param array $nodes Array of nodes + * @param PHPParser_Node[] $nodes Array of nodes * * @return string Pretty printed nodes */ @@ -93,8 +93,8 @@ abstract class PHPParser_PrettyPrinterAbstract /** * Pretty prints an array of nodes (statements) and indents them optionally. * - * @param array $nodes Array of nodes - * @param bool $indent Whether to indent the printed nodes + * @param PHPParser_Node[] $nodes Array of nodes + * @param bool $indent Whether to indent the printed nodes * * @return string Pretty printed statements */ @@ -151,8 +151,8 @@ abstract class PHPParser_PrettyPrinterAbstract /** * Pretty prints an array of nodes and implodes the printed values. * - * @param array $nodes Array of Nodes to be printed - * @param string $glue Character to implode with + * @param PHPParser_Node[] $nodes Array of Nodes to be printed + * @param string $glue Character to implode with * * @return string Imploded pretty printed nodes */ @@ -168,7 +168,7 @@ abstract class PHPParser_PrettyPrinterAbstract /** * Pretty prints an array of nodes and implodes the printed values with commas. * - * @param array $nodes Array of Nodes to be printed + * @param PHPParser_Node[] $nodes Array of Nodes to be printed * * @return string Comma separated pretty printed nodes */