Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

php-cs-fixer

  • Loading branch information...
commit ab028f88bf3854f061a7cc6115baa62a4e3a4ed4 1 parent 8e767e3
@jmalloc jmalloc authored
View
23 lib/Icecave/Rasta/Renderer.php
@@ -29,8 +29,6 @@
use Icecave\Pasta\AST\Expr\Equals;
use Icecave\Pasta\AST\Expr\Greater;
use Icecave\Pasta\AST\Expr\GreaterEqual;
-use Icecave\Pasta\AST\Expr\IExpression;
-use Icecave\Pasta\AST\Expr\IOperator;
use Icecave\Pasta\AST\Expr\InstanceOfType;
use Icecave\Pasta\AST\Expr\Less;
use Icecave\Pasta\AST\Expr\LessEqual;
@@ -132,6 +130,7 @@ public function visitGlobalFunction(GlobalFunction $node)
}
$code = $this->indent('function ' . $node->name()->accept($this) . '(' . implode(', ', $parameters) . ')' . PHP_EOL);
$code .= $node->statementBlock()->accept($this);
+
return $code;
}
@@ -172,6 +171,7 @@ public function visitPhpBlock(PhpBlock $node, $closeTag = true)
if ($closeTag) {
$code .= '?>';
}
+
return $code;
}
@@ -208,6 +208,7 @@ public function visitDoWhileStatement(DoWhileStatement $node)
$code = $this->indent('do' . PHP_EOL);
$code .= $this->generateStatementCode($node->statement());
$code .= $this->indent('while (' . $node->conditionExpression()->accept($this) . ');' . PHP_EOL);
+
return $code;
}
@@ -225,6 +226,7 @@ public function visitForeachStatement(ForeachStatement $node)
}
$code = $this->indent('foreach (' . $node->sequence()->accept($this) . ' as ' . $unpack . ')' . PHP_EOL);
$code .= $this->generateStatementCode($node->statement());
+
return $code;
}
@@ -248,6 +250,7 @@ public function visitForStatement(ForStatement $node)
$code = $this->indent('for (' . $init . ';' . $cond . ';' . $iter . ')' . PHP_EOL);
$code .= $this->generateStatementCode($node->statement());
+
return $code;
}
@@ -279,6 +282,7 @@ public function visitReturnStatement(ReturnStatement $node)
if ($expr = $node->expression()) {
$expression = ' ' . $expr->accept($this);
}
+
return $this->indent('return' . $expression . ';' . PHP_EOL);
}
@@ -289,6 +293,7 @@ public function visitStatementBlock(StatementBlock $node)
$code .= $this->visitChildren($node);
$this->endIndent();
$code .= $this->indent('}' . PHP_EOL);
+
return $code;
}
@@ -304,6 +309,7 @@ public function visitUseStatement(UseStatement $node)
$code .= ' as ' . $alias->accept($this);
}
$code .= ';' . PHP_EOL;
+
return $code;
}
@@ -311,6 +317,7 @@ public function visitWhileStatement(WhileStatement $node)
{
$code = $this->indent('while (' . $node->conditionExpression()->accept($this) . ')' . PHP_EOL);
$code .= $this->generateStatementCode($node->statement());
+
return $code;
}
@@ -323,6 +330,7 @@ public function visitSyntaxTree(SyntaxTree $node)
return $this->visitPhpBlock($child, false);
}
}
+
return $this->visitChildren($node);
}
@@ -369,6 +377,7 @@ public function visitClassDefinition(ClassDefinition $node)
$code .= $this->visitChildren($node);
$this->endIndent();
$code .= $this->indent('}' . PHP_EOL);
+
return $code;
}
@@ -386,6 +395,7 @@ public function visitConcreteMethod(ConcreteMethod $node)
$code = $this->indent(implode(' ', $modifiers) . ' function ' . $node->name()->accept($this) . '(' . implode(', ', $parameters) . ')' . PHP_EOL);
$code .= $node->statementBlock()->accept($this);
+
return $code;
}
@@ -426,6 +436,7 @@ public function visitInterfaceDefinition(InterfaceDefinition $node)
$this->endIndent();
$code .= $this->indent('}' . PHP_EOL);
$this->isInterfaceScope = false;
+
return $code;
}
@@ -468,6 +479,7 @@ public function visitLiteral(Literal $node)
if (null === $node->value()) {
return 'null';
}
+
return var_export($node->value(), true);
}
@@ -513,6 +525,7 @@ public function visitClosure(Closure $node)
$code = $this->indent('function (' . implode(', ', $parameters) . ')' . $use . PHP_EOL);
$code .= $node->statementBlock()->accept($this);
+
return $code;
}
@@ -815,6 +828,7 @@ public function visitSumAssign(SumAssign $node)
protected function indent($code, $level = null)
{
$indent = str_repeat($this->indentString, $level ?: $this->indentLevel);
+
return preg_replace('/^/m', $indent, $code);
}
@@ -834,6 +848,7 @@ protected function visitChildren(Node $node)
foreach ($node->children() as $child) {
$code .= $child->accept($this);
}
+
return $code;
}
@@ -847,10 +862,10 @@ protected function generateUnaryOperatorCode($operator, UnaryOperator $node, $pr
if ($prefix) {
return '(' . $operator . $node->expression()->accept($this) . ')';
}
+
return '(' . $node->expression()->accept($this) . $operator . ')';
}
-
protected function generateBinaryOperatorCode($operator, BinaryOperator $node)
{
return '(' . $node->leftExpression()->accept($this) . ' ' . $operator . ' ' . $node->rightExpression()->accept($this) . ')';
@@ -862,6 +877,7 @@ protected function generatePolyadicOperatorCode($operator, PolyadicOperator $nod
foreach ($node->children() as $expression) {
$expressions[] = $expression->accept($this);
}
+
return '(' . implode(' ' . $operator . ' ', $expressions) . ')';
}
@@ -874,6 +890,7 @@ protected function generateStatementCode(IStatement $node)
$this->startIndent();
$code = $node->accept($this);
$this->endIndent();
+
return $code;
}
View
2  test/suite/Icecave/Rasta/RendererTest.php
@@ -18,7 +18,6 @@
use Icecave\Pasta\AST\Func\GlobalFunction;
use Icecave\Pasta\AST\Func\ObjectTypeHint;
use Icecave\Pasta\AST\Func\Parameter;
-use Icecave\Pasta\AST\IVisitor;
use Icecave\Pasta\AST\Identifier;
use Icecave\Pasta\AST\Node;
use Icecave\Pasta\AST\PhpBlock;
@@ -28,7 +27,6 @@
use Icecave\Pasta\AST\Stmt\ExpressionStatement;
use Icecave\Pasta\AST\Stmt\ForStatement;
use Icecave\Pasta\AST\Stmt\ForeachStatement;
-use Icecave\Pasta\AST\Stmt\IStatement;
use Icecave\Pasta\AST\Stmt\IfStatement;
use Icecave\Pasta\AST\Stmt\NamespaceStatement;
use Icecave\Pasta\AST\Stmt\ReturnStatement;
Please sign in to comment.
Something went wrong with that request. Please try again.