-
Notifications
You must be signed in to change notification settings - Fork 79
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.