Hard to figure out from an error message where incompatible method declarations meet
@derickr がすでに取り組んでいます。
2023年8月31日 から。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
When we launch a PHP application, we might get a similar message:
Fatal error: Declaration of Baz::getId(): mixed must be compatible with Foo::getId(): int in /tmp/preview on line 13
When we look up the declarations of these methods, we get this:
interface Foo
{
public function getId(): int;
}
abstract class Baz
{
public function getId(): mixed
{
//...
}
}
They have nothing in common, their existence on their own shouldn't be a problem for our application.
The problem is when they meet via a common child that both extends Baz and implements Foo:
class Lorem extends Baz implements Foo
{
}
The problem is that we don't learn about Lorem from the PHP error message which makes it really hard to find Loremin a large application.
Personally I solved it by enabling Xdebug in develop mode and looking at the stack trace. One (or both) of these two things would help to debug this problem in the future:
- Show fatal error stack trace in PHP out of the box, without requiring Xdebug.
- Somehow include
Loremtoo in this error message:Fatal error: Declaration of Baz::getId(): mixed must be compatible with Foo::getId(): int in /tmp/preview on line 13
3v4l.org link: https://3v4l.org/4iOYG
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。