mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-26 20:14:46 +01:00
Fix some prettyprinting issues
This commit is contained in:
parent
15e268cd8b
commit
489f8c8b56
@ -299,7 +299,7 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pExpr_StaticCall(Node_Expr_StaticCall $node) {
|
||||
return $this->p($node->class) . '::'
|
||||
return $this->pClassName($node->class) . '::'
|
||||
. ($node->func instanceof Node_Variable ? $this->p($node->func) : $node->func)
|
||||
. '(' . $this->pCommaSeparated($node->args) . ')';
|
||||
}
|
||||
@ -351,7 +351,7 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pExpr_StaticPropertyFetch(Node_Expr_StaticPropertyFetch $node) {
|
||||
return $this->p($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
return $this->pClassName($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
}
|
||||
|
||||
public function pExpr_ShellExec(Node_Expr_ShellExec $node) {
|
||||
@ -370,7 +370,7 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pExpr_New(Node_Expr_New $node) {
|
||||
return 'new ' . $this->p($node->class) . '(' . $this->pCommaSeparated($node->args) . ')';
|
||||
return 'new ' . $this->pClassName($node->class) . '(' . $this->pCommaSeparated($node->args) . ')';
|
||||
}
|
||||
|
||||
public function pExpr_Ternary(Node_Expr_Ternary $node) {
|
||||
@ -406,7 +406,9 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
|
||||
return $this->pModifiers($node->type)
|
||||
. 'function ' . $node->name
|
||||
. '(' . $this->pCommaSeparated($node->params) . ')'
|
||||
. "\n" . '{' . "\n" . $this->pIndent($this->pStmts($node->stmts)) . '}';
|
||||
. (null !== $node->stmts
|
||||
? "\n" . '{' . "\n" . $this->pIndent($this->pStmts($node->stmts)) . '}'
|
||||
: ';');
|
||||
}
|
||||
|
||||
public function pStmt_ClassConst(Node_Stmt_ClassConst $node) {
|
||||
@ -535,12 +537,10 @@ class PrettyPrinter_Zend extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pClassName($node) {
|
||||
if ($node instanceof Node_Name) {
|
||||
return $this->pName($node);
|
||||
} elseif ($node == 'static') {
|
||||
if ($node == 'static') {
|
||||
return 'static';
|
||||
} else {
|
||||
throw new InvalidArgumentException();
|
||||
return $this->p($node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$DIR = '..';
|
||||
$DIR = '../../symfony2';
|
||||
|
||||
function __autoload($class) {
|
||||
is_file($file = '../lib/' . strtr($class, '_', '/') . '.php') && require_once $file;
|
||||
@ -30,6 +30,10 @@ echo '<!DOCTYPE html>
|
||||
.failReason {
|
||||
background-color: rgba(255, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.failCount {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
<table>
|
||||
<tr>
|
||||
@ -37,10 +41,12 @@ echo '<!DOCTYPE html>
|
||||
<td>Parse</td>
|
||||
<td>Time</td>
|
||||
<td>PrettyPrint</td>
|
||||
<td>Same</td>
|
||||
<td>Compare</td>
|
||||
</tr>';
|
||||
|
||||
$GST = microtime(true);
|
||||
$totalStartTime = microtime(true);
|
||||
$parseFail = $parseCount = $ppFail = $ppCount = $compareFail = $compareCount = 0;
|
||||
|
||||
foreach (new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($DIR),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY)
|
||||
@ -67,6 +73,7 @@ foreach (new RecursiveIteratorIterator(
|
||||
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
++$parseCount;
|
||||
if (false !== $stmts) {
|
||||
$code = '<?php' . "\n" . $prettyPrinter->pStmts($stmts);
|
||||
|
||||
@ -77,7 +84,9 @@ foreach (new RecursiveIteratorIterator(
|
||||
}
|
||||
);
|
||||
|
||||
++$ppCount;
|
||||
if (false !== $ppStmts) {
|
||||
++$compareCount;
|
||||
if ($stmts == $ppStmts) {
|
||||
echo '
|
||||
<td class="pass">PASS</td>
|
||||
@ -91,6 +100,8 @@ foreach (new RecursiveIteratorIterator(
|
||||
<td class="pass">PASS</td>
|
||||
<td class="fail">FAIL</td>
|
||||
</tr>';
|
||||
|
||||
++$compareFail;
|
||||
}
|
||||
} else {
|
||||
echo '
|
||||
@ -99,6 +110,8 @@ foreach (new RecursiveIteratorIterator(
|
||||
<td class="fail">FAIL</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
++$ppFail;
|
||||
}
|
||||
} else {
|
||||
echo '
|
||||
@ -108,12 +121,21 @@ foreach (new RecursiveIteratorIterator(
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="failReason"><td colspan="5">' . $errMsg . '</td></tr>';
|
||||
|
||||
++$parseFail;
|
||||
}
|
||||
|
||||
flush();
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>Fail / Total:</td>
|
||||
<td><span class="failCount">' . $parseFail . '</span> / ' . $parseCount . '</td>
|
||||
<td></td>
|
||||
<td><span class="failCount">' . $ppFail . '</span> / ' . $ppCount . '</td>
|
||||
<td><span class="failCount">' . $compareFail . '</span> / ' . $compareCount . '</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
echo 'Total time: ', microtime(true) - $GST;
|
||||
echo 'Total time: ', microtime(true) - $totalStartTime;
|
Loading…
Reference in New Issue
Block a user