Add php 7.2 linter and fix errors

Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
Anna Larch 2021-11-30 09:10:42 +01:00
parent 3c09657231
commit 358659bfb8
8 changed files with 17 additions and 25 deletions

View File

@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3', '7.4', '8.0']
php-versions: ['7.2', '7.3', '7.4', '8.0']
name: php${{ matrix.php-versions }} lint
steps:
- name: Checkout

View File

@ -15,7 +15,7 @@
"scripts": {
"cs:fix": "php-cs-fixer fix",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './tests/*' -print0 | xargs -0 -n1 php -l",
"test": "phpunit --configuration phpunit.unit.xml --fail-on-warning",
"test:dev": "phpunit --configuration phpunit.unit.xml --fail-on-warning --stop-on-error --stop-on-failure"
}

View File

@ -90,11 +90,11 @@ class AppointmentController extends Controller {
[
'uid' => $user->getUID(),
'displayName' => $user->getDisplayName(),
],
]
);
$this->initialState->provideInitialState(
'appointmentConfigs',
$this->configService->getAllAppointmentConfigurations($userId, AppointmentConfig::VISIBILITY_PUBLIC),
$this->configService->getAllAppointmentConfigurations($userId, AppointmentConfig::VISIBILITY_PUBLIC)
);
return new TemplateResponse(
@ -135,7 +135,7 @@ class AppointmentController extends Controller {
[
'uid' => $configOwner->getUID(),
'displayName' => $configOwner->getDisplayName(),
],
]
);
$this->initialState->provideInitialState(
'config',
@ -153,7 +153,7 @@ class AppointmentController extends Controller {
[
'displayName' => $currentUser->getDisplayName(),
'email' => $currentUser->getEMailAddress(),
],
]
);
}

View File

@ -112,10 +112,7 @@ class ViewController extends Controller {
$this->initialStateService->provideInitialState('default_reminder', $defaultReminder);
$this->initialStateService->provideInitialState('show_tasks', $showTasks);
$this->initialStateService->provideInitialState('tasks_enabled', $tasksEnabled);
$this->initialStateService->provideInitialState(
'appointmentConfigs',
$this->appointmentConfigService->getAllAppointmentConfigurations($this->userId),
);
$this->initialStateService->provideInitialState('appointmentConfigs',$this->appointmentConfigService->getAllAppointmentConfigurations($this->userId));
return new TemplateResponse($this->appName, 'main');
}

View File

@ -158,7 +158,7 @@ class AppointmentConfig extends Entity implements JsonSerializable {
}
public function getCalendarFreebusyUrisAsArray(): array {
return json_decode($this->getCalendarFreebusyUris(), true, 512, JSON_THROW_ON_ERROR);
return json_decode($this->getCalendarFreebusyUris(), true);
}
/**
@ -171,7 +171,7 @@ class AppointmentConfig extends Entity implements JsonSerializable {
}
public function setAvailabilityAsArray(array $availability): self {
$this->setAvailability(json_encode($availability, JSON_THROW_ON_ERROR));
$this->setAvailability(json_encode($availability));
return $this;
}
@ -187,7 +187,7 @@ class AppointmentConfig extends Entity implements JsonSerializable {
'userId' => $this->getUserId(),
'targetCalendarUri' => $this->getTargetCalendarUri(),
'calendarFreeBusyUris' => $this->getCalendarFreebusyUris(),
'availability' => $this->getAvailability() === null ? null : json_decode($this->getAvailability(), true, 512, JSON_THROW_ON_ERROR),
'availability' => $this->getAvailability() === null ? null : json_decode($this->getAvailability(), true),
'start' => $this->getStart(),
'end' => $this->getEnd(),
'length' => $this->getLength(),

View File

@ -113,14 +113,14 @@ class AppointmentsAction implements ILinkAction {
if (count($this->configs) === 1) {
return $this->urlGenerator->linkToRouteAbsolute(
'calendar.appointment.show',
['token' => $this->configs[0]->getToken()],
['token' => $this->configs[0]->getToken()]
);
}
// Link to the overview page
return $this->urlGenerator->linkToRouteAbsolute(
'calendar.appointment.index',
['userId' => $this->targetUser->getUID()],
['userId' => $this->targetUser->getUID()]
);
}
}

View File

@ -29,10 +29,8 @@ use DateInterval;
use DatePeriod;
use DateTimeImmutable;
use DateTimeZone;
use JsonException;
use OCA\Calendar\Db\AppointmentConfig;
use OCP\AppFramework\Utility\ITimeFactory;
use RuntimeException;
use function ceil;
use function max;
use function min;
@ -92,11 +90,8 @@ class AvailabilityGenerator {
];
}
try {
$availabilityRule = json_decode($config->getAvailability(), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
throw new RuntimeException('Could not parse JSON for slots', 0, $e);
}
$availabilityRule = json_decode($config->getAvailability(), true);
$timeZone = $availabilityRule['timezoneId'];
$slots = $availabilityRule['slots'];
@ -149,7 +144,7 @@ class AvailabilityGenerator {
$period = new DatePeriod(
(new DateTimeImmutable())->setTimezone($tz)->setTimestamp($start - 87600)->setTime(0, 0),
new DateInterval('P1D'),
(new DateTimeImmutable())->setTimezone($tz)->setTimestamp($start + 87600)->setTime(23, 59),
(new DateTimeImmutable())->setTimezone($tz)->setTimestamp($start + 87600)->setTime(23, 59)
);
/** @var Interval[] $applicable */
@ -170,7 +165,7 @@ class AvailabilityGenerator {
$dEnd = $dailyRule['end'];
$applicable[] = new Interval(
$item->setTime((int)$dStart->format('H'), (int)$dStart->format('i'))->getTimestamp(),
$item->setTime((int)$dEnd->format('H'), (int)$dEnd->format('i'))->getTimestamp(),
$item->setTime((int)$dEnd->format('H'), (int)$dEnd->format('i'))->getTimestamp()
);
}
}

View File

@ -176,7 +176,7 @@ class BookingService {
'availabilityIntervals' => count($availabilityIntervals),
'allPossibleSlots' => count($allPossibleSlots),
'filteredByDailyLimit' => count($filteredByDailyLimit),
'available' => count($available),
'available' => count($available)
]);
return $available;