prettier / prettier/plugin-php

Syntax error anonymous readonly class

Open
#2,452 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
1.9k
Forks
139
PR merge metrics
No merged PRs in 30d

Description

@prettier/plugin-php v0.24.0
Playground link

Input:

<?php

abstract readonly class Foo {
  public function bar() {
    echo 'bar';
  }
}

$foo = new readonly class extends Foo{};
echo $foo->bar();

Output:

Parse Error : syntax error, unexpected 'readonly' (T_READ_ONLY) on line 9

   7 | }
   8 |
>  9 | $foo = new readonly class extends Foo{};
     |           ^
  10 | echo $foo->bar();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Playground reproduction and compare how the PHP plugin handles new readonly class extends Foo{}. Trace the parser or formatter entry point reached by this input and add or run a focused reproduction; the work is done when the input no longer produces the reported syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.