fix: psalm errors

pull/126/head
sualko 2021-02-13 17:36:14 +01:00
parent b54f9db4e4
commit f78fd5c47e
9 changed files with 714 additions and 443 deletions

View File

@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ocp-version: [ 'dev-master', '^20.0' ]
ocp-version: [ 'dev-stable21', 'dev-stable20', 'dev-stable19' ]
name: Nextcloud ${{ matrix.ocp-version }}
steps:
- name: Checkout

1074
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,8 @@ class Application extends App {
}
private function registerAsPersonalSetting() {
$settingsManager = $this->getContainer()->getServer()->getSettingsManager();
/** @var ISettingsManager */
$settingsManager = $this->getContainer()->query(ISettingsManager::class);
$settingsManager->registerSetting(ISettingsManager::KEY_PERSONAL_SETTINGS, \OCA\BigBlueButton\Settings\Personal::class);
}

View File

@ -69,7 +69,7 @@ class RestrictionController extends Controller {
string $groupId
): DataResponse {
if ($this->service->existsByGroupId($groupId)) {
return new DataResponse(null, Http::STATUS_CONFLICT);
return new DataResponse([], Http::STATUS_CONFLICT);
}
return new DataResponse($this->service->create(

View File

@ -75,22 +75,22 @@ class RoomController extends Controller {
string $access
): DataResponse {
if (!$this->permission->isAllowedToCreateRoom($this->userId)) {
return new DataResponse(null, Http::STATUS_FORBIDDEN);
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
$restriction = $this->permission->getRestriction($this->userId);
if ($restriction->getMaxParticipants() > -1 && ($maxParticipants > $restriction->getMaxParticipants() || $maxParticipants <= 0)) {
return new DataResponse('Max participants limit exceeded.', Http::STATUS_BAD_REQUEST);
return new DataResponse(['message' => 'Max participants limit exceeded.'], Http::STATUS_BAD_REQUEST);
}
if (!$restriction->getAllowRecording() && $record) {
return new DataResponse('Not allowed to enable recordings.', Http::STATUS_BAD_REQUEST);
return new DataResponse(['message' => 'Not allowed to enable recordings.'], Http::STATUS_BAD_REQUEST);
}
$disabledRoomTypes = \json_decode($restriction->getRoomTypes());
if (in_array($access, $disabledRoomTypes) || !in_array($access, Room::ACCESS)) {
return new DataResponse('Access type not allowed.', Http::STATUS_BAD_REQUEST);
return new DataResponse(['message' => 'Access type not allowed.'], Http::STATUS_BAD_REQUEST);
}
return new DataResponse($this->service->create(
@ -126,16 +126,16 @@ class RoomController extends Controller {
$restriction = $this->permission->getRestriction($this->userId);
if ($restriction->getMaxParticipants() > -1 && $maxParticipants !== $room->getMaxParticipants() && ($maxParticipants > $restriction->getMaxParticipants() || $maxParticipants <= 0)) {
return new DataResponse('Max participants limit exceeded.', Http::STATUS_BAD_REQUEST);
return new DataResponse(['message' => 'Max participants limit exceeded.'], Http::STATUS_BAD_REQUEST);
}
if (!$restriction->getAllowRecording() && $record !== $room->getRecord()) {
return new DataResponse('Not allowed to enable recordings.', Http::STATUS_BAD_REQUEST);
return new DataResponse(['message' => 'Not allowed to enable recordings.'], Http::STATUS_BAD_REQUEST);
}
$disabledRoomTypes = \json_decode($restriction->getRoomTypes());
if ((in_array($access, $disabledRoomTypes) && $access !== $room->getAccess()) || !in_array($access, Room::ACCESS)) {
return new DataResponse('Access type not allowed.', Http::STATUS_BAD_REQUEST);
return new DataResponse(['message' => 'Access type not allowed.'], Http::STATUS_BAD_REQUEST);
}
return $this->handleNotFound(function () use ($id, $name, $welcome, $maxParticipants, $record, $access, $everyoneIsModerator, $requireModerator, $moderatorToken) {
@ -150,7 +150,7 @@ class RoomController extends Controller {
$room = $this->service->find($id);
if (!$this->permission->isAdmin($room, $this->userId)) {
return new DataResponse(null, Http::STATUS_FORBIDDEN);
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
return $this->handleNotFound(function () use ($id) {

View File

@ -108,7 +108,7 @@ class RoomShareController extends Controller {
int $permission
): DataResponse {
if (!$this->isUserAllowed($roomId)) {
return new DataResponse(null, Http::STATUS_FORBIDDEN);
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
return new DataResponse($this->service->create(
@ -130,7 +130,7 @@ class RoomShareController extends Controller {
int $permission
): DataResponse {
if (!$this->isUserAllowed($roomId)) {
return new DataResponse(null, Http::STATUS_FORBIDDEN);
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
return $this->handleNotFound(function () use (
@ -157,7 +157,7 @@ class RoomShareController extends Controller {
$roomShare = $this->service->find($id);
if (!$this->isUserAllowed($roomShare->getRoomId())) {
return new DataResponse(null, Http::STATUS_FORBIDDEN);
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
return $this->service->delete($id);

View File

@ -57,11 +57,11 @@ class HookMiddleware extends Middleware {
}
if ($exception instanceof NotFoundException) {
return new JSONResponse(null, Http::STATUS_NOT_FOUND);
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
if ($exception instanceof NoPermissionException) {
return new JSONResponse(null, Http::STATUS_FORBIDDEN);
return new JSONResponse([], Http::STATUS_FORBIDDEN);
}
throw $exception;

View File

@ -6,6 +6,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="tests/psalm-baseline.xml"
>
<projectFiles>
<directory name="lib" />

49
tests/psalm-baseline.xml Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.5.1@257a1ca672a79dedc852be1285a7b97154646418">
<file src="lib/CircleHelper.php">
<UndefinedClass occurrences="3">
<code>\OCA\Circles\Api\v1\Circles</code>
<code>\OCA\Circles\Model\Circle</code>
<code>\OCA\Circles\Model\Member</code>
</UndefinedClass>
</file>
<file src="lib/Controller/RoomController.php">
<NullArgument occurrences="1">
<code>null</code>
</NullArgument>
</file>
<file src="lib/Controller/ServerController.php">
<InvalidArgument occurrences="1">
<code>$success</code>
</InvalidArgument>
</file>
<file src="lib/NoPermissionResponse.php">
<MissingDependency occurrences="1">
<code>Template</code>
</MissingDependency>
</file>
<file src="lib/NotFoundResponse.php">
<MissingDependency occurrences="1">
<code>Template</code>
</MissingDependency>
</file>
<file src="lib/Service/RestrictionService.php">
<InvalidReturnType occurrences="3">
<code>Restriction</code>
<code>Restriction</code>
<code>Restriction</code>
</InvalidReturnType>
</file>
<file src="lib/Service/RoomService.php">
<InvalidReturnType occurrences="1">
<code>Room</code>
</InvalidReturnType>
</file>
<file src="lib/Service/RoomShareService.php">
<InvalidReturnType occurrences="3">
<code>RoomShare</code>
<code>RoomShare</code>
<code>RoomShare</code>
</InvalidReturnType>
</file>
</files>