Skip to content

Commit e7b709d

Browse files
committed
refactor(objectstorage): cleanup types
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
1 parent 72999b4 commit e7b709d

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
namespace OC\Files\ObjectStore;
2727

2828
class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage {
29-
/** @var string */
30-
private $internalId;
29+
private string $internalId;
3130

31+
/**
32+
* @param array $params
33+
* @throws \Exception
34+
*/
3235
public function __construct($params) {
3336
if (!isset($params['internal-id'])) {
3437
throw new \Exception('missing id in parameters');
@@ -37,7 +40,7 @@ public function __construct($params) {
3740
parent::__construct($params);
3841
}
3942

40-
public function getId() {
43+
public function getId(): string {
4144
return 'object::appdata::preview:' . $this->internalId;
4245
}
4346
}

lib/private/Files/ObjectStore/HomeObjectStoreStorage.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727
namespace OC\Files\ObjectStore;
2828

29+
use Exception;
2930
use OCP\Files\IHomeStorage;
3031
use OCP\IUser;
3132

@@ -34,31 +35,30 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage
3435

3536
/**
3637
* The home user storage requires a user object to create a unique storage id
38+
*
3739
* @param array $params
40+
* @throws Exception
3841
*/
3942
public function __construct($params) {
4043
if (! isset($params['user']) || ! $params['user'] instanceof IUser) {
41-
throw new \Exception('missing user object in parameters');
44+
throw new Exception('missing user object in parameters');
4245
}
4346
$this->user = $params['user'];
4447
parent::__construct($params);
4548
}
4649

47-
public function getId() {
50+
public function getId(): string {
4851
return 'object::user:' . $this->user->getUID();
4952
}
5053

5154
/**
5255
* get the owner of a path
5356
*
5457
* @param string $path The path to get the owner
55-
* @return false|string uid
58+
* @return string uid
5659
*/
57-
public function getOwner($path) {
58-
if (is_object($this->user)) {
59-
return $this->user->getUID();
60-
}
61-
return false;
60+
public function getOwner($path): string {
61+
return $this->user->getUID();
6262
}
6363

6464
public function getUser(): IUser {

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload;
4848
use OCP\Files\Storage\IChunkedFileWrite;
4949
use OCP\Files\Storage\IStorage;
50+
use OCP\ILogger;
5051

5152
class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFileWrite {
5253
use CopyDirectory;
@@ -55,13 +56,15 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
5556
protected string $id;
5657
private string $objectPrefix = 'urn:oid:';
5758

58-
private $logger;
59+
private ILogger $logger;
5960

6061
private bool $handleCopiesAsOwned;
62+
protected bool $validateWrites = true;
6163

62-
/** @var bool */
63-
protected $validateWrites = true;
64-
64+
/**
65+
* @param array $params
66+
* @throws \Exception
67+
*/
6568
public function __construct($params) {
6669
if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
6770
$this->objectStore = $params['objectstore'];

tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
* Allow overwriting the object store instance for test purposes
3131
*/
3232
class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
33-
public function setObjectStore(IObjectStore $objectStore) {
33+
public function setObjectStore(IObjectStore $objectStore): void {
3434
$this->objectStore = $objectStore;
3535
}
3636

3737
public function getObjectStore(): IObjectStore {
3838
return $this->objectStore;
3939
}
4040

41-
public function setValidateWrites(bool $validate) {
41+
public function setValidateWrites(bool $validate): void {
4242
$this->validateWrites = $validate;
4343
}
4444
}

0 commit comments

Comments
 (0)