Skip to content

Commit

Permalink
Fix php cs and psalm
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
  • Loading branch information
CarlSchwan committed Aug 23, 2022
1 parent 479e0c4 commit 5ae8c8b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 71 deletions.
1 change: 1 addition & 0 deletions lib/Sabre/Album/AlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function getDateRange(): array {
$latestDate = null;

foreach ($this->getChildren() as $child) {
assert($child instanceof \OCA\Sabre\Connector\Sabre\Node);
$childCreationDate = $child->getFileInfo()->getMtime();
if ($childCreationDate < $earliestDate || $earliestDate === null) {
$earliestDate = $childCreationDate;
Expand Down
12 changes: 6 additions & 6 deletions lib/Sabre/Album/PropFindPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public function initialize(Server $server) {
public function propFind(PropFind $propFind, INode $node): void {
if ($node instanceof AlbumPhoto) {
$propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, fn () => $node->getFile()->getFileId());
$propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, fn () => $node->getETag());
$propFind->handle(self::FILE_NAME_PROPERTYNAME, fn () => $node->getFile()->getName());
$propFind->handle(self::REALPATH_PROPERTYNAME, fn () => $node->getFileInfo()->getPath());
$propFind->handle(self::FAVORITE_PROPERTYNAME, fn () => $node->isFavorite() ? 1 : 0);
$propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, fn () => $node->getETag());
$propFind->handle(self::FILE_NAME_PROPERTYNAME, fn () => $node->getFile()->getName());
$propFind->handle(self::REALPATH_PROPERTYNAME, fn () => $node->getFileInfo()->getPath());
$propFind->handle(self::FAVORITE_PROPERTYNAME, fn () => $node->isFavorite() ? 1 : 0);

$propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
Expand All @@ -106,8 +106,8 @@ public function propFind(PropFind $propFind, INode $node): void {

if ($node instanceof AlbumRoot) {
$propFind->handle(self::LAST_PHOTO_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLastAddedPhoto());
$propFind->handle(self::NBITEMS_PROPERTYNAME, fn () => count($node->getChildren()));
$propFind->handle(self::LOCATION_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLocation());
$propFind->handle(self::NBITEMS_PROPERTYNAME, fn () => count($node->getChildren()));
$propFind->handle(self::LOCATION_PROPERTYNAME, fn () => $node->getAlbum()->getAlbum()->getLocation());
$propFind->handle(self::DATE_RANGE_PROPERTYNAME, fn () => json_encode($node->getDateRange()));

// TODO detect dynamically which metadata groups are requested and
Expand Down
4 changes: 2 additions & 2 deletions tests/Album/AlbumMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ public function testCreateDeleteList() {

public function testCreateRenameGet() {
$album = $this->mapper->create("user1", "album1");
$this->mapper->rename($album->getId(),"renamed");
$this->mapper->rename($album->getId(), "renamed");

$retrievedAlbum = $this->mapper->get($album->getId());
$this->assertEquals("renamed", $retrievedAlbum->getTitle());
}

public function testCreateUpdateGet() {
$album = $this->mapper->create("user1", "album1");
$this->mapper->setLocation($album->getId(),"nowhere");
$this->mapper->setLocation($album->getId(), "nowhere");

$retrievedAlbum = $this->mapper->get($album->getId());
$this->assertEquals("nowhere", $retrievedAlbum->getLocation());
Expand Down
6 changes: 0 additions & 6 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,4 @@
<code>SearchQuery</code>
</UndefinedClass>
</file>
<file src="lib/Sabre/Album/AlbumRoot.php">
<UndefinedMethod occurrences="2">
<code>getFileId</code>
<code>getFileInfo</code>
</UndefinedMethod>
</file>
</files>
58 changes: 1 addition & 57 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ namespace OCA\DAV\Upload {
}

namespace OCA\DAV\Connector\Sabre {

class Node {
class Node extends \Sabre\DAV\INode {
public function getFileInfo(): \OCP\Files\FileInfo {}
}
}
Expand Down Expand Up @@ -665,7 +664,6 @@ class FileMetadata extends Entity {

}


namespace OCA\DAV\Connector\Sabre {
class Node extends \Sabre\Dav\INode {
public function getNode(): \OCP\Files\Node { }
Expand All @@ -684,60 +682,6 @@ namespace OCA\DAV\Upload {
class FutureFile extends \Sabre\Dav\INode {}
}

namespace Sabre\Http {
class RequestInterface {
public function getPath(): string {}
public function getUrl(): string {}
public function setUrl(string $url): void {}
public function getHeader(string $value): string {}
public function getMethod(): string {}
public function setMethod(string $method): void {}
public function setHeader(string $key, string $value) {}
public function hasHeader(string $key): bool {}
public function getAbsoluteUrl(): string {}
public function getQueryParameters(): array {}
}
class ResponseInterface {
public function setHeader(string $key, string $value) {}
public function setMethod(string $method): void {}
public function getStatus(): int {}
public function setStatus(int $status): void {}
public function getPath(): string {}
}
}

namespace Sabre\DAV {
class ServerPlugin {}

class INode {
public function getPath(): string {}
public function getFileInfo(): \OCP\Files\FileInfo {}
public function getFileId(): int {}
}

class PropFind {
public function get(string $key) {}
public function set(string $key, string $value, int $stuff) {}
public function getPath(): string {}
public function setPath(string $string): void {}
}

class Server {
public function addPlugin(ServerPlugin $plugin) {}
public function on(string $method, callable $call, int $priority): void {}
public function getCopyAndMoveInfo(\Sabre\HTTP\RequestInterface $request): array {}
public function invokeMethod(\Sabre\HTTP\RequestInterface $request, \Sabre\HTTP\ResponseInterface $response): void {}
}
}

namespace Sabre\Dav\Exception {
class Conflict extends \Exception {}

class NotFound extends \Exception {}

class Forbidden extends \Exception {}
}

namespace Doctrine\DBAL\Exception {
class UniqueConstraintViolationException extends \Exception {}
}

0 comments on commit 5ae8c8b

Please sign in to comment.