Skip to content

Commit

Permalink
docs: do not create ArrayIterator.
Browse files Browse the repository at this point in the history
It's not needed anymore since a69acec
  • Loading branch information
drupol committed Sep 28, 2022
1 parent aacb5e9 commit 2e50e49
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Features
$reverse = Reverse::of();
$pipe = Pipe::of()($reverse, $filter);
print_r(iterator_to_array($pipe(new ArrayIterator($data)))); // ['baz', 'bar']
print_r(iterator_to_array($pipe($data))); // ['baz', 'bar']
More information about this in the `Brian Lonsdorf's conference`_,
even if this is for Javascript,
Expand All @@ -110,8 +110,7 @@ Features
<?php
$input = ['foo,bar', 'baz,john'];
$userData = new ArrayIterator($input);
$userData = ['foo,bar', 'baz,john'];
$flatMap = static fn (callable $callable) =>
Pipe::of()(
Expand Down
3 changes: 1 addition & 2 deletions docs/pages/code/operations/all.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App;

use ArrayIterator;
use Generator;
use loophp\collection\Collection;
use loophp\collection\Operation\All;
Expand Down Expand Up @@ -39,5 +38,5 @@
// Example 3 -> standalone operation usage
$even = static fn (int $value): bool => $value % 2 === 0;

$piped = Pipe::of()(Filter::of()($even), All::of()(true))(new ArrayIterator([1, 2, 3, 4]));
$piped = Pipe::of()(Filter::of()($even), All::of()(true))([1, 2, 3, 4]);
print_r(iterator_to_array($piped)); // [2, 4]
3 changes: 1 addition & 2 deletions docs/pages/code/operations/partition.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App;

use ArrayIterator;
use Closure;
use loophp\collection\Collection;
use loophp\collection\Operation\Partition;
Expand Down Expand Up @@ -63,7 +62,7 @@
*/

// Example 3 -> Use Partition operation separately
[$left] = iterator_to_array(Partition::of()($isGreaterThan(5))(new ArrayIterator($input)));
[$left] = iterator_to_array(Partition::of()($isGreaterThan(5))($input));

// Numbers that are greater than 5
print_r(iterator_to_array($left));
Expand Down
3 changes: 1 addition & 2 deletions docs/pages/code/operations/span.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App;

use ArrayIterator;
use loophp\collection\Collection;
use loophp\collection\Operation\Span;

Expand All @@ -28,6 +27,6 @@
print_r($last->all()); // [4, 5, 6, 7, 8, 9, 10]

// Example 3 -> Use Span operation separately
[$left] = iterator_to_array(Span::of()(static fn ($x): bool => 4 > $x)(new ArrayIterator($input)));
[$left] = iterator_to_array(Span::of()(static fn ($x): bool => 4 > $x)($input));

print_r(iterator_to_array($left)); // [1, 2, 3]

0 comments on commit 2e50e49

Please sign in to comment.