prettier / prettier/plugin-php

Unexpected syntax error with multi-level scope resolution

Open
#2,175 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

@prettier/plugin-php v0.19.4
Playground link

Input:

<?php
enum Bar: int {
    case test = 42;
}

class Foo
{
	const BarInFoo = Bar::test;
}

print Foo::BarInFoo::class; //Prints Bar
?>

Output:

Parse Error : syntax error, unexpected '::' (T_DOUBLE_COLON) on line 11

   9 | }
  10 |
> 11 | print Foo::BarInFoo::class; //Prints Bar
     |                   ^
  12 | ?>

Expected behavior:

No error reported.

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

Reproduce the syntax error using the linked Playground example and the provided PHP input. Trace how the plugin parses the chained Foo::BarInFoo::class expression, then add regression coverage for the expected successful parse and verify that no error is reported.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.