Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ class KeepDocblockOnReturn
{
public function run()
{

/** @psalm-suppress UndefinedFunction */

fn() => ff();


// @psalm-suppress UndefinedFunction
/** @psalm-suppress UndefinedFunction */
fn() => ff();

fn() => ff();
// @psalm-suppress UndefinedFunction
fn() => ff();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ class WithEqualVarDocType
{
public function run()
{

/** @var string $var */

fn(string $var) => $var;
/** @var string $var */
fn(string $var) => $var;
}
}

Expand Down
14 changes: 9 additions & 5 deletions src/PhpParser/Printer/BetterStandardPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $preced
return parent::pExpr_ArrowFunction($arrowFunction, $precedence, $lhsPrecedence);
}

$indent = $this->resolveIndentSpaces();
$indentOnlyLevel = $this->resolveIndentSpaces(true);

$text = "\n" . $indent;
$text = "";
foreach ($comments as $key => $comment) {
$commentText = $key > 0 ? $indent . $comment->getText() : $comment->getText();
$commentText = $key > 0 ? $indentOnlyLevel . $comment->getText() : $comment->getText();
$text .= $commentText . "\n";
}

return $text . "\n" . $indent . parent::pExpr_ArrowFunction($arrowFunction, $precedence, $lhsPrecedence);
return $text . $indentOnlyLevel . parent::pExpr_ArrowFunction($arrowFunction, $precedence, $lhsPrecedence);
}

/**
Expand Down Expand Up @@ -502,10 +502,14 @@ private function cleanStartIndentationOnHeredocNowDoc(string $content): string
return implode("\n", $trimmedLines);
}

private function resolveIndentSpaces(): string
private function resolveIndentSpaces(bool $onlyLevel = false): string
{
$indentSize = SimpleParameterProvider::provideIntParameter(Option::INDENT_SIZE);

if ($onlyLevel) {
return str_repeat($this->getIndentCharacter(), $this->indentLevel);
}

return str_repeat($this->getIndentCharacter(), $this->indentLevel) .
str_repeat($this->getIndentCharacter(), $indentSize);
}
Expand Down