From: Nikita Popov Date: Tue, 5 Jul 2016 13:51:11 +0000 (+0200) Subject: Closure::fromCallable(): Getting non-static method statically X-Git-Tag: php-7.1.0alpha3~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbe6a231942ff4cbd2f6373828cecf4744356886;p=php Closure::fromCallable(): Getting non-static method statically As this is new functionality, I'm going directly for a TypeError, rather than a deprecation warning. --- diff --git a/Zend/tests/closures/closure_from_callable_non_static_statically.phpt b/Zend/tests/closures/closure_from_callable_non_static_statically.phpt new file mode 100644 index 0000000000..17d39c052e --- /dev/null +++ b/Zend/tests/closures/closure_from_callable_non_static_statically.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing Closure::fromCallable() functionality: Getting non-static method statically +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECT-- +Failed to create closure from callable: non-static method A::method() should not be called statically diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 137e437fb9..bedf022a4b 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -322,7 +322,7 @@ ZEND_METHOD(Closure, fromCallable) success = zend_create_closure_from_callable(return_value, callable, &error); EG(current_execute_data) = execute_data; - if (success == FAILURE) { + if (success == FAILURE || error) { if (error) { zend_throw_exception_ex(zend_ce_type_error, 0, "Failed to create closure from callable: %s", error); efree(error);