Rename cast nodes and give them a common Expr_Cast parent (with specialized constructor)

This commit is contained in:
nikic 2011-08-11 09:20:25 +02:00
parent 284f32f475
commit f412b3915f
18 changed files with 65 additions and 78 deletions

View File

@ -509,13 +509,13 @@ expr:
| T_EVAL '(' expr ')' { $$ = Expr_Eval[expr: $3]; }
| T_REQUIRE expr { $$ = Expr_Include[expr: $2, type: Expr_Include::TYPE_REQUIRE]; }
| T_REQUIRE_ONCE expr { $$ = Expr_Include[expr: $2, type: Expr_Include::TYPE_REQUIRE_ONCE]; }
| T_INT_CAST expr { $$ = Expr_IntCast[expr: $2]; }
| T_DOUBLE_CAST expr { $$ = Expr_DoubleCast[expr: $2]; }
| T_STRING_CAST expr { $$ = Expr_StringCast[expr: $2]; }
| T_ARRAY_CAST expr { $$ = Expr_ArrayCast[$2]; }
| T_OBJECT_CAST expr { $$ = Expr_ObjectCast[expr: $2]; }
| T_BOOL_CAST expr { $$ = Expr_BoolCast[expr: $2]; }
| T_UNSET_CAST expr { $$ = Expr_UnsetCast[expr: $2]; }
| T_INT_CAST expr { $$ = Expr_Cast_Int [$2]; }
| T_DOUBLE_CAST expr { $$ = Expr_Cast_Double[$2]; }
| T_STRING_CAST expr { $$ = Expr_Cast_String[$2]; }
| T_ARRAY_CAST expr { $$ = Expr_Cast_Array [$2]; }
| T_OBJECT_CAST expr { $$ = Expr_Cast_Object[$2]; }
| T_BOOL_CAST expr { $$ = Expr_Cast_Bool [$2]; }
| T_UNSET_CAST expr { $$ = Expr_Cast_Unset [$2]; }
| T_EXIT exit_expr { $$ = Expr_Exit[expr: $2]; }
| '@' expr { $$ = Expr_ErrorSuppress[expr: $2]; }
| scalar { $$ = $1; }

View File

@ -1,8 +0,0 @@
<?php
/**
* @property PHPParser_Node_Expr $expr Expression
*/
class PHPParser_Node_Expr_BoolCast extends PHPParser_Node_Expr
{
}

View File

@ -3,10 +3,10 @@
/**
* @property PHPParser_Node_Expr $expr Expression
*/
class PHPParser_Node_Expr_ArrayCast extends PHPParser_Node_Expr
abstract class PHPParser_Node_Expr_Cast extends PHPParser_Node_Expr
{
/**
* Constructs an array cast node.
* Constructs a cast node.
*
* @param PHPParser_Node_Expr $expr Expression
* @param int $line Line

View File

@ -0,0 +1,5 @@
<?php
class PHPParser_Node_Expr_Cast_Array extends PHPParser_Node_Expr_Cast
{
}

View File

@ -0,0 +1,5 @@
<?php
class PHPParser_Node_Expr_Cast_Bool extends PHPParser_Node_Expr_Cast
{
}

View File

@ -0,0 +1,5 @@
<?php
class PHPParser_Node_Expr_Cast_Double extends PHPParser_Node_Expr_Cast
{
}

View File

@ -0,0 +1,5 @@
<?php
class PHPParser_Node_Expr_Cast_Int extends PHPParser_Node_Expr_Cast
{
}

View File

@ -0,0 +1,5 @@
<?php
class PHPParser_Node_Expr_Cast_Object extends PHPParser_Node_Expr_Cast
{
}

View File

@ -0,0 +1,5 @@
<?php
class PHPParser_Node_Expr_Cast_String extends PHPParser_Node_Expr_Cast
{
}

View File

@ -0,0 +1,5 @@
<?php
class PHPParser_Node_Expr_Cast_Unset extends PHPParser_Node_Expr_Cast
{
}

View File

@ -1,8 +0,0 @@
<?php
/**
* @property PHPParser_Node_Expr $expr Expression
*/
class PHPParser_Node_Expr_DoubleCast extends PHPParser_Node_Expr
{
}

View File

@ -1,8 +0,0 @@
<?php
/**
* @property PHPParser_Node_Expr $expr Expression
*/
class PHPParser_Node_Expr_IntCast extends PHPParser_Node_Expr
{
}

View File

@ -1,8 +0,0 @@
<?php
/**
* @property PHPParser_Node_Expr $expr Expression
*/
class PHPParser_Node_Expr_ObjectCast extends PHPParser_Node_Expr
{
}

View File

@ -1,8 +0,0 @@
<?php
/**
* @property PHPParser_Node_Expr $expr Expression
*/
class PHPParser_Node_Expr_StringCast extends PHPParser_Node_Expr
{
}

View File

@ -1,8 +0,0 @@
<?php
/**
* @property PHPParser_Node_Expr $expr Expression
*/
class PHPParser_Node_Expr_UnsetCast extends PHPParser_Node_Expr
{
}

View File

@ -1863,31 +1863,31 @@ class PHPParser_Parser
}
private function yyn220($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_IntCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Int($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn221($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_DoubleCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Double($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn222($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_StringCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_String($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn223($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_ArrayCast($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Array($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn224($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_ObjectCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Object($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn225($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_BoolCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Bool($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn226($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_UnsetCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Unset($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn227($line, $docComment) {

View File

@ -2260,31 +2260,31 @@ class PHPParser_ParserDebug
}
private function yyn220($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_IntCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Int($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn221($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_DoubleCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Double($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn222($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_StringCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_String($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn223($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_ArrayCast($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Array($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn224($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_ObjectCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Object($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn225($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_BoolCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Bool($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn226($line, $docComment) {
$this->yyval = new PHPParser_Node_Expr_UnsetCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
$this->yyval = new PHPParser_Node_Expr_Cast_Unset($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
}
private function yyn227($line, $docComment) {

View File

@ -278,31 +278,31 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
// Casts
public function pExpr_IntCast(PHPParser_Node_Expr_IntCast $node) {
public function pExpr_Cast_Int(PHPParser_Node_Expr_Cast_Int $node) {
return '(int) ' . $this->p($node->expr);
}
public function pExpr_DoubleCast(PHPParser_Node_Expr_DoubleCast $node) {
public function pExpr_Cast_Double(PHPParser_Node_Expr_Cast_Double $node) {
return '(double) ' . $this->p($node->expr);
}
public function pExpr_StringCast(PHPParser_Node_Expr_StringCast $node) {
public function pExpr_Cast_String(PHPParser_Node_Expr_Cast_String $node) {
return '(string) ' . $this->p($node->expr);
}
public function pExpr_ArrayCast(PHPParser_Node_Expr_ArrayCast $node) {
public function pExpr_Cast_Array(PHPParser_Node_Expr_Cast_Array $node) {
return '(array) ' . $this->p($node->expr);
}
public function pExpr_ObjectCast(PHPParser_Node_Expr_ObjectCast $node) {
public function pExpr_Cast_Object(PHPParser_Node_Expr_Cast_Object $node) {
return '(object) ' . $this->p($node->expr);
}
public function pExpr_BoolCast(PHPParser_Node_Expr_BoolCast $node) {
public function pExpr_Cast_Bool(PHPParser_Node_Expr_Cast_Bool $node) {
return '(bool) ' . $this->p($node->expr);
}
public function pExpr_UnsetCast(PHPParser_Node_Expr_UnsetCast $node) {
public function pExpr_Cast_Unset(PHPParser_Node_Expr_Cast_Unset $node) {
return '(unset) ' . $this->p($node->expr);
}