Skip to content

First class callable syntax supported for functions and methods #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 8, 2024

Conversation

spaze
Copy link
Owner

@spaze spaze commented Dec 8, 2024

This is the syntax supported by PHP 8.1:

$func = print_r(...);
$func();

or

$obj = new Object();
$func = $obj->method(...);
$func();

or

$func = Class::method(...);
$func();

The errors for the disallowed code are reported on lines with (...), not when the callable is called.

Ref #275

spaze added 3 commits December 8, 2024 02:46
This is the syntax supported by PHP 8.1:
```
$callable = print_r(...);
$callable(42);
```
or
```
$blade = new \Waldo\Quux\Blade();
$callable = $blade->runner(...);
$callable(303);
```

The errors for the disallowed code are reported on lines with `(...)`, not when the callable is called.

Ref #275
@spaze spaze self-assigned this Dec 8, 2024
@spaze spaze merged commit 9fdeff6 into main Dec 8, 2024
124 checks passed
@spaze spaze deleted the spaze/first-class-callable-syntax branch December 8, 2024 05:13
spaze added a commit that referenced this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant