phpDocumentor / phpDocumentor/Reflection

Error parsing typed class constants with php 8.3

Open
#530 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
125
Forks
60
Avg merge
2m
Merged PRs (30d)
9

Description

Ran phpDocumentor as phpdoc.phar with version v3.4.3 on a php 8.3 code base.

fails:

class Something
{
    private const array REPLACEMENT_MAP = [ 'a' => 1 ];
}

works:

class Something
{
    private const REPLACEMENT_MAP = [ 'a' => 1 ];
}

output:

[alert]   Unable to parse file "Something.php", an error was detected: Syntax error, unexpected T_STRING, expecting '=' on line 5

Contributor guide

No contributing guide indexed for this repository

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 failure by running phpDocumentor v3.4.3 as phpdoc.phar against Something.php containing the typed private class constant shown in the report. Compare it with the untyped constant case and trace the parser entry point that reports the unexpected T_STRING error. Done means the typed constant parses without the reported syntax error on PHP 8.3.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.