Skip to content

Commit f6e45c7

Browse files
committed
Convert spl functions arginfo to php stubs
1 parent 071ccee commit f6e45c7

File tree

3 files changed

+111
-71
lines changed

3 files changed

+111
-71
lines changed

ext/spl/php_spl.c

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "php_main.h"
2626
#include "ext/standard/info.h"
2727
#include "php_spl.h"
28+
#include "php_spl_arginfo.h"
2829
#include "spl_functions.h"
2930
#include "spl_engine.h"
3031
#include "spl_array.h"
@@ -894,76 +895,6 @@ PHP_MINFO_FUNCTION(spl)
894895
}
895896
/* }}} */
896897

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

ext/spl/php_spl.stub.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 = []): int {}
8+
9+
/**
10+
* @param object|string $instance
11+
* @return array|false
12+
*/
13+
function class_parents($instance, bool $autoload = true) {}
14+
15+
/**
16+
* @param object|string $what
17+
* @return array|false
18+
*/
19+
function class_implements($what, bool $autoload = true) {}
20+
21+
/**
22+
* @param object|string $what
23+
* @return array|false
24+
*/
25+
function class_uses($what, bool $autoload = true) {}
26+
27+
function spl_classes(): array {}
28+
29+
/** @return array|false */
30+
function spl_autoload_functions() {}
31+
32+
function spl_autoload(string $class_name, string $file_extensions): void {}
33+
34+
function spl_autoload_extensions(string $file_extensions): string {}
35+
36+
function spl_autoload_call(string $class_name): void {}
37+
38+
function spl_autoload_register(callable $autoload_function = UNKNOWN, bool $throw = true, bool $prepend = false): bool {}
39+
40+
function spl_autoload_unregister($autoload_function): bool {}
41+
42+
function spl_object_hash(object $obj): string {}
43+
44+
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, 0)
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_INFO_EX(arginfo_class_parents, 0, 0, 1)
19+
ZEND_ARG_INFO(0, instance)
20+
ZEND_ARG_TYPE_INFO(0, autoload, _IS_BOOL, 0)
21+
ZEND_END_ARG_INFO()
22+
23+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_implements, 0, 0, 1)
24+
ZEND_ARG_INFO(0, what)
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_INFO_EX(arginfo_spl_autoload_functions, 0, 0, 0)
34+
ZEND_END_ARG_INFO()
35+
36+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_spl_autoload, 0, 2, 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, 1, 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_TYPE_INFO(0, autoload_function, IS_CALLABLE, 0)
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)