mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: [ci skip] NEWS [ci skip] NEWS Add tests Fix GH-8932: Provide a way to get the called-scope of closures (#9299)
This commit is contained in:
commit
dcde9b85a6
4 changed files with 138 additions and 1 deletions
|
@ -1701,6 +1701,28 @@ ZEND_METHOD(ReflectionFunctionAbstract, getClosureScopeClass)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Returns the called scope associated to the closure */
|
||||
ZEND_METHOD(ReflectionFunctionAbstract, getClosureCalledClass)
|
||||
{
|
||||
reflection_object *intern;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
GET_REFLECTION_OBJECT();
|
||||
if (!Z_ISUNDEF(intern->obj)) {
|
||||
zend_class_entry *called_scope;
|
||||
zend_function *closure_func;
|
||||
zend_object *object;
|
||||
if (Z_OBJ_HANDLER(intern->obj, get_closure)
|
||||
&& Z_OBJ_HANDLER(intern->obj, get_closure)(Z_OBJ(intern->obj), &called_scope, &closure_func, &object, 1) == SUCCESS
|
||||
&& closure_func && (called_scope || closure_func->common.scope)) {
|
||||
zend_reflection_class_factory(called_scope ? (zend_class_entry *) called_scope : closure_func->common.scope, return_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Returns an associative array containing the closures lexical scope variables */
|
||||
ZEND_METHOD(ReflectionFunctionAbstract, getClosureUsedVariables)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue