1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* A brief list of features we want in |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
// iterator interface |
8
|
|
|
p()->next(); |
9
|
|
|
p()->current(); |
10
|
|
|
p()->valid(); |
11
|
|
|
p()->rewind(); |
12
|
|
|
p()->getInnerIterator(); |
13
|
|
|
|
14
|
|
|
// pipes |
15
|
|
|
p()->chunk($num); // ok |
16
|
|
|
p()->each($function, $step = 1); //ok |
|
|
|
|
17
|
|
|
p()->filter($function); //ok |
18
|
|
|
p()->limit($skip = 0, $max); //ok |
19
|
|
|
p()->map($function); //okdi |
20
|
|
|
|
21
|
|
|
// factory methods |
22
|
|
|
p()->emit($key = null, $value); //ok |
23
|
|
|
p()->flags($flag1, $flag2 =null, $flagN = null); |
24
|
|
|
|
25
|
|
|
// terminals |
26
|
|
|
p()->toValues(); // ok. outputs an indexed array. |
27
|
|
|
p()->toArray(); // ok. outputs an array. Keys preserved (last key wins) |
28
|
|
|
p()->toIterator(); // ok. outputs an array. Keys preserved (last key wins) |
29
|
|
|
p()->reduce($function = null); // outputs an array. Keys preserved. Conflicts handled by $function |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
// timed pipes |
33
|
|
|
p()->maxTime($seconds); //also floats 0.001 etc |
34
|
|
|
p()->wait($seconds, $function = null); // !$function ? wait again |
35
|
|
|
|
36
|
|
|
// push to other queues (array, queues, chains) |
37
|
|
|
p()->filter($function, $queue); |
|
|
|
|
38
|
|
|
p()->map($function, $queue); |
|
|
|
|
39
|
|
|
|
40
|
|
|
// accumulators |
41
|
|
|
p()->groupBy($function); |
42
|
|
|
p()->sort(); |
43
|
|
|
|
44
|
|
|
// queues |
45
|
|
|
p()->queues->sqlite('queue.db'); |
46
|
|
|
p()->queues->file('queue.txt'); |
47
|
|
|
p()->queues->json('queue.json'); // one json per line |
48
|
|
|
p()->queues->post($url, $moreParams); |
49
|
|
|
|
50
|
|
|
// anonymous pipes |
51
|
|
|
$func = p()->filter($foo)->map($bar); |
52
|
|
|
$result = $func('hello'); |
53
|
|
|
|
54
|
|
|
$func->wrap($array); |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
p($array)->map('p()->emit($k, $v)'); |
58
|
|
|
|
59
|
|
|
// --- advanced stuff |
60
|
|
|
|
61
|
|
|
// caching |
62
|
|
|
p()->keep(3)->each(function(){ |
63
|
|
|
$previous = p()->kept(-1); // also -2, -3 |
64
|
|
|
}); |
65
|
|
|
|
66
|
|
|
// map reduce |
67
|
|
|
p()->shard($function); |
68
|
|
|
p()->reduce($shard); |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/* |
72
|
|
|
|
73
|
|
|
Figure out how to: |
74
|
|
|
|
75
|
|
|
- properly replace an inneriterator with another in PipeIterator |
76
|
|
|
- properly append new iterms in PipeIterator |
77
|
|
|
- how to make PipeIterator a simple reference to a Pipe Instance |
78
|
|
|
|
79
|
|
|
- Pipe iterator should not wrap the Pipe instance but iterate on its |
80
|
|
|
inner iterator. |
81
|
|
|
- Thus, a new Pipe iterator should be initialized for each chainWith |
82
|
|
|
operation. |
83
|
|
|
- Pipe iterator should keep an instance of its pipe for easy retrieval. |
84
|
|
|
- Each chain operation on Pipe iterator should be passed on to its |
85
|
|
|
Pipe parent, but should be reflected on the iterator (?) |
86
|
|
|
|
87
|
|
|
Should we return a new Pipe instance for each chainWith? |
88
|
|
|
$pipe = p($collection)->filter('isEmpty'); |
89
|
|
|
$map = $pipe->map('myfunc')->each('func')->limit(3); |
90
|
|
|
$discard = $pipe->each('logme'); |
91
|
|
|
$result = $map->toArray(); |
92
|
|
|
$discarded = $discard->toArray(); |
93
|
|
|
|
94
|
|
|
*/ |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: