Improve incompatible trait property error message
オープン
まだ誰も着手していません。
Feature
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code results in a PHP Fatal Error:
trait FooTrait
{
private array $options = [];
}
class Foo
{
use FooTrait;
public function __construct(private array $options = []) {}
}
The error thrown is
PHP Fatal error: Foo and FooTrait define the same property ($options) in the composition of Foo. However, the definition differs and is considered incompatible.
However, the same thing defined in the class instead of in the constructor works:
trait FooTrait
{
private array $options = [];
}
class Foo
{
use FooTrait;
private array $options = [];
}
As does the same thing, but without setting a default value:
trait FooTrait
{
private array $options;
}
class Foo
{
use FooTrait;
public function __construct(private array $options) {}
}
This seems to be ane rror
PHP Version
PHP 8.1.29 to PHP 8.4.0-dev
Operating System
MAC OSX 14.7
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue ではソースファイルもテストも特定されていません。記載されている PHP バージョンで例を再現し、その後、コンストラクターでプロモートされたプロパティを含む trait のプロパティ合成を追跡してください。互換性のないプロパティの動作が修正され、回帰テストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100