1 | <?php |
||
12 | abstract class FixedFDirectory /* a */ extends FSObject |
||
13 | { |
||
14 | /** |
||
15 | * See documentation of FDirectory. |
||
16 | * |
||
17 | * @return FDirectory<a> |
||
|
|||
18 | */ |
||
19 | abstract public function unfix() : FDirectory; |
||
20 | |||
21 | /** |
||
22 | * Get an iterator over the content of this directory. |
||
23 | */ |
||
24 | 18 | public function iterateOn() : Iterator |
|
28 | |||
29 | /** |
||
30 | * Get an recursor over the content of this directory. |
||
31 | */ |
||
32 | 16 | public function recurseOn() : Recursor |
|
36 | |||
37 | /** |
||
38 | * Get an object that can unfold a directory structure in this directory. |
||
39 | * |
||
40 | * @param mixed $start_value |
||
41 | * @throws \LogicException If the directory is not empty. |
||
42 | */ |
||
43 | 6 | public function unfold($start_value) : Unfolder |
|
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | */ |
||
54 | 51 | public function isFile() : bool |
|
58 | |||
59 | /** |
||
60 | * Only regard contents that match the predicate. |
||
61 | * |
||
62 | * @param \Closure $predicate File|Directory -> bool |
||
63 | */ |
||
64 | 20 | public function filter(\Closure $predicate) : FixedFDirectory |
|
70 | |||
71 | /** |
||
72 | * Map over the contents of this directory. |
||
73 | * |
||
74 | * @param \Closure $trans |
||
75 | */ |
||
76 | 14 | public function map(\Closure $trans) : FixedFDirectory |
|
82 | |||
83 | /** |
||
84 | * Map the contents this directory. |
||
85 | * |
||
86 | * @param \Closure $trans |
||
87 | */ |
||
88 | public function outer_map(\Closure $trans) : Directory |
||
94 | |||
95 | /** |
||
96 | * Fold the contents of this directory with a function. |
||
97 | * |
||
98 | * Provide a start value that is fed together with the any content |
||
99 | * of this directory to the function successively to get a new value. |
||
100 | * |
||
101 | * @param \Closure $iteration a -> b -> a |
||
102 | */ |
||
103 | 18 | public function fold($start_value, $iteration) : FixedFDirectory |
|
109 | |||
110 | /** |
||
111 | * Get the the things inside this abstract directory. |
||
112 | * |
||
113 | * @return mixed |
||
114 | */ |
||
115 | 24 | public function contents() |
|
119 | |||
120 | /** |
||
121 | * We could also use the catamorphism on this to do recursion, as we |
||
122 | * have an unfix and an underlying fmap from the FDirectory. |
||
123 | * |
||
124 | * Supply a function $trans from File|FDirectory a to a that flattens |
||
125 | * (folds) a directory. Will start the directories where only files are |
||
126 | * included, folds them and then proceeds upwards. |
||
127 | * |
||
128 | * The return type should be 'a' (from the function $trans) instead |
||
129 | * of mixed, but we can't express that fact correctly in the docstring |
||
130 | * typing. |
||
131 | * |
||
132 | * @param \Closure $trans File|FDirectory a -> a |
||
133 | * @return mixed |
||
134 | */ |
||
135 | 16 | public function cata(\Closure $trans) |
|
139 | |||
140 | /** |
||
141 | * Fold over all files in this directory and subjacent |
||
142 | * directories. |
||
143 | * |
||
144 | * Start with an initial value of some type and a function from that type |
||
145 | * and File to a new value of the type. Will successively feed all files |
||
146 | * and the resulting values to that function. |
||
147 | * |
||
148 | * @param mixed $start_value |
||
149 | * @param \Closure $fold_with a -> File -> a |
||
150 | * @return Recursor|array |
||
151 | */ |
||
152 | 2 | public function foldFiles($start_value, \Closure $fold_with) |
|
156 | |||
157 | /** |
||
158 | * As we have an unfix and an underlying fmap from FDirectory, we could |
||
159 | * also implement the anamorphism. |
||
160 | * |
||
161 | * An anamorphism creates a structure from a start value and thus somehow |
||
162 | * is the reverse of cata. |
||
163 | * |
||
164 | * You need to provide a function from a to File or FDirectory a. This |
||
165 | * function then is recursively applied on the contents it produces, |
||
166 | * starting with the start value. |
||
167 | * |
||
168 | * @param \Closure $unfolder a -> File|FDirectory a |
||
169 | * @param mixed $start_value |
||
170 | */ |
||
171 | 5 | final public static function ana(\Closure $unfolder, $start_value) : FSObject |
|
184 | } |
||
185 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.