1 | <?php |
||
22 | abstract class Collection implements Equatable, Countable, IteratorAggregate |
||
23 | { |
||
24 | protected $items = []; |
||
25 | |||
26 | public function getIterator(): Traversable |
||
30 | |||
31 | public function isEmpty(): bool |
||
35 | |||
36 | public function count(): int |
||
40 | |||
41 | public function countItem($value): int |
||
53 | |||
54 | public function contains($value): bool |
||
63 | |||
64 | abstract public function search($value); |
||
65 | |||
66 | public function searchAll($value): Vector |
||
78 | |||
79 | /** |
||
80 | * The reducer callable is given the carry value and an item, |
||
81 | * and should return the value it is reduced to. |
||
82 | * |
||
83 | * function ($carry, $item) { |
||
84 | * return $carry . $item; |
||
85 | * } |
||
86 | */ |
||
87 | public function reduce(callable $reducer, $initial = null) |
||
91 | |||
92 | protected function theseAreEqual($left, $right): bool |
||
104 | |||
105 | protected function guardAgainstInvalidValue($value): void |
||
111 | } |
||
112 |
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@return
doc comment to communicate to implementors of these methods what they are expected to return.