Code cleanup

This commit is contained in:
James Cole 2018-04-02 15:10:40 +02:00
parent fa7ab45a40
commit a3c34e6b3c
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
151 changed files with 802 additions and 990 deletions

View File

@ -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]);

View File

@ -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

View File

@ -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');

View File

@ -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'));
}

View File

@ -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);

View File

@ -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]);

View File

@ -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);

View File

@ -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);

View File

@ -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')]);
}

View File

@ -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)
{

View File

@ -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());

View File

@ -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)
{

View File

@ -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);

View File

@ -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']);

View File

@ -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);

View File

@ -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();

View File

@ -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

View File

@ -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) {

View File

@ -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]);

View File

@ -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,

View File

@ -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]);

View File

@ -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();
}
/**

View File

@ -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;
}

View File

@ -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)
)
);

View File

@ -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();
}
/**

View File

@ -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

View File

@ -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);

View File

@ -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
}
/**

View File

@ -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'));

View File

@ -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>';
}
}

View File

@ -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)
{

View File

@ -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)

View File

@ -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
}

View File

@ -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);

View File

@ -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,

View File

@ -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,

View File

@ -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';

View File

@ -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);
}

View File

@ -36,7 +36,7 @@ class FrontpageController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function piggyBanks(PiggyBankRepositoryInterface $repository)
{

View File

@ -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;
}
/**

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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();

View File

@ -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'));

View File

@ -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;

View File

@ -40,7 +40,7 @@ class AccountController extends Controller
*
* @return mixed|string
*
* @throws \Throwable
*/
public function general(Collection $accounts, Carbon $start, Carbon $end)
{

View File

@ -41,7 +41,7 @@ class BalanceController extends Controller
*
* @return mixed|string
*
* @throws \Throwable
*/
public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
{

View File

@ -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)
{

View File

@ -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);

View File

@ -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])) {

View File

@ -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)
{

View File

@ -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();
}
}

View File

@ -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],

View File

@ -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);

View File

@ -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);
}

View File

@ -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'),
];

View File

@ -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);

View File

@ -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

View File

@ -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;
}

View File

@ -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]));

View File

@ -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,

View File

@ -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]);

View File

@ -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);

View File

@ -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 */

View File

@ -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();

View File

@ -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)
{

View File

@ -63,7 +63,7 @@ class Binder
*
* @return mixed
*
* @throws \LogicException
*/
public function handle($request, Closure $next, ...$guards)
{

View File

@ -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(

View File

@ -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) {

View File

@ -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'));
}

View File

@ -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);

View File

@ -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);

View File

@ -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)];
}

View File

@ -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',
];
}
}

View File

@ -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 [

View File

@ -40,7 +40,6 @@ class ExportFormRequest extends Request
/**
* @return array
* @throws \InvalidArgumentException
*/
public function rules()
{

View File

@ -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]);

View File

@ -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);
}
/**

View File

@ -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,

View File

@ -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 [

View File

@ -41,7 +41,6 @@ class SelectTransactionsRequest extends Request
/**
* @return array
* @throws \InvalidArgumentException
*/
public function rules()
{

View File

@ -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',
];
}

View File

@ -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');
}

View File

@ -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';

View File

@ -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();

View File

@ -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';

View File

@ -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, '.', ''));
}
/**

View File

@ -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;

View File

@ -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 . ')';
}

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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 . ')';
}

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}
}

Some files were not shown because too many files have changed in this diff Show More