Skip to content

Firefly III: a personal finances manager

Code cleanup

James Colea3c34e6b3c13
diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php
index 4ac431f472..a844c703f5 100644
--- a/app/Http/Controllers/Account/ReconcileController.php
+++ b/app/Http/Controllers/Account/ReconcileController.php
@@ -123,7 +123,6 @@ class ReconcileController extends Controller
* @return \Illuminate\Http\JsonResponse
*
* @throws FireflyException
- * @throws \Throwable
*/
public function overview(Request $request, Account $account, Carbon $start, Carbon $end)
{
@@ -189,7 +188,7 @@ class ReconcileController extends Controller
return redirect(route('accounts.index', [config('firefly.shortNamesByFullName.' . $account->accountType->type)]));
}
- $currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id'));
+ $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
@@ -263,7 +262,7 @@ class ReconcileController extends Controller
/** @var Transaction $transaction */
foreach ($data['transactions'] as $transactionId) {
- $repository->reconcileById(intval($transactionId));
+ $repository->reconcileById((int)$transactionId);
}
Log::debug('Reconciled all transactions.');
@@ -300,7 +299,7 @@ class ReconcileController extends Controller
'tags' => null,
'interest_date' => null,
'transactions' => [[
- 'currency_id' => intval($this->accountRepos->getMetaValue($account, 'currency_id')),
+ 'currency_id' => (int)$this->accountRepos->getMetaValue($account, 'currency_id'),
'currency_code' => null,
'description' => null,
'amount' => app('steam')->positive($difference),
@@ -338,7 +337,6 @@ class ReconcileController extends Controller
*
* @return mixed
*
- * @throws \Throwable
* @throws FireflyException
*/
public function transactions(Account $account, Carbon $start, Carbon $end)
@@ -350,7 +348,7 @@ class ReconcileController extends Controller
$startDate = clone $start;
$startDate->subDays(1);
- $currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id'));
+ $currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
@@ -400,7 +398,7 @@ class ReconcileController extends Controller
$destination = $this->repository->getJournalDestinationAccounts($journal)->first();
if (bccomp($submitted['amount'], '0') === 1) {
// amount is positive, switch accounts:
- list($source, $destination) = [$destination, $source];
+ [$source, $destination] = [$destination, $source];
}
// expand data with journal data:
@@ -417,7 +415,7 @@ class ReconcileController extends Controller
'interest_date' => null,
'book_date' => null,
'transactions' => [[
- 'currency_id' => intval($journal->transaction_currency_id),
+ 'currency_id' => (int)$journal->transaction_currency_id,
'currency_code' => null,
'description' => null,
'amount' => app('steam')->positive($submitted['amount']),
@@ -442,7 +440,7 @@ class ReconcileController extends Controller
$this->repository->update($journal, $data);
// @codeCoverageIgnoreStart
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
Session::put('reconcile.edit.fromUpdate', true);
return redirect(route('accounts.reconcile.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index f43e22938e..6e92d75b4e 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -84,7 +84,6 @@ class AccountController extends Controller
* @param string $what
*
* @return View
- * @throws \RuntimeException
*/
public function create(Request $request, string $what = 'asset')
{
@@ -133,18 +132,17 @@ class AccountController extends Controller
* @param Account $account
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function destroy(Request $request, Account $account)
{
$type = $account->accountType->type;
$typeName = config('firefly.shortNamesByFullName.' . $type);
$name = $account->name;
- $moveTo = $this->repository->findNull(intval($request->get('move_account_before_delete')));
+ $moveTo = $this->repository->findNull((int)$request->get('move_account_before_delete'));
$this->repository->destroy($account, $moveTo);
- $request->session()->flash('success', strval(trans('firefly.' . $typeName . '_deleted', ['name' => $name])));
+ $request->session()->flash('success', (string)trans('firefly.' . $typeName . '_deleted', ['name' => $name]));
Preferences::mark();
return redirect($this->getPreviousUri('accounts.delete.uri'));
@@ -163,7 +161,7 @@ class AccountController extends Controller
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
- * @throws \RuntimeException
+
*/
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
{
@@ -174,7 +172,7 @@ class AccountController extends Controller
$currencySelectList = ExpandedForm::makeSelectList($allCurrencies);
$roles = [];
foreach (config('firefly.accountRoles') as $role) {
- $roles[$role] = strval(trans('firefly.account_role_' . $role));
+ $roles[$role] = (string)trans('firefly.account_role_' . $role);
}
// put previous url in session if not redirect from store (not "return_to_edit").
@@ -186,11 +184,11 @@ class AccountController extends Controller
// pre fill some useful values.
// the opening balance is tricky:
- $openingBalanceAmount = strval($repository->getOpeningBalanceAmount($account));
+ $openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);
$openingBalanceDate = $repository->getOpeningBalanceDate($account);
$default = app('amount')->getDefaultCurrency();
- $currency = $this->currencyRepos->findNull(intval($repository->getMetaValue($account, 'currency_id')));
- if (is_null($currency)) {
+ $currency = $this->currencyRepos->findNull((int)$repository->getMetaValue($account, 'currency_id'));
+ if (null === $currency) {
$currency = $default;
}
@@ -246,8 +244,8 @@ class AccountController extends Controller
$types = config('firefly.accountTypesByIdentifier.' . $what);
$collection = $this->repository->getAccountsByType($types);
$total = $collection->count();
- $page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
unset($collection);
/** @var Carbon $start */
@@ -378,7 +376,6 @@ class AccountController extends Controller
* @param AccountFormRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function store(AccountFormRequest $request)
{
@@ -396,7 +393,7 @@ class AccountController extends Controller
// @codeCoverageIgnoreEnd
}
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// set value so create routine will not overwrite URL:
$request->session()->put('accounts.create.fromStore', true);
@@ -412,17 +409,16 @@ class AccountController extends Controller
* @param Account $account
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function update(AccountFormRequest $request, Account $account)
{
$data = $request->getAccountData();
$this->repository->update($account, $data);
- $request->session()->flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
+ $request->session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL:
$request->session()->put('accounts.edit.fromUpdate', true);
@@ -467,7 +463,7 @@ class AccountController extends Controller
$start = $this->repository->oldestJournalDate($account);
$end = $date ?? new Carbon;
if ($end < $start) {
- list($start, $end) = [$end, $start]; // @codeCoverageIgnore
+ [$start, $end] = [$end, $start]; // @codeCoverageIgnore
}
// properties for cache
diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php
index 8296d41c43..64c47a5be5 100644
--- a/app/Http/Controllers/Admin/ConfigurationController.php
+++ b/app/Http/Controllers/Admin/ConfigurationController.php
@@ -46,7 +46,7 @@ class ConfigurationController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', strval(trans('firefly.administration')));
+ app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request);
@@ -61,7 +61,7 @@ class ConfigurationController extends Controller
*/
public function index()
{
- $subTitle = strval(trans('firefly.instance_configuration'));
+ $subTitle = (string)trans('firefly.instance_configuration');
$subTitleIcon = 'fa-wrench';
// all available configuration and their default value in case
@@ -91,7 +91,7 @@ class ConfigurationController extends Controller
FireflyConfig::set('is_demo_site', $data['is_demo_site']);
// flash message
- Session::flash('success', strval(trans('firefly.configuration_updated')));
+ Session::flash('success', (string)trans('firefly.configuration_updated'));
Preferences::mark();
return Redirect::route('admin.configuration.index');
diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php
index fd4832b7fa..a13c54280b 100644
--- a/app/Http/Controllers/Admin/HomeController.php
+++ b/app/Http/Controllers/Admin/HomeController.php
@@ -50,7 +50,7 @@ class HomeController extends Controller
*/
public function index()
{
- $title = strval(trans('firefly.administration'));
+ $title = (string)trans('firefly.administration');
$mainTitleIcon = 'fa-hand-spock-o';
return view('admin.index', compact('title', 'mainTitleIcon'));
@@ -66,7 +66,7 @@ class HomeController extends Controller
$ipAddress = $request->ip();
Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress));
event(new AdminRequestedTestMessage(auth()->user(), $ipAddress));
- Session::flash('info', strval(trans('firefly.send_test_triggered')));
+ Session::flash('info', (string)trans('firefly.send_test_triggered'));
return redirect(route('admin.index'));
}
diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php
index aa2078da42..be3be8fdb4 100644
--- a/app/Http/Controllers/Admin/LinkController.php
+++ b/app/Http/Controllers/Admin/LinkController.php
@@ -45,7 +45,7 @@ class LinkController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', strval(trans('firefly.administration')));
+ app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request);
@@ -76,12 +76,11 @@ class LinkController extends Controller
* @param LinkType $linkType
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
- * @throws \RuntimeException
*/
public function delete(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{
if (!$linkType->editable) {
- $request->session()->flash('error', strval(trans('firefly.cannot_edit_link_type', ['name' => $linkType->name])));
+ $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]));
return redirect(route('admin.links.index'));
}
@@ -109,15 +108,14 @@ class LinkController extends Controller
* @param LinkType $linkType
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function destroy(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{
$name = $linkType->name;
- $moveTo = $repository->find(intval($request->get('move_link_type_before_delete')));
+ $moveTo = $repository->find((int)$request->get('move_link_type_before_delete'));
$repository->destroy($linkType, $moveTo);
- $request->session()->flash('success', strval(trans('firefly.deleted_link_type', ['name' => $name])));
+ $request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name]));
Preferences::mark();
return redirect($this->getPreviousUri('link_types.delete.uri'));
@@ -128,12 +126,11 @@ class LinkController extends Controller
* @param LinkType $linkType
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
- * @throws \RuntimeException
*/
public function edit(Request $request, LinkType $linkType)
{
if (!$linkType->editable) {
- $request->session()->flash('error', strval(trans('firefly.cannot_edit_link_type', ['name' => $linkType->name])));
+ $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]));
return redirect(route('admin.links.index'));
}
@@ -187,7 +184,6 @@ class LinkController extends Controller
* @param LinkTypeRepositoryInterface $repository
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function store(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository)
{
@@ -197,9 +193,9 @@ class LinkController extends Controller
'outward' => $request->string('outward'),
];
$linkType = $repository->store($data);
- $request->session()->flash('success', strval(trans('firefly.stored_new_link_type', ['name' => $linkType->name])));
+ $request->session()->flash('success', (string)trans('firefly.stored_new_link_type', ['name' => $linkType->name]));
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// set value so create routine will not overwrite URL:
$request->session()->put('link_types.create.fromStore', true);
@@ -216,12 +212,11 @@ class LinkController extends Controller
* @param LinkType $linkType
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function update(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{
if (!$linkType->editable) {
- $request->session()->flash('error', strval(trans('firefly.cannot_edit_link_type', ['name' => $linkType->name])));
+ $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => $linkType->name]));
return redirect(route('admin.links.index'));
}
@@ -233,10 +228,10 @@ class LinkController extends Controller
];
$repository->update($linkType, $data);
- $request->session()->flash('success', strval(trans('firefly.updated_link_type', ['name' => $linkType->name])));
+ $request->session()->flash('success', (string)trans('firefly.updated_link_type', ['name' => $linkType->name]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL:
$request->session()->put('link_types.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php
index 423de9cb6b..44834b3597 100644
--- a/app/Http/Controllers/Admin/UpdateController.php
+++ b/app/Http/Controllers/Admin/UpdateController.php
@@ -49,7 +49,7 @@ class UpdateController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
- app('view')->share('title', strval(trans('firefly.administration')));
+ app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request);
@@ -87,10 +87,10 @@ class UpdateController extends Controller
*/
public function post(Request $request)
{
- $checkForUpdates = intval($request->get('check_for_updates'));
+ $checkForUpdates = (int)$request->get('check_for_updates');
FireflyConfig::set('permission_update_check', $checkForUpdates);
FireflyConfig::set('last_update_check', time());
- Session::flash('success', strval(trans('firefly.configuration_updated')));
+ Session::flash('success', (string)trans('firefly.configuration_updated'));
return redirect(route('admin.update-check'));
}
@@ -118,7 +118,7 @@ class UpdateController extends Controller
Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
}
if ($check === -2) {
- $string = strval(trans('firefly.update_check_error'));
+ $string = (string)trans('firefly.update_check_error');
}
if ($check === -1) {
@@ -126,25 +126,23 @@ class UpdateController extends Controller
// has it been released for more than three days?
$today = new Carbon;
if ($today->diffInDays($first->getUpdated(), true) > 3) {
- $string = strval(
- trans(
- 'firefly.update_new_version_alert',
- [
- 'your_version' => $current,
- 'new_version' => $first->getTitle(),
- 'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat),
- ]
- )
+ $string = (string)trans(
+ 'firefly.update_new_version_alert',
+ [
+ 'your_version' => $current,
+ 'new_version' => $first->getTitle(),
+ 'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat),
+ ]
);
}
}
if ($check === 0) {
// you are running the current version!
- $string = strval(trans('firefly.update_current_version_alert', ['version' => $current]));
+ $string = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
}
if ($check === 1) {
// you are running a newer version!
- $string = strval(trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $first->getTitle()]));
+ $string = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $first->getTitle()]);
}
return response()->json(['result' => $string]);
diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php
index f4fa02a18b..a7f2e4e102 100644
--- a/app/Http/Controllers/Admin/UserController.php
+++ b/app/Http/Controllers/Admin/UserController.php
@@ -47,7 +47,7 @@ class UserController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', strval(trans('firefly.administration')));
+ app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request);
@@ -78,7 +78,7 @@ class UserController extends Controller
public function destroy(User $user, UserRepositoryInterface $repository)
{
$repository->destroy($user);
- Session::flash('success', strval(trans('firefly.user_deleted')));
+ Session::flash('success', (string)trans('firefly.user_deleted'));
return redirect(route('admin.users'));
}
@@ -96,13 +96,13 @@ class UserController extends Controller
}
Session::forget('users.edit.fromUpdate');
- $subTitle = strval(trans('firefly.edit_user', ['email' => $user->email]));
+ $subTitle = (string)trans('firefly.edit_user', ['email' => $user->email]);
$subTitleIcon = 'fa-user-o';
$codes = [
- '' => strval(trans('firefly.no_block_code')),
- 'bounced' => strval(trans('firefly.block_code_bounced')),
- 'expired' => strval(trans('firefly.block_code_expired')),
- 'email_changed' => strval(trans('firefly.block_code_email_changed')),
+ '' => (string)trans('firefly.no_block_code'),
+ 'bounced' => (string)trans('firefly.block_code_bounced'),
+ 'expired' => (string)trans('firefly.block_code_expired'),
+ 'email_changed' => (string)trans('firefly.block_code_email_changed'),
];
return view('admin.users.edit', compact('user', 'subTitle', 'subTitleIcon', 'codes'));
@@ -115,7 +115,7 @@ class UserController extends Controller
*/
public function index(UserRepositoryInterface $repository)
{
- $subTitle = strval(trans('firefly.user_administration'));
+ $subTitle = (string)trans('firefly.user_administration');
$subTitleIcon = 'fa-users';
$users = $repository->all();
@@ -143,9 +143,9 @@ class UserController extends Controller
*/
public function show(UserRepositoryInterface $repository, User $user)
{
- $title = strval(trans('firefly.administration'));
+ $title = (string)trans('firefly.administration');
$mainTitleIcon = 'fa-hand-spock-o';
- $subTitle = strval(trans('firefly.single_user_administration', ['email' => $user->email]));
+ $subTitle = (string)trans('firefly.single_user_administration', ['email' => $user->email]);
$subTitleIcon = 'fa-user';
$information = $repository->getUserData($user);
@@ -182,10 +182,10 @@ class UserController extends Controller
$repository->changeStatus($user, $data['blocked'], $data['blocked_code']);
$repository->updateEmail($user, $data['email']);
- Session::flash('success', strval(trans('firefly.updated_user', ['email' => $user->email])));
+ Session::flash('success', (string)trans('firefly.updated_user', ['email' => $user->email]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
Session::put('users.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index bce1cde2fe..df25aec1db 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -80,7 +80,6 @@ class AttachmentController extends Controller
* @param Attachment $attachment
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function destroy(Request $request, Attachment $attachment)
{
@@ -88,7 +87,7 @@ class AttachmentController extends Controller
$this->repository->destroy($attachment);
- $request->session()->flash('success', strval(trans('firefly.attachment_deleted', ['name' => $name])));
+ $request->session()->flash('success', (string)trans('firefly.attachment_deleted', ['name' => $name]));
Preferences::mark();
return redirect($this->getPreviousUri('attachments.delete.uri'));
@@ -130,7 +129,6 @@ class AttachmentController extends Controller
* @param Attachment $attachment
*
* @return View
- * @throws \RuntimeException
*/
public function edit(Request $request, Attachment $attachment)
{
@@ -154,17 +152,16 @@ class AttachmentController extends Controller
* @param Attachment $attachment
*
* @return \Illuminate\Http\RedirectResponse
- * @throws \RuntimeException
*/
public function update(AttachmentFormRequest $request, Attachment $attachment)
{
$data = $request->getAttachmentData();
$this->repository->update($attachment, $data);
- $request->session()->flash('success', strval(trans('firefly.attachment_updated', ['name' => $attachment->filename])));
+ $request->session()->flash('success', (string)trans('firefly.attachment_updated', ['name' => $attachment->filename]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
$request->session()->put('attachments.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
index 89bbf55b54..bd870e2b45 100644
--- a/app/Http/Controllers/Auth/ForgotPasswordController.php
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
@@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller
// verify if the user is not a demo user. If so, we give him back an error.
$user = User::where('email', $request->get('email'))->first();
- if (!is_null($user) && $repository->hasRole($user, 'demo')) {
+ if (null !== $user && $repository->hasRole($user, 'demo')) {
return back()->withErrors(['email' => trans('firefly.cannot_reset_demo_user')]);
}
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index 1c621d6866..8b76348ea1 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -65,7 +65,6 @@ class LoginController extends Controller
*
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
*
- * @throws \RuntimeException
* @throws \Illuminate\Validation\ValidationException
*/
public function login(Request $request)
@@ -103,7 +102,6 @@ class LoginController extends Controller
* @param CookieJar $cookieJar
*
* @return $this|\Illuminate\Http\RedirectResponse
- * @throws \RuntimeException
*/
public function logout(Request $request, CookieJar $cookieJar)
{
@@ -121,7 +119,6 @@ class LoginController extends Controller
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
- * @throws \RuntimeException
*/
public function showLoginForm(Request $request)
{
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index f2ebccb86e..7e78ef8f2d 100644
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -83,7 +83,7 @@ class RegisterController extends Controller
$this->guard()->login($user);
- Session::flash('success', strval(trans('firefly.registered')));
+ Session::flash('success', (string)trans('firefly.registered'));
return $this->registered($request, $user)
?: redirect($this->redirectPath());
diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php
index b54e9fdf8a..2ce3ddf14b 100644
--- a/app/Http/Controllers/Auth/TwoFactorController.php
+++ b/app/Http/Controllers/Auth/TwoFactorController.php
@@ -40,7 +40,6 @@ class TwoFactorController extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*
- * @throws \RuntimeException
* @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -52,7 +51,7 @@ class TwoFactorController extends Controller
// to make sure the validator in the next step gets the secret, we push it in session
$secretPreference = Preferences::get('twoFactorAuthSecret', null);
$secret = null === $secretPreference ? null : $secretPreference->data;
- $title = strval(trans('firefly.two_factor_title'));
+ $title = (string)trans('firefly.two_factor_title');
// make sure the user has two factor configured:
$has2FA = Preferences::get('twoFactorAuthEnabled', false)->data;
@@ -60,7 +59,7 @@ class TwoFactorController extends Controller
return redirect(route('index'));
}
- if (0 === strlen(strval($secret))) {
+ if (0 === strlen((string)$secret)) {
throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.');
}
$request->session()->flash('two-factor-secret', $secret);
@@ -75,7 +74,7 @@ class TwoFactorController extends Controller
{
$user = auth()->user();
$siteOwner = env('SITE_OWNER', '');
- $title = strval(trans('firefly.two_factor_forgot_title'));
+ $title = (string)trans('firefly.two_factor_forgot_title');
Log::info(
'To reset the two factor authentication for user #' . $user->id .
@@ -92,7 +91,6 @@ class TwoFactorController extends Controller
*
* @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
- * @throws \RuntimeException
*/
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
{
diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php
index e275a2f2b1..ee3e104bde 100644
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@ -75,7 +75,6 @@ class BillController extends Controller
* @param Request $request
*
* @return View
- * @throws \RuntimeException
*/
public function create(Request $request)
{
@@ -114,14 +113,13 @@ class BillController extends Controller
* @param Bill $bill
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function destroy(Request $request, BillRepositoryInterface $repository, Bill $bill)
{
$name = $bill->name;
$repository->destroy($bill);
- $request->session()->flash('success', strval(trans('firefly.deleted_bill', ['name' => $name])));
+ $request->session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $name]));
Preferences::mark();
return redirect($this->getPreviousUri('bills.delete.uri'));
@@ -132,7 +130,6 @@ class BillController extends Controller
* @param Bill $bill
*
* @return View
- * @throws \RuntimeException
*/
public function edit(Request $request, Bill $bill)
{
@@ -177,7 +174,7 @@ class BillController extends Controller
{
$start = session('start');
$end = session('end');
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$paginator = $repository->getPaginator($pageSize);
$parameters = new ParameterBag();
$parameters->set('start', $start);
@@ -201,12 +198,11 @@ class BillController extends Controller
* @param Bill $bill
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill)
{
- if (0 === intval($bill->active)) {
- $request->session()->flash('warning', strval(trans('firefly.cannot_scan_inactive_bill')));
+ if (0 === (int)$bill->active) {
+ $request->session()->flash('warning', (string)trans('firefly.cannot_scan_inactive_bill'));
return redirect(URL::previous());
}
@@ -217,7 +213,7 @@ class BillController extends Controller
$repository->scan($bill, $journal);
}
- $request->session()->flash('success', strval(trans('firefly.rescanned_bill')));
+ $request->session()->flash('success', (string)trans('firefly.rescanned_bill'));
Preferences::mark();
return redirect(URL::previous());
@@ -236,8 +232,8 @@ class BillController extends Controller
$start = session('start');
$end = session('end');
$year = $start->year;
- $page = intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$yearAverage = $repository->getYearAverage($bill, $start);
$overallAverage = $repository->getOverallAverage($bill);
$manager = new Manager();
@@ -268,13 +264,12 @@ class BillController extends Controller
* @param BillRepositoryInterface $repository
*
* @return \Illuminate\Http\RedirectResponse
- * @throws \RuntimeException
*/
public function store(BillFormRequest $request, BillRepositoryInterface $repository)
{
$billData = $request->getBillData();
$bill = $repository->store($billData);
- $request->session()->flash('success', strval(trans('firefly.stored_new_bill', ['name' => $bill->name])));
+ $request->session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
Preferences::mark();
/** @var array $files */
@@ -286,7 +281,7 @@ class BillController extends Controller
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
}
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
$request->session()->put('bills.create.fromStore', true);
@@ -304,14 +299,13 @@ class BillController extends Controller
* @param Bill $bill
*
* @return \Illuminate\Http\RedirectResponse
- * @throws \RuntimeException
*/
public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill)
{
$billData = $request->getBillData();
$bill = $repository->update($bill, $billData);
- $request->session()->flash('success', strval(trans('firefly.updated_bill', ['name' => $bill->name])));
+ $request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));
Preferences::mark();
/** @var array $files */
@@ -323,7 +317,7 @@ class BillController extends Controller
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
}
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
$request->session()->put('bills.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php
index b4e35b81e2..ebe0ca12e3 100644
--- a/app/Http/Controllers/BudgetController.php
+++ b/app/Http/Controllers/BudgetController.php
@@ -78,11 +78,10 @@ class BudgetController extends Controller
* @param Budget $budget
*
* @return \Illuminate\Http\JsonResponse
- * @throws \InvalidArgumentException
*/
public function amount(Request $request, BudgetRepositoryInterface $repository, Budget $budget)
{
- $amount = strval($request->get('amount'));
+ $amount = (string)$request->get('amount');
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
@@ -106,18 +105,16 @@ class BudgetController extends Controller
$diff = $start->diffInDays($end);
$current = $amount;
if ($diff > 0) {
- $current = bcdiv($amount, strval($diff));
+ $current = bcdiv($amount, (string)$diff);
}
if (bccomp(bcmul('1.1', $average), $current) === -1) {
$largeDiff = true;
- $warnText = strval(
- trans(
- 'firefly.over_budget_warn',
- [
- 'amount' => app('amount')->formatAnything($currency, $average, false),
- 'over_amount' => app('amount')->formatAnything($currency, $current, false),
- ]
- )
+ $warnText = (string)trans(
+ 'firefly.over_budget_warn',
+ [
+ 'amount' => app('amount')->formatAnything($currency, $average, false),
+ 'over_amount' => app('amount')->formatAnything($currency, $current, false),
+ ]
);
}
@@ -142,7 +139,6 @@ class BudgetController extends Controller
* @param Request $request
*
* @return View
- * @throws \RuntimeException
*/
public function create(Request $request)
{
@@ -176,13 +172,12 @@ class BudgetController extends Controller
* @param Budget $budget
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function destroy(Request $request, Budget $budget)
{
$name = $budget->name;
$this->repository->destroy($budget);
- $request->session()->flash('success', strval(trans('firefly.deleted_budget', ['name' => $name])));
+ $request->session()->flash('success', (string)trans('firefly.deleted_budget', ['name' => $name]));
Preferences::mark();
return redirect($this->getPreviousUri('budgets.delete.uri'));
@@ -193,7 +188,6 @@ class BudgetController extends Controller
* @param Budget $budget
*
* @return View
- * @throws \RuntimeException
*/
public function edit(Request $request, Budget $budget)
{
@@ -222,8 +216,8 @@ class BudgetController extends Controller
$range = Preferences::get('viewRange', '1M')->data;
$start = session('start', new Carbon);
$end = session('end', new Carbon);
- $page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
// make date if present:
if (null !== $moment || '' !== (string)$moment) {
@@ -366,7 +360,7 @@ class BudgetController extends Controller
if (0 === $count) {
$count = 1;
}
- $result['available'] = bcdiv($total, strval($count));
+ $result['available'] = bcdiv($total, (string)$count);
// amount earned in this period:
$subDay = clone $end;
@@ -374,13 +368,13 @@ class BudgetController extends Controller
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount();
- $result['earned'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count));
+ $result['earned'] = bcdiv((string)$collector->getJournals()->sum('transaction_amount'), (string)$count);
// amount spent in period
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount();
- $result['spent'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count));
+ $result['spent'] = bcdiv((string)$collector->getJournals()->sum('transaction_amount'), (string)$count);
// suggestion starts with the amount spent
$result['suggested'] = bcmul($result['spent'], '-1');
$result['suggested'] = 1 === bccomp($result['suggested'], $result['earned']) ? $result['earned'] : $result['suggested'];
@@ -439,8 +433,8 @@ class BudgetController extends Controller
);
}
- $page = intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
@@ -456,7 +450,6 @@ class BudgetController extends Controller
* @param BudgetIncomeRequest $request
*
* @return \Illuminate\Http\RedirectResponse
- * @throws \InvalidArgumentException
*/
public function postUpdateIncome(BudgetIncomeRequest $request)
{
@@ -477,7 +470,6 @@ class BudgetController extends Controller
* @param Budget $budget
*
* @return View
- * @throws \InvalidArgumentException
*/
public function show(Request $request, Budget $budget)
{
@@ -508,7 +500,6 @@ class BudgetController extends Controller
*
* @return View
*
- * @throws \InvalidArgumentException
* @throws FireflyException
*/
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
@@ -517,8 +508,8 @@ class BudgetController extends Controller
throw new FireflyException('This budget limit is not part of this budget.');
}
- $page = intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$subTitle = trans(
'firefly.budget_in_period',
[
@@ -546,17 +537,16 @@ class BudgetController extends Controller
* @param BudgetFormRequest $request
*
* @return \Illuminate\Http\RedirectResponse
- * @throws \RuntimeException
*/
public function store(BudgetFormRequest $request)
{
$data = $request->getBudgetData();
$budget = $this->repository->store($data);
$this->repository->cleanupBudgets();
- $request->session()->flash('success', strval(trans('firefly.stored_new_budget', ['name' => $budget->name])));
+ $request->session()->flash('success', (string)trans('firefly.stored_new_budget', ['name' => $budget->name]));
Preferences::mark();
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
$request->session()->put('budgets.create.fromStore', true);
@@ -572,18 +562,17 @@ class BudgetController extends Controller
* @param Budget $budget
*
* @return \Illuminate\Http\RedirectResponse
- * @throws \RuntimeException
*/
public function update(BudgetFormRequest $request, Budget $budget)
{
$data = $request->getBudgetData();
$this->repository->update($budget, $data);
- $request->session()->flash('success', strval(trans('firefly.updated_budget', ['name' => $budget->name])));
+ $request->session()->flash('success', (string)trans('firefly.updated_budget', ['name' => $budget->name]));
$this->repository->cleanupBudgets();
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
$request->session()->put('budgets.edit.fromUpdate', true);
@@ -606,7 +595,7 @@ class BudgetController extends Controller
$defaultCurrency = app('amount')->getDefaultCurrency();
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
$available = round($available, $defaultCurrency->decimal_places);
- $page = intval($request->get('page'));
+ $page = (int)$request->get('page');
return view('budgets.income', compact('available', 'start', 'end', 'page'));
}
@@ -672,7 +661,7 @@ class BudgetController extends Controller
[TransactionType::WITHDRAWAL]
);
$set = $collector->getJournals();
- $sum = strval($set->sum('transaction_amount') ?? '0');
+ $sum = (string)($set->sum('transaction_amount') ?? '0');
$journals = $set->count();
$dateStr = $date['end']->format('Y-m-d');
$dateName = app('navigation')->periodShow($date['end'], $date['period']);
diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php
index bb1bbea092..0598240fd3 100644
--- a/app/Http/Controllers/CategoryController.php
+++ b/app/Http/Controllers/CategoryController.php
@@ -77,7 +77,6 @@ class CategoryController extends Controller
* @param Request $request
*
* @return View
- * @throws \RuntimeException
*/
public function create(Request $request)
{
@@ -110,14 +109,13 @@ class CategoryController extends Controller
* @param Category $category
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function destroy(Request $request, Category $category)
{
$name = $category->name;
$this->repository->destroy($category);
- $request->session()->flash('success', strval(trans('firefly.deleted_category', ['name' => $name])));
+ $request->session()->flash('success', (string)trans('firefly.deleted_category', ['name' => $name]));
Preferences::mark();
return redirect($this->getPreviousUri('categories.delete.uri'));
@@ -128,7 +126,6 @@ class CategoryController extends Controller
* @param Category $category
*
* @return View
- * @throws \RuntimeException
*/
public function edit(Request $request, Category $category)
{
@@ -150,8 +147,8 @@ class CategoryController extends Controller
*/
public function index(Request $request)
{
- $page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$collection = $this->repository->getCategories();
$total = $collection->count();
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
@@ -182,8 +179,8 @@ class CategoryController extends Controller
$start = null;
$end = null;
$periods = new Collection;
- $page = intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
// prep for "all" view.
if ('all' === $moment) {
@@ -239,8 +236,8 @@ class CategoryController extends Controller
// default values:
$subTitle = $category->name;
$subTitleIcon = 'fa-bar-chart';
- $page = intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$range = Preferences::get('viewRange', '1M')->data;
$start = null;
$end = null;
@@ -252,7 +249,7 @@ class CategoryController extends Controller
$subTitle = trans('firefly.all_journals_for_category', ['name' => $category->name]);
$first = $repository->firstUseDate($category);
/** @var Carbon $start */
- $start = null === $first ? new Carbon : $first;
+ $start = $first ?? new Carbon;
$end = new Carbon;
$path = route('categories.show', [$category->id, 'all']);
}
@@ -300,17 +297,16 @@ class CategoryController extends Controller
* @param CategoryRepositoryInterface $repository
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function store(CategoryFormRequest $request, CategoryRepositoryInterface $repository)
{
$data = $request->getCategoryData();
$category = $repository->store($data);
- $request->session()->flash('success', strval(trans('firefly.stored_category', ['name' => $category->name])));
+ $request->session()->flash('success', (string)trans('firefly.stored_category', ['name' => $category->name]));
Preferences::mark();
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
$request->session()->put('categories.create.fromStore', true);
@@ -327,17 +323,16 @@ class CategoryController extends Controller
* @param Category $category
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function update(CategoryFormRequest $request, CategoryRepositoryInterface $repository, Category $category)
{
$data = $request->getCategoryData();
$repository->update($category, $data);
- $request->session()->flash('success', strval(trans('firefly.updated_category', ['name' => $category->name])));
+ $request->session()->flash('success', (string)trans('firefly.updated_category', ['name' => $category->name]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
$request->session()->put('categories.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 6006316482..8e417dfe58 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -93,7 +93,7 @@ class AccountController extends Controller
}
arsort($chartData);
- $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData);
+ $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data);
return response()->json($data);
@@ -124,8 +124,8 @@ class AccountController extends Controller
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- $jrnlBudgetId = intval($transaction->transaction_journal_budget_id);
- $transBudgetId = intval($transaction->transaction_budget_id);
+ $jrnlBudgetId = (int)$transaction->transaction_journal_budget_id;
+ $transBudgetId = (int)$transaction->transaction_budget_id;
$budgetId = max($jrnlBudgetId, $transBudgetId);
$result[$budgetId] = $result[$budgetId] ?? '0';
$result[$budgetId] = bcadd($transaction->transaction_amount, $result[$budgetId]);
@@ -181,8 +181,8 @@ class AccountController extends Controller
$chartData = [];
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- $jrnlCatId = intval($transaction->transaction_journal_category_id);
- $transCatId = intval($transaction->transaction_category_id);
+ $jrnlCatId = (int)$transaction->transaction_journal_category_id;
+ $transCatId = (int)$transaction->transaction_category_id;
$categoryId = max($jrnlCatId, $transCatId);
$result[$categoryId] = $result[$categoryId] ?? '0';
$result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]);
@@ -264,8 +264,8 @@ class AccountController extends Controller
$chartData = [];
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- $jrnlCatId = intval($transaction->transaction_journal_category_id);
- $transCatId = intval($transaction->transaction_category_id);
+ $jrnlCatId = (int)$transaction->transaction_journal_category_id;
+ $transCatId = (int)$transaction->transaction_category_id;
$categoryId = max($jrnlCatId, $transCatId);
$result[$categoryId] = $result[$categoryId] ?? '0';
$result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]);
@@ -336,7 +336,7 @@ class AccountController extends Controller
$theDate = $current->format('Y-m-d');
$balance = $range[$theDate] ?? $previous;
$label = $current->formatLocalized($format);
- $chartData[$label] = floatval($balance);
+ $chartData[$label] = (float)$balance;
$previous = $balance;
$current->addDay();
}
@@ -346,7 +346,7 @@ class AccountController extends Controller
case '1M':
case '1Y':
while ($end >= $current) {
- $balance = floatval(app('steam')->balance($account, $current));
+ $balance = (float)app('steam')->balance($account, $current);
$label = app('navigation')->periodShow($current, $step);
$chartData[$label] = $balance;
$current = app('navigation')->addPeriod($current, $step, 1);
@@ -411,7 +411,7 @@ class AccountController extends Controller
}
arsort($chartData);
- $data = $this->generator->singleSet(strval(trans('firefly.earned')), $chartData);
+ $data = $this->generator->singleSet((string)trans('firefly.earned'), $chartData);
$cache->store($data);
return response()->json($data);
@@ -442,7 +442,7 @@ class AccountController extends Controller
$chartData = [];
foreach ($accounts as $account) {
- $currency = $repository->findNull(intval($account->getMeta('currency_id')));
+ $currency = $repository->findNull((int)$account->getMeta('currency_id'));
$currentSet = [
'label' => $account->name,
'currency_symbol' => $currency->symbol,
@@ -453,7 +453,7 @@ class AccountController extends Controller
$previous = array_values($range)[0];
while ($currentStart <= $end) {
$format = $currentStart->format('Y-m-d');
- $label = $currentStart->formatLocalized(strval(trans('config.month_and_day')));
+ $label = $currentStart->formatLocalized((string)trans('config.month_and_day'));
$balance = isset($range[$format]) ? round($range[$format], 12) : $previous;
$previous = $balance;
$currentStart->addDay();
diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php
index d5794c45a9..b145249092 100644
--- a/app/Http/Controllers/Chart/BillController.php
+++ b/app/Http/Controllers/Chart/BillController.php
@@ -71,8 +71,8 @@ class BillController extends Controller
$paid = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
$unpaid = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
$chartData = [
- strval(trans('firefly.unpaid')) => $unpaid,
- strval(trans('firefly.paid')) => $paid,
+ (string)trans('firefly.unpaid') => $unpaid,
+ (string)trans('firefly.paid') => $paid,
];
$data = $this->generator->pieChart($chartData);
@@ -110,7 +110,7 @@ class BillController extends Controller
/** @var Transaction $entry */
foreach ($results as $entry) {
- $date = $entry->date->formatLocalized(strval(trans('config.month_and_day')));
+ $date = $entry->date->formatLocalized((string)trans('config.month_and_day'));
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
$chartData[2]['entries'][$date] = bcmul($entry->transaction_amount, '-1'); // amount of journal
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index da87461707..379c4efa8a 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -112,12 +112,12 @@ class BudgetController extends Controller
}
$spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $current, $currentEnd);
$label = app('navigation')->periodShow($current, $step);
- $chartData[$label] = floatval(bcmul($spent, '-1'));
+ $chartData[$label] = (float)bcmul($spent, '-1');
$current = clone $currentEnd;
$current->addDay();
}
- $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData);
+ $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data);
@@ -161,12 +161,12 @@ class BudgetController extends Controller
while ($start <= $end) {
$spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $start, $start);
$amount = bcadd($amount, $spent);
- $format = $start->formatLocalized(strval(trans('config.month_and_day')));
+ $format = $start->formatLocalized((string)trans('config.month_and_day'));
$entries[$format] = $amount;
$start->addDay();
}
- $data = $this->generator->singleSet(strval(trans('firefly.left')), $entries);
+ $data = $this->generator->singleSet((string)trans('firefly.left'), $entries);
$cache->store($data);
return response()->json($data);
@@ -200,7 +200,7 @@ class BudgetController extends Controller
$chartData = [];
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- $assetId = intval($transaction->account_id);
+ $assetId = (int)$transaction->account_id;
$result[$assetId] = $result[$assetId] ?? '0';
$result[$assetId] = bcadd($transaction->transaction_amount, $result[$assetId]);
}
@@ -244,8 +244,8 @@ class BudgetController extends Controller
$chartData = [];
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- $jrnlCatId = intval($transaction->transaction_journal_category_id);
- $transCatId = intval($transaction->transaction_category_id);
+ $jrnlCatId = (int)$transaction->transaction_journal_category_id;
+ $transCatId = (int)$transaction->transaction_category_id;
$categoryId = max($jrnlCatId, $transCatId);
$result[$categoryId] = $result[$categoryId] ?? '0';
$result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]);
@@ -290,7 +290,7 @@ class BudgetController extends Controller
$chartData = [];
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- $opposingId = intval($transaction->opposing_account_id);
+ $opposingId = (int)$transaction->opposing_account_id;
$result[$opposingId] = $result[$opposingId] ?? '0';
$result[$opposingId] = bcadd($transaction->transaction_amount, $result[$opposingId]);
}
@@ -329,9 +329,9 @@ class BudgetController extends Controller
}
$budgets = $this->repository->getActiveBudgets();
$chartData = [
- ['label' => strval(trans('firefly.spent_in_budget')), 'entries' => [], 'type' => 'bar'],
- ['label' => strval(trans('firefly.left_to_spend')), 'entries' => [], 'type' => 'bar'],
- ['label' => strval(trans('firefly.overspent')), 'entries' => [], 'type' => 'bar'],
+ ['label' => (string)trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],
+ ['label' => (string)trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],
+ ['label' => (string)trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],
];
/** @var Budget $budget */
@@ -348,7 +348,7 @@ class BudgetController extends Controller
}
// for no budget:
$spent = $this->spentInPeriodWithout($start, $end);
- $name = strval(trans('firefly.no_budget'));
+ $name = (string)trans('firefly.no_budget');
if (0 !== bccomp($spent, '0')) {
$chartData[0]['entries'][$name] = bcmul($spent, '-1');
$chartData[1]['entries'][$name] = '0';
@@ -389,14 +389,14 @@ class BudgetController extends Controller
// join them into one set of data:
$chartData = [
- ['label' => strval(trans('firefly.spent')), 'type' => 'bar', 'entries' => []],
- ['label' => strval(trans('firefly.budgeted')), 'type' => 'bar', 'entries' => []],
+ ['label' => (string)trans('firefly.spent'), 'type' => 'bar', 'entries' => []],
+ ['label' => (string)trans('firefly.budgeted'), 'type' => 'bar', 'entries' => []],
];
foreach (array_keys($periods) as $period) {
$label = $periods[$period];
- $spent = isset($entries[$budget->id]['entries'][$period]) ? $entries[$budget->id]['entries'][$period] : '0';
- $limit = isset($budgeted[$period]) ? $budgeted[$period] : 0;
+ $spent = $entries[$budget->id]['entries'][$period] ?? '0';
+ $limit = (int)($budgeted[$period] ?? 0);
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
$chartData[1]['entries'][$label] = $limit;
}
@@ -433,10 +433,10 @@ class BudgetController extends Controller
// join them:
foreach (array_keys($periods) as $period) {
$label = $periods[$period];
- $spent = isset($entries['entries'][$period]) ? $entries['entries'][$period] : '0';
+ $spent = $entries['entries'][$period] ?? '0';
$chartData[$label] = bcmul($spent, '-1');
}
- $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData);
+ $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data);
return response()->json($data);
@@ -568,7 +568,7 @@ class BudgetController extends Controller
private function spentInPeriodMulti(Budget $budget, Collection $limits): array
{
$return = [];
- $format = strval(trans('config.month_and_day'));
+ $format = (string)trans('config.month_and_day');
$name = $budget->name;
/** @var BudgetLimit $budgetLimit */
foreach ($limits as $budgetLimit) {
diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.php
index e7aaf052a4..e4285a2ef9 100644
--- a/app/Http/Controllers/Chart/BudgetReportController.php
+++ b/app/Http/Controllers/Chart/BudgetReportController.php
@@ -83,7 +83,7 @@ class BudgetReportController extends Controller
$helper->setBudgets($budgets);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'account');
$data = $this->generator->pieChart($chartData);
@@ -107,7 +107,7 @@ class BudgetReportController extends Controller
$helper->setBudgets($budgets);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'budget');
$data = $this->generator->pieChart($chartData);
@@ -141,20 +141,20 @@ class BudgetReportController extends Controller
// prep chart data:
foreach ($budgets as $budget) {
$chartData[$budget->id] = [
- 'label' => strval(trans('firefly.spent_in_specific_budget', ['budget' => $budget->name])),
+ 'label' => (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
$chartData[$budget->id . '-sum'] = [
- 'label' => strval(trans('firefly.sum_of_expenses_in_budget', ['budget' => $budget->name])),
+ 'label' => (string)trans('firefly.sum_of_expenses_in_budget', ['budget' => $budget->name]),
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
'entries' => [],
];
$chartData[$budget->id . '-left'] = [
- 'label' => strval(trans('firefly.left_in_budget_limit', ['budget' => $budget->name])),
+ 'label' => (string)trans('firefly.left_in_budget_limit', ['budget' => $budget->name]),
'type' => 'bar',
'fill' => false,
'yAxisID' => 'y-axis-0',
@@ -182,7 +182,7 @@ class BudgetReportController extends Controller
if (count($budgetLimits) > 0) {
$budgetLimitId = $budgetLimits->first()->id;
- $leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? strval($budgetLimits->sum('amount'));
+ $leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? (string)$budgetLimits->sum('amount');
$leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses);
$chartData[$budget->id . '-left']['entries'][$label] = $leftOfLimits[$budgetLimitId];
}
@@ -244,9 +244,7 @@ class BudgetReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(PositiveAmountFilter::class);
- $transactions = $collector->getJournals();
-
- return $transactions;
+ return $collector->getJournals();
}
/**
@@ -260,8 +258,8 @@ class BudgetReportController extends Controller
$grouped = [];
/** @var Transaction $transaction */
foreach ($set as $transaction) {
- $jrnlBudId = intval($transaction->transaction_journal_budget_id);
- $transBudId = intval($transaction->transaction_budget_id);
+ $jrnlBudId = (int)$transaction->transaction_journal_budget_id;
+ $transBudId = (int)$transaction->transaction_budget_id;
$budgetId = max($jrnlBudId, $transBudId);
$grouped[$budgetId] = $grouped[$budgetId] ?? '0';
$grouped[$budgetId] = bcadd($transaction->transaction_amount, $grouped[$budgetId]);
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index db05731ab0..130c482aea 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -81,17 +81,17 @@ class CategoryController extends Controller
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$chartData = [
[
- 'label' => strval(trans('firefly.spent')),
+ 'label' => (string)trans('firefly.spent'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.earned')),
+ 'label' => (string)trans('firefly.earned'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.sum')),
+ 'label' => (string)trans('firefly.sum'),
'entries' => [],
'type' => 'line',
'fill' => false,
@@ -145,12 +145,12 @@ class CategoryController extends Controller
}
}
- $chartData[strval(trans('firefly.no_category'))] = bcmul($repository->spentInPeriodWithoutCategory(new Collection, $start, $end), '-1');
+ $chartData[(string)trans('firefly.no_category')] = bcmul($repository->spentInPeriodWithoutCategory(new Collection, $start, $end), '-1');
// sort
arsort($chartData);
- $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData);
+ $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
$cache->store($data);
return response()->json($data);
@@ -181,17 +181,17 @@ class CategoryController extends Controller
$periods = app('navigation')->listOfPeriods($start, $end);
$chartData = [
[
- 'label' => strval(trans('firefly.spent')),
+ 'label' => (string)trans('firefly.spent'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.earned')),
+ 'label' => (string)trans('firefly.earned'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.sum')),
+ 'label' => (string)trans('firefly.sum'),
'entries' => [],
'type' => 'line',
'fill' => false,
@@ -237,17 +237,17 @@ class CategoryController extends Controller
$periods = app('navigation')->listOfPeriods($start, $end);
$chartData = [
[
- 'label' => strval(trans('firefly.spent')),
+ 'label' => (string)trans('firefly.spent'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.earned')),
+ 'label' => (string)trans('firefly.earned'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.sum')),
+ 'label' => (string)trans('firefly.sum'),
'entries' => [],
'type' => 'line',
'fill' => false,
@@ -313,17 +313,17 @@ class CategoryController extends Controller
// chart data
$chartData = [
[
- 'label' => strval(trans('firefly.spent')),
+ 'label' => (string)trans('firefly.spent'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.earned')),
+ 'label' => (string)trans('firefly.earned'),
'entries' => [],
'type' => 'bar',
],
[
- 'label' => strval(trans('firefly.sum')),
+ 'label' => (string)trans('firefly.sum'),
'entries' => [],
'type' => 'line',
'fill' => false,
diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.php
index d2405d2af5..a62db6c9c4 100644
--- a/app/Http/Controllers/Chart/CategoryReportController.php
+++ b/app/Http/Controllers/Chart/CategoryReportController.php
@@ -75,7 +75,7 @@ class CategoryReportController extends Controller
{
/** @var MetaPieChartInterface $helper */
$helper = app(MetaPieChartInterface::class);
- $helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === intval($others));
+ $helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'account');
$data = $this->generator->pieChart($chartData);
@@ -100,7 +100,7 @@ class CategoryReportController extends Controller
$helper->setCategories($categories);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'account');
$data = $this->generator->pieChart($chartData);
@@ -124,7 +124,7 @@ class CategoryReportController extends Controller
$helper->setCategories($categories);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'category');
$data = $this->generator->pieChart($chartData);
@@ -148,7 +148,7 @@ class CategoryReportController extends Controller
$helper->setCategories($categories);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'category');
$data = $this->generator->pieChart($chartData);
@@ -183,27 +183,27 @@ class CategoryReportController extends Controller
// prep chart data:
foreach ($categories as $category) {
$chartData[$category->id . '-in'] = [
- 'label' => $category->name . ' (' . strtolower(strval(trans('firefly.income'))) . ')',
+ 'label' => $category->name . ' (' . strtolower((string)trans('firefly.income')) . ')',
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
$chartData[$category->id . '-out'] = [
- 'label' => $category->name . ' (' . strtolower(strval(trans('firefly.expenses'))) . ')',
+ 'label' => $category->name . ' (' . strtolower((string)trans('firefly.expenses')) . ')',
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
// total in, total out:
$chartData[$category->id . '-total-in'] = [
- 'label' => $category->name . ' (' . strtolower(strval(trans('firefly.sum_of_income'))) . ')',
+ 'label' => $category->name . ' (' . strtolower((string)trans('firefly.sum_of_income')) . ')',
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
'entries' => [],
];
$chartData[$category->id . '-total-out'] = [
- 'label' => $category->name . ' (' . strtolower(strval(trans('firefly.sum_of_expenses'))) . ')',
+ 'label' => $category->name . ' (' . strtolower((string)trans('firefly.sum_of_expenses')) . ')',
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
@@ -279,9 +279,7 @@ class CategoryReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(PositiveAmountFilter::class);
- $transactions = $collector->getJournals();
-
- return $transactions;
+ return $collector->getJournals();
}
/**
@@ -302,9 +300,7 @@ class CategoryReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(NegativeAmountFilter::class);
- $transactions = $collector->getJournals();
-
- return $transactions;
+ return $collector->getJournals();
}
/**
@@ -318,8 +314,8 @@ class CategoryReportController extends Controller
$grouped = [];
/** @var Transaction $transaction */
foreach ($set as $transaction) {
- $jrnlCatId = intval($transaction->transaction_journal_category_id);
- $transCatId = intval($transaction->transaction_category_id);
+ $jrnlCatId = (int)$transaction->transaction_journal_category_id;
+ $transCatId = (int)$transaction->transaction_category_id;
$categoryId = max($jrnlCatId, $transCatId);
$grouped[$categoryId] = $grouped[$categoryId] ?? '0';
$grouped[$categoryId] = bcadd($transaction->transaction_amount, $grouped[$categoryId]);
diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php
index 3772e5c5c0..031d5f113b 100644
--- a/app/Http/Controllers/Chart/ExpenseReportController.php
+++ b/app/Http/Controllers/Chart/ExpenseReportController.php
@@ -100,27 +100,27 @@ class ExpenseReportController extends Controller
/** @var Account $exp */
$exp = $combi->first();
$chartData[$exp->id . '-in'] = [
- 'label' => $name . ' (' . strtolower(strval(trans('firefly.income'))) . ')',
+ 'label' => $name . ' (' . strtolower((string)trans('firefly.income')) . ')',
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
$chartData[$exp->id . '-out'] = [
- 'label' => $name . ' (' . strtolower(strval(trans('firefly.expenses'))) . ')',
+ 'label' => $name . ' (' . strtolower((string)trans('firefly.expenses')) . ')',
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
// total in, total out:
$chartData[$exp->id . '-total-in'] = [
- 'label' => $name . ' (' . strtolower(strval(trans('firefly.sum_of_income'))) . ')',
+ 'label' => $name . ' (' . strtolower((string)trans('firefly.sum_of_income')) . ')',
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
'entries' => [],
];
$chartData[$exp->id . '-total-out'] = [
- 'label' => $name . ' (' . strtolower(strval(trans('firefly.sum_of_expenses'))) . ')',
+ 'label' => $name . ' (' . strtolower((string)trans('firefly.sum_of_expenses')) . ')',
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
@@ -196,7 +196,7 @@ class ExpenseReportController extends Controller
$collection->push($expenseAccount);
$revenue = $this->accountRepository->findByName($expenseAccount->name, [AccountType::REVENUE]);
- if (!is_null($revenue)) {
+ if (null !== $revenue) {
$collection->push($revenue);
}
$combined[$expenseAccount->name] = $collection;
@@ -219,9 +219,7 @@ class ExpenseReportController extends Controller
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setOpposingAccounts($opposing);
- $transactions = $collector->getJournals();
-
- return $transactions;
+ return $collector->getJournals();
}
/**
@@ -239,9 +237,7 @@ class ExpenseReportController extends Controller
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setOpposingAccounts($opposing);
- $transactions = $collector->getJournals();
-
- return $transactions;
+ return $collector->getJournals();
}
/**
diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.php
index 12beec2072..37beb074ce 100644
--- a/app/Http/Controllers/Chart/PiggyBankController.php
+++ b/app/Http/Controllers/Chart/PiggyBankController.php
@@ -71,7 +71,7 @@ class PiggyBankController extends Controller
$sum = '0';
/** @var PiggyBankEvent $entry */
foreach ($set as $entry) {
- $label = $entry->date->formatLocalized(strval(trans('config.month_and_day')));
+ $label = $entry->date->formatLocalized((string)trans('config.month_and_day'));
$sum = bcadd($sum, $entry->amount);
$chartData[$label] = $sum;
}
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php
index 5120b807bf..30c5657d59 100644
--- a/app/Http/Controllers/Chart/ReportController.php
+++ b/app/Http/Controllers/Chart/ReportController.php
@@ -75,12 +75,12 @@ class ReportController extends Controller
while ($current < $end) {
$balances = Steam::balancesByAccounts($accounts, $current);
$sum = $this->arraySum($balances);
- $label = $current->formatLocalized(strval(trans('config.month_and_day')));
+ $label = $current->formatLocalized((string)trans('config.month_and_day'));
$chartData[$label] = $sum;
$current->addDays(7);
}
- $data = $this->generator->singleSet(strval(trans('firefly.net_worth')), $chartData);
+ $data = $this->generator->singleSet((string)trans('firefly.net_worth'), $chartData);
$cache->store($data);
return response()->json($data);
@@ -188,19 +188,19 @@ class ReportController extends Controller
$chartData = [
[
- 'label' => strval(trans('firefly.income')),
+ 'label' => (string)trans('firefly.income'),
'type' => 'bar',
'entries' => [
- strval(trans('firefly.sum_of_period')) => $numbers['sum_earned'],
- strval(trans('firefly.average_in_period')) => $numbers['avg_earned'],
+ (string)trans('firefly.sum_of_period') => $numbers['sum_earned'],
+ (string)trans('firefly.average_in_period') => $numbers['avg_earned'],
],
],
[
'label' => trans('firefly.expenses'),
'type' => 'bar',
'entries' => [
- strval(trans('firefly.sum_of_period')) => $numbers['sum_spent'],
- strval(trans('firefly.average_in_period')) => $numbers['avg_spent'],
+ (string)trans('firefly.sum_of_period') => $numbers['sum_spent'],
+ (string)trans('firefly.average_in_period') => $numbers['avg_spent'],
],
],
];
@@ -255,25 +255,21 @@ class ReportController extends Controller
while ($currentStart <= $end) {
$currentEnd = app('navigation')->endOfPeriod($currentStart, '1M');
- $earned = strval(
- array_sum(
- array_map(
- function ($item) {
- return $item['sum'];
- },
- $tasker->getIncomeReport($currentStart, $currentEnd, $accounts)
- )
+ $earned = (string)array_sum(
+ array_map(
+ function ($item) {
+ return $item['sum'];
+ },
+ $tasker->getIncomeReport($currentStart, $currentEnd, $accounts)
)
);
- $spent = strval(
- array_sum(
- array_map(
- function ($item) {
- return $item['sum'];
- },
- $tasker->getExpenseReport($currentStart, $currentEnd, $accounts)
- )
+ $spent = (string)array_sum(
+ array_map(
+ function ($item) {
+ return $item['sum'];
+ },
+ $tasker->getExpenseReport($currentStart, $currentEnd, $accounts)
)
);
diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.php
index 58a7d2c7eb..ceb4b52105 100644
--- a/app/Http/Controllers/Chart/TagReportController.php
+++ b/app/Http/Controllers/Chart/TagReportController.php
@@ -72,7 +72,7 @@ class TagReportController extends Controller
$helper->setTags($tags);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'account');
$data = $this->generator->pieChart($chartData);
@@ -96,7 +96,7 @@ class TagReportController extends Controller
$helper->setTags($tags);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'account');
$data = $this->generator->pieChart($chartData);
@@ -177,27 +177,27 @@ class TagReportController extends Controller
// prep chart data:
foreach ($tags as $tag) {
$chartData[$tag->id . '-in'] = [
- 'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.income'))) . ')',
+ 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.income')) . ')',
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
$chartData[$tag->id . '-out'] = [
- 'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.expenses'))) . ')',
+ 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.expenses')) . ')',
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
// total in, total out:
$chartData[$tag->id . '-total-in'] = [
- 'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.sum_of_income'))) . ')',
+ 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.sum_of_income')) . ')',
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
'entries' => [],
];
$chartData[$tag->id . '-total-out'] = [
- 'label' => $tag->tag . ' (' . strtolower(strval(trans('firefly.sum_of_expenses'))) . ')',
+ 'label' => $tag->tag . ' (' . strtolower((string)trans('firefly.sum_of_expenses')) . ')',
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
@@ -271,7 +271,7 @@ class TagReportController extends Controller
$helper->setTags($tags);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'tag');
$data = $this->generator->pieChart($chartData);
@@ -295,7 +295,7 @@ class TagReportController extends Controller
$helper->setTags($tags);
$helper->setStart($start);
$helper->setEnd($end);
- $helper->setCollectOtherObjects(1 === intval($others));
+ $helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'tag');
$data = $this->generator->pieChart($chartData);
@@ -321,9 +321,7 @@ class TagReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(PositiveAmountFilter::class);
- $transactions = $collector->getJournals();
-
- return $transactions;
+ return $collector->getJournals();
}
/**
@@ -344,9 +342,7 @@ class TagReportController extends Controller
$collector->addFilter(OpposingAccountFilter::class);
$collector->addFilter(NegativeAmountFilter::class);
- $transactions = $collector->getJournals();
-
- return $transactions;
+ return $collector->getJournals();
}
/**
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 02e8aa7793..851a8efff5 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -121,7 +121,7 @@ class Controller extends BaseController
*/
protected function getPreviousUri(string $identifier): string
{
- $uri = strval(session($identifier));
+ $uri = (string)session($identifier);
if (!(false === strpos($identifier, 'delete')) && !(false === strpos($uri, '/show/'))) {
$uri = $this->redirectUri;
}
@@ -159,7 +159,7 @@ class Controller extends BaseController
}
}
// @codeCoverageIgnoreStart
- Session::flash('error', strval(trans('firefly.cannot_redirect_to_account')));
+ Session::flash('error', (string)trans('firefly.cannot_redirect_to_account'));
return redirect(route('index'));
// @codeCoverageIgnoreEnd
diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php
index 1a2ce4c916..67d62ea22f 100644
--- a/app/Http/Controllers/CurrencyController.php
+++ b/app/Http/Controllers/CurrencyController.php
@@ -67,7 +67,6 @@ class CurrencyController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
- * @throws \RuntimeException
*/
public function create(Request $request)
{
@@ -94,7 +93,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function defaultCurrency(Request $request, TransactionCurrency $currency)
{
@@ -113,7 +111,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
- * @throws \RuntimeException
*/
public function delete(Request $request, TransactionCurrency $currency)
{
@@ -143,7 +140,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function destroy(Request $request, TransactionCurrency $currency)
{
@@ -172,7 +168,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
- * @throws \RuntimeException
*/
public function edit(Request $request, TransactionCurrency $currency)
{
@@ -201,12 +196,11 @@ class CurrencyController extends Controller
* @param Request $request
*
* @return View
- * @throws \RuntimeException
*/
public function index(Request $request)
{
- $page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$collection = $this->repository->get();
$total = $collection->count();
$collection = $collection->sortBy(
@@ -232,7 +226,6 @@ class CurrencyController extends Controller
* @param CurrencyFormRequest $request
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function store(CurrencyFormRequest $request)
{
@@ -248,7 +241,7 @@ class CurrencyController extends Controller
$currency = $this->repository->store($data);
$request->session()->flash('success', trans('firefly.created_currency', ['name' => $currency->name]));
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
$request->session()->put('currencies.create.fromStore', true);
@@ -264,7 +257,6 @@ class CurrencyController extends Controller
* @param TransactionCurrency $currency
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function update(CurrencyFormRequest $request, TransactionCurrency $currency)
{
@@ -281,7 +273,7 @@ class CurrencyController extends Controller
$request->session()->flash('success', trans('firefly.updated_currency', ['name' => $currency->name]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
$request->session()->put('currencies.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 38bf6e7fea..4a56acf427 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -50,7 +50,6 @@ class DebugController extends Controller
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
- * @throws \InvalidArgumentException
*/
public function index(Request $request)
{
@@ -69,7 +68,7 @@ class DebugController extends Controller
$isDocker = var_export(env('IS_DOCKER', 'unknown'), true);
$trustedProxies = env('TRUSTED_PROXIES', '(none)');
$displayErrors = ini_get('display_errors');
- $errorReporting = $this->errorReporting(intval(ini_get('error_reporting')));
+ $errorReporting = $this->errorReporting((int)ini_get('error_reporting'));
$appEnv = env('APP_ENV', '');
$appDebug = var_export(env('APP_DEBUG', false), true);
$appLog = env('APP_LOG', '');
@@ -156,7 +155,7 @@ class DebugController extends Controller
return $array[$value];
}
- return strval($value); // @codeCoverageIgnore
+ return (string)$value; // @codeCoverageIgnore
}
/**
diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php
index 4cb9e5c422..3ff7d4f982 100644
--- a/app/Http/Controllers/ExportController.php
+++ b/app/Http/Controllers/ExportController.php
@@ -111,7 +111,6 @@ class ExportController extends Controller
* @param ExportJobRepositoryInterface $jobs
*
* @return View
- * @throws \InvalidArgumentException
*/
public function index(AccountRepositoryInterface $repository, ExportJobRepositoryInterface $jobs)
{
@@ -121,7 +120,7 @@ class ExportController extends Controller
$jobs->cleanup();
// does the user have shared accounts?
- $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
+ $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$accountList = ExpandedForm::makeSelectList($accounts);
$checked = array_keys($accountList);
$formats = array_keys(config('firefly.export_formats'));
diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php
index 1f7e13f4b9..eb13a6a623 100644
--- a/app/Http/Controllers/HelpController.php
+++ b/app/Http/Controllers/HelpController.php
@@ -72,7 +72,7 @@ class HelpController extends Controller
private function getHelpText(string $route, string $language): string
{
// get language and default variables.
- $content = '<p>' . strval(trans('firefly.route_has_no_help')) . '</p>';
+ $content = '<p>' . (string)trans('firefly.route_has_no_help') . '</p>';
// if no such route, log error and return default text.
if (!$this->help->hasRoute($route)) {
@@ -114,6 +114,6 @@ class HelpController extends Controller
return $content;
}
- return '<p>' . strval(trans('firefly.route_has_no_help')) . '</p>';
+ return '<p>' . (string)trans('firefly.route_has_no_help') . '</p>';
}
}
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index a32d290b40..f47bce951f 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -62,7 +62,6 @@ class HomeController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
- * @throws \RuntimeException
*/
public function dateRange(Request $request)
{
@@ -75,7 +74,7 @@ class HomeController extends Controller
// check if the label is "everything" or "Custom range" which will betray
// a possible problem with the budgets.
- if ($label === strval(trans('firefly.everything')) || $label === strval(trans('firefly.customRange'))) {
+ if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) {
$isCustomRange = true;
Log::debug('Range is now marked as "custom".');
}
@@ -83,7 +82,7 @@ class HomeController extends Controller
$diff = $start->diffInDays($end);
if ($diff > 50) {
- $request->session()->flash('warning', strval(trans('firefly.warning_much_data', ['days' => $diff])));
+ $request->session()->flash('warning', (string)trans('firefly.warning_much_data', ['days' => $diff]));
}
$request->session()->put('is_custom_range', $isCustomRange);
@@ -117,7 +116,6 @@ class HomeController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function flush(Request $request)
{
@@ -232,7 +230,6 @@ class HomeController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function testFlash(Request $request)
{
diff --git a/app/Http/Controllers/Import/ConfigurationController.php b/app/Http/Controllers/Import/ConfigurationController.php
index 3c3df4f9c5..8450c26aab 100644
--- a/app/Http/Controllers/Import/ConfigurationController.php
+++ b/app/Http/Controllers/Import/ConfigurationController.php
@@ -97,7 +97,6 @@ class ConfigurationController extends Controller
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
- * @throws \RuntimeException
* @throws FireflyException
*/
public function post(Request $request, ImportJob $job)
diff --git a/app/Http/Controllers/Import/PrerequisitesController.php b/app/Http/Controllers/Import/PrerequisitesController.php
index 81065bb670..76b4973321 100644
--- a/app/Http/Controllers/Import/PrerequisitesController.php
+++ b/app/Http/Controllers/Import/PrerequisitesController.php
@@ -69,7 +69,7 @@ class PrerequisitesController extends Controller
if (true === !config(sprintf('import.enabled.%s', $bank))) {
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore
}
- $class = strval(config(sprintf('import.prerequisites.%s', $bank)));
+ $class = (string)config(sprintf('import.prerequisites.%s', $bank));
if (!class_exists($class)) {
throw new FireflyException(sprintf('No class to handle "%s".', $bank)); // @codeCoverageIgnore
}
@@ -80,7 +80,7 @@ class PrerequisitesController extends Controller
if ($object->hasPrerequisites()) {
$view = $object->getView();
- $parameters = ['title' => strval(trans('firefly.import_index_title')), 'mainTitleIcon' => 'fa-archive'];
+ $parameters = ['title' => (string)trans('firefly.import_index_title'), 'mainTitleIcon' => 'fa-archive'];
$parameters = array_merge($object->getViewParameters(), $parameters);
return view($view, $parameters);
@@ -103,7 +103,6 @@ class PrerequisitesController extends Controller
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
- * @throws \RuntimeException
* @throws FireflyException
*/
public function post(Request $request, string $bank)
@@ -114,7 +113,7 @@ class PrerequisitesController extends Controller
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore
}
- $class = strval(config(sprintf('import.prerequisites.%s', $bank)));
+ $class = (string)config(sprintf('import.prerequisites.%s', $bank));
if (!class_exists($class)) {
throw new FireflyException(sprintf('Cannot find class %s', $class)); // @codeCoverageIgnore
}
diff --git a/app/Http/Controllers/Import/StatusController.php b/app/Http/Controllers/Import/StatusController.php
index d476cd3578..6c33e3695a 100644
--- a/app/Http/Controllers/Import/StatusController.php
+++ b/app/Http/Controllers/Import/StatusController.php
@@ -97,7 +97,7 @@ class StatusController extends Controller
}
if ('finished' === $job->status) {
$result['finished'] = true;
- $tagId = intval($job->extended_status['tag']);
+ $tagId = (int)$job->extended_status['tag'];
if ($tagId !== 0) {
/** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class);
diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php
index 4fcdc4f734..d47992d9ed 100644
--- a/app/Http/Controllers/JavascriptController.php
+++ b/app/Http/Controllers/JavascriptController.php
@@ -54,7 +54,7 @@ class JavascriptController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$accountId = $account->id;
- $currency = intval($repository->getMetaValue($account, 'currency_id'));
+ $currency = (int)$repository->getMetaValue($account, 'currency_id');
$currency = 0 === $currency ? $default->id : $currency;
$entry = ['preferredCurrency' => $currency, 'name' => $account->name];
$data['accounts'][$accountId] = $entry;
@@ -92,14 +92,13 @@ class JavascriptController extends Controller
* @param CurrencyRepositoryInterface $currencyRepository
*
* @return \Illuminate\Http\Response
- * @throws \RuntimeException
*/
public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository)
{
- $account = $repository->findNull(intval($request->get('account')));
+ $account = $repository->findNull((int)$request->get('account'));
$currencyId = 0;
if (null !== $account) {
- $currencyId = intval($repository->getMetaValue($account, 'currency_id'));
+ $currencyId = (int)$repository->getMetaValue($account, 'currency_id');
}
/** @var TransactionCurrency $currency */
$currency = $currencyRepository->findNull($currencyId);
@@ -175,21 +174,21 @@ class JavascriptController extends Controller
$todayStart = app('navigation')->startOfPeriod($today, $viewRange);
$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);
if ($todayStart->ne($start) || $todayEnd->ne($end)) {
- $ranges[ucfirst(strval(trans('firefly.today')))] = [$todayStart, $todayEnd];
+ $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];
}
// everything
- $index = strval(trans('firefly.everything'));
+ $index = (string)trans('firefly.everything');
$ranges[$index] = [$first, new Carbon];
$return = [
'title' => $title,
'configuration' => [
- 'apply' => strval(trans('firefly.apply')),
- 'cancel' => strval(trans('firefly.cancel')),
- 'from' => strval(trans('firefly.from')),
- 'to' => strval(trans('firefly.to')),
- 'customRange' => strval(trans('firefly.customRange')),
+ 'apply' => (string)trans('firefly.apply'),
+ 'cancel' => (string)trans('firefly.cancel'),
+ 'from' => (string)trans('firefly.from'),
+ 'to' => (string)trans('firefly.to'),
+ 'customRange' => (string)trans('firefly.customRange'),
'start' => $start->format('Y-m-d'),
'end' => $end->format('Y-m-d'),
'ranges' => $ranges,
diff --git a/app/Http/Controllers/Json/AutoCompleteController.php b/app/Http/Controllers/Json/AutoCompleteController.php
index 2efcc72696..2a0b712545 100644
--- a/app/Http/Controllers/Json/AutoCompleteController.php
+++ b/app/Http/Controllers/Json/AutoCompleteController.php
@@ -113,7 +113,7 @@ class AutoCompleteController extends Controller
$set = $collector->getJournals()->pluck('description', 'journal_id')->toArray();
$return = [];
foreach ($set as $id => $description) {
- $id = intval($id);
+ $id = (int)$id;
if ($id !== $except->id) {
$return[] = [
'id' => $id,
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index dbd80ec03e..132ea0c829 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -123,7 +123,7 @@ class BoxController extends Controller
$set = $collector->getJournals();
/** @var Transaction $transaction */
foreach ($set as $transaction) {
- $currencyId = intval($transaction->transaction_currency_id);
+ $currencyId = (int)$transaction->transaction_currency_id;
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes[$currencyId] = bcadd($incomes[$currencyId], $transaction->transaction_amount);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
diff --git a/app/Http/Controllers/Json/ExchangeController.php b/app/Http/Controllers/Json/ExchangeController.php
index 7752fec71e..e4846f43f7 100644
--- a/app/Http/Controllers/Json/ExchangeController.php
+++ b/app/Http/Controllers/Json/ExchangeController.php
@@ -50,9 +50,6 @@ class ExchangeController extends Controller
$rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date);
-
-
-
if (null === $rate->id) {
Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
@@ -69,7 +66,7 @@ class ExchangeController extends Controller
$return['amount'] = null;
if (null !== $request->get('amount')) {
// assume amount is in "from" currency:
- $return['amount'] = bcmul($request->get('amount'), strval($rate->rate), 12);
+ $return['amount'] = bcmul($request->get('amount'), (string)$rate->rate, 12);
// round to toCurrency decimal places:
$return['amount'] = round($return['amount'], $toCurrency->decimal_places);
}
diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.php
index 0fef3453eb..0051608c91 100644
--- a/app/Http/Controllers/Json/FrontpageController.php
+++ b/app/Http/Controllers/Json/FrontpageController.php
@@ -36,7 +36,7 @@ class FrontpageController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*
- * @throws \Throwable
+
*/
public function piggyBanks(PiggyBankRepositoryInterface $repository)
{
diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.php
index 2a8d2b5bf9..6b1c6c1be1 100644
--- a/app/Http/Controllers/Json/IntroController.php
+++ b/app/Http/Controllers/Json/IntroController.php
@@ -76,14 +76,17 @@ class IntroController
$routeKey = str_replace('.', '_', $route);
Log::debug(sprintf('Has outro step for route %s', $routeKey));
$elements = config(sprintf('intro.%s', $routeKey));
- if (!is_array($elements)) {
+ if (!\is_array($elements)) {
return false;
}
+
+ $hasStep = array_key_exists('outro', $elements);
+
Log::debug('Elements is array', $elements);
Log::debug('Keys is', array_keys($elements));
- Log::debug(sprintf('Keys has "outro": %s', var_export(in_array('outro', array_keys($elements)), true)));
+ Log::debug(sprintf('Keys has "outro": %s', var_export($hasStep, true)));
- return in_array('outro', array_keys($elements));
+ return $hasStep;
}
/**
diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php
index 33c5ce17ac..199d342d48 100644
--- a/app/Http/Controllers/JsonController.php
+++ b/app/Http/Controllers/JsonController.php
@@ -33,24 +33,16 @@ use Illuminate\Http\Request;
*/
class JsonController extends Controller
{
- /**
- * JsonController constructor.
- */
- public function __construct()
- {
- parent::__construct();
- }
-
/**
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*
- * @throws \Throwable
+
*/
public function action(Request $request)
{
- $count = intval($request->get('count')) > 0 ? intval($request->get('count')) : 1;
+ $count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1;
$keys = array_keys(config('firefly.rule-actions'));
$actions = [];
foreach ($keys as $key) {
@@ -122,11 +114,11 @@ class JsonController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*
- * @throws \Throwable
+
*/
public function trigger(Request $request)
{
- $count = intval($request->get('count')) > 0 ? intval($request->get('count')) : 1;
+ $count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1;
$keys = array_keys(config('firefly.rule-triggers'));
$triggers = [];
foreach ($keys as $key) {
diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php
index 341c3b7852..2be34e546d 100644
--- a/app/Http/Controllers/NewUserController.php
+++ b/app/Http/Controllers/NewUserController.php
@@ -85,7 +85,7 @@ class NewUserController extends Controller
$this->createSavingsAccount($request, $repository);
// also store currency preference from input:
- $currency = $currencyRepository->findNull(intval($request->input('amount_currency_id_bank_balance')));
+ $currency = $currencyRepository->findNull((int)$request->input('amount_currency_id_bank_balance'));
if (null !== $currency) {
// store currency preference:
@@ -107,7 +107,7 @@ class NewUserController extends Controller
];
Preferences::set('transaction_journal_optional_fields', $visibleFields);
- Session::flash('success', strval(trans('firefly.stored_new_accounts_new_user')));
+ Session::flash('success', (string)trans('firefly.stored_new_accounts_new_user'));
Preferences::mark();
return redirect(route('index'));
@@ -131,7 +131,7 @@ class NewUserController extends Controller
'accountRole' => 'defaultAsset',
'openingBalance' => $request->input('bank_balance'),
'openingBalanceDate' => new Carbon,
- 'currency_id' => intval($request->input('amount_currency_id_bank_balance')),
+ 'currency_id' => (int)$request->input('amount_currency_id_bank_balance'),
];
$repository->store($assetAccount);
@@ -157,7 +157,7 @@ class NewUserController extends Controller
'accountRole' => 'savingAsset',
'openingBalance' => $request->input('savings_balance'),
'openingBalanceDate' => new Carbon,
- 'currency_id' => intval($request->input('amount_currency_id_bank_balance')),
+ 'currency_id' => (int)$request->input('amount_currency_id_bank_balance'),
];
$repository->store($savingsAccount);
diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php
index d81ed60593..f4e587cd33 100644
--- a/app/Http/Controllers/PiggyBankController.php
+++ b/app/Http/Controllers/PiggyBankController.php
@@ -83,6 +83,7 @@ class PiggyBankController extends Controller
* @param PiggyBank $piggyBank
*
* @param PiggyBankRepositoryInterface $repository
+ *
* @return View
*/
public function addMobile(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
@@ -137,7 +138,7 @@ class PiggyBankController extends Controller
*/
public function destroy(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
- Session::flash('success', strval(trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name])));
+ Session::flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
Preferences::mark();
$repository->destroy($piggyBank);
@@ -192,8 +193,8 @@ class PiggyBankController extends Controller
{
$collection = $piggyRepository->getPiggyBanks();
$total = $collection->count();
- $page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
@@ -203,8 +204,8 @@ class PiggyBankController extends Controller
foreach ($collection as $piggyBank) {
$piggyBank->savedSoFar = $piggyRepository->getCurrentAmount($piggyBank);
- $piggyBank->percentage = 0 !== bccomp('0', $piggyBank->savedSoFar) ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
- $piggyBank->leftToSave = bcsub($piggyBank->targetamount, strval($piggyBank->savedSoFar));
+ $piggyBank->percentage = 0 !== bccomp('0', $piggyBank->savedSoFar) ? (int)$piggyBank->savedSoFar / $piggyBank->targetamount * 100 : 0;
+ $piggyBank->leftToSave = bcsub($piggyBank->targetamount, (string)$piggyBank->savedSoFar);
$piggyBank->percentage = $piggyBank->percentage > 100 ? 100 : $piggyBank->percentage;
// Fill account information:
@@ -216,13 +217,13 @@ class PiggyBankController extends Controller
'name' => $account->name,
'balance' => Steam::balanceIgnoreVirtual($account, $end),
'leftForPiggyBanks' => $piggyBank->leftOnAccount($end),
- 'sumOfSaved' => strval($piggyBank->savedSoFar),
+ 'sumOfSaved' => (string)$piggyBank->savedSoFar,
'sumOfTargets' => $piggyBank->targetamount,
'leftToSave' => $piggyBank->leftToSave,
];
}
if (isset($accounts[$account->id]) && false === $new) {
- $accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], strval($piggyBank->savedSoFar));
+ $accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], (string)$piggyBank->savedSoFar);
$accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount);
$accounts[$account->id]['leftToSave'] = bcadd($accounts[$account->id]['leftToSave'], $piggyBank->leftToSave);
}
@@ -251,7 +252,7 @@ class PiggyBankController extends Controller
if (is_array($data)) {
foreach ($data as $order => $id) {
- $repository->setOrder(intval($id), $order + 1);
+ $repository->setOrder((int)$id, $order + 1);
}
}
@@ -273,11 +274,9 @@ class PiggyBankController extends Controller
$repository->addAmount($piggyBank, $amount);
Session::flash(
'success',
- strval(
- trans(
- 'firefly.added_amount_to_piggy',
- ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
- )
+ (string)trans(
+ 'firefly.added_amount_to_piggy',
+ ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
);
Preferences::mark();
@@ -288,11 +287,9 @@ class PiggyBankController extends Controller
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
Session::flash(
'error',
- strval(
- trans(
- 'firefly.cannot_add_amount_piggy',
- ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
- )
+ (string)trans(
+ 'firefly.cannot_add_amount_piggy',
+ ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
);
@@ -314,11 +311,9 @@ class PiggyBankController extends Controller
$repository->removeAmount($piggyBank, $amount);
Session::flash(
'success',
- strval(
- trans(
- 'firefly.removed_amount_from_piggy',
- ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
- )
+ (string)trans(
+ 'firefly.removed_amount_from_piggy',
+ ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
);
Preferences::mark();
@@ -326,15 +321,13 @@ class PiggyBankController extends Controller
return redirect(route('piggy-banks.index'));
}
- $amount = strval(round($request->get('amount'), 12));
+ $amount = (string)round($request->get('amount'), 12);
Session::flash(
'error',
- strval(
- trans(
- 'firefly.cannot_remove_from_piggy',
- ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
- )
+ (string)trans(
+ 'firefly.cannot_remove_from_piggy',
+ ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
);
@@ -392,10 +385,10 @@ class PiggyBankController extends Controller
}
$piggyBank = $repository->store($data);
- Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name])));
+ Session::flash('success', (string)trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
Preferences::mark();
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
Session::put('piggy-banks.create.fromStore', true);
@@ -418,10 +411,10 @@ class PiggyBankController extends Controller
$data = $request->getPiggyBankData();
$piggyBank = $repository->update($piggyBank, $data);
- Session::flash('success', strval(trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name])));
+ Session::flash('success', (string)trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
Session::put('piggy-banks.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.php
index 456be43bec..b20a9b15a0 100644
--- a/app/Http/Controllers/Popup/ReportController.php
+++ b/app/Http/Controllers/Popup/ReportController.php
@@ -81,11 +81,6 @@ class ReportController extends Controller
* @return \Illuminate\Http\JsonResponse
*
* @throws FireflyException
- * @throws \Throwable
- * @throws \Throwable
- * @throws \Throwable
- * @throws \Throwable
- * @throws \Throwable
*/
public function general(Request $request)
{
@@ -124,13 +119,12 @@ class ReportController extends Controller
* @return string
*
* @throws FireflyException
- * @throws \Throwable
*/
private function balanceAmount(array $attributes): string
{
- $role = intval($attributes['role']);
- $budget = $this->budgetRepository->findNull(intval($attributes['budgetId']));
- $account = $this->accountRepository->findNull(intval($attributes['accountId']));
+ $role = (int)$attributes['role'];
+ $budget = $this->budgetRepository->findNull((int)$attributes['budgetId']);
+ $account = $this->accountRepository->findNull((int)$attributes['accountId']);
switch (true) {
case BalanceLine::ROLE_DEFAULTROLE === $role && null !== $budget->id:
@@ -140,11 +134,11 @@ class ReportController extends Controller
case BalanceLine::ROLE_DEFAULTROLE === $role && null === $budget->id:
// normal row without a budget:
$journals = $this->popupHelper->balanceForNoBudget($account, $attributes);
- $budget->name = strval(trans('firefly.no_budget'));
+ $budget->name = (string)trans('firefly.no_budget');
break;
case BalanceLine::ROLE_DIFFROLE === $role:
$journals = $this->popupHelper->balanceDifference($account, $attributes);
- $budget->name = strval(trans('firefly.leftUnbalanced'));
+ $budget->name = (string)trans('firefly.leftUnbalanced');
break;
case BalanceLine::ROLE_TAGROLE === $role:
// row with tag info.
@@ -162,11 +156,11 @@ class ReportController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
private function budgetSpentAmount(array $attributes): string
{
- $budget = $this->budgetRepository->findNull(intval($attributes['budgetId']));
+ $budget = $this->budgetRepository->findNull((int)$attributes['budgetId']);
$journals = $this->popupHelper->byBudget($budget, $attributes);
$view = view('popup.report.budget-spent-amount', compact('journals', 'budget'))->render();
@@ -180,11 +174,11 @@ class ReportController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
private function categoryEntry(array $attributes): string
{
- $category = $this->categoryRepository->findNull(intval($attributes['categoryId']));
+ $category = $this->categoryRepository->findNull((int)$attributes['categoryId']);
$journals = $this->popupHelper->byCategory($category, $attributes);
$view = view('popup.report.category-entry', compact('journals', 'category'))->render();
@@ -198,11 +192,11 @@ class ReportController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
private function expenseEntry(array $attributes): string
{
- $account = $this->accountRepository->findNull(intval($attributes['accountId']));
+ $account = $this->accountRepository->findNull((int)$attributes['accountId']);
$journals = $this->popupHelper->byExpenses($account, $attributes);
$view = view('popup.report.expense-entry', compact('journals', 'account'))->render();
@@ -216,11 +210,11 @@ class ReportController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
private function incomeEntry(array $attributes): string
{
- $account = $this->accountRepository->findNull(intval($attributes['accountId']));
+ $account = $this->accountRepository->findNull((int)$attributes['accountId']);
$journals = $this->popupHelper->byIncome($account, $attributes);
$view = view('popup.report.income-entry', compact('journals', 'account'))->render();
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index b4e5d68855..6b3082ba38 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -97,7 +97,7 @@ class PreferencesController extends Controller
$frontPageAccounts = [];
if (is_array($request->get('frontPageAccounts'))) {
foreach ($request->get('frontPageAccounts') as $id) {
- $frontPageAccounts[] = intval($id);
+ $frontPageAccounts[] = (int)$id;
}
Preferences::set('frontPageAccounts', $frontPageAccounts);
}
@@ -110,21 +110,21 @@ class PreferencesController extends Controller
Session::forget('range');
// custom fiscal year
- $customFiscalYear = 1 === intval($request->get('customFiscalYear'));
- $fiscalYearStart = date('m-d', strtotime(strval($request->get('fiscalYearStart'))));
+ $customFiscalYear = 1 === (int)$request->get('customFiscalYear');
+ $fiscalYearStart = date('m-d', strtotime((string)$request->get('fiscalYearStart')));
Preferences::set('customFiscalYear', $customFiscalYear);
Preferences::set('fiscalYearStart', $fiscalYearStart);
// save page size:
Preferences::set('listPageSize', 50);
- $listPageSize = intval($request->get('listPageSize'));
+ $listPageSize = (int)$request->get('listPageSize');
if ($listPageSize > 0 && $listPageSize < 1337) {
Preferences::set('listPageSize', $listPageSize);
}
// language:
$lang = $request->get('language');
- if (in_array($lang, array_keys(config('firefly.languages')))) {
+ if (array_key_exists($lang, config('firefly.languages'))) {
Preferences::set('language', $lang);
}
@@ -143,7 +143,7 @@ class PreferencesController extends Controller
];
Preferences::set('transaction_journal_optional_fields', $optionalTj);
- Session::flash('success', strval(trans('firefly.saved_preferences')));
+ Session::flash('success', (string)trans('firefly.saved_preferences'));
Preferences::mark();
return redirect(route('preferences.index'));
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index a039ec2212..2ab60e6b0f 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -76,7 +76,7 @@ class ProfileController extends Controller
{
$title = auth()->user()->email;
$email = auth()->user()->email;
- $subTitle = strval(trans('firefly.change_your_email'));
+ $subTitle = (string)trans('firefly.change_your_email');
$subTitleIcon = 'fa-envelope';
return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email'));
@@ -88,7 +88,7 @@ class ProfileController extends Controller
public function changePassword()
{
$title = auth()->user()->email;
- $subTitle = strval(trans('firefly.change_your_password'));
+ $subTitle = (string)trans('firefly.change_your_password');
$subTitleIcon = 'fa-key';
return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon'));
@@ -139,7 +139,7 @@ class ProfileController extends Controller
$repository->unblockUser($user);
// return to login.
- Session::flash('success', strval(trans('firefly.login_with_new_email')));
+ Session::flash('success', (string)trans('firefly.login_with_new_email'));
return redirect(route('login'));
}
@@ -150,7 +150,7 @@ class ProfileController extends Controller
public function deleteAccount()
{
$title = auth()->user()->email;
- $subTitle = strval(trans('firefly.delete_account'));
+ $subTitle = (string)trans('firefly.delete_account');
$subTitleIcon = 'fa-trash';
return view('profile.delete-account', compact('title', 'subTitle', 'subTitleIcon'));
@@ -163,8 +163,8 @@ class ProfileController extends Controller
{
Preferences::delete('twoFactorAuthEnabled');
Preferences::delete('twoFactorAuthSecret');
- Session::flash('success', strval(trans('firefly.pref_two_factor_auth_disabled')));
- Session::flash('info', strval(trans('firefly.pref_two_factor_auth_remove_it')));
+ Session::flash('success', (string)trans('firefly.pref_two_factor_auth_disabled'));
+ Session::flash('info', (string)trans('firefly.pref_two_factor_auth_remove_it'));
return redirect(route('profile.index'));
}
@@ -201,7 +201,7 @@ class ProfileController extends Controller
{
$subTitle = auth()->user()->email;
$userId = auth()->user()->id;
- $enabled2FA = intval(Preferences::get('twoFactorAuthEnabled', 0)->data) === 1;
+ $enabled2FA = (int)Preferences::get('twoFactorAuthEnabled', 0)->data === 1;
// get access token or create one.
$accessToken = Preferences::get('access_token', null);
@@ -218,7 +218,6 @@ class ProfileController extends Controller
* @param UserRepositoryInterface $repository
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
- * @throws \RuntimeException
*/
public function postChangeEmail(EmailFormRequest $request, UserRepositoryInterface $repository)
{
@@ -227,7 +226,7 @@ class ProfileController extends Controller
$newEmail = $request->string('email');
$oldEmail = $user->email;
if ($newEmail === $user->email) {
- Session::flash('error', strval(trans('firefly.email_not_changed')));
+ Session::flash('error', (string)trans('firefly.email_not_changed'));
return redirect(route('profile.change-email'))->withInput();
}
@@ -237,7 +236,7 @@ class ProfileController extends Controller
Auth::guard()->logout();
$request->session()->invalidate();
- Session::flash('success', strval(trans('firefly.email_changed')));
+ Session::flash('success', (string)trans('firefly.email_changed'));
return redirect(route('index'));
}
@@ -252,7 +251,7 @@ class ProfileController extends Controller
// force user logout.
Auth::guard()->logout();
$request->session()->invalidate();
- Session::flash('success', strval(trans('firefly.email_changed')));
+ Session::flash('success', (string)trans('firefly.email_changed'));
return redirect(route('index'));
}
@@ -278,7 +277,7 @@ class ProfileController extends Controller
}
$repository->changePassword(auth()->user(), $request->get('new_password'));
- Session::flash('success', strval(trans('firefly.password_changed')));
+ Session::flash('success', (string)trans('firefly.password_changed'));
return redirect(route('profile.index'));
}
@@ -294,7 +293,7 @@ class ProfileController extends Controller
Preferences::set('twoFactorAuthEnabled', 1);
Preferences::set('twoFactorAuthSecret', Session::get('two-factor-secret'));
- Session::flash('success', strval(trans('firefly.saved_preferences')));
+ Session::flash('success', (string)trans('firefly.saved_preferences'));
Preferences::mark();
return redirect(route('profile.index'));
@@ -309,7 +308,7 @@ class ProfileController extends Controller
public function postDeleteAccount(UserRepositoryInterface $repository, DeleteAccountFormRequest $request)
{
if (!Hash::check($request->get('password'), auth()->user()->password)) {
- Session::flash('error', strval(trans('firefly.invalid_password')));
+ Session::flash('error', (string)trans('firefly.invalid_password'));
return redirect(route('profile.delete-account'));
}
@@ -330,7 +329,7 @@ class ProfileController extends Controller
{
$token = auth()->user()->generateAccessToken();
Preferences::set('access_token', $token);
- Session::flash('success', strval(trans('firefly.token_regenerated')));
+ Session::flash('success', (string)trans('firefly.token_regenerated'));
return redirect(route('profile.index'));
}
@@ -380,7 +379,7 @@ class ProfileController extends Controller
$repository->unblockUser($user);
// return to login.
- Session::flash('success', strval(trans('firefly.login_with_old_email')));
+ Session::flash('success', (string)trans('firefly.login_with_old_email'));
return redirect(route('login'));
}
@@ -397,11 +396,11 @@ class ProfileController extends Controller
protected function validatePassword(User $user, string $current, string $new): bool
{
if (!Hash::check($current, $user->password)) {
- throw new ValidationException(strval(trans('firefly.invalid_current_password')));
+ throw new ValidationException((string)trans('firefly.invalid_current_password'));
}
if ($current === $new) {
- throw new ValidationException(strval(trans('firefly.should_change')));
+ throw new ValidationException((string)trans('firefly.should_change'));
}
return true;
diff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.php
index c7c8ff447f..db107b0eba 100644
--- a/app/Http/Controllers/Report/AccountController.php
+++ b/app/Http/Controllers/Report/AccountController.php
@@ -40,7 +40,7 @@ class AccountController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function general(Collection $accounts, Carbon $start, Carbon $end)
{
diff --git a/app/Http/Controllers/Report/BalanceController.php b/app/Http/Controllers/Report/BalanceController.php
index 77aec1cc00..c66c7f666e 100644
--- a/app/Http/Controllers/Report/BalanceController.php
+++ b/app/Http/Controllers/Report/BalanceController.php
@@ -41,7 +41,7 @@ class BalanceController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
{
diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php
index 09b42e0a5a..9e6a8cb5e4 100644
--- a/app/Http/Controllers/Report/BudgetController.php
+++ b/app/Http/Controllers/Report/BudgetController.php
@@ -42,7 +42,7 @@ class BudgetController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function general(BudgetReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
{
@@ -71,7 +71,7 @@ class BudgetController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function period(Collection $accounts, Carbon $start, Carbon $end)
{
diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php
index 7491bd34a2..f55aa23429 100644
--- a/app/Http/Controllers/Report/CategoryController.php
+++ b/app/Http/Controllers/Report/CategoryController.php
@@ -41,7 +41,7 @@ class CategoryController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function expenses(Collection $accounts, Carbon $start, Carbon $end)
{
@@ -74,7 +74,7 @@ class CategoryController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
public function income(Collection $accounts, Carbon $start, Carbon $end)
{
@@ -109,7 +109,7 @@ class CategoryController extends Controller
*
* @internal param ReportHelperInterface $helper
*
- * @throws \Throwable
+
*/
public function operations(Collection $accounts, Carbon $start, Carbon $end)
{
@@ -139,7 +139,7 @@ class CategoryController extends Controller
// Obtain a list of columns
$sum = [];
foreach ($report as $categoryId => $row) {
- $sum[$categoryId] = floatval($row['spent']);
+ $sum[$categoryId] = (float)$row['spent'];
}
array_multisort($sum, SORT_ASC, $report);
diff --git a/app/Http/Controllers/Report/ExpenseController.php b/app/Http/Controllers/Report/ExpenseController.php
index 3fb3b9b7cd..2f4df4daef 100644
--- a/app/Http/Controllers/Report/ExpenseController.php
+++ b/app/Http/Controllers/Report/ExpenseController.php
@@ -68,7 +68,7 @@ class ExpenseController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
@@ -116,7 +116,7 @@ class ExpenseController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
@@ -174,7 +174,7 @@ class ExpenseController extends Controller
*
* @return array|mixed|string
*
- * @throws \Throwable
+
*/
public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
@@ -219,7 +219,7 @@ class ExpenseController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
@@ -246,7 +246,7 @@ class ExpenseController extends Controller
$set = $collector->getJournals();
$sorted = $set->sortBy(
function (Transaction $transaction) {
- return floatval($transaction->transaction_amount);
+ return (float)$transaction->transaction_amount;
}
);
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
@@ -263,7 +263,7 @@ class ExpenseController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
@@ -290,7 +290,7 @@ class ExpenseController extends Controller
$set = $collector->getJournals();
$sorted = $set->sortByDesc(
function (Transaction $transaction) {
- return floatval($transaction->transaction_amount);
+ return (float)$transaction->transaction_amount;
}
);
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
@@ -313,7 +313,7 @@ class ExpenseController extends Controller
$collection->push($expenseAccount);
$revenue = $this->accountRepository->findByName($expenseAccount->name, [AccountType::REVENUE]);
- if (!is_null($revenue)) {
+ if (null !== $revenue) {
$collection->push($revenue);
}
$combined[$expenseAccount->name] = $collection;
@@ -342,11 +342,11 @@ class ExpenseController extends Controller
foreach ($set as $transaction) {
$currencyId = $transaction->transaction_currency_id;
$categoryName = $transaction->transaction_category_name;
- $categoryId = intval($transaction->transaction_category_id);
+ $categoryId = (int)$transaction->transaction_category_id;
// if null, grab from journal:
if (0 === $categoryId) {
$categoryName = $transaction->transaction_journal_category_name;
- $categoryId = intval($transaction->transaction_journal_category_id);
+ $categoryId = (int)$transaction->transaction_journal_category_id;
}
if (0 !== $categoryId) {
$categoryName = app('steam')->tryDecrypt($categoryName);
@@ -445,11 +445,11 @@ class ExpenseController extends Controller
foreach ($set as $transaction) {
$currencyId = $transaction->transaction_currency_id;
$budgetName = $transaction->transaction_budget_name;
- $budgetId = intval($transaction->transaction_budget_id);
+ $budgetId = (int)$transaction->transaction_budget_id;
// if null, grab from journal:
if (0 === $budgetId) {
$budgetName = $transaction->transaction_journal_budget_name;
- $budgetId = intval($transaction->transaction_journal_budget_id);
+ $budgetId = (int)$transaction->transaction_journal_budget_id;
}
if (0 !== $budgetId) {
$budgetName = app('steam')->tryDecrypt($budgetName);
@@ -506,11 +506,11 @@ class ExpenseController extends Controller
foreach ($set as $transaction) {
$currencyId = $transaction->transaction_currency_id;
$categoryName = $transaction->transaction_category_name;
- $categoryId = intval($transaction->transaction_category_id);
+ $categoryId = (int)$transaction->transaction_category_id;
// if null, grab from journal:
if (0 === $categoryId) {
$categoryName = $transaction->transaction_journal_category_name;
- $categoryId = intval($transaction->transaction_journal_category_id);
+ $categoryId = (int)$transaction->transaction_journal_category_id;
}
if (0 !== $categoryId) {
$categoryName = app('steam')->tryDecrypt($categoryName);
@@ -568,7 +568,7 @@ class ExpenseController extends Controller
];
// loop to support multi currency
foreach ($set as $transaction) {
- $currencyId = intval($transaction->transaction_currency_id);
+ $currencyId = (int)$transaction->transaction_currency_id;
// if not set, set to zero:
if (!isset($sum['per_currency'][$currencyId])) {
diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php
index c86d3c07d2..d112384006 100644
--- a/app/Http/Controllers/Report/OperationsController.php
+++ b/app/Http/Controllers/Report/OperationsController.php
@@ -41,7 +41,7 @@ class OperationsController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function expenses(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
{
@@ -70,7 +70,7 @@ class OperationsController extends Controller
*
* @return string
*
- * @throws \Throwable
+
*/
public function income(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
{
@@ -100,7 +100,7 @@ class OperationsController extends Controller
*
* @return mixed|string
*
- * @throws \Throwable
+
*/
public function operations(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
{
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index c79b940008..9681f9440f 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -175,9 +175,8 @@ class ReportController extends Controller
$generator = ReportGeneratorFactory::reportGenerator('Budget', $start, $end);
$generator->setAccounts($accounts);
$generator->setBudgets($budgets);
- $result = $generator->generate();
- return $result;
+ return $generator->generate();
}
/**
@@ -214,9 +213,8 @@ class ReportController extends Controller
$generator = ReportGeneratorFactory::reportGenerator('Category', $start, $end);
$generator->setAccounts($accounts);
$generator->setCategories($categories);
- $result = $generator->generate();
- return $result;
+ return $generator->generate();
}
/**
@@ -252,9 +250,8 @@ class ReportController extends Controller
$generator = ReportGeneratorFactory::reportGenerator('Standard', $start, $end);
$generator->setAccounts($accounts);
- $result = $generator->generate();
- return $result;
+ return $generator->generate();
}
/**
@@ -269,7 +266,7 @@ class ReportController extends Controller
$months = $this->helper->listOfMonths($start);
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
- $accountList = join(',', $accounts->pluck('id')->toArray());
+ $accountList = implode(',', $accounts->pluck('id')->toArray());
$this->repository->cleanupBudgets();
return view('reports.index', compact('months', 'accounts', 'start', 'accountList', 'customFiscalYear'));
@@ -280,7 +277,7 @@ class ReportController extends Controller
*
* @return mixed
*
- * @throws \Throwable
+
*/
public function options(string $reportType)
{
@@ -319,11 +316,11 @@ class ReportController extends Controller
$reportType = $request->get('report_type');
$start = $request->getStartDate()->format('Ymd');
$end = $request->getEndDate()->format('Ymd');
- $accounts = join(',', $request->getAccountList()->pluck('id')->toArray());
- $categories = join(',', $request->getCategoryList()->pluck('id')->toArray());
- $budgets = join(',', $request->getBudgetList()->pluck('id')->toArray());
- $tags = join(',', $request->getTagList()->pluck('tag')->toArray());
- $expense = join(',', $request->getExpenseList()->pluck('id')->toArray());
+ $accounts = implode(',', $request->getAccountList()->pluck('id')->toArray());
+ $categories = implode(',', $request->getCategoryList()->pluck('id')->toArray());
+ $budgets = implode(',', $request->getBudgetList()->pluck('id')->toArray());
+ $tags = implode(',', $request->getTagList()->pluck('tag')->toArray());
+ $expense = implode(',', $request->getExpenseList()->pluck('id')->toArray());
$uri = route('reports.index');
if (0 === $request->getAccountList()->count()) {
@@ -413,15 +410,14 @@ class ReportController extends Controller
$generator = ReportGeneratorFactory::reportGenerator('Tag', $start, $end);
$generator->setAccounts($accounts);
$generator->setTags($tags);
- $result = $generator->generate();
- return $result;
+ return $generator->generate();
}
/**
* @return string
*
- * @throws \Throwable
+
*/
private function accountReportOptions(): string
{
@@ -437,45 +433,41 @@ class ReportController extends Controller
}
}
- $result = view('reports.options.account', compact('set'))->render();
-
- return $result;
+ return view('reports.options.account', compact('set'))->render();
}
/**
* @return string
*
- * @throws \Throwable
+
*/
private function budgetReportOptions(): string
{
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
$budgets = $repository->getBudgets();
- $result = view('reports.options.budget', compact('budgets'))->render();
- return $result;
+ return view('reports.options.budget', compact('budgets'))->render();
}
/**
* @return string
*
- * @throws \Throwable
+
*/
private function categoryReportOptions(): string
{
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$categories = $repository->getCategories();
- $result = view('reports.options.category', compact('categories'))->render();
- return $result;
+ return view('reports.options.category', compact('categories'))->render();
}
/**
* @return string
*
- * @throws \Throwable
+
*/
private function noReportOptions(): string
{
@@ -485,7 +477,7 @@ class ReportController extends Controller
/**
* @return string
*
- * @throws \Throwable
+
*/
private function tagReportOptions(): string
{
@@ -496,8 +488,7 @@ class ReportController extends Controller
return $tag->tag;
}
);
- $result = view('reports.options.tag', compact('tags'))->render();
- return $result;
+ return view('reports.options.tag', compact('tags'))->render();
}
}
diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php
index 2959754ece..c6b550967f 100644
--- a/app/Http/Controllers/RuleController.php
+++ b/app/Http/Controllers/RuleController.php
@@ -72,8 +72,8 @@ class RuleController extends Controller
*
* @return View
*
- * @throws \Throwable
- * @throws \Throwable
+
+
*/
public function create(Request $request, RuleGroup $ruleGroup)
{
@@ -167,10 +167,10 @@ class RuleController extends Controller
*
* @return View
*
- * @throws \Throwable
- * @throws \Throwable
- * @throws \Throwable
- * @throws \Throwable
+
+
+
+
*/
public function edit(Request $request, RuleRepositoryInterface $repository, Rule $rule)
{
@@ -253,7 +253,7 @@ class RuleController extends Controller
$this->dispatch($job);
// Tell the user that the job is queued
- Session::flash('success', strval(trans('firefly.applied_rule_selection', ['title' => $rule->title])));
+ Session::flash('success', (string)trans('firefly.applied_rule_selection', ['title' => $rule->title]));
return redirect()->route('rules.index');
}
@@ -311,7 +311,6 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
- * @throws \InvalidArgumentException
*/
public function selectTransactions(AccountRepositoryInterface $repository, Rule $rule)
{
@@ -342,7 +341,7 @@ class RuleController extends Controller
Session::flash('success', trans('firefly.stored_new_rule', ['title' => $rule->title]));
Preferences::mark();
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
Session::put('rules.create.fromStore', true);
@@ -365,7 +364,7 @@ class RuleController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*
- * @throws \Throwable
+
*/
public function testTriggers(TestRuleFormRequest $request)
{
@@ -376,8 +375,8 @@ class RuleController extends Controller
return response()->json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
}
- $limit = intval(config('firefly.test-triggers.limit'));
- $range = intval(config('firefly.test-triggers.range'));
+ $limit = (int)config('firefly.test-triggers.limit');
+ $range = (int)config('firefly.test-triggers.range');
/** @var TransactionMatcher $matcher */
$matcher = app(TransactionMatcher::class);
@@ -414,7 +413,7 @@ class RuleController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*
- * @throws \Throwable
+
*/
public function testTriggersByRule(Rule $rule)
{
@@ -424,8 +423,8 @@ class RuleController extends Controller
return response()->json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
}
- $limit = intval(config('firefly.test-triggers.limit'));
- $range = intval(config('firefly.test-triggers.range'));
+ $limit = (int)config('firefly.test-triggers.limit');
+ $range = (int)config('firefly.test-triggers.range');
/** @var TransactionMatcher $matcher */
$matcher = app(TransactionMatcher::class);
@@ -477,7 +476,7 @@ class RuleController extends Controller
Session::flash('success', trans('firefly.updated_rule', ['title' => $rule->title]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
Session::put('rules.edit.fromUpdate', true);
@@ -540,7 +539,7 @@ class RuleController extends Controller
*
* @return array
*
- * @throws \Throwable
+
*/
private function getCurrentActions(Rule $rule)
{
@@ -570,7 +569,7 @@ class RuleController extends Controller
*
* @return array
*
- * @throws \Throwable
+
*/
private function getCurrentTriggers(Rule $rule)
{
@@ -602,7 +601,7 @@ class RuleController extends Controller
*
* @return array
*
- * @throws \Throwable
+
*/
private function getPreviousActions(Request $request)
{
@@ -633,7 +632,7 @@ class RuleController extends Controller
*
* @return array
*
- * @throws \Throwable
+
*/
private function getPreviousTriggers(Request $request)
{
@@ -674,7 +673,7 @@ class RuleController extends Controller
];
if (is_array($data['rule-triggers'])) {
foreach ($data['rule-triggers'] as $index => $triggerType) {
- $data['rule-trigger-stop'][$index] = $data['rule-trigger-stop'][$index] ?? 0;
+ $data['rule-trigger-stop'][$index] = (int)($data['rule-trigger-stop'][$index] ?? 0.0);
$triggers[] = [
'type' => $triggerType,
'value' => $data['rule-trigger-values'][$index],
diff --git a/app/Http/Controllers/RuleGroupController.php b/app/Http/Controllers/RuleGroupController.php
index 366c5c6d0e..adf37c3746 100644
--- a/app/Http/Controllers/RuleGroupController.php
+++ b/app/Http/Controllers/RuleGroupController.php
@@ -104,11 +104,11 @@ class RuleGroupController extends Controller
public function destroy(Request $request, RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
{
$title = $ruleGroup->title;
- $moveTo = auth()->user()->ruleGroups()->find(intval($request->get('move_rules_before_delete')));
+ $moveTo = auth()->user()->ruleGroups()->find((int)$request->get('move_rules_before_delete'));
$repository->destroy($ruleGroup, $moveTo);
- Session::flash('success', strval(trans('firefly.deleted_rule_group', ['title' => $title])));
+ Session::flash('success', (string)trans('firefly.deleted_rule_group', ['title' => $title]));
Preferences::mark();
return redirect($this->getPreviousUri('rule-groups.delete.uri'));
@@ -174,7 +174,7 @@ class RuleGroupController extends Controller
$this->dispatch($job);
// Tell the user that the job is queued
- Session::flash('success', strval(trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title])));
+ Session::flash('success', (string)trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));
return redirect()->route('rules.index');
}
@@ -184,12 +184,11 @@ class RuleGroupController extends Controller
* @param RuleGroup $ruleGroup
*
* @return View
- * @throws \InvalidArgumentException
*/
public function selectTransactions(AccountRepositoryInterface $repository, RuleGroup $ruleGroup)
{
// does the user have shared accounts?
- $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
+ $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$accountList = ExpandedForm::makeSelectList($accounts);
$checkedAccounts = array_keys($accountList);
$first = session('first')->format('Y-m-d');
@@ -210,10 +209,10 @@ class RuleGroupController extends Controller
$data = $request->getRuleGroupData();
$ruleGroup = $repository->store($data);
- Session::flash('success', strval(trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title])));
+ Session::flash('success', (string)trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));
Preferences::mark();
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
Session::put('rule-groups.create.fromStore', true);
@@ -249,15 +248,15 @@ class RuleGroupController extends Controller
$data = [
'title' => $request->input('title'),
'description' => $request->input('description'),
- 'active' => 1 === intval($request->input('active')),
+ 'active' => 1 === (int)$request->input('active'),
];
$repository->update($ruleGroup, $data);
- Session::flash('success', strval(trans('firefly.updated_rule_group', ['title' => $ruleGroup->title])));
+ Session::flash('success', (string)trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
Session::put('rule-groups.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php
index 65f5fc6ab0..401f9bcc8f 100644
--- a/app/Http/Controllers/SearchController.php
+++ b/app/Http/Controllers/SearchController.php
@@ -58,7 +58,7 @@ class SearchController extends Controller
*/
public function index(Request $request, SearchInterface $searcher)
{
- $fullQuery = strval($request->get('q'));
+ $fullQuery = (string)$request->get('q');
// parse search terms:
$searcher->parseQuery($fullQuery);
@@ -74,11 +74,11 @@ class SearchController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*
- * @throws \Throwable
+
*/
public function search(Request $request, SearchInterface $searcher)
{
- $fullQuery = strval($request->get('query'));
+ $fullQuery = (string)$request->get('query');
$transactions = new Collection;
// cache
$cache = new CacheProperties;
@@ -92,7 +92,7 @@ class SearchController extends Controller
if (!$cache->has()) {
// parse search terms:
$searcher->parseQuery($fullQuery);
- $searcher->setLimit(intval(env('SEARCH_RESULT_LIMIT', 50)));
+ $searcher->setLimit((int)env('SEARCH_RESULT_LIMIT', 50));
$transactions = $searcher->searchTransactions();
$cache->store($transactions);
}
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index cd9bb698f0..5aded663df 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -36,6 +36,7 @@ use phpseclib\Crypt\RSA;
class InstallController extends Controller
{
/** @noinspection MagicMethodsValidityInspection */
+ /** @noinspection PhpMissingParentConstructorInspection */
/**
* InstallController constructor.
*/
@@ -62,7 +63,7 @@ class InstallController extends Controller
$rsa = new RSA();
$keys = $rsa->createKey(4096);
- list($publicKey, $privateKey) = [
+ [$publicKey, $privateKey] = [
Passport::keyPath('oauth-public.key'),
Passport::keyPath('oauth-private.key'),
];
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index c4e1e05d69..0957c6db62 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -63,7 +63,7 @@ class TagController extends Controller
$this->middleware(
function ($request, $next) {
$this->repository = app(TagRepositoryInterface::class);
- app('view')->share('title', strval(trans('firefly.tags')));
+ app('view')->share('title', (string)trans('firefly.tags'));
app('view')->share('mainTitleIcon', 'fa-tags');
return $next($request);
@@ -118,7 +118,7 @@ class TagController extends Controller
$tagName = $tag->tag;
$this->repository->destroy($tag);
- Session::flash('success', strval(trans('firefly.deleted_tag', ['tag' => $tagName])));
+ Session::flash('success', (string)trans('firefly.deleted_tag', ['tag' => $tagName]));
Preferences::mark();
return redirect($this->getPreviousUri('tags.delete.uri'));
@@ -195,8 +195,8 @@ class TagController extends Controller
// default values:
$subTitle = $tag->tag;
$subTitleIcon = 'fa-tag';
- $page = intval($request->get('page'));
- $pageSize = intval(Preferences::get('listPageSize', 50)->data);
+ $page = (int)$request->get('page');
+ $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$range = Preferences::get('viewRange', '1M')->data;
$start = null;
$end = null;
@@ -260,10 +260,10 @@ class TagController extends Controller
$data = $request->collectTagData();
$this->repository->store($data);
- Session::flash('success', strval(trans('firefly.created_tag', ['tag' => $data['tag']])));
+ Session::flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']]));
Preferences::mark();
- if (1 === intval($request->get('create_another'))) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
Session::put('tags.create.fromStore', true);
@@ -285,10 +285,10 @@ class TagController extends Controller
$data = $request->collectTagData();
$this->repository->update($tag, $data);
- Session::flash('success', strval(trans('firefly.updated_tag', ['tag' => $data['tag']])));
+ Session::flash('success', (string)trans('firefly.updated_tag', ['tag' => $data['tag']]));
Preferences::mark();
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
Session::put('tags.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php
index 3c98c177a3..d4ed300ea6 100644
--- a/app/Http/Controllers/Transaction/BulkController.php
+++ b/app/Http/Controllers/Transaction/BulkController.php
@@ -70,7 +70,6 @@ class BulkController extends Controller
* @param Collection $journals
*
* @return View
- * @throws \RuntimeException
*/
public function edit(Request $request, Collection $journals)
{
@@ -140,22 +139,21 @@ class BulkController extends Controller
* @param JournalRepositoryInterface $repository
*
* @return mixed
- * @throws \RuntimeException
*/
public function update(BulkEditJournalRequest $request, JournalRepositoryInterface $repository)
{
/** @var JournalUpdateService $service */
$service = app(JournalUpdateService::class);
$journalIds = $request->get('journals');
- $ignoreCategory = intval($request->get('ignore_category')) === 1;
- $ignoreBudget = intval($request->get('ignore_budget')) === 1;
- $ignoreTags = intval($request->get('ignore_tags')) === 1;
+ $ignoreCategory = (int)$request->get('ignore_category') === 1;
+ $ignoreBudget = (int)$request->get('ignore_budget') === 1;
+ $ignoreTags = (int)$request->get('ignore_tags') === 1;
$count = 0;
if (is_array($journalIds)) {
foreach ($journalIds as $journalId) {
- $journal = $repository->find(intval($journalId));
- if (!is_null($journal)) {
+ $journal = $repository->find((int)$journalId);
+ if (null !== $journal) {
$count++;
Log::debug(sprintf('Found journal #%d', $journal->id));
// update category if not told to ignore
diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php
index d536705bcd..2d4cb53068 100644
--- a/app/Http/Controllers/Transaction/ConvertController.php
+++ b/app/Http/Controllers/Transaction/ConvertController.php
@@ -191,7 +191,7 @@ class ConvertController extends Controller
break;
case TransactionType::WITHDRAWAL . '-' . TransactionType::TRANSFER:
// two
- $destination = $accountRepository->findNull(intval($data['destination_account_asset']));
+ $destination = $accountRepository->findNull((int)$data['destination_account_asset']);
break;
case TransactionType::DEPOSIT . '-' . TransactionType::WITHDRAWAL:
case TransactionType::TRANSFER . '-' . TransactionType::WITHDRAWAL:
@@ -266,7 +266,7 @@ class ConvertController extends Controller
$source = $destinationAccount;
break;
case TransactionType::DEPOSIT . '-' . TransactionType::TRANSFER:
- $source = $accountRepository->findNull(intval($data['source_account_asset']));
+ $source = $accountRepository->findNull((int)$data['source_account_asset']);
break;
}
diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php
index 86d6618e18..0c7f0b02b2 100644
--- a/app/Http/Controllers/Transaction/LinkController.php
+++ b/app/Http/Controllers/Transaction/LinkController.php
@@ -86,10 +86,10 @@ class LinkController extends Controller
{
$this->repository->destroyLink($link);
- Session::flash('success', strval(trans('firefly.deleted_link')));
+ Session::flash('success', (string)trans('firefly.deleted_link'));
Preferences::mark();
- return redirect(strval(session('journal_links.delete.uri')));
+ return redirect((string)session('journal_links.delete.uri'));
}
/**
@@ -111,7 +111,7 @@ class LinkController extends Controller
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
$alreadyLinked = $this->repository->findLink($journal, $other);
- if($other->id === $journal->id) {
+ if ($other->id === $journal->id) {
Session::flash('error', trans('firefly.journals_link_to_self'));
return redirect(route('transactions.show', [$journal->id]));
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index e21f296f4c..bfd29a23e2 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -92,8 +92,8 @@ class MassController extends Controller
/** @var int $journalId */
foreach ($ids as $journalId) {
/** @var TransactionJournal $journal */
- $journal = $this->repository->find(intval($journalId));
- if (null !== $journal->id && intval($journalId) === $journal->id) {
+ $journal = $this->repository->find((int)$journalId);
+ if (null !== $journal->id && (int)$journalId === $journal->id) {
$set->push($journal);
}
}
@@ -174,14 +174,14 @@ class MassController extends Controller
function (TransactionJournal $journal) {
$transaction = $this->repository->getFirstPosTransaction($journal);
$currency = $transaction->transactionCurrency;
- $journal->amount = floatval($transaction->amount);
+ $journal->amount = (float)$transaction->amount;
$sources = $this->repository->getJournalSourceAccounts($journal);
$destinations = $this->repository->getJournalDestinationAccounts($journal);
$journal->transaction_count = $journal->transactions()->count();
$journal->currency_symbol = $currency->symbol;
$journal->transaction_type_type = $journal->transactionType->type;
- $journal->foreign_amount = floatval($transaction->foreign_amount);
+ $journal->foreign_amount = (float)$transaction->foreign_amount;
$journal->foreign_currency = $transaction->foreignCurrency;
if (null !== $sources->first()) {
@@ -216,8 +216,8 @@ class MassController extends Controller
$count = 0;
if (is_array($journalIds)) {
foreach ($journalIds as $journalId) {
- $journal = $repository->find(intval($journalId));
- if (!is_null($journal)) {
+ $journal = $repository->find((int)$journalId);
+ if (null !== $journal) {
// get optional fields:
$what = strtolower($this->repository->getTransactionType($journal));
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? null;
@@ -225,13 +225,13 @@ class MassController extends Controller
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? null;
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? null;
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? null;
- $budgetId = $request->get('budget_id')[$journal->id] ?? 0;
+ $budgetId = (int)($request->get('budget_id')[$journal->id] ?? 0.0);
$category = $request->get('category')[$journal->id];
$tags = $journal->tags->pluck('tag')->toArray();
$amount = round($request->get('amount')[$journal->id], 12);
$foreignAmount = isset($request->get('foreign_amount')[$journal->id]) ? round($request->get('foreign_amount')[$journal->id], 12) : null;
$foreignCurrencyId = isset($request->get('foreign_currency_id')[$journal->id]) ?
- intval($request->get('foreign_currency_id')[$journal->id]) : null;
+ (int)$request->get('foreign_currency_id')[$journal->id] : null;
// build data array
$data = [
'id' => $journal->id,
@@ -245,16 +245,16 @@ class MassController extends Controller
'category_id' => null,
'category_name' => $category,
- 'budget_id' => intval($budgetId),
+ 'budget_id' => (int)$budgetId,
'budget_name' => null,
- 'source_id' => intval($sourceAccountId),
+ 'source_id' => (int)$sourceAccountId,
'source_name' => $sourceAccountName,
- 'destination_id' => intval($destAccountId),
+ 'destination_id' => (int)$destAccountId,
'destination_name' => $destAccountName,
'amount' => $amount,
'identifier' => 0,
'reconciled' => false,
- 'currency_id' => intval($currencyId),
+ 'currency_id' => (int)$currencyId,
'currency_code' => null,
'description' => null,
'foreign_amount' => $foreignAmount,
diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php
index b9dcc296a6..c76a87dc9c 100644
--- a/app/Http/Controllers/Transaction/SingleController.php
+++ b/app/Http/Controllers/Transaction/SingleController.php
@@ -162,7 +162,7 @@ class SingleController extends Controller
$subTitle = trans('form.add_new_' . $what);
$subTitleIcon = 'fa-plus';
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
- $source = intval($request->get('source'));
+ $source = (int)$request->get('source');
if (($what === 'withdrawal' || $what === 'transfer') && $source > 0) {
$preFilled['source_account_id'] = $source;
@@ -227,7 +227,7 @@ class SingleController extends Controller
}
// @codeCoverageIgnoreEnd
$type = $transactionJournal->transactionTypeStr();
- Session::flash('success', strval(trans('firefly.deleted_' . strtolower($type), ['description' => $transactionJournal->description])));
+ Session::flash('success', (string)trans('firefly.deleted_' . strtolower($type), ['description' => $transactionJournal->description]));
$this->repository->destroy($transactionJournal);
@@ -272,7 +272,7 @@ class SingleController extends Controller
$destinationAccounts = $repository->getJournalDestinationAccounts($journal);
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$pTransaction = $repository->getFirstPosTransaction($journal);
- $foreignCurrency = null !== $pTransaction->foreignCurrency ? $pTransaction->foreignCurrency : $pTransaction->transactionCurrency;
+ $foreignCurrency = $pTransaction->foreignCurrency ?? $pTransaction->transactionCurrency;
$preFilled = [
'date' => $repository->getJournalDate($journal, null), // $journal->dateAsString()
'interest_date' => $repository->getJournalDate($journal, 'interest_date'),
@@ -334,16 +334,16 @@ class SingleController extends Controller
*/
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
{
- $doSplit = 1 === intval($request->get('split_journal'));
- $createAnother = 1 === intval($request->get('create_another'));
+ $doSplit = 1 === (int)$request->get('split_journal');
+ $createAnother = 1 === (int)$request->get('create_another');
$data = $request->getJournalData();
$journal = $repository->store($data);
if (null === $journal->id) {
// error!
- Log::error('Could not store transaction journal: ', $journal->getErrors()->toArray());
- Session::flash('error', $journal->getErrors()->first());
+ Log::error('Could not store transaction journal.');
+ Session::flash('error', (string)trans('firefly.unknown_journal_error'));
return redirect(route('transactions.create', [$request->input('what')]))->withInput();
}
@@ -354,17 +354,17 @@ class SingleController extends Controller
// store the journal only, flash the rest.
Log::debug(sprintf('Count of error messages is %d', $this->attachments->getErrors()->count()));
- if (count($this->attachments->getErrors()->get('attachments')) > 0) {
+ if (\count($this->attachments->getErrors()->get('attachments')) > 0) {
Session::flash('error', $this->attachments->getErrors()->get('attachments'));
}
// flash messages
- if (count($this->attachments->getMessages()->get('attachments')) > 0) {
+ if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
Session::flash('info', $this->attachments->getMessages()->get('attachments'));
}
event(new StoredTransactionJournal($journal, $data['piggy_bank_id']));
- Session::flash('success', strval(trans('firefly.stored_journal', ['description' => $journal->description])));
+ Session::flash('success', (string)trans('firefly.stored_journal', ['description' => $journal->description]));
Preferences::mark();
// @codeCoverageIgnoreStart
@@ -417,11 +417,11 @@ class SingleController extends Controller
// update, get events by date and sort DESC
$type = strtolower($this->repository->getTransactionType($journal));
- Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => $data['description']])));
+ Session::flash('success', (string)trans('firefly.updated_' . $type, ['description' => $data['description']]));
Preferences::mark();
// @codeCoverageIgnoreStart
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
Session::put('transactions.edit.fromUpdate', true);
return redirect(route('transactions.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);
diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php
index be620809ce..807bf1ab10 100644
--- a/app/Http/Controllers/Transaction/SplitController.php
+++ b/app/Http/Controllers/Transaction/SplitController.php
@@ -114,7 +114,7 @@ class SplitController extends Controller
/** @var Account $account */
foreach ($accountList as $account) {
$accountArray[$account->id] = $account;
- $accountArray[$account->id]['currency_id'] = intval($account->getMeta('currency_id'));
+ $accountArray[$account->id]['currency_id'] = (int)$account->getMeta('currency_id');
}
// put previous url in session if not redirect from store (not "return_to_edit").
@@ -126,8 +126,7 @@ class SplitController extends Controller
return view(
'transactions.split.edit', compact(
'subTitleIcon', 'currencies', 'optionalFields', 'preFilled', 'subTitle', 'uploadSize', 'budgets',
- 'journal', 'accountArray',
- 'previous'
+ 'journal', 'accountArray'
)
);
}
@@ -160,11 +159,11 @@ class SplitController extends Controller
// @codeCoverageIgnoreEnd
$type = strtolower($this->repository->getTransactionType($journal));
- Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => $journal->description])));
+ Session::flash('success', (string)trans('firefly.updated_' . $type, ['description' => $journal->description]));
Preferences::mark();
// @codeCoverageIgnoreStart
- if (1 === intval($request->get('return_to_edit'))) {
+ if (1 === (int)$request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL:
Session::put('transactions.edit-split.fromUpdate', true);
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 0d7a950ed2..f010d38b26 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -94,7 +94,7 @@ class TransactionController extends Controller
}
if ($end < $start) {
- list($start, $end) = [$end, $start];
+ [$start, $end] = [$end, $start];
}
$startStr = $start->formatLocalized($this->monthAndDayFormat);
$endStr = $end->formatLocalized($this->monthAndDayFormat);
@@ -240,9 +240,9 @@ class TransactionController extends Controller
*/
private function getPeriodOverview(string $what, Carbon $date): Collection
{
- $range = Preferences::get('viewRange', '1M')->data;
- $first = $this->repository->first();
- $start = new Carbon;
+ $range = Preferences::get('viewRange', '1M')->data;
+ $first = $this->repository->firstNull();
+ $start = new Carbon;
$start->subYear();
$types = config('firefly.transactionTypesByWhat.' . $what);
$entries = new Collection;
@@ -250,7 +250,7 @@ class TransactionController extends Controller
$start = $first->date;
}
if ($date < $start) {
- list($start, $date) = [$date, $start]; // @codeCoverageIgnore
+ [$start, $date] = [$date, $start]; // @codeCoverageIgnore
}
/** @var array $dates */
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 372655d233..cfd265b47b 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -84,10 +84,10 @@ class Authenticate
if ($this->auth->check()) {
// do an extra check on user object.
$user = $this->auth->authenticate();
- if (1 === intval($user->blocked)) {
- $message = strval(trans('firefly.block_account_logout'));
+ if (1 === (int)$user->blocked) {
+ $message = (string)trans('firefly.block_account_logout');
if ('email_changed' === $user->blocked_code) {
- $message = strval(trans('firefly.email_changed_logout'));
+ $message = (string)trans('firefly.email_changed_logout');
}
app('session')->flash('logoutMessage', $message);
$this->auth->logout();
diff --git a/app/Http/Middleware/AuthenticateTwoFactor.php b/app/Http/Middleware/AuthenticateTwoFactor.php
index e78a155a0a..61e747bd02 100644
--- a/app/Http/Middleware/AuthenticateTwoFactor.php
+++ b/app/Http/Middleware/AuthenticateTwoFactor.php
@@ -58,7 +58,6 @@ class AuthenticateTwoFactor
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|mixed
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
- * @throws \Illuminate\Container\EntryNotFoundException
*/
public function handle($request, Closure $next, ...$guards)
{
diff --git a/app/Http/Middleware/Binder.php b/app/Http/Middleware/Binder.php
index 3e58b67dee..fd321892fa 100644
--- a/app/Http/Middleware/Binder.php
+++ b/app/Http/Middleware/Binder.php
@@ -63,7 +63,7 @@ class Binder
*
* @return mixed
*
- * @throws \LogicException
+
*/
public function handle($request, Closure $next, ...$guards)
{
diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.php
index f5ff6ec02c..1afa004cdf 100644
--- a/app/Http/Middleware/Installer.php
+++ b/app/Http/Middleware/Installer.php
@@ -58,8 +58,8 @@ class Installer
}
// older version in config than database?
- $configVersion = intval(config('firefly.db_version'));
- $dbVersion = intval(FireflyConfig::getFresh('db_version', 1)->data);
+ $configVersion = (int)config('firefly.db_version');
+ $dbVersion = (int)FireflyConfig::getFresh('db_version', 1)->data;
if ($configVersion > $dbVersion) {
Log::warning(
sprintf(
diff --git a/app/Http/Middleware/IsDemoUser.php b/app/Http/Middleware/IsDemoUser.php
index bd9e708bd5..f89e05cc30 100644
--- a/app/Http/Middleware/IsDemoUser.php
+++ b/app/Http/Middleware/IsDemoUser.php
@@ -39,18 +39,17 @@ class IsDemoUser
* @param \Closure $next
*
* @return mixed
- * @throws \RuntimeException
*/
public function handle(Request $request, Closure $next)
{
/** @var User $user */
$user = $request->user();
- if (is_null($user)) {
+ if (null === $user) {
return $next($request);
}
if ($user->hasRole('demo')) {
- $request->session()->flash('info', strval(trans('firefly.not_available_demo_user')));
+ $request->session()->flash('info', (string)trans('firefly.not_available_demo_user'));
$current = $request->url();
$previous = $request->session()->previousUrl();
if ($current !== $previous) {
diff --git a/app/Http/Middleware/IsSandStormUser.php b/app/Http/Middleware/IsSandStormUser.php
index 4847fdef31..227151199b 100644
--- a/app/Http/Middleware/IsSandStormUser.php
+++ b/app/Http/Middleware/IsSandStormUser.php
@@ -48,8 +48,8 @@ class IsSandStormUser
return $next($request);
}
- if (1 === intval(getenv('SANDSTORM'))) {
- Session::flash('warning', strval(trans('firefly.sandstorm_not_available')));
+ if (1 === (int)getenv('SANDSTORM')) {
+ Session::flash('warning', (string)trans('firefly.sandstorm_not_available'));
return response()->redirectTo(route('index'));
}
diff --git a/app/Http/Middleware/Sandstorm.php b/app/Http/Middleware/Sandstorm.php
index c8b6e3e878..30ad044198 100644
--- a/app/Http/Middleware/Sandstorm.php
+++ b/app/Http/Middleware/Sandstorm.php
@@ -52,7 +52,7 @@ class Sandstorm
public function handle(Request $request, Closure $next, $guard = null)
{
// is in Sandstorm environment?
- $sandstorm = 1 === intval(getenv('SANDSTORM'));
+ $sandstorm = 1 === (int)getenv('SANDSTORM');
View::share('SANDSTORM', $sandstorm);
if (!$sandstorm) {
return $next($request);
@@ -62,7 +62,7 @@ class Sandstorm
if (Auth::guard($guard)->guest()) {
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
- $userId = strval($request->header('X-Sandstorm-User-Id'));
+ $userId = (string)$request->header('X-Sandstorm-User-Id');
Log::debug(sprintf('Sandstorm user ID is "%s"', $userId));
$count = $repository->count();
@@ -120,7 +120,7 @@ class Sandstorm
}
}
// if in Sandstorm, user logged in, still must check if user is anon.
- $userId = strval($request->header('X-Sandstorm-User-Id'));
+ $userId = (string)$request->header('X-Sandstorm-User-Id');
if (strlen($userId) === 0) {
View::share('SANDSTORM_ANON', true);
diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php
index 63cbdbd2f3..7fbac67e3c 100644
--- a/app/Http/Middleware/TrustProxies.php
+++ b/app/Http/Middleware/TrustProxies.php
@@ -51,7 +51,7 @@ class TrustProxies extends Middleware
{
$trustedProxies = env('TRUSTED_PROXIES', null);
if (false !== $trustedProxies && null !== $trustedProxies && strlen($trustedProxies) > 0) {
- $this->proxies = strval($trustedProxies);
+ $this->proxies = (string)$trustedProxies;
}
parent::__construct($config);
diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php
index e380bcd243..289be2b07b 100644
--- a/app/Http/Requests/AccountFormRequest.php
+++ b/app/Http/Requests/AccountFormRequest.php
@@ -91,10 +91,10 @@ class AccountFormRequest extends Request
/** @var Account $account */
$account = $this->route()->parameter('account');
- if (!is_null($account)) {
+ if (null !== $account) {
// add rules:
$rules['id'] = 'belongsToUser:accounts';
- $rules['name'] = 'required|min:1|uniqueAccountForUser:' . intval($this->get('id'));
+ $rules['name'] = 'required|min:1|uniqueAccountForUser:' . (int)$this->get('id');
$rules['iban'] = ['iban', 'nullable', new UniqueIban($account, $account->accountType->type)];
}
diff --git a/app/Http/Requests/AttachmentFormRequest.php b/app/Http/Requests/AttachmentFormRequest.php
index a05ac1ac87..58b70356a4 100644
--- a/app/Http/Requests/AttachmentFormRequest.php
+++ b/app/Http/Requests/AttachmentFormRequest.php
@@ -43,8 +43,8 @@ class AttachmentFormRequest extends Request
public function getAttachmentData(): array
{
return [
- 'title' => $this->string('title'),
- 'notes' => $this->string('notes'),
+ 'title' => $this->string('title'),
+ 'notes' => $this->string('notes'),
];
}
@@ -55,8 +55,8 @@ class AttachmentFormRequest extends Request
{
// fixed
return [
- 'title' => 'between:1,255|nullable',
- 'notes' => 'between:1,65536|nullable',
+ 'title' => 'between:1,255|nullable',
+ 'notes' => 'between:1,65536|nullable',
];
}
}
diff --git a/app/Http/Requests/BudgetFormRequest.php b/app/Http/Requests/BudgetFormRequest.php
index 9bce8af565..90cd932635 100644
--- a/app/Http/Requests/BudgetFormRequest.php
+++ b/app/Http/Requests/BudgetFormRequest.php
@@ -58,8 +58,8 @@ class BudgetFormRequest extends Request
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name';
- if (null !== $repository->findNull(intval($this->get('id')))) {
- $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,' . intval($this->get('id'));
+ if (null !== $repository->findNull((int)$this->get('id'))) {
+ $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,' . (int)$this->get('id');
}
return [
diff --git a/app/Http/Requests/ExportFormRequest.php b/app/Http/Requests/ExportFormRequest.php
index 7a3057987d..d57207f05c 100644
--- a/app/Http/Requests/ExportFormRequest.php
+++ b/app/Http/Requests/ExportFormRequest.php
@@ -40,7 +40,6 @@ class ExportFormRequest extends Request
/**
* @return array
- * @throws \InvalidArgumentException
*/
public function rules()
{
diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php
index 4c2632a54e..ce59a59330 100644
--- a/app/Http/Requests/ReportFormRequest.php
+++ b/app/Http/Requests/ReportFormRequest.php
@@ -58,7 +58,7 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $accountId) {
- $account = $repository->findNull(intval($accountId));
+ $account = $repository->findNull((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -79,7 +79,7 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $budgetId) {
- $budget = $repository->findNull(intval($budgetId));
+ $budget = $repository->findNull((int)$budgetId);
if (null !== $budget) {
$collection->push($budget);
}
@@ -100,7 +100,7 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $categoryId) {
- $category = $repository->findNull(intval($categoryId));
+ $category = $repository->findNull((int)$categoryId);
if (null !== $category) {
$collection->push($category);
}
@@ -119,7 +119,7 @@ class ReportFormRequest extends Request
{
$date = new Carbon;
$range = $this->get('daterange');
- $parts = explode(' - ', strval($range));
+ $parts = explode(' - ', (string)$range);
if (2 === count($parts)) {
try {
$date = new Carbon($parts[1]);
@@ -147,7 +147,7 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $accountId) {
- $account = $repository->findNull(intval($accountId));
+ $account = $repository->findNull((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -166,7 +166,7 @@ class ReportFormRequest extends Request
{
$date = new Carbon;
$range = $this->get('daterange');
- $parts = explode(' - ', strval($range));
+ $parts = explode(' - ', (string)$range);
if (2 === count($parts)) {
try {
$date = new Carbon($parts[0]);
diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php
index 2b0406614c..fb9162f74d 100644
--- a/app/Http/Requests/Request.php
+++ b/app/Http/Requests/Request.php
@@ -37,7 +37,7 @@ class Request extends FormRequest
*/
public function boolean(string $field): bool
{
- return 1 === intval($this->input($field));
+ return 1 === (int)$this->input($field);
}
/**
@@ -47,7 +47,7 @@ class Request extends FormRequest
*/
public function integer(string $field): int
{
- return intval($this->get($field));
+ return (int)$this->get($field);
}
/**
diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php
index 0890a543e4..c466f3bc45 100644
--- a/app/Http/Requests/RuleFormRequest.php
+++ b/app/Http/Requests/RuleFormRequest.php
@@ -73,8 +73,8 @@ class RuleFormRequest extends Request
$contextActions = implode(',', config('firefly.rule-actions-text'));
$titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title';
- if (null !== $repository->find(intval($this->get('id')))->id) {
- $titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title,' . intval($this->get('id'));
+ if (null !== $repository->find((int)$this->get('id'))->id) {
+ $titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title,' . (int)$this->get('id');
}
$rules = [
'title' => $titleRule,
diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.php
index 25c7bb59da..dc2dc06ffd 100644
--- a/app/Http/Requests/RuleGroupFormRequest.php
+++ b/app/Http/Requests/RuleGroupFormRequest.php
@@ -58,8 +58,8 @@ class RuleGroupFormRequest extends Request
/** @var RuleGroupRepositoryInterface $repository */
$repository = app(RuleGroupRepositoryInterface::class);
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title';
- if (null !== $repository->find(intval($this->get('id')))->id) {
- $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . intval($this->get('id'));
+ if (null !== $repository->find((int)$this->get('id'))->id) {
+ $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . (int)$this->get('id');
}
return [
diff --git a/app/Http/Requests/SelectTransactionsRequest.php b/app/Http/Requests/SelectTransactionsRequest.php
index 082e4dd746..249613892a 100644
--- a/app/Http/Requests/SelectTransactionsRequest.php
+++ b/app/Http/Requests/SelectTransactionsRequest.php
@@ -41,7 +41,6 @@ class SelectTransactionsRequest extends Request
/**
* @return array
- * @throws \InvalidArgumentException
*/
public function rules()
{
diff --git a/app/Http/Requests/SplitJournalFormRequest.php b/app/Http/Requests/SplitJournalFormRequest.php
index 14aa681378..7f7d0f7737 100644
--- a/app/Http/Requests/SplitJournalFormRequest.php
+++ b/app/Http/Requests/SplitJournalFormRequest.php
@@ -77,7 +77,7 @@ class SplitJournalFormRequest extends Request
break;
}
$foreignAmount = $transaction['foreign_amount'] ?? null;
- $foreignCurrencyId = intval($transaction['foreign_currency_id'] ?? 0);
+ $foreignCurrencyId = (int)($transaction['foreign_currency_id'] ?? 0.0);
$set = [
'source_id' => $sourceId,
'source_name' => $sourceName,
@@ -92,7 +92,7 @@ class SplitJournalFormRequest extends Request
'currency_code' => null,
'description' => $transaction['transaction_description'],
'amount' => $transaction['amount'],
- 'budget_id' => intval($transaction['budget_id'] ?? 0),
+ 'budget_id' => (int)($transaction['budget_id'] ?? 0.0),
'budget_name' => null,
'category_id' => null,
'category_name' => $transaction['category_name'],
@@ -124,7 +124,7 @@ class SplitJournalFormRequest extends Request
'transactions.*.destination_name' => 'between:1,255|nullable',
'transactions.*.amount' => 'required|numeric',
'transactions.*.budget_id' => 'belongsToUser:budgets,id',
- 'transactions.*.category_name' => 'between:1,255|nullable',
+ 'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.piggy_bank_id' => 'between:1,255|nullable',
];
}
diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php
index 563c920652..85a7acdb0c 100644
--- a/app/Http/Requests/TagFormRequest.php
+++ b/app/Http/Requests/TagFormRequest.php
@@ -74,7 +74,7 @@ class TagFormRequest extends Request
$repository = app(TagRepositoryInterface::class);
$idRule = '';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
- if (null !== $repository->find(intval($this->get('id')))->id) {
+ if (null !== $repository->find((int)$this->get('id'))->id) {
$idRule = 'belongsToUser:tags';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . $this->get('id');
}
diff --git a/app/Import/Configuration/BunqConfigurator.php b/app/Import/Configuration/BunqConfigurator.php
index 8dbf9255f2..f1bb96fe60 100644
--- a/app/Import/Configuration/BunqConfigurator.php
+++ b/app/Import/Configuration/BunqConfigurator.php
@@ -60,7 +60,7 @@ class BunqConfigurator implements ConfiguratorInterface
*/
public function configureJob(array $data): bool
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$stage = $this->getConfig()['stage'] ?? 'initial';
@@ -94,7 +94,7 @@ class BunqConfigurator implements ConfiguratorInterface
*/
public function getNextData(): array
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$config = $this->getConfig();
@@ -107,9 +107,8 @@ class BunqConfigurator implements ConfiguratorInterface
/** @var HaveAccounts $class */
$class = app(HaveAccounts::class);
$class->setJob($this->job);
- $data = $class->getData();
- return $data;
+ return $class->getData();
default:
return [];
}
@@ -122,7 +121,7 @@ class BunqConfigurator implements ConfiguratorInterface
*/
public function getNextView(): string
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$stage = $this->getConfig()['stage'] ?? 'initial';
@@ -153,7 +152,7 @@ class BunqConfigurator implements ConfiguratorInterface
*/
public function isJobConfigured(): bool
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$stage = $this->getConfig()['stage'] ?? 'initial';
diff --git a/app/Import/Configuration/FileConfigurator.php b/app/Import/Configuration/FileConfigurator.php
index 38e1113d01..0eae8d7d07 100644
--- a/app/Import/Configuration/FileConfigurator.php
+++ b/app/Import/Configuration/FileConfigurator.php
@@ -84,7 +84,7 @@ class FileConfigurator implements ConfiguratorInterface
*/
public function configureJob(array $data): bool
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
/** @var ConfigurationInterface $object */
@@ -105,7 +105,7 @@ class FileConfigurator implements ConfiguratorInterface
*/
public function getNextData(): array
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call getNextData() without a job.');
}
/** @var ConfigurationInterface $object */
@@ -122,7 +122,7 @@ class FileConfigurator implements ConfiguratorInterface
*/
public function getNextView(): string
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call getNextView() without a job.');
}
$config = $this->getConfig();
@@ -149,7 +149,7 @@ class FileConfigurator implements ConfiguratorInterface
*/
public function getWarningMessage(): string
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call getWarningMessage() without a job.');
}
@@ -163,7 +163,7 @@ class FileConfigurator implements ConfiguratorInterface
*/
public function isJobConfigured(): bool
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call isJobConfigured() without a job.');
}
$config = $this->getConfig();
diff --git a/app/Import/Configuration/SpectreConfigurator.php b/app/Import/Configuration/SpectreConfigurator.php
index 0c03c5adb9..e09f7d17fb 100644
--- a/app/Import/Configuration/SpectreConfigurator.php
+++ b/app/Import/Configuration/SpectreConfigurator.php
@@ -60,7 +60,7 @@ class SpectreConfigurator implements ConfiguratorInterface
*/
public function configureJob(array $data): bool
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$stage = $this->getConfig()['stage'] ?? 'initial';
@@ -93,7 +93,7 @@ class SpectreConfigurator implements ConfiguratorInterface
*/
public function getNextData(): array
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$config = $this->getConfig();
@@ -116,9 +116,8 @@ class SpectreConfigurator implements ConfiguratorInterface
/** @var HaveAccounts $class */
$class = app(HaveAccounts::class);
$class->setJob($this->job);
- $data = $class->getData();
- return $data;
+ return $class->getData();
default:
return [];
}
@@ -131,7 +130,7 @@ class SpectreConfigurator implements ConfiguratorInterface
*/
public function getNextView(): string
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$stage = $this->getConfig()['stage'] ?? 'initial';
@@ -166,7 +165,7 @@ class SpectreConfigurator implements ConfiguratorInterface
*/
public function isJobConfigured(): bool
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call configureJob() without a job.');
}
$stage = $this->getConfig()['stage'] ?? 'initial';
diff --git a/app/Import/Converter/Amount.php b/app/Import/Converter/Amount.php
index d75346d78b..3a9103780b 100644
--- a/app/Import/Converter/Amount.php
+++ b/app/Import/Converter/Amount.php
@@ -47,7 +47,7 @@ class Amount implements ConverterInterface
}
Log::debug(sprintf('Start with amount "%s"', $value));
$original = $value;
- $value = strval($value);
+ $value = (string)$value;
$value = $this->stripAmount($value);
$len = strlen($value);
$decimalPosition = $len - 3;
@@ -69,7 +69,7 @@ class Amount implements ConverterInterface
}
// decimal character still null? Search from the left for '.',',' or ' '.
- if (is_null($decimal)) {
+ if (null === $decimal) {
Log::debug('Decimal is still NULL, probably number with >2 decimals. Search for a dot.');
$res = strrpos($value, '.');
if (!(false === $res)) {
@@ -99,9 +99,7 @@ class Amount implements ConverterInterface
Log::debug(sprintf('No decimal character found. Converted amount from "%s" to "%s".', $original, $value));
}
- $number = strval(number_format(round(floatval($value), 12), 12, '.', ''));
-
- return $number;
+ return strval(number_format(round(floatval($value), 12), 12, '.', ''));
}
/**
diff --git a/app/Import/FileProcessor/CsvProcessor.php b/app/Import/FileProcessor/CsvProcessor.php
index b4b8b31858..84915aa160 100644
--- a/app/Import/FileProcessor/CsvProcessor.php
+++ b/app/Import/FileProcessor/CsvProcessor.php
@@ -46,9 +46,9 @@ class CsvProcessor implements FileProcessorInterface
/** @var ImportJobRepositoryInterface */
private $repository;
/** @var array */
- private $validConverters = [];
+ private $validConverters;
/** @var array */
- private $validSpecifics = [];
+ private $validSpecifics;
/**
* FileProcessorInterface constructor.
@@ -67,7 +67,7 @@ class CsvProcessor implements FileProcessorInterface
*/
public function getObjects(): Collection
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call getObjects() without a job.');
}
@@ -84,7 +84,7 @@ class CsvProcessor implements FileProcessorInterface
*/
public function run(): bool
{
- if (is_null($this->job)) {
+ if (null === $this->job) {
throw new FireflyException('Cannot call run() without a job.');
}
Log::debug('Now in CsvProcessor run(). Job is now running...');
@@ -128,7 +128,7 @@ class CsvProcessor implements FileProcessorInterface
*
* @param array $array
*/
- public function setExtendedStatus(array $array)
+ public function setExtendedStatus(array $array): void
{
$this->repository->setExtendedStatus($this->job, $array);
}
@@ -213,7 +213,7 @@ class CsvProcessor implements FileProcessorInterface
$config = $this->getConfig();
$reader = Reader::createFromString($content);
$delimiter = $config['delimiter'] ?? ',';
- $hasHeaders = isset($config['has-headers']) ? $config['has-headers'] : false;
+ $hasHeaders = $config['has-headers'] ?? false;
$offset = 0;
if ('tab' === $delimiter) {
$delimiter = "\t"; // @codeCoverageIgnore
@@ -312,7 +312,7 @@ class CsvProcessor implements FileProcessorInterface
* @var string $value
*/
foreach ($row as $rowIndex => $value) {
- $value = trim(strval($value));
+ $value = trim((string)$value);
if (strlen($value) > 0) {
$annotated = $this->annotateValue($rowIndex, $value);
Log::debug('Annotated value', $annotated);
@@ -320,7 +320,7 @@ class CsvProcessor implements FileProcessorInterface
}
}
// set some extra info:
- $importAccount = intval($config['import-account'] ?? 0);
+ $importAccount = (int)($config['import-account'] ?? 0.0);
$journal->asset->setDefaultAccountId($importAccount);
return $journal;
diff --git a/app/Import/Mapper/AssetAccountIbans.php b/app/Import/Mapper/AssetAccountIbans.php
index 20f60ba9cf..c9ffcdbe01 100644
--- a/app/Import/Mapper/AssetAccountIbans.php
+++ b/app/Import/Mapper/AssetAccountIbans.php
@@ -45,7 +45,7 @@ class AssetAccountIbans implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
$iban = $account->iban ?? '';
- $accountId = intval($account->id);
+ $accountId = (int)$account->id;
if (strlen($iban) > 0) {
$topList[$accountId] = $account->iban . ' (' . $account->name . ')';
}
diff --git a/app/Import/Mapper/AssetAccounts.php b/app/Import/Mapper/AssetAccounts.php
index 9344cfb522..23536b13c5 100644
--- a/app/Import/Mapper/AssetAccounts.php
+++ b/app/Import/Mapper/AssetAccounts.php
@@ -43,7 +43,7 @@ class AssetAccounts implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
- $accountId = intval($account->id);
+ $accountId = (int)$account->id;
$name = $account->name;
$iban = $account->iban ?? '';
if (strlen($iban) > 0) {
diff --git a/app/Import/Mapper/Bills.php b/app/Import/Mapper/Bills.php
index bea7a2b3ff..6457affe4f 100644
--- a/app/Import/Mapper/Bills.php
+++ b/app/Import/Mapper/Bills.php
@@ -42,7 +42,7 @@ class Bills implements MapperInterface
/** @var Bill $bill */
foreach ($result as $bill) {
- $billId = intval($bill->id);
+ $billId = (int)$bill->id;
$list[$billId] = $bill->name . ' [' . $bill->match . ']';
}
asort($list);
diff --git a/app/Import/Mapper/Budgets.php b/app/Import/Mapper/Budgets.php
index 119e844be3..4c566611b4 100644
--- a/app/Import/Mapper/Budgets.php
+++ b/app/Import/Mapper/Budgets.php
@@ -42,7 +42,7 @@ class Budgets implements MapperInterface
/** @var Budget $budget */
foreach ($result as $budget) {
- $budgetId = intval($budget->id);
+ $budgetId = (int)$budget->id;
$list[$budgetId] = $budget->name;
}
asort($list);
diff --git a/app/Import/Mapper/Categories.php b/app/Import/Mapper/Categories.php
index 21963f8eaf..e8cddc8c2c 100644
--- a/app/Import/Mapper/Categories.php
+++ b/app/Import/Mapper/Categories.php
@@ -42,7 +42,7 @@ class Categories implements MapperInterface
/** @var Category $category */
foreach ($result as $category) {
- $categoryId = intval($category->id);
+ $categoryId = (int)$category->id;
$list[$categoryId] = $category->name;
}
asort($list);
diff --git a/app/Import/Mapper/OpposingAccountIbans.php b/app/Import/Mapper/OpposingAccountIbans.php
index efddc090b4..8ae1f146e3 100644
--- a/app/Import/Mapper/OpposingAccountIbans.php
+++ b/app/Import/Mapper/OpposingAccountIbans.php
@@ -51,7 +51,7 @@ class OpposingAccountIbans implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
$iban = $account->iban ?? '';
- $accountId = intval($account->id);
+ $accountId = (int)$account->id;
if (strlen($iban) > 0) {
$topList[$accountId] = $account->iban . ' (' . $account->name . ')';
}
diff --git a/app/Import/Mapper/OpposingAccounts.php b/app/Import/Mapper/OpposingAccounts.php
index e451ace5eb..63875ad338 100644
--- a/app/Import/Mapper/OpposingAccounts.php
+++ b/app/Import/Mapper/OpposingAccounts.php
@@ -49,7 +49,7 @@ class OpposingAccounts implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
- $accountId = intval($account->id);
+ $accountId = (int)$account->id;
$name = $account->name;
$iban = $account->iban ?? '';
if (strlen($iban) > 0) {
diff --git a/app/Import/Mapper/Tags.php b/app/Import/Mapper/Tags.php
index 68536a86b7..b2cfa3f630 100644
--- a/app/Import/Mapper/Tags.php
+++ b/app/Import/Mapper/Tags.php
@@ -42,7 +42,7 @@ class Tags implements MapperInterface
/** @var Tag $tag */
foreach ($result as $tag) {
- $tagId = intval($tag->id);
+ $tagId = (int)$tag->id;
$list[$tagId] = $tag->tag;
}
asort($list);
diff --git a/app/Import/Mapper/TransactionCurrencies.php b/app/Import/Mapper/TransactionCurrencies.php
index 7e81f4a8c8..e9fa683bce 100644
--- a/app/Import/Mapper/TransactionCurrencies.php
+++ b/app/Import/Mapper/TransactionCurrencies.php
@@ -39,7 +39,7 @@ class TransactionCurrencies implements MapperInterface
$currencies = $repository->get();
$list = [];
foreach ($currencies as $currency) {
- $currencyId = intval($currency->id);
+ $currencyId = (int)$currency->id;
$list[$currencyId] = $currency->name . ' (' . $currency->code . ')';
}
asort($list);
diff --git a/app/Import/MapperPreProcess/TagsComma.php b/app/Import/MapperPreProcess/TagsComma.php
index 43d628c577..0866cfc1d5 100644
--- a/app/Import/MapperPreProcess/TagsComma.php
+++ b/app/Import/MapperPreProcess/TagsComma.php
@@ -34,11 +34,10 @@ class TagsComma implements PreProcessorInterface
*/
public function run(string $value): array
{
- $set = explode(',', $value);
- $set = array_map('trim', $set);
- $set = array_filter($set, 'strlen');
- $return = array_values($set);
+ $set = explode(',', $value);
+ $set = array_map('trim', $set);
+ $set = array_filter($set, 'strlen');
- return $return;
+ return array_values($set);
}
}
diff --git a/app/Import/MapperPreProcess/TagsSpace.php b/app/Import/MapperPreProcess/TagsSpace.php
index d8967ee9fb..e87627b5be 100644
--- a/app/Import/MapperPreProcess/TagsSpace.php
+++ b/app/Import/MapperPreProcess/TagsSpace.php
@@ -34,11 +34,10 @@ class TagsSpace implements PreProcessorInterface
*/
public function run(string $value): array
{
- $set = explode(' ', $value);
- $set = array_map('trim', $set);
- $set = array_filter($set, 'strlen');
- $return = array_values($set);
+ $set = explode(' ', $value);
+ $set = array_map('trim', $set);
+ $set = array_filter($set, 'strlen');
- return $return;
+ return array_values($set);
}
}
diff --git a/app/Import/Object/ImportAccount.php b/app/Import/Object/ImportAccount.php
index 638cdfd83a..34da909602 100644
--- a/app/Import/Object/ImportAccount.php
+++ b/app/Import/Object/ImportAccount.php
@@ -49,7 +49,7 @@ class ImportAccount
/** @var int */
private $defaultAccountId = 0;
/** @var string */
- private $expectedType = '';
+ private $expectedType;
/**
* This value is used to indicate the other account ID (the opposing transaction's account),
* if it is know. If so, this particular import account may never return an Account with this ID.
@@ -299,19 +299,19 @@ class ImportAccount
/** @var AccountType $accountType */
$accountType = $this->repository->getAccountType($this->expectedType);
$result = $this->findById($accountType);
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
$result = $this->findByIBAN($accountType);
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
$result = $this->findByName($accountType);
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
@@ -365,7 +365,7 @@ class ImportAccount
Log::debug('Finding a mapped account based on', $array);
- $search = intval($array['mapped'] ?? 0);
+ $search = (int)($array['mapped'] ?? 0.0);
$account = $this->repository->findNull($search);
if (null === $account) {
@@ -401,10 +401,10 @@ class ImportAccount
*/
private function store(): bool
{
- if (is_null($this->user)) {
+ if (null === $this->user) {
throw new FireflyException('ImportAccount cannot continue without user.');
}
- if ((is_null($this->defaultAccountId) || 0 === intval($this->defaultAccountId)) && AccountType::ASSET === $this->expectedType) {
+ if ((null === $this->defaultAccountId || 0 === (int)$this->defaultAccountId) && AccountType::ASSET === $this->expectedType) {
throw new FireflyException('ImportAccount cannot continue without a default account to fall back on.');
}
// 1: find mapped object:
diff --git a/app/Import/Object/ImportBill.php b/app/Import/Object/ImportBill.php
index 32061504a2..19996e1058 100644
--- a/app/Import/Object/ImportBill.php
+++ b/app/Import/Object/ImportBill.php
@@ -108,7 +108,7 @@ class ImportBill
if (3 === count($this->id)) {
Log::debug(sprintf('Finding bill with ID #%d', $this->id['value']));
/** @var Bill $bill */
- $bill = $this->repository->find(intval($this->id['value']));
+ $bill = $this->repository->find((int)$this->id['value']);
if (null !== $bill) {
Log::debug(sprintf('Found unmapped bill by ID (#%d): %s', $bill->id, $bill->name));
@@ -157,11 +157,11 @@ class ImportBill
{
Log::debug('In findExistingObject() for Bill');
$result = $this->findById();
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
$result = $this->findByName();
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
@@ -215,7 +215,7 @@ class ImportBill
Log::debug('Finding a mapped bill based on', $array);
- $search = intval($array['mapped']);
+ $search = (int)$array['mapped'];
$bill = $this->repository->find($search);
if (null === $bill) {
diff --git a/app/Import/Object/ImportBudget.php b/app/Import/Object/ImportBudget.php
index 5327855d89..2a34c18906 100644
--- a/app/Import/Object/ImportBudget.php
+++ b/app/Import/Object/ImportBudget.php
@@ -97,7 +97,7 @@ class ImportBudget
if (3 === count($this->id)) {
Log::debug(sprintf('Finding budget with ID #%d', $this->id['value']));
/** @var Budget $budget */
- $budget = $this->repository->findNull(intval($this->id['value']));
+ $budget = $this->repository->findNull((int)$this->id['value']);
if (null !== $budget) {
Log::debug(sprintf('Found unmapped budget by ID (#%d): %s', $budget->id, $budget->name));
@@ -146,11 +146,11 @@ class ImportBudget
{
Log::debug('In findExistingObject() for Budget');
$result = $this->findById();
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
$result = $this->findByName();
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
@@ -204,7 +204,7 @@ class ImportBudget
Log::debug('Finding a mapped budget based on', $array);
- $search = intval($array['mapped']);
+ $search = (int)$array['mapped'];
$budget = $this->repository->find($search);
if (null === $budget->id) {
diff --git a/app/Import/Object/ImportCategory.php b/app/Import/Object/ImportCategory.php
index 176ce6fc0c..dde6cfa24e 100644
--- a/app/Import/Object/ImportCategory.php
+++ b/app/Import/Object/ImportCategory.php
@@ -99,7 +99,7 @@ class ImportCategory
if (3 === count($this->id)) {
Log::debug(sprintf('Finding category with ID #%d', $this->id['value']));
/** @var Category $category */
- $category = $this->repository->findNull(intval($this->id['value']));
+ $category = $this->repository->findNull((int)$this->id['value']);
if (null !== $category) {
Log::debug(sprintf('Found unmapped category by ID (#%d): %s', $category->id, $category->name));
@@ -150,12 +150,12 @@ class ImportCategory
{
Log::debug('In findExistingObject() for Category');
$result = $this->findById();
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
$result = $this->findByName();
- if (!is_null($result)) {
+ if (null !== $result) {
return $result;
}
@@ -209,7 +209,7 @@ class ImportCategory
Log::debug('Finding a mapped category based on', $array);
- $search = intval($array['mapped']);
+ $search = (int)$array['mapped'];
$category = $this->repository->findNull($search);
if (null === $category) {
diff --git a/app/Import/Object/ImportCurrency.php b/app/Import/Object/ImportCurrency.php
index d375048024..47b7a0fa95 100644
--- a/app/Import/Object/ImportCurrency.php
+++ b/app/Import/Object/ImportCurrency.php
@@ -114,7 +114,7 @@ class ImportCurrency
*/
public function setId(array $id)
{
- $id['value'] = intval($id['value']);
+ $id['value'] = (int)$id['value'];
$this->id = $id;
}
@@ -215,7 +215,7 @@ class ImportCurrency
Log::debug('Finding a mapped object based on', $array);
- $search = intval($array['mapped']);
+ $search = (int)$array['mapped'];
$currency = $this->repository->findNull($search);
if (null === $currency) {
diff --git a/app/Import/Object/ImportJournal.php b/app/Import/Object/ImportJournal.php
index 1b8d04bfd9..fa5d7ad66f 100644
--- a/app/Import/Object/ImportJournal.php
+++ b/app/Import/Object/ImportJournal.php
@@ -71,7 +71,7 @@ class ImportJournal
/** @var array */
private $amountDebit;
/** @var string */
- private $convertedAmount = null;
+ private $convertedAmount;
/** @var string */
private $date = '';
/** @var string */
@@ -225,7 +225,7 @@ class ImportJournal
public function getMetaString(string $field): ?string
{
if (isset($this->metaFields[$field]) && strlen($this->metaFields[$field]) > 0) {
- return strval($this->metaFields[$field]);
+ return (string)$this->metaFields[$field];
}
return null;
@@ -277,7 +277,7 @@ class ImportJournal
case 'sepa-country':
case 'sepa-ep':
case 'sepa-ci':
- $value = trim(strval($array['value']));
+ $value = trim((string)$array['value']);
if (strlen($value) > 0) {
$this->metaFields[$array['role']] = $value;
}
@@ -448,17 +448,17 @@ class ImportJournal
{
$info = [];
$converterClass = '';
- if (!is_null($this->amount)) {
+ if (null !== $this->amount) {
Log::debug('Amount value is not NULL, assume this is the correct value.');
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amount['role'])));
$info = $this->amount;
}
- if (!is_null($this->amountDebit)) {
+ if (null !== $this->amountDebit) {
Log::debug('Amount DEBIT value is not NULL, assume this is the correct value (overrules Amount).');
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amountDebit['role'])));
$info = $this->amountDebit;
}
- if (!is_null($this->amountCredit)) {
+ if (null !== $this->amountCredit) {
Log::debug('Amount CREDIT value is not NULL, assume this is the correct value (overrules Amount and AmountDebit).');
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amountCredit['role'])));
$info = $this->amountCredit;
diff --git a/app/Import/Prerequisites/BunqPrerequisites.php b/app/Import/Prerequisites/BunqPrerequisites.php
index 7c982c9bec..05246d701d 100644
--- a/app/Import/Prerequisites/BunqPrerequisites.php
+++ b/app/Import/Prerequisites/BunqPrerequisites.php
@@ -58,7 +58,7 @@ class BunqPrerequisites implements PrerequisitesInterface
Log::debug('Now in BunqPrerequisites::getViewParameters()');
$apiKey = Preferences::getForUser($this->user, 'bunq_api_key', null);
$string = '';
- if (!is_null($apiKey)) {
+ if (null !== $apiKey) {
$string = $apiKey->data;
}
diff --git a/app/Import/Prerequisites/SpectrePrerequisites.php b/app/Import/Prerequisites/SpectrePrerequisites.php
index e59e102ecc..a662ed3de9 100644
--- a/app/Import/Prerequisites/SpectrePrerequisites.php
+++ b/app/Import/Prerequisites/SpectrePrerequisites.php
@@ -55,7 +55,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
public function getViewParameters(): array
{
$publicKey = $this->getPublicKey();
- $subTitle = strval(trans('import.spectre_title'));
+ $subTitle = (string)trans('import.spectre_title');
$subTitleIcon = 'fa-archive';
return compact('publicKey', 'subTitle', 'subTitleIcon');
diff --git a/app/Import/Routine/BunqRoutine.php b/app/Import/Routine/BunqRoutine.php
index e4feb97f1d..bff5cbfb6e 100644
--- a/app/Import/Routine/BunqRoutine.php
+++ b/app/Import/Routine/BunqRoutine.php
@@ -325,7 +325,7 @@ class BunqRoutine implements RoutineInterface
Log::debug('in convertToAccount()');
// find opposing party by IBAN first.
$result = $this->accountRepository->findByIbanNull($party->getIban(), [$expectedType]);
- if (!is_null($result)) {
+ if (null !== $result) {
Log::debug(sprintf('Search for %s resulted in account %s (#%d)', $party->getIban(), $result->name, $result->id));
return $result;
@@ -334,7 +334,7 @@ class BunqRoutine implements RoutineInterface
// try to find asset account just in case:
if ($expectedType !== AccountType::ASSET) {
$result = $this->accountRepository->findByIbanNull($party->getIban(), [AccountType::ASSET]);
- if (!is_null($result)) {
+ if (nul !== $result) {
Log::debug(sprintf('Search for Asset "%s" resulted in account %s (#%d)', $party->getIban(), $result->name, $result->id));
return $result;
@@ -400,8 +400,6 @@ class BunqRoutine implements RoutineInterface
Preferences::setForUser($this->job->user, 'bunq_private_key', $privKey);
Preferences::setForUser($this->job->user, 'bunq_public_key', $pubKey['key']);
Log::debug('Created and stored key pair');
-
- return;
}
/**
@@ -570,7 +568,7 @@ class BunqRoutine implements RoutineInterface
private function getServerPublicKey(): ServerPublicKey
{
$pref = Preferences::getForUser($this->job->user, 'bunq_server_public_key', null)->data;
- if (is_null($pref)) {
+ if (null === $pref) {
throw new FireflyException('Cannot determine bunq server public key, but should have it at this point.');
}
@@ -721,8 +719,6 @@ class BunqRoutine implements RoutineInterface
// set status to "finished"?
// update job:
$this->setStatus('finished');
-
- return;
}
/**
@@ -778,7 +774,7 @@ class BunqRoutine implements RoutineInterface
// we really have to quit at this point :(
throw new FireflyException($e->getMessage());
}
- if (is_null($deviceServerId)) {
+ if (null === $deviceServerId) {
throw new FireflyException('Was not able to register server with bunq. Please see the log files.');
}
@@ -881,8 +877,6 @@ class BunqRoutine implements RoutineInterface
// update job, set status to "configuring".
$this->setStatus('configuring');
$this->addStep();
-
- return;
}
/**
@@ -893,8 +887,6 @@ class BunqRoutine implements RoutineInterface
private function setConfig(array $config): void
{
$this->repository->setConfiguration($this->job, $config);
-
- return;
}
/**
@@ -905,8 +897,6 @@ class BunqRoutine implements RoutineInterface
private function setExtendedStatus(array $extended): void
{
$this->repository->setExtendedStatus($this->job, $extended);
-
- return;
}
/**
diff --git a/app/Import/Routine/SpectreRoutine.php b/app/Import/Routine/SpectreRoutine.php
index 9f035fc4ea..55aee3e111 100644
--- a/app/Import/Routine/SpectreRoutine.php
+++ b/app/Import/Routine/SpectreRoutine.php
@@ -24,13 +24,13 @@ namespace FireflyIII\Import\Routine;
use Carbon\Carbon;
use DB;
+use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Object\ImportJournal;
use FireflyIII\Import\Storage\ImportStorage;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
-use FireflyIII\Services\Spectre\Exception\DuplicatedCustomerException;
use FireflyIII\Services\Spectre\Exception\SpectreException;
use FireflyIII\Services\Spectre\Object\Account;
use FireflyIII\Services\Spectre\Object\Customer;
@@ -179,11 +179,11 @@ class SpectreRoutine implements RoutineInterface
try {
$newCustomerRequest->call();
$customer = $newCustomerRequest->getCustomer();
- } catch (DuplicatedCustomerException $e) {
+ } catch (Exception $e) {
// already exists, must fetch customer instead.
- Log::warning('Customer exists already for user, fetch it.');
+ Log::warning(sprintf('Customer exists already for user, fetch it: %s', $e->getMessage()));
}
- if (is_null($customer)) {
+ if (null === $customer) {
$getCustomerRequest = new ListCustomersRequest($this->job->user);
$getCustomerRequest->call();
$customers = $getCustomerRequest->getCustomers();
@@ -211,7 +211,7 @@ class SpectreRoutine implements RoutineInterface
protected function getCustomer(): Customer
{
$config = $this->getConfig();
- if (!is_null($config['customer'])) {
+ if (null !== $config['customer']) {
$customer = new Customer($config['customer']);
return $customer;
@@ -306,13 +306,13 @@ class SpectreRoutine implements RoutineInterface
/** @var Login $login */
foreach ($logins as $login) {
$attempt = $login->getLastAttempt();
- $attemptTime = intval($attempt->getCreatedAt()->format('U'));
- if ($attemptTime > $time && is_null($attempt->getFailErrorClass())) {
+ $attemptTime = (int)$attempt->getCreatedAt()->format('U');
+ if ($attemptTime > $time && null === $attempt->getFailErrorClass()) {
$time = $attemptTime;
$final = $login;
}
}
- if (is_null($final)) {
+ if (null === $final) {
Log::error('Could not find a valid login for this user.');
$this->repository->addError($this->job, 0, 'Spectre connection failed. Did you use invalid credentials, press Cancel or failed the 2FA challenge?');
$this->repository->setStatus($this->job, 'error');
@@ -420,8 +420,8 @@ class SpectreRoutine implements RoutineInterface
}
$extra = $transaction->getExtra()->toArray();
$notes = '';
- $notes .= strval(trans('import.imported_from_account', ['account' => $account->getName()])) . ' '
- . "\n"; // double space for newline in Markdown.
+ // double space for newline in Markdown.
+ $notes .= (string)trans('import.imported_from_account', ['account' => $account->getName()]) . ' ' . "\n";
foreach ($extra as $key => $value) {
switch ($key) {
@@ -535,8 +535,8 @@ class SpectreRoutine implements RoutineInterface
/** @var array $accountArray */
foreach ($accounts as $accountArray) {
$account = new Account($accountArray);
- $importId = intval($config['accounts-mapped'][$account->getId()] ?? 0);
- $doImport = 0 !== $importId ? true : false;
+ $importId = (int)($config['accounts-mapped'][$account->getId()] ?? 0.0);
+ $doImport = 0 !== $importId;
if (!$doImport) {
Log::debug(sprintf('Will NOT import from Spectre account #%d ("%s")', $account->getId(), $account->getName()));
continue;
diff --git a/app/Import/Storage/ImportStorage.php b/app/Import/Storage/ImportStorage.php
index 619e77d768..9c3f941505 100644
--- a/app/Import/Storage/ImportStorage.php
+++ b/app/Import/Storage/ImportStorage.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Import\Storage;
-use ErrorException;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\TransactionJournalFactory;
@@ -160,7 +159,7 @@ class ImportStorage
try {
$this->storeImportJournal($index, $importJournal);
$this->addStep();
- } catch (FireflyException | ErrorException | Exception $e) {
+ } catch (Exception $e) {
$this->errors->push($e->getMessage());
Log::error(sprintf('Cannot import row #%d because: %s', $index, $e->getMessage()));
Log::error($e->getTraceAsString());
@@ -239,7 +238,7 @@ class ImportStorage
'description' => $importJournal->getDescription(),
'piggy_bank_id' => null,
'piggy_bank_name' => null,
- 'bill_id' => is_null($bill) ? null : $bill->id,
+ 'bill_id' => null === $bill ? null : $bill->id,
'bill_name' => null,
'tags' => $importJournal->tags,
'interest_date' => $importJournal->getMetaDate('interest_date'),
@@ -262,14 +261,14 @@ class ImportStorage
[
'description' => null,
'amount' => $amount,
- 'currency_id' => intval($currencyId),
+ 'currency_id' => (int)$currencyId,
'currency_code' => null,
'foreign_amount' => $foreignAmount,
'foreign_currency_id' => $foreignCurrencyId,
'foreign_currency_code' => null,
- 'budget_id' => is_null($budget) ? null : $budget->id,
+ 'budget_id' => null === $budget ? null : $budget->id,
'budget_name' => null,
- 'category_id' => is_null($category) ? null : $category->id,
+ 'category_id' => null === $category ? null : $category->id,
'category_name' => null,
'source_id' => $source->id,
'source_name' => null,
diff --git a/app/Import/Storage/ImportSupport.php b/app/Import/Storage/ImportSupport.php
index a1bf25557b..ddcb5fa1f6 100644
--- a/app/Import/Storage/ImportSupport.php
+++ b/app/Import/Storage/ImportSupport.php
@@ -91,7 +91,7 @@ trait ImportSupport
*/
protected function matchBills(TransactionJournal $journal): bool
{
- if (!is_null($journal->bill_id)) {
+ if (null !== $journal->bill_id) {
Log::debug('Journal is already linked to a bill, will not scan.');
return true;
@@ -134,7 +134,7 @@ trait ImportSupport
{
// start with currency pref of account, if any:
$account = $importJournal->asset->getAccount();
- $currencyId = intval($account->getMeta('currency_id'));
+ $currencyId = (int)$account->getMeta('currency_id');
if ($currencyId > 0) {
return $currencyId;
}
@@ -166,7 +166,7 @@ trait ImportSupport
{
// use given currency by import journal.
$currency = $importJournal->foreignCurrency->getTransactionCurrency();
- if (null !== $currency && intval($currency->id) !== intval($currencyId)) {
+ if (null !== $currency && (int)$currency->id !== (int)$currencyId) {
return $currency->id;
}
@@ -206,9 +206,7 @@ trait ImportSupport
// amount is positive, it's a deposit, opposing is an revenue:
$account->setExpectedType(AccountType::REVENUE);
- $databaseAccount = $account->getAccount();
-
- return $databaseAccount;
+ return $account->getAccount();
}
/**
@@ -280,7 +278,6 @@ trait ImportSupport
* is not already present.
*
* @return array
- * @throws \InvalidArgumentException
*/
private function getTransfers(): array
{
diff --git a/app/Models/Account.php b/app/Models/Account.php
index cf1e6131ba..d799551c0e 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -32,14 +32,13 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\JoinClause;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Watson\Validating\ValidatingTrait;
/**
* Class Account.
*/
class Account extends Model
{
- use SoftDeletes, ValidatingTrait;
+ use SoftDeletes;
/**
* The attributes that should be casted to native types.
@@ -58,17 +57,6 @@ class Account extends Model
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
/** @var array */
protected $hidden = ['encrypted'];
- /**
- * @var array
- */
- protected $rules
- = [
- 'user_id' => 'required|exists:users,id',
- 'account_type_id' => 'required|exists:account_types,id',
- 'name' => 'required|between:1,200',
- 'active' => 'required|boolean',
- 'iban' => 'between:1,50|iban',
- ];
/** @var bool */
private $joinedAccountTypes;
@@ -77,6 +65,8 @@ class Account extends Model
*
* @return Account
*
+ * @deprecated
+ *
* @throws FireflyException
*/
public static function firstOrCreateEncrypted(array $fields)
@@ -121,9 +111,9 @@ class Account extends Model
public static function routeBinder(string $value): Account
{
if (auth()->check()) {
- $accountId = intval($value);
+ $accountId = (int)$value;
$account = auth()->user()->accounts()->find($accountId);
- if (!is_null($account)) {
+ if (null !== $account) {
return $account;
}
}
@@ -172,7 +162,7 @@ class Account extends Model
*/
public function getIbanAttribute($value): string
{
- if (null === $value || 0 === strlen(strval($value))) {
+ if (null === $value || 0 === strlen((string)$value)) {
return '';
}
try {
@@ -191,6 +181,7 @@ class Account extends Model
* @codeCoverageIgnore
*
* @param string $fieldName
+ *
* @deprecated
* @return string
*/
@@ -198,7 +189,7 @@ class Account extends Model
{
foreach ($this->accountMeta as $meta) {
if ($meta->name === $fieldName) {
- return strval($meta->data);
+ return (string)$meta->data;
}
}
@@ -281,7 +272,6 @@ class Account extends Model
* @param string $name
* @param string $value
*
- * @throws \InvalidArgumentException
*/
public function scopeHasMetaValue(EloquentBuilder $query, $name, $value)
{
@@ -312,6 +302,7 @@ class Account extends Model
* @codeCoverageIgnore
*
* @param $value
+ *
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setNameAttribute($value)
@@ -330,7 +321,7 @@ class Account extends Model
*/
public function setVirtualBalanceAttribute($value)
{
- $this->attributes['virtual_balance'] = strval($value);
+ $this->attributes['virtual_balance'] = (string)$value;
}
/**
diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php
index 9ef2343d09..3e6c3e81be 100644
--- a/app/Models/Attachment.php
+++ b/app/Models/Attachment.php
@@ -60,9 +60,9 @@ class Attachment extends Model
public static function routeBinder(string $value): Attachment
{
if (auth()->check()) {
- $attachmentId = intval($value);
+ $attachmentId = (int)$value;
$attachment = auth()->user()->attachments()->find($attachmentId);
- if (!is_null($attachment)) {
+ if (null !== $attachment) {
return $attachment;
}
}
@@ -89,7 +89,7 @@ class Attachment extends Model
*/
public function fileName(): string
{
- return sprintf('at-%s.data', strval($this->id));
+ return sprintf('at-%s.data', (string)$this->id);
}
/**
@@ -181,6 +181,7 @@ class Attachment extends Model
* @codeCoverageIgnore
*
* @param string $value
+ *
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setFilenameAttribute(string $value)
@@ -192,6 +193,7 @@ class Attachment extends Model
* @codeCoverageIgnore
*
* @param string $value
+ *
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setMimeAttribute(string $value)
@@ -203,6 +205,7 @@ class Attachment extends Model
* @codeCoverageIgnore
*
* @param string $value
+ *
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setTitleAttribute(string $value)
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index 823f39b426..10b240f9c8 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -28,14 +28,13 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Watson\Validating\ValidatingTrait;
/**
* Class Bill.
*/
class Bill extends Model
{
- use SoftDeletes, ValidatingTrait;
+ use SoftDeletes;
/**
* The attributes that should be casted to native types.
*
@@ -63,10 +62,6 @@ class Bill extends Model
* @var array
*/
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
- /**
- * @var array
- */
- protected $rules = ['name' => 'required|between:1,200'];
/**
* @param string $value
@@ -77,9 +72,9 @@ class Bill extends Model
public static function routeBinder(string $value): Bill
{
if (auth()->check()) {
- $billId = intval($value);
+ $billId = (int)$value;
$bill = auth()->user()->bills()->find($billId);
- if (!is_null($bill)) {
+ if (null !== $bill) {
return $bill;
}
}
@@ -105,7 +100,7 @@ class Bill extends Model
*/
public function getMatchAttribute($value)
{
- if (1 === intval($this->match_encrypted)) {
+ if (1 === (int)$this->match_encrypted) {
return Crypt::decrypt($value);
}
@@ -122,7 +117,7 @@ class Bill extends Model
*/
public function getNameAttribute($value)
{
- if (1 === intval($this->name_encrypted)) {
+ if (1 === (int)$this->name_encrypted) {
return Crypt::decrypt($value);
}
@@ -145,7 +140,7 @@ class Bill extends Model
*/
public function setAmountMaxAttribute($value)
{
- $this->attributes['amount_max'] = strval($value);
+ $this->attributes['amount_max'] = (string)$value;
}
/**
@@ -155,7 +150,7 @@ class Bill extends Model
*/
public function setAmountMinAttribute($value)
{
- $this->attributes['amount_min'] = strval($value);
+ $this->attributes['amount_min'] = (string)$value;
}
/**
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index 7d4a833322..2ef3a9ded5 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -27,14 +27,13 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Watson\Validating\ValidatingTrait;
/**
* Class Budget.
*/
class Budget extends Model
{
- use SoftDeletes, ValidatingTrait;
+ use SoftDeletes;
/**
* The attributes that should be casted to native types.
@@ -53,12 +52,11 @@ class Budget extends Model
protected $fillable = ['user_id', 'name', 'active'];
/** @var array */
protected $hidden = ['encrypted'];
- /** @var array */
- protected $rules = ['name' => 'required|between:1,200'];
/**
* @param array $fields
*
+ * @deprecated
* @return Budget
*/
public static function firstOrCreateEncrypted(array $fields)
@@ -92,9 +90,9 @@ class Budget extends Model
public static function routeBinder(string $value): Budget
{
if (auth()->check()) {
- $budgetId = intval($value);
+ $budgetId = (int)$value;
$budget = auth()->user()->budgets()->find($budgetId);
- if (!is_null($budget)) {
+ if (null !== $budget) {
return $budget;
}
}
diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php
index 8063df7936..4a1070f876 100644
--- a/app/Models/BudgetLimit.php
+++ b/app/Models/BudgetLimit.php
@@ -53,12 +53,12 @@ class BudgetLimit extends Model
public static function routeBinder(string $value): BudgetLimit
{
if (auth()->check()) {
- $budgetLimitId = intval($value);
+ $budgetLimitId = (int)$value;
$budgetLimit = self::where('budget_limits.id', $budgetLimitId)
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('budgets.user_id', auth()->user()->id)
->first(['budget_limits.*']);
- if (!is_null($budgetLimit)) {
+ if (null !== $budgetLimit) {
return $budgetLimit;
}
}
@@ -81,6 +81,6 @@ class BudgetLimit extends Model
*/
public function setAmountAttribute($value)
{
- $this->attributes['amount'] = strval(round($value, 12));
+ $this->attributes['amount'] = (string)round($value, 12);
}
}
diff --git a/app/Models/Category.php b/app/Models/Category.php
index f946d8bcdb..85a68a5cdd 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -27,14 +27,13 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Watson\Validating\ValidatingTrait;
/**
* Class Category.
*/
class Category extends Model
{
- use SoftDeletes, ValidatingTrait;
+ use SoftDeletes;
/**
* The attributes that should be casted to native types.
@@ -52,12 +51,11 @@ class Category extends Model
protected $fillable = ['user_id', 'name'];
/** @var array */
protected $hidden = ['encrypted'];
- /** @var array */
- protected $rules = ['name' => 'required|between:1,200'];
/**
* @param array $fields
*
+ * @deprecated
* @return Category
*/
public static function firstOrCreateEncrypted(array $fields)
@@ -91,9 +89,9 @@ class Category extends Model
public static function routeBinder(string $value): Category
{
if (auth()->check()) {
- $categoryId = intval($value);
+ $categoryId = (int)$value;
$category = auth()->user()->categories()->find($categoryId);
- if (!is_null($category)) {
+ if (null !== $category) {
return $category;
}
}
diff --git a/app/Models/ImportJob.php b/app/Models/ImportJob.php
index 70315a5c6b..84364547e1 100644
--- a/app/Models/ImportJob.php
+++ b/app/Models/ImportJob.php
@@ -139,7 +139,7 @@ class ImportJob extends Model
*/
public function getExtendedStatusAttribute($value)
{
- if (0 === strlen(strval($value))) {
+ if (0 === strlen((string)$value)) {
return [];
}
diff --git a/app/Models/LinkType.php b/app/Models/LinkType.php
index 143e30f4e6..04dd71f3aa 100644
--- a/app/Models/LinkType.php
+++ b/app/Models/LinkType.php
@@ -57,7 +57,7 @@ class LinkType extends Model
public static function routeBinder(string $value): LinkType
{
if (auth()->check()) {
- $linkTypeId = intval($value);
+ $linkTypeId = (int)$value;
$linkType = self::find($linkTypeId);
if (null !== $linkType) {
return $linkType;
diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php
index af6461ca30..ce24a63b30 100644
--- a/app/Models/PiggyBank.php
+++ b/app/Models/PiggyBank.php
@@ -69,11 +69,11 @@ class PiggyBank extends Model
public static function routeBinder(string $value): PiggyBank
{
if (auth()->check()) {
- $piggyBankId = intval($value);
+ $piggyBankId = (int)$value;
$piggyBank = self::where('piggy_banks.id', $piggyBankId)
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']);
- if (!is_null($piggyBank)) {
+ if (null !== $piggyBank) {
return $piggyBank;
}
}
@@ -142,7 +142,7 @@ class PiggyBank extends Model
// more than 1 month to go and still need money to save:
if ($diffInMonths > 0 && 1 === bccomp($remainingAmount, '0')) {
- $savePerMonth = bcdiv($remainingAmount, strval($diffInMonths));
+ $savePerMonth = bcdiv($remainingAmount, (string)$diffInMonths);
}
// less than 1 month to go but still need money to save:
@@ -221,6 +221,6 @@ class PiggyBank extends Model
*/
public function setTargetamountAttribute($value)
{
- $this->attributes['targetamount'] = strval($value);
+ $this->attributes['targetamount'] = (string)$value;
}
}
diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php
index 4da33d1726..3dec5e720c 100644
--- a/app/Models/PiggyBankEvent.php
+++ b/app/Models/PiggyBankEvent.php
@@ -69,7 +69,7 @@ class PiggyBankEvent extends Model
*/
public function setAmountAttribute($value)
{
- $this->attributes['amount'] = strval($value);
+ $this->attributes['amount'] = (string)$value;
}
/**
diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php
index af65867865..4b3d98a3b6 100644
--- a/app/Models/PiggyBankRepetition.php
+++ b/app/Models/PiggyBankRepetition.php
@@ -103,6 +103,6 @@ class PiggyBankRepetition extends Model
*/
public function setCurrentamountAttribute($value)
{
- $this->attributes['currentamount'] = strval($value);
+ $this->attributes['currentamount'] = (string)$value;
}
}
diff --git a/app/Models/Preference.php b/app/Models/Preference.php
index 23233b9bc4..7c3cae0da9 100644
--- a/app/Models/Preference.php
+++ b/app/Models/Preference.php
@@ -70,13 +70,17 @@ class Preference extends Model
}
$serialized = true;
try {
- unserialize($data);
+ unserialize($data, ['allowed_classes' => false]);
} catch (Exception $e) {
$serialized = false;
+ Log::debug(sprintf('Could not unserialise preference #%d. This is good. %s', $this->id, $e->getMessage()));
}
if (!$serialized) {
$result = json_decode($data, true);
}
+ if ($serialized) {
+ Log::error(sprintf('Preference #%d ("%s") was stored as serialised object. It will be deleted and recreated.', $this->id, $this->name));
+ }
return $result;
}
diff --git a/app/Models/Rule.php b/app/Models/Rule.php
index a7be9798ac..3d4eec456a 100644
--- a/app/Models/Rule.php
+++ b/app/Models/Rule.php
@@ -57,9 +57,9 @@ class Rule extends Model
public static function routeBinder(string $value): Rule
{
if (auth()->check()) {
- $ruleId = intval($value);
+ $ruleId = (int)$value;
$rule = auth()->user()->rules()->find($ruleId);
- if (!is_null($rule)) {
+ if (null !== $rule) {
return $rule;
}
}
diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php
index 0345afb535..d9355a24a6 100644
--- a/app/Models/RuleGroup.php
+++ b/app/Models/RuleGroup.php
@@ -60,9 +60,9 @@ class RuleGroup extends Model
public static function routeBinder(string $value): RuleGroup
{
if (auth()->check()) {
- $ruleGroupId = intval($value);
+ $ruleGroupId = (int)$value;
$ruleGroup = auth()->user()->ruleGroups()->find($ruleGroupId);
- if (!is_null($ruleGroup)) {
+ if (null !== $ruleGroup) {
return $ruleGroup;
}
}
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 8ff2aefe35..8c4b93d36e 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -26,14 +26,13 @@ use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Watson\Validating\ValidatingTrait;
/**
* Class Tag.
*/
class Tag extends Model
{
- use ValidatingTrait, SoftDeletes;
+ use SoftDeletes;
/**
* The attributes that should be casted to native types.
@@ -52,12 +51,11 @@ class Tag extends Model
protected $dates = ['date'];
/** @var array */
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
- /** @var array */
- protected $rules = ['tag' => 'required|between:1,200'];
/**
* @param array $fields
*
+ * @deprecated
* @return Tag|null
*/
public static function firstOrCreateEncrypted(array $fields)
@@ -95,9 +93,9 @@ class Tag extends Model
public static function routeBinder(string $value): Tag
{
if (auth()->check()) {
- $tagId = intval($value);
+ $tagId = (int)$value;
$tag = auth()->user()->tags()->find($tagId);
- if (!is_null($tag)) {
+ if (null !== $tag) {
return $tag;
}
}
@@ -154,6 +152,7 @@ class Tag extends Model
* @codeCoverageIgnore
*
* @param $value
+ *
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setTagAttribute($value)
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index 6e4a004b6b..77ba6c8b1d 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -27,7 +27,6 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Watson\Validating\ValidatingTrait;
/**
* Class Transaction.
@@ -98,17 +97,6 @@ class Transaction extends Model
* @var array
*/
protected $hidden = ['encrypted'];
- /**
- * @var array
- */
- protected $rules
- = [
- 'account_id' => 'required|exists:accounts,id',
- 'transaction_journal_id' => 'required|exists:transaction_journals,id',
- 'transaction_currency_id' => 'required|exists:transaction_currencies,id',
- 'description' => 'between:0,1024',
- 'amount' => 'required|numeric',
- ];
/**
* @codeCoverageIgnore
@@ -142,10 +130,10 @@ class Transaction extends Model
public static function routeBinder(string $value): Transaction
{
if (auth()->check()) {
- $transactionId = intval($value);
+ $transactionId = (int)$value;
$transaction = auth()->user()->transactions()->where('transactions.id', $transactionId)
->first(['transactions.*']);
- if (!is_null($transaction)) {
+ if (null !== $transaction) {
return $transaction;
}
}
@@ -153,7 +141,7 @@ class Transaction extends Model
throw new NotFoundHttpException;
}
- use SoftDeletes, ValidatingTrait;
+ use SoftDeletes;
/**
* @codeCoverageIgnore
@@ -256,7 +244,7 @@ class Transaction extends Model
*/
public function setAmountAttribute($value)
{
- $this->attributes['amount'] = strval($value);
+ $this->attributes['amount'] = (string)$value;
}
/**
diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php
index ec3dc40db4..afbddc2012 100644
--- a/app/Models/TransactionCurrency.php
+++ b/app/Models/TransactionCurrency.php
@@ -62,9 +62,9 @@ class TransactionCurrency extends Model
public static function routeBinder(string $value): TransactionCurrency
{
if (auth()->check()) {
- $currencyId = intval($value);
+ $currencyId = (int)$value;
$currency = self::find($currencyId);
- if (!is_null($currency)) {
+ if (null !== $currency) {
return $currency;
}
}
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 5842d765c4..acfbb2ef75 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -35,7 +35,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Log;
use Preferences;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Watson\Validating\ValidatingTrait;
/**
* Class TransactionJournal.
@@ -44,7 +43,7 @@ use Watson\Validating\ValidatingTrait;
*/
class TransactionJournal extends Model
{
- use SoftDeletes, ValidatingTrait, TransactionJournalTrait;
+ use SoftDeletes, TransactionJournalTrait;
/**
* The attributes that should be casted to native types.
@@ -73,16 +72,6 @@ class TransactionJournal extends Model
'date', 'rent_date', 'encrypted', 'tag_count',];
/** @var array */
protected $hidden = ['encrypted'];
- /** @var array */
- protected $rules
- = [
- 'user_id' => 'required|exists:users,id',
- 'transaction_type_id' => 'required|exists:transaction_types,id',
- 'description' => 'required|between:1,1024',
- 'completed' => 'required|boolean',
- 'date' => 'required|date',
- 'encrypted' => 'required|boolean',
- ];
/**
* @param string $value
@@ -93,10 +82,10 @@ class TransactionJournal extends Model
public static function routeBinder(string $value): TransactionJournal
{
if (auth()->check()) {
- $journalId = intval($value);
+ $journalId = (int)$value;
$journal = auth()->user()->transactionJournals()->where('transaction_journals.id', $journalId)
->first(['transaction_journals.*']);
- if (!is_null($journal)) {
+ if (null !== $journal) {
return $journal;
}
}
@@ -143,6 +132,7 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
* @deprecated
+ *
* @param string $name
*
* @return bool
@@ -222,6 +212,7 @@ class TransactionJournal extends Model
* @codeCoverageIgnore
*
* @param string $name
+ *
* @deprecated
* @return bool
*/
diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php
index 0675b5ce07..6b9d1afd46 100644
--- a/app/Models/TransactionJournalLink.php
+++ b/app/Models/TransactionJournalLink.php
@@ -47,14 +47,14 @@ class TransactionJournalLink extends Model
public static function routeBinder(string $value): TransactionJournalLink
{
if (auth()->check()) {
- $linkId = intval($value);
+ $linkId = (int)$value;
$link = self::where('journal_links.id', $linkId)
->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')
->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')
->where('t_a.user_id', auth()->user()->id)
->where('t_b.user_id', auth()->user()->id)
->first(['journal_links.*']);
- if (!is_null($link)) {
+ if (null !== $link) {
return $link;
}
}
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 7fafc5d844..14a2965912 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -22,8 +22,13 @@ declare(strict_types=1);
namespace FireflyIII\Providers;
+use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Events\RegisteredUser;
+use FireflyIII\Events\RequestedNewPassword;
use FireflyIII\Events\RequestedVersionCheckStatus;
+use FireflyIII\Events\StoredTransactionJournal;
+use FireflyIII\Events\UpdatedTransactionJournal;
+use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankRepetition;
use Illuminate\Auth\Events\Login;
@@ -43,39 +48,39 @@ class EventServiceProvider extends ServiceProvider
protected $listen
= [
// is a User related event.
- RegisteredUser::class => [
+ RegisteredUser::class => [
'FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationMail',
'FireflyIII\Handlers\Events\UserEventHandler@attachUserRole',
],
// is a User related event.
- Login::class => [
+ Login::class => [
'FireflyIII\Handlers\Events\UserEventHandler@checkSingleUserIsAdmin',
],
- RequestedVersionCheckStatus::class => [
+ RequestedVersionCheckStatus::class => [
'FireflyIII\Handlers\Events\VersionCheckEventHandler@checkForUpdates',
],
// is a User related event.
- 'FireflyIII\Events\RequestedNewPassword' => [
+ RequestedNewPassword::class => [
'FireflyIII\Handlers\Events\UserEventHandler@sendNewPassword',
],
// is a User related event.
- 'FireflyIII\Events\UserChangedEmail' => [
+ UserChangedEmail::class => [
'FireflyIII\Handlers\Events\UserEventHandler@sendEmailChangeConfirmMail',
'FireflyIII\Handlers\Events\UserEventHandler@sendEmailChangeUndoMail',
],
// admin related
- 'FireflyIII\Events\AdminRequestedTestMessage' => [
+ AdminRequestedTestMessage::class => [
'FireflyIII\Handlers\Events\AdminEventHandler@sendTestMessage',
],
// is a Transaction Journal related event.
- 'FireflyIII\Events\StoredTransactionJournal' => [
+ StoredTransactionJournal::class => [
'FireflyIII\Handlers\Events\StoredJournalEventHandler@scanBills',
'FireflyIII\Handlers\Events\StoredJournalEventHandler@processRules',
],
// is a Transaction Journal related event.
- 'FireflyIII\Events\UpdatedTransactionJournal' => [
+ UpdatedTransactionJournal::class => [
'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@scanBills',
'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@processRules',
],
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index f15114ac3c..3a633a4789 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -40,14 +40,6 @@ class RouteServiceProvider extends ServiceProvider
*/
protected $namespace = '';
- /**
- * Define your route model bindings, pattern filters, etc.
- */
- public function boot()
- {
- parent::boot();
- }
-
/**
* Define the routes for the application.
*/
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index ca37c54489..6b8551bc91 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -50,9 +50,7 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function count(array $types): int
{
- $count = $this->user->accounts()->accountTypeIn($types)->count();
-
- return $count;
+ return $this->user->accounts()->accountTypeIn($types)->count();
}
/**
@@ -63,7 +61,7 @@ class AccountRepository implements AccountRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(Account $account, ?Account $moveTo): bool
{
@@ -108,7 +106,7 @@ class AccountRepository implements AccountRepositoryInterface
{
foreach ($account->accountMeta as $meta) {
if ($meta->name === $field) {
- return strval($meta->data);
+ return (string)$meta->data;
}
}
@@ -135,7 +133,7 @@ class AccountRepository implements AccountRepositoryInterface
public function getNoteText(Account $account): ?string
{
$note = $account->notes()->first();
- if (is_null($note)) {
+ if (null === $note) {
return null;
}
@@ -164,7 +162,7 @@ class AccountRepository implements AccountRepositoryInterface
return null;
}
- return strval($transaction->amount);
+ return (string)$transaction->amount;
}
/**
@@ -227,7 +225,7 @@ class AccountRepository implements AccountRepositoryInterface
->orderBy('transaction_journals.id', 'ASC')
->first(['transaction_journals.id']);
if (null !== $first) {
- return TransactionJournal::find(intval($first->id));
+ return TransactionJournal::find((int)$first->id);
}
return new TransactionJournal();
@@ -272,9 +270,8 @@ class AccountRepository implements AccountRepositoryInterface
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($this->user);
- $account = $factory->create($data);
- return $account;
+ return $factory->create($data);
}
/**
diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php
index c032724f32..2c7b14259e 100644
--- a/app/Repositories/Account/AccountTasker.php
+++ b/app/Repositories/Account/AccountTasker.php
@@ -130,7 +130,7 @@ class AccountTasker implements AccountTaskerInterface
// Obtain a list of columns
$sum = [];
foreach ($expenses as $accountId => $row) {
- $sum[$accountId] = floatval($row['sum']);
+ $sum[$accountId] = (float)$row['sum'];
}
array_multisort($sum, SORT_ASC, $expenses);
@@ -172,7 +172,7 @@ class AccountTasker implements AccountTaskerInterface
// Obtain a list of columns
$sum = [];
foreach ($income as $accountId => $row) {
- $sum[$accountId] = floatval($row['sum']);
+ $sum[$accountId] = (float)$row['sum'];
}
array_multisort($sum, SORT_DESC, $income);
@@ -216,7 +216,7 @@ class AccountTasker implements AccountTaskerInterface
$keys = array_keys($expenses);
foreach ($keys as $key) {
if ($expenses[$key]['count'] > 1) {
- $expenses[$key]['average'] = bcdiv($expenses[$key]['sum'], strval($expenses[$key]['count']));
+ $expenses[$key]['average'] = bcdiv($expenses[$key]['sum'], (string)$expenses[$key]['count']);
}
}
diff --git a/app/Repositories/Account/FindAccountsTrait.php b/app/Repositories/Account/FindAccountsTrait.php
index a8e393631a..cf36898a51 100644
--- a/app/Repositories/Account/FindAccountsTrait.php
+++ b/app/Repositories/Account/FindAccountsTrait.php
@@ -251,9 +251,8 @@ trait FindAccountsTrait
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($this->user);
- $account = $factory->findOrCreate('Cash account', $type->type);
- return $account;
+ return $factory->findOrCreate('Cash account', $type->type);
}
/**
@@ -262,7 +261,6 @@ trait FindAccountsTrait
* @return Account|null
*
* @throws FireflyException
- * @throws \Exception
*/
public function getReconciliation(Account $account): ?Account
{
@@ -272,10 +270,10 @@ trait FindAccountsTrait
$name = $account->name . ' reconciliation';
$type = AccountType::where('type', AccountType::RECONCILIATION)->first();
$accounts = $this->user->accounts()->where('account_type_id', $type->id)->get();
- /** @var Account $account */
- foreach ($accounts as $account) {
- if ($account->name === $name) {
- return $account;
+ /** @var Account $current */
+ foreach ($accounts as $current) {
+ if ($current->name === $name) {
+ return $current;
}
}
/** @var AccountFactory $factory */
diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php
index 48da0f6ee9..5e4c913822 100644
--- a/app/Repositories/Attachment/AttachmentRepository.php
+++ b/app/Repositories/Attachment/AttachmentRepository.php
@@ -45,7 +45,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(Attachment $attachment): bool
{
@@ -165,8 +165,8 @@ class AttachmentRepository implements AttachmentRepositoryInterface
public function getNoteText(Attachment $attachment): ?string
{
$note = $attachment->notes()->first();
- if (!is_null($note)) {
- return strval($note->text);
+ if (null !== $note) {
+ return (string)$note->text;
}
return null;
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 11055dcafe..e8d64aea43 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -52,7 +52,7 @@ class BillRepository implements BillRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(Bill $bill): bool
{
@@ -72,10 +72,7 @@ class BillRepository implements BillRepositoryInterface
*/
public function find(int $billId): ?Bill
{
- /** @var Bill $res */
- $res = $this->user->bills()->find($billId);
-
- return $res;
+ return $this->user->bills()->find($billId);
}
/**
@@ -136,7 +133,6 @@ class BillRepository implements BillRepositoryInterface
* @param Collection $accounts
*
* @return Collection
- * @throws \InvalidArgumentException
*/
public function getBillsForAccounts(Collection $accounts): Collection
{
@@ -206,7 +202,7 @@ class BillRepository implements BillRepositoryInterface
$set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);
if ($set->count() > 0) {
$journalIds = $set->pluck('id')->toArray();
- $amount = strval(Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount'));
+ $amount = (string)Transaction::whereIn('transaction_journal_id', $journalIds)->where('amount', '<', 0)->sum('amount');
$sum = bcadd($sum, $amount);
Log::debug(sprintf('Total > 0, so add to sum %f, which becomes %f', $amount, $sum));
}
@@ -238,7 +234,7 @@ class BillRepository implements BillRepositoryInterface
if ($total > 0) {
$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');
- $multi = bcmul($average, strval($total));
+ $multi = bcmul($average, (string)$total);
$sum = bcadd($sum, $multi);
Log::debug(sprintf('Total > 0, so add to sum %f, which becomes %f', $multi, $sum));
}
@@ -259,7 +255,7 @@ class BillRepository implements BillRepositoryInterface
$repos->setUser($this->user);
$journals = $bill->transactionJournals()->get();
$sum = '0';
- $count = strval($journals->count());
+ $count = (string)$journals->count();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$sum = bcadd($sum, $repos->getJournalTotal($journal));
@@ -276,7 +272,6 @@ class BillRepository implements BillRepositoryInterface
* @param int $size
*
* @return LengthAwarePaginator
- * @throws \InvalidArgumentException
*/
public function getPaginator(int $size): LengthAwarePaginator
{
@@ -389,7 +384,7 @@ class BillRepository implements BillRepositoryInterface
->where('date', '<=', $date->year . '-12-31 23:59:59')
->get();
$sum = '0';
- $count = strval($journals->count());
+ $count = (string)$journals->count();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$sum = bcadd($sum, $repos->getJournalTotal($journal));
@@ -508,8 +503,8 @@ class BillRepository implements BillRepositoryInterface
$sourceAccounts = $repos->getJournalDestinationAccounts($journal);
$matches = explode(',', $bill->match);
$description = strtolower($journal->description) . ' ';
- $description .= strtolower(join(' ', $destinationAccounts->pluck('name')->toArray()));
- $description .= strtolower(join(' ', $sourceAccounts->pluck('name')->toArray()));
+ $description .= strtolower(implode(' ', $destinationAccounts->pluck('name')->toArray()));
+ $description .= strtolower(implode(' ', $sourceAccounts->pluck('name')->toArray()));
$wordMatch = $this->doWordMatch($matches, $description);
$amountMatch = $this->doAmountMatch($repos->getJournalTotal($journal), $bill->amount_min, $bill->amount_max);
@@ -550,10 +545,8 @@ class BillRepository implements BillRepositoryInterface
/** @var BillFactory $factory */
$factory = app(BillFactory::class);
$factory->setUser($this->user);
- $bill = $factory->create($data);
-
- return $bill;
+ return $factory->create($data);
}
/**
@@ -579,11 +572,7 @@ class BillRepository implements BillRepositoryInterface
*/
protected function doAmountMatch($amount, $min, $max): bool
{
- if ($amount >= $min && $amount <= $max) {
- return true;
- }
-
- return false;
+ return $amount >= $min && $amount <= $max;
}
/**
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 7df0701e48..41bef35866 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -61,15 +61,15 @@ class BudgetRepository implements BudgetRepositoryInterface
$total = '0';
$count = 0;
foreach ($budget->budgetlimits as $limit) {
- $diff = strval($limit->start_date->diffInDays($limit->end_date));
- $amount = strval($limit->amount);
+ $diff = (string)$limit->start_date->diffInDays($limit->end_date);
+ $amount = (string)$limit->amount;
$perDay = bcdiv($amount, $diff);
$total = bcadd($total, $perDay);
$count++;
}
$avg = $total;
if ($count > 0) {
- $avg = bcdiv($total, strval($count));
+ $avg = bcdiv($total, (string)$count);
}
return $avg;
@@ -78,8 +78,8 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @return bool
*
- * @throws \Exception
- * @throws \Exception
+
+
*/
public function cleanupBudgets(): bool
{
@@ -154,7 +154,7 @@ class BudgetRepository implements BudgetRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(Budget $budget): bool
{
@@ -180,7 +180,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/** @var stdClass $object */
$result = $set->filter(
function (TransactionJournal $object) use ($budgetId, $period) {
- $result = strval($object->period_marker) === strval($period) && $budgetId === intval($object->budget_id);
+ $result = (string)$object->period_marker === (string)$period && $budgetId === (int)$object->budget_id;
return $result;
}
@@ -252,7 +252,6 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param Budget $budget
*
* @return Carbon
- * @throws \InvalidArgumentException
*/
public function firstUseDate(Budget $budget): Carbon
{
@@ -348,7 +347,7 @@ class BudgetRepository implements BudgetRepositoryInterface
->where('start_date', $start->format('Y-m-d 00:00:00'))
->where('end_date', $end->format('Y-m-d 00:00:00'))->first();
if (null !== $availableBudget) {
- $amount = strval($availableBudget->amount);
+ $amount = (string)$availableBudget->amount;
}
return $amount;
@@ -432,7 +431,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// loop transactions:
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
- $budgetId = max(intval($transaction->transaction_journal_budget_id), intval($transaction->transaction_budget_id));
+ $budgetId = max((int)$transaction->transaction_journal_budget_id, (int)$transaction->transaction_budget_id);
$date = $transaction->date->format($carbonFormat);
$data[$budgetId]['entries'][$date] = bcadd($data[$budgetId]['entries'][$date] ?? '0', $transaction->transaction_amount);
}
@@ -492,7 +491,7 @@ class BudgetRepository implements BudgetRepositoryInterface
$transactions = $collector->getJournals();
$result = [
'entries' => [],
- 'name' => strval(trans('firefly.no_budget')),
+ 'name' => (string)trans('firefly.no_budget'),
'sum' => '0',
];
@@ -566,9 +565,8 @@ class BudgetRepository implements BudgetRepositoryInterface
}
$set = $collector->getJournals();
- $sum = strval($set->sum('transaction_amount'));
- return $sum;
+ return strval($set->sum('transaction_amount'));
}
/**
@@ -603,9 +601,7 @@ class BudgetRepository implements BudgetRepositoryInterface
}
);
- $sum = strval($set->sum('transaction_amount'));
-
- return $sum;
+ return strval($set->sum('transaction_amount'));
}
/**
@@ -650,7 +646,7 @@ class BudgetRepository implements BudgetRepositoryInterface
*
* @return BudgetLimit
*
- * @throws \Exception
+
*/
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): BudgetLimit
{
diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php
index 04d3e7911a..36879ca327 100644
--- a/app/Repositories/Budget/BudgetRepositoryInterface.php
+++ b/app/Repositories/Budget/BudgetRepositoryInterface.php
@@ -34,11 +34,6 @@ use Illuminate\Support\Collection;
*/
interface BudgetRepositoryInterface
{
- /**
- * @return bool
- */
- public function cleanupBudgets(): bool;
-
/**
* A method that returns the amount of money budgeted per day for this budget,
* on average.
@@ -49,6 +44,11 @@ interface BudgetRepositoryInterface
*/
public function budgetedPerDay(Budget $budget): string;
+ /**
+ * @return bool
+ */
+ public function cleanupBudgets(): bool;
+
/**
* This method collects various info on budgets, used on the budget page and on the index.
*
diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php
index 72f8f5c33a..94646bc84e 100644
--- a/app/Repositories/Category/CategoryRepository.php
+++ b/app/Repositories/Category/CategoryRepository.php
@@ -48,7 +48,7 @@ class CategoryRepository implements CategoryRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(Category $category): bool
{
@@ -74,9 +74,8 @@ class CategoryRepository implements CategoryRepositoryInterface
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($accounts)->setCategories($categories);
$set = $collector->getJournals();
- $sum = strval($set->sum('transaction_amount'));
- return $sum;
+ return strval($set->sum('transaction_amount'));
}
/**
@@ -237,7 +236,7 @@ class CategoryRepository implements CategoryRepositoryInterface
if (1 === bccomp($transaction->transaction_amount, '0')) {
continue;
}
- $categoryId = max(intval($transaction->transaction_journal_category_id), intval($transaction->transaction_category_id));
+ $categoryId = max((int)$transaction->transaction_journal_category_id, (int)$transaction->transaction_category_id);
$date = $transaction->date->format($carbonFormat);
$data[$categoryId]['entries'][$date] = bcadd($data[$categoryId]['entries'][$date] ?? '0', $transaction->transaction_amount);
}
@@ -263,7 +262,7 @@ class CategoryRepository implements CategoryRepositoryInterface
$transactions = $collector->getJournals();
$result = [
'entries' => [],
- 'name' => strval(trans('firefly.no_category')),
+ 'name' => (string)trans('firefly.no_category'),
'sum' => '0',
];
@@ -320,7 +319,7 @@ class CategoryRepository implements CategoryRepositoryInterface
if (bccomp($transaction->transaction_amount, '0') === -1) {
continue;
}
- $categoryId = max(intval($transaction->transaction_journal_category_id), intval($transaction->transaction_category_id));
+ $categoryId = max((int)$transaction->transaction_journal_category_id, (int)$transaction->transaction_category_id);
$date = $transaction->date->format($carbonFormat);
$data[$categoryId]['entries'][$date] = bcadd($data[$categoryId]['entries'][$date] ?? '0', $transaction->transaction_amount);
}
@@ -347,7 +346,7 @@ class CategoryRepository implements CategoryRepositoryInterface
$transactions = $collector->getJournals();
$result = [
'entries' => [],
- 'name' => strval(trans('firefly.no_category')),
+ 'name' => (string)trans('firefly.no_category'),
'sum' => '0',
];
Log::debug('Looping transactions..');
@@ -400,9 +399,8 @@ class CategoryRepository implements CategoryRepositoryInterface
}
$set = $collector->getJournals();
- $sum = strval($set->sum('transaction_amount'));
- return $sum;
+ return strval($set->sum('transaction_amount'));
}
/**
@@ -437,9 +435,7 @@ class CategoryRepository implements CategoryRepositoryInterface
}
);
- $sum = strval($set->sum('transaction_amount'));
-
- return $sum;
+ return strval($set->sum('transaction_amount'));
}
/**
@@ -452,9 +448,8 @@ class CategoryRepository implements CategoryRepositoryInterface
/** @var CategoryFactory $factory */
$factory = app(CategoryFactory::class);
$factory->setUser($this->user);
- $category = $factory->findOrCreate(null, $data['name']);
- return $category;
+ return $factory->findOrCreate(null, $data['name']);
}
/**
diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php
index f0da06ba51..c79aedf8ab 100644
--- a/app/Repositories/Currency/CurrencyRepository.php
+++ b/app/Repositories/Currency/CurrencyRepository.php
@@ -73,12 +73,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is the default currency for the system
$defaultSystemCode = config('firefly.default_currency', 'EUR');
- if ($currency->code === $defaultSystemCode) {
- return false;
- }
- // can be deleted
- return true;
+ return !($currency->code === $defaultSystemCode);
}
/**
@@ -232,10 +228,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
*/
public function findNull(int $currencyId): ?TransactionCurrency
{
- /** @var TransactionCurrency $res */
- $res = TransactionCurrency::find($currencyId);
-
- return $res;
+ return TransactionCurrency::find($currencyId);
}
/**
diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.php
index 39d3f78a47..2462ae8af5 100644
--- a/app/Repositories/Currency/CurrencyRepositoryInterface.php
+++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php
@@ -87,7 +87,9 @@ interface CurrencyRepositoryInterface
/**
* Find by currency name.
+ *
* @deprecated
+ *
* @param string $currencyName
*
* @return TransactionCurrency
@@ -105,7 +107,9 @@ interface CurrencyRepositoryInterface
/**
* Find by currency symbol.
+ *
* @deprecated
+ *
* @param string $currencySymbol
*
* @return TransactionCurrency
diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php
index 9117d85c69..20a01c9cf4 100644
--- a/app/Repositories/ExportJob/ExportJobRepository.php
+++ b/app/Repositories/ExportJob/ExportJobRepository.php
@@ -54,7 +54,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
/**
* @return bool
*
- * @throws \Exception
+
*/
public function cleanup(): bool
{
@@ -68,7 +68,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
foreach ($set as $entry) {
$key = $entry->key;
$len = strlen($key);
- $files = scandir(storage_path('export'));
+ $files = scandir(storage_path('export'), SCANDIR_SORT_NONE);
/** @var string $file */
foreach ($files as $file) {
if (substr($file, 0, $len) === $key) {
@@ -144,11 +144,10 @@ class ExportJobRepository implements ExportJobRepositoryInterface
*/
public function getContent(ExportJob $job): string
{
- $disk = Storage::disk('export');
- $file = $job->key . '.zip';
- $content = $disk->get($file);
+ $disk = Storage::disk('export');
+ $file = $job->key . '.zip';
- return $content;
+ return $disk->get($file);
}
/**
diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php
index e4019a360f..821a511b54 100644
--- a/app/Repositories/ImportJob/ImportJobRepository.php
+++ b/app/Repositories/ImportJob/ImportJobRepository.php
@@ -81,7 +81,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
public function addTotalSteps(ImportJob $job, int $steps = 1): ImportJob
{
$extended = $this->getExtendedStatus($job);
- $total = $extended['steps'] ?? 0;
+ $total = (int)($extended['steps'] ?? 0);
$total += $steps;
$extended['steps'] = $total;
@@ -104,7 +104,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
->where('name', 'importHash')
->count();
- return intval($count);
+ return (int)$count;
}
/**
@@ -210,8 +210,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
* @param UploadedFile $file
*
* @return bool
- * @throws \RuntimeException
- * @throws \LogicException
*/
public function processConfiguration(ImportJob $job, UploadedFile $file): bool
{
@@ -249,8 +247,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
*
* @return bool
*
- * @throws \RuntimeException
- * @throws \LogicException
* @throws \Illuminate\Contracts\Encryption\EncryptException
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index ed47af2193..4847148cff 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -105,7 +105,7 @@ class JournalRepository implements JournalRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(TransactionJournal $journal): bool
{
@@ -167,6 +167,7 @@ class JournalRepository implements JournalRepositoryInterface
/**
* Get users first transaction journal.
*
+ * @deprecated
* @return TransactionJournal
*/
public function first(): TransactionJournal
@@ -181,6 +182,23 @@ class JournalRepository implements JournalRepositoryInterface
return $entry;
}
+ /**
+ * Get users first transaction journal or NULL.
+ *
+ * @return TransactionJournal|null
+ */
+ public function firstNull(): ?TransactionJournal
+ {
+ /** @var TransactionJournal $entry */
+ $entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
+ $result = null;
+ if (null !== $entry) {
+ $result = $entry;
+ }
+
+ return $result;
+ }
+
/**
* @param TransactionJournal $journal
*
@@ -207,10 +225,7 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function getFirstPosTransaction(TransactionJournal $journal): Transaction
{
- /** @var Transaction $transaction */
- $transaction = $journal->transactions()->where('amount', '>', 0)->first();
-
- return $transaction;
+ return $journal->transactions()->where('amount', '>', 0)->first();
}
/**
@@ -266,7 +281,7 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function getJournalDate(TransactionJournal $journal, ?string $field): string
{
- if (is_null($field)) {
+ if (null === $field) {
return $journal->date->format('Y-m-d');
}
if (null !== $journal->$field && $journal->$field instanceof Carbon) {
@@ -363,7 +378,7 @@ class JournalRepository implements JournalRepositoryInterface
// saves on queries:
$amount = $journal->transactions()->where('amount', '>', 0)->get()->sum('amount');
- $amount = strval($amount);
+ $amount = (string)$amount;
$cache->store($amount);
return $amount;
@@ -389,7 +404,7 @@ class JournalRepository implements JournalRepositoryInterface
}
$entry = $journal->transactionJournalMeta()->where('name', $field)->first();
- if (is_null($entry)) {
+ if (null === $entry) {
return null;
}
$value = new Carbon($entry->data);
@@ -418,7 +433,7 @@ class JournalRepository implements JournalRepositoryInterface
}
$entry = $journal->transactionJournalMeta()->where('name', $field)->first();
- if (is_null($entry)) {
+ if (null === $entry) {
return null;
}
@@ -426,7 +441,7 @@ class JournalRepository implements JournalRepositoryInterface
// return when array:
if (is_array($value)) {
- $return = join(',', $value);
+ $return = implode(',', $value);
$cache->store($return);
return $return;
@@ -434,7 +449,7 @@ class JournalRepository implements JournalRepositoryInterface
// return when something else:
try {
- $return = strval($value);
+ $return = (string)$value;
$cache->store($return);
} catch (Exception $e) {
Log::error($e->getMessage());
@@ -465,7 +480,7 @@ class JournalRepository implements JournalRepositoryInterface
public function getNoteText(TransactionJournal $journal): ?string
{
$note = $this->getNote($journal);
- if (is_null($note)) {
+ if (null === $note) {
return null;
}
@@ -591,7 +606,7 @@ class JournalRepository implements JournalRepositoryInterface
{
/** @var Transaction $transaction */
$transaction = $this->user->transactions()->find($transactionId);
- if (!is_null($transaction)) {
+ if (null !== $transaction) {
return $this->reconcile($transaction);
}
diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php
index b0ddcfd54f..a3738e4c69 100644
--- a/app/Repositories/Journal/JournalRepositoryInterface.php
+++ b/app/Repositories/Journal/JournalRepositoryInterface.php
@@ -90,10 +90,18 @@ interface JournalRepositoryInterface
/**
* Get users very first transaction journal.
*
+ * @deprecated
* @return TransactionJournal
*/
public function first(): TransactionJournal;
+ /**
+ * Get users very first transaction journal.
+ *
+ * @return TransactionJournal|null
+ */
+ public function firstNull(): ?TransactionJournal;
+
/**
* @param TransactionJournal $journal
*
diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php
index 94490e91a7..6303e97baf 100644
--- a/app/Repositories/LinkType/LinkTypeRepository.php
+++ b/app/Repositories/LinkType/LinkTypeRepository.php
@@ -55,7 +55,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(LinkType $linkType, LinkType $moveTo): bool
{
@@ -72,7 +72,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroyLink(TransactionJournalLink $link): bool
{
@@ -135,7 +135,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
$filtered = $merged->filter(
function (TransactionJournalLink $link) {
- return (!is_null($link->source) && !is_null($link->destination));
+ return (null !== $link->source && null !== $link->destination);
}
);
@@ -179,9 +179,9 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
*/
public function storeLink(array $information, TransactionJournal $left, TransactionJournal $right): TransactionJournalLink
{
- $linkType = $this->find(intval($information['link_type_id']) ?? 0);
- if (is_null($linkType->id)) {
- throw new FireflyException(sprintf('Link type #%d cannot be resolved to an actual link type', intval($information['link_type_id']) ?? 0));
+ $linkType = $this->find((int)($information['link_type_id'] ?? 0));
+ if (null === $linkType->id) {
+ throw new FireflyException(sprintf('Link type #%d cannot be resolved to an actual link type', $information['link_type_id'] ?? 0));
}
$link = new TransactionJournalLink;
$link->linkType()->associate($linkType);
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index 2ad4a71bb3..aaca349ba8 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -84,9 +84,9 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
public function canAddAmount(PiggyBank $piggyBank, string $amount): bool
{
$leftOnAccount = $piggyBank->leftOnAccount(new Carbon);
- $savedSoFar = strval($piggyBank->currentRelevantRep()->currentamount);
+ $savedSoFar = (string)$piggyBank->currentRelevantRep()->currentamount;
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
- $maxAmount = strval(min(round($leftOnAccount, 12), round($leftToSave, 12)));
+ $maxAmount = (string)min(round($leftOnAccount, 12), round($leftToSave, 12));
return bccomp($amount, $maxAmount) <= 0;
}
@@ -144,7 +144,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*
* @return bool
*
- * @throws \Exception
+
*/
public function destroy(PiggyBank $piggyBank): bool
{
@@ -203,7 +203,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return '0';
}
- return strval($rep->currentamount);
+ return (string)$rep->currentamount;
}
/**
@@ -233,7 +233,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
$amount = $repos->getJournalTotal($journal);
$sources = $repos->getJournalSourceAccounts($journal)->pluck('id')->toArray();
- $room = bcsub(strval($piggyBank->targetamount), strval($repetition->currentamount));
+ $room = bcsub((string)$piggyBank->targetamount, (string)$repetition->currentamount);
$compare = bcmul($repetition->currentamount, '-1');
Log::debug(sprintf('Will add/remove %f to piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name));
@@ -271,7 +271,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/
public function getMaxOrder(): int
{
- return intval($this->user->piggyBanks()->max('order'));
+ return (int)$this->user->piggyBanks()->max('order');
}
/**
@@ -279,10 +279,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/
public function getPiggyBanks(): Collection
{
- /** @var Collection $set */
- $set = $this->user->piggyBanks()->orderBy('order', 'ASC')->get();
-
- return $set;
+ return $this->user->piggyBanks()->orderBy('order', 'ASC')->get();
}
/**
@@ -408,7 +405,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
public function update(PiggyBank $piggyBank, array $data): PiggyBank
{
$piggyBank->name = $data['name'];
- $piggyBank->account_id = intval($data['account_id']);
+ $piggyBank->account_id = (int)$data['account_id'];
$piggyBank->targetamount = round($data['targetamount'], 2);
$piggyBank->targetdate = $data['targetdate'];
$piggyBank->startdate = $data['startdate'];
diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php
index 50fa719748..d5eb41f507 100644
--- a/app/Repositories/Rule/RuleRepository.php
+++ b/app/Repositories/Rule/RuleRepository.php
@@ -50,9 +50,6 @@ class RuleRepository implements RuleRepositoryInterface
*
* @return bool
*
- * @throws \Exception
- * @throws \Exception
- * @throws \Exception
*/
public function destroy(Rule $rule): bool
{
@@ -99,7 +96,7 @@ class RuleRepository implements RuleRepositoryInterface
*/
public function getHighestOrderInRuleGroup(RuleGroup $ruleGroup): int
{
- return intval($ruleGroup->rules()->max('order'));
+ return (int)$ruleGroup->rules()->max('order');
}
/**
@@ -261,7 +258,7 @@ class RuleRepository implements RuleRepositoryInterface
$rule->rule_group_id = $data['rule_group_id'];
$rule->order = ($order + 1);
$rule->active = 1;
- $rule->stop_processing = 1 === intval($data['stop_processing']);
+ $rule->stop_processing = 1 === (int)$data['stop_processing'];
$rule->title = $data['title'];
$rule->description = strlen($data['description']) > 0 ? $data['description'] : null;
@@ -290,7 +287,7 @@ class RuleRepository implements RuleRepositoryInterface
$ruleAction->active = 1;
$ruleAction->stop_processing = $values['stopProcessing'];
$ruleAction->action_type = $values['action'];
- $ruleAction->action_value = null === $values['value'] ? '' : $values['value'];
+ $ruleAction->action_value = $values['value'] ?? '';
$ruleAction->save();
return $ruleAction;
@@ -310,7 +307,7 @@ class RuleRepository implements RuleRepositoryInterface
$ruleTrigger->active = 1;
$ruleTrigger->stop_processing = $values['stopProcessing'];
$ruleTrigger->trigger_type = $values['action'];
- $ruleTrigger->trigger_value = null === $values['value'] ? '' : $values['value'];
+ $ruleTrigger->trigger_value = $values['value'] ?? '';
$ruleTrigger->save();
return $ruleTrigger;
diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php
index 9d1268d19f..dd90b86cc9 100644
--- a/app/Repositories/RuleGroup/RuleGroupRepository.php
+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php
@@ -50,8 +50,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
*
* @return bool
*
- * @throws \Exception
- * @throws \Exception
+
+
*/
public function destroy(RuleGroup $ruleGroup, ?RuleGroup $moveTo): bool
{
@@ -146,7 +146,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
{
$entry = $this->user->ruleGroups()->max('order');
- return intval($entry);
+ return (int)$entry;
}
/**