From b633d82c5e9e406a5c2fb51205f4daca2bcebebc Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sat, 12 May 2018 11:10:23 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- lib/AppInfo/Application.php | 3 +-- lib/Db/AssignedUsersMapper.php | 2 +- lib/Db/BoardMapper.php | 12 ++++++------ lib/Db/Card.php | 12 ++++++------ lib/Db/CardMapper.php | 2 +- lib/Db/RelationalEntity.php | 24 ++++++++++++------------ lib/Db/RelationalObject.php | 2 +- lib/Middleware/SharingMiddleware.php | 2 +- lib/Migration/UnknownUsers.php | 8 ++++---- lib/Notification/NotificationHelper.php | 9 ++++++--- lib/Notification/Notifier.php | 10 +++++----- lib/Service/BoardService.php | 10 +++++----- lib/Service/CardService.php | 23 +++++++++++++---------- lib/Service/LabelService.php | 6 +++--- lib/Service/PermissionService.php | 10 +++++----- lib/Service/StackService.php | 9 +++++---- templates/part.board.sidebarView.php | 4 ++-- 17 files changed, 77 insertions(+), 71 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index e8f89e6f7..aac44b52d 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -30,7 +30,6 @@ use OCA\Deck\Notification\Notifier; use OCP\AppFramework\App; use OCA\Deck\Middleware\SharingMiddleware; use OCP\IGroup; - use OCP\IUser; use OCP\IUserManager; use OCP\IURLGenerator; @@ -114,7 +113,7 @@ class Application extends App { $self = &$this; $notificationManager->registerNotifier(function() use (&$self) { return $self->getContainer()->query(Notifier::class); - }, function () { + }, function() { return ['id' => 'deck', 'name' => 'Deck']; }); diff --git a/lib/Db/AssignedUsersMapper.php b/lib/Db/AssignedUsersMapper.php index 5edab10d0..e9323811f 100644 --- a/lib/Db/AssignedUsersMapper.php +++ b/lib/Db/AssignedUsersMapper.php @@ -86,7 +86,7 @@ class AssignedUsersMapper extends DeckMapper implements IPermissionMapper { $userManager = $this->userManager; $assignment->resolveRelation('participant', function() use (&$userManager, &$assignment) { $user = $userManager->get($assignment->getParticipant()); - if($user !== null) { + if ($user !== null) { return new User($user); } return null; diff --git a/lib/Db/BoardMapper.php b/lib/Db/BoardMapper.php index 77f5c6b8a..594c9b8ce 100644 --- a/lib/Db/BoardMapper.php +++ b/lib/Db/BoardMapper.php @@ -140,7 +140,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper { public function findToDelete() { // add buffer of 5 min - $timeLimit = time()-(60*5); + $timeLimit = time() - (60 * 5); $sql = 'SELECT id, title, owner, color, archived, deleted_at FROM `*PREFIX*deck_boards` ' . 'WHERE `deleted_at` > 0 AND `deleted_at` < ?'; return $this->findEntities($sql, [$timeLimit]); @@ -181,17 +181,17 @@ class BoardMapper extends DeckMapper implements IPermissionMapper { $userManager = $this->userManager; $groupManager = $this->groupManager; $acl->resolveRelation('participant', function($participant) use (&$acl, &$userManager, &$groupManager) { - if($acl->getType() === Acl::PERMISSION_TYPE_USER) { + if ($acl->getType() === Acl::PERMISSION_TYPE_USER) { $user = $userManager->get($participant); - if($user !== null) { + if ($user !== null) { return new User($user); } \OC::$server->getLogger()->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant()); return null; } - if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { + if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { $group = $groupManager->get($participant); - if($group !== null) { + if ($group !== null) { return new Group($group); } \OC::$server->getLogger()->debug('Group ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant()); @@ -208,7 +208,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper { $userManager = $this->userManager; $board->resolveRelation('owner', function($owner) use (&$userManager) { $user = $userManager->get($owner); - if($user !== null) { + if ($user !== null) { return new User($user); } return null; diff --git a/lib/Db/Card.php b/lib/Db/Card.php index 63b7b64e1..d2c3aee28 100644 --- a/lib/Db/Card.php +++ b/lib/Db/Card.php @@ -67,7 +67,7 @@ class Card extends RelationalEntity { } public function getDuedate($isoFormat = false) { - if($this->duedate === null) { + if ($this->duedate === null) { return null; } $dt = new DateTime($this->duedate); @@ -83,16 +83,16 @@ class Card extends RelationalEntity { $due = strtotime($this->duedate); $today = new DateTime(); - $today->setTime( 0, 0); + $today->setTime(0, 0); $match_date = new DateTime($this->duedate); - $match_date->setTime( 0, 0); + $match_date->setTime(0, 0); - $diff = $today->diff( $match_date ); - $diffDays = (integer)$diff->format('%R%a'); // Extract days count in interval + $diff = $today->diff($match_date); + $diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval - if($due !== false) { + if ($due !== false) { if ($diffDays === 1) { $json['overdue'] = self::DUEDATE_NEXT; } diff --git a/lib/Db/CardMapper.php b/lib/Db/CardMapper.php index a59e6929c..7c5e78462 100644 --- a/lib/Db/CardMapper.php +++ b/lib/Db/CardMapper.php @@ -178,7 +178,7 @@ class CardMapper extends DeckMapper implements IPermissionMapper { $userManager = $this->userManager; $card->resolveRelation('owner', function($owner) use (&$userManager) { $user = $userManager->get($owner); - if($user !== null) { + if ($user !== null) { return new User($user); } return null; diff --git a/lib/Db/RelationalEntity.php b/lib/Db/RelationalEntity.php index 188a36897..e5773f48b 100644 --- a/lib/Db/RelationalEntity.php +++ b/lib/Db/RelationalEntity.php @@ -32,7 +32,7 @@ class RelationalEntity extends Entity implements \JsonSerializable { /** * Mark a property as relation so it will not get updated using Mapper::update - * @param $property string Name of the property + * @param string $property string Name of the property */ public function addRelation($property) { if (!in_array($property, $this->_relations, true)) { @@ -42,7 +42,7 @@ class RelationalEntity extends Entity implements \JsonSerializable { /** * Mark a property as resolvable via resolveRelation() - * @param $property string Name of the property + * @param string $property string Name of the property */ public function addResolvable($property) { $this->_resolvedProperties[$property] = null; @@ -77,7 +77,7 @@ class RelationalEntity extends Entity implements \JsonSerializable { } } foreach ($this->_resolvedProperties as $property => $value) { - if($value !== null) { + if ($value !== null) { $json[$property] = $value; } } @@ -107,29 +107,29 @@ class RelationalEntity extends Entity implements \JsonSerializable { */ public function resolveRelation($property, $resolver) { $result = null; - if($property !== null && $this->$property !== null) { + if ($property !== null && $this->$property !== null) { $result = $resolver($this->$property); } - if($result instanceof RelationalObject || $result === null) { + if ($result instanceof RelationalObject || $result === null) { $this->_resolvedProperties[$property] = $result; } else { throw new \Exception('resolver must return an instance of RelationalObject'); } } - public function __call($methodName, $args){ - $attr = lcfirst( substr($methodName, 7) ); - if(array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'resolve') === 0) { - if($this->_resolvedProperties[$attr] !== null) { + public function __call($methodName, $args) { + $attr = lcfirst(substr($methodName, 7)); + if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'resolve') === 0) { + if ($this->_resolvedProperties[$attr] !== null) { return $this->_resolvedProperties[$attr]; } return $this->getter($attr); } - $attr = lcfirst( substr($methodName, 3) ); - if(array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'set') === 0) { - if(!is_scalar($args[0])) { + $attr = lcfirst(substr($methodName, 3)); + if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'set') === 0) { + if (!is_scalar($args[0])) { $args[0] = $args[0]['primaryKey']; } parent::setter($attr, $args); diff --git a/lib/Db/RelationalObject.php b/lib/Db/RelationalObject.php index 7b7291964..1bc21c8bd 100644 --- a/lib/Db/RelationalObject.php +++ b/lib/Db/RelationalObject.php @@ -52,7 +52,7 @@ class RelationalObject implements \JsonSerializable { * @throws \Exception */ public function getObjectSerialization() { - if($this->object instanceof \JsonSerializable) { + if ($this->object instanceof \JsonSerializable) { $this->object->jsonSerialize(); } else { throw new \Exception('jsonSerialize is not implemented on ' . get_class($this)); diff --git a/lib/Middleware/SharingMiddleware.php b/lib/Middleware/SharingMiddleware.php index 496ee0a57..13fed3cb9 100644 --- a/lib/Middleware/SharingMiddleware.php +++ b/lib/Middleware/SharingMiddleware.php @@ -60,7 +60,7 @@ class SharingMiddleware extends Middleware { */ public function afterException($controller, $methodName, \Exception $exception) { if ($exception instanceof StatusException) { - if($this->config->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { + if ($this->config->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { $this->logger->logException($exception); } return new JSONResponse([ diff --git a/lib/Migration/UnknownUsers.php b/lib/Migration/UnknownUsers.php index 7298d9e98..ae3694a05 100644 --- a/lib/Migration/UnknownUsers.php +++ b/lib/Migration/UnknownUsers.php @@ -64,15 +64,15 @@ class UnknownUsers implements IRepairStep { $acls = $this->aclMapper->findAll($board->getId()); /** @var Acl $acl */ foreach ($acls as $acl) { - if($acl->getType() === Acl::PERMISSION_TYPE_USER) { + if ($acl->getType() === Acl::PERMISSION_TYPE_USER) { $user = $this->userManager->get($acl->getParticipant()); - if($user === null) { + if ($user === null) { $this->aclMapper->delete($acl); } } - if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { + if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { $group = $this->groupManager->get($acl->getParticipant()); - if($group === null) { + if ($group === null) { $this->aclMapper->delete($acl); } } diff --git a/lib/Notification/NotificationHelper.php b/lib/Notification/NotificationHelper.php index 150c44623..b2d0a9aa9 100644 --- a/lib/Notification/NotificationHelper.php +++ b/lib/Notification/NotificationHelper.php @@ -83,7 +83,7 @@ class NotificationHelper { $notification = $this->notificationManager->createNotification(); $notification ->setApp('deck') - ->setUser((string)$user->getUID()) + ->setUser((string) $user->getUID()) ->setObject('card', $card->getId()) ->setSubject('card-overdue', [ $card->getTitle(), $board->getTitle() @@ -98,7 +98,7 @@ class NotificationHelper { * Send notifications that a board was shared with a user/group * * @param $boardId - * @param $acl + * @param Acl $acl * @throws \InvalidArgumentException */ public function sendBoardShared($boardId, $acl) { @@ -128,11 +128,14 @@ class NotificationHelper { return $this->boards[$boardId]; } + /** + * @param Board $board + */ private function generateBoardShared($board, $userId) { $notification = $this->notificationManager->createNotification(); $notification ->setApp('deck') - ->setUser((string)$userId) + ->setUser((string) $userId) ->setDateTime(new DateTime()) ->setObject('board', $board->getId()) ->setSubject('board-shared', [$board->getTitle(), $this->currentUser]); diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 6976f2c05..1049a8201 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -66,25 +66,25 @@ class Notifier implements INotifier { */ public function prepare(INotification $notification, $languageCode) { $l = $this->l10nFactory->get('deck', $languageCode); - if($notification->getApp() !== 'deck') { + if ($notification->getApp() !== 'deck') { throw new \InvalidArgumentException(); } $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('deck', 'deck-dark.svg'))); $params = $notification->getSubjectParameters(); - switch($notification->getSubject()) { + switch ($notification->getSubject()) { case 'card-overdue': $cardId = $notification->getObjectId(); $boardId = $this->cardMapper->findBoardId($cardId); $notification->setParsedSubject( (string) $l->t('The card "%s" on "%s" has reached its due date.', $params) ); - $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'//card/'.$cardId.''); + $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/' . $boardId . '//card/' . $cardId . ''); break; case 'board-shared': $boardId = $notification->getObjectId(); $initiator = $this->userManager->get($params[1]); - if($initiator !== null) { + if ($initiator !== null) { $dn = $initiator->getDisplayName(); } else { $dn = $params[1]; @@ -102,7 +102,7 @@ class Notifier implements INotifier { ] ] ); - $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'/'); + $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/' . $boardId . '/'); break; } return $notification; diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index 36be5c341..3f9a905cc 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -69,10 +69,10 @@ class BoardService { $groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups']); $complete = array_merge($userBoards, $groupBoards); $result = []; - foreach($complete as &$item) { - if(!array_key_exists($item->getId(), $result)) { + foreach ($complete as &$item) { + if (!array_key_exists($item->getId(), $result)) { $this->boardMapper->mapOwner($item); - if($item->getAcl() !== null) { + if ($item->getAcl() !== null) { foreach ($item->getAcl() as &$acl) { $this->boardMapper->mapAcl($acl); } @@ -96,7 +96,7 @@ class BoardService { $board = $this->boardMapper->find($boardId, true, true); $this->boardMapper->mapOwner($board); foreach ($board->getAcl() as &$acl) { - if($acl !== null) { + if ($acl !== null) { $this->boardMapper->mapAcl($acl); } } @@ -249,7 +249,7 @@ class BoardService { $this->boardMapper->mapAcl($acl); if ($acl->getType() === Acl::PERMISSION_TYPE_USER) { $assignements = $this->assignedUsersMapper->findByUserId($acl->getParticipant()); - foreach($assignements as $assignement) { + foreach ($assignements as $assignement) { $this->assignedUsersMapper->delete($assignement); } } diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index f01ddaa32..5376f2474 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -57,9 +57,12 @@ class CardService { return $card; } + /** + * @param integer $order + */ public function create($title, $stackId, $type, $order, $owner) { $this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->stackMapper, $stackId)) { + if ($this->boardService->isArchived($this->stackMapper, $stackId)) { throw new StatusException('Operation not allowed. This board is archived.'); } $card = new Card(); @@ -74,7 +77,7 @@ class CardService { public function delete($id) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $id)) { + if ($this->boardService->isArchived($this->cardMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } return $this->cardMapper->delete($this->cardMapper->find($id)); @@ -82,7 +85,7 @@ class CardService { public function update($id, $title, $stackId, $type, $order, $description, $owner, $duedate) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $id)) { + if ($this->boardService->isArchived($this->cardMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } $card = $this->cardMapper->find($id); @@ -101,7 +104,7 @@ class CardService { public function rename($id, $title) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $id)) { + if ($this->boardService->isArchived($this->cardMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } $card = $this->cardMapper->find($id); @@ -114,7 +117,7 @@ class CardService { public function reorder($id, $stackId, $order) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $id)) { + if ($this->boardService->isArchived($this->cardMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } $cards = $this->cardMapper->findAll($stackId); @@ -145,7 +148,7 @@ class CardService { public function archive($id) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $id)) { + if ($this->boardService->isArchived($this->cardMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } $card = $this->cardMapper->find($id); @@ -155,7 +158,7 @@ class CardService { public function unarchive($id) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $id)) { + if ($this->boardService->isArchived($this->cardMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } $card = $this->cardMapper->find($id); @@ -165,7 +168,7 @@ class CardService { public function assignLabel($cardId, $labelId) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $cardId)) { + if ($this->boardService->isArchived($this->cardMapper, $cardId)) { throw new StatusException('Operation not allowed. This board is archived.'); } $card = $this->cardMapper->find($cardId); @@ -177,7 +180,7 @@ class CardService { public function removeLabel($cardId, $labelId) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); - if($this->boardService->isArchived($this->cardMapper, $cardId)) { + if ($this->boardService->isArchived($this->cardMapper, $cardId)) { throw new StatusException('Operation not allowed. This board is archived.'); } $card = $this->cardMapper->find($cardId); @@ -194,7 +197,7 @@ class CardService { return false; } } - $assignment = new AssignedUsers(); + $assignment = new AssignedUsers(); $assignment->setCardId($cardId); $assignment->setParticipant($userId); return $this->assignedUsersMapper->insert($assignment); diff --git a/lib/Service/LabelService.php b/lib/Service/LabelService.php index 5562a60ca..2bb910083 100644 --- a/lib/Service/LabelService.php +++ b/lib/Service/LabelService.php @@ -51,7 +51,7 @@ class LabelService { public function create($title, $color, $boardId) { $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); - if($this->boardService->isArchived(null, $boardId)) { + if ($this->boardService->isArchived(null, $boardId)) { throw new StatusException('Operation not allowed. This board is archived.'); } $label = new Label(); @@ -63,7 +63,7 @@ class LabelService { public function delete($id) { $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE); - if($this->boardService->isArchived($this->labelMapper, $id)) { + if ($this->boardService->isArchived($this->labelMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } return $this->labelMapper->delete($this->find($id)); @@ -71,7 +71,7 @@ class LabelService { public function update($id, $title, $color) { $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE); - if($this->boardService->isArchived($this->labelMapper, $id)) { + if ($this->boardService->isArchived($this->labelMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } $label = $this->find($id); diff --git a/lib/Service/PermissionService.php b/lib/Service/PermissionService.php index f32748356..8b7e69d12 100644 --- a/lib/Service/PermissionService.php +++ b/lib/Service/PermissionService.php @@ -185,8 +185,8 @@ class PermissionService { */ public function findUsers($boardId) { // cache users of a board so we don't query them for every cards - if (array_key_exists((string)$boardId, $this->users)) { - return $this->users[(string)$boardId]; + if (array_key_exists((string) $boardId, $this->users)) { + return $this->users[(string) $boardId]; } try { $board = $this->boardMapper->find($boardId); @@ -203,14 +203,14 @@ class PermissionService { $user = $this->userManager->get($acl->getParticipant()); $users[$user->getUID()] = new User($user); } - if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { + if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { $group = $this->groupManager->get($acl->getParticipant()); foreach ($group->getUsers() as $user) { $users[$user->getUID()] = new User($user); } } } - $this->users[(string)$boardId] = $users; - return $this->users[(string)$boardId]; + $this->users[(string) $boardId] = $users; + return $this->users[(string) $boardId]; } } \ No newline at end of file diff --git a/lib/Service/StackService.php b/lib/Service/StackService.php index 2e8155068..598a5731c 100644 --- a/lib/Service/StackService.php +++ b/lib/Service/StackService.php @@ -27,9 +27,7 @@ use OCA\Deck\Db\Acl; use OCA\Deck\Db\CardMapper; use OCA\Deck\Db\LabelMapper; use OCA\Deck\Db\AssignedUsersMapper; - use OCA\Deck\Db\Stack; - use OCA\Deck\Db\StackMapper; use OCA\Deck\StatusException; @@ -93,9 +91,12 @@ class StackService { return $stacks; } + /** + * @param integer $order + */ public function create($title, $boardId, $order) { $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); - if($this->boardService->isArchived(null, $boardId)) { + if ($this->boardService->isArchived(null, $boardId)) { throw new StatusException('Operation not allowed. This board is archived.'); } $stack = new Stack(); @@ -113,7 +114,7 @@ class StackService { public function update($id, $title, $boardId, $order) { $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE); - if($this->boardService->isArchived($this->stackMapper, $id)) { + if ($this->boardService->isArchived($this->stackMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.'); } $stack = $this->stackMapper->find($id); diff --git a/templates/part.board.sidebarView.php b/templates/part.board.sidebarView.php index 45c2d394c..88ce3de6d 100644 --- a/templates/part.board.sidebarView.php +++ b/templates/part.board.sidebarView.php @@ -6,8 +6,8 @@