1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-30 04:19:30 +01:00

Further work on PrettyPrinter

This commit is contained in:
nikic 2011-05-29 21:06:43 +02:00
parent df82e3db45
commit 43b41e382f
6 changed files with 31 additions and 2 deletions

View File

@ -1,5 +1,8 @@
<?php
/**
* @property array $parts Encaps list
*/
class Node_Scalar_Encapsed extends Node_Scalar
{
}

View File

@ -1,5 +1,8 @@
<?php
/**
* @property Node_Name $ns Namespace
*/
class Node_Stmt_Namespace extends Node_Stmt
{
}

View File

@ -1,5 +1,8 @@
<?php
/**
* @property array $uses Aliases
*/
class Node_Stmt_Use extends Node_Stmt
{
}

View File

@ -1,5 +1,9 @@
<?php
/**
* @property Node_Name $ns Namespace/Class to alias
* @property string $alias Alias
*/
class Node_Stmt_UseUse extends Node_Stmt
{
}

View File

@ -58,6 +58,10 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
);
}
public function pScalar_Encapsed(Node_Scalar_Encapsed $node) {
return '"' . $this->pEncapsList($node->parts) . '"';
}
public function pScalar_LNumber(Node_Scalar_LNumber $node) {
return (string) $node->value;
}
@ -385,6 +389,18 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
// Declarations
public function pStmt_Namespace(Node_Stmt_Namespace $node) {
return 'namespace ' . $this->p($node->ns);
}
public function pStmt_Use(Node_Stmt_Use $node) {
return 'use ' . $this->pCommaSeparated($node->uses);
}
public function pStmt_UseUse(Node_Stmt_UseUse $node) {
return $this->p($node->ns) . (null !== $node->alias ? ' as ' . $node->alias : '');
}
public function pStmt_Class(Node_Stmt_Class $node) {
return $this->pModifiers($node->type)
. 'class ' . $node->name
@ -557,7 +573,7 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
$return = '';
foreach ($encapsList as $element) {
if (is_string($element)) {
$return .= $element;
$return .= addcslashes($element, "\n\r\t\f\v$\"\\");
} elseif ($element instanceof Node_Variable) {
if (is_string($element->name)) {
$return .= '$' . $element->name;

View File

@ -1,6 +1,6 @@
<?php
$DIR = '../../symfony2';
$DIR = '../../symfonySandbox';
function __autoload($class) {
is_file($file = '../lib/' . strtr($class, '_', '/') . '.php') && require_once $file;