Skip to content

Commit 618f559

Browse files
committed
Convert spl functions arginfo to php stubs
1 parent f826bbd commit 618f559

File tree

3 files changed

+101
-71
lines changed

3 files changed

+101
-71
lines changed

ext/spl/php_spl.c

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "php_main.h"
2424
#include "ext/standard/info.h"
2525
#include "php_spl.h"
26+
#include "php_spl_arginfo.h"
2627
#include "spl_functions.h"
2728
#include "spl_engine.h"
2829
#include "spl_array.h"
@@ -892,76 +893,6 @@ PHP_MINFO_FUNCTION(spl)
892893
}
893894
/* }}} */
894895

895-
/* {{{ arginfo */
896-
ZEND_BEGIN_ARG_INFO_EX(arginfo_iterator_to_array, 0, 0, 1)
897-
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
898-
ZEND_ARG_INFO(0, use_keys)
899-
ZEND_END_ARG_INFO();
900-
901-
ZEND_BEGIN_ARG_INFO(arginfo_iterator, 0)
902-
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
903-
ZEND_END_ARG_INFO();
904-
905-
ZEND_BEGIN_ARG_INFO_EX(arginfo_iterator_apply, 0, 0, 2)
906-
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
907-
ZEND_ARG_INFO(0, function)
908-
ZEND_ARG_ARRAY_INFO(0, args, 1)
909-
ZEND_END_ARG_INFO();
910-
911-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_parents, 0, 0, 1)
912-
ZEND_ARG_INFO(0, instance)
913-
ZEND_ARG_INFO(0, autoload)
914-
ZEND_END_ARG_INFO()
915-
916-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_implements, 0, 0, 1)
917-
ZEND_ARG_INFO(0, what)
918-
ZEND_ARG_INFO(0, autoload)
919-
ZEND_END_ARG_INFO()
920-
921-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_uses, 0, 0, 1)
922-
ZEND_ARG_INFO(0, what)
923-
ZEND_ARG_INFO(0, autoload)
924-
ZEND_END_ARG_INFO()
925-
926-
927-
ZEND_BEGIN_ARG_INFO(arginfo_spl_classes, 0)
928-
ZEND_END_ARG_INFO()
929-
930-
ZEND_BEGIN_ARG_INFO(arginfo_spl_autoload_functions, 0)
931-
ZEND_END_ARG_INFO()
932-
933-
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload, 0, 0, 1)
934-
ZEND_ARG_INFO(0, class_name)
935-
ZEND_ARG_INFO(0, file_extensions)
936-
ZEND_END_ARG_INFO()
937-
938-
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_extensions, 0, 0, 0)
939-
ZEND_ARG_INFO(0, file_extensions)
940-
ZEND_END_ARG_INFO()
941-
942-
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_call, 0, 0, 1)
943-
ZEND_ARG_INFO(0, class_name)
944-
ZEND_END_ARG_INFO()
945-
946-
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_register, 0, 0, 0)
947-
ZEND_ARG_INFO(0, autoload_function)
948-
ZEND_ARG_INFO(0, throw)
949-
ZEND_ARG_INFO(0, prepend)
950-
ZEND_END_ARG_INFO()
951-
952-
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_unregister, 0, 0, 1)
953-
ZEND_ARG_INFO(0, autoload_function)
954-
ZEND_END_ARG_INFO()
955-
956-
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_object_hash, 0, 0, 1)
957-
ZEND_ARG_INFO(0, obj)
958-
ZEND_END_ARG_INFO()
959-
960-
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_object_id, 0, 0, 1)
961-
ZEND_ARG_INFO(0, obj)
962-
ZEND_END_ARG_INFO()
963-
/* }}} */
964-
965896
/* {{{ spl_functions
966897
*/
967898
static const zend_function_entry spl_functions[] = {
@@ -978,7 +909,7 @@ static const zend_function_entry spl_functions[] = {
978909
PHP_FE(spl_object_hash, arginfo_spl_object_hash)
979910
PHP_FE(spl_object_id, arginfo_spl_object_id)
980911
PHP_FE(iterator_to_array, arginfo_iterator_to_array)
981-
PHP_FE(iterator_count, arginfo_iterator)
912+
PHP_FE(iterator_count, arginfo_iterator_count)
982913
PHP_FE(iterator_apply, arginfo_iterator_apply)
983914
PHP_FE_END
984915
};

ext/spl/php_spl.stub.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
function iterator_to_array(Traversable $iterator, bool $use_keys = true): array {}
4+
5+
function iterator_count(Traversable $iterator): int {}
6+
7+
function iterator_apply(Traversable $iterator, callable $function, ?array $args = null): ?int {}
8+
9+
function class_parents(object|string $instance, bool $autoload = true): array|false {}
10+
11+
function class_implements(object|string $what, bool $autoload = true): array|false {}
12+
13+
function class_uses(object|string $what, bool $autoload = true): array|false {}
14+
15+
function spl_classes(): array {}
16+
17+
function spl_autoload_functions(): array|false {}
18+
19+
function spl_autoload(string $class_name, string $file_extensions = UNKNOWN): void {}
20+
21+
function spl_autoload_extensions(string $file_extensions = UNKNOWN): string {}
22+
23+
function spl_autoload_call(string $class_name): void {}
24+
25+
/**
26+
* @param callable $autoload_function
27+
*/
28+
function spl_autoload_register($autoload_function = UNKNOWN, bool $throw = true, bool $prepend = false): bool {}
29+
30+
function spl_autoload_unregister($autoload_function): bool {}
31+
32+
function spl_object_hash(object $obj): string {}
33+
34+
function spl_object_id(object $obj): int {}

ext/spl/php_spl_arginfo.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_iterator_to_array, 0, 1, IS_ARRAY, 0)
4+
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
5+
ZEND_ARG_TYPE_INFO(0, use_keys, _IS_BOOL, 0)
6+
ZEND_END_ARG_INFO()
7+
8+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_iterator_count, 0, 1, IS_LONG, 0)
9+
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
10+
ZEND_END_ARG_INFO()
11+
12+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_iterator_apply, 0, 2, IS_LONG, 1)
13+
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
14+
ZEND_ARG_TYPE_INFO(0, function, IS_CALLABLE, 0)
15+
ZEND_ARG_TYPE_INFO(0, args, IS_ARRAY, 1)
16+
ZEND_END_ARG_INFO()
17+
18+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_parents, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
19+
ZEND_ARG_TYPE_MASK(0, instance, MAY_BE_OBJECT|MAY_BE_STRING)
20+
ZEND_ARG_TYPE_INFO(0, autoload, _IS_BOOL, 0)
21+
ZEND_END_ARG_INFO()
22+
23+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_implements, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
24+
ZEND_ARG_TYPE_MASK(0, what, MAY_BE_OBJECT|MAY_BE_STRING)
25+
ZEND_ARG_TYPE_INFO(0, autoload, _IS_BOOL, 0)
26+
ZEND_END_ARG_INFO()
27+
28+
#define arginfo_class_uses arginfo_class_implements
29+
30+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_classes, 0, 0, IS_ARRAY, 0)
31+
ZEND_END_ARG_INFO()
32+
33+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_spl_autoload_functions, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
34+
ZEND_END_ARG_INFO()
35+
36+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload, 0, 1, IS_VOID, 0)
37+
ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
38+
ZEND_ARG_TYPE_INFO(0, file_extensions, IS_STRING, 0)
39+
ZEND_END_ARG_INFO()
40+
41+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_extensions, 0, 0, IS_STRING, 0)
42+
ZEND_ARG_TYPE_INFO(0, file_extensions, IS_STRING, 0)
43+
ZEND_END_ARG_INFO()
44+
45+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_call, 0, 1, IS_VOID, 0)
46+
ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
47+
ZEND_END_ARG_INFO()
48+
49+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_register, 0, 0, _IS_BOOL, 0)
50+
ZEND_ARG_INFO(0, autoload_function)
51+
ZEND_ARG_TYPE_INFO(0, throw, _IS_BOOL, 0)
52+
ZEND_ARG_TYPE_INFO(0, prepend, _IS_BOOL, 0)
53+
ZEND_END_ARG_INFO()
54+
55+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload_unregister, 0, 1, _IS_BOOL, 0)
56+
ZEND_ARG_INFO(0, autoload_function)
57+
ZEND_END_ARG_INFO()
58+
59+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_object_hash, 0, 1, IS_STRING, 0)
60+
ZEND_ARG_TYPE_INFO(0, obj, IS_OBJECT, 0)
61+
ZEND_END_ARG_INFO()
62+
63+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_object_id, 0, 1, IS_LONG, 0)
64+
ZEND_ARG_TYPE_INFO(0, obj, IS_OBJECT, 0)
65+
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)