Skip to content

Commit

Permalink
[Printer] Avoid undefined index 0 on printing FileWithoutNamespace (#…
Browse files Browse the repository at this point in the history
…3459)

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Mar 5, 2023
1 parent ee55387 commit 6091bdd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/PhpParser/Printer/BetterStandardPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ private function resolveContentOnExpr(Expr $expr, string $content): string
*/
private function resolveNewStmts(array $stmts): array
{
$stmts = array_values($stmts);

if (count($stmts) === 1 && $stmts[0] instanceof FileWithoutNamespace) {
return $this->resolveNewStmts($stmts[0]->stmts);
}
Expand Down

0 comments on commit 6091bdd

Please sign in to comment.