Skip to content

Commit

Permalink
fix(storage): Add return types that got added upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Sep 30, 2024
1 parent 3cf5c57 commit 4b3a3a8
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions lib/StorageWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OC\Files\Storage\Storage;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Constants;
use OCP\Files\Cache\ICache;
use OCP\Files\ForbiddenException;
use OCP\Files\Storage\IStorage;
use OCP\Files\Storage\IWriteStreamStorage;
Expand Down Expand Up @@ -54,7 +55,7 @@ protected function checkFileAccess(string $path, ?bool $isDir = null): void {
* @return bool
* @throws ForbiddenException
*/
public function mkdir($path) {
public function mkdir($path): bool {
$this->checkFileAccess($path, true);
return $this->storage->mkdir($path);
}
Expand All @@ -66,7 +67,7 @@ public function mkdir($path) {
* @return bool
* @throws ForbiddenException
*/
public function rmdir($path) {
public function rmdir($path): bool {
$this->checkFileAccess($path, true);
return $this->storage->rmdir($path);
}
Expand All @@ -77,7 +78,7 @@ public function rmdir($path) {
* @param string $path
* @return bool
*/
public function isCreatable($path) {
public function isCreatable($path): bool {
try {
$this->checkFileAccess($path);
} catch (ForbiddenException $e) {
Expand All @@ -92,7 +93,7 @@ public function isCreatable($path) {
* @param string $path
* @return bool
*/
public function isReadable($path) {
public function isReadable($path): bool {
try {
$this->checkFileAccess($path);
} catch (ForbiddenException $e) {
Expand All @@ -107,7 +108,7 @@ public function isReadable($path) {
* @param string $path
* @return bool
*/
public function isUpdatable($path) {
public function isUpdatable($path): bool {
try {
$this->checkFileAccess($path);
} catch (ForbiddenException $e) {
Expand All @@ -122,7 +123,7 @@ public function isUpdatable($path) {
* @param string $path
* @return bool
*/
public function isDeletable($path) {
public function isDeletable($path): bool {
try {
$this->checkFileAccess($path);
} catch (ForbiddenException $e) {
Expand All @@ -131,7 +132,7 @@ public function isDeletable($path) {
return $this->storage->isDeletable($path);
}

public function getPermissions($path) {
public function getPermissions($path): int {
try {
$this->checkFileAccess($path);
} catch (ForbiddenException $e) {
Expand All @@ -147,7 +148,7 @@ public function getPermissions($path) {
* @return string
* @throws ForbiddenException
*/
public function file_get_contents($path) {
public function file_get_contents($path): string|false {
$this->checkFileAccess($path, false);
return $this->storage->file_get_contents($path);
}
Expand All @@ -160,7 +161,7 @@ public function file_get_contents($path) {
* @return bool
* @throws ForbiddenException
*/
public function file_put_contents($path, $data) {
public function file_put_contents($path, $data): int|float|false {
$this->checkFileAccess($path, false);
return $this->storage->file_put_contents($path, $data);
}
Expand All @@ -172,24 +173,24 @@ public function file_put_contents($path, $data) {
* @return bool
* @throws ForbiddenException
*/
public function unlink($path) {
public function unlink($path): bool {
$this->checkFileAccess($path, false);
return $this->storage->unlink($path);
}

/**
* see http://php.net/manual/en/function.rename.php
*
* @param string $path1
* @param string $path2
* @param string $source
* @param string $target
* @return bool
* @throws ForbiddenException
*/
public function rename($path1, $path2) {
$isDir = $this->is_dir($path1);
$this->checkFileAccess($path1, $isDir);
$this->checkFileAccess($path2, $isDir);
return $this->storage->rename($path1, $path2);
public function rename($source, $target): bool {
$isDir = $this->is_dir($source);
$this->checkFileAccess($source, $isDir);
$this->checkFileAccess($target, $isDir);
return $this->storage->rename($source, $target);
}

/**
Expand All @@ -200,11 +201,11 @@ public function rename($path1, $path2) {
* @return bool
* @throws ForbiddenException
*/
public function copy($path1, $path2) {
$isDir = $this->is_dir($path1);
$this->checkFileAccess($path1, $isDir);
$this->checkFileAccess($path2, $isDir);
return $this->storage->copy($path1, $path2);
public function copy($source, $target): bool {
$isDir = $this->is_dir($source);
$this->checkFileAccess($source, $isDir);
$this->checkFileAccess($target, $isDir);
return $this->storage->copy($source, $target);
}

/**
Expand All @@ -229,7 +230,7 @@ public function fopen($path, $mode) {
* @return bool
* @throws ForbiddenException
*/
public function touch($path, $mtime = null) {
public function touch($path, $mtime = null): bool {
$this->checkFileAccess($path, false);
return $this->storage->touch($path, $mtime);
}
Expand All @@ -241,7 +242,7 @@ public function touch($path, $mtime = null) {
* @param Storage (optional) the storage to pass to the cache
* @return Cache
*/
public function getCache($path = '', $storage = null) {
public function getCache($path = '', $storage = null): ICache {
if (!$storage) {
$storage = $this;
}
Expand All @@ -258,7 +259,7 @@ public function getCache($path = '', $storage = null) {
* @return array
* @throws ForbiddenException
*/
public function getDirectDownload($path) {
public function getDirectDownload($path): array|false {
$this->checkFileAccess($path, false);
return $this->storage->getDirectDownload($path);
}
Expand All @@ -270,7 +271,7 @@ public function getDirectDownload($path) {
* @return bool
* @throws ForbiddenException
*/
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
if ($sourceStorage === $this) {
return $this->copy($sourceInternalPath, $targetInternalPath);
}
Expand All @@ -286,7 +287,7 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
* @return bool
* @throws ForbiddenException
*/
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
if ($sourceStorage === $this) {
return $this->rename($sourceInternalPath, $targetInternalPath);
}
Expand Down

0 comments on commit 4b3a3a8

Please sign in to comment.