@@ -630,47 +630,17 @@ public static function divide($x = null, $y = null)
630
630
*
631
631
* ```php
632
632
* $date = new \DateTime('2015-02-02');
633
- * $addDays = function ($number) use ($date) { $date->modify("+{$number} days"); };
634
- * P::each($addDays, [3, 6, 2]);
635
- * $date->format('Y-m-d'); // => '2015-02-13'
636
- * ```
637
- *
638
- * @param callable $function
639
- * @param array|\Traversable|Collection $collection
640
- *
641
- * @return callable|array|\Traversable|Collection
642
- */
643
- public static function each ($ function = null , $ collection = null )
644
- {
645
- return static ::curry2 (function (callable $ function , $ collection ) {
646
- foreach ($ collection as $ key => $ item ) {
647
- $ function ($ item , $ key , $ collection );
648
- }
649
-
650
- return $ collection ;
651
- }, func_get_args ());
652
- }
653
-
654
- /**
655
- * Calls the given function for each element in the collection and returns the original collection.
656
- *
657
- * Like `each`, but the supplied `function` receives three arguments: `item`, `index`, `collection`.
658
- *
659
- * ```php
660
- * $date = new \DateTime('2015-02-02');
661
633
* $addCalendar = function ($number, $type) use ($date) { $date->modify("+{$number} {$type}"); };
662
- * P::eachIndexed ($addCalendar, ['months' => 3, 'weeks' => 6, 'days' => 2]);
634
+ * P::each ($addCalendar, ['months' => 3, 'weeks' => 6, 'days' => 2]);
663
635
* $date->format('Y-m-d'); // => '2015-06-15'
664
636
* ```
665
637
*
666
638
* @param callable $function
667
639
* @param array|\Traversable|Collection $collection
668
640
*
669
641
* @return callable|array|\Traversable|Collection
670
- *
671
- * @deprecated Since version 0.4, to be removed in 0.5. The callback of `each` now receives three arguments as well.
672
642
*/
673
- public static function eachIndexed ($ function = null , $ collection = null )
643
+ public static function each ($ function = null , $ collection = null )
674
644
{
675
645
return static ::curry2 (function (callable $ function , $ collection ) {
676
646
foreach ($ collection as $ key => $ item ) {
@@ -821,30 +791,6 @@ public static function filter($predicate = null, $collection = null)
821
791
}, func_get_args ());
822
792
}
823
793
824
- /**
825
- * Returns a new collection containing the items that match the given predicate.
826
- *
827
- * Like `filter`, but the supplied `predicate` receives three arguments: `item`, `index`, `collection`.
828
- *
829
- * ```php
830
- * $smallerThanNext = function ($value, $key, $list) { return isset($list[$key + 1]) ? $value < $list[$key + 1] : false; };
831
- * P::filterIndexed($smallerThanNext, [3, 6, 2, 19]); // => [0 => 3, 2 => 2]
832
- * ```
833
- *
834
- * @param callable $predicate
835
- * @param array|\Traversable|Collection $collection
836
- *
837
- * @return callable|array|Collection
838
- *
839
- * @deprecated Since version 0.4, to be removed in 0.5. The callback of `filter` now receives three arguments as well.
840
- */
841
- public static function filterIndexed ($ predicate = null , $ collection = null )
842
- {
843
- return static ::curry2 (function (callable $ predicate , $ collection ) {
844
- return static ::_filter ($ predicate , $ collection );
845
- }, func_get_args ());
846
- }
847
-
848
794
/**
849
795
* Returns the first item of a collection for which the given predicate matches, or null if no match is found.
850
796
*
@@ -1399,38 +1345,16 @@ public static function lte($x = null, $y = null)
1399
1345
* ```php
1400
1346
* $square = function ($x) { return $x ** 2; };
1401
1347
* P::map($square, [1, 2, 3, 4]); // => [1, 4, 9, 16]
1402
- * ```
1403
- *
1404
- * @param callable $function
1405
- * @param array|\Traversable|Collection $collection
1406
- *
1407
- * @return callable|array|Collection
1408
- */
1409
- public static function map ($ function = null , $ collection = null )
1410
- {
1411
- return static ::curry2 (function (callable $ function , $ collection ) {
1412
- return static ::_map ($ function , $ collection );
1413
- }, func_get_args ());
1414
- }
1415
-
1416
- /**
1417
- * Returns a new collection where values are created from the original collection by calling the supplied function.
1418
- *
1419
- * Like `map`, but the supplied `function` receives three arguments: `item`, `index`, `collection`.
1420
- *
1421
- * ```php
1422
1348
* $keyExp = function ($value, $key) { return $value ** $key; };
1423
- * P::mapIndexed ($keyExp, [1, 2, 3, 4]); // => [1, 2, 9, 64]
1349
+ * P::map ($keyExp, [1, 2, 3, 4]); // => [1, 2, 9, 64]
1424
1350
* ```
1425
1351
*
1426
1352
* @param callable $function
1427
1353
* @param array|\Traversable|Collection $collection
1428
1354
*
1429
1355
* @return callable|array|Collection
1430
- *
1431
- * @deprecated Since version 0.4, to be removed in 0.5. The callback of `map` now receives three arguments as well.
1432
1356
*/
1433
- public static function mapIndexed ($ function = null , $ collection = null )
1357
+ public static function map ($ function = null , $ collection = null )
1434
1358
{
1435
1359
return static ::curry2 (function (callable $ function , $ collection ) {
1436
1360
return static ::_map ($ function , $ collection );
@@ -2020,73 +1944,23 @@ public static function reduce($function = null, $initial = null, $collection = n
2020
1944
}, func_get_args ());
2021
1945
}
2022
1946
2023
- /**
2024
- * Returns a value accumulated by calling the given function for each element of the collection.
2025
- *
2026
- * Like `reduce`, but the supplied `function` receives four arguments: `previousValue`, `item`, `index`, `collection`.
2027
- *
2028
- * ```php
2029
- * $concat = function ($accumulator, $value, $key) { return $accumulator . $key . $value; };
2030
- * P::reduceIndexed($concat, 'no', ['foo' => 'bar', 'fiz' => 'buz']); // => 'nofoobarfizbuz'
2031
- * ```
2032
- *
2033
- * @param callable $function
2034
- * @param mixed $initial
2035
- * @param array|\Traversable $collection
2036
- *
2037
- * @return callable|mixed
2038
- *
2039
- * @deprecated Since version 0.4, to be removed in 0.5. The callback of `reduce` now receives four arguments as well.
2040
- */
2041
- public static function reduceIndexed ($ function = null , $ initial = null , $ collection = null )
2042
- {
2043
- return static ::curry3 (function (callable $ function , $ initial , $ collection ) {
2044
- return static ::_reduce ($ function , $ initial , $ collection );
2045
- }, func_get_args ());
2046
- }
2047
-
2048
1947
/**
2049
1948
* Returns a value accumulated by calling the given function for each element of the collection in reverse order.
2050
1949
*
2051
1950
* The supplied `function` receives four arguments: `previousValue`, `item`, `index`, `collection`.
2052
1951
*
2053
1952
* ```php
2054
- * $concat = function ($x, $y) { return $x . $y; };
2055
- * P::reduceRight($concat, 'foo', ['bar', 'baz']); // => 'foobazbar'
2056
- * ```
2057
- *
2058
- * @param callable $function
2059
- * @param mixed $initial
2060
- * @param array|\Traversable $collection
2061
- *
2062
- * @return callable|mixed
2063
- */
2064
- public static function reduceRight ($ function = null , $ initial = null , $ collection = null )
2065
- {
2066
- return static ::curry3 (function (callable $ function , $ initial , $ collection ) {
2067
- return static ::_reduce ($ function , $ initial , static ::_reverse ($ collection ));
2068
- }, func_get_args ());
2069
- }
2070
-
2071
- /**
2072
- * Returns a value accumulated by calling the given function for each element of the collection in reverse order.
2073
- *
2074
- * Like `reduceRight`, but the supplied `function` receives four arguments: `previousValue`, `item`, `index`, `collection`.
2075
- *
2076
- * ```php
2077
1953
* $concat = function ($accumulator, $value, $key) { return $accumulator . $key . $value; };
2078
- * P::reduceRightIndexed ($concat, 'no', ['foo' => 'bar', 'fiz' => 'buz']); // => 'nofizbuzfoobar'
1954
+ * P::reduceRight ($concat, 'no', ['foo' => 'bar', 'fiz' => 'buz']); // => 'nofizbuzfoobar'
2079
1955
* ```
2080
1956
*
2081
1957
* @param callable $function
2082
1958
* @param mixed $initial
2083
1959
* @param array|\Traversable $collection
2084
1960
*
2085
1961
* @return callable|mixed
2086
- *
2087
- * @deprecated Since version 0.4, to be removed in 0.5. The callback of `reduceRight` now receives four arguments as well.
2088
1962
*/
2089
- public static function reduceRightIndexed ($ function = null , $ initial = null , $ collection = null )
1963
+ public static function reduceRight ($ function = null , $ initial = null , $ collection = null )
2090
1964
{
2091
1965
return static ::curry3 (function (callable $ function , $ initial , $ collection ) {
2092
1966
return static ::_reduce ($ function , $ initial , static ::_reverse ($ collection ));
@@ -2115,30 +1989,6 @@ public static function reject($predicate = null, $collection = null)
2115
1989
}, func_get_args ());
2116
1990
}
2117
1991
2118
- /**
2119
- * Returns a new collection containing the items that do not match the given predicate.
2120
- *
2121
- * Like `reject`, but the supplied `predicate` receives three arguments: `item`, `index`, `collection`.
2122
- *
2123
- * ```php
2124
- * $smallerThanNext = function ($value, $key, $list) { return isset($list[$key + 1]) ? $value < $list[$key + 1] : false; };
2125
- * P::rejectIndexed($smallerThanNext, [3, 6, 2, 19]); // => [1 => 6, 3 => 19]
2126
- * ```
2127
- *
2128
- * @param callable $predicate
2129
- * @param array|\Traversable|Collection $collection
2130
- *
2131
- * @return callable|array|Collection
2132
- *
2133
- * @deprecated Since version 0.4, to be removed in 0.5. The callback of `reject` now receives three arguments as well.
2134
- */
2135
- public static function rejectIndexed ($ predicate = null , $ collection = null )
2136
- {
2137
- return static ::curry2 (function (callable $ predicate , $ collection ) {
2138
- return static ::_filter (Phamda::not ($ predicate ), $ collection );
2139
- }, func_get_args ());
2140
- }
2141
-
2142
1992
/**
2143
1993
* Returns a new collection where the items are in a reverse order.
2144
1994
*
0 commit comments