Skip to content

support doc comments for internal classes and functions #13130

Closed
@ju1ius

Description

@ju1ius

Description

Hi,

I recently built a small tool 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 @returns string[], 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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions