1
1
Phamda functions
2
2
================
3
3
4
- Currently included functions (110 ):
4
+ Currently included functions (104 ):
5
5
6
6
7
7
@@ -408,31 +408,11 @@ Calls the given function for each element in the collection and returns the orig
408
408
409
409
The supplied ``function `` receives three arguments: ``item ``, ``index ``, ``collection ``.
410
410
411
- .. code-block :: php
412
-
413
- $date = new \DateTime('2015-02-02');
414
- $addDays = function ($number) use ($date) { $date->modify("+{$number} days"); };
415
- P::each($addDays, [3, 6, 2]);
416
- $date->format('Y-m-d'); // => '2015-02-13'
417
-
418
-
419
- .. _eachIndexed :
420
-
421
- eachIndexed
422
- -----------
423
- ``array|\Traversable|Collection P::eachIndexed(callable $function, array|\Traversable|Collection $collection) ``
424
-
425
- Deprecated since version 0.4, to be removed in 0.5. The callback of ``each `` now receives three arguments as well.
426
-
427
- Calls the given function for each element in the collection and returns the original collection.
428
-
429
- Like ``each ``, but the supplied ``function `` receives three arguments: ``item ``, ``index ``, ``collection ``.
430
-
431
411
.. code-block :: php
432
412
433
413
$date = new \DateTime('2015-02-02');
434
414
$addCalendar = function ($number, $type) use ($date) { $date->modify("+{$number} {$type}"); };
435
- P::eachIndexed ($addCalendar, ['months' => 3, 'weeks' => 6, 'days' => 2]);
415
+ P::each ($addCalendar, ['months' => 3, 'weeks' => 6, 'days' => 2]);
436
416
$date->format('Y-m-d'); // => '2015-06-15'
437
417
438
418
@@ -528,24 +508,6 @@ The supplied ``predicate`` receives three arguments: ``item``, ``index``, ``coll
528
508
P::filter($gt2, ['foo' => 2, 'bar' => 3, 'baz' => 4]); // => ['bar' => 3, 'baz' => 4]
529
509
530
510
531
- .. _filterIndexed :
532
-
533
- filterIndexed
534
- -------------
535
- ``array|Collection P::filterIndexed(callable $predicate, array|\Traversable|Collection $collection) ``
536
-
537
- Deprecated since version 0.4, to be removed in 0.5. The callback of ``filter `` now receives three arguments as well.
538
-
539
- Returns a new collection containing the items that match the given predicate.
540
-
541
- Like ``filter ``, but the supplied ``predicate `` receives three arguments: ``item ``, ``index ``, ``collection ``.
542
-
543
- .. code-block :: php
544
-
545
- $smallerThanNext = function ($value, $key, $list) { return isset($list[$key + 1]) ? $value < $list[$key + 1] : false; };
546
- P::filterIndexed($smallerThanNext, [3, 6, 2, 19]); // => [0 => 3, 2 => 2]
547
-
548
-
549
511
.. _find :
550
512
551
513
find
@@ -896,24 +858,8 @@ The supplied ``function`` receives three arguments: ``item``, ``index``, ``colle
896
858
897
859
$square = function ($x) { return $x ** 2; };
898
860
P::map($square, [1, 2, 3, 4]); // => [1, 4, 9, 16]
899
-
900
-
901
- .. _mapIndexed :
902
-
903
- mapIndexed
904
- ----------
905
- ``array|Collection P::mapIndexed(callable $function, array|\Traversable|Collection $collection) ``
906
-
907
- Deprecated since version 0.4, to be removed in 0.5. The callback of ``map `` now receives three arguments as well.
908
-
909
- Returns a new collection where values are created from the original collection by calling the supplied function.
910
-
911
- Like ``map ``, but the supplied ``function `` receives three arguments: ``item ``, ``index ``, ``collection ``.
912
-
913
- .. code-block :: php
914
-
915
861
$keyExp = function ($value, $key) { return $value ** $key; };
916
- P::mapIndexed ($keyExp, [1, 2, 3, 4]); // => [1, 2, 9, 64]
862
+ P::map ($keyExp, [1, 2, 3, 4]); // => [1, 2, 9, 64]
917
863
918
864
919
865
.. _max :
@@ -1297,24 +1243,6 @@ The supplied ``function`` receives four arguments: ``previousValue``, ``item``,
1297
1243
P::reduce($concat, 'foo', ['bar', 'baz']); // => 'foobarbaz'
1298
1244
1299
1245
1300
- .. _reduceIndexed :
1301
-
1302
- reduceIndexed
1303
- -------------
1304
- ``mixed P::reduceIndexed(callable $function, mixed $initial, array|\Traversable $collection) ``
1305
-
1306
- Deprecated since version 0.4, to be removed in 0.5. The callback of ``reduce `` now receives four arguments as well.
1307
-
1308
- Returns a value accumulated by calling the given function for each element of the collection.
1309
-
1310
- Like ``reduce ``, but the supplied ``function `` receives four arguments: ``previousValue ``, ``item ``, ``index ``, ``collection ``.
1311
-
1312
- .. code-block :: php
1313
-
1314
- $concat = function ($accumulator, $value, $key) { return $accumulator . $key . $value; };
1315
- P::reduceIndexed($concat, 'no', ['foo' => 'bar', 'fiz' => 'buz']); // => 'nofoobarfizbuz'
1316
-
1317
-
1318
1246
.. _reduceRight :
1319
1247
1320
1248
reduceRight
@@ -1325,28 +1253,10 @@ Returns a value accumulated by calling the given function for each element of th
1325
1253
1326
1254
The supplied ``function `` receives four arguments: ``previousValue ``, ``item ``, ``index ``, ``collection ``.
1327
1255
1328
- .. code-block :: php
1329
-
1330
- $concat = function ($x, $y) { return $x . $y; };
1331
- P::reduceRight($concat, 'foo', ['bar', 'baz']); // => 'foobazbar'
1332
-
1333
-
1334
- .. _reduceRightIndexed :
1335
-
1336
- reduceRightIndexed
1337
- ------------------
1338
- ``mixed P::reduceRightIndexed(callable $function, mixed $initial, array|\Traversable $collection) ``
1339
-
1340
- Deprecated since version 0.4, to be removed in 0.5. The callback of ``reduceRight `` now receives four arguments as well.
1341
-
1342
- Returns a value accumulated by calling the given function for each element of the collection in reverse order.
1343
-
1344
- Like ``reduceRight ``, but the supplied ``function `` receives four arguments: ``previousValue ``, ``item ``, ``index ``, ``collection ``.
1345
-
1346
1256
.. code-block :: php
1347
1257
1348
1258
$concat = function ($accumulator, $value, $key) { return $accumulator . $key . $value; };
1349
- P::reduceRightIndexed ($concat, 'no', ['foo' => 'bar', 'fiz' => 'buz']); // => 'nofizbuzfoobar'
1259
+ P::reduceRight ($concat, 'no', ['foo' => 'bar', 'fiz' => 'buz']); // => 'nofizbuzfoobar'
1350
1260
1351
1261
1352
1262
.. _reject :
@@ -1365,24 +1275,6 @@ The supplied ``predicate`` receives three arguments: ``item``, ``index``, ``coll
1365
1275
P::reject($isEven, [1, 2, 3, 4]); // => [0 => 1, 2 => 3]
1366
1276
1367
1277
1368
- .. _rejectIndexed :
1369
-
1370
- rejectIndexed
1371
- -------------
1372
- ``array|Collection P::rejectIndexed(callable $predicate, array|\Traversable|Collection $collection) ``
1373
-
1374
- Deprecated since version 0.4, to be removed in 0.5. The callback of ``reject `` now receives three arguments as well.
1375
-
1376
- Returns a new collection containing the items that do not match the given predicate.
1377
-
1378
- Like ``reject ``, but the supplied ``predicate `` receives three arguments: ``item ``, ``index ``, ``collection ``.
1379
-
1380
- .. code-block :: php
1381
-
1382
- $smallerThanNext = function ($value, $key, $list) { return isset($list[$key + 1]) ? $value < $list[$key + 1] : false; };
1383
- P::rejectIndexed($smallerThanNext, [3, 6, 2, 19]); // => [1 => 6, 3 => 19]
1384
-
1385
-
1386
1278
.. _reverse :
1387
1279
1388
1280
reverse
0 commit comments