Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

classes that specify visibility on class constants can't be parsed

オープン
#224 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
php

調査の方向性

nikic/php-parser と phpdocumentor/reflection に関係する Composer の依存関係を調査し、issue にあるクラス定数の例で失敗を再現してください。依存関係の更新によって public および protected のクラス定数をパースできることと、既存の parser の動作が維持されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
PHP
スター
239
フォーク
81
平均マージ
16時間 29分
マージ済み PR(30日)
8

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WordPress/phpdoc-parser のほかの issue

WordPress/phpdoc-parser の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。