aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-11-04 09:15:17 +0100
committerprovokateurin <kate@provokateurin.de>2024-11-04 10:30:52 +0100
commita0e2749513a7bec9b2e9bd26f1204f5a1f82fb4f (patch)
tree9ac27bc80f75efab57e7e7cdd42d91450485931d
parent1ca309c10497d7d48eb0ec02665a3bf091ce5e7e (diff)
downloadnextcloud-server-refactor/storage/strong-type-properties.tar.gz
nextcloud-server-refactor/storage/strong-type-properties.zip
refactor(files_sharing): Strong-type Storage propertiesrefactor/storage/strong-type-properties
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--apps/files_sharing/lib/SharedStorage.php61
-rw-r--r--build/psalm-baseline.xml11
2 files changed, 15 insertions, 57 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index fc1ee9341c0..c4ffbddfbde 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -45,49 +45,21 @@ use Psr\Log\LoggerInterface;
* Convert target path to source path and pass the function call to the correct storage provider
*/
class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage, IDisableEncryptionStorage {
- /** @var IShare */
- private $superShare;
-
- /** @var IShare[] */
- private $groupedShares;
-
- /**
- * @var View
- */
- private $ownerView;
-
- private $initialized = false;
-
- /**
- * @var ICacheEntry
- */
- private $sourceRootInfo;
-
- /** @var string */
- private $user;
-
+ private IShare $superShare;
+ /** @var list<IShare> */
+ private array $groupedShares;
+ private View $ownerView;
+ private bool $initialized = false;
+ private ICacheEntry|false|null $sourceRootInfo = null;
+ private string $user;
private LoggerInterface $logger;
-
- /** @var IStorage */
- private $nonMaskedStorage;
-
+ private ?IStorage $nonMaskedStorage = null;
private array $mountOptions = [];
-
- /** @var boolean */
- private $sharingDisabledForUser;
-
- /** @var ?Folder $ownerUserFolder */
- private $ownerUserFolder = null;
-
+ private bool $sharingDisabledForUser;
+ private ?Folder $ownerUserFolder = null;
private string $sourcePath = '';
-
private static int $initDepth = 0;
-
- /**
- * @psalm-suppress NonInvariantDocblockPropertyType
- * @var ?Storage $storage
- */
- protected $storage;
+ protected ?Storage $storage;
public function __construct(array $parameters) {
$this->ownerView = $parameters['ownerView'];
@@ -105,14 +77,11 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
parent::__construct([
'storage' => null,
- 'root' => null,
+ 'root' => '',
]);
}
- /**
- * @return ICacheEntry
- */
- private function getSourceRootInfo() {
+ private function getSourceRootInfo(): ICacheEntry|false|null {
if (is_null($this->sourceRootInfo)) {
if (is_null($this->superShare->getNodeCacheEntry())) {
$this->init();
@@ -127,7 +96,7 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
/**
* @psalm-assert Storage $this->storage
*/
- private function init() {
+ private function init(): void {
if ($this->initialized) {
if (!$this->storage) {
// marked as initialized but no storage set
@@ -508,7 +477,7 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
// shares do not participate in availability logic
}
- public function getSourceStorage() {
+ public function getSourceStorage(): ?IStorage {
$this->init();
return $this->nonMaskedStorage;
}
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 824431c46a5..79bdaaa0a0b 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -907,17 +907,6 @@
<code><![CDATA[bool]]></code>
</InvalidReturnType>
</file>
- <file src="apps/files_sharing/lib/SharedStorage.php">
- <FalsableReturnStatement>
- <code><![CDATA[$this->sourceRootInfo]]></code>
- </FalsableReturnStatement>
- <InvalidNullableReturnType>
- <code><![CDATA[ICacheEntry]]></code>
- </InvalidNullableReturnType>
- <NullableReturnStatement>
- <code><![CDATA[$this->sourceRootInfo]]></code>
- </NullableReturnStatement>
- </file>
<file src="apps/files_sharing/lib/Updater.php">
<UndefinedMethod>
<code><![CDATA[moveMount]]></code>