Skip to content

Commit 18a1db2

Browse files
committed
Implement "support doc comments for internal classes and functions"
Fixes php#13130
1 parent 844c1ac commit 18a1db2

File tree

130 files changed

+4857
-4351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+4857
-4351
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*.[ch] diff=cpp
2121

2222
# Collapse generated files within git and pull request diff.
23-
**/*_arginfo.h linguist-generated -diff
23+
#**/*_arginfo.h linguist-generated -diff
2424
/Zend/zend_vm_execute.h linguist-generated -diff
2525
/Zend/zend_vm_handlers.h linguist-generated -diff
2626
/Zend/zend_vm_opcodes.[ch] linguist-generated -diff

Zend/zend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,13 @@ struct _zend_class_entry {
219219
uint32_t enum_backing_type;
220220
HashTable *backed_enum_table;
221221

222+
zend_string *doc_comment;
223+
222224
union {
223225
struct {
224226
zend_string *filename;
225227
uint32_t line_start;
226228
uint32_t line_end;
227-
zend_string *doc_comment;
228229
} user;
229230
struct {
230231
const struct _zend_function_entry *builtin_functions;

Zend/zend_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,6 +2848,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
28482848
while (ptr->fname) {
28492849
fname_len = strlen(ptr->fname);
28502850
internal_function->handler = ptr->handler;
2851+
internal_function->doc_comment = ptr->doc_comment ? zend_string_init_interned(ptr->doc_comment, strlen(ptr->doc_comment), 1) : NULL;
28512852
internal_function->function_name = zend_string_init_interned(ptr->fname, fname_len, 1);
28522853
internal_function->scope = scope;
28532854
internal_function->prototype = NULL;

Zend/zend_attributes_arginfo.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,39 @@ ZEND_METHOD(Override, __construct);
3636

3737

3838
static const zend_function_entry class_Attribute_methods[] = {
39-
ZEND_ME(Attribute, __construct, arginfo_class_Attribute___construct, ZEND_ACC_PUBLIC)
39+
ZEND_RAW_FENTRY("__construct", zim_Attribute___construct, arginfo_class_Attribute___construct, ZEND_ACC_PUBLIC, NULL)
4040
ZEND_FE_END
4141
};
4242

4343

4444
static const zend_function_entry class_ReturnTypeWillChange_methods[] = {
45-
ZEND_ME(ReturnTypeWillChange, __construct, arginfo_class_ReturnTypeWillChange___construct, ZEND_ACC_PUBLIC)
45+
ZEND_RAW_FENTRY("__construct", zim_ReturnTypeWillChange___construct, arginfo_class_ReturnTypeWillChange___construct, ZEND_ACC_PUBLIC, NULL)
4646
ZEND_FE_END
4747
};
4848

4949

5050
static const zend_function_entry class_AllowDynamicProperties_methods[] = {
51-
ZEND_ME(AllowDynamicProperties, __construct, arginfo_class_AllowDynamicProperties___construct, ZEND_ACC_PUBLIC)
51+
ZEND_RAW_FENTRY("__construct", zim_AllowDynamicProperties___construct, arginfo_class_AllowDynamicProperties___construct, ZEND_ACC_PUBLIC, NULL)
5252
ZEND_FE_END
5353
};
5454

5555

5656
static const zend_function_entry class_SensitiveParameter_methods[] = {
57-
ZEND_ME(SensitiveParameter, __construct, arginfo_class_SensitiveParameter___construct, ZEND_ACC_PUBLIC)
57+
ZEND_RAW_FENTRY("__construct", zim_SensitiveParameter___construct, arginfo_class_SensitiveParameter___construct, ZEND_ACC_PUBLIC, NULL)
5858
ZEND_FE_END
5959
};
6060

6161

6262
static const zend_function_entry class_SensitiveParameterValue_methods[] = {
63-
ZEND_ME(SensitiveParameterValue, __construct, arginfo_class_SensitiveParameterValue___construct, ZEND_ACC_PUBLIC)
64-
ZEND_ME(SensitiveParameterValue, getValue, arginfo_class_SensitiveParameterValue_getValue, ZEND_ACC_PUBLIC)
65-
ZEND_ME(SensitiveParameterValue, __debugInfo, arginfo_class_SensitiveParameterValue___debugInfo, ZEND_ACC_PUBLIC)
63+
ZEND_RAW_FENTRY("__construct", zim_SensitiveParameterValue___construct, arginfo_class_SensitiveParameterValue___construct, ZEND_ACC_PUBLIC, NULL)
64+
ZEND_RAW_FENTRY("getValue", zim_SensitiveParameterValue_getValue, arginfo_class_SensitiveParameterValue_getValue, ZEND_ACC_PUBLIC, NULL)
65+
ZEND_RAW_FENTRY("__debugInfo", zim_SensitiveParameterValue___debugInfo, arginfo_class_SensitiveParameterValue___debugInfo, ZEND_ACC_PUBLIC, NULL)
6666
ZEND_FE_END
6767
};
6868

6969

7070
static const zend_function_entry class_Override_methods[] = {
71-
ZEND_ME(Override, __construct, arginfo_class_Override___construct, ZEND_ACC_PUBLIC)
71+
ZEND_RAW_FENTRY("__construct", zim_Override___construct, arginfo_class_Override___construct, ZEND_ACC_PUBLIC, NULL)
7272
ZEND_FE_END
7373
};
7474

Zend/zend_builtin_functions_arginfo.h

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -293,66 +293,66 @@ ZEND_FUNCTION(gc_status);
293293

294294

295295
static const zend_function_entry ext_functions[] = {
296-
ZEND_FE(zend_version, arginfo_zend_version)
297-
ZEND_FE(func_num_args, arginfo_func_num_args)
298-
ZEND_FE(func_get_arg, arginfo_func_get_arg)
299-
ZEND_FE(func_get_args, arginfo_func_get_args)
300-
ZEND_FE(strlen, arginfo_strlen)
301-
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strcmp, arginfo_strcmp)
302-
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strncmp, arginfo_strncmp)
303-
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strcasecmp, arginfo_strcasecmp)
304-
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strncasecmp, arginfo_strncasecmp)
305-
ZEND_FE(error_reporting, arginfo_error_reporting)
306-
ZEND_FE(define, arginfo_define)
307-
ZEND_FE(defined, arginfo_defined)
308-
ZEND_FE(get_class, arginfo_get_class)
309-
ZEND_FE(get_called_class, arginfo_get_called_class)
310-
ZEND_FE(get_parent_class, arginfo_get_parent_class)
311-
ZEND_FE(is_subclass_of, arginfo_is_subclass_of)
312-
ZEND_FE(is_a, arginfo_is_a)
313-
ZEND_FE(get_class_vars, arginfo_get_class_vars)
314-
ZEND_FE(get_object_vars, arginfo_get_object_vars)
315-
ZEND_FE(get_mangled_object_vars, arginfo_get_mangled_object_vars)
316-
ZEND_FE(get_class_methods, arginfo_get_class_methods)
317-
ZEND_FE(method_exists, arginfo_method_exists)
296+
ZEND_RAW_FENTRY("zend_version", zif_zend_version, arginfo_zend_version, 0, NULL)
297+
ZEND_RAW_FENTRY("func_num_args", zif_func_num_args, arginfo_func_num_args, 0, NULL)
298+
ZEND_RAW_FENTRY("func_get_arg", zif_func_get_arg, arginfo_func_get_arg, 0, NULL)
299+
ZEND_RAW_FENTRY("func_get_args", zif_func_get_args, arginfo_func_get_args, 0, NULL)
300+
ZEND_RAW_FENTRY("strlen", zif_strlen, arginfo_strlen, 0, NULL)
301+
ZEND_RAW_FENTRY("strcmp", zif_strcmp, arginfo_strcmp, ZEND_ACC_COMPILE_TIME_EVAL, NULL)
302+
ZEND_RAW_FENTRY("strncmp", zif_strncmp, arginfo_strncmp, ZEND_ACC_COMPILE_TIME_EVAL, NULL)
303+
ZEND_RAW_FENTRY("strcasecmp", zif_strcasecmp, arginfo_strcasecmp, ZEND_ACC_COMPILE_TIME_EVAL, NULL)
304+
ZEND_RAW_FENTRY("strncasecmp", zif_strncasecmp, arginfo_strncasecmp, ZEND_ACC_COMPILE_TIME_EVAL, NULL)
305+
ZEND_RAW_FENTRY("error_reporting", zif_error_reporting, arginfo_error_reporting, 0, NULL)
306+
ZEND_RAW_FENTRY("define", zif_define, arginfo_define, 0, NULL)
307+
ZEND_RAW_FENTRY("defined", zif_defined, arginfo_defined, 0, NULL)
308+
ZEND_RAW_FENTRY("get_class", zif_get_class, arginfo_get_class, 0, NULL)
309+
ZEND_RAW_FENTRY("get_called_class", zif_get_called_class, arginfo_get_called_class, 0, NULL)
310+
ZEND_RAW_FENTRY("get_parent_class", zif_get_parent_class, arginfo_get_parent_class, 0, NULL)
311+
ZEND_RAW_FENTRY("is_subclass_of", zif_is_subclass_of, arginfo_is_subclass_of, 0, NULL)
312+
ZEND_RAW_FENTRY("is_a", zif_is_a, arginfo_is_a, 0, NULL)
313+
ZEND_RAW_FENTRY("get_class_vars", zif_get_class_vars, arginfo_get_class_vars, 0, NULL)
314+
ZEND_RAW_FENTRY("get_object_vars", zif_get_object_vars, arginfo_get_object_vars, 0, NULL)
315+
ZEND_RAW_FENTRY("get_mangled_object_vars", zif_get_mangled_object_vars, arginfo_get_mangled_object_vars, 0, NULL)
316+
ZEND_RAW_FENTRY("get_class_methods", zif_get_class_methods, arginfo_get_class_methods, 0, NULL)
317+
ZEND_RAW_FENTRY("method_exists", zif_method_exists, arginfo_method_exists, 0, NULL)
318318
ZEND_FRAMELESS_FE(property_exists, arginfo_property_exists, 0, frameless_function_infos_property_exists)
319319
ZEND_FRAMELESS_FE(class_exists, arginfo_class_exists, 0, frameless_function_infos_class_exists)
320-
ZEND_FE(interface_exists, arginfo_interface_exists)
321-
ZEND_FE(trait_exists, arginfo_trait_exists)
322-
ZEND_FE(enum_exists, arginfo_enum_exists)
323-
ZEND_FE(function_exists, arginfo_function_exists)
324-
ZEND_FE(class_alias, arginfo_class_alias)
325-
ZEND_FE(get_included_files, arginfo_get_included_files)
326-
ZEND_FALIAS(get_required_files, get_included_files, arginfo_get_required_files)
327-
ZEND_FE(trigger_error, arginfo_trigger_error)
328-
ZEND_FALIAS(user_error, trigger_error, arginfo_user_error)
329-
ZEND_FE(set_error_handler, arginfo_set_error_handler)
330-
ZEND_FE(restore_error_handler, arginfo_restore_error_handler)
331-
ZEND_FE(set_exception_handler, arginfo_set_exception_handler)
332-
ZEND_FE(restore_exception_handler, arginfo_restore_exception_handler)
333-
ZEND_FE(get_declared_classes, arginfo_get_declared_classes)
334-
ZEND_FE(get_declared_traits, arginfo_get_declared_traits)
335-
ZEND_FE(get_declared_interfaces, arginfo_get_declared_interfaces)
336-
ZEND_FE(get_defined_functions, arginfo_get_defined_functions)
337-
ZEND_FE(get_defined_vars, arginfo_get_defined_vars)
338-
ZEND_FE(get_resource_type, arginfo_get_resource_type)
339-
ZEND_FE(get_resource_id, arginfo_get_resource_id)
340-
ZEND_FE(get_resources, arginfo_get_resources)
341-
ZEND_FE(get_loaded_extensions, arginfo_get_loaded_extensions)
342-
ZEND_FE(get_defined_constants, arginfo_get_defined_constants)
343-
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
344-
ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace)
345-
ZEND_FE(extension_loaded, arginfo_extension_loaded)
346-
ZEND_FE(get_extension_funcs, arginfo_get_extension_funcs)
320+
ZEND_RAW_FENTRY("interface_exists", zif_interface_exists, arginfo_interface_exists, 0, NULL)
321+
ZEND_RAW_FENTRY("trait_exists", zif_trait_exists, arginfo_trait_exists, 0, NULL)
322+
ZEND_RAW_FENTRY("enum_exists", zif_enum_exists, arginfo_enum_exists, 0, NULL)
323+
ZEND_RAW_FENTRY("function_exists", zif_function_exists, arginfo_function_exists, 0, NULL)
324+
ZEND_RAW_FENTRY("class_alias", zif_class_alias, arginfo_class_alias, 0, NULL)
325+
ZEND_RAW_FENTRY("get_included_files", zif_get_included_files, arginfo_get_included_files, 0, NULL)
326+
ZEND_RAW_FENTRY("get_required_files", zif_get_included_files, arginfo_get_required_files, 0, NULL)
327+
ZEND_RAW_FENTRY("trigger_error", zif_trigger_error, arginfo_trigger_error, 0, NULL)
328+
ZEND_RAW_FENTRY("user_error", zif_trigger_error, arginfo_user_error, 0, NULL)
329+
ZEND_RAW_FENTRY("set_error_handler", zif_set_error_handler, arginfo_set_error_handler, 0, NULL)
330+
ZEND_RAW_FENTRY("restore_error_handler", zif_restore_error_handler, arginfo_restore_error_handler, 0, NULL)
331+
ZEND_RAW_FENTRY("set_exception_handler", zif_set_exception_handler, arginfo_set_exception_handler, 0, NULL)
332+
ZEND_RAW_FENTRY("restore_exception_handler", zif_restore_exception_handler, arginfo_restore_exception_handler, 0, NULL)
333+
ZEND_RAW_FENTRY("get_declared_classes", zif_get_declared_classes, arginfo_get_declared_classes, 0, NULL)
334+
ZEND_RAW_FENTRY("get_declared_traits", zif_get_declared_traits, arginfo_get_declared_traits, 0, NULL)
335+
ZEND_RAW_FENTRY("get_declared_interfaces", zif_get_declared_interfaces, arginfo_get_declared_interfaces, 0, NULL)
336+
ZEND_RAW_FENTRY("get_defined_functions", zif_get_defined_functions, arginfo_get_defined_functions, 0, NULL)
337+
ZEND_RAW_FENTRY("get_defined_vars", zif_get_defined_vars, arginfo_get_defined_vars, 0, NULL)
338+
ZEND_RAW_FENTRY("get_resource_type", zif_get_resource_type, arginfo_get_resource_type, 0, NULL)
339+
ZEND_RAW_FENTRY("get_resource_id", zif_get_resource_id, arginfo_get_resource_id, 0, NULL)
340+
ZEND_RAW_FENTRY("get_resources", zif_get_resources, arginfo_get_resources, 0, NULL)
341+
ZEND_RAW_FENTRY("get_loaded_extensions", zif_get_loaded_extensions, arginfo_get_loaded_extensions, 0, NULL)
342+
ZEND_RAW_FENTRY("get_defined_constants", zif_get_defined_constants, arginfo_get_defined_constants, 0, NULL)
343+
ZEND_RAW_FENTRY("debug_backtrace", zif_debug_backtrace, arginfo_debug_backtrace, 0, NULL)
344+
ZEND_RAW_FENTRY("debug_print_backtrace", zif_debug_print_backtrace, arginfo_debug_print_backtrace, 0, NULL)
345+
ZEND_RAW_FENTRY("extension_loaded", zif_extension_loaded, arginfo_extension_loaded, 0, NULL)
346+
ZEND_RAW_FENTRY("get_extension_funcs", zif_get_extension_funcs, arginfo_get_extension_funcs, 0, NULL)
347347
#if ZEND_DEBUG && defined(ZTS)
348-
ZEND_FE(zend_thread_id, arginfo_zend_thread_id)
348+
ZEND_RAW_FENTRY("zend_thread_id", zif_zend_thread_id, arginfo_zend_thread_id, 0, NULL)
349349
#endif
350-
ZEND_FE(gc_mem_caches, arginfo_gc_mem_caches)
351-
ZEND_FE(gc_collect_cycles, arginfo_gc_collect_cycles)
352-
ZEND_FE(gc_enabled, arginfo_gc_enabled)
353-
ZEND_FE(gc_enable, arginfo_gc_enable)
354-
ZEND_FE(gc_disable, arginfo_gc_disable)
355-
ZEND_FE(gc_status, arginfo_gc_status)
350+
ZEND_RAW_FENTRY("gc_mem_caches", zif_gc_mem_caches, arginfo_gc_mem_caches, 0, NULL)
351+
ZEND_RAW_FENTRY("gc_collect_cycles", zif_gc_collect_cycles, arginfo_gc_collect_cycles, 0, NULL)
352+
ZEND_RAW_FENTRY("gc_enabled", zif_gc_enabled, arginfo_gc_enabled, 0, NULL)
353+
ZEND_RAW_FENTRY("gc_enable", zif_gc_enable, arginfo_gc_enable, 0, NULL)
354+
ZEND_RAW_FENTRY("gc_disable", zif_gc_disable, arginfo_gc_disable, 0, NULL)
355+
ZEND_RAW_FENTRY("gc_status", zif_gc_status, arginfo_gc_status, 0, NULL)
356356
ZEND_FE_END
357357
};
358358

Zend/zend_closures_arginfo.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ ZEND_METHOD(Closure, fromCallable);
3333

3434

3535
static const zend_function_entry class_Closure_methods[] = {
36-
ZEND_ME(Closure, __construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE)
37-
ZEND_ME(Closure, bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
38-
ZEND_ME(Closure, bindTo, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC)
39-
ZEND_ME(Closure, call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC)
40-
ZEND_ME(Closure, fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
36+
ZEND_RAW_FENTRY("__construct", zim_Closure___construct, arginfo_class_Closure___construct, ZEND_ACC_PRIVATE, NULL)
37+
ZEND_RAW_FENTRY("bind", zim_Closure_bind, arginfo_class_Closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL)
38+
ZEND_RAW_FENTRY("bindTo", zim_Closure_bindTo, arginfo_class_Closure_bindTo, ZEND_ACC_PUBLIC, NULL)
39+
ZEND_RAW_FENTRY("call", zim_Closure_call, arginfo_class_Closure_call, ZEND_ACC_PUBLIC, NULL)
40+
ZEND_RAW_FENTRY("fromCallable", zim_Closure_fromCallable, arginfo_class_Closure_fromCallable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL)
4141
ZEND_FE_END
4242
};
4343

Zend/zend_compile.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,9 +2001,8 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_hand
20012001
zend_hash_init(&ce->constants_table, 8, NULL, NULL, persistent_hashes);
20022002
zend_hash_init(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes);
20032003

2004-
if (ce->type == ZEND_USER_CLASS) {
2005-
ce->info.user.doc_comment = NULL;
2006-
}
2004+
ce->doc_comment = NULL;
2005+
20072006
ZEND_MAP_PTR_INIT(ce->static_members_table, NULL);
20082007
ZEND_MAP_PTR_INIT(ce->mutable_data, NULL);
20092008

@@ -8278,7 +8277,7 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
82788277
ce->info.user.line_end = decl->end_lineno;
82798278

82808279
if (decl->doc_comment) {
8281-
ce->info.user.doc_comment = zend_string_copy(decl->doc_comment);
8280+
ce->doc_comment = zend_string_copy(decl->doc_comment);
82828281
}
82838282

82848283
if (UNEXPECTED((decl->flags & ZEND_ACC_ANON_CLASS))) {

Zend/zend_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ typedef struct _zend_internal_function {
520520
uint32_t num_args;
521521
uint32_t required_num_args;
522522
zend_internal_arg_info *arg_info;
523+
zend_string *doc_comment;
523524
HashTable *attributes;
524525
ZEND_MAP_PTR_DEF(void **, run_time_cache);
525526
uint32_t T; /* number of temporary variables */

Zend/zend_enum_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ ZEND_END_ARG_INFO()
1616

1717

1818
static const zend_function_entry class_UnitEnum_methods[] = {
19-
ZEND_ABSTRACT_ME_WITH_FLAGS(UnitEnum, cases, arginfo_class_UnitEnum_cases, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT)
19+
ZEND_RAW_FENTRY("cases", NULL, arginfo_class_UnitEnum_cases, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT, NULL)
2020
ZEND_FE_END
2121
};
2222

2323

2424
static const zend_function_entry class_BackedEnum_methods[] = {
25-
ZEND_ABSTRACT_ME_WITH_FLAGS(BackedEnum, from, arginfo_class_BackedEnum_from, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT)
26-
ZEND_ABSTRACT_ME_WITH_FLAGS(BackedEnum, tryFrom, arginfo_class_BackedEnum_tryFrom, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT)
25+
ZEND_RAW_FENTRY("from", NULL, arginfo_class_BackedEnum_from, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT, NULL)
26+
ZEND_RAW_FENTRY("tryFrom", NULL, arginfo_class_BackedEnum_tryFrom, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT, NULL)
2727
ZEND_FE_END
2828
};
2929

0 commit comments

Comments
 (0)