Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
415 changed files with 7462 additions and 6874 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* RuleGroupRepository.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -61,6 +62,14 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
}
/**
* @return Collection
*/
public function get(): Collection
{
return $this->user->ruleGroups()->orderBy('order', 'ASC')->get();
}
/**
* @return int
*/
@@ -70,8 +79,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param RuleGroup $ruleGroup
* @param RuleGroup|null $moveTo
* @param RuleGroup $ruleGroup
* @param RuleGroup|null $moveTo
*
* @return bool
* @throws Exception
@@ -128,7 +137,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param RuleGroup $ruleGroup
* @param RuleGroup $ruleGroup
*
* @return bool
*/
@@ -142,7 +151,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$count = 1;
/** @var Rule $entry */
foreach ($set as $entry) {
if ((int) $entry->order !== $count) {
if ((int)$entry->order !== $count) {
Log::debug(sprintf('Rule #%d was on spot %d but must be on spot %d', $entry->id, $entry->order, $count));
$entry->order = $count;
$entry->save();
@@ -157,7 +166,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param Rule $rule
* @param Rule $rule
*/
private function resetRuleActionOrder(Rule $rule): void
{
@@ -169,7 +178,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$index = 1;
/** @var RuleAction $action */
foreach ($actions as $action) {
if ((int) $action->order !== $index) {
if ((int)$action->order !== $index) {
$action->order = $index;
$action->save();
Log::debug(sprintf('Rule action #%d was on spot %d but must be on spot %d', $action->id, $action->order, $index));
@@ -179,7 +188,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param Rule $rule
* @param Rule $rule
*/
private function resetRuleTriggerOrder(Rule $rule): void
{
@@ -191,7 +200,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$index = 1;
/** @var RuleTrigger $trigger */
foreach ($triggers as $trigger) {
$order = (int) $trigger->order;
$order = (int)$trigger->order;
if ($order !== $index) {
$trigger->order = $index;
$trigger->save();
@@ -215,15 +224,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @return Collection
*/
public function get(): Collection
{
return $this->user->ruleGroups()->orderBy('order', 'ASC')->get();
}
/**
* @param int $ruleGroupId
* @param int $ruleGroupId
*
* @return RuleGroup|null
*/
@@ -233,7 +234,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param string $title
* @param string $title
*
* @return RuleGroup|null
*/
@@ -251,7 +252,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
@@ -263,7 +264,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
@@ -278,7 +279,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
@@ -293,7 +294,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param string|null $filter
* @param string|null $filter
*
* @return Collection
*/
@@ -351,11 +352,11 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
{
$entry = $this->user->ruleGroups()->max('order');
return (int) $entry;
return (int)$entry;
}
/**
* @param string|null $filter
* @param string|null $filter
*
* @return Collection
*/
@@ -408,7 +409,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
@@ -423,7 +424,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
*/
public function maxOrder(): int
{
return (int) $this->user->ruleGroups()->where('active', true)->max('order');
return (int)$this->user->ruleGroups()->where('active', true)->max('order');
}
/**
@@ -442,7 +443,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user): void
{
@@ -450,7 +451,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param array $data
* @param array $data
*
* @return RuleGroup
*/
@@ -479,7 +480,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
*/
public function setOrder(RuleGroup $ruleGroup, int $newOrder): void
{
$oldOrder = (int) $ruleGroup->order;
$oldOrder = (int)$ruleGroup->order;
if ($newOrder > $oldOrder) {
$this->user->ruleGroups()->where('rule_groups.order', '<=', $newOrder)->where('rule_groups.order', '>', $oldOrder)
@@ -501,8 +502,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
* @param RuleGroup $ruleGroup
* @param array $data
* @param RuleGroup $ruleGroup
* @param array $data
*
* @return RuleGroup
*/
@@ -521,7 +522,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
// order
if (array_key_exists('order', $data) && $ruleGroup->order !== $data['order']) {
$this->resetOrder();
$this->setOrder($ruleGroup, (int) $data['order']);
$this->setOrder($ruleGroup, (int)$data['order']);
}
$ruleGroup->save();

View File

@@ -1,4 +1,5 @@
<?php
/**
* RuleGroupRepositoryInterface.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -42,8 +43,8 @@ interface RuleGroupRepositoryInterface
public function count(): int;
/**
* @param RuleGroup $ruleGroup
* @param RuleGroup|null $moveTo
* @param RuleGroup $ruleGroup
* @param RuleGroup|null $moveTo
*
* @return bool
*/
@@ -55,14 +56,14 @@ interface RuleGroupRepositoryInterface
public function destroyAll(): void;
/**
* @param int $ruleGroupId
* @param int $ruleGroupId
*
* @return RuleGroup|null
*/
public function find(int $ruleGroupId): ?RuleGroup;
/**
* @param string $title
* @param string $title
*
* @return RuleGroup|null
*/
@@ -81,21 +82,21 @@ interface RuleGroupRepositoryInterface
public function getActiveGroups(): Collection;
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
public function getActiveRules(RuleGroup $group): Collection;
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
public function getActiveStoreRules(RuleGroup $group): Collection;
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
@@ -104,7 +105,7 @@ interface RuleGroupRepositoryInterface
/**
* Also inactive groups.
*
* @param string|null $filter
* @param string|null $filter
*
* @return Collection
*/
@@ -116,14 +117,14 @@ interface RuleGroupRepositoryInterface
public function getHighestOrderRuleGroup(): int;
/**
* @param string|null $filter
* @param string|null $filter
*
* @return Collection
*/
public function getRuleGroupsWithRules(?string $filter): Collection;
/**
* @param RuleGroup $group
* @param RuleGroup $group
*
* @return Collection
*/
@@ -142,41 +143,41 @@ interface RuleGroupRepositoryInterface
public function resetOrder(): bool;
/**
* @param RuleGroup $ruleGroup
* @param RuleGroup $ruleGroup
*
* @return bool
*/
public function resetRuleOrder(RuleGroup $ruleGroup): bool;
/**
* @param string $query
* @param int $limit
* @param string $query
* @param int $limit
*
* @return Collection
*/
public function searchRuleGroup(string $query, int $limit): Collection;
/**
* @param RuleGroup $ruleGroup
* @param int $newOrder
* @param RuleGroup $ruleGroup
* @param int $newOrder
*/
public function setOrder(RuleGroup $ruleGroup, int $newOrder): void;
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user);
/**
* @param array $data
* @param array $data
*
* @return RuleGroup
*/
public function store(array $data): RuleGroup;
/**
* @param RuleGroup $ruleGroup
* @param array $data
* @param RuleGroup $ruleGroup
* @param array $data
*
* @return RuleGroup
*/