Deprecation errors are inconsistently triggered for underscore class aliases
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
namespace Foo {
class __ {}
}
namespace Bar {
class _ {} // Deprecated
}
namespace {
class __ {}
class_alias('Foo\__', 'Foo\_'); // Is this meant to be deprecated?
class_alias('__', '_'); // Deprecated
}
namespace Baz {
use Foo\_;
}
namespace Qux {
use Foo\__ as _; // Is this meant to be deprecated?
}
Resulted in this output:
Deprecated: Using "_" as a class name is deprecated since 8.4 in /in/ZZMJs on line 8
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 15
But I expected this output instead:
Deprecated: Using "_" as a class name is deprecated since 8.4 in /in/ZZMJs on line 8
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 14
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 15
Deprecated: Using "_" as a class alias is deprecated since 8.4 in /in/ZZMJs on line 23
I encountered this issue while trying to migrate a large closed source project to PHP 8.4. The namespaced _ class was used as a wrapper for the gettext _ function (eg new _("string")), to delay performing the translation of cached content until the http response is stringified. The class had ~35k instantiations in source control and more instances in compressed + serialized database records. This made class aliases a potentially appealing solution, but I understand from @Girgias that these not emitting deprecation errors is an oversight.
PHP Version
8.4.1 - 8.4.6 on 3v4l
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された PHP 8.4 の再現コードを実行し、クラス宣言、class_alias() の呼び出し、namespaced use alias に対する deprecation の動作を比較します。次に、クラスエイリアスと namespace import を処理するインタープリターの経路を追跡し、想定される 4 つすべてのアンダースコアケースで deprecation が発生することを示すリグレッションテストのカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100