Fix php cs issues

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-04-22 19:57:19 +02:00
parent 7ad5daabeb
commit 52febb396c
130 changed files with 1068 additions and 1424 deletions

View File

@@ -23,7 +23,6 @@
namespace OCA\Deck\Service;
use OCA\Deck\Activity\ActivityManager;
use OCA\Deck\BadRequestException;
use OCA\Deck\Db\Acl;
@@ -40,8 +39,6 @@ use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\EventDispatcher\IEventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class AssignmentService {
@@ -110,7 +107,6 @@ class AssignmentService {
* @throws DoesNotExistException
*/
public function assignUser($cardId, $userId, int $type = AssignedUsers::TYPE_USER) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}

View File

@@ -23,7 +23,6 @@
namespace OCA\Deck\Service;
use OCA\Deck\Activity\ActivityManager;
use OCA\Deck\AppInfo\Application;
use OCA\Deck\BadRequestException;
@@ -42,7 +41,6 @@ use OCP\ICacheFactory;
use OCP\IL10N;
class AttachmentService {
private $attachmentMapper;
private $cardMapper;
private $permissionService;
@@ -116,7 +114,6 @@ class AttachmentService {
* @throws BadRequestException
*/
public function findAll($cardId, $withDeleted = false) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -144,7 +141,6 @@ class AttachmentService {
* @throws BadRequestException
*/
public function count($cardId) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -167,7 +163,6 @@ class AttachmentService {
* @throws BadRequestException
*/
public function create($cardId, $type, $data) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -228,7 +223,6 @@ class AttachmentService {
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
*/
public function display($cardId, $attachmentId) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -261,7 +255,6 @@ class AttachmentService {
* @throws BadRequestException
*/
public function update($cardId, $attachmentId, $data) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -312,7 +305,6 @@ class AttachmentService {
* @throws BadRequestException
*/
public function delete($cardId, $attachmentId) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -343,7 +335,6 @@ class AttachmentService {
}
public function restore($cardId, $attachmentId) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}

View File

@@ -26,7 +26,6 @@ namespace OCA\Deck\Service;
use OCA\Deck\Activity\ActivityManager;
use OCA\Deck\Activity\ChangeSet;
use OCA\Deck\Collaboration\Resources\ResourceProvider;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\AclMapper;
use OCA\Deck\Db\AssignedUsersMapper;
@@ -48,9 +47,7 @@ use OCA\Deck\BadRequestException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class BoardService {
private $boardMapper;
private $stackMapper;
private $labelMapper;
@@ -154,8 +151,7 @@ class BoardService {
* @throws BadRequestException
*/
public function find($boardId) {
if ( is_numeric($boardId) === false ) {
if (is_numeric($boardId) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -202,8 +198,7 @@ class BoardService {
* @throws BadRequestException
*/
public function isArchived($mapper, $id) {
if (is_numeric($id) === false) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -232,12 +227,11 @@ class BoardService {
* @throws BadRequestException
*/
public function isDeleted($mapper, $id) {
if ($mapper === false || $mapper === null) {
throw new BadRequestException('mapper must be provided');
}
if (is_numeric($id) === false) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -265,7 +259,6 @@ class BoardService {
* @throws BadRequestException
*/
public function create($title, $userId, $color) {
if ($title === false || $title === null) {
throw new BadRequestException('title must be provided');
}
@@ -334,7 +327,6 @@ class BoardService {
* @throws BadRequestException
*/
public function delete($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -364,7 +356,6 @@ class BoardService {
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
*/
public function deleteUndo($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -392,7 +383,7 @@ class BoardService {
* @throws BadRequestException
*/
public function deleteForce($id) {
if (is_numeric($id) === false) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -419,7 +410,6 @@ class BoardService {
* @throws BadRequestException
*/
public function update($id, $title, $color, $archived) {
if (is_numeric($id) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -432,7 +422,7 @@ class BoardService {
throw new BadRequestException('color must be provided');
}
if ( is_bool($archived) === false ) {
if (is_bool($archived) === false) {
throw new BadRequestException('archived must be a boolean');
}
@@ -479,7 +469,6 @@ class BoardService {
* @throws \OCA\Deck\NoPermissionException
*/
public function addAcl($boardId, $type, $participant, $edit, $share, $manage) {
if (is_numeric($boardId) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -529,7 +518,8 @@ class BoardService {
try {
$resourceProvider = \OC::$server->query(\OCA\Deck\Collaboration\Resources\ResourceProvider::class);
$resourceProvider->invalidateAccessCache($boardId);
} catch (\Exception $e) {}
} catch (\Exception $e) {
}
}
$this->eventDispatcher->dispatch(
@@ -551,7 +541,6 @@ class BoardService {
* @throws BadRequestException
*/
public function updateAcl($id, $edit, $share, $manage) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -596,7 +585,6 @@ class BoardService {
* @throws BadRequestException
*/
public function deleteAcl($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -619,7 +607,8 @@ class BoardService {
try {
$resourceProvider = \OC::$server->query(\OCA\Deck\Collaboration\Resources\ResourceProvider::class);
$resourceProvider->invalidateAccessCache($acl->getBoardId());
} catch (\Exception $e) {}
} catch (\Exception $e) {
}
}
$delete = $this->aclMapper->delete($acl);
@@ -639,7 +628,6 @@ class BoardService {
* @throws BadRequestException
*/
public function clone($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -683,7 +671,7 @@ class BoardService {
private function enrichWithStacks($board, $since = -1) {
$stacks = $this->stackMapper->findAll($board->getId(), null, null, $since);
if(\count($stacks) === 0) {
if (\count($stacks) === 0) {
return;
}
@@ -693,7 +681,7 @@ class BoardService {
private function enrichWithLabels($board, $since = -1) {
$labels = $this->labelMapper->findAll($board->getId(), null, null, $since);
if(\count($labels) === 0) {
if (\count($labels) === 0) {
return;
}
@@ -702,10 +690,9 @@ class BoardService {
private function enrichWithUsers($board, $since = -1) {
$boardUsers = $this->permissionService->findUsers($board->getId());
if(\count($boardUsers) === 0) {
if (\count($boardUsers) === 0) {
return;
}
$board->setUsers(array_values($boardUsers));
}
}

View File

@@ -28,7 +28,6 @@ namespace OCA\Deck\Service;
use OCA\Deck\Activity\ActivityManager;
use OCA\Deck\Activity\ChangeSet;
use OCA\Deck\Db\AssignedUsers;
use OCA\Deck\Db\AssignedUsersMapper;
use OCA\Deck\Db\Card;
use OCA\Deck\Db\CardMapper;
@@ -39,19 +38,13 @@ use OCA\Deck\Event\FTSEvent;
use OCA\Deck\Notification\NotificationHelper;
use OCA\Deck\Db\BoardMapper;
use OCA\Deck\Db\LabelMapper;
use OCA\Deck\NotFoundException;
use OCA\Deck\StatusException;
use OCA\Deck\BadRequestException;
use OCP\Activity\IEvent;
use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUserManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class CardService {
private $cardMapper;
private $stackMapper;
private $boardMapper;
@@ -132,7 +125,6 @@ class CardService {
* @throws BadRequestException
*/
public function find($cardId) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -218,7 +210,6 @@ class CardService {
* @throws BadRequestException
*/
public function delete($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -257,7 +248,6 @@ class CardService {
* @throws BadRequestException
*/
public function update($id, $title, $stackId, $type, $order = 0, $description = '', $owner, $duedate = null, $deletedAt = null, $archived = null) {
if (is_numeric($id) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -347,7 +337,6 @@ class CardService {
* @throws BadRequestException
*/
public function rename($id, $title) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -387,7 +376,6 @@ class CardService {
* @throws BadRequestException
*/
public function reorder($id, $stackId, $order) {
if (is_numeric($id) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -448,7 +436,6 @@ class CardService {
* @throws BadRequestException
*/
public function archive($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -481,7 +468,6 @@ class CardService {
* @throws BadRequestException
*/
public function unarchive($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('id must be a number');
}
@@ -513,7 +499,6 @@ class CardService {
* @throws BadRequestException
*/
public function assignLabel($cardId, $labelId) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -550,7 +535,6 @@ class CardService {
* @throws BadRequestException
*/
public function removeLabel($cardId, $labelId) {
if (is_numeric($cardId) === false) {
throw new BadRequestException('card id must be a number');
}
@@ -576,5 +560,4 @@ class CardService {
'\OCA\Deck\Card::onUpdate', new FTSEvent(null, ['id' => $cardId, 'card' => $card])
);
}
}

View File

@@ -23,14 +23,12 @@
namespace OCA\Deck\Service;
use OCA\Deck\AppInfo\Application;
use OCA\Deck\BadRequestException;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\NoPermissionException;
use OCA\Deck\NotFoundException;
use OCA\Deck\StatusException;
use OCP\AppFramework\Http\DataResponse;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
@@ -39,7 +37,6 @@ use OCP\Comments\NotFoundException as CommentNotFoundException;
use OCP\ILogger;
use OCP\IUserManager;
use OutOfBoundsException;
use Sabre\DAV\Exception\Forbidden;
use function is_numeric;
class CommentService {
@@ -125,7 +122,6 @@ class CommentService {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
try {
$comment = $this->commentsManager->get($commentId);
} catch (CommentNotFoundException $e) {
throw new NotFoundException('No comment found.');
}
@@ -147,7 +143,6 @@ class CommentService {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
try {
$comment = $this->commentsManager->get($commentId);
} catch (CommentNotFoundException $e) {
throw new NotFoundException('No comment found.');
}
@@ -170,7 +165,7 @@ class CommentService {
'actorType' => $comment->getActorType(),
'actorDisplayName' => $actorDisplayName,
'creationDateTime' => $comment->getCreationDateTime()->format(\DateTime::ATOM),
'mentions' => array_map(function($mention) {
'mentions' => array_map(function ($mention) {
try {
$displayName = $this->commentsManager->resolveDisplayName($mention['type'], $mention['id']);
} catch (OutOfBoundsException $e) {
@@ -187,5 +182,4 @@ class CommentService {
}, $comment->getMentions()),
];
}
}

View File

@@ -31,7 +31,6 @@ use OCA\Deck\BadRequestException;
use OCP\PreConditionNotMetException;
class DefaultBoardService {
private $boardMapper;
private $boardService;
private $stackService;
@@ -39,7 +38,7 @@ class DefaultBoardService {
private $config;
private $l10n;
public function __construct(
public function __construct(
IL10N $l10n,
BoardMapper $boardMapper,
BoardService $boardService,
@@ -47,14 +46,13 @@ class DefaultBoardService {
CardService $cardService,
IConfig $config
) {
$this->boardService = $boardService;
$this->stackService = $stackService;
$this->cardService = $cardService;
$this->config = $config;
$this->boardMapper = $boardMapper;
$this->l10n = $l10n;
}
}
/**
* Return true if this is the first time a user is acessing their instance with deck enabled
@@ -76,7 +74,7 @@ class DefaultBoardService {
}
return false;
}
}
/**
* @param $title
@@ -90,7 +88,6 @@ class DefaultBoardService {
* @throws BadRequestException
*/
public function createDefaultBoard(string $title, string $userId, string $color) {
if ($title === false || $title === null) {
throw new BadRequestException('title must be provided');
}
@@ -103,9 +100,9 @@ class DefaultBoardService {
throw new BadRequestException('color must be provided');
}
$defaultBoard = $this->boardService->create($title, $userId, $color);
$defaultStacks = [];
$defaultCards = [];
$defaultBoard = $this->boardService->create($title, $userId, $color);
$defaultStacks = [];
$defaultCards = [];
$boardId = $defaultBoard->getId();
@@ -118,5 +115,5 @@ class DefaultBoardService {
$defaultCards[] = $this->cardService->create($this->l10n->t('Example Task 1'), $defaultStacks[2]->getId(), 'text', 0, $userId);
return $defaultBoard;
}
}
}

View File

@@ -23,17 +23,13 @@
namespace OCA\Deck\Service;
use OC\Security\CSP\ContentSecurityPolicyManager;
use OCA\Deck\Db\Attachment;
use OCA\Deck\Db\AttachmentMapper;
use OCA\Deck\StatusException;
use OCA\Deck\Exceptions\ConflictException;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\StreamResponse;
use OCP\Files\Cache\IScanner;
use OCP\Files\Folder;
use OCP\Files\IAppData;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
@@ -45,9 +41,7 @@ use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
class FileService implements IAttachmentService {
private $l10n;
private $appData;
private $request;
@@ -122,18 +116,18 @@ class FileService implements IAttachmentService {
* @return array
* @throws StatusException
*/
private function getUploadedFile () {
private function getUploadedFile() {
$file = $this->request->getUploadedFile('file');
$error = null;
$phpFileUploadErrors = [
UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'),
UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'),
UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'),
UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'),
UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'),
UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'),
UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'),
UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'),
];
if (empty($file)) {
@@ -271,4 +265,4 @@ class FileService implements IAttachmentService {
public function markAsDeleted(Attachment $attachment) {
$attachment->setDeletedAt(time());
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
@@ -28,7 +29,6 @@ declare(strict_types=1);
namespace OCA\Deck\Service;
use OC\FullTextSearch\Model\DocumentAccess;
use OC\FullTextSearch\Model\IndexDocument;
use OCA\Deck\Db\Board;
@@ -47,7 +47,6 @@ use OCP\FullTextSearch\Model\IDocumentAccess;
use OCP\FullTextSearch\Model\IIndex;
use OCP\FullTextSearch\Model\IIndexDocument;
/**
* Class FullTextSearchService
*
@@ -142,7 +141,7 @@ class FullTextSearchService {
$boardId = (int)$e->getArgument('boardId');
$cards = array_map(
function(Card $item) {
function (Card $item) {
return $item->getId();
},
$this->getCardsFromBoard($boardId)
@@ -266,7 +265,6 @@ class FullTextSearchService {
*/
private function getStacksFromBoard(int $boardId): array {
return $this->stackMapper->findAll($boardId, null, null);
}
@@ -278,7 +276,4 @@ class FullTextSearchService {
private function getBoardsFromUser(string $userId): array {
return $this->boardMapper->findAllByUser($userId, null, null, -1);
}
}

View File

@@ -23,7 +23,6 @@
namespace OCA\Deck\Service;
use OCA\Deck\Db\Attachment;
use OCP\AppFramework\Http\Response;
@@ -95,5 +94,4 @@ interface IAttachmentService {
* @param Attachment $attachment
*/
public function markAsDeleted(Attachment $attachment);
}
}

View File

@@ -30,7 +30,6 @@ use OCA\Deck\Db\LabelMapper;
use OCA\Deck\StatusException;
use OCA\Deck\BadRequestException;
class LabelService {
/** @var LabelMapper */
@@ -77,7 +76,6 @@ class LabelService {
* @throws BadRequestException
*/
public function create($title, $color, $boardId) {
if ($title === false || $title === null) {
throw new BadRequestException('title must be provided');
}
@@ -94,7 +92,7 @@ class LabelService {
$boardLabels = $this->labelMapper->findAll($boardId);
if (\is_array($boardLabels)) {
foreach($boardLabels as $boardLabel) {
foreach ($boardLabels as $boardLabel) {
if ($boardLabel->getTitle() === $title) {
throw new BadRequestException('title must be unique');
break;
@@ -123,7 +121,6 @@ class LabelService {
* @throws BadRequestException
*/
public function delete($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('label id must be a number');
}
@@ -149,7 +146,6 @@ class LabelService {
* @throws BadRequestException
*/
public function update($id, $title, $color) {
if (is_numeric($id) === false) {
throw new BadRequestException('label id must be a number');
}
@@ -168,7 +164,7 @@ class LabelService {
$boardLabels = $this->labelMapper->findAll($label->getBoardId());
if (\is_array($boardLabels)) {
foreach($boardLabels as $boardLabel) {
foreach ($boardLabels as $boardLabel) {
if ($boardLabel->getId() === $label->getId()) {
continue;
}
@@ -188,5 +184,4 @@ class LabelService {
$this->changeHelper->boardChanged($label->getBoardId());
return $this->labelMapper->update($label);
}
}

View File

@@ -33,14 +33,12 @@ use OCA\Deck\NoPermissionException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\QueryException;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IUserManager;
use OCP\Share\IManager;
class PermissionService {
/** @var BoardMapper */

View File

@@ -39,9 +39,7 @@ use OCA\Deck\StatusException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class StackService {
private $stackMapper;
private $cardMapper;
private $boardMapper;
@@ -166,7 +164,6 @@ class StackService {
* @throws BadRequestException
*/
public function findAllArchived($boardId) {
if (is_numeric($boardId) === false) {
throw new BadRequestException('board id must be a number');
}
@@ -200,7 +197,6 @@ class StackService {
* @throws BadRequestException
*/
public function create($title, $boardId, $order) {
if ($title === false || $title === null) {
throw new BadRequestException('title must be provided');
}
@@ -245,7 +241,6 @@ class StackService {
* @throws BadRequestException
*/
public function delete($id) {
if (is_numeric($id) === false) {
throw new BadRequestException('stack id must be a number');
}
@@ -284,7 +279,6 @@ class StackService {
* @throws BadRequestException
*/
public function update($id, $title, $boardId, $order, $deletedAt) {
if (is_numeric($id) === false) {
throw new BadRequestException('stack id must be a number');
}
@@ -336,7 +330,6 @@ class StackService {
* @throws BadRequestException
*/
public function reorder($id, $order) {
if (is_numeric($id) === false) {
throw new BadRquestException('id must be a number');
}