1212use OC \Files \Storage \Storage ;
1313use OC \Files \Storage \Wrapper \Wrapper ;
1414use OCP \Constants ;
15+ use OCP \Files \Cache \ICache ;
1516use OCP \Files \ForbiddenException ;
1617use OCP \Files \Storage \IStorage ;
1718use OCP \Files \Storage \IWriteStreamStorage ;
@@ -54,7 +55,7 @@ protected function checkFileAccess(string $path, ?bool $isDir = null): void {
5455 * @return bool
5556 * @throws ForbiddenException
5657 */
57- public function mkdir ($ path ) {
58+ public function mkdir ($ path ): bool {
5859 $ this ->checkFileAccess ($ path , true );
5960 return $ this ->storage ->mkdir ($ path );
6061 }
@@ -66,7 +67,7 @@ public function mkdir($path) {
6667 * @return bool
6768 * @throws ForbiddenException
6869 */
69- public function rmdir ($ path ) {
70+ public function rmdir ($ path ): bool {
7071 $ this ->checkFileAccess ($ path , true );
7172 return $ this ->storage ->rmdir ($ path );
7273 }
@@ -77,7 +78,7 @@ public function rmdir($path) {
7778 * @param string $path
7879 * @return bool
7980 */
80- public function isCreatable ($ path ) {
81+ public function isCreatable ($ path ): bool {
8182 try {
8283 $ this ->checkFileAccess ($ path );
8384 } catch (ForbiddenException $ e ) {
@@ -92,7 +93,7 @@ public function isCreatable($path) {
9293 * @param string $path
9394 * @return bool
9495 */
95- public function isReadable ($ path ) {
96+ public function isReadable ($ path ): bool {
9697 try {
9798 $ this ->checkFileAccess ($ path );
9899 } catch (ForbiddenException $ e ) {
@@ -107,7 +108,7 @@ public function isReadable($path) {
107108 * @param string $path
108109 * @return bool
109110 */
110- public function isUpdatable ($ path ) {
111+ public function isUpdatable ($ path ): bool {
111112 try {
112113 $ this ->checkFileAccess ($ path );
113114 } catch (ForbiddenException $ e ) {
@@ -122,7 +123,7 @@ public function isUpdatable($path) {
122123 * @param string $path
123124 * @return bool
124125 */
125- public function isDeletable ($ path ) {
126+ public function isDeletable ($ path ): bool {
126127 try {
127128 $ this ->checkFileAccess ($ path );
128129 } catch (ForbiddenException $ e ) {
@@ -131,7 +132,7 @@ public function isDeletable($path) {
131132 return $ this ->storage ->isDeletable ($ path );
132133 }
133134
134- public function getPermissions ($ path ) {
135+ public function getPermissions ($ path ): int {
135136 try {
136137 $ this ->checkFileAccess ($ path );
137138 } catch (ForbiddenException $ e ) {
@@ -147,7 +148,7 @@ public function getPermissions($path) {
147148 * @return string
148149 * @throws ForbiddenException
149150 */
150- public function file_get_contents ($ path ) {
151+ public function file_get_contents ($ path ): string | false {
151152 $ this ->checkFileAccess ($ path , false );
152153 return $ this ->storage ->file_get_contents ($ path );
153154 }
@@ -160,7 +161,7 @@ public function file_get_contents($path) {
160161 * @return bool
161162 * @throws ForbiddenException
162163 */
163- public function file_put_contents ($ path , $ data ) {
164+ public function file_put_contents ($ path , $ data ): int | float | false {
164165 $ this ->checkFileAccess ($ path , false );
165166 return $ this ->storage ->file_put_contents ($ path , $ data );
166167 }
@@ -172,24 +173,24 @@ public function file_put_contents($path, $data) {
172173 * @return bool
173174 * @throws ForbiddenException
174175 */
175- public function unlink ($ path ) {
176+ public function unlink ($ path ): bool {
176177 $ this ->checkFileAccess ($ path , false );
177178 return $ this ->storage ->unlink ($ path );
178179 }
179180
180181 /**
181182 * see http://php.net/manual/en/function.rename.php
182183 *
183- * @param string $path1
184- * @param string $path2
184+ * @param string $source
185+ * @param string $target
185186 * @return bool
186187 * @throws ForbiddenException
187188 */
188- public function rename ($ path1 , $ path2 ) {
189- $ isDir = $ this ->is_dir ($ path1 );
190- $ this ->checkFileAccess ($ path1 , $ isDir );
191- $ this ->checkFileAccess ($ path2 , $ isDir );
192- return $ this ->storage ->rename ($ path1 , $ path2 );
189+ public function rename ($ source , $ target ): bool {
190+ $ isDir = $ this ->is_dir ($ source );
191+ $ this ->checkFileAccess ($ source , $ isDir );
192+ $ this ->checkFileAccess ($ target , $ isDir );
193+ return $ this ->storage ->rename ($ source , $ target );
193194 }
194195
195196 /**
@@ -200,11 +201,11 @@ public function rename($path1, $path2) {
200201 * @return bool
201202 * @throws ForbiddenException
202203 */
203- public function copy ($ path1 , $ path2 ) {
204- $ isDir = $ this ->is_dir ($ path1 );
205- $ this ->checkFileAccess ($ path1 , $ isDir );
206- $ this ->checkFileAccess ($ path2 , $ isDir );
207- return $ this ->storage ->copy ($ path1 , $ path2 );
204+ public function copy ($ source , $ target ): bool {
205+ $ isDir = $ this ->is_dir ($ source );
206+ $ this ->checkFileAccess ($ source , $ isDir );
207+ $ this ->checkFileAccess ($ target , $ isDir );
208+ return $ this ->storage ->copy ($ source , $ target );
208209 }
209210
210211 /**
@@ -229,7 +230,7 @@ public function fopen($path, $mode) {
229230 * @return bool
230231 * @throws ForbiddenException
231232 */
232- public function touch ($ path , $ mtime = null ) {
233+ public function touch ($ path , $ mtime = null ): bool {
233234 $ this ->checkFileAccess ($ path , false );
234235 return $ this ->storage ->touch ($ path , $ mtime );
235236 }
@@ -241,7 +242,7 @@ public function touch($path, $mtime = null) {
241242 * @param Storage (optional) the storage to pass to the cache
242243 * @return Cache
243244 */
244- public function getCache ($ path = '' , $ storage = null ) {
245+ public function getCache ($ path = '' , $ storage = null ): ICache {
245246 if (!$ storage ) {
246247 $ storage = $ this ;
247248 }
@@ -258,7 +259,7 @@ public function getCache($path = '', $storage = null) {
258259 * @return array
259260 * @throws ForbiddenException
260261 */
261- public function getDirectDownload ($ path ) {
262+ public function getDirectDownload ($ path ): array | false {
262263 $ this ->checkFileAccess ($ path , false );
263264 return $ this ->storage ->getDirectDownload ($ path );
264265 }
@@ -270,7 +271,7 @@ public function getDirectDownload($path) {
270271 * @return bool
271272 * @throws ForbiddenException
272273 */
273- public function copyFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ) {
274+ public function copyFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ): bool {
274275 if ($ sourceStorage === $ this ) {
275276 return $ this ->copy ($ sourceInternalPath , $ targetInternalPath );
276277 }
@@ -286,7 +287,7 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
286287 * @return bool
287288 * @throws ForbiddenException
288289 */
289- public function moveFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ) {
290+ public function moveFromStorage (IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath ): bool {
290291 if ($ sourceStorage === $ this ) {
291292 return $ this ->rename ($ sourceInternalPath , $ targetInternalPath );
292293 }
0 commit comments