in return type class with __invoke method is not a callable
オープン
まだ誰も着手していません。
Category: Engine
Feature
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
interface I {
public function test(): callable;
}
class Invokable {
public function __invoke() {}
}
var_dump(is_callable(new Invokable()));
class C implements I {
public function test(): Invokable {}
}
Resulted in this output:
bool(true)
Fatal error: Declaration of C::test(): Invokable must be compatible with I::test(): callable in /in/PfBWX on line 10
Process exited with code 255.
Methods should be able to restrict callable return types from interfaces and parent classes to more specific types that unconditionally fall within the callable type. Any class or interface that contains an __invoke method should be considered a callable type an be allowed as a more specific subtype of callable in subclasses. Also \Closure should be allowed as well.
PHP Version
8.4.5
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず issue の PHP reproducer を実行し、戻り値型の互換性が callable 型とクラス型をどのように扱うかを調べます。__invoke と Closure を持つクラスを callable 宣言のより狭い戻り値型として受け入れられるようになり、報告されたケースをカバーする互換性テストが追加された時点で issue は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100