classes that specify visibility on class constants can't be parsed
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- php
- Domain
- documentation, tooling
Research direction
Inspect the Composer dependencies involving nikic/php-parser and phpdocumentor/reflection, then reproduce the failure with the class-constant example in the issue. Verify that the dependency update parses public and protected class constants and that the existing parser behavior remains intact.
Written by the indexing model from the issue text.
Description
For example,
class My_Class {
public const C1 = 'value';
protected const C2 = 'another value';
...
}
Trying the parse the above results in an error like:
Parse Error: Syntax error, unexpected T_CONST, expecting T_FUNCTION on line xyz
and the entire class is not imported.
Visibility for class constants wasn't added to PHP until 7.1. Of course, as of today (2020-08-14) nothing in core specifies visibility on class constants since the minimum PHP is still 5.6. And current WPCS states:
Visibility for class constants can not be used in WordPress Core until the minimum PHP version has been raised to PHP 7.1 (and won’t be enforced until that time).
It is hopeful (likely?) that WP 5.6 will bump the minimum PHP to 7.1. So, the need to parse such classes will be coming sooner rather than later.
As best I can tell, the error is generated by nikic/php-parser, which is a transitive dependency of phpdocumentor/reflection. The latest version of nikic/php-parser fully supports PHP 7.1+, so I think the solution is simply to update the composer dependencies of this plugin, but things will need to be tested thoroughly after those dependencies are updated.
- Dominant language
- PHP
- Stars
- 239
- Forks
- 81
- Avg merge
- 16h 29m
- Merged PRs (30d)
- 8
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WordPress/phpdoc-parser
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
WordPress/phpdoc-parser#269 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
WordPress/phpdoc-parser#268 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
WordPress/phpdoc-parser#254 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WordPress/phpdoc-parser#246 · 9 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
WordPress/phpdoc-parser#235 · 1 comment ·
All issues in WordPress/phpdoc-parser
Similar issues
-
tooling
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
UX
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/safe-publish#594 ·