php / php/php-src

Awkward error using first-class callable syntax with missing function

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

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

Bug Category: Engine Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

The following code:

<?php

'missing'(...);

Resulted in this output:

Fatal error: Uncaught Error: Call to undefined function missing() 

But I expected this output instead:

Fatal error: Uncaught Error: Unable to create closure from undefined function missing() 

When using the first-class callable syntax on a missing function, the error message claims the user is calling a function. However, this should only be creating a closure.

I thought the (...) syntax would only try to create a closure. Does it actually try to call the function with a ... argument if it's not found?

If you use the original Closure::fromCallable() method, the error is different.

Closure::fromCallable('missing');
Uncaught TypeError: Failed to create closure from callable: function "missing" not found or invalid function name
PHP Version

8.1

Operating System

No response

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

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

はじめの一歩

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

調査の方向性

まず、'missing'(...); を使った PHP 8.1 の例を再現し、そのエラーを Closure::fromCallable('missing') と比較します。未定義の関数に対する first-class callable の処理を追跡します。構文が関数が呼び出されたと主張するのではなく、クロージャ作成エラーを報告すれば完了です。

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

評価

技術スタック
php
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

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

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