Skip to content

Commit

Permalink
chore: Fix psalm errors
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Aug 29, 2024
1 parent 625a332 commit 2bcb928
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 26 deletions.
27 changes: 10 additions & 17 deletions lib/Sabre/Album/AlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,13 @@
use Sabre\DAV\INode;

class AlbumRoot implements ICollection, ICopyTarget {
protected AlbumMapper $albumMapper;
protected AlbumWithFiles $album;
protected IRootFolder $rootFolder;
protected string $userId;

public function __construct(
AlbumMapper $albumMapper,
AlbumWithFiles $album,
IRootFolder $rootFolder,
string $userId,
UserConfigService $userConfigService
protected AlbumMapper $albumMapper,
protected AlbumWithFiles $album,
protected IRootFolder $rootFolder,
protected string $userId,
protected UserConfigService $userConfigService
) {
$this->albumMapper = $albumMapper;
$this->album = $album;
$this->rootFolder = $rootFolder;
$this->userId = $userId;
$this->userConfigService = $userConfigService;
}

/**
Expand Down Expand Up @@ -73,7 +63,7 @@ protected function getPhotosLocationInfo() {
*
* @param string $name
* @param null|resource|string $data
* @return void
* @return string|null
*/
public function createFile($name, $data = null) {
try {
Expand All @@ -92,7 +82,7 @@ public function createFile($name, $data = null) {
}

// Check for conflict and rename the file accordingly
$newName = \basename(\OC_Helper::buildNotExistingFileName($photosLocation, $name));
$newName = $photosFolder->getNonExistingName($name);

$node = $photosFolder->newFile($newName, $data);
$this->addFile($node->getId(), $node->getOwner()->getUID());
Expand All @@ -112,6 +102,9 @@ public function createDirectory($name) {
throw new Forbidden('Not allowed to create directories in this folder');
}

/**
* @return AlbumPhoto[]
*/
public function getChildren(): array {
return array_map(function (AlbumFile $file) {
return new AlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId));
Expand Down
1 change: 0 additions & 1 deletion lib/Sabre/Album/PublicAlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function setCollaborators($collaborators): array {
throw new Forbidden('Not allowed to collaborators a public album');
}

/** @return never */
public function getChildren(): array {
return array_map(function (AlbumFile $file) {
return new PublicAlbumPhoto($this->albumMapper, $this->album->getAlbum(), $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId));
Expand Down
1 change: 0 additions & 1 deletion lib/Sabre/Album/SharedAlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function __construct(
$rootFolder,
$userId,
$userConfigService,
$userManager
);

$this->userManager = $userManager;
Expand Down
2 changes: 1 addition & 1 deletion lib/Sabre/PhotosHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function getChild($name) {
}

/**
* @return (AlbumsHome)[]
* @return (AlbumsHome|SharedAlbumsHome|PlacesHome)[]
*/
public function getChildren(): array {
return [
Expand Down
2 changes: 1 addition & 1 deletion lib/Sabre/Place/PlaceRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Sabre\DAV\ICollection;

class PlaceRoot implements ICollection {
/** @var PlaceFile[]|null */
/** @var PlacePhoto[]|null */
protected ?array $children = null;

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion lib/Sabre/PublicRootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getChildForPrincipal(array $principalInfo): PublicAlbumRoot {
*
* @throws NotFound
*
* @return DAV\INode
* @return \Sabre\DAV\INode
*/
public function getChild($name) {
$this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), self::BRUTEFORCE_ACTION);
Expand Down
5 changes: 3 additions & 2 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0"?>
<psalm errorLevel="4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor-bin/psalm/vendor/vimeo/psalm/config.xsd"
errorBaseline="tests/psalm-baseline.xml">
xsi:schemaLocation="https://getpsalm.org/schema/config https://getpsalm.org/schema/config"
errorBaseline="tests/psalm-baseline.xml"
autoloader="vendor-bin/psalm/vendor/autoload.php">
<stubs>
<file name="tests/stub.phpstub" preloadClasses="true" />
</stubs>
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"symfony/console": "^5.4.24",
"sabre/dav": "^4.4.0"
}
}
}
2 changes: 1 addition & 1 deletion vendor-bin/psalm/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bcb928

Please sign in to comment.