You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
For example,
Trying the parse the above results in an error like:
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:
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 ofphpdocumentor/reflection
. The latest version ofnikic/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.The text was updated successfully, but these errors were encountered: