Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"nextcloud/coding-standard": "^1.2",
"psalm/phar": "^5.25",
"psalm/phar": "^6.15.1",
"sabre/dav": "^4.6",
"nextcloud/ocp": "dev-master"
},
"config": {
"platform": {
"php": "8.1"
"php": "8.2"
}
},
"require": {
"php": "^8.1"
"php": "^8.2"
},
"scripts": {
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
Expand Down
280 changes: 168 additions & 112 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function __construct(array $params = []) {
parent::__construct(self::APP_ID, $params);
}

#[\Override]
public function register(IRegistrationContext $context): void {
$context->registerCapability(Capability::class);
$context->registerEventListener(
Expand All @@ -56,6 +57,7 @@ public function register(IRegistrationContext $context): void {
);
}

#[\Override]
public function boot(IBootContext $context): void {
$this->registerHooks();

Expand Down
1 change: 1 addition & 0 deletions lib/Capability.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OCP\Capabilities\ICapability;

class Capability implements ICapability {
#[\Override]
public function getCapabilities() {
return [
'files' => [
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/LockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ public function unlocking(string $fileId, int $lockType = ILock::TYPE_USER): Dat
}


#[\Override]
public function setOCSVersion($version) {
$this->ocsVersion = $version;
}

private function buildOCSResponse($format, DataResponse $data) {
$message = null;
if ($data->getStatus() === Http::STATUS_LOCKED) {
/** @var FileLock $lock */
$lock = new FileLock();
$lock->import($data->getData());
$this->lockService->injectMetadata($lock);
Expand Down
1 change: 1 addition & 0 deletions lib/Cron/Unlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(ITimeFactory $timeFactory, LockService $lockService)
$this->setInterval(12 * 60);
}

#[\Override]
protected function run($argument): void {
$this->deleteExpiredLocks();
}
Expand Down
3 changes: 3 additions & 0 deletions lib/DAV/LockBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function __construct(
*
* @return LockInfo[]
*/
#[\Override]
public function getLocks($uri, $returnChildLocks): array {
$locks = [];
try {
Expand Down Expand Up @@ -64,6 +65,7 @@ public function getLocks($uri, $returnChildLocks): array {
*
* @return bool
*/
#[\Override]
public function lock($uri, LockInfo $lockInfo): bool {
try {
$file = $this->getFileFromUri($uri);
Expand Down Expand Up @@ -95,6 +97,7 @@ public function lock($uri, LockInfo $lockInfo): bool {
*
* @return bool
*/
#[\Override]
public function unlock($uri, LockInfo $lockInfo): bool {
try {
$file = $this->getFileFromUri($uri);
Expand Down
3 changes: 3 additions & 0 deletions lib/DAV/LockPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function __construct(LockService $lockService, FileService $fileService,
$this->userSession = $userSession;
}

#[\Override]
public function initialize(Server $server) {
$fakePlugin = $server->getPlugins()[FakeLockerPlugin::class] ?? null;
if ($fakePlugin) {
Expand Down Expand Up @@ -183,6 +184,7 @@ public function customProperties(PropFind $propFind, INode $node) {
});
}

#[\Override]
public function httpLock(RequestInterface $request, ResponseInterface $response) {
if ($request->getHeader('X-User-Lock')) {
$lockType = (int)($request->getHeader('X-User-Lock-Type') ?? ILock::TYPE_USER);
Expand Down Expand Up @@ -217,6 +219,7 @@ public function httpLock(RequestInterface $request, ResponseInterface $response)
return parent::httpLock($request, $response);
}

#[\Override]
public function httpUnlock(RequestInterface $request, ResponseInterface $response) {
if ($request->getHeader('X-User-Lock')) {
$lockType = (int)($request->getHeader('X-User-Lock-Type') ?? ILock::TYPE_USER);
Expand Down
1 change: 1 addition & 0 deletions lib/Listeners/LoadAdditionalScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/** @template-implements IEventListener<Event|LoadAdditionalScriptsEvent> */
class LoadAdditionalScripts implements IEventListener {
#[\Override]
public function handle(Event $event): void {
if (!($event instanceof LoadAdditionalScriptsEvent)) {
return;
Expand Down
1 change: 1 addition & 0 deletions lib/Listeners/PropfindPropertiesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @template-implements IEventListener<BeforeRemotePropfindEvent>
*/
class PropfindPropertiesListener implements IEventListener {
#[\Override]
public function handle(Event $event): void {
if (!($event instanceof BeforeRemotePropfindEvent)) {
return;
Expand Down
3 changes: 3 additions & 0 deletions lib/LockProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function __construct(LockService $lockService) {
$this->lockService = $lockService;
}

#[\Override]
public function getLocks(int $fileId): array {
$lock = $this->lockService->getLockForNodeId($fileId);
if (!$lock) {
Expand All @@ -32,13 +33,15 @@ public function getLocks(int $fileId): array {
/**
* @inheritdoc
*/
#[\Override]
public function lock(LockContext $lockInfo): ILock {
return $this->lockService->lock($lockInfo);
}

/**
* @inheritdoc
*/
#[\Override]
public function unlock(LockContext $lockInfo): void {
try {
$this->lockService->getLockFromFileId($lockInfo->getNode()->getId());
Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/Version0001Date20191105000001.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function __construct(IDBConnection $connection) {
*
* @return ISchemaWrapper
*/
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
Expand Down Expand Up @@ -106,6 +107,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
*
* @throws Exception
*/
#[\Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}
}
2 changes: 1 addition & 1 deletion lib/Migration/Version1000Date20220201111525.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* Auto-generated migration step: Please modify to your needs!
*/
class Version1000Date20220201111525 extends SimpleMigrationStep {
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('files_lock');

Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/Version1000Date20220430180808.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Version1000Date20220430180808 extends SimpleMigrationStep {
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
#[\Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}

Expand All @@ -33,6 +34,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
* @param array $options
* @return null|ISchemaWrapper
*/
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
Expand Down
10 changes: 10 additions & 0 deletions lib/Model/FileLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function setUri(string $uri): self {
/**
* @return string
*/
#[\Override]
public function getOwner(): string {
return $this->userId;
}
Expand All @@ -135,6 +136,7 @@ public function setUserId(string $userId): self {
/**
* @return int
*/
#[\Override]
public function getFileId(): int {
return $this->fileId;
}
Expand All @@ -154,6 +156,7 @@ public function setFileId(int $fileId): self {
/**
* @return string
*/
#[\Override]
public function getToken(): string {
return $this->token;
}
Expand All @@ -173,6 +176,7 @@ public function setToken(string $token): self {
/**
* @return int
*/
#[\Override]
public function getTimeout(): int {
return $this->timeout;
}
Expand Down Expand Up @@ -203,6 +207,7 @@ public function getETA(): int {
/**
* @return int
*/
#[\Override]
public function getCreatedAt(): int {
return $this->creation;
}
Expand All @@ -218,10 +223,12 @@ public function setCreation(int $creation): self {
return $this;
}

#[\Override]
public function getDepth(): int {
return ILock::LOCK_DEPTH_ZERO;
}

#[\Override]
public function getScope(): int {
return $this->scope;
}
Expand All @@ -232,6 +239,7 @@ public function setScope(int $scope): self {
return $this;
}

#[\Override]
public function getType(): int {
return $this->lockType;
}
Expand Down Expand Up @@ -272,6 +280,7 @@ public function toLockInfo(): LockInfo {
*
* @return IQueryRow
*/
#[\Override]
public function importFromDatabase(array $data):IQueryRow {
$this->setId($this->getInt('id', $data));
$this->setUserId($this->get('user_id', $data));
Expand Down Expand Up @@ -305,6 +314,7 @@ public function import(array $data) {
/**
* @return array
*/
#[\Override]
public function jsonSerialize(): array {
return [
'id' => $this->getId(),
Expand Down
22 changes: 10 additions & 12 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@
<directory name="vendor" />
</extraFiles>
<issueHandlers>
<UndefinedMagicMethod>
<errorLevel type="suppress">
<referencedMethod name="/Db\\.*::.*/" />
</errorLevel>
</UndefinedMagicMethod>
<UndefinedInterfaceMethod>
<errorLevel type="suppress">
<!-- FIXME Deprecated event handling -->
<referencedMethod name="OCP\IUserManager::listen" />
<referencedMethod name="OCP\IGroupManager::listen" />
</errorLevel>
</UndefinedInterfaceMethod>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OC\*" />
Expand All @@ -54,5 +42,15 @@
<referencedClass name="OC\Security\CSP\ContentSecurityPolicyNonceManager" />
</errorLevel>
</UndefinedDocblockClass>
<UnusedVariable errorLevel="suppress" />
<UnusedClosureParam errorLevel="suppress" />
<UnusedParam errorLevel="suppress" />
<UnusedReturnValue errorLevel="suppress" />
<UnusedFunctionCall errorLevel="suppress" />
<UnusedMethod errorLevel="suppress" />
<PossiblyUnusedMethod errorLevel="suppress" />
<UnusedClass errorLevel="suppress" />
<UnusedProperty errorLevel="suppress" />
<PossiblyUnusedProperty errorLevel="suppress" />
</issueHandlers>
</psalm>
20 changes: 13 additions & 7 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<files psalm-version="6.15.1@28dc127af1b5aecd52314f6f645bafc10d0e11f9">
<file src="lib/DAV/LockPlugin.php">
<UndefinedClass>
<code><![CDATA[CachingTree]]></code>
Expand Down Expand Up @@ -55,9 +55,6 @@
<code><![CDATA[$qb]]></code>
<code><![CDATA[$qb]]></code>
<code><![CDATA[$qb]]></code>
<code><![CDATA[$qb]]></code>
<code><![CDATA[$qb]]></code>
<code><![CDATA[$qb]]></code>
</MissingDependency>
</file>
<file src="lib/Db/LocksRequestBuilder.php">
Expand All @@ -71,9 +68,12 @@
</MissingDependency>
</file>
<file src="lib/LockProvider.php">
<RedundantCondition>
<code><![CDATA[$lock]]></code>
</RedundantCondition>
<InvalidReturnStatement>
<code><![CDATA[[$lock]]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[array]]></code>
</InvalidReturnType>
</file>
<file src="lib/Service/FileService.php">
<MissingDependency>
Expand All @@ -85,6 +85,12 @@
<code><![CDATA[IRootFolder]]></code>
</MissingDependency>
</file>
<file src="lib/Service/LockService.php">
<MissingDependency>
<code><![CDATA[$this->rootFolder]]></code>
<code><![CDATA[private]]></code>
</MissingDependency>
</file>
<file src="lib/Tools/Traits/TArrayTools.php">
<TypeDoesNotContainNull>
<code><![CDATA[$arr === null]]></code>
Expand Down
Loading