aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2024-10-07 14:37:25 +0200
committerGitHub <noreply@github.com>2024-10-07 14:37:25 +0200
commit414430980a9efa3ced924d092ef50d336b2b7dde (patch)
tree78635302621e721c0ffc890d81afe56df25b8cd8 /lib/private
parentbbb6cb2eb01937ca5346b30b44e1969eb1eb0807 (diff)
parent4412b2b8a8842718ad194d1b1715a6488f15af75 (diff)
downloadnextcloud-server-414430980a9efa3ced924d092ef50d336b2b7dde.tar.gz
nextcloud-server-414430980a9efa3ced924d092ef50d336b2b7dde.zip
Merge pull request #48487 from nextcloud/refactor/stream-encryption/typings
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php74
-rw-r--r--lib/private/Files/Stream/Encryption.php116
2 files changed, 57 insertions, 133 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index f2f3cdb94f6..a4e8a571f42 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -29,76 +29,32 @@ use Psr\Log\LoggerInterface;
class Encryption extends Wrapper {
use LocalTempFileTrait;
- /** @var string */
- private $mountPoint;
-
- /** @var \OC\Encryption\Util */
- private $util;
-
- /** @var \OCP\Encryption\IManager */
- private $encryptionManager;
-
- private LoggerInterface $logger;
-
- /** @var string */
- private $uid;
-
- /** @var array */
- protected $unencryptedSize;
-
- /** @var \OCP\Encryption\IFile */
- private $fileHelper;
-
- /** @var IMountPoint */
- private $mount;
-
- /** @var IStorage */
- private $keyStorage;
-
- /** @var Update */
- private $update;
-
- /** @var Manager */
- private $mountManager;
-
- /** @var array remember for which path we execute the repair step to avoid recursions */
- private $fixUnencryptedSizeOf = [];
-
- /** @var ArrayCache */
- private $arrayCache;
-
+ private string $mountPoint;
+ protected array $unencryptedSize = [];
+ private IMountPoint $mount;
+ /** for which path we execute the repair step to avoid recursions */
+ private array $fixUnencryptedSizeOf = [];
/** @var CappedMemoryCache<bool> */
private CappedMemoryCache $encryptedPaths;
-
- private $enabled = true;
+ private bool $enabled = true;
/**
* @param array $parameters
*/
public function __construct(
$parameters,
- ?IManager $encryptionManager = null,
- ?Util $util = null,
- ?LoggerInterface $logger = null,
- ?IFile $fileHelper = null,
- $uid = null,
- ?IStorage $keyStorage = null,
- ?Update $update = null,
- ?Manager $mountManager = null,
- ?ArrayCache $arrayCache = null,
+ private IManager $encryptionManager,
+ private Util $util,
+ private LoggerInterface $logger,
+ private IFile $fileHelper,
+ private ?string $uid,
+ private IStorage $keyStorage,
+ private Update $update,
+ private Manager $mountManager,
+ private ArrayCache $arrayCache,
) {
$this->mountPoint = $parameters['mountPoint'];
$this->mount = $parameters['mount'];
- $this->encryptionManager = $encryptionManager;
- $this->util = $util;
- $this->logger = $logger;
- $this->uid = $uid;
- $this->fileHelper = $fileHelper;
- $this->keyStorage = $keyStorage;
- $this->unencryptedSize = [];
- $this->update = $update;
- $this->mountManager = $mountManager;
- $this->arrayCache = $arrayCache;
$this->encryptedPaths = new CappedMemoryCache();
parent::__construct($parameters);
}
diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php
index 8f08f925da0..10df9ae98e2 100644
--- a/lib/private/Files/Stream/Encryption.php
+++ b/lib/private/Files/Stream/Encryption.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -9,81 +11,42 @@ namespace OC\Files\Stream;
use Icewind\Streams\Wrapper;
use OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException;
+use OC\Encryption\File;
+use OC\Encryption\Util;
+use OC\Files\Storage\Storage;
+use OCP\Encryption\IEncryptionModule;
use function is_array;
use function stream_context_create;
class Encryption extends Wrapper {
- /** @var \OC\Encryption\Util */
- protected $util;
-
- /** @var \OC\Encryption\File */
- protected $file;
-
- /** @var \OCP\Encryption\IEncryptionModule */
- protected $encryptionModule;
-
- /** @var \OC\Files\Storage\Storage */
- protected $storage;
-
- /** @var \OC\Files\Storage\Wrapper\Encryption */
- protected $encryptionStorage;
-
- /** @var string */
- protected $internalPath;
-
- /** @var string */
- protected $cache;
-
- /** @var integer */
- protected $size;
-
- /** @var integer */
- protected $position;
-
- /** @var integer */
- protected $unencryptedSize;
-
- /** @var integer */
- protected $headerSize;
-
- /** @var integer */
- protected $unencryptedBlockSize;
-
- /** @var array */
- protected $header;
-
- /** @var string */
- protected $fullPath;
-
- /** @var bool */
- protected $signed;
-
+ protected Util $util;
+ protected File $file;
+ protected IEncryptionModule $encryptionModule;
+ protected Storage $storage;
+ protected \OC\Files\Storage\Wrapper\Encryption $encryptionStorage;
+ protected string $internalPath;
+ protected string $cache;
+ protected ?int $size = null;
+ protected int $position;
+ protected ?int $unencryptedSize = null;
+ protected int $headerSize;
+ protected int $unencryptedBlockSize;
+ protected array $header;
+ protected string $fullPath;
+ protected bool $signed;
/**
* header data returned by the encryption module, will be written to the file
* in case of a write operation
- *
- * @var array
*/
- protected $newHeader;
-
+ protected array $newHeader;
/**
* user who perform the read/write operation null for public access
- *
- * @var string
*/
- protected $uid;
-
- /** @var bool */
- protected $readOnly;
-
- /** @var bool */
- protected $writeFlag;
-
- /** @var array */
- protected $expectedContextProperties;
-
- /** @var bool */
- protected $fileUpdated;
+ protected string $uid;
+ protected bool $readOnly;
+ protected bool $writeFlag;
+ protected array $expectedContextProperties;
+ protected bool $fileUpdated;
public function __construct() {
$this->expectedContextProperties = [
@@ -113,11 +76,11 @@ class Encryption extends Wrapper {
* @param string $fullPath relative to data/
* @param array $header
* @param string $uid
- * @param \OCP\Encryption\IEncryptionModule $encryptionModule
- * @param \OC\Files\Storage\Storage $storage
+ * @param IEncryptionModule $encryptionModule
+ * @param Storage $storage
* @param \OC\Files\Storage\Wrapper\Encryption $encStorage
- * @param \OC\Encryption\Util $util
- * @param \OC\Encryption\File $file
+ * @param Util $util
+ * @param File $file
* @param string $mode
* @param int|float $size
* @param int|float $unencryptedSize
@@ -128,19 +91,24 @@ class Encryption extends Wrapper {
*
* @throws \BadMethodCallException
*/
- public static function wrap($source, $internalPath, $fullPath, array $header,
+ public static function wrap(
+ $source,
+ $internalPath,
+ $fullPath,
+ array $header,
$uid,
- \OCP\Encryption\IEncryptionModule $encryptionModule,
- \OC\Files\Storage\Storage $storage,
+ IEncryptionModule $encryptionModule,
+ Storage $storage,
\OC\Files\Storage\Wrapper\Encryption $encStorage,
- \OC\Encryption\Util $util,
- \OC\Encryption\File $file,
+ Util $util,
+ File $file,
$mode,
$size,
$unencryptedSize,
$headerSize,
$signed,
- $wrapper = Encryption::class) {
+ $wrapper = Encryption::class,
+ ) {
$context = stream_context_create([
'ocencryption' => [
'source' => $source,