From 693e404667a1f15e8a7d40d345ab44a86d71e9b0 Mon Sep 17 00:00:00 2001 From: CismonX Date: Sun, 9 Sep 2018 23:05:00 +0800 Subject: [PATCH] Update signature for `binarySearch()` and `binarySearchBy()`. --- src/collections_me.c | 16 ++++++++++++---- stubs/Collection.php | 14 +++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/collections_me.c b/src/collections_me.c index 7624b8f..94ad376 100644 --- a/src/collections_me.c +++ b/src/collections_me.c @@ -101,17 +101,25 @@ ZEND_BEGIN_ARG_INFO(copy_of_range_arginfo, 0) ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(element_from_to_arginfo, 0) +ZEND_BEGIN_ARG_INFO(fill_arginfo, 0) ZEND_ARG_INFO(0, element) ZEND_ARG_TYPE_INFO(0, from_index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(binary_search_arginfo, 0) + ZEND_ARG_INFO(0, element) + ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, from_index, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(binary_search_by_arginfo, 0) ZEND_ARG_INFO(0, element) + ZEND_ARG_CALLABLE_INFO(0, selector, 0) + ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, from_index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0) - ZEND_ARG_CALLABLE_INFO(0, selector, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(chuncked_arginfo, 0) @@ -138,7 +146,7 @@ const zend_function_entry collection_methods[] = { PHP_ME(Collection, associateBy, associate_by_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, associateByTo, associate_by_to_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, average, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Collection, binarySearch, element_from_to_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(Collection, binarySearch, binary_search_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, binarySearchBy, binary_search_by_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, chunked, chuncked_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, containsAll, other_arginfo, ZEND_ACC_PUBLIC) @@ -155,7 +163,7 @@ const zend_function_entry collection_methods[] = { PHP_ME(Collection, dropLast, n_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, dropLastWhile, predicate_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, dropWhile, predicate_arginfo, ZEND_ACC_PUBLIC) - PHP_ME(Collection, fill, element_from_to_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(Collection, fill, fill_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, filter, predicate_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, filterNot, predicate_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, filterNotTo, destination_predicate_arginfo, ZEND_ACC_PUBLIC) diff --git a/stubs/Collection.php b/stubs/Collection.php index 9e51999..7ac6315 100644 --- a/stubs/Collection.php +++ b/stubs/Collection.php @@ -96,29 +96,33 @@ class Collection implements ArrayAccess, Countable * Searches the array or the range of the array for the provided element using the * binary search algorithm. * - * The array is expected to be packed and sorted, otherwise the result is undefined. + * The array is expected to be packed and sorted into ascending order, otherwise the + * result is undefined. * * @param mixed $element + * @param int $flags[optional] * @param int $from_index[optional] * @param int $num_elements[optional] * @return int|null */ - function binarySearch($element, $from_index, $num_elements) {} + function binarySearch($element, $flags, $from_index, $num_elements) {} /** * Searches the array or the range of the array for the provided element using the * binary search algorithm, where the element equals to the one returned by the * corresponding selector function. * - * The array is expected to be packed and sorted, otherwise the result is undefined. + * The array is expected to be packed and sorted into ascending order, otherwise the + * result is undefined. * * @param mixed $element + * @param callable $selector ($value, $key) -> $new_value + * @param int $flags[optional] * @param int $from_index[optional] * @param int $num_elements[optional] - * @param callable $selector ($value, $key) -> $new_value * @return int|null */ - function binarySearchBy($element, $from_index, $num_elements, $selector) {} + function binarySearchBy($element, $selector, $flags, $from_index, $num_elements) {} /** * Splits this collection into a collection of arrays each not exceeding the given size.