@@ -59,11 +59,7 @@ public function __construct($parameters) {
5959 $ this ->logger = Server::get (LoggerInterface::class);
6060 }
6161
62- /**
63- * @param string $path
64- * @return string correctly encoded path
65- */
66- private function normalizePath ($ path ): string {
62+ private function normalizePath (string $ path ): string {
6763 $ path = trim ($ path , '/ ' );
6864
6965 if (!$ path ) {
@@ -73,11 +69,11 @@ private function normalizePath($path): string {
7369 return $ path ;
7470 }
7571
76- private function isRoot ($ path ): bool {
72+ private function isRoot (string $ path ): bool {
7773 return $ path === '. ' ;
7874 }
7975
80- private function cleanKey ($ path ): string {
76+ private function cleanKey (string $ path ): string {
8177 if ($ this ->isRoot ($ path )) {
8278 return '/ ' ;
8379 }
@@ -90,7 +86,7 @@ private function clearCache(): void {
9086 $ this ->filesCache = new CappedMemoryCache ();
9187 }
9288
93- private function invalidateCache ($ key ): void {
89+ private function invalidateCache (string $ key ): void {
9490 unset($ this ->objectCache [$ key ]);
9591 $ keys = array_keys ($ this ->objectCache ->getData ());
9692 $ keyLength = strlen ($ key );
@@ -143,7 +139,7 @@ private function headObject(string $key): array|false {
143139 *
144140 * @throws \Exception
145141 */
146- private function doesDirectoryExist ($ path ): bool {
142+ private function doesDirectoryExist (string $ path ): bool {
147143 if ($ path === '. ' || $ path === '' ) {
148144 return true ;
149145 }
@@ -185,7 +181,7 @@ private function doesDirectoryExist($path): bool {
185181 return false ;
186182 }
187183
188- protected function remove ($ path ): bool {
184+ protected function remove (string $ path ): bool {
189185 // remember fileType to reduce http calls
190186 $ fileType = $ this ->filetype ($ path );
191187 if ($ fileType === 'dir ' ) {
@@ -197,7 +193,7 @@ protected function remove($path): bool {
197193 }
198194 }
199195
200- public function mkdir ($ path ): bool {
196+ public function mkdir (string $ path ): bool {
201197 $ path = $ this ->normalizePath ($ path );
202198
203199 if ($ this ->is_dir ($ path )) {
@@ -225,12 +221,12 @@ public function mkdir($path): bool {
225221 return true ;
226222 }
227223
228- public function file_exists ($ path ): bool {
224+ public function file_exists (string $ path ): bool {
229225 return $ this ->filetype ($ path ) !== false ;
230226 }
231227
232228
233- public function rmdir ($ path ): bool {
229+ public function rmdir (string $ path ): bool {
234230 $ path = $ this ->normalizePath ($ path );
235231
236232 if ($ this ->isRoot ($ path )) {
@@ -250,7 +246,7 @@ protected function clearBucket(): bool {
250246 return $ this ->batchDelete ();
251247 }
252248
253- private function batchDelete ($ path = null ): bool {
249+ private function batchDelete (? string $ path = null ): bool {
254250 // TODO explore using https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.S3.BatchDelete.html
255251 $ params = [
256252 'Bucket ' => $ this ->bucket
@@ -290,7 +286,7 @@ private function batchDelete($path = null): bool {
290286 return true ;
291287 }
292288
293- public function opendir ($ path ) {
289+ public function opendir (string $ path ) {
294290 try {
295291 $ content = iterator_to_array ($ this ->getDirectoryContent ($ path ));
296292 return IteratorDirectory::wrap (array_map (function (array $ item ) {
@@ -301,7 +297,7 @@ public function opendir($path) {
301297 }
302298 }
303299
304- public function stat ($ path ): array |false {
300+ public function stat (string $ path ): array |false {
305301 $ path = $ this ->normalizePath ($ path );
306302
307303 if ($ this ->is_dir ($ path )) {
@@ -324,7 +320,7 @@ public function stat($path): array|false {
324320 * When the information is already present (e.g. opendir has been called before)
325321 * this value is return. Otherwise a headObject is emitted.
326322 */
327- private function getContentLength ($ path ): int {
323+ private function getContentLength (string $ path ): int {
328324 if (isset ($ this ->filesCache [$ path ])) {
329325 return (int )$ this ->filesCache [$ path ]['ContentLength ' ];
330326 }
@@ -343,7 +339,7 @@ private function getContentLength($path): int {
343339 * When the information is already present (e.g. opendir has been called before)
344340 * this value is return. Otherwise a headObject is emitted.
345341 */
346- private function getLastModified ($ path ): string {
342+ private function getLastModified (string $ path ): string {
347343 if (isset ($ this ->filesCache [$ path ])) {
348344 return $ this ->filesCache [$ path ]['LastModified ' ];
349345 }
@@ -356,7 +352,7 @@ private function getLastModified($path): string {
356352 return 'now ' ;
357353 }
358354
359- public function is_dir ($ path ): bool {
355+ public function is_dir (string $ path ): bool {
360356 $ path = $ this ->normalizePath ($ path );
361357
362358 if (isset ($ this ->filesCache [$ path ])) {
@@ -374,7 +370,7 @@ public function is_dir($path): bool {
374370 }
375371 }
376372
377- public function filetype ($ path ): string |false {
373+ public function filetype (string $ path ): string |false {
378374 $ path = $ this ->normalizePath ($ path );
379375
380376 if ($ this ->isRoot ($ path )) {
@@ -402,15 +398,15 @@ public function filetype($path): string|false {
402398 return false ;
403399 }
404400
405- public function getPermissions ($ path ): int {
401+ public function getPermissions (string $ path ): int {
406402 $ type = $ this ->filetype ($ path );
407403 if (!$ type ) {
408404 return 0 ;
409405 }
410406 return $ type === 'dir ' ? Constants::PERMISSION_ALL : Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE ;
411407 }
412408
413- public function unlink ($ path ): bool {
409+ public function unlink (string $ path ): bool {
414410 $ path = $ this ->normalizePath ($ path );
415411
416412 if ($ this ->is_dir ($ path )) {
@@ -431,7 +427,7 @@ public function unlink($path): bool {
431427 return true ;
432428 }
433429
434- public function fopen ($ path , $ mode ) {
430+ public function fopen (string $ path , string $ mode ) {
435431 $ path = $ this ->normalizePath ($ path );
436432
437433 switch ($ mode ) {
@@ -489,7 +485,7 @@ public function fopen($path, $mode) {
489485 return false ;
490486 }
491487
492- public function touch ($ path , $ mtime = null ): bool {
488+ public function touch (string $ path , ? int $ mtime = null ): bool {
493489 if (is_null ($ mtime )) {
494490 $ mtime = time ();
495491 }
@@ -524,7 +520,7 @@ public function touch($path, $mtime = null): bool {
524520 return true ;
525521 }
526522
527- public function copy ($ source , $ target , $ isFile = null ): bool {
523+ public function copy (string $ source , string $ target , ? bool $ isFile = null ): bool {
528524 $ source = $ this ->normalizePath ($ source );
529525 $ target = $ this ->normalizePath ($ target );
530526
@@ -567,7 +563,7 @@ public function copy($source, $target, $isFile = null): bool {
567563 return true ;
568564 }
569565
570- public function rename ($ source , $ target ): bool {
566+ public function rename (string $ source , string $ target ): bool {
571567 $ source = $ this ->normalizePath ($ source );
572568 $ target = $ this ->normalizePath ($ target );
573569
@@ -605,7 +601,7 @@ public function getId(): string {
605601 return $ this ->id ;
606602 }
607603
608- public function writeBack ($ tmpFile , $ path ): bool {
604+ public function writeBack (string $ tmpFile , string $ path ): bool {
609605 try {
610606 $ source = fopen ($ tmpFile , 'r ' );
611607 $ this ->writeObject ($ path , $ source , $ this ->mimeDetector ->detectPath ($ path ));
@@ -629,7 +625,7 @@ public static function checkDependencies(): bool {
629625 return true ;
630626 }
631627
632- public function getDirectoryContent ($ directory ): \Traversable {
628+ public function getDirectoryContent (string $ directory ): \Traversable {
633629 $ path = $ this ->normalizePath ($ directory );
634630
635631 if ($ this ->isRoot ($ path )) {
@@ -726,7 +722,7 @@ protected function getVersioningStatusFromBucket(): bool {
726722 }
727723 }
728724
729- public function hasUpdated ($ path , $ time ): bool {
725+ public function hasUpdated (string $ path , int $ time ): bool {
730726 // for files we can get the proper mtime
731727 if ($ path !== '' && $ object = $ this ->headObject ($ path )) {
732728 $ stat = $ this ->objectToMetaData ($ object );
0 commit comments