Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Leverage the PhpParser v5 printer changes #1040

Merged
merged 1 commit into from
Jun 10, 2024
Merged
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
7 changes: 4 additions & 3 deletions src/PhpParser/Printer/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
namespace Humbug\PhpScoper\PhpParser\Printer;

use PhpParser\Node;
use PhpParser\Token;

interface Printer
{
/**
* @param Node[] $newStmts
* @param Node[] $oldStmts
* @param array<mixed> $oldTokens
* @param Node[] $newStmts
* @param Node[] $oldStmts
* @param Token[] $oldTokens
*/
public function print(array $newStmts, array $oldStmts, array $oldTokens): string;
}
8 changes: 5 additions & 3 deletions src/PhpParser/Printer/StandardPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@

namespace Humbug\PhpScoper\PhpParser\Printer;

use PhpParser\PrettyPrinterAbstract;
use PhpParser\PrettyPrinter;

final readonly class StandardPrinter implements Printer
{
public function __construct(private PrettyPrinterAbstract $decoratedPrinter)
public function __construct(private PrettyPrinter $decoratedPrinter)
{
}

public function print(array $newStmts, array $oldStmts, array $oldTokens): string
{
return $this->decoratedPrinter->prettyPrintFile($newStmts)."\n";
$printedStatements = $this->decoratedPrinter->prettyPrintFile($newStmts);

return $printedStatements."\n";
}
}
Loading