Fix code quality with rector [skip ci]

This commit is contained in:
James Cole
2025-11-09 09:08:03 +01:00
parent d2610be790
commit 68183a0a0e
209 changed files with 1021 additions and 1248 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Binder;
use Illuminate\Support\Facades\Log;
use FireflyIII\Enums\AccountTypeEnum;
use Illuminate\Routing\Route;
use Illuminate\Support\Collection;
@@ -50,7 +51,7 @@ class AccountList implements BinderInterface
;
}
if ('allAssetAccounts' !== $value) {
$incoming = array_map('\intval', explode(',', $value));
$incoming = array_map(\intval(...), explode(',', $value));
$list = array_merge(array_unique($incoming), [0]);
/** @var Collection $collection */
@@ -66,7 +67,7 @@ class AccountList implements BinderInterface
return $collection;
}
}
app('log')->error(sprintf('Trying to show account list (%s), but user is not logged in or list is empty.', $route->uri));
Log::error(sprintf('Trying to show account list (%s), but user is not logged in or list is empty.', $route->uri));
throw new NotFoundHttpException();
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Binder;
use Illuminate\Support\Facades\Log;
use FireflyIII\Models\Budget;
use Illuminate\Routing\Route;
use Illuminate\Support\Collection;
@@ -47,10 +48,10 @@ class BudgetList implements BinderInterface
;
}
$list = array_unique(array_map('\intval', explode(',', $value)));
$list = array_unique(array_map(\intval(...), explode(',', $value)));
if (0 === count($list)) { // @phpstan-ignore-line
app('log')->warning('Budget list count is zero, return 404.');
Log::warning('Budget list count is zero, return 404.');
throw new NotFoundHttpException();
}
@@ -71,7 +72,7 @@ class BudgetList implements BinderInterface
return $collection;
}
}
app('log')->warning('BudgetList fallback to 404.');
Log::warning('BudgetList fallback to 404.');
throw new NotFoundHttpException();
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Binder;
use Illuminate\Support\Facades\Log;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Routing\Route;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -33,10 +34,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class CLIToken implements BinderInterface
{
/**
* @return mixed
*/
public static function routeBinder(string $value, Route $route)
public static function routeBinder(string $value, Route $route): string
{
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
@@ -50,12 +48,12 @@ class CLIToken implements BinderInterface
foreach ($users as $user) {
$accessToken = app('preferences')->getForUser($user, 'access_token');
if (null !== $accessToken && $accessToken->data === $value) {
app('log')->info(sprintf('Recognized user #%d (%s) from his access token.', $user->id, $user->email));
Log::info(sprintf('Recognized user #%d (%s) from his access token.', $user->id, $user->email));
return $value;
}
}
app('log')->error(sprintf('Recognized no users by access token "%s"', $value));
Log::error(sprintf('Recognized no users by access token "%s"', $value));
throw new NotFoundHttpException();
}

View File

@@ -46,7 +46,7 @@ class CategoryList implements BinderInterface
;
}
$list = array_unique(array_map('\intval', explode(',', $value)));
$list = array_unique(array_map(\intval(...), explode(',', $value)));
if (0 === count($list)) { // @phpstan-ignore-line
throw new NotFoundHttpException();
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Binder;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException;
use Carbon\Exceptions\InvalidFormatException;
@@ -61,7 +62,7 @@ class Date implements BinderInterface
];
if (array_key_exists($value, $magicWords)) {
$return = $magicWords[$value];
app('log')->debug(sprintf('User requests "%s", so will return "%s"', $value, $return));
Log::debug(sprintf('User requests "%s", so will return "%s"', $value, $return));
return $return;
}
@@ -70,7 +71,7 @@ class Date implements BinderInterface
$result = new Carbon($value);
} catch (InvalidDateException|InvalidFormatException $e) { // @phpstan-ignore-line
$message = sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage());
app('log')->error($message);
Log::error($message);
throw new NotFoundHttpException('Could not parse value', $e);
}

View File

@@ -60,7 +60,7 @@ class JournalList implements BinderInterface
protected static function parseList(string $value): array
{
$list = array_unique(array_map('\intval', explode(',', $value)));
$list = array_unique(array_map(\intval(...), explode(',', $value)));
if (0 === count($list)) { // @phpstan-ignore-line
throw new NotFoundHttpException();
}

View File

@@ -47,11 +47,11 @@ class TagList implements BinderInterface
->get()
;
}
$list = array_unique(array_map('\strtolower', explode(',', $value)));
app('log')->debug('List of tags is', $list);
$list = array_unique(array_map(\strtolower(...), explode(',', $value)));
Log::debug('List of tags is', $list);
if (0 === count($list)) { // @phpstan-ignore-line
app('log')->error('Tag list is empty.');
Log::error('Tag list is empty.');
throw new NotFoundHttpException();
}
@@ -62,7 +62,7 @@ class TagList implements BinderInterface
$allTags = $repository->get();
$collection = $allTags->filter(
static function (Tag $tag) use ($list) {
static function (Tag $tag) use ($list): bool {
if (in_array(strtolower($tag->tag), $list, true)) {
Log::debug(sprintf('TagList: (string) found tag #%d ("%s") in list.', $tag->id, $tag->tag));
@@ -82,7 +82,7 @@ class TagList implements BinderInterface
return $collection;
}
}
app('log')->error('TagList: user is not logged in.');
Log::error('TagList: user is not logged in.');
throw new NotFoundHttpException();
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Binder;
use Illuminate\Support\Facades\Log;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Routing\Route;
@@ -47,11 +48,11 @@ class TagOrId implements BinderInterface
if (null !== $result) {
return $result;
}
app('log')->error('TagOrId: tag not found.');
Log::error('TagOrId: tag not found.');
throw new NotFoundHttpException();
}
app('log')->error('TagOrId: user is not logged in.');
Log::error('TagOrId: user is not logged in.');
throw new NotFoundHttpException();
}