Skip to content

Commit 0125bdb

Browse files
committed
Use common function for autoload_list functions
1 parent 76e1e44 commit 0125bdb

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
{
@@ -239,19 +256,7 @@ ZEND_FUNCTION(autoload_call_class)
239256
/* Return all registered class autoloader functions */
240257
ZEND_FUNCTION(autoload_list_class)
241258
{
242-
zend_fcall_info_cache *func_info;
243-
244-
if (zend_parse_parameters_none() == FAILURE) {
245-
RETURN_THROWS();
246-
}
247-
248-
array_init(return_value);
249-
250-
ZEND_HASH_FOREACH_PTR(&EG(autoloaders).class_autoload_functions, func_info) {
251-
zval tmp;
252-
zend_get_callable_zval_from_fcc(func_info, &tmp);
253-
add_next_index_zval(return_value, &tmp);
254-
} ZEND_HASH_FOREACH_END();
259+
autoload_list(INTERNAL_FUNCTION_PARAM_PASSTHRU, &EG(autoloaders).class_autoload_functions);
255260
}
256261

257262
/* Register given function as a function autoloader */
@@ -344,19 +349,7 @@ ZEND_FUNCTION(autoload_call_function)
344349
/* Return all registered function autoloader functions */
345350
ZEND_FUNCTION(autoload_list_function)
346351
{
347-
zend_fcall_info_cache *func_info;
348-
349-
if (zend_parse_parameters_none() == FAILURE) {
350-
RETURN_THROWS();
351-
}
352-
353-
array_init(return_value);
354-
355-
ZEND_HASH_FOREACH_PTR(&EG(autoloaders).function_autoload_functions, func_info) {
356-
zval tmp;
357-
zend_get_callable_zval_from_fcc(func_info, &tmp);
358-
add_next_index_zval(return_value, &tmp);
359-
} ZEND_HASH_FOREACH_END();
352+
autoload_list(INTERNAL_FUNCTION_PARAM_PASSTHRU, &EG(autoloaders).function_autoload_functions);
360353
}
361354

362355
void zend_autoload_shutdown(void)

0 commit comments

Comments
 (0)