Skip to content

Commit 15d6f25

Browse files
committed
Use common function for autoload_list functions
1 parent 87aec86 commit 15d6f25

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

Zend/zend_autoload.c

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,28 @@ ZEND_API void zend_register_class_autoloader(zend_fcall_info *fci, zend_fcall_in
179179
}
180180

181181
// TODO USERLAND FUNCTIONS, maybe namespace them?
182+
static void autoload_list(INTERNAL_FUNCTION_PARAMETERS, HashTable *symbol_table)
183+
{
184+
185+
zend_fcall_info_cache *func_info;
186+
187+
if (zend_parse_parameters_none() == FAILURE) {
188+
RETURN_THROWS();
189+
}
190+
191+
if (!symbol_table) {
192+
RETURN_EMPTY_ARRAY();
193+
}
194+
195+
array_init(return_value);
196+
197+
ZEND_HASH_FOREACH_PTR(symbol_table, func_info) {
198+
zval tmp;
199+
zend_get_callable_zval_from_fcc(func_info, &tmp);
200+
add_next_index_zval(return_value, &tmp);
201+
} ZEND_HASH_FOREACH_END();
202+
}
203+
182204
/* Register given function as a class autoloader */
183205
ZEND_FUNCTION(autoload_register_class)
184206
{
@@ -252,23 +274,7 @@ ZEND_FUNCTION(autoload_call_class)
252274
/* Return all registered class autoloader functions */
253275
ZEND_FUNCTION(autoload_list_class)
254276
{
255-
zend_fcall_info_cache *func_info;
256-
257-
if (zend_parse_parameters_none() == FAILURE) {
258-
RETURN_THROWS();
259-
}
260-
261-
if (!autoloader_class_autoload_functions) {
262-
RETURN_EMPTY_ARRAY();
263-
}
264-
265-
array_init(return_value);
266-
267-
ZEND_HASH_FOREACH_PTR(autoloader_class_autoload_functions, func_info) {
268-
zval tmp;
269-
zend_get_callable_zval_from_fcc(func_info, &tmp);
270-
add_next_index_zval(return_value, &tmp);
271-
} ZEND_HASH_FOREACH_END();
277+
autoload_list(INTERNAL_FUNCTION_PARAM_PASSTHRU, autoloader_class_autoload_functions);
272278
}
273279

274280
/* Register given function as a function autoloader */
@@ -370,23 +376,7 @@ ZEND_FUNCTION(autoload_call_function)
370376
/* Return all registered function autoloader functions */
371377
ZEND_FUNCTION(autoload_list_function)
372378
{
373-
zend_fcall_info_cache *func_info;
374-
375-
if (zend_parse_parameters_none() == FAILURE) {
376-
RETURN_THROWS();
377-
}
378-
379-
if (!autoloader_function_autoload_functions) {
380-
RETURN_EMPTY_ARRAY();
381-
}
382-
383-
array_init(return_value);
384-
385-
ZEND_HASH_FOREACH_PTR(autoloader_function_autoload_functions, func_info) {
386-
zval tmp;
387-
zend_get_callable_zval_from_fcc(func_info, &tmp);
388-
add_next_index_zval(return_value, &tmp);
389-
} ZEND_HASH_FOREACH_END();
379+
autoload_list(INTERNAL_FUNCTION_PARAM_PASSTHRU, autoloader_function_autoload_functions);
390380
}
391381

392382
void zend_autoload_shutdown(void)

0 commit comments

Comments
 (0)