Method printStatementList
has 43 lines of code (exceeds 25 allowed). Consider refactoring.
private function printStatementList(array $statements, OutputInterface $output, int $nesting = 0): void
{
if ($nesting === 0) {
$statements = $this->trimTrailingNoops($statements);
}
Function printStatementList
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
private function printStatementList(array $statements, OutputInterface $output, int $nesting = 0): void
{
if ($nesting === 0) {
$statements = $this->trimTrailingNoops($statements);
}
The method printStatementList() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
private function printStatementList(array $statements, OutputInterface $output, int $nesting = 0): void
{
if ($nesting === 0) {
$statements = $this->trimTrailingNoops($statements);
}
The class PrettyPrinter has a coupling between objects value of 19. Consider to reduce the number of dependencies under 13.
class PrettyPrinter implements ASTPrinterInterface
{
private PrettyPrinterConfiguration $prettyPrinterConfiguration;
public function __construct(?PrettyPrinterConfiguration $prettyPrinterConfiguration = null)
Avoid using static access to class 'Helmich\TypoScriptParser\Parser\Printer\PrettyPrinterConfiguration' in method '__construct'.
$this->prettyPrinterConfiguration = $prettyPrinterConfiguration ?? PrettyPrinterConfiguration::create();
Avoid using Helmich\TypoScriptParser\Parser\Printer\count() function in while loops.
while (count($out) && $out[count($out) - 1] instanceof NopStatement) {
array_pop($out);
}
Avoid using Helmich\TypoScriptParser\Parser\Printer\count() function in while loops.
while (count($out) && $out[count($out) - 1] instanceof NopStatement) {
array_pop($out);
}
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 35 and the first side effect is on line 31.
<?php
Possible parse error: class missing opening or closing brace
class PrettyPrinter implements ASTPrinterInterface
DEFAULT statements must be defined using a colon
default => "[end]",
Possible parse error: class missing opening or closing brace
class PrettyPrinter implements ASTPrinterInterface
Line indented incorrectly; expected 4 spaces, found 8
if ($nesting === 0) {
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof MultilineComment) {
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 0 spaces, found 4
private function getIndent(int $nesting): string
Line indented incorrectly; expected 4 spaces, found 8
if ($operator instanceof Copy) {
Line indented incorrectly; expected 8 spaces, found 12
if ($statement->condition !== null) {
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof Delete) {
Line indented incorrectly; expected 0 spaces, found 4
private function printNestedAssignment(OutputInterface $output, int $nesting, NestedAssignment $statement): void
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 4 spaces, found 8
switch ($this->prettyPrinterConfiguration->getConditionTermination()) {
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 4 spaces, found 8
if ($statement->newSyntax) {
Line indented incorrectly; expected 0 spaces, found 4
private function printAssignment(OutputInterface $output, Assignment $statement, string $indent): void
Line indented incorrectly; expected 8 spaces, found 12
case PrettyPrinterConditionTermination::EnforceGlobal:
Line indented incorrectly; expected 8 spaces, found 12
}
Line indented incorrectly; expected 4 spaces, found 8
if ($this->closeCondition($hasNext)) {
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 0 spaces, found 4
private PrettyPrinterConfiguration $prettyPrinterConfiguration;
Line indented incorrectly; expected 0 spaces, found 4
public function __construct(?PrettyPrinterConfiguration $prettyPrinterConfiguration = null)
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof Assignment) {
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 12
}
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 12
if ($statement instanceof NestedAssignment) {
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof BinaryObjectOperator) {
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof ConditionalStatement) {
Line indented incorrectly; expected 0 spaces, found 4
private function printBinaryObjectOperator(OutputInterface $output, BinaryObjectOperator $operator, int $nesting): void
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 4 spaces, found 8
if (str_contains($statement->value->value, "\n")) {
Line indented incorrectly; expected 4 spaces, found 8
while (count($out) && $out[count($out) - 1] instanceof NopStatement) {
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 0 spaces, found 4
private function printFileIncludeStatement(OutputInterface $output, FileIncludeStatement $statement): void
Line indented incorrectly; expected 4 spaces, found 8
if ($statement->condition !== null) {
Line indented incorrectly; expected 0 spaces, found 4
private function trimTrailingNoops(array $statements): array
Line indented incorrectly; expected 4 spaces, found 8
} elseif ($operator instanceof Reference) {
Line indented incorrectly; expected 4 spaces, found 8
if ($statement instanceof FileIncludeStatement) {
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 4 spaces, found 8
if ($this->prettyPrinterConfiguration->shouldIndentConditions()) {
Line indented incorrectly; expected 0 spaces, found 4
private function printNopStatement(OutputInterface $output): void
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 0 spaces, found 4
private function closeCondition(bool $hasNext): bool
Line indented incorrectly; expected 8 spaces, found 12
case PrettyPrinterConditionTermination::Keep:
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof IncludeStatement) {
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof Modification) {
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 20
default => "[end]",
Closing brace indented incorrectly; expected 4 spaces, found 0
}
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof Comment) {
Line indented incorrectly; expected 8 spaces, found 12
} elseif ($statement instanceof NopStatement) {
Line indented incorrectly; expected 4 spaces, found 8
} elseif ($statement instanceof DirectoryIncludeStatement) {
Line indented incorrectly; expected 4 spaces, found 8
} else {
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 4 spaces, found 8
}
Closing brace indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 0 spaces, found 4
public function printStatements(array $statements, OutputInterface $output): void
Line indented incorrectly; expected 4 spaces, found 8
for ($i = 0; $i < $count; $i++) {
Line indented incorrectly; expected 4 spaces, found 8
if ($statement->extensions !== null && $statement->extensions !== "") {
Line indented incorrectly; expected 0 spaces, found 4
public function setPrettyPrinterConfiguration(PrettyPrinterConfiguration $prettyPrinterConfiguration): void
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 0 spaces, found 4
private function printStatementList(array $statements, OutputInterface $output, int $nesting = 0): void
Line indented incorrectly; expected 0 spaces, found 4
private function printIncludeStatement(OutputInterface $output, IncludeStatement $statement): void
Line indented incorrectly; expected 0 spaces, found 4
private function printDirectoryIncludeStatement(OutputInterface $output, DirectoryIncludeStatement $statement): void
Line indented incorrectly; expected 0 spaces, found 4
private function printConditionalStatement(OutputInterface $output, int $nesting, ConditionalStatement $statement, bool $hasNext = false): void
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 0 spaces, found 4
private function getConditionTerminatorStatement(ConditionalStatement $stmt): string
Space before opening parenthesis of function call prohibited
return match ($stmt->terminator) {
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 4 spaces, found 8
}
Line indented incorrectly; expected 4 spaces, found 8
if (count($statement->elseStatements) > 0) {
Line indented incorrectly; expected 0 spaces, found 4
}
Line indented incorrectly; expected 4 spaces, found 8
if ($this->prettyPrinterConfiguration->shouldIncludeEmptyLineBreaks()) {
There are no issues that match your filters.