Skip to content

Commit

Permalink
Fix more psalm issues
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan committed May 16, 2022
1 parent 829490a commit f7be761
Show file tree
Hide file tree
Showing 29 changed files with 93 additions and 296 deletions.
2 changes: 1 addition & 1 deletion apps/dav/appinfo/v1/caldav.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

// Add plugins
$server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud'));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
$server->addPlugin(new \Sabre\CalDAV\Plugin());

$server->addPlugin(new LegacyDAVACL());
Expand Down
1 change: 0 additions & 1 deletion apps/dav/appinfo/v1/carddav.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use OCP\App\IAppManager;
use Psr\Log\LoggerInterface;
use Sabre\CardDAV\Plugin;
use Psr\Log\LoggerInterface;

$authBackend = new Auth(
\OC::$server->getSession(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ public function __construct(IDBConnection $db,
$this->timeFactory = $timeFactory;
}

/**
* @param $arguments
*/
public function run($arguments) {
$offset = (int) $arguments['offset'];
$stopAt = (int) $arguments['stopAt'];
public function run($argument) {
$offset = (int) $argument['offset'];
$stopAt = (int) $argument['stopAt'];

$this->logger->info('Building calendar reminder index (' . $offset .'/' . $stopAt . ')');

Expand Down
3 changes: 1 addition & 2 deletions apps/dav/lib/BackgroundJob/EventReminderJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ public function __construct(ITimeFactory $time,
}

/**
* @param $arg
* @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException
* @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException
* @throws \OC\User\NoUserException
*/
public function run($arg):void {
public function run($argument):void {
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ public function __construct(ITimeFactory $time,
$this->config = $config;
}

/**
* @param array $arguments
*/
public function run($arguments) {
$userId = $arguments['userId'];
$purgeBeforeGenerating = $arguments['purgeBeforeGenerating'] ?? false;
public function run($argument) {
$userId = $argument['userId'];
$purgeBeforeGenerating = $argument['purgeBeforeGenerating'] ?? false;

// make sure admin didn't change his mind
$isGloballyEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes');
Expand Down
10 changes: 4 additions & 6 deletions apps/dav/lib/BackgroundJob/UploadCleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\TimedJob;
use OCP\Files\Node;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;

class UploadCleanup extends TimedJob {

/** @var IRootFolder */
private $rootFolder;

/** @var IJobList */
private $jobList;
private IRootFolder $rootFolder;
private IJobList $jobList;

public function __construct(ITimeFactory $time, IRootFolder $rootFolder, IJobList $jobList) {
parent::__construct($time);
Expand Down Expand Up @@ -71,6 +68,7 @@ protected function run($argument) {
return;
}

/** @var File[] $files */
$files = $uploadFolder->getDirectoryListing();

// Remove if all files have an mtime of more than a day
Expand Down
48 changes: 9 additions & 39 deletions apps/dav/lib/CalDAV/BirthdayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,15 @@
*/
class BirthdayService {
public const BIRTHDAY_CALENDAR_URI = 'contact_birthdays';

/** @var GroupPrincipalBackend */
private $principalBackend;

/** @var CalDavBackend */
private $calDavBackEnd;

/** @var CardDavBackend */
private $cardDavBackEnd;

/** @var IConfig */
private $config;

/** @var IDBConnection */
private $dbConnection;

/** @var IL10N */
private $l10n;
private GroupPrincipalBackend $principalBackend;
private CalDavBackend $calDavBackEnd;
private CardDavBackend $cardDavBackEnd;
private IConfig $config;
private IDBConnection $dbConnection;
private IL10N $l10n;

/**
* BirthdayService constructor.
*
* @param CalDavBackend $calDavBackEnd
* @param CardDavBackend $cardDavBackEnd
* @param GroupPrincipalBackend $principalBackend
* @param IConfig $config
* @param IDBConnection $dbConnection
* @param IL10N $l10n
*/
public function __construct(CalDavBackend $calDavBackEnd,
CardDavBackend $cardDavBackEnd,
Expand All @@ -96,14 +77,9 @@ public function __construct(CalDavBackend $calDavBackEnd,
$this->l10n = $l10n;
}

/**
* @param int $addressBookId
* @param string $cardUri
* @param string $cardData
*/
public function onCardChanged(int $addressBookId,
string $cardUri,
string $cardData) {
string $cardData): void {
if (!$this->isGloballyEnabled()) {
return;
}
Expand All @@ -129,12 +105,8 @@ public function onCardChanged(int $addressBookId,
}
}

/**
* @param int $addressBookId
* @param string $cardUri
*/
public function onCardDeleted(int $addressBookId,
string $cardUri) {
string $cardUri): void {
if (!$this->isGloballyEnabled()) {
return;
}
Expand All @@ -156,11 +128,9 @@ public function onCardDeleted(int $addressBookId,
}

/**
* @param string $principal
* @return array|null
* @throws \Sabre\DAV\Exception\BadRequest
*/
public function ensureCalendarExists(string $principal):?array {
public function ensureCalendarExists(string $principal): ?array {
$calendar = $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
if (!is_null($calendar)) {
return $calendar;
Expand Down
13 changes: 7 additions & 6 deletions apps/dav/lib/CalDAV/CachedSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Sabre\CalDAV\Backend\BackendInterface;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;
use Sabre\DAV\PropPatch;

/**
Expand All @@ -51,7 +52,7 @@ public function getPrincipalURI():string {
/**
* @return array
*/
public function getACL():array {
public function getACL() {
return [
[
'privilege' => '{DAV:}read',
Expand Down Expand Up @@ -79,7 +80,7 @@ public function getACL():array {
/**
* @return array
*/
public function getChildACL():array {
public function getChildACL() {
return [
[
'privilege' => '{DAV:}read',
Expand Down Expand Up @@ -139,9 +140,9 @@ public function getChild($name) {
}

/**
* @return array
* @return INode[]
*/
public function getChildren():array {
public function getChildren(): array {
$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);

$children = [];
Expand Down Expand Up @@ -169,8 +170,8 @@ public function getMultipleChildren(array $paths):array {

/**
* @param string $name
* @param null $calendarData
* @return null|string|void
* @param null|resource|string $calendarData
* @return null|string
* @throws MethodNotAllowed
*/
public function createFile($name, $calendarData = null) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/CachedSubscriptionObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function get() {

/**
* @param resource|string $calendarData
* @return string|void
* @return string
* @throws MethodNotAllowed
*/
public function put($calendarData) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
namespace OCA\DAV\CalDAV\ICSExportPlugin;

use OCP\IConfig;
use Psr\Log\LoggerInterface;
use Sabre\HTTP\ResponseInterface;
use Sabre\VObject\DateTimeParser;
use Sabre\VObject\InvalidDataException;
use Sabre\VObject\Property\ICalendar\Duration;
use Psr\Log\LoggerInterface;

/**
* Class ICSExportPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use OCP\EventDispatcher\IEventDispatcher;
use Psr\Log\LoggerInterface;
use Sabre\VObject\ITip\Message;
use Psr\Log\LoggerInterface;

class InvitationResponseServer {

Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public function propFind(PropFind $propFind, INode $node) {
$canPublish = (!$node->isSubscription() && $node->canWrite());

if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') {
$canShare &= ($node->getOwner() === $node->getPrincipalURI());
$canPublish &= ($node->getOwner() === $node->getPrincipalURI());
$canShare = $canShare && ($node->getOwner() === $node->getPrincipalURI());
$canPublish = $canPublish && ($node->getOwner() === $node->getPrincipalURI());
}

return new AllowedSharingModes($canShare, $canPublish);
Expand Down
Loading

0 comments on commit f7be761

Please sign in to comment.