Skip to content

Commit

Permalink
chore: Cleanup psalm baseline
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jun 23, 2023
1 parent 56411bd commit 2ac9431
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 108 deletions.
5 changes: 3 additions & 2 deletions lib/Listeners/BeforeNodeDeletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public function handle(Event $event): void {
if (!$event instanceof BeforeNodeDeletedEvent) {
return;
}
if ($event->getNode() instanceof File && $event->getNode()->getMimeType() === 'text/markdown') {
$this->attachmentService->deleteAttachments($event->getNode());
$node = $event->getNode();
if ($node instanceof File && $node->getMimeType() === 'text/markdown') {
$this->attachmentService->deleteAttachments($node);
}
}
}
10 changes: 6 additions & 4 deletions lib/Listeners/BeforeNodeRenamedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public function handle(Event $event): void {
if (!$event instanceof BeforeNodeRenamedEvent) {
return;
}
if ($event->getSource() instanceof File
&& $event->getSource()->getMimeType() === 'text/markdown'
&& $event->getTarget() instanceof File
$source = $event->getSource();
$target = $event->getTarget();
if ($source instanceof File
&& $source->getMimeType() === 'text/markdown'
&& $target instanceof File
) {
$this->attachmentService->moveAttachments($event->getSource(), $event->getTarget());
$this->attachmentService->moveAttachments($source, $target);
}
}
}
12 changes: 7 additions & 5 deletions lib/Listeners/NodeCopiedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public function handle(Event $event): void {
if (!$event instanceof NodeCopiedEvent) {
return;
}
if ($event->getSource() instanceof File
&& $event->getSource()->getMimeType() === 'text/markdown'
&& $event->getTarget() instanceof File
&& $event->getTarget()->getMimeType() === 'text/markdown'
$source = $event->getSource();
$target = $event->getTarget();
if ($source instanceof File
&& $source->getMimeType() === 'text/markdown'
&& $target instanceof File
&& $target->getMimeType() === 'text/markdown'
) {
$this->attachmentService->copyAttachments($event->getSource(), $event->getTarget());
$this->attachmentService->copyAttachments($source, $target);
}
}
}
4 changes: 2 additions & 2 deletions lib/Service/DocumentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function createDocument(File $file): Document {
} catch (Exception $e) {
if ($e->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
// Document might have been created in the meantime
return $this->documentMapper->find($file->getFileInfo()->getId());
return $this->documentMapper->find($file->getId());
}

throw $e;
Expand Down Expand Up @@ -509,7 +509,7 @@ public function getFileByShareToken(string $shareToken, ?string $path = null): F
}

$node = $share->getNode();
if ($node instanceof Folder) {
if ($path !== null && $node instanceof Folder) {
$node = $node->get($path);
}
if ($node instanceof File) {
Expand Down
100 changes: 5 additions & 95 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,112 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>RegisterDirectEditorEventListener::class</code>
</InvalidArgument>
<UndefinedClass occurrences="3">
<code>BeforeTemplateRenderedEvent</code>
<code>LoadAdditionalScriptsEvent</code>
<code>LoadViewer</code>
</UndefinedClass>
</file>
<file src="lib/Controller/DirectSessionController.php">
<UndefinedClass occurrences="1">
<code>InvalidTokenException</code>
</UndefinedClass>
</file>
<files psalm-version="5.12.0@f90118cdeacd0088e7215e64c0c99ceca819e176">
<file src="lib/Controller/WorkspaceController.php">
<InvalidReturnType occurrences="3">
<code>DataResponse</code>
<code>DataResponse</code>
<code>DataResponse</code>
</InvalidReturnType>
<MissingDependency occurrences="4">
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
</MissingDependency>
<UndefinedInterfaceMethod occurrences="1">
<UndefinedInterfaceMethod>
<code>open</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/DAV/WorkspacePlugin.php">
<UndefinedClass occurrences="1">
<UndefinedClass>
<code>ServerPlugin</code>
</UndefinedClass>
</file>
<file src="lib/DirectEditing/TextDirectEditor.php">
<LessSpecificImplementedReturnType occurrences="3">
<code>array</code>
<code>array</code>
<code>array</code>
</LessSpecificImplementedReturnType>
<UndefinedInterfaceMethod occurrences="1">
<UndefinedInterfaceMethod>
<code>getToken</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/Listeners/FilesLoadAdditionalScriptsListener.php">
<UndefinedClass occurrences="1">
<code>LoadAdditionalScriptsEvent</code>
</UndefinedClass>
</file>
<file src="lib/Listeners/LoadViewerListener.php">
<UndefinedClass occurrences="1">
<code>LoadViewer</code>
</UndefinedClass>
</file>
<file src="lib/Service/ApiService.php">
<UndefinedDocblockClass occurrences="1"/>
</file>
<file src="lib/Service/DocumentService.php">
<MismatchingDocblockReturnType occurrences="1">
<code>Entity</code>
</MismatchingDocblockReturnType>
<MissingDependency occurrences="3">
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
</MissingDependency>
<UndefinedClass occurrences="1">
<code>\OC\User\NoUserException</code>
</UndefinedClass>
</file>
<file src="lib/Service/AttachmentService.php">
<MissingDependency occurrences="6">
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
</MissingDependency>
<UndefinedClass occurrences="3">
<code>ClientException</code>
<code>ConnectException</code>
<code>ServerException</code>
</UndefinedClass>
<UndefinedDocblockClass occurrences="16">
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
<code>\OC\User\NoUserException</code>
</UndefinedDocblockClass>
</file>
<file src="vendor/nextcloud/ocp/OCP/BackgroundJob/TimedJob.php">
<ImplementedParamTypeMismatch occurrences="1">
<ImplementedParamTypeMismatch>
<code>$jobList</code>
</ImplementedParamTypeMismatch>
</file>
Expand Down
4 changes: 4 additions & 0 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ namespace OC\AppFramework\OCS {
class BaseResponse {}
}

namespace OCA\Files\Event {
class LoadAdditionalScriptsEvent extends \OCP\EventDispatcher\Event {}
}

namespace OCA\Viewer\Event {
class LoadViewer extends \OCP\EventDispatcher\Event {}
}
Expand Down

0 comments on commit 2ac9431

Please sign in to comment.