[php-src] master: `ReflectionFunctionAbstract::getDocComment()`: use `zend_function.common`

Daniel Scherzer <[email protected]> Fri, 17 Jul 2026 18:45:04 +0000
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Daniel Scherzer (DanielEScherzer)
Date: 2026-07-17T11:40:42-07:00

Commit: https://github.com/php/php-src/commit/5457092f87c7e048b9f0946a91f3f553de4a1eb3
Raw diff: https://github.com/php/php-src/commit/5457092f87c7e048b9f0946a91f3f553de4a1eb3.diff

`ReflectionFunctionAbstract::getDocComment()`: use `zend_function.common`

Internal and userland functions store their documentation comments the same
way, as a `zend_string` pointer. These pointers are part of the common elements
at the start of both `zend_op_array` and `zend_internal_function` that are made
available via `zend_function.common`; use the common access rather than
checking for the different types of functions individually.

Changed paths:
  M  ext/reflection/php_reflection.c


Diff:

diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index ea577cdea548..2e585aff34c7 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2048,12 +2048,8 @@ ZEND_METHOD(ReflectionFunctionAbstract, getDocComment)
 
 	GET_REFLECTION_OBJECT_PTR(fptr);
 
-	if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
-		RETURN_STR_COPY(fptr->op_array.doc_comment);
-	}
-
-	if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function *) fptr)->doc_comment) {
-		RETURN_STR_COPY(((zend_internal_function *) fptr)->doc_comment);
+	if (fptr->common.doc_comment) {
+		RETURN_STR_COPY(fptr->common.doc_comment);
 	}
 
 	RETURN_FALSE;