Skip to content

Commit 546bc4f

Browse files
committed
Use common function for autoload_list functions
1 parent 3fe37f2 commit 546bc4f

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

Zend/zend_autoload.c

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ ZEND_API void zend_register_class_autoloader(zend_fcall_info *fci, zend_fcall_in
169169
}
170170

171171
// TODO USERLAND FUNCTIONS, maybe namespace them?
172+
static void autoload_list(INTERNAL_FUNCTION_PARAMETERS, HashTable *symbol_table)
173+
{
174+
zend_fcall_info_cache *func_info;
175+
176+
if (zend_parse_parameters_none() == FAILURE) {
177+
RETURN_THROWS();
178+
}
179+
180+
array_init(return_value);
181+
182+
ZEND_HASH_FOREACH_PTR(symbol_table, func_info) {
183+
zval tmp;
184+
zend_get_callable_zval_from_fcc(func_info, &tmp);
185+
add_next_index_zval(return_value, &tmp);
186+
} ZEND_HASH_FOREACH_END();
187+
}
188+
172189
/* Register given function as a class autoloader */
173190
ZEND_FUNCTION(autoload_register_class)
174191
{
@@ -233,19 +250,7 @@ ZEND_FUNCTION(autoload_call_class)
233250
/* Return all registered class autoloader functions */
234251
ZEND_FUNCTION(autoload_list_class)
235252
{
236-
zend_fcall_info_cache *func_info;
237-
238-
if (zend_parse_parameters_none() == FAILURE) {
239-
RETURN_THROWS();
240-
}
241-
242-
array_init(return_value);
243-
244-
ZEND_HASH_FOREACH_PTR(&EG(autoloaders).class_autoload_functions, func_info) {
245-
zval tmp;
246-
zend_get_callable_zval_from_fcc(func_info, &tmp);
247-
add_next_index_zval(return_value, &tmp);
248-
} ZEND_HASH_FOREACH_END();
253+
autoload_list(INTERNAL_FUNCTION_PARAM_PASSTHRU, &EG(autoloaders).class_autoload_functions);
249254
}
250255

251256
/* Register given function as a function autoloader */
@@ -333,19 +338,7 @@ ZEND_FUNCTION(autoload_call_function)
333338
/* Return all registered function autoloader functions */
334339
ZEND_FUNCTION(autoload_list_function)
335340
{
336-
zend_fcall_info_cache *func_info;
337-
338-
if (zend_parse_parameters_none() == FAILURE) {
339-
RETURN_THROWS();
340-
}
341-
342-
array_init(return_value);
343-
344-
ZEND_HASH_FOREACH_PTR(&EG(autoloaders).function_autoload_functions, func_info) {
345-
zval tmp;
346-
zend_get_callable_zval_from_fcc(func_info, &tmp);
347-
add_next_index_zval(return_value, &tmp);
348-
} ZEND_HASH_FOREACH_END();
341+
autoload_list(INTERNAL_FUNCTION_PARAM_PASSTHRU, &EG(autoloaders).function_autoload_functions);
349342
}
350343

351344
void zend_autoload_shutdown(void)

0 commit comments

Comments
 (0)