1 | <?php |
||
25 | class FilesystemWrapper implements FilesystemWrapperInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var FilesystemInterface |
||
29 | */ |
||
30 | private $fileSystem; |
||
31 | |||
32 | /** |
||
33 | * FilesystemWrapper constructor. |
||
34 | * |
||
35 | * @param FilesystemInterface $fileSystem |
||
36 | */ |
||
37 | 117 | public function __construct(FilesystemInterface $fileSystem) |
|
41 | |||
42 | /** |
||
43 | * Check whether a file exists. |
||
44 | * |
||
45 | * @param string $path |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | 69 | public function has($path) |
|
53 | |||
54 | /** |
||
55 | * Read a file. |
||
56 | * |
||
57 | * @param string $path The path to the file. |
||
58 | * |
||
59 | * @throws FileNotFoundException |
||
60 | * |
||
61 | * @return string|false The file contents or false on failure. |
||
62 | */ |
||
63 | 25 | public function read($path) |
|
67 | |||
68 | /** |
||
69 | * Retrieves a read-stream for a path. |
||
70 | * |
||
71 | * @param string $path The path to the file. |
||
72 | * |
||
73 | * @throws FileNotFoundException |
||
74 | * |
||
75 | * @return resource|false The path resource or false on failure. |
||
76 | */ |
||
77 | 8 | public function readStream($path) |
|
81 | |||
82 | /** |
||
83 | * List contents of a directory. |
||
84 | * |
||
85 | * @param string $directory The directory to list. |
||
86 | * @param bool $recursive Whether to list recursively. |
||
87 | * |
||
88 | * @return array A list of file metadata. |
||
89 | */ |
||
90 | 1 | public function listContents($directory = '', $recursive = false) |
|
94 | |||
95 | /** |
||
96 | * Get a file's metadata. |
||
97 | * |
||
98 | * @param string $path The path to the file. |
||
99 | * |
||
100 | * @throws FileNotFoundException |
||
101 | * |
||
102 | * @return array|false The file metadata or false on failure. |
||
103 | */ |
||
104 | 1 | public function getMetadata($path) |
|
108 | |||
109 | /** |
||
110 | * Get a file's size. |
||
111 | * |
||
112 | * @param string $path The path to the file. |
||
113 | * |
||
114 | * @return int|false The file size or false on failure. |
||
115 | */ |
||
116 | 1 | public function getSize($path) |
|
120 | |||
121 | /** |
||
122 | * Get a file's mime-type. |
||
123 | * |
||
124 | * @param string $path The path to the file. |
||
125 | * |
||
126 | * @throws FileNotFoundException |
||
127 | * |
||
128 | * @return string|false The file mime-type or false on failure. |
||
129 | */ |
||
130 | 1 | public function getMimetype($path) |
|
134 | |||
135 | /** |
||
136 | * Get a file's timestamp. |
||
137 | * |
||
138 | * @param string $path The path to the file. |
||
139 | * |
||
140 | * @throws FileNotFoundException |
||
141 | * |
||
142 | * @return string|false The timestamp or false on failure. |
||
143 | */ |
||
144 | 1 | public function getTimestamp($path) |
|
148 | |||
149 | /** |
||
150 | * Get a file's visibility. |
||
151 | * |
||
152 | * @param string $path The path to the file. |
||
153 | * |
||
154 | * @throws FileNotFoundException |
||
155 | * |
||
156 | * @return string|false The visibility (public|private) or false on failure. |
||
157 | */ |
||
158 | 1 | public function getVisibility($path) |
|
162 | |||
163 | /** |
||
164 | * Write a new file. |
||
165 | * |
||
166 | * @param string $path The path of the new file. |
||
167 | * @param string $contents The file contents. |
||
168 | * @param array $config An optional configuration array. |
||
169 | * |
||
170 | * @throws FileExistsException |
||
171 | * |
||
172 | * @return bool True on success, false on failure. |
||
173 | */ |
||
174 | 2 | public function write($path, $contents, array $config = []) |
|
178 | |||
179 | /** |
||
180 | * Write a new file using a stream. |
||
181 | * |
||
182 | * @param string $path The path of the new file. |
||
183 | * @param resource $resource The file handle. |
||
184 | * @param array $config An optional configuration array. |
||
185 | * |
||
186 | * @throws \League\Flysystem\InvalidArgumentException If $resource is not a file handle. |
||
187 | * @throws FileExistsException |
||
188 | * |
||
189 | * @return bool True on success, false on failure. |
||
190 | */ |
||
191 | 4 | public function writeStream($path, $resource, array $config = []) |
|
195 | |||
196 | /** |
||
197 | * Update an existing file. |
||
198 | * |
||
199 | * @param string $path The path of the existing file. |
||
200 | * @param string $contents The file contents. |
||
201 | * @param array $config An optional configuration array. |
||
202 | * |
||
203 | * @throws FileNotFoundException |
||
204 | * |
||
205 | * @return bool True on success, false on failure. |
||
206 | */ |
||
207 | 1 | public function update($path, $contents, array $config = []) |
|
211 | |||
212 | /** |
||
213 | * Update an existing file using a stream. |
||
214 | * |
||
215 | * @param string $path The path of the existing file. |
||
216 | * @param resource $resource The file handle. |
||
217 | * @param array $config An optional configuration array. |
||
218 | * |
||
219 | * @throws \League\Flysystem\InvalidArgumentException If $resource is not a file handle. |
||
220 | * @throws FileNotFoundException |
||
221 | * |
||
222 | * @return bool True on success, false on failure. |
||
223 | */ |
||
224 | 1 | public function updateStream($path, $resource, array $config = []) |
|
228 | |||
229 | /** |
||
230 | * Rename a file. |
||
231 | * |
||
232 | * @param string $path Path to the existing file. |
||
233 | * @param string $newpath The new path of the file. |
||
234 | * |
||
235 | * @throws FileExistsException Thrown if $newpath exists. |
||
236 | * @throws FileNotFoundException Thrown if $path does not exist. |
||
237 | * |
||
238 | * @return bool True on success, false on failure. |
||
239 | */ |
||
240 | 1 | public function rename($path, $newpath) |
|
244 | |||
245 | /** |
||
246 | * Copy a file. |
||
247 | * |
||
248 | * @param string $path Path to the existing file. |
||
249 | * @param string $newpath The new path of the file. |
||
250 | * |
||
251 | * @throws FileExistsException Thrown if $newpath exists. |
||
252 | * @throws FileNotFoundException Thrown if $path does not exist. |
||
253 | * |
||
254 | * @return bool True on success, false on failure. |
||
255 | */ |
||
256 | 5 | public function copy($path, $newpath) |
|
260 | |||
261 | /** |
||
262 | * Delete a file. |
||
263 | * |
||
264 | * @param string $path |
||
265 | * |
||
266 | * @throws FileNotFoundException |
||
267 | * |
||
268 | * @return bool True on success, false on failure. |
||
269 | */ |
||
270 | 15 | public function delete($path) |
|
274 | |||
275 | /** |
||
276 | * Delete a directory. |
||
277 | * |
||
278 | * @param string $dirname |
||
279 | * |
||
280 | * @throws RootViolationException Thrown if $dirname is empty. |
||
281 | * |
||
282 | * @return bool True on success, false on failure. |
||
283 | */ |
||
284 | 1 | public function deleteDir($dirname) |
|
288 | |||
289 | /** |
||
290 | * Create a directory. |
||
291 | * |
||
292 | * @param string $dirname The name of the new directory. |
||
293 | * @param array $config An optional configuration array. |
||
294 | * |
||
295 | * @return bool True on success, false on failure. |
||
296 | */ |
||
297 | 10 | public function createDir($dirname, array $config = []) |
|
301 | |||
302 | /** |
||
303 | * Set the visibility for a file. |
||
304 | * |
||
305 | * @param string $path The path to the file. |
||
306 | * @param string $visibility One of 'public' or 'private'. |
||
307 | * |
||
308 | * @return bool True on success, false on failure. |
||
309 | */ |
||
310 | 1 | public function setVisibility($path, $visibility) |
|
314 | |||
315 | /** |
||
316 | * Create a file or update if exists. |
||
317 | * |
||
318 | * @param string $path The path to the file. |
||
319 | * @param string $contents The file contents. |
||
320 | * @param array $config An optional configuration array. |
||
321 | * |
||
322 | * @return bool True on success, false on failure. |
||
323 | */ |
||
324 | 86 | public function put($path, $contents, array $config = []) |
|
328 | |||
329 | /** |
||
330 | * Create a file or update if exists. |
||
331 | * |
||
332 | * @param string $path The path to the file. |
||
333 | * @param resource $resource The file handle. |
||
334 | * @param array $config An optional configuration array. |
||
335 | * |
||
336 | * @throws \League\Flysystem\InvalidArgumentException Thrown if $resource is not a resource. |
||
337 | * |
||
338 | * @return bool True on success, false on failure. |
||
339 | */ |
||
340 | 1 | public function putStream($path, $resource, array $config = []) |
|
344 | |||
345 | /** |
||
346 | * Read and delete a file. |
||
347 | * |
||
348 | * @param string $path The path to the file. |
||
349 | * |
||
350 | * @throws FileNotFoundException |
||
351 | * |
||
352 | * @return string|false The file contents, or false on failure. |
||
353 | */ |
||
354 | 1 | public function readAndDelete($path) |
|
358 | |||
359 | /** |
||
360 | * Get a file/directory handler. |
||
361 | * |
||
362 | * @param string $path The path to the file. |
||
363 | * @param Handler $handler An optional existing handler to populate. |
||
|
|||
364 | * |
||
365 | * @return Handler Either a file or directory handler. |
||
366 | */ |
||
367 | 1 | public function get($path, Handler $handler = null) |
|
371 | |||
372 | /** |
||
373 | * Register a plugin. |
||
374 | * |
||
375 | * @param PluginInterface $plugin The plugin to register. |
||
376 | * |
||
377 | * @return $this |
||
378 | */ |
||
379 | 1 | public function addPlugin(PluginInterface $plugin) |
|
383 | |||
384 | /** |
||
385 | * @return AdapterInterface |
||
386 | */ |
||
387 | 2 | public function getAdapter() |
|
396 | } |
||
397 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.