diff --git a/apps/dav/lib/Connector/Sabre/TagsPlugin.php b/apps/dav/lib/Connector/Sabre/TagsPlugin.php
index 5c1781c002d08..41d38f4a4e77d 100644
--- a/apps/dav/lib/Connector/Sabre/TagsPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/TagsPlugin.php
@@ -49,11 +49,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin {
* @var \Sabre\DAV\Server
*/
private $server;
-
- /**
- * @var ITags
- */
- private $tagger;
+ private ?ITags $tagger = null;
/**
* Array of file id to tags array
@@ -105,12 +101,17 @@ public function initialize(\Sabre\DAV\Server $server) {
*
* @return ITags tagger
*/
- private function getTagger() {
- if (!$this->tagger) {
- $this->tagger = $this->tagManager->load('files');
- assert($this->tagger !== null);
+ private function getTagger(): ITags {
+ if ($this->tagger) {
+ return $this->tagger;
+ }
+
+ $tagger = $this->tagManager->load('files');
+ if ($tagger === null) {
+ throw new \RuntimeException('Tagger not found for files');
}
- return $this->tagger;
+ $this->tagger = $tagger;
+ return $tagger;
}
/**
diff --git a/apps/federation/lib/SyncFederationAddressBooks.php b/apps/federation/lib/SyncFederationAddressBooks.php
index 0452c3e1fd0cb..51af00310e8c6 100644
--- a/apps/federation/lib/SyncFederationAddressBooks.php
+++ b/apps/federation/lib/SyncFederationAddressBooks.php
@@ -7,16 +7,16 @@
*/
namespace OCA\Federation;
-use OC\OCS\DiscoveryService;
use OCA\DAV\CardDAV\SyncService;
use OCP\AppFramework\Http;
+use OCP\OCS\IDiscoveryService;
use Psr\Log\LoggerInterface;
class SyncFederationAddressBooks {
public function __construct(
protected DbHandler $dbHandler,
private SyncService $syncService,
- private DiscoveryService $ocsDiscoveryService,
+ private IDiscoveryService $ocsDiscoveryService,
private LoggerInterface $logger,
) {
}
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 93c9d6e817d97..770c0c40e3f30 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -125,6 +125,8 @@ protected function setUp(): void {
return $fileInfo->getMimeType() === 'mimeWithPreview';
});
$this->dateTimeZone = $this->createMock(IDateTimeZone::class);
+ $this->dateTimeZone->method('getTimeZone')
+ ->willReturn(new \DateTimeZone('UTC'));
$this->logger = $this->createMock(LoggerInterface::class);
$this->factory = $this->createMock(IProviderFactory::class);
$this->mailer = $this->createMock(IMailer::class);
@@ -158,10 +160,7 @@ protected function setUp(): void {
}
- /**
- * @return ShareAPIController&MockObject
- */
- private function mockFormatShare() {
+ private function mockFormatShare(): ShareAPIController&MockObject {
return $this->getMockBuilder(ShareAPIController::class)
->setConstructorArgs([
$this->appName,
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index a62d004bd8757..c49f623b4cfcf 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -1050,9 +1050,6 @@ public function countObjects(?int $limit = null, ?int $offset = null) {
/**
* Returns the LDAP handler
*
- * @throws \OC\ServerNotAvailableException
- */
- /**
* @param mixed[] $arguments
* @return mixed
* @throws ServerNotAvailableException
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index f9bb48746ceea..5191ed6d2e09e 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -260,8 +260,7 @@ public function getUsers($search = '', $limit = 10, $offset = 0) {
/**
* checks whether a user is still available on LDAP
*
- * @param string|User $user either the Nextcloud user
- * name or an instance of that user
+ * @param string|User $user either the Nextcloud user id or an instance of that user
* @throws \Exception
* @throws ServerNotAvailableException
*/
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index be496793f4906..0a923a76f33bc 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -3473,16 +3473,16 @@
-
-
-
+
+
+
-
-
-
+
+
+
@@ -3593,16 +3593,6 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/core/routes.php b/core/routes.php
index 63350c969c016..81f84456d528d 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -5,7 +5,7 @@
use OC\Route\Router;
/**
- * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
diff --git a/lib/private/AppFramework/Bootstrap/ServiceAliasRegistration.php b/lib/private/AppFramework/Bootstrap/ServiceAliasRegistration.php
index 928965d1d528e..27a1b74759095 100644
--- a/lib/private/AppFramework/Bootstrap/ServiceAliasRegistration.php
+++ b/lib/private/AppFramework/Bootstrap/ServiceAliasRegistration.php
@@ -13,32 +13,26 @@
*/
class ServiceAliasRegistration extends ARegistration {
/**
- * @psalm-param string|class-string $alias
- * @paslm-param string|class-string $target
+ * @param class-string $alias
+ * @param class-string $target
*/
public function __construct(
string $appId,
- /**
- * @psalm-var string|class-string
- */
- private string $alias,
- /**
- * @psalm-var string|class-string
- */
- private string $target,
+ private readonly string $alias,
+ private readonly string $target,
) {
parent::__construct($appId);
}
/**
- * @psalm-return string|class-string
+ * @return class-string
*/
public function getAlias(): string {
return $this->alias;
}
/**
- * @psalm-return string|class-string
+ * @return class-string
*/
public function getTarget(): string {
return $this->target;
diff --git a/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php b/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php
index 1c1a222359045..a3195bb1b32f5 100644
--- a/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php
+++ b/lib/private/AppFramework/Bootstrap/ServiceFactoryRegistration.php
@@ -18,11 +18,11 @@ class ServiceFactoryRegistration extends ARegistration {
*/
private $factory;
+ /**
+ * @param class-string $name
+ */
public function __construct(
string $appId,
- /**
- * @psalm-var string|class-string
- */
private string $name,
callable $target,
private bool $shared,
diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
index 2da297ed91aea..f711618410b90 100644
--- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
+++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
@@ -19,7 +19,7 @@
use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\Settings\AuthorizedGroupMapper;
use OC\User\Session;
-use OCA\Talk\Controller\PageController;
+use OCA\Talk\Controller\PageController as TalkPageController;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
@@ -110,7 +110,7 @@ public function beforeController($controller, $methodName) {
$this->navigationManager->setActiveEntry($this->appName);
/** @psalm-suppress UndefinedClass */
- if (get_class($controller) === PageController::class && $methodName === 'showCall') {
+ if (get_class($controller) === TalkPageController::class && $methodName === 'showCall') {
$this->navigationManager->setActiveEntry('spreed');
}
diff --git a/lib/private/AppFramework/Routing/RouteActionHandler.php b/lib/private/AppFramework/Routing/RouteActionHandler.php
index 085ef7178b33d..bbccda74d0b2f 100644
--- a/lib/private/AppFramework/Routing/RouteActionHandler.php
+++ b/lib/private/AppFramework/Routing/RouteActionHandler.php
@@ -11,14 +11,10 @@
use OC\AppFramework\DependencyInjection\DIContainer;
class RouteActionHandler {
- /**
- * @param string $controllerName
- * @param string $actionName
- */
public function __construct(
private DIContainer $container,
- private $controllerName,
- private $actionName,
+ private string $controllerName,
+ private string $actionName,
) {
}
diff --git a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php
index 7572f997a5d89..cf18ae2afccbb 100644
--- a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php
+++ b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php
@@ -27,8 +27,7 @@
* @template-implements IEventListener
*/
class RemoteWipeEmailListener implements IEventListener {
- /** @var IL10N */
- private $l10n;
+ private IL10N $l10n;
public function __construct(
private IMailer $mailer,
diff --git a/lib/private/Authentication/Login/ALoginCommand.php b/lib/private/Authentication/Login/ALoginCommand.php
index a9f51f0da9e57..c60fef2019cf6 100644
--- a/lib/private/Authentication/Login/ALoginCommand.php
+++ b/lib/private/Authentication/Login/ALoginCommand.php
@@ -21,7 +21,7 @@ protected function processNextOrFinishSuccessfully(LoginData $loginData): LoginR
if ($this->next !== null) {
return $this->next->process($loginData);
} else {
- return LoginResult::success($loginData);
+ return LoginResult::success();
}
}
diff --git a/lib/private/Authentication/Login/LoggedInCheckCommand.php b/lib/private/Authentication/Login/LoggedInCheckCommand.php
index 5ffa4d5dd27b7..58a076919438a 100644
--- a/lib/private/Authentication/Login/LoggedInCheckCommand.php
+++ b/lib/private/Authentication/Login/LoggedInCheckCommand.php
@@ -30,7 +30,7 @@ public function process(LoginData $loginData): LoginResult {
$this->dispatcher->dispatchTyped(new LoginFailed($loginName, $password));
- return LoginResult::failure($loginData, LoginController::LOGIN_MSG_INVALIDPASSWORD);
+ return LoginResult::failure(LoginController::LOGIN_MSG_INVALIDPASSWORD);
}
return $this->processNextOrFinishSuccessfully($loginData);
diff --git a/lib/private/Authentication/Login/LoginResult.php b/lib/private/Authentication/Login/LoginResult.php
index a71ff6da55597..8a4b61db59e32 100644
--- a/lib/private/Authentication/Login/LoginResult.php
+++ b/lib/private/Authentication/Login/LoginResult.php
@@ -11,28 +11,24 @@
use OC\Core\Controller\LoginController;
class LoginResult {
- /** @var string|null */
- private $redirectUrl;
-
- /** @var string|null */
- private $errorMessage;
+ private ?string $redirectUrl = null;
+ private ?string $errorMessage = null;
private function __construct(
- private bool $success,
- private LoginData $loginData,
+ private readonly bool $success,
) {
}
- private function setRedirectUrl(string $url) {
+ private function setRedirectUrl(string $url): void {
$this->redirectUrl = $url;
}
- private function setErrorMessage(string $msg) {
+ private function setErrorMessage(string $msg): void {
$this->errorMessage = $msg;
}
- public static function success(LoginData $data, ?string $redirectUrl = null) {
- $result = new static(true, $data);
+ public static function success(?string $redirectUrl = null): self {
+ $result = new static(true);
if ($redirectUrl !== null) {
$result->setRedirectUrl($redirectUrl);
}
@@ -42,8 +38,8 @@ public static function success(LoginData $data, ?string $redirectUrl = null) {
/**
* @param LoginController::LOGIN_MSG_*|null $msg
*/
- public static function failure(LoginData $data, ?string $msg = null): LoginResult {
- $result = new static(false, $data);
+ public static function failure(?string $msg = null): self {
+ $result = new static(false);
if ($msg !== null) {
$result->setErrorMessage($msg);
}
diff --git a/lib/private/Authentication/Login/TwoFactorCommand.php b/lib/private/Authentication/Login/TwoFactorCommand.php
index e66d16dc735f5..af425744122b4 100644
--- a/lib/private/Authentication/Login/TwoFactorCommand.php
+++ b/lib/private/Authentication/Login/TwoFactorCommand.php
@@ -58,7 +58,6 @@ public function process(LoginData $loginData): LoginResult {
}
return LoginResult::success(
- $loginData,
$this->urlGenerator->linkToRoute($url, $urlParams)
);
}
diff --git a/lib/private/Authentication/Login/UserDisabledCheckCommand.php b/lib/private/Authentication/Login/UserDisabledCheckCommand.php
index be91fe42e566a..b8977b583047e 100644
--- a/lib/private/Authentication/Login/UserDisabledCheckCommand.php
+++ b/lib/private/Authentication/Login/UserDisabledCheckCommand.php
@@ -27,7 +27,7 @@ public function process(LoginData $loginData): LoginResult {
$this->logger->warning("Login failed: $username disabled (Remote IP: $ip)");
- return LoginResult::failure($loginData, LoginController::LOGIN_MSG_USERDISABLED);
+ return LoginResult::failure(LoginController::LOGIN_MSG_USERDISABLED);
}
return $this->processNextOrFinishSuccessfully($loginData);
diff --git a/lib/private/Authentication/LoginCredentials/Credentials.php b/lib/private/Authentication/LoginCredentials/Credentials.php
index 27af14a022c42..690a7c4fdd903 100644
--- a/lib/private/Authentication/LoginCredentials/Credentials.php
+++ b/lib/private/Authentication/LoginCredentials/Credentials.php
@@ -7,38 +7,28 @@
namespace OC\Authentication\LoginCredentials;
use OCP\Authentication\LoginCredentials\ICredentials;
+use Override;
class Credentials implements ICredentials {
- /**
- * @param string $uid
- * @param string $loginName
- * @param string $password
- */
public function __construct(
- private $uid,
- private $loginName,
- private $password,
+ private readonly string $uid,
+ private readonly string $loginName,
+ private readonly string $password,
) {
}
- /**
- * @return string
- */
- public function getUID() {
+ #[Override]
+ public function getUID(): string {
return $this->uid;
}
- /**
- * @return string
- */
- public function getLoginName() {
+ #[Override]
+ public function getLoginName(): string {
return $this->loginName;
}
- /**
- * @return string
- */
- public function getPassword() {
+ #[Override]
+ public function getPassword(): string {
return $this->password;
}
}
diff --git a/lib/private/CapabilitiesManager.php b/lib/private/CapabilitiesManager.php
index 2e33ceb67b2ed..494504af3d80a 100644
--- a/lib/private/CapabilitiesManager.php
+++ b/lib/private/CapabilitiesManager.php
@@ -23,7 +23,7 @@ class CapabilitiesManager {
public const ACCEPTABLE_LOADING_TIME = 0.1;
/** @var \Closure[] */
- private $capabilities = [];
+ private array $capabilities = [];
public function __construct(
private LoggerInterface $logger,
diff --git a/lib/private/Command/CommandJob.php b/lib/private/Command/CommandJob.php
index b22ed38fdeed3..ac73987e59cf9 100644
--- a/lib/private/Command/CommandJob.php
+++ b/lib/private/Command/CommandJob.php
@@ -10,6 +10,9 @@
use OCA\Files_Trashbin\Command\Expire;
use OCP\BackgroundJob\QueuedJob;
use OCP\Command\ICommand;
+use Test\Command\FilesystemCommand;
+use Test\Command\SimpleCommand;
+use Test\Command\StateFullCommand;
/**
* Wrap a command in the background job interface
@@ -17,9 +20,9 @@
class CommandJob extends QueuedJob {
protected function run($argument) {
$command = unserialize($argument, ['allowed_classes' => [
- \Test\Command\SimpleCommand::class,
- \Test\Command\StateFullCommand::class,
- \Test\Command\FilesystemCommand::class,
+ SimpleCommand::class,
+ StateFullCommand::class,
+ FilesystemCommand::class,
Expire::class,
\OCA\Files_Versions\Command\Expire::class,
]]);
diff --git a/lib/private/Command/QueueBus.php b/lib/private/Command/QueueBus.php
index 06c7bacf55e9c..6a355c8ca6be1 100644
--- a/lib/private/Command/QueueBus.php
+++ b/lib/private/Command/QueueBus.php
@@ -12,6 +12,9 @@
use OCA\Files_Trashbin\Command\Expire;
use OCP\Command\IBus;
use OCP\Command\ICommand;
+use Test\Command\FilesystemCommand;
+use Test\Command\SimpleCommand;
+use Test\Command\StateFullCommand;
class QueueBus implements IBus {
/**
@@ -39,9 +42,9 @@ private function runCommand(ICommand $command): void {
throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
}
$unserialized = unserialize($serialized, ['allowed_classes' => [
- \Test\Command\SimpleCommand::class,
- \Test\Command\StateFullCommand::class,
- \Test\Command\FilesystemCommand::class,
+ SimpleCommand::class,
+ StateFullCommand::class,
+ FilesystemCommand::class,
Expire::class,
\OCA\Files_Versions\Command\Expire::class,
]]);
diff --git a/lib/private/Config.php b/lib/private/Config.php
index 17836659efaf6..03fdbff776720 100644
--- a/lib/private/Config.php
+++ b/lib/private/Config.php
@@ -17,27 +17,20 @@
class Config {
public const ENV_PREFIX = 'NC_';
- /** @var array Associative array ($key => $value) */
- protected $cache = [];
- /** @var array */
- protected $envCache = [];
- /** @var string */
- protected $configFilePath;
- /** @var string */
- protected $configFileName;
- /** @var bool */
- protected $isReadOnly;
+ protected array $cache = [];
+ protected array $envCache = [];
+ protected string $configFilePath;
+ protected bool $isReadOnly;
/**
* @param string $configDir Path to the config dir, needs to end with '/'
- * @param string $fileName (Optional) Name of the config file. Defaults to config.php
+ * @param string $configFileName (Optional) Name of the config file. Defaults to config.php
*/
public function __construct(
- protected $configDir,
- $fileName = 'config.php',
+ protected string $configDir,
+ protected string $configFileName = 'config.php',
) {
- $this->configFilePath = $this->configDir . $fileName;
- $this->configFileName = $fileName;
+ $this->configFilePath = $this->configDir . $configFileName;
$this->readData();
$this->isReadOnly = $this->getValue('config_is_read_only', false);
}
@@ -49,7 +42,7 @@ public function __construct(
*
* @return array an array of key names
*/
- public function getKeys() {
+ public function getKeys(): array {
return array_merge(array_keys($this->cache), array_keys($this->envCache));
}
diff --git a/lib/private/Console/TimestampFormatter.php b/lib/private/Console/TimestampFormatter.php
index e5398e35a6d5a..2df34a84c874a 100644
--- a/lib/private/Console/TimestampFormatter.php
+++ b/lib/private/Console/TimestampFormatter.php
@@ -12,18 +12,10 @@
use Symfony\Component\Console\Formatter\OutputFormatterStyleInterface;
class TimestampFormatter implements OutputFormatterInterface {
- /** @var OutputFormatterInterface */
- protected $formatter;
-
- /**
- * @param ?IConfig $config
- * @param OutputFormatterInterface $formatter
- */
public function __construct(
- protected ?IConfig $config,
- OutputFormatterInterface $formatter,
+ protected readonly ?IConfig $config,
+ protected readonly OutputFormatterInterface $formatter,
) {
- $this->formatter = $formatter;
}
/**
@@ -31,7 +23,7 @@ public function __construct(
*
* @param bool $decorated Whether to decorate the messages or not
*/
- public function setDecorated(bool $decorated) {
+ public function setDecorated(bool $decorated): void {
$this->formatter->setDecorated($decorated);
}
@@ -50,7 +42,7 @@ public function isDecorated(): bool {
* @param string $name The style name
* @param OutputFormatterStyleInterface $style The style instance
*/
- public function setStyle(string $name, OutputFormatterStyleInterface $style) {
+ public function setStyle(string $name, OutputFormatterStyleInterface $style): void {
$this->formatter->setStyle($name, $style);
}
diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php
index 4acd28dba7c7c..6ebcfdc34f242 100644
--- a/lib/private/DB/Adapter.php
+++ b/lib/private/DB/Adapter.php
@@ -16,11 +16,8 @@
* handled by the database abstraction layer.
*/
class Adapter {
- /**
- * @param \OC\DB\Connection $conn
- */
public function __construct(
- protected $conn,
+ protected readonly Connection $conn,
) {
}
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index dd1d26830114a..081ef017aa301 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -52,35 +52,21 @@
use function in_array;
class Connection extends PrimaryReadReplicaConnection {
- /** @var string */
- protected $tablePrefix;
-
- /** @var Adapter $adapter */
- protected $adapter;
-
- /** @var SystemConfig */
- private $systemConfig;
-
+ protected string $tablePrefix;
+ protected Adapter $adapter;
+ private SystemConfig $systemConfig;
private ClockInterface $clock;
-
private LoggerInterface $logger;
-
protected $lockedTable = null;
-
- /** @var int */
- protected $queriesBuilt = 0;
-
- /** @var int */
- protected $queriesExecuted = 0;
-
- /** @var DbDataCollector|null */
- protected $dbDataCollector = null;
+ protected int $queriesBuilt = 0;
+ protected int $queriesExecuted = 0;
+ protected ?DbDataCollector $dbDataCollector = null;
private array $lastConnectionCheck = [];
protected ?float $transactionActiveSince = null;
/** @var array */
- protected $tableDirtyWrites = [];
+ protected array $tableDirtyWrites = [];
protected bool $logDbException = false;
private ?array $transactionBacktrace = null;
@@ -328,10 +314,7 @@ protected function getCallerBacktrace() {
return '';
}
- /**
- * @return string
- */
- public function getPrefix() {
+ public function getPrefix(): string {
return $this->tablePrefix;
}
diff --git a/lib/private/DB/DbDataCollector.php b/lib/private/DB/DbDataCollector.php
index a85db66fc41e1..828674586e043 100644
--- a/lib/private/DB/DbDataCollector.php
+++ b/lib/private/DB/DbDataCollector.php
@@ -17,9 +17,6 @@
class DbDataCollector extends AbstractDataCollector {
protected ?BacktraceDebugStack $debugStack = null;
- /**
- * DbDataCollector constructor.
- */
public function __construct(
private Connection $connection,
) {
diff --git a/lib/private/DB/Exceptions/DbalException.php b/lib/private/DB/Exceptions/DbalException.php
index fa22641fe28dc..a34ebfe651d41 100644
--- a/lib/private/DB/Exceptions/DbalException.php
+++ b/lib/private/DB/Exceptions/DbalException.php
@@ -33,16 +33,8 @@
* @psalm-immutable
*/
class DbalException extends Exception {
- /** @var \Doctrine\DBAL\Exception */
- private $original;
-
- /**
- * @param \Doctrine\DBAL\Exception $original
- * @param int $code
- * @param string $message
- */
private function __construct(
- \Doctrine\DBAL\Exception $original,
+ private \Doctrine\DBAL\Exception $original,
int $code,
string $message,
public readonly ?string $query = null,
@@ -52,7 +44,6 @@ private function __construct(
$code,
$original
);
- $this->original = $original;
}
public static function wrap(\Doctrine\DBAL\Exception $original, string $message = '', ?string $query = null): self {
diff --git a/lib/private/DB/MigrationException.php b/lib/private/DB/MigrationException.php
index 2fd58478d2f43..d7e0d9528f094 100644
--- a/lib/private/DB/MigrationException.php
+++ b/lib/private/DB/MigrationException.php
@@ -9,7 +9,7 @@
class MigrationException extends \Exception {
public function __construct(
- private $table,
+ private string $table,
$message,
) {
parent::__construct($message);
@@ -18,7 +18,7 @@ public function __construct(
/**
* @return string
*/
- public function getTable() {
+ public function getTable(): string {
return $this->table;
}
}
diff --git a/lib/private/DB/Migrator.php b/lib/private/DB/Migrator.php
index 87d65b33b92b6..0d2f73a9a1df7 100644
--- a/lib/private/DB/Migrator.php
+++ b/lib/private/DB/Migrator.php
@@ -20,32 +20,24 @@
use function preg_match;
class Migrator {
- /** @var Connection */
- protected $connection;
-
- /** @var bool */
- private $noEmit = false;
+ private bool $noEmit = false;
public function __construct(
- Connection $connection,
+ protected Connection $connection,
protected IConfig $config,
private ?IEventDispatcher $dispatcher = null,
) {
- $this->connection = $connection;
}
/**
* @throws Exception
*/
- public function migrate(Schema $targetSchema) {
+ public function migrate(Schema $targetSchema): void {
$this->noEmit = true;
$this->applySchema($targetSchema);
}
- /**
- * @return string
- */
- public function generateChangeScript(Schema $targetSchema) {
+ public function generateChangeScript(Schema $targetSchema): string {
$schemaDiff = $this->getDiff($targetSchema, $this->connection);
$script = '';
@@ -60,7 +52,7 @@ public function generateChangeScript(Schema $targetSchema) {
/**
* @throws Exception
*/
- public function createSchema() {
+ public function createSchema(): Schema {
$this->connection->getConfiguration()->setSchemaAssetsFilter(function ($asset) {
/** @var string|AbstractAsset $asset */
$filterExpression = $this->getFilterExpression();
@@ -72,10 +64,7 @@ public function createSchema() {
return $this->connection->createSchemaManager()->introspectSchema();
}
- /**
- * @return SchemaDiff
- */
- protected function getDiff(Schema $targetSchema, Connection $connection) {
+ protected function getDiff(Schema $targetSchema, Connection $connection): SchemaDiff {
// Adjust STRING columns with a length higher than 4000 to TEXT (clob)
// for consistency between the supported databases and
// old vs. new installations.
diff --git a/lib/private/DB/ObjectParameter.php b/lib/private/DB/ObjectParameter.php
index ed5894c92bf24..04159f818cfc7 100644
--- a/lib/private/DB/ObjectParameter.php
+++ b/lib/private/DB/ObjectParameter.php
@@ -14,21 +14,15 @@ final class ObjectParameter {
private $stringable;
private $class;
- /**
- * @param object $object
- */
public function __construct(
- private $object,
+ private object $object,
private ?\Throwable $error,
) {
$this->stringable = \is_callable([$this->object, '__toString']);
$this->class = \get_class($this->object);
}
- /**
- * @return object
- */
- public function getObject() {
+ public function getObject(): object {
return $this->object;
}
diff --git a/lib/private/DB/PgSqlTools.php b/lib/private/DB/PgSqlTools.php
index 94b1b65626ecf..cc8812e202bec 100644
--- a/lib/private/DB/PgSqlTools.php
+++ b/lib/private/DB/PgSqlTools.php
@@ -16,9 +16,6 @@
* Various PostgreSQL specific helper functions.
*/
class PgSqlTools {
- /**
- * @param IConfig $config
- */
public function __construct(
private IConfig $config,
) {
@@ -27,10 +24,8 @@ public function __construct(
/**
* @brief Resynchronizes all sequences of a database after using INSERTs
* without leaving out the auto-incremented column.
- * @param \OC\DB\Connection $conn
- * @return null
*/
- public function resynchronizeDatabaseSequences(Connection $conn) {
+ public function resynchronizeDatabaseSequences(Connection $conn): void {
$databaseName = $conn->getDatabase();
$conn->getConfiguration()->setSchemaAssetsFilter(function ($asset) {
/** @var string|AbstractAsset $asset */
diff --git a/lib/private/DB/QueryBuilder/CompositeExpression.php b/lib/private/DB/QueryBuilder/CompositeExpression.php
index 0335d29cb421e..c0da96fb3af0b 100644
--- a/lib/private/DB/QueryBuilder/CompositeExpression.php
+++ b/lib/private/DB/QueryBuilder/CompositeExpression.php
@@ -9,6 +9,7 @@
namespace OC\DB\QueryBuilder;
use OCP\DB\QueryBuilder\ICompositeExpression;
+use Override;
class CompositeExpression implements ICompositeExpression, \Countable {
public const TYPE_AND = 'AND';
@@ -20,13 +21,7 @@ public function __construct(
) {
}
- /**
- * Adds multiple parts to composite expression.
- *
- * @param array $parts
- *
- * @return ICompositeExpression
- */
+ #[Override]
public function addMultiple(array $parts = []): ICompositeExpression {
foreach ($parts as $part) {
$this->add($part);
@@ -35,13 +30,7 @@ public function addMultiple(array $parts = []): ICompositeExpression {
return $this;
}
- /**
- * Adds an expression to composite expression.
- *
- * @param mixed $part
- *
- * @return ICompositeExpression
- */
+ #[Override]
public function add($part): ICompositeExpression {
if ($part === null) {
return $this;
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
index f57a5e3c347b0..8436fd365a09a 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
@@ -10,12 +10,12 @@
use Doctrine\DBAL\Query\Expression\ExpressionBuilder as DoctrineExpressionBuilder;
use OC\DB\ConnectionAdapter;
use OC\DB\QueryBuilder\CompositeExpression;
-use OC\DB\QueryBuilder\FunctionBuilder\FunctionBuilder;
use OC\DB\QueryBuilder\Literal;
use OC\DB\QueryBuilder\QueryFunction;
use OC\DB\QueryBuilder\QuoteHelper;
use OCP\DB\QueryBuilder\ICompositeExpression;
use OCP\DB\QueryBuilder\IExpressionBuilder;
+use OCP\DB\QueryBuilder\IFunctionBuilder;
use OCP\DB\QueryBuilder\ILiteral;
use OCP\DB\QueryBuilder\IParameter;
use OCP\DB\QueryBuilder\IQueryBuilder;
@@ -23,14 +23,9 @@
use Psr\Log\LoggerInterface;
class ExpressionBuilder implements IExpressionBuilder {
- /** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */
- protected $expressionBuilder;
-
- /** @var QuoteHelper */
- protected $helper;
-
- /** @var FunctionBuilder */
- protected $functionBuilder;
+ protected DoctrineExpressionBuilder $expressionBuilder;
+ protected QuoteHelper $helper;
+ protected IFunctionBuilder $functionBuilder;
public function __construct(
protected ConnectionAdapter $connection,
diff --git a/lib/private/DB/QueryBuilder/QueryFunction.php b/lib/private/DB/QueryBuilder/QueryFunction.php
index ae168b0bc636b..6a91127f5d29e 100644
--- a/lib/private/DB/QueryBuilder/QueryFunction.php
+++ b/lib/private/DB/QueryBuilder/QueryFunction.php
@@ -10,15 +10,12 @@
use OCP\DB\QueryBuilder\IQueryFunction;
class QueryFunction implements IQueryFunction {
- /**
- * @param string $function
- */
public function __construct(
- protected $function,
+ protected string $function,
) {
}
public function __toString(): string {
- return (string)$this->function;
+ return $this->function;
}
}
diff --git a/lib/private/DB/SQLiteMigrator.php b/lib/private/DB/SQLiteMigrator.php
index 6be17625476a3..40503ae17812d 100644
--- a/lib/private/DB/SQLiteMigrator.php
+++ b/lib/private/DB/SQLiteMigrator.php
@@ -8,14 +8,10 @@
namespace OC\DB;
use Doctrine\DBAL\Schema\Schema;
+use Doctrine\DBAL\Schema\SchemaDiff;
class SQLiteMigrator extends Migrator {
- /**
- * @param Schema $targetSchema
- * @param \Doctrine\DBAL\Connection $connection
- * @return \Doctrine\DBAL\Schema\SchemaDiff
- */
- protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
+ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection): SchemaDiff {
foreach ($targetSchema->getTables() as $table) {
foreach ($table->getColumns() as $column) {
// column comments are not supported on SQLite
diff --git a/lib/private/DB/SQLiteSessionInit.php b/lib/private/DB/SQLiteSessionInit.php
index 6c5763187a8a4..6ad4c121349ba 100644
--- a/lib/private/DB/SQLiteSessionInit.php
+++ b/lib/private/DB/SQLiteSessionInit.php
@@ -13,22 +13,15 @@
class SQLiteSessionInit implements EventSubscriber {
/**
- * Configure case sensitive like for each connection
- *
- * @param bool $caseSensitiveLike
- * @param string $journalMode
+ * Configure case-sensitive like for each connection
*/
public function __construct(
- private $caseSensitiveLike,
- private $journalMode,
+ private readonly bool $caseSensitiveLike,
+ private readonly string $journalMode,
) {
}
- /**
- * @param ConnectionEventArgs $args
- * @return void
- */
- public function postConnect(ConnectionEventArgs $args) {
+ public function postConnect(ConnectionEventArgs $args): void {
$sensitive = $this->caseSensitiveLike ? 'true' : 'false';
$args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive);
$args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode);
@@ -38,7 +31,7 @@ public function postConnect(ConnectionEventArgs $args) {
$pdo->sqliteCreateFunction('md5', 'md5', 1);
}
- public function getSubscribedEvents() {
+ public function getSubscribedEvents(): array {
return [Events::postConnect];
}
}
diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php
index 273c591038b18..57f0caecb8d80 100644
--- a/lib/private/DB/SchemaWrapper.php
+++ b/lib/private/DB/SchemaWrapper.php
@@ -15,17 +15,16 @@
use Psr\Log\LoggerInterface;
class SchemaWrapper implements ISchemaWrapper {
- /** @var Schema */
- protected $schema;
+ protected Schema $schema;
- /** @var array */
- protected $tablesToDelete = [];
+ /** @var array */
+ protected array $tablesToDelete = [];
public function __construct(
protected Connection $connection,
?Schema $schema = null,
) {
- if ($schema) {
+ if ($schema !== null) {
$this->schema = $schema;
} else {
$this->schema = $this->connection->createSchema();
@@ -36,7 +35,7 @@ public function getWrappedSchema() {
return $this->schema;
}
- public function performDropTableCalls() {
+ public function performDropTableCalls(): void {
foreach ($this->tablesToDelete as $tableName => $true) {
$this->connection->dropTable($tableName);
foreach ($this->connection->getShardConnections() as $shardConnection) {
diff --git a/lib/private/DateTimeZone.php b/lib/private/DateTimeZone.php
index 3597c4ec1ffd2..589d2e0a6a977 100644
--- a/lib/private/DateTimeZone.php
+++ b/lib/private/DateTimeZone.php
@@ -10,26 +10,20 @@
use OCP\IConfig;
use OCP\IDateTimeZone;
use OCP\ISession;
-use OCP\Server;
use Psr\Log\LoggerInterface;
class DateTimeZone implements IDateTimeZone {
- /**
- * Constructor
- *
- * @param IConfig $config
- * @param ISession $session
- */
public function __construct(
- protected IConfig $config,
- protected ISession $session,
+ protected readonly IConfig $config,
+ protected readonly ISession $session,
+ protected readonly LoggerInterface $logger,
) {
}
/**
* @inheritdoc
*/
- public function getTimeZone($timestamp = false, ?string $userId = null): \DateTimeZone {
+ public function getTimeZone(int|false $timestamp = false, ?string $userId = null): \DateTimeZone {
$uid = $userId ?? $this->session->get('user_id');
$timezoneName = $this->config->getUserValue($uid, 'core', 'timezone', '');
if ($timezoneName === '') {
@@ -42,7 +36,7 @@ public function getTimeZone($timestamp = false, ?string $userId = null): \DateTi
try {
return new \DateTimeZone($timezoneName);
} catch (\Exception $e) {
- Server::get(LoggerInterface::class)->debug('Failed to created DateTimeZone "' . $timezoneName . '"', ['app' => 'datetimezone']);
+ $this->logger->debug('Failed to created DateTimeZone "' . $timezoneName . '"', ['app' => 'datetimezone']);
return $this->getDefaultTimeZone();
}
}
@@ -65,10 +59,8 @@ public function getDefaultTimeZone(): \DateTimeZone {
* we try to find it manually, before falling back to UTC.
*
* @param mixed $offset
- * @param int|false $timestamp
- * @return \DateTimeZone
*/
- protected function guessTimeZoneFromOffset($offset, $timestamp) {
+ protected function guessTimeZoneFromOffset($offset, int|false $timestamp): \DateTimeZone {
try {
// Note: the timeZone name is the inverse to the offset,
// so a positive offset means negative timeZone
@@ -98,7 +90,7 @@ protected function guessTimeZoneFromOffset($offset, $timestamp) {
}
// No timezone found, fallback to UTC
- Server::get(LoggerInterface::class)->debug('Failed to find DateTimeZone for offset "' . $offset . '"', ['app' => 'datetimezone']);
+ $this->logger->debug('Failed to find DateTimeZone for offset "' . $offset . '"', ['app' => 'datetimezone']);
return $this->getDefaultTimeZone();
}
}
diff --git a/lib/private/Diagnostics/Event.php b/lib/private/Diagnostics/Event.php
index 74750212806c1..956d86b2693f3 100644
--- a/lib/private/Diagnostics/Event.php
+++ b/lib/private/Diagnostics/Event.php
@@ -10,62 +10,36 @@
use OCP\Diagnostics\IEvent;
class Event implements IEvent {
- /**
- * @var float
- */
- protected $end;
+ protected ?float $end = null;
- /**
- * @param string $id
- * @param string $description
- * @param float $start
- */
public function __construct(
- protected $id,
- protected $description,
- protected $start,
+ protected string $id,
+ protected string $description,
+ protected float $start,
) {
}
- /**
- * @param float $time
- */
- public function end($time) {
+ public function end(float $time): void {
$this->end = $time;
}
- /**
- * @return float
- */
- public function getStart() {
+ public function getStart(): float {
return $this->start;
}
- /**
- * @return string
- */
- public function getId() {
+ public function getId(): string {
return $this->id;
}
- /**
- * @return string
- */
- public function getDescription() {
+ public function getDescription(): string {
return $this->description;
}
- /**
- * @return float
- */
- public function getEnd() {
- return $this->end;
+ public function getEnd(): float {
+ return $this->end ?? -1;
}
- /**
- * @return float
- */
- public function getDuration() {
+ public function getDuration(): float {
if (!$this->end) {
$this->end = microtime(true);
}
diff --git a/lib/private/Diagnostics/EventLogger.php b/lib/private/Diagnostics/EventLogger.php
index da522646d8889..f61b470e83645 100644
--- a/lib/private/Diagnostics/EventLogger.php
+++ b/lib/private/Diagnostics/EventLogger.php
@@ -15,12 +15,12 @@
class EventLogger implements IEventLogger {
/** @var Event[] */
- private $events = [];
+ private array $events = [];
/**
* @var bool - Module needs to be activated by some app
*/
- private $activated = false;
+ private bool $activated = false;
public function __construct(
private SystemConfig $config,
diff --git a/lib/private/Diagnostics/Query.php b/lib/private/Diagnostics/Query.php
index 829bbf15dc1c2..fd14b94688328 100644
--- a/lib/private/Diagnostics/Query.php
+++ b/lib/private/Diagnostics/Query.php
@@ -10,58 +10,41 @@
use OCP\Diagnostics\IQuery;
class Query implements IQuery {
- private $end;
+ private ?float $end = null;
- /**
- * @param string $sql
- * @param array $params
- * @param int $start
- */
public function __construct(
- private $sql,
- private $params,
- private $start,
+ private string $sql,
+ private array $params,
+ private float $start,
private array $stack,
) {
}
- public function end($time) {
+ public function end($time): void {
$this->end = $time;
}
- /**
- * @return array
- */
- public function getParams() {
+ public function getParams(): array {
return $this->params;
}
- /**
- * @return string
- */
- public function getSql() {
+ public function getSql(): string {
return $this->sql;
}
- /**
- * @return float
- */
- public function getStart() {
+ public function getStart(): float {
return $this->start;
}
- /**
- * @return float
- */
- public function getDuration() {
+ public function getDuration(): float {
return $this->end - $this->start;
}
- public function getStartTime() {
+ public function getStartTime(): float {
return $this->start;
}
- public function getStacktrace() {
+ public function getStacktrace(): array {
return $this->stack;
}
}
diff --git a/lib/private/Encryption/EncryptionEventListener.php b/lib/private/Encryption/EncryptionEventListener.php
index 1eee9ccc3ee7f..693dded42b844 100644
--- a/lib/private/Encryption/EncryptionEventListener.php
+++ b/lib/private/Encryption/EncryptionEventListener.php
@@ -13,6 +13,7 @@
use OC\Files\View;
use OCA\Files_Trashbin\Events\NodeRestoredEvent;
use OCP\Encryption\IFile;
+use OCP\Encryption\IManager;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
@@ -85,8 +86,9 @@ private function getUpdate(?IUser $owner = null): Update {
new View(),
$this->userManager,
Server::get(IGroupManager::class),
- Server::get(IConfig::class)),
- Server::get(\OCP\Encryption\IManager::class),
+ Server::get(IConfig::class)
+ ),
+ Server::get(IManager::class),
Server::get(IFile::class),
Server::get(LoggerInterface::class),
);
diff --git a/lib/private/Encryption/Keys/Storage.php b/lib/private/Encryption/Keys/Storage.php
index bad832dcddf79..d1d225cd5734c 100644
--- a/lib/private/Encryption/Keys/Storage.php
+++ b/lib/private/Encryption/Keys/Storage.php
@@ -17,35 +17,21 @@
use OCP\Security\ICrypto;
class Storage implements IStorage {
- // hidden file which indicate that the folder is a valid key storage
+ /** @var string hidden file which indicate that the folder is a valid key storage */
public const KEY_STORAGE_MARKER = '.oc_key_storage';
+ /** @var string base dir where all the file related keys are stored */
+ private string $keys_base_dir;
+ /** @var string root of the key storage default is empty which means that we use the data folder */
+ private string $root_dir;
+ private string $encryption_base_dir;
+ private string $backup_base_dir;
+ private array $keyCache = [];
- // base dir where all the file related keys are stored
- /** @var string */
- private $keys_base_dir;
-
- // root of the key storage default is empty which means that we use the data folder
- /** @var string */
- private $root_dir;
-
- /** @var string */
- private $encryption_base_dir;
-
- /** @var string */
- private $backup_base_dir;
-
- /** @var array */
- private $keyCache = [];
-
- /**
- * @param View $view
- * @param Util $util
- */
public function __construct(
- private View $view,
- private Util $util,
- private ICrypto $crypto,
- private IConfig $config,
+ private readonly View $view,
+ private readonly Util $util,
+ private readonly ICrypto $crypto,
+ private readonly IConfig $config,
) {
$this->encryption_base_dir = '/files_encryption';
$this->keys_base_dir = $this->encryption_base_dir . '/keys';
diff --git a/lib/private/Files/AppData/AppData.php b/lib/private/Files/AppData/AppData.php
index ee809c4050d13..5bea7ec470c88 100644
--- a/lib/private/Files/AppData/AppData.php
+++ b/lib/private/Files/AppData/AppData.php
@@ -24,13 +24,6 @@ class AppData implements IAppData {
/** @var CappedMemoryCache */
private CappedMemoryCache $folders;
- /**
- * AppData constructor.
- *
- * @param IRootFolder $rootFolder
- * @param SystemConfig $config
- * @param string $appId
- */
public function __construct(
private IRootFolder $rootFolder,
private SystemConfig $config,
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index 98ba4c39bc3fa..d777b784166a0 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -41,30 +41,15 @@
* @package OC\Files\Cache
*/
class Scanner extends BasicEmitter implements IScanner {
- /**
- * @var string $storageId
- */
- protected $storageId;
-
- /**
- * @var Cache $cache
- */
+ protected string $storageId;
+ /** @var Cache */
protected $cache;
-
- /**
- * @var boolean $cacheActive If true, perform cache operations, if false, do not affect cache
- */
- protected $cacheActive;
-
- /**
- * @var bool $useTransactions whether to use transactions
- */
- protected $useTransactions = true;
-
- /**
- * @var ILockingProvider
- */
- protected $lockingProvider;
+ /** @var boolean $cacheActive If true, perform cache operations, if false, do not affect cache */
+ protected bool $cacheActive;
+ /** @var bool $useTransactions whether to use transactions */
+ protected bool $useTransactions = true;
+ /** * @var ILockingProvider */
+ protected ILockingProvider $lockingProvider;
protected IDBConnection $connection;
diff --git a/lib/private/Files/Config/CachedMountInfo.php b/lib/private/Files/Config/CachedMountInfo.php
index 9dbdd54cbb243..431d20b194e8f 100644
--- a/lib/private/Files/Config/CachedMountInfo.php
+++ b/lib/private/Files/Config/CachedMountInfo.php
@@ -13,38 +13,23 @@
use OCP\IUser;
class CachedMountInfo implements ICachedMountInfo {
- protected string $mountProvider;
protected string $key;
- /**
- * CachedMountInfo constructor.
- *
- * @param IUser $user
- * @param int $storageId
- * @param int $rootId
- * @param string $mountPoint
- * @param int|null $mountId
- * @param string $rootInternalPath
- */
public function __construct(
protected IUser $user,
protected int $storageId,
protected int $rootId,
protected string $mountPoint,
- string $mountProvider,
+ protected string $mountProvider,
protected ?int $mountId = null,
protected string $rootInternalPath = '',
) {
if (strlen($mountProvider) > 128) {
throw new \Exception("Mount provider $mountProvider name exceeds the limit of 128 characters");
}
- $this->mountProvider = $mountProvider;
$this->key = $this->rootId . '::' . $this->mountPoint;
}
- /**
- * @return IUser
- */
public function getUser(): IUser {
return $this->user;
}
diff --git a/lib/public/IDateTimeZone.php b/lib/public/IDateTimeZone.php
index 650f9d6b24383..32b3903b81200 100644
--- a/lib/public/IDateTimeZone.php
+++ b/lib/public/IDateTimeZone.php
@@ -7,11 +7,14 @@
*/
namespace OCP;
+use OCP\AppFramework\Attribute\Consumable;
+
/**
* Interface IDateTimeZone
*
* @since 8.0.0
*/
+#[Consumable(since: '8.0.0')]
interface IDateTimeZone {
/**
@@ -19,14 +22,12 @@ interface IDateTimeZone {
* If a timestamp is passed the timezone for that given timestamp is retrieved (might differ due to DST).
* If no userId is passed the current user is used.
*
- * @param bool|int $timestamp
* @param ?string $userId - The user to fetch the timezone for (defaults to current user)
- * @return \DateTimeZone
* @since 8.0.0
* @since 8.1.0 - parameter $timestamp was added
* @since 32.0.0 - parameter $userId was added
*/
- public function getTimeZone($timestamp = false, ?string $userId = null);
+ public function getTimeZone(int|false $timestamp = false, ?string $userId = null): \DateTimeZone;
/**
* Get the timezone configured as the default for this Nextcloud server.
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
index d9fcc3e2394a9..0bfa0ba4cc528 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
@@ -1,5 +1,7 @@
connection = Server::get(IDBConnection::class);
- $this->internalConnection = Server::get(\OC\DB\Connection::class);
+ $this->internalConnection = Server::get(Connection::class);
$this->logger = $this->createMock(LoggerInterface::class);
$queryBuilder = $this->createMock(IQueryBuilder::class);
+ $queryBuilder->method('func')
+ ->willReturn($this->createMock(IFunctionBuilder::class));
$this->expressionBuilder = new ExpressionBuilder($this->connection, $queryBuilder, $this->logger);
@@ -67,16 +66,8 @@ public static function dataComparison(): array {
return $testSets;
}
- /**
- *
- * @param string $comparison
- * @param mixed $input1
- * @param bool $isInput1Literal
- * @param mixed $input2
- * @param bool $isInput2Literal
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataComparison')]
- public function testComparison($comparison, $input1, $isInput1Literal, $input2, $isInput2Literal): void {
+ #[DataProvider('dataComparison')]
+ public function testComparison(string $comparison, string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -95,15 +86,8 @@ public static function dataComparisons(): array {
];
}
- /**
- *
- * @param mixed $input1
- * @param bool $isInput1Literal
- * @param mixed $input2
- * @param bool $isInput2Literal
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
- public function testEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
+ #[DataProvider('dataComparisons')]
+ public function testEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -113,15 +97,8 @@ public function testEquals($input1, $isInput1Literal, $input2, $isInput2Literal)
);
}
- /**
- *
- * @param mixed $input1
- * @param bool $isInput1Literal
- * @param mixed $input2
- * @param bool $isInput2Literal
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
- public function testNotEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
+ #[DataProvider('dataComparisons')]
+ public function testNotEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -131,15 +108,8 @@ public function testNotEquals($input1, $isInput1Literal, $input2, $isInput2Liter
);
}
- /**
- *
- * @param mixed $input1
- * @param bool $isInput1Literal
- * @param mixed $input2
- * @param bool $isInput2Literal
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
- public function testLowerThan($input1, $isInput1Literal, $input2, $isInput2Literal): void {
+ #[DataProvider('dataComparisons')]
+ public function testLowerThan(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -149,15 +119,8 @@ public function testLowerThan($input1, $isInput1Literal, $input2, $isInput2Liter
);
}
- /**
- *
- * @param mixed $input1
- * @param bool $isInput1Literal
- * @param mixed $input2
- * @param bool $isInput2Literal
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
- public function testLowerThanEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
+ #[DataProvider('dataComparisons')]
+ public function testLowerThanEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -167,15 +130,8 @@ public function testLowerThanEquals($input1, $isInput1Literal, $input2, $isInput
);
}
- /**
- *
- * @param mixed $input1
- * @param bool $isInput1Literal
- * @param mixed $input2
- * @param bool $isInput2Literal
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
- public function testGreaterThan($input1, $isInput1Literal, $input2, $isInput2Literal): void {
+ #[DataProvider('dataComparisons')]
+ public function testGreaterThan(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -185,15 +141,8 @@ public function testGreaterThan($input1, $isInput1Literal, $input2, $isInput2Lit
);
}
- /**
- *
- * @param mixed $input1
- * @param bool $isInput1Literal
- * @param mixed $input2
- * @param bool $isInput2Literal
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
- public function testGreaterThanEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
+ #[DataProvider('dataComparisons')]
+ public function testGreaterThanEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -224,13 +173,8 @@ public static function dataLike(): array {
];
}
- /**
- *
- * @param mixed $input
- * @param bool $isLiteral
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataLike')]
- public function testLike($input, $isLiteral): void {
+ #[DataProvider('dataLike')]
+ public function testLike(string $input, bool $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
$this->assertEquals(
@@ -239,13 +183,8 @@ public function testLike($input, $isLiteral): void {
);
}
- /**
- *
- * @param mixed $input
- * @param bool $isLiteral
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataLike')]
- public function testNotLike($input, $isLiteral): void {
+ #[DataProvider('dataLike')]
+ public function testNotLike(string $input, bool $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
$this->assertEquals(
@@ -263,13 +202,8 @@ public static function dataIn(): array {
];
}
- /**
- *
- * @param mixed $input
- * @param bool $isLiteral
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataIn')]
- public function testIn($input, $isLiteral): void {
+ #[DataProvider('dataIn')]
+ public function testIn(string|array $input, bool $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
$this->assertEquals(
@@ -278,13 +212,8 @@ public function testIn($input, $isLiteral): void {
);
}
- /**
- *
- * @param mixed $input
- * @param bool $isLiteral
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataIn')]
- public function testNotIn($input, $isLiteral): void {
+ #[DataProvider('dataIn')]
+ public function testNotIn(string|array $input, bool $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
$this->assertEquals(
@@ -293,7 +222,7 @@ public function testNotIn($input, $isLiteral): void {
);
}
- protected function helpWithLiteral($input, $isLiteral) {
+ protected function helpWithLiteral(string|array $input, bool $isLiteral) {
if ($isLiteral) {
if (is_array($input)) {
$doctrineInput = array_map(function ($ident) {
@@ -332,13 +261,8 @@ public static function dataLiteral(): array {
];
}
- /**
- *
- * @param mixed $input
- * @param string|null $type
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataLiteral')]
- public function testLiteral($input, $type): void {
+ #[DataProvider('dataLiteral')]
+ public function testLiteral(string|int $input, string|int|null $type): void {
/** @var Literal $actual */
$actual = $this->expressionBuilder->literal($input, $type);
@@ -376,15 +300,8 @@ public static function dataClobComparisons(): array {
];
}
- /**
- * @param string $function
- * @param mixed $value
- * @param mixed $type
- * @param bool $compareKeyToValue
- * @param int $expected
- */
- #[\PHPUnit\Framework\Attributes\DataProvider('dataClobComparisons')]
- public function testClobComparisons($function, $value, $type, $compareKeyToValue, $expected): void {
+ #[DataProvider('dataClobComparisons')]
+ public function testClobComparisons(string $function, string|array $value, int $type, bool $compareKeyToValue, int $expected): void {
$appId = $this->getUniqueID('testing');
$this->createConfig($appId, 1, 4);
$this->createConfig($appId, 2, 5);
@@ -419,7 +336,7 @@ public function testClobComparisons($function, $value, $type, $compareKeyToValue
->executeStatement();
}
- protected function createConfig($appId, $key, $value) {
+ protected function createConfig(string $appId, int $key, int|string $value) {
$query = $this->connection->getQueryBuilder();
$query->insert('appconfig')
->values([