[php-src] Issue #8421: Attributes that target functions are not valid for anonymous functions defined within a method

From: Date: Fri, 22 Apr 2022 07:12:24 +0000
Subject: [php-src] Issue #8421: Attributes that target functions are not valid for anonymous functions defined within a method
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241145@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8421 Comment Author: ollieread > Agree, I think closures should use TARGET_FUNCTION. It should > be possible to handle this with an additional check for > ZEND_ACC_CLOSURE. So if my understanding is correct, a fix for this would be; ```c ZEND_METHOD(ReflectionFunctionAbstract, getAttributes) { reflection_object *intern; zend_function *fptr; uint32_t target; GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->common.scope && ! (fptr->common.fn_flags & ZEND_ACC_CLOSURE)) { target = ZEND_ATTRIBUTE_TARGET_METHOD; } else { target = ZEND_ATTRIBUTE_TARGET_FUNCTION; } reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU, fptr->common.attributes, 0, fptr->common.scope, target, fptr->type == ZEND_USER_FUNCTION ? fptr->op_array.filename : NULL); } ``` If this is the case, I'm happy to make a PR with the changes and a test, unless somebody else would rather pick it up.

« previous php.bugs (#241145) next »