diff --git a/src/collections_me.c b/src/collections_me.c index 58bcdad..e2bd2bf 100644 --- a/src/collections_me.c +++ b/src/collections_me.c @@ -114,17 +114,6 @@ ZEND_BEGIN_ARG_INFO(get_arginfo, 0) ZEND_ARG_INFO(0, default) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(group_by_arginfo, 0) - ZEND_ARG_CALLABLE_INFO(0, key_selector, 0) - ZEND_ARG_CALLABLE_INFO(0, value_transform, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(group_by_to_arginfo, 0) - ZEND_ARG_OBJ_INFO(0, destination, Collection, 0) - ZEND_ARG_CALLABLE_INFO(0, key_selector, 0) - ZEND_ARG_CALLABLE_INFO(0, value_transform, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO(to_collection_arginfo, 0) ZEND_ARG_OBJ_INFO(0, destination, Collection, 0) ZEND_END_ARG_INFO() @@ -164,8 +153,8 @@ const zend_function_entry collection_methods[] = { PHP_ME(Collection, foldRight, initial_operation_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, forEach, action_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, get, get_arginfo, ZEND_ACC_PUBLIC) - PHP_ME(Collection, groupBy, group_by_arginfo, ZEND_ACC_PUBLIC) - PHP_ME(Collection, groupByTo, group_by_to_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(Collection, groupBy, transform_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(Collection, groupByTo, destination_transform_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, indexOf, element_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, indexOfFirst, predicate_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, indexOfLast, predicate_arginfo, ZEND_ACC_PUBLIC) diff --git a/stubs/Collection.php b/stubs/Collection.php index f7db537..f4d1de4 100644 --- a/stubs/Collection.php +++ b/stubs/Collection.php @@ -314,27 +314,29 @@ class Collection implements ArrayAccess, Countable function get($key, $default) {} /** - * Groups values returned by the value_transform function applied to each element of the - * original collection by the key returned by the given key_selector function applied to the element + * Groups values by the key returned by the given transform function applied to the element * and returns a collection where each group key is associated with a list of corresponding values. + * + * Key should be either string or integer. If the transform function returns a Pair, the + * original value will be mapped to the new value. * - * @param callable $key_selector ($value, $key) -> $new_key - * @param callable $value_transform[optional] ($value) -> $new_value + * @param callable $transform ($value, $key) -> $new_key | Pair($new_key, $new_value) * @return Collection */ - function groupBy($key_selector, $value_transform) {} + function groupBy($transform) {} /** - * Groups values returned by the value_transform function applied to each element of the original - * collection by the key returned by the given key_selector function applied to the element and + * Groups values by the key returned by the given transform function applied to the element and * puts to the destination collection each group key associated with a list of corresponding values. + * + * Key should be either string or integer. If the transform function returns a Pair, the + * original value will be mapped to the new value. * * @param Collection $destination - * @param callable $key_selector ($value, $key) -> $new_key - * @param callable $value_transform[optional] ($value) -> $new_value + * @param callable $transform ($value, $key) -> $new_key | Pair($new_key, $new_value) * @return Collection */ - function groupByTo($destination, $key_selector, $value_transform) {} + function groupByTo($destination, $transform) {} /** * Returns first key of element, or null if the collection does not contain element.