aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-10-01 16:14:04 +0200
committerprovokateurin <kate@provokateurin.de>2024-10-07 15:00:07 +0200
commit6d8ffb381f82549846c54c94ce2fb93732b5a02b (patch)
tree403fd91a5935c293cd8e28c34412fe2a1cd7f855 /apps
parent2489608a72b51d4dd95b07bb0a21c92648544bd3 (diff)
downloadnextcloud-server-6d8ffb381f82549846c54c94ce2fb93732b5a02b.tar.gz
nextcloud-server-6d8ffb381f82549846c54c94ce2fb93732b5a02b.zip
refactor(files_trashbin): Add Storage parameter strong types
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/lib/Storage.php13
-rw-r--r--apps/files_trashbin/tests/StorageTest.php4
2 files changed, 7 insertions, 10 deletions
diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php
index 23a0e5bd919..c6f90b175b9 100644
--- a/apps/files_trashbin/lib/Storage.php
+++ b/apps/files_trashbin/lib/Storage.php
@@ -48,7 +48,7 @@ class Storage extends Wrapper {
parent::__construct($parameters);
}
- public function unlink($path): bool {
+ public function unlink(string $path): bool {
if ($this->trashEnabled) {
try {
return $this->doDelete($path, 'unlink');
@@ -65,7 +65,7 @@ class Storage extends Wrapper {
}
}
- public function rmdir($path): bool {
+ public function rmdir(string $path): bool {
if ($this->trashEnabled) {
return $this->doDelete($path, 'rmdir');
} else {
@@ -76,11 +76,8 @@ class Storage extends Wrapper {
/**
* check if it is a file located in data/user/files only files in the
* 'files' directory should be moved to the trash
- *
- * @param $path
- * @return bool
*/
- protected function shouldMoveToTrash($path): bool {
+ protected function shouldMoveToTrash(string $path): bool {
$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
$parts = explode('/', $normalized);
if (count($parts) < 4 || strpos($normalized, '/appdata_') === 0) {
@@ -130,7 +127,7 @@ class Storage extends Wrapper {
*
* @return bool true if the operation succeeded, false otherwise
*/
- private function doDelete($path, $method): bool {
+ private function doDelete(string $path, string $method): bool {
if (
!\OC::$server->getAppManager()->isEnabledForUser('files_trashbin')
|| (pathinfo($path, PATHINFO_EXTENSION) === 'part')
@@ -181,7 +178,7 @@ class Storage extends Wrapper {
return $this->mountPoint;
}
- public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
+ public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool {
$sourceIsTrashbin = $sourceStorage->instanceOfStorage(Storage::class);
try {
// the fallback for moving between storage involves a copy+delete
diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php
index 65e4d9a9bca..8271109037c 100644
--- a/apps/files_trashbin/tests/StorageTest.php
+++ b/apps/files_trashbin/tests/StorageTest.php
@@ -28,11 +28,11 @@ use Psr\Log\LoggerInterface;
use Test\Traits\MountProviderTrait;
class TemporaryNoCross extends Temporary {
- public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = null): bool {
+ public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, ?bool $preserveMtime = null): bool {
return Common::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime);
}
- public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
+ public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool {
return Common::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}
}