Skip to content

Awkward error using first-class callable syntax with missing function #8623

Open
@othercorey

Description

@othercorey

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions