1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-03 09:47:59 +01:00

Make Node_Scalar instanceof Node_Expr

This commit is contained in:
nikic 2011-05-30 18:01:38 +02:00
parent 9aed651d51
commit 22ea3d6a70
4 changed files with 6 additions and 11 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
abstract class Node_Scalar extends NodeAbstract abstract class Node_Scalar extends Node_Expr
{ {
} }

View File

@ -324,7 +324,7 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
public function pExpr_StaticCall(Node_Expr_StaticCall $node) { public function pExpr_StaticCall(Node_Expr_StaticCall $node) {
return $this->pClassName($node->class) . '::' return $this->pClassName($node->class) . '::'
. ($node->func instanceof NodeAbstract ? $this->p($node->func) : $node->func) . ($node->func instanceof Node_Expr ? $this->p($node->func) : $node->func)
. '(' . $this->pCommaSeparated($node->args) . ')'; . '(' . $this->pCommaSeparated($node->args) . ')';
} }
@ -606,7 +606,7 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
public function pObjectProperty($node) { public function pObjectProperty($node) {
if ($node instanceof Node_Variable || $node instanceof Node_Expr_ArrayDimFetch) { if ($node instanceof Node_Variable || $node instanceof Node_Expr_ArrayDimFetch) {
return $this->p($node); return $this->p($node);
} elseif ($node instanceof NodeAbstract) { } elseif ($node instanceof Node_Expr) {
return '{' . $this->p($node) . '}'; return '{' . $this->p($node) . '}';
} else { } else {
return $node; return $node;
@ -635,12 +635,8 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
foreach ($encapsList as $element) { foreach ($encapsList as $element) {
if (is_string($element)) { if (is_string($element)) {
$return .= addcslashes($element, "\n\r\t\f\v$\"\\"); $return .= addcslashes($element, "\n\r\t\f\v$\"\\");
} elseif ($element instanceof Node_Variable) { } elseif ($element instanceof Node_Variable && is_string($element->name)) {
if (is_string($element->name)) {
$return .= '$' . $element->name; $return .= '$' . $element->name;
} else {
$return .= '{' . $this->p($element->name). '}';
}
} else { } else {
$return .= '{' . $this->p($element) . '}'; $return .= '{' . $this->p($element) . '}';
} }

View File

@ -35,7 +35,7 @@ $prettyPrinter = new PrettyPrinter_Zend;
$code = $prettyPrinter->pStmts( $code = $prettyPrinter->pStmts(
$parser->yyparse( $parser->yyparse(
new Lexer(file_get_contents( new Lexer(file_get_contents(
__FILE__ '../symfonySandbox\src\vendor\symfony\src\Symfony\Components\Console\Input\InputDefinition.php'
)), )),
function ($msg) { function ($msg) {
echo $msg; echo $msg;

View File

@ -7,7 +7,6 @@ function __autoload($class) {
} }
$parser = new Parser(); $parser = new Parser();
$parser->yydebug = false;
$prettyPrinter = new PrettyPrinter_Zend; $prettyPrinter = new PrettyPrinter_Zend;