Mainly using PHP8's constructor property promotion.
Signed-off-by: Faraz Samapoor <fsa@adlas.at>
use OCP\Calendar\ICalendarQuery;
class CalendarQuery implements ICalendarQuery {
- /** @var string */
- private $principalUri;
+ public array $searchProperties = [];
- /** @var array */
- public $searchProperties;
+ private ?string $searchPattern;
- /** @var string|null */
- private $searchPattern;
+ private array $options = [
+ 'types' => [],
+ ];
- /** @var array */
- private $options;
+ private ?int $offset;
- /** @var int|null */
- private $offset;
-
- /** @var int|null */
- private $limit;
+ private ?int $limit;
/** @var string[] */
- private $calendarUris = [];
+ private array $calendarUris = [];
- public function __construct(string $principalUri) {
- $this->principalUri = $principalUri;
- $this->searchProperties = [];
- $this->options = [
- 'types' => [],
- ];
+ public function __construct(
+ private string $principalUri,
+ ) {
}
public function getPrincipalUri(): string {
/**
* @var ICalendar[] holds all registered calendars
*/
- private $calendars = [];
+ private array $calendars = [];
/**
* @var \Closure[] to call to load/register calendar providers
*/
- private $calendarLoaders = [];
-
- /** @var Coordinator */
- private $coordinator;
-
- /** @var ContainerInterface */
- private $container;
-
- /** @var LoggerInterface */
- private $logger;
-
- private ITimeFactory $timeFactory;
-
-
- public function __construct(Coordinator $coordinator,
- ContainerInterface $container,
- LoggerInterface $logger,
- ITimeFactory $timeFactory) {
- $this->coordinator = $coordinator;
- $this->container = $container;
- $this->logger = $logger;
- $this->timeFactory = $timeFactory;
+ private array $calendarLoaders = [];
+
+ public function __construct(
+ private Coordinator $coordinator,
+ private ContainerInterface $container,
+ private LoggerInterface $logger,
+ private ITimeFactory $timeFactory,
+ ) {
}
/**
* @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs
* @since 13.0.0
*/
- public function search($pattern, array $searchProperties = [], array $options = [], $limit = null, $offset = null) {
+ public function search(
+ $pattern,
+ array $searchProperties = [],
+ array $options = [],
+ $limit = null,
+ $offset = null,
+ ): array {
$this->loadCalendars();
$result = [];
foreach ($this->calendars as $calendar) {
* @return bool true if enabled, false if not
* @since 13.0.0
*/
- public function isEnabled() {
+ public function isEnabled(): bool {
return !empty($this->calendars) || !empty($this->calendarLoaders);
}
/**
* Registers a calendar
*
- * @param ICalendar $calendar
- * @return void
* @since 13.0.0
*/
- public function registerCalendar(ICalendar $calendar) {
+ public function registerCalendar(ICalendar $calendar): void {
$this->calendars[$calendar->getKey()] = $calendar;
}
/**
* Unregisters a calendar
*
- * @param ICalendar $calendar
- * @return void
* @since 13.0.0
*/
- public function unregisterCalendar(ICalendar $calendar) {
+ public function unregisterCalendar(ICalendar $calendar): void {
unset($this->calendars[$calendar->getKey()]);
}
* In order to improve lazy loading a closure can be registered which will be called in case
* calendars are actually requested
*
- * @param \Closure $callable
- * @return void
* @since 13.0.0
*/
- public function register(\Closure $callable) {
+ public function register(\Closure $callable): void {
$this->calendarLoaders[] = $callable;
}
/**
* @return ICalendar[]
+ *
* @since 13.0.0
*/
- public function getCalendars() {
+ public function getCalendars(): array {
$this->loadCalendars();
return array_values($this->calendars);
/**
* removes all registered calendar instances
- * @return void
+ *
* @since 13.0.0
*/
- public function clear() {
+ public function clear(): void {
$this->calendars = [];
$this->calendarLoaders = [];
}
/**
* loads all calendars
*/
- private function loadCalendars() {
+ private function loadCalendars(): void {
foreach ($this->calendarLoaders as $callable) {
$callable($this);
}
}
/**
- * @param string $principalUri
- * @param array $calendarUris
* @return ICreateFromString[]
*/
public function getCalendarsForPrincipal(string $principalUri, array $calendarUris = []): array {
/**
* @throws \OCP\DB\Exception
*/
- public function handleIMipReply(string $principalUri, string $sender, string $recipient, string $calendarData): bool {
+ public function handleIMipReply(
+ string $principalUri,
+ string $sender,
+ string $recipient,
+ string $calendarData,
+ ): bool {
/** @var VCalendar $vObject */
$vObject = Reader::read($calendarData);
/** @var VEvent $vEvent */
* @since 25.0.0
* @throws \OCP\DB\Exception
*/
- public function handleIMipCancel(string $principalUri, string $sender, ?string $replyTo, string $recipient, string $calendarData): bool {
+ public function handleIMipCancel(
+ string $principalUri,
+ string $sender,
+ ?string $replyTo,
+ string $recipient,
+ string $calendarData,
+ ): bool {
$vObject = Reader::read($calendarData);
/** @var VEvent $vEvent */
$vEvent = $vObject->{'VEVENT'};
use OCP\IServerContainer;
class Manager implements IManager {
- private Coordinator $bootstrapCoordinator;
-
- private IServerContainer $server;
-
private bool $bootstrapBackendsLoaded = false;
/**
* @var string[] holds all registered resource backends
* @psalm-var class-string<IBackend>[]
*/
- private $backends = [];
+ private array $backends = [];
/** @var IBackend[] holds all backends that have been initialized already */
- private $initializedBackends = [];
+ private array $initializedBackends = [];
- public function __construct(Coordinator $bootstrapCoordinator,
- IServerContainer $server) {
- $this->bootstrapCoordinator = $bootstrapCoordinator;
- $this->server = $server;
+ public function __construct(
+ private Coordinator $bootstrapCoordinator,
+ private IServerContainer $server,
+ ) {
}
/**
* Registers a resource backend
*
- * @param string $backendClass
- * @return void
* @since 14.0.0
*/
- public function registerBackend(string $backendClass) {
+ public function registerBackend(string $backendClass): void {
$this->backends[$backendClass] = $backendClass;
}
/**
* Unregisters a resource backend
*
- * @param string $backendClass
- * @return void
* @since 14.0.0
*/
- public function unregisterBackend(string $backendClass) {
+ public function unregisterBackend(string $backendClass): void {
unset($this->backends[$backendClass], $this->initializedBackends[$backendClass]);
}
/**
* @param string $backendId
* @throws \OCP\AppFramework\QueryException
- * @return IBackend|null
*/
- public function getBackend($backendId) {
+ public function getBackend($backendId): ?IBackend {
$backends = $this->getBackends();
foreach ($backends as $backend) {
if ($backend->getBackendIdentifier() === $backendId) {
/**
* removes all registered backend instances
- * @return void
+ *
* @since 14.0.0
*/
- public function clear() {
+ public function clear(): void {
$this->backends = [];
$this->initializedBackends = [];
}
use OCP\IServerContainer;
class Manager implements IManager {
- private Coordinator $bootstrapCoordinator;
-
- private IServerContainer $server;
-
private bool $bootstrapBackendsLoaded = false;
/**
/** @var IBackend[] holds all backends that have been initialized already */
private array $initializedBackends = [];
- public function __construct(Coordinator $bootstrapCoordinator,
- IServerContainer $server) {
- $this->bootstrapCoordinator = $bootstrapCoordinator;
- $this->server = $server;
+ public function __construct(
+ private Coordinator $bootstrapCoordinator,
+ private IServerContainer $server,
+ ) {
}
/**
* Registers a resource backend
*
- * @param string $backendClass
- * @return void
* @since 14.0.0
*/
- public function registerBackend(string $backendClass) {
+ public function registerBackend(string $backendClass): void {
$this->backends[$backendClass] = $backendClass;
}
* Unregisters a resource backend
*
* @param string $backendClass
- * @return void
* @since 14.0.0
*/
- public function unregisterBackend(string $backendClass) {
+ public function unregisterBackend(string $backendClass): void {
unset($this->backends[$backendClass], $this->initializedBackends[$backendClass]);
}
/**
* @param string $backendId
* @throws \OCP\AppFramework\QueryException
- * @return IBackend|null
*/
- public function getBackend($backendId) {
+ public function getBackend($backendId): ?IBackend {
$backends = $this->getBackends();
foreach ($backends as $backend) {
if ($backend->getBackendIdentifier() === $backendId) {
/**
* removes all registered backend instances
- * @return void
+ *
* @since 14.0.0
*/
- public function clear() {
+ public function clear(): void {
$this->backends = [];
$this->initializedBackends = [];
}