Skip to content

Commit 4c6533c

Browse files
committed
Generate class entries from stubs for com, standard, xmlreader, xmlwriter, xsl, zip, Zend
Closes GH-6706
1 parent d03be8b commit 4c6533c

39 files changed

+345
-125
lines changed

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
/* }}} */
3333

3434
ZEND_MINIT_FUNCTION(core) { /* {{{ */
35-
zend_class_entry class_entry;
36-
37-
INIT_CLASS_ENTRY(class_entry, "stdClass", NULL);
38-
zend_standard_class_def = zend_register_internal_class(&class_entry);
35+
zend_standard_class_def = register_class_stdClass();
3936

4037
zend_register_default_classes();
4138

Zend/zend_builtin_functions.stub.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
/** @generate-class-entries */
44

5+
class stdClass
6+
{
7+
}
8+
59
function zend_version(): string {}
610

711
function func_num_args(): int {}

Zend/zend_builtin_functions_arginfo.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: b2216a294367f50c8b6208653ebf6fa43dc106d1 */
2+
* Stub hash: 429fc9b22054348101d0b9d6746494e52dc04edf */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
55
ZEND_END_ARG_INFO()
@@ -333,3 +333,18 @@ static const zend_function_entry ext_functions[] = {
333333
ZEND_FE(gc_status, arginfo_gc_status)
334334
ZEND_FE_END
335335
};
336+
337+
338+
static const zend_function_entry class_stdClass_methods[] = {
339+
ZEND_FE_END
340+
};
341+
342+
static zend_class_entry *register_class_stdClass(void)
343+
{
344+
zend_class_entry ce, *class_entry;
345+
346+
INIT_CLASS_ENTRY(ce, "stdClass", class_stdClass_methods);
347+
class_entry = zend_register_internal_class_ex(&ce, NULL);
348+
349+
return class_entry;
350+
}

ext/com_dotnet/com_extension.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,40 +159,33 @@ static PHP_GINIT_FUNCTION(com_dotnet)
159159
/* {{{ PHP_MINIT_FUNCTION */
160160
PHP_MINIT_FUNCTION(com_dotnet)
161161
{
162-
zend_class_entry ce, *tmp;
162+
zend_class_entry *tmp;
163163

164164
php_com_wrapper_minit(INIT_FUNC_ARGS_PASSTHRU);
165165
php_com_persist_minit(INIT_FUNC_ARGS_PASSTHRU);
166166

167-
INIT_CLASS_ENTRY(ce, "com_exception", NULL);
168-
php_com_exception_class_entry = zend_register_internal_class_ex(&ce, zend_ce_exception);
169-
php_com_exception_class_entry->ce_flags |= ZEND_ACC_FINAL;
167+
php_com_exception_class_entry = register_class_com_exception(zend_ce_exception);
170168
/* php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; */
171169

172-
INIT_CLASS_ENTRY(ce, "com_safearray_proxy", NULL);
173-
php_com_saproxy_class_entry = zend_register_internal_class(&ce);
174-
php_com_saproxy_class_entry->ce_flags |= ZEND_ACC_FINAL;
170+
php_com_saproxy_class_entry = register_class_com_safearray_proxy();
175171
/* php_com_saproxy_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED; */
176172
php_com_saproxy_class_entry->get_iterator = php_com_saproxy_iter_get;
177173

178-
INIT_CLASS_ENTRY(ce, "variant", class_variant_methods);
179-
ce.create_object = php_com_object_new;
180-
php_com_variant_class_entry = zend_register_internal_class(&ce);
174+
php_com_variant_class_entry = register_class_variant();
175+
php_com_variant_class_entry->create_object = php_com_object_new;
181176
php_com_variant_class_entry->get_iterator = php_com_iter_get;
182177
php_com_variant_class_entry->serialize = zend_class_serialize_deny;
183178
php_com_variant_class_entry->unserialize = zend_class_unserialize_deny;
184179

185-
INIT_CLASS_ENTRY(ce, "com", class_com_methods);
186-
ce.create_object = php_com_object_new;
187-
tmp = zend_register_internal_class_ex(&ce, php_com_variant_class_entry);
180+
tmp = register_class_com(php_com_variant_class_entry);
181+
tmp->create_object = php_com_object_new;
188182
tmp->get_iterator = php_com_iter_get;
189183
tmp->serialize = zend_class_serialize_deny;
190184
tmp->unserialize = zend_class_unserialize_deny;
191185

192186
#if HAVE_MSCOREE_H
193-
INIT_CLASS_ENTRY(ce, "dotnet", class_dotnet_methods);
194-
ce.create_object = php_com_object_new;
195-
tmp = zend_register_internal_class_ex(&ce, php_com_variant_class_entry);
187+
tmp = register_class_dotnet(php_com_variant_class_entry);
188+
tmp->create_object = php_com_object_new;
196189
tmp->get_iterator = php_com_iter_get;
197190
tmp->serialize = zend_class_serialize_deny;
198191
tmp->unserialize = zend_class_unserialize_deny;

ext/com_dotnet/com_extension.stub.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/** @generate-function-entries */
3+
/** @generate-class-entries */
44

55
function variant_set(variant $variant, mixed $value): void {}
66

@@ -71,18 +71,22 @@ class variant
7171
public function __construct(mixed $value = null, int $type = VT_EMPTY, int $codepage = CP_ACP) {}
7272
}
7373

74-
class com
74+
class com extends variant
7575
{
7676
public function __construct(string $module_name, array|string|null $server_name = null, int $codepage = CP_ACP, string $typelib = "") {}
7777
}
7878

7979
#if HAVE_MSCOREE_H
80-
class dotnet
80+
class dotnet extends variant
8181
{
8282
public function __construct(string $assembly_name, string $datatype_name, int $codepage = CP_ACP) {}
8383
}
8484
#endif
8585

86-
final class com_exception extends exception
86+
final class com_safearray_proxy
87+
{
88+
}
89+
90+
final class com_exception extends Exception
8791
{
8892
}

ext/com_dotnet/com_extension_arginfo.h

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 6b162963bcceb90144fdd3165137fb567f916812 */
2+
* Stub hash: ba77cee0a718bcbe7ac280f07a41f9e97a8e2246 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_set, 0, 2, IS_VOID, 0)
55
ZEND_ARG_OBJ_INFO(0, variant, variant, 0)
@@ -228,6 +228,63 @@ static const zend_function_entry class_dotnet_methods[] = {
228228
};
229229

230230

231+
static const zend_function_entry class_com_safearray_proxy_methods[] = {
232+
ZEND_FE_END
233+
};
234+
235+
231236
static const zend_function_entry class_com_exception_methods[] = {
232237
ZEND_FE_END
233238
};
239+
240+
static zend_class_entry *register_class_variant(void)
241+
{
242+
zend_class_entry ce, *class_entry;
243+
244+
INIT_CLASS_ENTRY(ce, "variant", class_variant_methods);
245+
class_entry = zend_register_internal_class_ex(&ce, NULL);
246+
247+
return class_entry;
248+
}
249+
250+
static zend_class_entry *register_class_com(zend_class_entry *class_entry_variant)
251+
{
252+
zend_class_entry ce, *class_entry;
253+
254+
INIT_CLASS_ENTRY(ce, "com", class_com_methods);
255+
class_entry = zend_register_internal_class_ex(&ce, class_entry_variant);
256+
257+
return class_entry;
258+
}
259+
260+
static zend_class_entry *register_class_dotnet(zend_class_entry *class_entry_variant)
261+
{
262+
zend_class_entry ce, *class_entry;
263+
264+
INIT_CLASS_ENTRY(ce, "dotnet", class_dotnet_methods);
265+
class_entry = zend_register_internal_class_ex(&ce, class_entry_variant);
266+
267+
return class_entry;
268+
}
269+
270+
static zend_class_entry *register_class_com_safearray_proxy(void)
271+
{
272+
zend_class_entry ce, *class_entry;
273+
274+
INIT_CLASS_ENTRY(ce, "com_safearray_proxy", class_com_safearray_proxy_methods);
275+
class_entry = zend_register_internal_class_ex(&ce, NULL);
276+
class_entry->ce_flags |= ZEND_ACC_FINAL;
277+
278+
return class_entry;
279+
}
280+
281+
static zend_class_entry *register_class_com_exception(zend_class_entry *class_entry_Exception)
282+
{
283+
zend_class_entry ce, *class_entry;
284+
285+
INIT_CLASS_ENTRY(ce, "com_exception", class_com_exception_methods);
286+
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
287+
class_entry->ce_flags |= ZEND_ACC_FINAL;
288+
289+
return class_entry;
290+
}

ext/com_dotnet/com_persist.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -721,16 +721,12 @@ static zend_object* helper_new(zend_class_entry *ce)
721721

722722
int php_com_persist_minit(INIT_FUNC_ARGS)
723723
{
724-
zend_class_entry ce;
725-
726724
memcpy(&helper_handlers, &std_object_handlers, sizeof(helper_handlers));
727725
helper_handlers.free_obj = helper_free_storage;
728726
helper_handlers.clone_obj = helper_clone;
729727

730-
INIT_CLASS_ENTRY(ce, "COMPersistHelper", class_COMPersistHelper_methods);
731-
ce.create_object = helper_new;
732-
helper_ce = zend_register_internal_class(&ce);
733-
helper_ce->ce_flags |= ZEND_ACC_FINAL;
728+
helper_ce = register_class_COMPersistHelper();
729+
helper_ce->create_object = helper_new;
734730

735731
le_istream = zend_register_list_destructors_ex(istream_dtor,
736732
NULL, "com_dotnet_istream_wrapper", module_number);

ext/com_dotnet/com_persist.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/** @generate-function-entries */
3+
/** @generate-class-entries */
44

55
final class COMPersistHelper
66
{

ext/com_dotnet/com_persist_arginfo.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 2c2759e6c1894713439e3ee8da7f56810d00d8cf */
2+
* Stub hash: d14d30fb232f08da37ba0df0b9186eb8bac5e1a4 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_COMPersistHelper___construct, 0, 0, 0)
55
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, variant, variant, 1, "null")
@@ -52,3 +52,14 @@ static const zend_function_entry class_COMPersistHelper_methods[] = {
5252
ZEND_ME(COMPersistHelper, SaveToStream, arginfo_class_COMPersistHelper_SaveToStream, ZEND_ACC_PUBLIC)
5353
ZEND_FE_END
5454
};
55+
56+
static zend_class_entry *register_class_COMPersistHelper(void)
57+
{
58+
zend_class_entry ce, *class_entry;
59+
60+
INIT_CLASS_ENTRY(ce, "COMPersistHelper", class_COMPersistHelper_methods);
61+
class_entry = zend_register_internal_class_ex(&ce, NULL);
62+
class_entry->ce_flags |= ZEND_ACC_FINAL;
63+
64+
return class_entry;
65+
}

ext/dom/php_dom.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc);
132132
void dom_parent_node_before(dom_object *context, zval *nodes, int nodesc);
133133
void dom_child_node_remove(dom_object *context);
134134

135-
#define REGISTER_DOM_CLASS(ce, name, parent_ce, funcs, entry) \
136-
INIT_CLASS_ENTRY(ce, name, funcs); \
137-
ce.create_object = dom_objects_new; \
138-
entry = zend_register_internal_class_ex(&ce, parent_ce);
139-
140135
#define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \
141136
__intern = Z_DOMOBJ_P(__id); \
142137
if (__intern->ptr == NULL || !(__ptr = (__prtype)((php_libxml_node_ptr *)__intern->ptr)->node)) { \

ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Felix De Vliegher <felix.devliegher@gmail.com>
77
$standard = new ReflectionExtension('standard');
88
var_dump($standard->getClassNames());
99
?>
10-
--EXPECTF--
10+
--EXPECT--
1111
array(4) {
1212
[0]=>
13-
%s(22) "__PHP_Incomplete_Class"
13+
string(22) "__PHP_Incomplete_Class"
1414
[1]=>
15-
%s(15) "php_user_filter"
15+
string(14) "AssertionError"
1616
[2]=>
17-
%s(9) "Directory"
17+
string(15) "php_user_filter"
1818
[3]=>
19-
%s(14) "AssertionError"
19+
string(9) "Directory"
2020
}

ext/standard/assert.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ ZEND_END_MODULE_GLOBALS(assert)
3232

3333
ZEND_DECLARE_MODULE_GLOBALS(assert)
3434

35-
static zend_class_entry *assertion_error_ce;
36-
3735
#define ASSERTG(v) ZEND_MODULE_GLOBALS_ACCESSOR(assert, v)
3836

3937
#define SAFE_STRING(s) ((s)?(s):"")
@@ -46,6 +44,8 @@ enum {
4644
ASSERT_EXCEPTION
4745
};
4846

47+
PHPAPI zend_class_entry *assertion_error_ce;
48+
4949
static PHP_INI_MH(OnChangeCallback) /* {{{ */
5050
{
5151
if (EG(current_execute_data)) {
@@ -89,8 +89,6 @@ static void php_assert_init_globals(zend_assert_globals *assert_globals_p) /* {{
8989

9090
PHP_MINIT_FUNCTION(assert) /* {{{ */
9191
{
92-
zend_class_entry ce;
93-
9492
ZEND_INIT_MODULE_GLOBALS(assert, php_assert_init_globals, NULL);
9593

9694
REGISTER_INI_ENTRIES();
@@ -101,9 +99,6 @@ PHP_MINIT_FUNCTION(assert) /* {{{ */
10199
REGISTER_LONG_CONSTANT("ASSERT_WARNING", ASSERT_WARNING, CONST_CS|CONST_PERSISTENT);
102100
REGISTER_LONG_CONSTANT("ASSERT_EXCEPTION", ASSERT_EXCEPTION, CONST_CS|CONST_PERSISTENT);
103101

104-
INIT_CLASS_ENTRY(ce, "AssertionError", NULL);
105-
assertion_error_ce = zend_register_internal_class_ex(&ce, zend_ce_error);
106-
107102
return SUCCESS;
108103
}
109104
/* }}} */

ext/standard/basic_functions.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
283283
#endif
284284
#endif
285285

286-
php_register_incomplete_class();
286+
php_ce_incomplete_class = register_class___PHP_Incomplete_Class();
287+
php_register_incomplete_class_handlers();
288+
289+
assertion_error_ce = register_class_AssertionError(zend_ce_error);
287290

288291
REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT);
289292
REGISTER_LONG_CONSTANT("CONNECTION_NORMAL", PHP_CONNECTION_NORMAL, CONST_CS | CONST_PERSISTENT);

ext/standard/basic_functions.stub.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
22

3-
/** @generate-function-entries */
3+
/** @generate-class-entries */
4+
5+
final class __PHP_Incomplete_Class
6+
{
7+
}
8+
9+
class AssertionError extends Error
10+
{
11+
}
412

513
/* main/main.c */
614

ext/standard/basic_functions_arginfo.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: e9f39cbc595f0f2cdd84e58d4857f9fdb03ff7b7 */
2+
* Stub hash: 97edf8c87780c892984099e52ad1c6c745b919f8 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
55
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
@@ -3491,3 +3491,34 @@ static const zend_function_entry ext_functions[] = {
34913491
#endif
34923492
ZEND_FE_END
34933493
};
3494+
3495+
3496+
static const zend_function_entry class___PHP_Incomplete_Class_methods[] = {
3497+
ZEND_FE_END
3498+
};
3499+
3500+
3501+
static const zend_function_entry class_AssertionError_methods[] = {
3502+
ZEND_FE_END
3503+
};
3504+
3505+
static zend_class_entry *register_class___PHP_Incomplete_Class(void)
3506+
{
3507+
zend_class_entry ce, *class_entry;
3508+
3509+
INIT_CLASS_ENTRY(ce, "__PHP_Incomplete_Class", class___PHP_Incomplete_Class_methods);
3510+
class_entry = zend_register_internal_class_ex(&ce, NULL);
3511+
class_entry->ce_flags |= ZEND_ACC_FINAL;
3512+
3513+
return class_entry;
3514+
}
3515+
3516+
static zend_class_entry *register_class_AssertionError(zend_class_entry *class_entry_Error)
3517+
{
3518+
zend_class_entry ce, *class_entry;
3519+
3520+
INIT_CLASS_ENTRY(ce, "AssertionError", class_AssertionError_methods);
3521+
class_entry = zend_register_internal_class_ex(&ce, class_entry_Error);
3522+
3523+
return class_entry;
3524+
}

0 commit comments

Comments
 (0)