Skip to content

Commit

Permalink
Merge pull request #6291 from nextcloud/update-coding-standard-123
Browse files Browse the repository at this point in the history
Hello coding-standard 1.2.3
  • Loading branch information
kesselb authored Aug 26, 2024
2 parents 03f7bc0 + 5d30e16 commit 6bd46b8
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 86 deletions.
7 changes: 7 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .git-blame-ignore-revs

# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later

# Update to coding-standard 1.2.3
3b3935b4e754ccbc00d3abb71ab6836f3db5b026
1 change: 1 addition & 0 deletions .nextcloudignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.editorconfig
.eslintrc.js
.git
.git-blame-ignore-revs
.github
.gitignore
.gitlab-ci.yml
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function index():TemplateResponse {
* @return FileDisplayResponse
* @throws NotPermittedException
*/
public function getCalendarDotSvg(string $color = "#0082c9"): FileDisplayResponse {
public function getCalendarDotSvg(string $color = '#0082c9'): FileDisplayResponse {
$validColor = '#0082c9';
$color = trim(urldecode($color), '#');
if (preg_match('/^([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Dashboard/CalendarWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
$this->dateTimeFormatter->formatTimeSpan(DateTime::createFromImmutable($startDate)),
$this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('calendar.view.index', ['objectId' => $calendarEvent['uid']])),
$this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('calendar.view.getCalendarDotSvg', ['color' => $calendar->getDisplayColor() ?? '#0082c9'])), // default NC blue fallback
(string) $startDate->getTimestamp(),
(string)$startDate->getTimestamp(),
);
$widgetItems[] = $widget;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/AppointmentConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function __construct() {
* Total length of one slot of the appointment config
* in minutes
*
* @return int Minutes of Appointment slot length
* @return int Minutes of Appointment slot length
*/
public function getTotalLength(): int {
return $this->getLength() + $this->getPreparationDuration() + $this->getFollowupDuration();
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/ClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ClientException extends Exception {
/** @var int|null */
private $httpCode;

public function __construct($message = "",
public function __construct($message = '',
$code = 0,
?Throwable $previous = null,
?int $httpCode = null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/ServiceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ServiceException extends Exception {
/** @var int|null */
private $httpCode;

public function __construct($message = "",
public function __construct($message = '',
$code = 0,
?Throwable $previous = null,
?int $httpCode = null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Listener/UserDeletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public function handle(Event $event): void {
$this->bookingService->deleteByUser($event->getUser());
$this->appointmentConfigService->deleteByUser($event->getUser());

$this->logger->info("Calendar appointments cleaned up for deleted user " . $event->getUser()->getUID());
$this->logger->info('Calendar appointments cleaned up for deleted user ' . $event->getUser()->getUID());
}
}
2 changes: 1 addition & 1 deletion lib/Service/Appointments/AppointmentConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function update(AppointmentConfig $appointmentConfig): AppointmentConfig
public function findById(int $id): AppointmentConfig {
try {
return $this->mapper->findById($id);
} catch (DbException | DoesNotExistException | MultipleObjectsReturnedException $e) {
} catch (DbException|DoesNotExistException|MultipleObjectsReturnedException $e) {
throw new ClientException(
'Could not find a record for id',
$e->getCode(),
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/Appointments/BookingCalendarWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function write(AppointmentConfig $config,
);
if ($defaultReminder !== 'none') {
$alarm = $vcalendar->createComponent('VALARM');
$alarm->add($vcalendar->createProperty('TRIGGER', '-' . $this->secondsToIso8601Duration(abs((int) $defaultReminder)), ['RELATED' => 'START']));
$alarm->add($vcalendar->createProperty('TRIGGER', '-' . $this->secondsToIso8601Duration(abs((int)$defaultReminder)), ['RELATED' => 'START']));
$alarm->add($vcalendar->createProperty('ACTION', 'DISPLAY'));
$vcalendar->VEVENT->add($alarm);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Service/Appointments/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function sendConfirmationEmail(Booking $booking, AppointmentConfig $confi
$template->setSubject($subject);

// Heading
$summary = $this->l10n->t("Dear %s, please confirm your booking", [$booking->getDisplayName()]);
$summary = $this->l10n->t('Dear %s, please confirm your booking', [$booking->getDisplayName()]);
$template->addHeading($summary);

$bookingUrl = $this->urlGenerator->linkToRouteAbsolute('calendar.booking.confirmBooking', ['token' => $booking->getToken()]);
Expand Down Expand Up @@ -190,7 +190,7 @@ public function sendBookingInformationEmail(Booking $booking, AppointmentConfig

$template->addFooter();

$attachment = $this->mailer->createAttachment($calendar, "appointment.ics", "text/calendar");
$attachment = $this->mailer->createAttachment($calendar, 'appointment.ics', 'text/calendar');
$message->attach($attachment);
$message->useTemplate($template);

Expand Down Expand Up @@ -219,7 +219,7 @@ private function addBulletList(IEMailTemplate $template,

// determain timezone depending on who is getting the message (Requestee/Requester)
$tzid = ($recipient) ? $config->getAvailabilityAsArray()['timezoneId'] : $booking->getTimezone();
$dtstart = new \DateTime("now", new \DateTimeZone($booking->getTimezone())); // generate DateTime with booking time zone
$dtstart = new \DateTime('now', new \DateTimeZone($booking->getTimezone())); // generate DateTime with booking time zone
$dtstart->setTimestamp($booking->getStart()); // set booking time stamp

$l = $this->lFactory->findGenericLanguage();
Expand Down Expand Up @@ -324,7 +324,7 @@ public function sendOrganizerBookingInformationEmail(Booking $booking, Appointme

public function sendOrganizerBookingInformationNotification(Booking $booking, AppointmentConfig $config): void {
$tzid = $config->getAvailabilityAsArray()['timezoneId']; // extract time zone from appointment configuration
$dtstart = new \DateTime("now", new \DateTimeZone($booking->getTimezone())); // generate DateTime with booking time zone
$dtstart = new \DateTime('now', new \DateTimeZone($booking->getTimezone())); // generate DateTime with booking time zone
$dtstart->setTimestamp($booking->getStart()); // set booking time stamp

$relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay(
Expand All @@ -339,7 +339,7 @@ public function sendOrganizerBookingInformationNotification(Booking $booking, Ap
$notification
->setApp('calendar')
->setUser($config->getUserId())
->setObject('booking', (string) $booking->getId())
->setObject('booking', (string)$booking->getId())
->setSubject('booking_accepted',
[
'type' => 'highlight',
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/Appointments/TimezoneGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TimezoneGenerator {
* @psalm-suppress NoValue
*
* @return null|VTimeZone A Sabre\VObject\Component object representing a VTIMEZONE definition
* or null if no timezone information is available
* or null if no timezone information is available
*/
public function generateVtimezone(string $timezone, int $from, int $to): ?VTimeZone {
try {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/integration/Composer/AutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function tearDown(): void {
public function testLoadDynamicClass(): void {
$rand = Server::get(ISecureRandom::class);
$className = ucfirst($rand->generate(10, ISecureRandom::CHAR_LOWER));
$namespace = "OCA\\Calendar";
$namespace = 'OCA\\Calendar';

file_put_contents(self::getClassPath($className), <<<FILE
<?php
Expand Down
2 changes: 1 addition & 1 deletion tests/php/unit/Controller/AppointmentControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppointmentControllerTest extends TestCase {
/** @var InitialState|MockObject */
protected $initialState;

/** @var IUser|MockObject */
/** @var IUser|MockObject */
protected $user;

/** @var AppointmentConfigService|MockObject */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppointmentControllerVisitorTest extends TestCase {
/** @var InitialState|MockObject */
protected $initialState;

/** @var IUser|MockObject */
/** @var IUser|MockObject */
protected $user;

/** @var AppointmentConfigService|MockObject */
Expand Down
4 changes: 2 additions & 2 deletions tests/php/unit/Controller/BookingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BookingControllerTest extends TestCase {
/** @var IInitialStateService|MockObject */
protected $initialState;

/** @var IUser|MockObject */
/** @var IUser|MockObject */
protected $user;

/** @var AppointmentConfigService|MockObject */
Expand All @@ -71,7 +71,7 @@ class BookingControllerTest extends TestCase {
/** @var IMailer|MockObject */
private $mailer;

/** @var IConfig|MockObject */
/** @var IConfig|MockObject */
private $systemConfig;

protected function setUp():void {
Expand Down
16 changes: 8 additions & 8 deletions tests/php/unit/Dashbaord/CalendarWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@
use Test\TestCase;

class CalendarWidgetTest extends TestCase {
/** @var IL10N|MockObject */
/** @var IL10N|MockObject */
private $l10n;

/** @var IInitialState|MockObject */
/** @var IInitialState|MockObject */
private $initialState;

/** @var JSDataService|MockObject */
/** @var JSDataService|MockObject */
private $service;

private CalendarWidget $widget;

/** @var IDateTimeFormatter|MockObject */
/** @var IDateTimeFormatter|MockObject */
private $dateTimeFormatter;

/** @var IURLGenerator|MockObject */
/** @var IURLGenerator|MockObject */
private $urlGenerator;

/** @var IManager|MockObject */
/** @var IManager|MockObject */
private $calendarManager;

/** @var ITimeFactory|MockObject */
/** @var ITimeFactory|MockObject */
private $timeFactory;

protected function setUp(): void {
Expand Down Expand Up @@ -152,7 +152,7 @@ public function testGetItems() : void {
'12345678',
'59d30b6c-5a31-4d28-b1d6-c8f928180e96',
'#ffffff',
(string) $start->getTimestamp(),
(string)$start->getTimestamp(),
);

$widgets = $this->widget->getItems($userId);
Expand Down
92 changes: 46 additions & 46 deletions tests/php/unit/Service/Appointments/MailServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MailServiceTest extends TestCase {
/** @var mixed|IFactory|MockObject */
private $lFactory;

/** @var IManager|MockObject */
/** @var IManager|MockObject */
private $notificationManager;

/** @var MailService */
Expand Down Expand Up @@ -333,15 +333,15 @@ public function testSendBookingInformationEmail(): void {
$config->setLocation('Test');
$config->setAvailabilityAsArray(
[
"timezoneId" => "Europe/Berlin",
"slots" => [
"MO" => [["start" => 1713153660, "end" => 1713239940]],
"TU" => [["start" => 1713153660, "end" => 1713239940]],
"WE" => [["start" => 1713153660, "end" => 1713239940]],
"TH" => [["start" => 1713153660, "end" => 1713239940]],
"FR" => [["start" => 1713153660, "end" => 1713239940]],
"SA" => [["start" => 1713153660, "end" => 1713239940]],
"SU" => [["start" => 1713153660, "end" => 1713239940]]
'timezoneId' => 'Europe/Berlin',
'slots' => [
'MO' => [['start' => 1713153660, 'end' => 1713239940]],
'TU' => [['start' => 1713153660, 'end' => 1713239940]],
'WE' => [['start' => 1713153660, 'end' => 1713239940]],
'TH' => [['start' => 1713153660, 'end' => 1713239940]],
'FR' => [['start' => 1713153660, 'end' => 1713239940]],
'SA' => [['start' => 1713153660, 'end' => 1713239940]],
'SU' => [['start' => 1713153660, 'end' => 1713239940]]
]
]
);
Expand Down Expand Up @@ -506,15 +506,15 @@ public function testSendOrganizerBookingInformationEmail(): void {
$config->setLocation('Test');
$config->setAvailabilityAsArray(
[
"timezoneId" => "Europe/Berlin",
"slots" => [
"MO" => [["start" => 1713153660, "end" => 1713239940]],
"TU" => [["start" => 1713153660, "end" => 1713239940]],
"WE" => [["start" => 1713153660, "end" => 1713239940]],
"TH" => [["start" => 1713153660, "end" => 1713239940]],
"FR" => [["start" => 1713153660, "end" => 1713239940]],
"SA" => [["start" => 1713153660, "end" => 1713239940]],
"SU" => [["start" => 1713153660, "end" => 1713239940]]
'timezoneId' => 'Europe/Berlin',
'slots' => [
'MO' => [['start' => 1713153660, 'end' => 1713239940]],
'TU' => [['start' => 1713153660, 'end' => 1713239940]],
'WE' => [['start' => 1713153660, 'end' => 1713239940]],
'TH' => [['start' => 1713153660, 'end' => 1713239940]],
'FR' => [['start' => 1713153660, 'end' => 1713239940]],
'SA' => [['start' => 1713153660, 'end' => 1713239940]],
'SU' => [['start' => 1713153660, 'end' => 1713239940]]
]
]
);
Expand Down Expand Up @@ -592,15 +592,15 @@ public function testSendOrganizerBookingInformationEmailDifferentTZ(): void {
$config->setLocation('Test');
$config->setAvailabilityAsArray(
[
"timezoneId" => "Europe/Berlin",
"slots" => [
"MO" => [["start" => 1713153660, "end" => 1713239940]],
"TU" => [["start" => 1713153660, "end" => 1713239940]],
"WE" => [["start" => 1713153660, "end" => 1713239940]],
"TH" => [["start" => 1713153660, "end" => 1713239940]],
"FR" => [["start" => 1713153660, "end" => 1713239940]],
"SA" => [["start" => 1713153660, "end" => 1713239940]],
"SU" => [["start" => 1713153660, "end" => 1713239940]]
'timezoneId' => 'Europe/Berlin',
'slots' => [
'MO' => [['start' => 1713153660, 'end' => 1713239940]],
'TU' => [['start' => 1713153660, 'end' => 1713239940]],
'WE' => [['start' => 1713153660, 'end' => 1713239940]],
'TH' => [['start' => 1713153660, 'end' => 1713239940]],
'FR' => [['start' => 1713153660, 'end' => 1713239940]],
'SA' => [['start' => 1713153660, 'end' => 1713239940]],
'SU' => [['start' => 1713153660, 'end' => 1713239940]]
]
]
);
Expand Down Expand Up @@ -680,15 +680,15 @@ public function testSendOrganizerBookingInformationEmailFailed(): void {
$config->setLocation('Test');
$config->setAvailabilityAsArray(
[
"timezoneId" => "Europe/Berlin",
"slots" => [
"MO" => [["start" => 1713153660, "end" => 1713239940]],
"TU" => [["start" => 1713153660, "end" => 1713239940]],
"WE" => [["start" => 1713153660, "end" => 1713239940]],
"TH" => [["start" => 1713153660, "end" => 1713239940]],
"FR" => [["start" => 1713153660, "end" => 1713239940]],
"SA" => [["start" => 1713153660, "end" => 1713239940]],
"SU" => [["start" => 1713153660, "end" => 1713239940]]
'timezoneId' => 'Europe/Berlin',
'slots' => [
'MO' => [['start' => 1713153660, 'end' => 1713239940]],
'TU' => [['start' => 1713153660, 'end' => 1713239940]],
'WE' => [['start' => 1713153660, 'end' => 1713239940]],
'TH' => [['start' => 1713153660, 'end' => 1713239940]],
'FR' => [['start' => 1713153660, 'end' => 1713239940]],
'SA' => [['start' => 1713153660, 'end' => 1713239940]],
'SU' => [['start' => 1713153660, 'end' => 1713239940]]
]
]
);
Expand Down Expand Up @@ -779,15 +779,15 @@ public function testSendOrganizerBookingNotification(): void {
$config->setLocation('Test');
$config->setAvailabilityAsArray(
[
"timezoneId" => "Europe/Berlin",
"slots" => [
"MO" => [["start" => 1713153660, "end" => 1713239940]],
"TU" => [["start" => 1713153660, "end" => 1713239940]],
"WE" => [["start" => 1713153660, "end" => 1713239940]],
"TH" => [["start" => 1713153660, "end" => 1713239940]],
"FR" => [["start" => 1713153660, "end" => 1713239940]],
"SA" => [["start" => 1713153660, "end" => 1713239940]],
"SU" => [["start" => 1713153660, "end" => 1713239940]]
'timezoneId' => 'Europe/Berlin',
'slots' => [
'MO' => [['start' => 1713153660, 'end' => 1713239940]],
'TU' => [['start' => 1713153660, 'end' => 1713239940]],
'WE' => [['start' => 1713153660, 'end' => 1713239940]],
'TH' => [['start' => 1713153660, 'end' => 1713239940]],
'FR' => [['start' => 1713153660, 'end' => 1713239940]],
'SA' => [['start' => 1713153660, 'end' => 1713239940]],
'SU' => [['start' => 1713153660, 'end' => 1713239940]]
]
]
);
Expand Down
2 changes: 1 addition & 1 deletion tests/php/unit/Service/CalendarInitialStateServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CalendarInitialStateServiceTest extends TestCase {
/** @var CalendarInitialStateService */
private $service;

/** @var CompareVersion|MockObject*/
/** @var CompareVersion|MockObject */
private $compareVersion;

protected function setUp(): void {
Expand Down
Loading

0 comments on commit 6bd46b8

Please sign in to comment.