2011-05-27 22:57:55 +02:00
|
|
|
<?php
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
2011-05-27 22:57:55 +02:00
|
|
|
{
|
2011-08-14 18:44:24 +02:00
|
|
|
// Special nodes
|
2011-05-29 12:20:47 +02:00
|
|
|
|
2011-08-14 18:44:24 +02:00
|
|
|
public function pParam(PHPParser_Node_Param $node) {
|
|
|
|
return ($node->type ? ('array' == $node->type ? 'array' : $this->p($node->type)) . ' ' : '')
|
|
|
|
. ($node->byRef ? '&' : '')
|
|
|
|
. '$' . $node->name
|
|
|
|
. ($node->default ? ' = ' . $this->p($node->default) : '');
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-09-22 20:34:35 +02:00
|
|
|
public function pArg(PHPParser_Node_Arg $node) {
|
|
|
|
return ($node->byRef ? '&' : '') . $this->p($node->value);
|
|
|
|
}
|
|
|
|
|
2011-09-23 21:00:59 +02:00
|
|
|
public function pConst(PHPParser_Node_Const $node) {
|
|
|
|
return $node->name . ' = ' . $this->p($node->value);
|
|
|
|
}
|
|
|
|
|
2011-09-24 16:53:40 +02:00
|
|
|
// Names
|
|
|
|
|
|
|
|
public function pName(PHPParser_Node_Name $node) {
|
|
|
|
return implode('\\', $node->parts);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pName_FullyQualified(PHPParser_Node_Name_FullyQualified $node) {
|
|
|
|
return '\\' . implode('\\', $node->parts);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pName_Relative(PHPParser_Node_Name_Relative $node) {
|
|
|
|
return 'namespace\\' . implode('\\', $node->parts);
|
|
|
|
}
|
|
|
|
|
2011-05-29 12:20:47 +02:00
|
|
|
// Magic Constants
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_ClassConst(PHPParser_Node_Scalar_ClassConst $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '__CLASS__';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_DirConst(PHPParser_Node_Scalar_DirConst $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '__DIR__';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_FileConst(PHPParser_Node_Scalar_FileConst $node) {
|
2011-05-27 22:57:55 +02:00
|
|
|
return '__FILE__';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_FuncConst(PHPParser_Node_Scalar_FuncConst $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '__FUNCTION__';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_LineConst(PHPParser_Node_Scalar_LineConst $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '__LINE__';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_MethodConst(PHPParser_Node_Scalar_MethodConst $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '__METHOD__';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_NSConst(PHPParser_Node_Scalar_NSConst $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '__NAMESPACE__';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scalars
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_String(PHPParser_Node_Scalar_String $node) {
|
2011-08-09 14:19:44 +02:00
|
|
|
return '\'' . $this->pSafe(addcslashes($node->value, '\'\\')) . '\'';
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_Encapsed(PHPParser_Node_Scalar_Encapsed $node) {
|
2011-10-16 15:19:50 +02:00
|
|
|
return '"' . $this->pEncapsList($node->parts, '"') . '"';
|
2011-05-29 21:06:43 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_LNumber(PHPParser_Node_Scalar_LNumber $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return (string) $node->value;
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pScalar_DNumber(PHPParser_Node_Scalar_DNumber $node) {
|
2011-10-16 15:39:23 +02:00
|
|
|
$stringValue = (string) $node->value;
|
|
|
|
|
|
|
|
// ensure that number is really printed as float
|
|
|
|
return ctype_digit($stringValue) ? $stringValue . '.0' : $stringValue;
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Assignments
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Assign(PHPParser_Node_Expr_Assign $node) {
|
2011-05-27 22:57:55 +02:00
|
|
|
return $this->p($node->var) . ' = ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignRef(PHPParser_Node_Expr_AssignRef $node) {
|
2011-08-11 08:35:10 +02:00
|
|
|
return $this->p($node->var) . ' =& ' . $this->p($node->expr);
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignPlus(PHPParser_Node_Expr_AssignPlus $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' += ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignMinus(PHPParser_Node_Expr_AssignMinus $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' -= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignMul(PHPParser_Node_Expr_AssignMul $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' *= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignDiv(PHPParser_Node_Expr_AssignDiv $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' /= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignConcat(PHPParser_Node_Expr_AssignConcat $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' .= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignMod(PHPParser_Node_Expr_AssignMod $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' %= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 08:42:28 +02:00
|
|
|
public function pExpr_AssignBitwiseAnd(PHPParser_Node_Expr_AssignBitwiseAnd $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' &= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 08:42:28 +02:00
|
|
|
public function pExpr_AssignBitwiseOr(PHPParser_Node_Expr_AssignBitwiseOr $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' |= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 08:42:28 +02:00
|
|
|
public function pExpr_AssignBitwiseXor(PHPParser_Node_Expr_AssignBitwiseXor $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' ^= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignShiftLeft(PHPParser_Node_Expr_AssignShiftLeft $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' <<= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_AssignShiftRight(PHPParser_Node_Expr_AssignShiftRight $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . ' >>= ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-10-16 14:49:13 +02:00
|
|
|
public function pExpr_AssignList(PHPParser_Node_Expr_AssignList $node) {
|
|
|
|
return $this->pAssignList($node->vars) . ' = ' . $this->p($node->expr);
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-05-29 12:20:47 +02:00
|
|
|
// Binary expressions
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Plus(PHPParser_Node_Expr_Plus $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' + ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Minus(PHPParser_Node_Expr_Minus $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' - ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Mul(PHPParser_Node_Expr_Mul $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' * ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Div(PHPParser_Node_Expr_Div $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' / ' . $this->p($node->right);
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Concat(PHPParser_Node_Expr_Concat $node) {
|
2011-05-27 22:57:55 +02:00
|
|
|
return $this->p($node->left) . ' . ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Mod(PHPParser_Node_Expr_Mod $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' % ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_BooleanAnd(PHPParser_Node_Expr_BooleanAnd $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' && ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_BooleanOr(PHPParser_Node_Expr_BooleanOr $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' || ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-08-11 08:42:28 +02:00
|
|
|
public function pExpr_BitwiseAnd(PHPParser_Node_Expr_BitwiseAnd $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' & ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-08-11 08:42:28 +02:00
|
|
|
public function pExpr_BitwiseOr(PHPParser_Node_Expr_BitwiseOr $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' | ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-08-11 08:42:28 +02:00
|
|
|
public function pExpr_BitwiseXor(PHPParser_Node_Expr_BitwiseXor $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' ^ ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ShiftLeft(PHPParser_Node_Expr_ShiftLeft $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return $this->p($node->left) . ' << ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ShiftRight(PHPParser_Node_Expr_ShiftRight $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return $this->p($node->left) . ' >> ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_LogicalAnd(PHPParser_Node_Expr_LogicalAnd $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' and ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_LogicalOr(PHPParser_Node_Expr_LogicalOr $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' or ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_LogicalXor(PHPParser_Node_Expr_LogicalXor $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' xor ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Equal(PHPParser_Node_Expr_Equal $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' == ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_NotEqual(PHPParser_Node_Expr_NotEqual $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' != ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Identical(PHPParser_Node_Expr_Identical $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' === ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_NotIdentical(PHPParser_Node_Expr_NotIdentical $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' !== ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Greater(PHPParser_Node_Expr_Greater $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' > ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_GreaterOrEqual(PHPParser_Node_Expr_GreaterOrEqual $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' >= ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Smaller(PHPParser_Node_Expr_Smaller $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' < ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_SmallerOrEqual(PHPParser_Node_Expr_SmallerOrEqual $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->left) . ' <= ' . $this->p($node->right);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Instanceof(PHPParser_Node_Expr_Instanceof $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->expr) . ' instanceof ' . $this->p($node->class);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unary expressions
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_BooleanNot(PHPParser_Node_Expr_BooleanNot $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '!' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 08:42:28 +02:00
|
|
|
public function pExpr_BitwiseNot(PHPParser_Node_Expr_BitwiseNot $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return '~' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_UnaryMinus(PHPParser_Node_Expr_UnaryMinus $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '-' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_UnaryPlus(PHPParser_Node_Expr_UnaryPlus $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return '+' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_PreInc(PHPParser_Node_Expr_PreInc $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '++' . $this->p($node->var);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_PreDec(PHPParser_Node_Expr_PreDec $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '--' . $this->p($node->var);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_PostInc(PHPParser_Node_Expr_PostInc $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . '++';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_PostDec(PHPParser_Node_Expr_PostDec $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . '--';
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ErrorSuppress(PHPParser_Node_Expr_ErrorSuppress $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return '@' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-05-29 12:20:47 +02:00
|
|
|
// Casts
|
|
|
|
|
2011-08-11 09:20:25 +02:00
|
|
|
public function pExpr_Cast_Int(PHPParser_Node_Expr_Cast_Int $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '(int) ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 09:20:25 +02:00
|
|
|
public function pExpr_Cast_Double(PHPParser_Node_Expr_Cast_Double $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '(double) ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 09:20:25 +02:00
|
|
|
public function pExpr_Cast_String(PHPParser_Node_Expr_Cast_String $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '(string) ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 09:20:25 +02:00
|
|
|
public function pExpr_Cast_Array(PHPParser_Node_Expr_Cast_Array $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '(array) ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 09:20:25 +02:00
|
|
|
public function pExpr_Cast_Object(PHPParser_Node_Expr_Cast_Object $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '(object) ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 09:20:25 +02:00
|
|
|
public function pExpr_Cast_Bool(PHPParser_Node_Expr_Cast_Bool $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '(bool) ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-08-11 09:20:25 +02:00
|
|
|
public function pExpr_Cast_Unset(PHPParser_Node_Expr_Cast_Unset $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '(unset) ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function calls and similar constructs
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_FuncCall(PHPParser_Node_Expr_FuncCall $node) {
|
2011-08-11 10:25:51 +02:00
|
|
|
return $this->p($node->name) . '(' . $this->pCommaSeparated($node->args) . ')';
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_MethodCall(PHPParser_Node_Expr_MethodCall $node) {
|
2011-05-27 22:57:55 +02:00
|
|
|
return $this->p($node->var) . '->' . $this->pObjectProperty($node->name)
|
|
|
|
. '(' . $this->pCommaSeparated($node->args) . ')';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_StaticCall(PHPParser_Node_Expr_StaticCall $node) {
|
2011-08-19 17:44:42 +02:00
|
|
|
return $this->p($node->class) . '::'
|
2011-08-11 10:25:51 +02:00
|
|
|
. ($node->name instanceof PHPParser_Node_Expr ? $this->p($node->name) : $node->name)
|
2011-05-29 17:33:03 +02:00
|
|
|
. '(' . $this->pCommaSeparated($node->args) . ')';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Empty(PHPParser_Node_Expr_Empty $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return 'empty(' . $this->p($node->var) . ')';
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Isset(PHPParser_Node_Expr_Isset $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return 'isset(' . $this->pCommaSeparated($node->vars) . ')';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Print(PHPParser_Node_Expr_Print $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return 'print ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Eval(PHPParser_Node_Expr_Eval $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return 'eval(' . $this->p($node->expr) . ')';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Include(PHPParser_Node_Expr_Include $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
static $map = array(
|
2011-06-05 18:40:04 +02:00
|
|
|
PHPParser_Node_Expr_Include::TYPE_INCLUDE => 'include',
|
|
|
|
PHPParser_Node_Expr_Include::TYPE_INCLUDE_ONCE => 'include_once',
|
|
|
|
PHPParser_Node_Expr_Include::TYPE_REQUIRE => 'require',
|
|
|
|
PHPParser_Node_Expr_Include::TYPE_REQUIRE_ONCE => 'require_once',
|
2011-05-29 12:20:47 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return $map[$node->type] . ' ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Other
|
|
|
|
|
2011-08-14 18:44:24 +02:00
|
|
|
public function pExpr_Variable(PHPParser_Node_Expr_Variable $node) {
|
2011-10-16 15:25:40 +02:00
|
|
|
if ($node->name instanceof PHPParser_Node_Expr) {
|
2011-08-14 18:44:24 +02:00
|
|
|
return '${' . $this->p($node->name) . '}';
|
|
|
|
} else {
|
|
|
|
return '$' . $node->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Array(PHPParser_Node_Expr_Array $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return 'array(' . $this->pCommaSeparated($node->items) . ')';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ArrayItem(PHPParser_Node_Expr_ArrayItem $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return (null !== $node->key ? $this->p($node->key) . ' => ' : '')
|
|
|
|
. ($node->byRef ? '&' : '') . $this->p($node->value);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ArrayDimFetch(PHPParser_Node_Expr_ArrayDimFetch $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->var) . '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ConstFetch(PHPParser_Node_Expr_ConstFetch $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->name);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ClassConstFetch(PHPParser_Node_Expr_ClassConstFetch $node) {
|
2011-08-19 17:44:42 +02:00
|
|
|
return $this->p($node->class) . '::' . $node->name;
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_PropertyFetch(PHPParser_Node_Expr_PropertyFetch $node) {
|
2011-05-27 22:57:55 +02:00
|
|
|
return $this->p($node->var) . '->' . $this->pObjectProperty($node->name);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_StaticPropertyFetch(PHPParser_Node_Expr_StaticPropertyFetch $node) {
|
2011-08-19 17:44:42 +02:00
|
|
|
return $this->p($node->class) . '::$' . $this->pObjectProperty($node->name);
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_ShellExec(PHPParser_Node_Expr_ShellExec $node) {
|
2011-10-16 15:19:50 +02:00
|
|
|
return '`' . $this->pEncapsList($node->parts, '`') . '`';
|
2011-05-29 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_LambdaFunc(PHPParser_Node_Expr_LambdaFunc $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return 'function ' . ($node->byRef ? '&' : '')
|
|
|
|
. '(' . $this->pCommaSeparated($node->params) . ')'
|
2011-08-14 18:26:06 +02:00
|
|
|
. (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')': '')
|
2011-06-02 22:52:24 +02:00
|
|
|
. ' {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_LambdaFuncUse(PHPParser_Node_Expr_LambdaFuncUse $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return ($node->byRef ? '&' : '') . '$' . $node->var;
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_New(PHPParser_Node_Expr_New $node) {
|
2011-08-19 17:44:42 +02:00
|
|
|
return 'new ' . $this->p($node->class) . '(' . $this->pCommaSeparated($node->args) . ')';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Clone(PHPParser_Node_Expr_Clone $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return 'clone ' . $this->p($node->expr);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Ternary(PHPParser_Node_Expr_Ternary $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->p($node->cond) . ' ?'
|
|
|
|
. (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '')
|
|
|
|
. ': ' . $this->p($node->else);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pExpr_Exit(PHPParser_Node_Expr_Exit $node) {
|
2011-05-29 17:33:03 +02:00
|
|
|
return 'die' . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : '');
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-05-29 17:33:03 +02:00
|
|
|
// Declarations
|
2011-05-29 12:20:47 +02:00
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Namespace(PHPParser_Node_Stmt_Namespace $node) {
|
2011-06-26 18:40:23 +02:00
|
|
|
return 'namespace' . (null !== $node->name ? ' ' . $this->p($node->name) : '')
|
|
|
|
. ' {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 21:06:43 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Use(PHPParser_Node_Stmt_Use $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'use ' . $this->pCommaSeparated($node->uses) . ';';
|
2011-05-29 21:06:43 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_UseUse(PHPParser_Node_Stmt_UseUse $node) {
|
2011-08-04 12:58:12 +02:00
|
|
|
return $this->p($node->name)
|
|
|
|
. ($node->name->getLast() !== $node->alias ? ' as ' . $node->alias : '');
|
2011-05-29 21:06:43 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Interface(PHPParser_Node_Stmt_Interface $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return 'interface ' . $node->name
|
|
|
|
. (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '')
|
2011-06-02 22:52:24 +02:00
|
|
|
. "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-30 17:29:10 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Class(PHPParser_Node_Stmt_Class $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->pModifiers($node->type)
|
|
|
|
. 'class ' . $node->name
|
|
|
|
. (null !== $node->extends ? ' extends ' . $this->p($node->extends) : '')
|
|
|
|
. (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '')
|
2011-06-02 22:52:24 +02:00
|
|
|
. "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Property(PHPParser_Node_Stmt_Property $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return $this->pModifiers($node->type) . $this->pCommaSeparated($node->props) . ';';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_PropertyProperty(PHPParser_Node_Stmt_PropertyProperty $node) {
|
2011-05-29 17:33:03 +02:00
|
|
|
return '$' . $node->name
|
|
|
|
. (null !== $node->default ? ' = ' . $this->p($node->default) : '');
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_ClassMethod(PHPParser_Node_Stmt_ClassMethod $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return $this->pModifiers($node->type)
|
2011-05-30 22:11:11 +02:00
|
|
|
. 'function ' . ($node->byRef ? '&' : '') . $node->name
|
2011-05-29 12:20:47 +02:00
|
|
|
. '(' . $this->pCommaSeparated($node->params) . ')'
|
2011-05-29 20:38:36 +02:00
|
|
|
. (null !== $node->stmts
|
2011-06-02 22:52:24 +02:00
|
|
|
? "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}'
|
2011-05-29 20:38:36 +02:00
|
|
|
: ';');
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_ClassConst(PHPParser_Node_Stmt_ClassConst $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'const ' . $this->pCommaSeparated($node->consts) . ';';
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Func(PHPParser_Node_Stmt_Func $node) {
|
2011-05-27 22:57:55 +02:00
|
|
|
return 'function ' . ($node->byRef ? '&' : '') . $node->name
|
2011-06-02 22:52:24 +02:00
|
|
|
. '(' . $this->pCommaSeparated($node->params) . ')'
|
|
|
|
. "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Const(PHPParser_Node_Stmt_Const $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'const ' . $this->pCommaSeparated($node->consts) . ';';
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-09-23 18:53:11 +02:00
|
|
|
public function pStmt_Declare(PHPParser_Node_Stmt_Declare $node) {
|
|
|
|
return 'declare (' . $this->pCommaSeparated($node->declares) . ') {'
|
|
|
|
. "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pStmt_DeclareDeclare(PHPParser_Node_Stmt_DeclareDeclare $node) {
|
2011-10-16 13:38:23 +02:00
|
|
|
return $node->key . ' = ' . $this->p($node->value);
|
2011-09-23 18:53:11 +02:00
|
|
|
}
|
|
|
|
|
2011-05-29 17:33:03 +02:00
|
|
|
// Control flow
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_If(PHPParser_Node_Stmt_If $node) {
|
2011-06-02 22:52:24 +02:00
|
|
|
return 'if (' . $this->p($node->cond) . ') {'
|
|
|
|
. "\n" . $this->pStmts($node->stmts) . "\n" . '}'
|
2011-05-29 12:20:47 +02:00
|
|
|
. $this->pImplode($node->elseifList)
|
|
|
|
. (null !== $node->else ? $this->p($node->else) : '');
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Elseif(PHPParser_Node_Stmt_Elseif $node) {
|
2011-06-02 22:52:24 +02:00
|
|
|
return ' elseif (' . $this->p($node->cond) . ') {'
|
|
|
|
. "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Else(PHPParser_Node_Stmt_Else $node) {
|
2011-06-02 22:52:24 +02:00
|
|
|
return ' else {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_For(PHPParser_Node_Stmt_For $node) {
|
2011-05-29 17:33:03 +02:00
|
|
|
return 'for ('
|
2011-08-11 07:53:55 +02:00
|
|
|
. $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '')
|
|
|
|
. $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '')
|
2011-05-29 17:33:03 +02:00
|
|
|
. $this->pCommaSeparated($node->loop)
|
2011-06-02 22:52:24 +02:00
|
|
|
. ') {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Foreach(PHPParser_Node_Stmt_Foreach $node) {
|
2011-05-29 17:33:03 +02:00
|
|
|
return 'foreach (' . $this->p($node->expr) . ' as '
|
|
|
|
. (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '')
|
2011-06-02 22:52:24 +02:00
|
|
|
. ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {'
|
|
|
|
. "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_While(PHPParser_Node_Stmt_While $node) {
|
2011-05-29 17:33:03 +02:00
|
|
|
return 'while (' . $this->p($node->cond) . ') {'
|
2011-06-02 22:52:24 +02:00
|
|
|
. "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Do(PHPParser_Node_Stmt_Do $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'do {' . "\n" . $this->pStmts($node->stmts) . "\n"
|
|
|
|
. '} while (' . $this->p($node->cond) . ');';
|
2011-05-30 17:29:10 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Switch(PHPParser_Node_Stmt_Switch $node) {
|
2011-05-29 17:33:03 +02:00
|
|
|
return 'switch (' . $this->p($node->cond) . ') {'
|
2011-10-15 19:30:48 +02:00
|
|
|
. "\n" . $this->pImplode($node->cases) . '}';
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_TryCatch(PHPParser_Node_Stmt_TryCatch $node) {
|
2011-06-02 22:52:24 +02:00
|
|
|
return 'try {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}'
|
2011-05-30 17:29:10 +02:00
|
|
|
. $this->pImplode($node->catches);
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Catch(PHPParser_Node_Stmt_Catch $node) {
|
2011-05-30 17:29:10 +02:00
|
|
|
return ' catch (' . $this->p($node->type) . ' $' . $node->var . ') {'
|
2011-06-02 22:52:24 +02:00
|
|
|
. "\n" . $this->pStmts($node->stmts) . "\n" . '}';
|
2011-05-30 17:29:10 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Case(PHPParser_Node_Stmt_Case $node) {
|
2011-05-29 17:33:03 +02:00
|
|
|
return (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default') . ':'
|
2011-06-02 22:52:24 +02:00
|
|
|
. "\n" . $this->pStmts($node->stmts) . "\n";
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Break(PHPParser_Node_Stmt_Break $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'break' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Continue(PHPParser_Node_Stmt_Continue $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'continue' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Return(PHPParser_Node_Stmt_Return $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'return' . (null !== $node->expr ? ' ' . $this->p($node->expr) : '') . ';';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Throw(PHPParser_Node_Stmt_Throw $node) {
|
2011-09-30 19:30:33 +02:00
|
|
|
return 'throw ' . $this->p($node->expr) . ';';
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Label(PHPParser_Node_Stmt_Label $node) {
|
2011-05-31 16:43:46 +02:00
|
|
|
return $node->name . ':';
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Goto(PHPParser_Node_Stmt_Goto $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'goto ' . $node->name . ';';
|
2011-05-31 16:43:46 +02:00
|
|
|
}
|
|
|
|
|
2011-05-29 17:33:03 +02:00
|
|
|
// Other
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Echo(PHPParser_Node_Stmt_Echo $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'echo ' . $this->pCommaSeparated($node->exprs) . ';';
|
2011-05-29 17:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Static(PHPParser_Node_Stmt_Static $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'static ' . $this->pCommaSeparated($node->vars) . ';';
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Global(PHPParser_Node_Stmt_Global $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'global ' . $this->pCommaSeparated($node->vars) . ';';
|
2011-05-30 17:29:10 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_StaticVar(PHPParser_Node_Stmt_StaticVar $node) {
|
2011-05-29 12:20:47 +02:00
|
|
|
return '$' . $node->name
|
|
|
|
. (null !== $node->default ? ' = ' . $this->p($node->default) : '');
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_Unset(PHPParser_Node_Stmt_Unset $node) {
|
2011-08-04 18:36:06 +02:00
|
|
|
return 'unset(' . $this->pCommaSeparated($node->vars) . ');';
|
2011-05-30 17:29:10 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_InlineHTML(PHPParser_Node_Stmt_InlineHTML $node) {
|
2011-06-02 23:05:14 +02:00
|
|
|
return '?>' . $this->pSafe(
|
|
|
|
("\n" === $node->value[0] || "\r" === $node->value[0] ? "\n" : '')
|
|
|
|
. $node->value
|
|
|
|
) . '<?php ';
|
2011-05-30 17:29:10 +02:00
|
|
|
}
|
|
|
|
|
2011-06-05 18:40:04 +02:00
|
|
|
public function pStmt_HaltCompiler(PHPParser_Node_Stmt_HaltCompiler $node) {
|
2011-06-03 22:02:02 +02:00
|
|
|
return '__halt_compiler();' . $node->remaining;
|
|
|
|
}
|
|
|
|
|
2011-05-29 17:33:03 +02:00
|
|
|
// Helpers
|
2011-05-27 22:57:55 +02:00
|
|
|
|
|
|
|
public function pObjectProperty($node) {
|
2011-08-11 08:13:01 +02:00
|
|
|
if ($node instanceof PHPParser_Node_Expr) {
|
2011-05-27 22:57:55 +02:00
|
|
|
return '{' . $this->p($node) . '}';
|
|
|
|
} else {
|
|
|
|
return $node;
|
|
|
|
}
|
|
|
|
}
|
2011-05-29 12:20:47 +02:00
|
|
|
|
|
|
|
public function pModifiers($modifiers) {
|
2011-06-05 18:40:04 +02:00
|
|
|
return ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC ? 'public ' : '')
|
|
|
|
. ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED ? 'protected ' : '')
|
|
|
|
. ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE ? 'private ' : '')
|
|
|
|
. ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_STATIC ? 'static ' : '')
|
|
|
|
. ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT ? 'abstract ' : '')
|
|
|
|
. ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_FINAL ? 'final ' : '');
|
2011-05-29 12:20:47 +02:00
|
|
|
}
|
2011-05-29 19:38:04 +02:00
|
|
|
|
2011-10-16 15:19:50 +02:00
|
|
|
public function pEncapsList(array $encapsList, $quote) {
|
2011-05-29 19:38:04 +02:00
|
|
|
$return = '';
|
2011-06-06 18:56:19 +02:00
|
|
|
foreach ($encapsList as $element) {
|
2011-05-29 19:38:04 +02:00
|
|
|
if (is_string($element)) {
|
2011-10-16 15:19:50 +02:00
|
|
|
$return .= addcslashes($element, "\n\r\t\f\v$" . $quote . "\\");
|
2011-05-29 19:38:04 +02:00
|
|
|
} else {
|
|
|
|
$return .= '{' . $this->p($element) . '}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
2011-10-16 14:11:23 +02:00
|
|
|
|
|
|
|
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) . ')';
|
|
|
|
}
|
2011-05-27 22:57:55 +02:00
|
|
|
}
|