1 | <?php |
||
14 | class FilesystemWrapper implements FilesystemWrapperInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var FilesystemInterface |
||
18 | */ |
||
19 | private $fileSystem; |
||
20 | |||
21 | /** |
||
22 | * FilesystemWrapper constructor. |
||
23 | * |
||
24 | * @param FilesystemInterface $fileSystem |
||
25 | */ |
||
26 | 117 | public function __construct(FilesystemInterface $fileSystem) |
|
30 | |||
31 | /** |
||
32 | * Check whether a file exists. |
||
33 | * |
||
34 | * @param string $path |
||
35 | * |
||
36 | * @return bool |
||
37 | */ |
||
38 | 69 | public function has($path) |
|
42 | |||
43 | /** |
||
44 | * Read a file. |
||
45 | * |
||
46 | * @param string $path The path to the file. |
||
47 | * |
||
48 | * @throws FileNotFoundException |
||
49 | * |
||
50 | * @return string|false The file contents or false on failure. |
||
51 | */ |
||
52 | 25 | public function read($path) |
|
56 | |||
57 | /** |
||
58 | * Retrieves a read-stream for a path. |
||
59 | * |
||
60 | * @param string $path The path to the file. |
||
61 | * |
||
62 | * @throws FileNotFoundException |
||
63 | * |
||
64 | * @return resource|false The path resource or false on failure. |
||
65 | */ |
||
66 | 8 | public function readStream($path) |
|
70 | |||
71 | /** |
||
72 | * List contents of a directory. |
||
73 | * |
||
74 | * @param string $directory The directory to list. |
||
75 | * @param bool $recursive Whether to list recursively. |
||
76 | * |
||
77 | * @return array A list of file metadata. |
||
78 | */ |
||
79 | 1 | public function listContents($directory = '', $recursive = false) |
|
83 | |||
84 | /** |
||
85 | * Get a file's metadata. |
||
86 | * |
||
87 | * @param string $path The path to the file. |
||
88 | * |
||
89 | * @throws FileNotFoundException |
||
90 | * |
||
91 | * @return array|false The file metadata or false on failure. |
||
92 | */ |
||
93 | 1 | public function getMetadata($path) |
|
97 | |||
98 | /** |
||
99 | * Get a file's size. |
||
100 | * |
||
101 | * @param string $path The path to the file. |
||
102 | * |
||
103 | * @return int|false The file size or false on failure. |
||
104 | */ |
||
105 | 1 | public function getSize($path) |
|
109 | |||
110 | /** |
||
111 | * Get a file's mime-type. |
||
112 | * |
||
113 | * @param string $path The path to the file. |
||
114 | * |
||
115 | * @throws FileNotFoundException |
||
116 | * |
||
117 | * @return string|false The file mime-type or false on failure. |
||
118 | */ |
||
119 | 1 | public function getMimetype($path) |
|
123 | |||
124 | /** |
||
125 | * Get a file's timestamp. |
||
126 | * |
||
127 | * @param string $path The path to the file. |
||
128 | * |
||
129 | * @throws FileNotFoundException |
||
130 | * |
||
131 | * @return string|false The timestamp or false on failure. |
||
132 | */ |
||
133 | 1 | public function getTimestamp($path) |
|
137 | |||
138 | /** |
||
139 | * Get a file's visibility. |
||
140 | * |
||
141 | * @param string $path The path to the file. |
||
142 | * |
||
143 | * @throws FileNotFoundException |
||
144 | * |
||
145 | * @return string|false The visibility (public|private) or false on failure. |
||
146 | */ |
||
147 | 1 | public function getVisibility($path) |
|
151 | |||
152 | /** |
||
153 | * Write a new file. |
||
154 | * |
||
155 | * @param string $path The path of the new file. |
||
156 | * @param string $contents The file contents. |
||
157 | * @param array $config An optional configuration array. |
||
158 | * |
||
159 | * @throws FileExistsException |
||
160 | * |
||
161 | * @return bool True on success, false on failure. |
||
162 | */ |
||
163 | 2 | public function write($path, $contents, array $config = []) |
|
167 | |||
168 | /** |
||
169 | * Write a new file using a stream. |
||
170 | * |
||
171 | * @param string $path The path of the new file. |
||
172 | * @param resource $resource The file handle. |
||
173 | * @param array $config An optional configuration array. |
||
174 | * |
||
175 | * @throws \League\Flysystem\InvalidArgumentException If $resource is not a file handle. |
||
176 | * @throws FileExistsException |
||
177 | * |
||
178 | * @return bool True on success, false on failure. |
||
179 | */ |
||
180 | 4 | public function writeStream($path, $resource, array $config = []) |
|
184 | |||
185 | /** |
||
186 | * Update an existing file. |
||
187 | * |
||
188 | * @param string $path The path of the existing file. |
||
189 | * @param string $contents The file contents. |
||
190 | * @param array $config An optional configuration array. |
||
191 | * |
||
192 | * @throws FileNotFoundException |
||
193 | * |
||
194 | * @return bool True on success, false on failure. |
||
195 | */ |
||
196 | 1 | public function update($path, $contents, array $config = []) |
|
200 | |||
201 | /** |
||
202 | * Update an existing file using a stream. |
||
203 | * |
||
204 | * @param string $path The path of the existing file. |
||
205 | * @param resource $resource The file handle. |
||
206 | * @param array $config An optional configuration array. |
||
207 | * |
||
208 | * @throws \League\Flysystem\InvalidArgumentException If $resource is not a file handle. |
||
209 | * @throws FileNotFoundException |
||
210 | * |
||
211 | * @return bool True on success, false on failure. |
||
212 | */ |
||
213 | 1 | public function updateStream($path, $resource, array $config = []) |
|
217 | |||
218 | /** |
||
219 | * Rename a file. |
||
220 | * |
||
221 | * @param string $path Path to the existing file. |
||
222 | * @param string $newpath The new path of the file. |
||
223 | * |
||
224 | * @throws FileExistsException Thrown if $newpath exists. |
||
225 | * @throws FileNotFoundException Thrown if $path does not exist. |
||
226 | * |
||
227 | * @return bool True on success, false on failure. |
||
228 | */ |
||
229 | 1 | public function rename($path, $newpath) |
|
233 | |||
234 | /** |
||
235 | * Copy a file. |
||
236 | * |
||
237 | * @param string $path Path to the existing file. |
||
238 | * @param string $newpath The new path of the file. |
||
239 | * |
||
240 | * @throws FileExistsException Thrown if $newpath exists. |
||
241 | * @throws FileNotFoundException Thrown if $path does not exist. |
||
242 | * |
||
243 | * @return bool True on success, false on failure. |
||
244 | */ |
||
245 | 5 | public function copy($path, $newpath) |
|
249 | |||
250 | /** |
||
251 | * Delete a file. |
||
252 | * |
||
253 | * @param string $path |
||
254 | * |
||
255 | * @throws FileNotFoundException |
||
256 | * |
||
257 | * @return bool True on success, false on failure. |
||
258 | */ |
||
259 | 15 | public function delete($path) |
|
263 | |||
264 | /** |
||
265 | * Delete a directory. |
||
266 | * |
||
267 | * @param string $dirname |
||
268 | * |
||
269 | * @throws RootViolationException Thrown if $dirname is empty. |
||
270 | * |
||
271 | * @return bool True on success, false on failure. |
||
272 | */ |
||
273 | 1 | public function deleteDir($dirname) |
|
277 | |||
278 | /** |
||
279 | * Create a directory. |
||
280 | * |
||
281 | * @param string $dirname The name of the new directory. |
||
282 | * @param array $config An optional configuration array. |
||
283 | * |
||
284 | * @return bool True on success, false on failure. |
||
285 | */ |
||
286 | 10 | public function createDir($dirname, array $config = []) |
|
290 | |||
291 | /** |
||
292 | * Set the visibility for a file. |
||
293 | * |
||
294 | * @param string $path The path to the file. |
||
295 | * @param string $visibility One of 'public' or 'private'. |
||
296 | * |
||
297 | * @return bool True on success, false on failure. |
||
298 | */ |
||
299 | 1 | public function setVisibility($path, $visibility) |
|
303 | |||
304 | /** |
||
305 | * Create a file or update if exists. |
||
306 | * |
||
307 | * @param string $path The path to the file. |
||
308 | * @param string $contents The file contents. |
||
309 | * @param array $config An optional configuration array. |
||
310 | * |
||
311 | * @return bool True on success, false on failure. |
||
312 | */ |
||
313 | 86 | public function put($path, $contents, array $config = []) |
|
317 | |||
318 | /** |
||
319 | * Create a file or update if exists. |
||
320 | * |
||
321 | * @param string $path The path to the file. |
||
322 | * @param resource $resource The file handle. |
||
323 | * @param array $config An optional configuration array. |
||
324 | * |
||
325 | * @throws \League\Flysystem\InvalidArgumentException Thrown if $resource is not a resource. |
||
326 | * |
||
327 | * @return bool True on success, false on failure. |
||
328 | */ |
||
329 | 1 | public function putStream($path, $resource, array $config = []) |
|
333 | |||
334 | /** |
||
335 | * Read and delete a file. |
||
336 | * |
||
337 | * @param string $path The path to the file. |
||
338 | * |
||
339 | * @throws FileNotFoundException |
||
340 | * |
||
341 | * @return string|false The file contents, or false on failure. |
||
342 | */ |
||
343 | 1 | public function readAndDelete($path) |
|
347 | |||
348 | /** |
||
349 | * Get a file/directory handler. |
||
350 | * |
||
351 | * @param string $path The path to the file. |
||
352 | * @param Handler $handler An optional existing handler to populate. |
||
|
|||
353 | * |
||
354 | * @return Handler Either a file or directory handler. |
||
355 | */ |
||
356 | 1 | public function get($path, Handler $handler = null) |
|
360 | |||
361 | /** |
||
362 | * Register a plugin. |
||
363 | * |
||
364 | * @param PluginInterface $plugin The plugin to register. |
||
365 | * |
||
366 | * @return $this |
||
367 | */ |
||
368 | 1 | public function addPlugin(PluginInterface $plugin) |
|
372 | |||
373 | /** |
||
374 | * @return AdapterInterface |
||
375 | */ |
||
376 | 2 | public function getAdapter() |
|
385 | } |
||
386 |
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.