[php-src] Issue #13130: support doc comments for internal classes and functions
| From: | ju1ius | Date: | Fri, 12 Jan 2024 09:44:54 +0000 |
| Subject: | [php-src] Issue #13130: support doc comments for internal classes and functions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246249@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13130
Author: ju1ius
### Description
Hi,
I recently built [a small tool](https://github.com/souplette-php/chicot) that generates IDE stubs
for an extension module using the runtime Reflection API.
However, since the
zend_internal_function and
zend_class_entry.info.internal structs don't currently hold a zend_string*
doc_comment field like their userland counterparts,
ReflectionFunctionAbstract::getDocComment() and
ReflectionClass::getDocComment() always return the empty string for internal
functions/methods and classes.
It is thus currently impossible for this tool to include doc comments for internal classes and
function/methods in the generated stubs (which, in addition to plain-text documentation, is also
useful for i.e. specifiying @throws annotations, generic type overrides like
@param string[] $arg, etc).
A zend_internal_function is currently much smaller than a zend_op_array,
so there's definitely room in here to stash a zend_string* pointer. The size of
zend_class_entry.info.user is currently 24 bytes on 64bit platforms, and
zend_class_entry.info.internal is 16, so there's just enough room for an
additional pointer.
Note that having this feature would not only be beneficial for the aforementioned tool. For example
when encountering an unknown extension, an LSP server could now fetch all needed informations using
runtime reflection.
Is this something that could be considered?