Use PSR-12 code style

This commit is contained in:
James Cole 2022-10-30 14:24:19 +01:00
parent 64ff5eed27
commit 2eebcb21f1
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
60 changed files with 103 additions and 158 deletions

View File

@ -55,8 +55,7 @@ class APIEventHandler
$user = $repository->find((int) $event->userId);
if (null !== $user) {
Notification::send($user, new NewAccessToken);
Notification::send($user, new NewAccessToken());
}
}
}

View File

@ -29,7 +29,6 @@ use FireflyIII\Repositories\AuditLogEntry\ALERepositoryInterface;
class AuditEventHandler
{
/**
* @param TriggeredAuditLog $event
* @return void
@ -47,5 +46,4 @@ class AuditEventHandler
$repository = app(ALERepositoryInterface::class);
$repository->store($array);
}
}

View File

@ -41,7 +41,6 @@ use Mail;
*/
class AutomationHandler
{
/**
* Respond to the creation of X journals.
*

View File

@ -51,6 +51,6 @@ class DestroyedGroupEventHandler
$engine->setTrigger(WebhookTrigger::DESTROY_TRANSACTION->value);
$engine->generateMessages();
event(new RequestedSendWebhookMessages);
event(new RequestedSendWebhookMessages());
}
}

View File

@ -43,5 +43,4 @@ class StoredAccountEventHandler
$object->setAccount($account);
$object->recalculate();
}
}

View File

@ -118,7 +118,6 @@ class StoredGroupEventHandler
$engine->generateMessages();
// trigger event to send them:
event(new RequestedSendWebhookMessages);
event(new RequestedSendWebhookMessages());
}
}

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
use FireflyIII\Events\UpdatedAccount;
use FireflyIII\Services\Internal\Support\CreditRecalculateService;

View File

@ -110,7 +110,7 @@ class UpdatedGroupEventHandler
$engine->setTrigger(WebhookTrigger::UPDATE_TRANSACTION->value);
$engine->generateMessages();
event(new RequestedSendWebhookMessages);
event(new RequestedSendWebhookMessages());
}
/**
@ -155,6 +155,5 @@ class UpdatedGroupEventHandler
Transaction::whereIn('transaction_journal_id', $all)
->where('amount', '>', 0)->update(['account_id' => $destAccount->id]);
}
}
}

View File

@ -89,7 +89,6 @@ class UserEventHandler
$url = route('invite', [$event->invitee->invite_code]);
try {
Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));
} catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
@ -101,7 +100,7 @@ class UserEventHandler
*/
public function createExchangeRates(RegisteredUser $event): void
{
$seeder = new ExchangeRateSeeder;
$seeder = new ExchangeRateSeeder();
$seeder->run();
}
@ -246,7 +245,6 @@ class UserEventHandler
try {
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));
} catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
@ -270,7 +268,6 @@ class UserEventHandler
$url = route('profile.undo-email-change', [$token->data, $hashed]);
try {
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
} catch (Exception $e) { // @phpstan-ignore-line
Log::error($e->getMessage());
}
@ -296,7 +293,7 @@ class UserEventHandler
{
$sendMail = FireflyConfig::get('notification_user_new_reg', true)->data;
if ($sendMail) {
Notification::send($event->user, new UserRegistrationNotification);
Notification::send($event->user, new UserRegistrationNotification());
}
}
@ -374,6 +371,5 @@ class UserEventHandler
if (false === $inArray && true === $send) {
event(new DetectedNewIPAddress($user, $ip));
}
}
}

View File

@ -38,8 +38,7 @@ class WebhookEventHandler
public function sendWebhookMessages(): void
{
// kick off the job!
$messages = WebhookMessage
::where('webhook_messages.sent', 0)
$messages = WebhookMessage::where('webhook_messages.sent', 0)
//->where('webhook_messages.errored', 0)
->get(['webhook_messages.*'])
->filter(

View File

@ -59,9 +59,9 @@ class AttachmentHelper implements AttachmentHelperInterface
{
$this->maxUploadSize = (int) config('firefly.maxUploadSize');
$this->allowedMimes = (array) config('firefly.allowedMimes');
$this->errors = new MessageBag;
$this->messages = new MessageBag;
$this->attachments = new Collection;
$this->errors = new MessageBag();
$this->messages = new MessageBag();
$this->attachments = new Collection();
$this->uploadDisk = Storage::disk('upload');
}
@ -145,11 +145,9 @@ class AttachmentHelper implements AttachmentHelperInterface
{
$resource = tmpfile();
if (false === $resource) {
Log::error('Cannot create temp-file for file upload.');
return false;
}
if ('' === $content) {
@ -239,7 +237,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$user = $model->account->user;
}
$attachment = new Attachment; // create Attachment object.
$attachment = new Attachment(); // create Attachment object.
$attachment->user()->associate($user);
$attachment->attachable()->associate($model);
$attachment->md5 = md5_file($file->getRealPath());

View File

@ -33,7 +33,6 @@ use Illuminate\Support\Collection;
*/
trait AccountCollection
{
/**
* These accounts must not be included.
*

View File

@ -32,7 +32,6 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
*/
trait AmountCollection
{
/**
* Get transactions with a specific amount.
*

View File

@ -855,7 +855,7 @@ trait MetaCollection
$filter = function (int $index, array $object) use ($list): bool {
foreach ($object['transactions'] as $transaction) {
foreach ($transaction['tags'] as $tag) {
if (in_array($tag['name'], $list)) {
if (in_array($tag['name'], $list, true)) {
return false;
}
}

View File

@ -100,7 +100,6 @@ trait TimeCollection
$this->postFilters[] = $filter;
return $this;
}
/**
@ -430,7 +429,6 @@ trait TimeCollection
{
$this->query->whereMonth('transaction_journals.date', '>=', $month);
return $this;
}
/**
@ -441,7 +439,6 @@ trait TimeCollection
{
$this->query->whereMonth('transaction_journals.date', '<=', $month);
return $this;
}
/**
@ -718,7 +715,6 @@ trait TimeCollection
};
$this->postFilters[] = $filter;
return $this;
}
/**
@ -841,5 +837,4 @@ trait TimeCollection
$this->query->whereYear('transaction_journals.date', '!=', $year);
return $this;
}
}

View File

@ -50,7 +50,12 @@ use Log;
*/
class GroupCollector implements GroupCollectorInterface
{
use CollectorProperties, AccountCollection, AmountCollection, TimeCollection, MetaCollection, AttachmentCollection;
use CollectorProperties;
use AccountCollection;
use AmountCollection;
use TimeCollection;
use MetaCollection;
use AttachmentCollection;
/**
* Group collector constructor.
@ -352,7 +357,6 @@ class GroupCollector implements GroupCollectorInterface
*/
public function excludeIds(array $groupIds): GroupCollectorInterface
{
$this->query->whereNotIn('transaction_groups.id', $groupIds);
return $this;
@ -767,7 +771,7 @@ class GroupCollector implements GroupCollectorInterface
* @var Closure $function
*/
foreach ($this->postFilters as $function) {
$nextCollection = new Collection;
$nextCollection = new Collection();
// loop everything in the current collection
// and save it (or not) in the new collection.
// that new collection is the next current collection
@ -874,7 +878,6 @@ class GroupCollector implements GroupCollectorInterface
*/
public function setIds(array $groupIds): GroupCollectorInterface
{
$this->query->whereIn('transaction_groups.id', $groupIds);
return $this;
@ -992,7 +995,6 @@ class GroupCollector implements GroupCollectorInterface
if (null === $this->user) {
$this->user = $user;
$this->startQuery();
}
return $this;

View File

@ -1395,6 +1395,4 @@ interface GroupCollectorInterface
* @return GroupCollectorInterface
*/
public function yearIsNot(string $year): GroupCollectorInterface;
}

View File

@ -67,7 +67,7 @@ class NetWorth implements NetWorthInterface
public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array
{
// start in the past, end in the future? use $date
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($date);
$cache->addProperty('net-worth-by-currency');
$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));
@ -184,7 +184,7 @@ class NetWorth implements NetWorthInterface
private function getAccounts(): Collection
{
$accounts = $this->accountRepository->getAccountsByType([AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::DEFAULT, AccountType::CREDITCARD]);
$filtered = new Collection;
$filtered = new Collection();
/** @var Account $account */
foreach ($accounts as $account) {
if (1 === (int) $this->accountRepository->getMetaValue($account, 'include_net_worth')) {

View File

@ -66,5 +66,4 @@ interface NetWorthInterface
* @return array
*/
public function sumNetWorthByCurrency(Carbon $date): array;
}

View File

@ -31,7 +31,6 @@ use FireflyIII\Models\Category;
*/
interface PopupReportInterface
{
/**
* Get balances for budget.
*

View File

@ -28,7 +28,6 @@ use FireflyIII\Models\WebhookMessage;
use JsonException;
use Log;
/**
* Class Sha3SignatureGenerator
*/

View File

@ -113,5 +113,4 @@ class DeleteController extends Controller
return redirect($this->getPreviousUrl('accounts.delete.url'));
}
}

View File

@ -120,7 +120,6 @@ class IndexController extends Controller
$accounts->setPath(route('accounts.inactive.index', [$objectType]));
return view('accounts.index', compact('objectType', 'inactivePage', 'subTitleIcon', 'subTitle', 'page', 'accounts'));
}
/**

View File

@ -96,11 +96,9 @@ class ReconcileController extends Controller
return $this->redirectAccountToAccount($account);
}
if (AccountType::ASSET !== $account->accountType->type) {
session()->flash('error', (string) trans('firefly.must_be_asset_account'));
return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));
}
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
@ -110,11 +108,10 @@ class ReconcileController extends Controller
// get start and end
if (null === $start && null === $end) {
/** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon(), $range));
/** @var Carbon $end */
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range));
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon(), $range));
}
if (null === $end) {
/** @var Carbon $end */

View File

@ -188,7 +188,7 @@ class ShowController extends Controller
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
$periods = new Collection;
$periods = new Collection();
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation();

View File

@ -246,11 +246,9 @@ class UserController extends Controller
app('preferences')->mark();
$redirect = redirect($this->getPreviousUrl('users.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
session()->put('users.edit.fromUpdate', true);
$redirect = redirect(route('admin.users.edit', [$user->id]))->withInput(['return_to_edit' => 1]);
}
// redirect to previous URL.

View File

@ -40,7 +40,6 @@ use Illuminate\View\View;
*/
class AttachmentController extends Controller
{
/** @var AttachmentRepositoryInterface Attachment repository */
private $repository;
@ -198,11 +197,9 @@ class AttachmentController extends Controller
$redirect = redirect($this->getPreviousUrl('attachments.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
$request->session()->put('attachments.edit.fromUpdate', true);
$redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]);
}
// redirect to previous URL.

View File

@ -52,7 +52,8 @@ use Log;
*/
class LoginController extends Controller
{
use AuthenticatesUsers, ThrottlesLogins;
use AuthenticatesUsers;
use ThrottlesLogins;
/**
* Where to redirect users after login.

View File

@ -51,7 +51,8 @@ use Psr\Container\NotFoundExceptionInterface;
*/
class RegisterController extends Controller
{
use RegistersUsers, CreateStuff;
use RegistersUsers;
use CreateStuff;
/**
* Where to redirect users after registration.
@ -74,7 +75,6 @@ class RegisterController extends Controller
if ('eloquent' !== $loginProvider || 'web' !== $authGuard) {
throw new FireflyException('Using external identity provider. Cannot continue.');
}
}
/**
@ -191,7 +191,7 @@ class RegisterController extends Controller
return view('error', compact('message'));
}
if(false === $validCode) {
if (false === $validCode) {
$message = 'Invalid code.';
return view('error', compact('message'));

View File

@ -144,11 +144,9 @@ class EditController extends Controller
$redirect = redirect($this->getPreviousUrl('bills.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
$request->session()->put('bills.edit.fromUpdate', true);
$redirect = redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]);
}
return $redirect;

View File

@ -77,7 +77,7 @@ class IndexController extends Controller
$total = $collection->count();
$defaultCurrency = app('amount')->getDefaultCurrency();
$parameters = new ParameterBag;
$parameters = new ParameterBag();
$parameters->set('start', $start);
$parameters->set('end', $end);

View File

@ -88,7 +88,7 @@ class ShowController extends Controller
return redirect(route('bills.show', [$bill->id]));
}
$set = new Collection;
$set = new Collection();
if (true === $bill->active) {
$set = $this->repository->getRulesForBill($bill);
$total = 0;
@ -167,7 +167,7 @@ class ShowController extends Controller
// transform any attachments as well.
$collection = $this->repository->getAttachments($bill);
$attachments = new Collection;
$attachments = new Collection();
if ($collection->count() > 0) {
@ -183,5 +183,4 @@ class ShowController extends Controller
return view('bills.show', compact('attachments', 'groups', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle'));
}
}

View File

@ -160,7 +160,7 @@ class BudgetLimitController extends Controller
if ((int) $amount > 268435456) {
$amount = '268435456';
}
if((float) $amount < 0.0) {
if ((float) $amount < 0.0) {
$amount = bcmul($amount, '-1');
}
@ -229,7 +229,7 @@ class BudgetLimitController extends Controller
if ((int) $amount > 268435456) { // 268 million
$amount = '268435456';
}
if((float) $amount < 0.0) {
if ((float) $amount < 0.0) {
$amount = bcmul($amount, '-1');
}

View File

@ -139,11 +139,9 @@ class CreateController extends Controller
$redirect = redirect($this->getPreviousUrl('budgets.create.url'));
if (1 === (int) $request->get('create_another')) {
$request->session()->put('budgets.create.fromStore', true);
$redirect = redirect(route('budgets.create'))->withInput();
}
return $redirect;

View File

@ -95,5 +95,4 @@ class DeleteController extends Controller
return redirect($this->getPreviousUrl('budgets.delete.url'));
}
}

View File

@ -149,11 +149,9 @@ class EditController extends Controller
}
if (1 === (int) $request->get('return_to_edit')) {
$request->session()->put('budgets.edit.fromUpdate', true);
$redirect = redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]);
}
return $redirect;

View File

@ -123,7 +123,7 @@ class IndexController extends Controller
// get budgeted for default currency:
if (empty($availableBudgets)) {
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency,);
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, );
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
unset($spentArr);
@ -137,10 +137,25 @@ class IndexController extends Controller
$inactive = $this->repository->getInactiveBudgets();
return view(
'budgets.index', compact(
'availableBudgets', 'budgeted', 'spent', 'prevLoop', 'nextLoop', 'budgets', 'currencies', 'periodTitle',
'defaultCurrency', 'activeDaysPassed', 'activeDaysLeft', 'inactive', 'budgets', 'start', 'end', 'sums'
)
'budgets.index',
compact(
'availableBudgets',
'budgeted',
'spent',
'prevLoop',
'nextLoop',
'budgets',
'currencies',
'periodTitle',
'defaultCurrency',
'activeDaysPassed',
'activeDaysLeft',
'inactive',
'budgets',
'start',
'end',
'sums'
)
);
}
@ -167,7 +182,7 @@ class IndexController extends Controller
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
// budgeted in period:
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency,);
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency, );
$array['budgeted'] = $budgeted;
$availableBudgets[] = $array;
unset($spentArr);

View File

@ -44,7 +44,8 @@ use Illuminate\View\View;
*/
class ShowController extends Controller
{
use PeriodOverview, AugumentData;
use PeriodOverview;
use AugumentData;
protected JournalRepositoryInterface $journalRepos;
private BudgetRepositoryInterface $repository;
@ -123,10 +124,9 @@ class ShowController extends Controller
*/
public function noBudgetAll(Request $request)
{
$subTitle = (string) trans('firefly.all_journals_without_budget');
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date;
$start = null === $first ? new Carbon() : $first->date;
$end = today(config('app.timezone'));
$page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;

View File

@ -112,11 +112,9 @@ class CreateController extends Controller
$redirect = redirect(route('categories.index'));
if (1 === (int) $request->get('create_another')) {
$request->session()->put('categories.create.fromStore', true);
$redirect = redirect(route('categories.create'))->withInput();
}
return $redirect;

View File

@ -39,7 +39,6 @@ use Illuminate\View\View;
*/
class EditController extends Controller
{
private AttachmentHelperInterface $attachments;
private CategoryRepositoryInterface $repository;
@ -120,11 +119,9 @@ class EditController extends Controller
$redirect = redirect($this->getPreviousUrl('categories.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
$request->session()->put('categories.edit.fromUpdate', true);
$redirect = redirect(route('categories.edit', [$category->id]));
}
return $redirect;

View File

@ -81,7 +81,7 @@ class IndexController extends Controller
$collection->each(
function (Category $category) {
$category->lastActivity = $this->repository->lastUseDate($category, new Collection);
$category->lastActivity = $this->repository->lastUseDate($category, new Collection());
}
);
@ -91,5 +91,4 @@ class IndexController extends Controller
return view('categories.index', compact('categories'));
}
}

View File

@ -125,13 +125,13 @@ class NoCategoryController extends Controller
// default values:
$start = null;
$end = null;
$periods = new Collection;
$periods = new Collection();
$page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
Log::debug('Start of noCategory()');
$subTitle = (string) trans('firefly.all_journals_without_category');
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date;
$start = null === $first ? new Carbon() : $first->date;
$end = today(config('app.timezone'));
Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));

View File

@ -132,7 +132,7 @@ class ShowController extends Controller
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$start = null;
$end = null;
$periods = new Collection;
$periods = new Collection();
$subTitle = (string) trans('firefly.all_journals_for_category', ['name' => $category->name]);
$first = $this->repository->firstUseDate($category);

View File

@ -48,7 +48,9 @@ use Log;
*/
class AccountController extends Controller
{
use DateCalculation, AugumentData, ChartGeneration;
use DateCalculation;
use AugumentData;
use ChartGeneration;
protected GeneratorInterface $generator;
private AccountRepositoryInterface $accountRepository;
@ -88,7 +90,7 @@ class AccountController extends Controller
$start = clone session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = clone session('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('chart.account.expense-accounts');
@ -196,7 +198,7 @@ class AccountController extends Controller
*/
public function expenseBudget(Account $account, Carbon $start, Carbon $end): JsonResponse
{
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty($start);
$cache->addProperty($end);
@ -271,7 +273,7 @@ class AccountController extends Controller
*/
public function expenseCategory(Account $account, Carbon $start, Carbon $end): JsonResponse
{
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty($start);
$cache->addProperty($end);
@ -372,7 +374,7 @@ class AccountController extends Controller
*/
public function incomeCategory(Account $account, Carbon $start, Carbon $end): JsonResponse
{
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty($start);
$cache->addProperty($end);
@ -432,7 +434,7 @@ class AccountController extends Controller
public function period(Account $account, Carbon $start, Carbon $end): JsonResponse
{
$chartData = [];
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty('chart.account.period');
$cache->addProperty($start);
$cache->addProperty($end);
@ -508,7 +510,6 @@ class AccountController extends Controller
$current = app('navigation')->addPeriod($current, $step, 0);
}
break;
}
$result['entries'] = $entries;
@ -547,7 +548,7 @@ class AccountController extends Controller
$start = clone session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = clone session('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('chart.account.revenue-accounts');

View File

@ -62,7 +62,7 @@ class BillController extends Controller
{
$start = session('start', Carbon::now()->startOfMonth());
$end = session('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('chart.bill.frontpage');
@ -106,7 +106,7 @@ class BillController extends Controller
*/
public function single(Bill $bill): JsonResponse
{
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty('chart.bill.single');
$cache->addProperty($bill->id);
if ($cache->has()) {

View File

@ -49,7 +49,8 @@ use JsonException;
*/
class BudgetController extends Controller
{
use DateCalculation, AugumentData;
use DateCalculation;
use AugumentData;
protected GeneratorInterface $generator;
protected OperationsRepositoryInterface $opsRepository;
@ -209,7 +210,7 @@ class BudgetController extends Controller
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($budgetLimitId);
$cache->addProperty('chart.budget.expense-asset');
@ -277,7 +278,7 @@ class BudgetController extends Controller
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($budgetLimitId);
$cache->addProperty('chart.budget.expense-category');
@ -341,7 +342,7 @@ class BudgetController extends Controller
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($budgetLimitId);
$cache->addProperty('chart.budget.expense-expense');

View File

@ -41,7 +41,8 @@ use Illuminate\Support\Collection;
*/
class BudgetReportController extends Controller
{
use AugumentData, TransactionCalculation;
use AugumentData;
use TransactionCalculation;
/** @var GeneratorInterface Chart generation methods. */
private $generator;

View File

@ -46,7 +46,9 @@ use JsonException;
*/
class CategoryController extends Controller
{
use DateCalculation, AugumentData, ChartGeneration;
use DateCalculation;
use AugumentData;
use ChartGeneration;
/** @var GeneratorInterface Chart generation methods. */
protected $generator;
@ -77,7 +79,7 @@ class CategoryController extends Controller
public function all(Category $category): JsonResponse
{
// cache results:
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty('chart.category.all');
$cache->addProperty($category->id);
if ($cache->has()) {
@ -125,7 +127,7 @@ class CategoryController extends Controller
$start = session('start', Carbon::now()->startOfMonth());
$end = session('end', Carbon::now()->endOfMonth());
// chart properties for cache:
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('chart.category.frontpage');
@ -154,7 +156,7 @@ class CategoryController extends Controller
*/
public function reportPeriod(Category $category, Collection $accounts, Carbon $start, Carbon $end): JsonResponse
{
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('chart.category.period');
@ -202,7 +204,6 @@ class CategoryController extends Controller
$collection = new Collection([$category]);
$expenses = $opsRepository->listExpenses($start, $end, null, $collection);
$income = $opsRepository->listIncome($start, $end, null, $collection);
}
$currencies = array_unique(array_merge(array_keys($income), array_keys($expenses)));
$periods = app('navigation')->listOfPeriods($start, $end);
@ -269,7 +270,7 @@ class CategoryController extends Controller
*/
public function reportPeriodNoCategory(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
{
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('chart.category.period.no-cat');
@ -305,7 +306,7 @@ class CategoryController extends Controller
[$end, $start] = [$start, $end];
}
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($category->id);

View File

@ -39,7 +39,8 @@ use Illuminate\Support\Collection;
*/
class CategoryReportController extends Controller
{
use AugumentData, TransactionCalculation;
use AugumentData;
use TransactionCalculation;
/** @var GeneratorInterface Chart generation methods. */
private $generator;

View File

@ -38,7 +38,6 @@ use Illuminate\Support\Collection;
*/
class DoubleReportController extends Controller
{
/** @var GeneratorInterface Chart generation methods. */
private $generator;
/** @var OperationsRepositoryInterface */

View File

@ -42,7 +42,8 @@ use JsonException;
*/
class ExpenseReportController extends Controller
{
use AugumentData, TransactionCalculation;
use AugumentData;
use TransactionCalculation;
/** @var AccountRepositoryInterface The account repository */
protected $accountRepository;
@ -82,7 +83,7 @@ class ExpenseReportController extends Controller
*/
public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): JsonResponse
{
$cache = new CacheProperties;
$cache = new CacheProperties();
$cache->addProperty('chart.expense.report.main');
$cache->addProperty($accounts);
$cache->addProperty($expense);
@ -98,7 +99,7 @@ class ExpenseReportController extends Controller
$currentStart = clone $start;
$combined = $this->combineAccounts($expense);
// make "all" set:
$all = new Collection;
$all = new Collection();
foreach ($combined as $name => $combination) {
$all = $all->merge($combination);
}

View File

@ -36,7 +36,11 @@ use Route;
*/
abstract class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, RequestInformation, UserNavigation;
use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
use RequestInformation;
use UserNavigation;
protected string $dateTimeFormat;
protected string $monthAndDayFormat;

View File

@ -139,12 +139,10 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
}
if ($this->repository->currencyInUse($currency)) {
@ -177,12 +175,10 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
}
if ($this->repository->currencyInUse($currency)) {
@ -228,16 +224,13 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to disable currency %s but is not site owner.', $currency->code));
return response()->json([]);
}
// currency cannot be in use.
if ($this->repository->currencyInUse($currency)) {
$location = $this->repository->currencyInUseAt($currency);
$message = (string) trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
@ -274,12 +267,10 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code));
return redirect(route('currencies.index'));
}
$subTitleIcon = 'fa-pencil';
@ -371,12 +362,10 @@ class CurrencyController extends Controller
$user = auth()->user();
$data = $request->getCurrencyData();
if (!$this->userRepository->hasRole($user, 'owner')) {
Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');
Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data);
return redirect($this->getPreviousUrl('currencies.create.url'));
}
$data['enabled'] = true;
@ -394,11 +383,9 @@ class CurrencyController extends Controller
$request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));
Log::channel('audit')->info('Created (POST) currency.', $data);
if (1 === (int) $request->get('create_another')) {
$request->session()->put('currencies.create.fromStore', true);
$redirect = redirect(route('currencies.create'))->withInput();
}
}
@ -423,12 +410,10 @@ class CurrencyController extends Controller
$data['enabled'] = true;
}
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data);
return redirect(route('currencies.index'));
}
$currency = $this->repository->update($currency, $data);
Log::channel('audit')->info('Updated (POST) currency.', $data);
@ -436,11 +421,9 @@ class CurrencyController extends Controller
app('preferences')->mark();
if (1 === (int) $request->get('return_to_edit')) {
$request->session()->put('currencies.edit.fromUpdate', true);
return redirect(route('currencies.edit', [$currency->id]));
}
return redirect($this->getPreviousUrl('currencies.edit.url'));

View File

@ -98,7 +98,6 @@ class DebugController extends Controller
Log::debug('Call twig:clean...');
try {
Artisan::call('twig:clean');
} catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException
}
@ -189,11 +188,9 @@ class DebugController extends Controller
if (null !== $logFile) {
try {
$logContent = file_get_contents($logFile);
} catch (Exception $e) { // @phpstan-ignore-line
// @ignoreException
}
}
}
}
@ -238,7 +235,6 @@ class DebugController extends Controller
'defaultLanguage',
'defaultLocale',
'isDocker'
)
);
}

View File

@ -166,5 +166,4 @@ class JavascriptController extends Controller
->view('v2.javascript.variables', $data)
->header('Content-Type', 'text/javascript');
}
}

View File

@ -95,7 +95,6 @@ class NewUserController extends Controller
$language = $request->convertString('language');
if (!array_key_exists($language, config('firefly.languages'))) {
$language = 'en_US';
}
// set language preference:
@ -133,5 +132,4 @@ class NewUserController extends Controller
return redirect(route('index'));
}
}

View File

@ -195,10 +195,10 @@ class PreferencesController extends Controller
// slack URL:
$url = (string) $request->get('slackUrl');
if(str_starts_with($url, 'https://hooks.slack.com/services/')){
if (str_starts_with($url, 'https://hooks.slack.com/services/')) {
app('preferences')->set('slack_webhook_url', $url);
}
if('' === $url) {
if ('' === $url) {
app('preferences')->delete('slack_webhook_url');
}

View File

@ -210,9 +210,7 @@ class ProfileController extends Controller
public function confirmEmailChange(UserRepositoryInterface $repository, string $token)
{
if (!$this->internalAuth || !$this->internalIdentity) {
throw new FireflyException(trans('firefly.external_user_mgt_disabled'));
}
// find preference with this token value.
/** @var Collection $set */
@ -349,7 +347,8 @@ class ProfileController extends Controller
}
return view(
'profile.index', compact('subTitle', 'mfaBackupCount', 'userId', 'accessToken', 'enabled2FA', 'isInternalAuth', 'isInternalIdentity')
'profile.index',
compact('subTitle', 'mfaBackupCount', 'userId', 'accessToken', 'enabled2FA', 'isInternalAuth', 'isInternalIdentity')
);
}
@ -633,7 +632,6 @@ class ProfileController extends Controller
session()->flash('error', (string) trans('auth.failed'));
return redirect(route('profile.index'));
}
/**

View File

@ -119,7 +119,6 @@ class SearchController extends Controller
try {
$html = view('search.search', compact('groups', 'hasPages', 'searchTime'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render search.search: %s', $e->getMessage()));
$html = 'Could not render view.';

View File

@ -335,11 +335,9 @@ class TagController extends Controller
}
$redirect = redirect($this->getPreviousUrl('tags.create.url'));
if (1 === (int) $request->get('create_another')) {
session()->put('tags.create.fromStore', true);
$redirect = redirect(route('tags.create'))->withInput();
}
return $redirect;
@ -376,11 +374,9 @@ class TagController extends Controller
}
$redirect = redirect($this->getPreviousUrl('tags.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
session()->put('tags.edit.fromUpdate', true);
$redirect = redirect(route('tags.edit', [$tag->id]))->withInput(['return_to_edit' => 1]);
}
// redirect to previous URL.