refactor: Apply comments

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
Carl Schwan
2025-11-18 17:36:29 +01:00
committed by Carl Schwan
parent 6e48f9fedb
commit 65e769a861
45 changed files with 180 additions and 402 deletions
+11 -10
View File
@@ -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 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin {
*
* @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;
}
return $this->tagger;
$tagger = $this->tagManager->load('files');
if ($tagger === null) {
throw new \RuntimeException('Tagger not found for files');
}
$this->tagger = $tagger;
return $tagger;
}
/**
@@ -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,
) {
}
-3
View File
@@ -1048,9 +1048,6 @@ class Access extends LDAPUtility {
/**
* Returns the LDAP handler
*
* @throws \OC\ServerNotAvailableException
*/
/**
* @param mixed[] $arguments
* @return mixed
* @throws ServerNotAvailableException
+1 -2
View File
@@ -262,8 +262,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
/**
* 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
*/
+6 -16
View File
@@ -3360,16 +3360,16 @@
</file>
<file src="lib/private/Command/CommandJob.php">
<UndefinedClass>
<code><![CDATA[\Test\Command\FilesystemCommand]]></code>
<code><![CDATA[\Test\Command\SimpleCommand]]></code>
<code><![CDATA[\Test\Command\StateFullCommand]]></code>
<code><![CDATA[FilesystemCommand]]></code>
<code><![CDATA[SimpleCommand]]></code>
<code><![CDATA[StateFullCommand]]></code>
</UndefinedClass>
</file>
<file src="lib/private/Command/QueueBus.php">
<UndefinedClass>
<code><![CDATA[\Test\Command\FilesystemCommand]]></code>
<code><![CDATA[\Test\Command\SimpleCommand]]></code>
<code><![CDATA[\Test\Command\StateFullCommand]]></code>
<code><![CDATA[FilesystemCommand]]></code>
<code><![CDATA[SimpleCommand]]></code>
<code><![CDATA[StateFullCommand]]></code>
</UndefinedClass>
</file>
<file src="lib/private/Comments/Manager.php">
@@ -3472,16 +3472,6 @@
<code><![CDATA[string]]></code>
</InvalidReturnType>
</file>
<file src="lib/private/Diagnostics/Query.php">
<ImplementedReturnTypeMismatch>
<code><![CDATA[float]]></code>
</ImplementedReturnTypeMismatch>
</file>
<file src="lib/private/Diagnostics/QueryLogger.php">
<InvalidArgument>
<code><![CDATA[microtime(true)]]></code>
</InvalidArgument>
</file>
<file src="lib/private/DirectEditing/Manager.php">
<InvalidReturnType>
<code><![CDATA[TemplateResponse]]></code>
+1 -1
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
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
*/
@@ -13,32 +13,26 @@ namespace OC\AppFramework\Bootstrap;
*/
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;
@@ -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,
@@ -19,7 +19,7 @@ use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
use OC\AppFramework\Middleware\Security\Exceptions\StrictCookieMissingException;
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 @@ class SecurityMiddleware extends Middleware {
$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');
}
@@ -11,14 +11,10 @@ use OC\AppFramework\App;
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,
) {
}
@@ -27,8 +27,7 @@ use function substr;
* @template-implements IEventListener<ARemoteWipeEvent>
*/
class RemoteWipeEmailListener implements IEventListener {
/** @var IL10N */
private $l10n;
private IL10N $l10n;
public function __construct(
private IMailer $mailer,
@@ -21,7 +21,7 @@ abstract class ALoginCommand {
if ($this->next !== null) {
return $this->next->process($loginData);
} else {
return LoginResult::success($loginData);
return LoginResult::success();
}
}
@@ -30,7 +30,7 @@ class LoggedInCheckCommand extends ALoginCommand {
$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);
@@ -11,28 +11,24 @@ namespace OC\Authentication\Login;
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 @@ class LoginResult {
/**
* @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);
}
@@ -58,7 +58,6 @@ class TwoFactorCommand extends ALoginCommand {
}
return LoginResult::success(
$loginData,
$this->urlGenerator->linkToRoute($url, $urlParams)
);
}
@@ -27,7 +27,7 @@ class UserDisabledCheckCommand extends ALoginCommand {
$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);
@@ -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;
}
}
+1 -1
View File
@@ -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,
+6 -3
View File
@@ -10,6 +10,9 @@ namespace OC\Command;
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 @@ use OCP\Command\ICommand;
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,
]]);
+6 -3
View File
@@ -12,6 +12,9 @@ namespace OC\Command;
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 @@ class QueueBus implements IBus {
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,
]]);
+9 -16
View File
@@ -17,27 +17,20 @@ use OCP\Util;
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 @@ class Config {
*
* @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));
}
+4 -12
View File
@@ -12,18 +12,10 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
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 @@ class TimestampFormatter implements OutputFormatterInterface {
*
* @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 @@ class TimestampFormatter implements OutputFormatterInterface {
* @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);
}
+1 -4
View File
@@ -16,11 +16,8 @@ use OC\DB\Exceptions\DbalException;
* handled by the database abstraction layer.
*/
class Adapter {
/**
* @param \OC\DB\Connection $conn
*/
public function __construct(
protected $conn,
protected readonly Connection $conn,
) {
}
+8 -25
View File
@@ -52,35 +52,21 @@ use function count;
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<string, int> */
protected $tableDirtyWrites = [];
protected array $tableDirtyWrites = [];
protected bool $logDbException = false;
private ?array $transactionBacktrace = null;
@@ -328,10 +314,7 @@ class Connection extends PrimaryReadReplicaConnection {
return '';
}
/**
* @return string
*/
public function getPrefix() {
public function getPrefix(): string {
return $this->tablePrefix;
}
-3
View File
@@ -17,9 +17,6 @@ use OCP\DataCollector\AbstractDataCollector;
class DbDataCollector extends AbstractDataCollector {
protected ?BacktraceDebugStack $debugStack = null;
/**
* DbDataCollector constructor.
*/
public function __construct(
private Connection $connection,
) {
+1 -10
View File
@@ -33,16 +33,8 @@ use OCP\DB\Exception;
* @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 @@ class DbalException extends Exception {
$code,
$original
);
$this->original = $original;
}
public static function wrap(\Doctrine\DBAL\Exception $original, string $message = '', ?string $query = null): self {
+2 -2
View File
@@ -9,7 +9,7 @@ namespace OC\DB;
class MigrationException extends \Exception {
public function __construct(
private $table,
private string $table,
$message,
) {
parent::__construct($message);
@@ -18,7 +18,7 @@ class MigrationException extends \Exception {
/**
* @return string
*/
public function getTable() {
public function getTable(): string {
return $this->table;
}
}
+6 -17
View File
@@ -20,32 +20,24 @@ use OCP\IConfig;
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 @@ class Migrator {
/**
* @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 @@ class Migrator {
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.
+2 -8
View File
@@ -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;
}
+1 -6
View File
@@ -16,9 +16,6 @@ use function preg_quote;
* Various PostgreSQL specific helper functions.
*/
class PgSqlTools {
/**
* @param IConfig $config
*/
public function __construct(
private IConfig $config,
) {
@@ -27,10 +24,8 @@ class PgSqlTools {
/**
* @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 */
@@ -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 @@ class CompositeExpression implements ICompositeExpression, \Countable {
) {
}
/**
* 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 @@ class CompositeExpression implements ICompositeExpression, \Countable {
return $this;
}
/**
* Adds an expression to composite expression.
*
* @param mixed $part
*
* @return ICompositeExpression
*/
#[Override]
public function add($part): ICompositeExpression {
if ($part === null) {
return $this;
@@ -10,12 +10,12 @@ namespace OC\DB\QueryBuilder\ExpressionBuilder;
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 OCP\DB\QueryBuilder\IQueryFunction;
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,
@@ -10,15 +10,12 @@ namespace OC\DB\QueryBuilder;
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;
}
}
+2 -6
View File
@@ -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
+5 -12
View File
@@ -13,22 +13,15 @@ use Doctrine\DBAL\Events;
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);
@@ -42,7 +35,7 @@ class SQLiteSessionInit implements EventSubscriber {
}
}
public function getSubscribedEvents() {
public function getSubscribedEvents(): array {
return [Events::postConnect];
}
}
+5 -6
View File
@@ -15,17 +15,16 @@ use OCP\Server;
use Psr\Log\LoggerInterface;
class SchemaWrapper implements ISchemaWrapper {
/** @var Schema */
protected $schema;
protected Schema $schema;
/** @var array */
protected $tablesToDelete = [];
/** @var array<string, true> */
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 @@ class SchemaWrapper implements ISchemaWrapper {
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) {
+7 -15
View File
@@ -10,26 +10,20 @@ namespace OC;
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 @@ class DateTimeZone implements IDateTimeZone {
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 @@ class DateTimeZone implements IDateTimeZone {
* 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 @@ class DateTimeZone implements IDateTimeZone {
}
// 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();
}
}
+11 -37
View File
@@ -10,62 +10,36 @@ namespace OC\Diagnostics;
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);
}
+2 -2
View File
@@ -15,12 +15,12 @@ use Psr\Log\LoggerInterface;
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,
+11 -28
View File
@@ -10,58 +10,41 @@ namespace OC\Diagnostics;
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;
}
}
+12 -26
View File
@@ -17,35 +17,21 @@ use OCP\IConfig;
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';
-7
View File
@@ -24,13 +24,6 @@ class AppData implements IAppData {
/** @var CappedMemoryCache<ISimpleFolder|NotFoundException> */
private CappedMemoryCache $folders;
/**
* AppData constructor.
*
* @param IRootFolder $rootFolder
* @param SystemConfig $config
* @param string $appId
*/
public function __construct(
private IRootFolder $rootFolder,
private SystemConfig $config,
+8 -23
View File
@@ -41,30 +41,15 @@ use Psr\Log\LoggerInterface;
* @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;
@@ -30,9 +30,6 @@ class CachedMountInfo implements ICachedMountInfo {
$this->key = $this->rootId . '::' . $this->mountPoint;
}
/**
* @return IUser
*/
public function getUser(): IUser {
return $this->user;
}
+4 -3
View File
@@ -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.