Skip to content

Commit 49af316

Browse files
authored
refactor: Leverage the PhpParser v5 printer changes (#1040)
- Typehint against the interface instead of the abstract method. - Correct the type for the old tokens.
1 parent c9646d2 commit 49af316

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/PhpParser/Printer/Printer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
namespace Humbug\PhpScoper\PhpParser\Printer;
1616

1717
use PhpParser\Node;
18+
use PhpParser\Token;
1819

1920
interface Printer
2021
{
2122
/**
22-
* @param Node[] $newStmts
23-
* @param Node[] $oldStmts
24-
* @param array<mixed> $oldTokens
23+
* @param Node[] $newStmts
24+
* @param Node[] $oldStmts
25+
* @param Token[] $oldTokens
2526
*/
2627
public function print(array $newStmts, array $oldStmts, array $oldTokens): string;
2728
}

src/PhpParser/Printer/StandardPrinter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@
1414

1515
namespace Humbug\PhpScoper\PhpParser\Printer;
1616

17-
use PhpParser\PrettyPrinterAbstract;
17+
use PhpParser\PrettyPrinter;
1818

1919
final readonly class StandardPrinter implements Printer
2020
{
21-
public function __construct(private PrettyPrinterAbstract $decoratedPrinter)
21+
public function __construct(private PrettyPrinter $decoratedPrinter)
2222
{
2323
}
2424

2525
public function print(array $newStmts, array $oldStmts, array $oldTokens): string
2626
{
27-
return $this->decoratedPrinter->prettyPrintFile($newStmts)."\n";
27+
$printedStatements = $this->decoratedPrinter->prettyPrintFile($newStmts);
28+
29+
return $printedStatements."\n";
2830
}
2931
}

0 commit comments

Comments
 (0)