Skip to content

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed May 12, 2018
1 parent 08d9d51 commit b633d82
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 71 deletions.
3 changes: 1 addition & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use OCP\AppFramework\App;
use OCA\Deck\Middleware\SharingMiddleware;
use OCP\IGroup;

use OCP\IUser;
use OCP\IUserManager;
use OCP\IURLGenerator;
Expand Down Expand Up @@ -114,7 +113,7 @@ public function registerNotifications() {
$self = &$this;
$notificationManager->registerNotifier(function() use (&$self) {
return $self->getContainer()->query(Notifier::class);
}, function () {
}, function() {
return ['id' => 'deck', 'name' => 'Deck'];
});

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/AssignedUsersMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function mapParticipant(AssignedUsers &$assignment) {
$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;
Expand Down
12 changes: 6 additions & 6 deletions lib/Db/BoardMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function findAll() {

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]);
Expand Down Expand Up @@ -181,17 +181,17 @@ public function mapAcl(Acl &$acl) {
$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());
Expand All @@ -208,7 +208,7 @@ public function mapOwner(Board &$board) {
$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;
Expand Down
12 changes: 6 additions & 6 deletions lib/Db/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function setDatabaseType($type) {
}

public function getDuedate($isoFormat = false) {
if($this->duedate === null) {
if ($this->duedate === null) {
return null;
}
$dt = new DateTime($this->duedate);
Expand All @@ -83,16 +83,16 @@ public function jsonSerialize() {
$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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/CardMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function mapOwner(Card &$card) {
$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;
Expand Down
24 changes: 12 additions & 12 deletions lib/Db/RelationalEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -42,7 +42,7 @@ public function addRelation($property) {

/**
* 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;
Expand Down Expand Up @@ -77,7 +77,7 @@ public function jsonSerialize() {
}
}
foreach ($this->_resolvedProperties as $property => $value) {
if($value !== null) {
if ($value !== null) {
$json[$property] = $value;
}
}
Expand Down Expand Up @@ -107,29 +107,29 @@ public function jsonSerialize() {
*/
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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/RelationalObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function jsonSerialize() {
* @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));
Expand Down
2 changes: 1 addition & 1 deletion lib/Middleware/SharingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(ILogger $logger, IConfig $config) {
*/
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([
Expand Down
8 changes: 4 additions & 4 deletions lib/Migration/UnknownUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ public function run(IOutput $output) {
$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);
}
}
Expand Down
9 changes: 6 additions & 3 deletions lib/Notification/NotificationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function sendCardDuedate($card) {
$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()
Expand All @@ -98,7 +98,7 @@ public function sendCardDuedate($card) {
* 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) {
Expand Down Expand Up @@ -128,11 +128,14 @@ private function getBoard($boardId) {
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]);
Expand Down
10 changes: 5 additions & 5 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ public function __construct(
*/
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];
Expand All @@ -102,7 +102,7 @@ public function prepare(INotification $notification, $languageCode) {
]
]
);
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'/');
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/' . $boardId . '/');
break;
}
return $notification;
Expand Down
10 changes: 5 additions & 5 deletions lib/Service/BoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function findAll($userInfo) {
$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);
}
Expand All @@ -96,7 +96,7 @@ public function find($boardId) {
$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);
}
}
Expand Down Expand Up @@ -249,7 +249,7 @@ public function deleteAcl($id) {
$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);
}
}
Expand Down
Loading

0 comments on commit b633d82

Please sign in to comment.