-
Notifications
You must be signed in to change notification settings - Fork 8k
first class callable conversion #7019
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
Conversation
|
Would it make sense to update zend_undefined_function_helper (etc) to indicate that it is creating a closure from an undefined function (etc) rather than calling the function at the time the error is thrown? The current implementation: ZEND_VM_COLD_HELPER(zend_undefined_function_helper, ANY, ANY)
{
USE_OPLINE
zval *function_name;
SAVE_OPLINE();
function_name = RT_CONSTANT(opline, opline->op2);
zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(function_name));
HANDLE_EXCEPTION();
} |
|
@TysonAndre Having a more specific error message would be nice, but it wouldn't be as simple as changing that one place. For example, the error for calling an inaccessible method is generated in the get_method object handler, and I don't think we want to thread information about what kind of "call" it is through there. Possibly we could make the message more generic so it would work in both situations, for example:
Though maybe that makes the message in the common case slightly harder to understand. |
161b714 to
fe21832
Compare
|
Please improve also dump of Closure to contain the specific method/function name. https://3v4l.org/SjSnR |
5635d27 to
3fcece3
Compare
|
I added some more test coverage. Anything still missing? |
2336613 to
7a3ac9f
Compare
Fix acquiring callable to assert() in namespace, and also add support for (...) to the AST printer.
I wasn't able to make this work with tracing JIT quickly.
Does not necessarily hold (e.g. exit in call args).
7a3ac9f to
f3af1d4
Compare
> Closures for callables can now be created using the syntax `myFunc(...)`, which is identical to `Closure::fromCallable('myFunc')`.
Refs:
* https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.core.callable-syntax
* https://wiki.php.net/rfc/first_class_callable_syntax
* php/php-src#7019
* php/php-src@d0b09a7
Includes unit tests.
Includes sniff documentation.
> Closures for callables can now be created using the syntax `myFunc(...)`, which is identical to `Closure::fromCallable('myFunc')`.
Refs:
* https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.core.callable-syntax
* https://wiki.php.net/rfc/first_class_callable_syntax
* php/php-src#7019
* php/php-src@d0b09a7
Includes unit tests.
Includes sniff documentation.
Impl for https://wiki.php.net/rfc/first_class_callable_syntax