Various phpstan fixes

This commit is contained in:
James Cole
2023-11-28 04:45:07 +01:00
parent 8604b05d07
commit 14e9d73768
24 changed files with 133 additions and 58 deletions

View File

@@ -31,7 +31,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Middleware\Installer; use FireflyIII\Http\Middleware\Installer;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
@@ -69,7 +68,7 @@ class HomeController extends Controller
public function dateRange(Request $request): JsonResponse public function dateRange(Request $request): JsonResponse
{ {
$stringStart = ''; $stringStart = '';
$stringEnd = ''; $stringEnd = '';
try { try {
$stringStart = e((string)$request->get('start')); $stringStart = e((string)$request->get('start'));
$start = Carbon::createFromFormat('Y-m-d', $stringStart); $start = Carbon::createFromFormat('Y-m-d', $stringStart);
@@ -84,6 +83,13 @@ class HomeController extends Controller
app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd)); app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd));
$end = Carbon::now()->endOfMonth(); $end = Carbon::now()->endOfMonth();
} }
if (false === $start) {
$start = Carbon::now()->startOfMonth();
}
if (false === $end) {
$end = Carbon::now()->endOfMonth();
}
$label = $request->get('label'); $label = $request->get('label');
$isCustomRange = false; $isCustomRange = false;
@@ -128,20 +134,26 @@ class HomeController extends Controller
if (0 === $count) { if (0 === $count) {
return redirect(route('new-user.index')); return redirect(route('new-user.index'));
} }
$subTitle = (string)trans('firefly.welcome_back'); $subTitle = (string)trans('firefly.welcome_back');
$transactions = []; $transactions = [];
$frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray()); $frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
$frontPageArray = $frontPage->data;
if (!is_array($frontPageArray)) {
$frontPageArray = [];
}
/** @var Carbon $start */ /** @var Carbon $start */
$start = session('start', today(config('app.timezone'))->startOfMonth()); $start = session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $end */ /** @var Carbon $end */
$end = session('end', today(config('app.timezone'))->endOfMonth()); $end = session('end', today(config('app.timezone'))->endOfMonth());
$accounts = $repository->getAccountsById($frontPage->data); $accounts = $repository->getAccountsById($frontPageArray);
$today = today(config('app.timezone')); $today = today(config('app.timezone'));
// sort frontpage accounts by order // sort frontpage accounts by order
$accounts = $accounts->sortBy('order'); $accounts = $accounts->sortBy('order');
app('log')->debug('Frontpage accounts are ', $frontPage->data); app('log')->debug('Frontpage accounts are ', $frontPageArray);
/** @var BillRepositoryInterface $billRepository */ /** @var BillRepositoryInterface $billRepository */
$billRepository = app(BillRepositoryInterface::class); $billRepository = app(BillRepositoryInterface::class);

View File

@@ -79,6 +79,11 @@ class RecurrenceController extends Controller
$repetitionType = explode(',', $request->get('type'))[0]; $repetitionType = explode(',', $request->get('type'))[0];
$repetitions = (int)$request->get('reps'); $repetitions = (int)$request->get('reps');
$repetitionMoment = ''; $repetitionMoment = '';
if(false === $start || false === $end || false === $firstDate || false === $endDate) {
return response()->json();
}
$start->startOfDay(); $start->startOfDay();
// if $firstDate is beyond $end, simply return an empty array. // if $firstDate is beyond $end, simply return an empty array.
@@ -148,10 +153,14 @@ class RecurrenceController extends Controller
$string = '' === (string)$request->get('date') ? date('Y-m-d') : (string)$request->get('date'); $string = '' === (string)$request->get('date') ? date('Y-m-d') : (string)$request->get('date');
$today = today(config('app.timezone'))->startOfDay(); $today = today(config('app.timezone'))->startOfDay();
try { try {
$date = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'))->startOfDay(); $date = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'));
} catch (InvalidFormatException $e) { } catch (InvalidFormatException $e) {
$date = Carbon::today(config('app.timezone')); $date = Carbon::today(config('app.timezone'));
} }
if(false === $date) {
return response()->json();
}
$date->startOfDay();
$preSelected = (string)$request->get('pre_select'); $preSelected = (string)$request->get('pre_select');
$locale = app('steam')->getLocale(); $locale = app('steam')->getLocale();

View File

@@ -91,13 +91,18 @@ class PreferencesController extends Controller
if ('opt_group_' === $role) { if ('opt_group_' === $role) {
$role = 'opt_group_defaultAsset'; $role = 'opt_group_defaultAsset';
} }
$groupedAccounts[trans(sprintf('firefly.%s', $role))][$account->id] = $account->name; $groupedAccounts[(string)trans(sprintf('firefly.%s', $role))][$account->id] = $account->name;
} }
ksort($groupedAccounts); ksort($groupedAccounts);
$accountIds = $accounts->pluck('id')->toArray(); /** @var array<int, int> $accountIds */
$viewRange = app('navigation')->getViewRange(false); $accountIds = $accounts->pluck('id')->toArray();
$frontPageAccounts = app('preferences')->get('frontPageAccounts', $accountIds); $viewRange = app('navigation')->getViewRange(false);
$frontPageAccountsPref = app('preferences')->get('frontPageAccounts', $accountIds);
$frontPageAccounts = $frontPageAccountsPref->data;
if (!is_array($frontPageAccounts)) {
$frontPageAccounts = $accountIds;
}
$language = app('steam')->getLanguage(); $language = app('steam')->getLanguage();
$languages = config('firefly.languages'); $languages = config('firefly.languages');
$locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data; $locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data;
@@ -106,7 +111,10 @@ class PreferencesController extends Controller
$slackUrl = app('preferences')->get('slack_webhook_url', '')->data; $slackUrl = app('preferences')->get('slack_webhook_url', '')->data;
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data; $customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
$fiscalYearStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data; $fiscalYearStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr; if (is_array($fiscalYearStartStr)) {
$fiscalYearStartStr = '01-01';
}
$fiscalYearStart = sprintf('%s-%s', date('Y'), (string)$fiscalYearStartStr);
$tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data; $tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$availableDarkModes = config('firefly.available_dark_modes'); $availableDarkModes = config('firefly.available_dark_modes');
@@ -121,7 +129,7 @@ class PreferencesController extends Controller
// list of locales also has "equal" which makes it equal to whatever the language is. // list of locales also has "equal" which makes it equal to whatever the language is.
try { try {
$locales = json_decode(file_get_contents(resource_path(sprintf('lang/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR); $locales = json_decode((string)file_get_contents(resource_path(sprintf('lang/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) { } catch (JsonException $e) {
app('log')->error($e->getMessage()); app('log')->error($e->getMessage());
$locales = []; $locales = [];
@@ -129,12 +137,12 @@ class PreferencesController extends Controller
$locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales; $locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales;
// an important fallback is that the frontPageAccount array gets refilled automatically // an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty. // when it turns up empty.
if (0 === count($frontPageAccounts->data)) { if (0 === count($frontPageAccounts)) {
$frontPageAccounts = $accountIds; $frontPageAccounts = $accountIds;
} }
// for the demo user, the slackUrl is automatically emptied. // for the demo user, the slackUrl is automatically emptied.
// this isn't really secure but it means that the demo site has a semi-secret // this isn't really secure, but it means that the demo site has a semi-secret
// slackUrl. // slackUrl.
if (auth()->user()->hasRole('demo')) { if (auth()->user()->hasRole('demo')) {
$slackUrl = ''; $slackUrl = '';

View File

@@ -36,7 +36,6 @@ use FireflyIII\Http\Requests\ProfileFormRequest;
use FireflyIII\Http\Requests\TokenFormRequest; use FireflyIII\Http\Requests\TokenFormRequest;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Support\Http\Controllers\CreateStuff; use FireflyIII\Support\Http\Controllers\CreateStuff;
use FireflyIII\User; use FireflyIII\User;
use Google2FA; use Google2FA;
@@ -129,6 +128,9 @@ class ProfileController extends Controller
// get secret from session and flash // get secret from session and flash
$secret = $secretPreference->data; $secret = $secretPreference->data;
} }
if (is_array($secret)) {
$secret = '';
}
// generate recovery codes if not in session: // generate recovery codes if not in session:
$recoveryCodes = ''; $recoveryCodes = '';
@@ -144,10 +146,13 @@ class ProfileController extends Controller
if (null !== $codesPreference) { if (null !== $codesPreference) {
$recoveryCodes = $codesPreference->data; $recoveryCodes = $codesPreference->data;
} }
if (!is_array($recoveryCodes)) {
$recoveryCodes = [];
}
$codes = implode("\r\n", $recoveryCodes); $codes = implode("\r\n", $recoveryCodes);
$image = Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret); $image = Google2FA::getQRCodeInline($domain, auth()->user()->email, (string)$secret);
return view('profile.code', compact('image', 'secret', 'codes')); return view('profile.code', compact('image', 'secret', 'codes'));
} }
@@ -283,7 +288,11 @@ class ProfileController extends Controller
$subTitle = $user->email; $subTitle = $user->email;
$userId = $user->id; $userId = $user->id;
$enabled2FA = null !== $user->mfa_secret; $enabled2FA = null !== $user->mfa_secret;
$mfaBackupCount = count(app('preferences')->get('mfa_recovery', [])->data); $recoveryData = app('preferences')->get('mfa_recovery', [])->data;
if (!is_array($recoveryData)) {
$recoveryData = [];
}
$mfaBackupCount = count($recoveryData);
$this->createOAuthKeys(); $this->createOAuthKeys();
if (0 === $count) { if (0 === $count) {
@@ -499,6 +508,12 @@ class ProfileController extends Controller
/** @var UserRepositoryInterface $repository */ /** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class); $repository = app(UserRepositoryInterface::class);
$secret = app('preferences')->get('temp-mfa-secret')?->data; $secret = app('preferences')->get('temp-mfa-secret')?->data;
if (is_array($secret)) {
$secret = null;
}
if (is_int($secret)) {
$secret = (string)$secret;
}
$repository->setMFACode($user, $secret); $repository->setMFACode($user, $secret);

View File

@@ -181,6 +181,7 @@ class EditController extends Controller
$request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title])); $request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
// store new attachment(s): // store new attachment(s):
/** @var array|null $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null; $files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) { if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($recurrence, $files); $this->attachments->saveAttachmentsForModel($recurrence, $files);

View File

@@ -49,12 +49,8 @@ use Psr\Container\NotFoundExceptionInterface;
class ReportController extends Controller class ReportController extends Controller
{ {
use RenderPartialViews; use RenderPartialViews;
protected ReportHelperInterface $helper;
/** @var ReportHelperInterface Helper interface. */ private BudgetRepositoryInterface $repository;
protected $helper;
/** @var BudgetRepositoryInterface The budget repository */
private $repository;
/** /**
* ReportController constructor. * ReportController constructor.
@@ -291,7 +287,7 @@ class ReportController extends Controller
if ('opt_group_' === $role) { if ('opt_group_' === $role) {
$role = 'opt_group_defaultAsset'; $role = 'opt_group_defaultAsset';
} }
$groupedAccounts[trans(sprintf('firefly.%s', $role))][$account->id] = $account; $groupedAccounts[(string)trans(sprintf('firefly.%s', $role))][$account->id] = $account;
} }
ksort($groupedAccounts); ksort($groupedAccounts);

View File

@@ -220,7 +220,7 @@ class CreateController extends Controller
]; ];
// restore actions and triggers from old input: // restore actions and triggers from old input:
if (null !== $request->old() && count($request->old()) > 0) { if (null !== $request->old() && is_array($request->old()) && count($request->old()) > 0) {
$oldTriggers = $this->getPreviousTriggers($request); $oldTriggers = $this->getPreviousTriggers($request);
$oldActions = $this->getPreviousActions($request); $oldActions = $this->getPreviousActions($request);
} }

View File

@@ -100,7 +100,7 @@ class EditController extends Controller
$oldTriggers = $this->parseFromOperators($operators); $oldTriggers = $this->parseFromOperators($operators);
} }
// has old input? // has old input?
if (count($request->old()) > 0) { if (null !== $request->old() && is_array($request->old()) && count($request->old()) > 0) {
$oldTriggers = $this->getPreviousTriggers($request); $oldTriggers = $this->getPreviousTriggers($request);
$oldActions = $this->getPreviousActions($request); $oldActions = $this->getPreviousActions($request);
} }

View File

@@ -137,6 +137,7 @@ class SelectController extends Controller
{ {
// build fake rule // build fake rule
$rule = new Rule(); $rule = new Rule();
/** @var \Illuminate\Database\Eloquent\Collection<int, RuleTrigger> $triggers */
$triggers = new Collection(); $triggers = new Collection();
$rule->strict = '1' === $request->get('strict'); $rule->strict = '1' === $request->get('strict');

View File

@@ -117,7 +117,7 @@ class InstallController extends Controller
} catch (FireflyException $e) { } catch (FireflyException $e) {
app('log')->error($e->getMessage()); app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString()); app('log')->error($e->getTraceAsString());
if (strpos($e->getMessage(), 'open_basedir restriction in effect')) { if (str_contains($e->getMessage(), 'open_basedir restriction in effect')) {
$this->lastError = self::BASEDIR_ERROR; $this->lastError = self::BASEDIR_ERROR;
} }
$result = false; $result = false;

View File

@@ -99,9 +99,9 @@ class DeleteController extends Controller
* *
* @param TransactionGroup $group * @param TransactionGroup $group
* *
* @return RedirectResponse * @return RedirectResponse|Redirector
*/ */
public function destroy(TransactionGroup $group): RedirectResponse public function destroy(TransactionGroup $group): RedirectResponse|Redirector
{ {
app('log')->debug(sprintf('Now in %s(#%d).', __METHOD__, $group->id)); app('log')->debug(sprintf('Now in %s(#%d).', __METHOD__, $group->id));
if (!$this->isEditableGroup($group)) { if (!$this->isEditableGroup($group)) {

View File

@@ -163,9 +163,9 @@ class ShowController extends Controller
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']); $amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);
if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount']
&& bccomp( && bccomp(
'0', '0',
$transaction['foreign_amount'] $transaction['foreign_amount']
) !== 0) { ) !== 0) {
// same for foreign currency: // same for foreign currency:
$foreignSymbol = $transaction['foreign_currency_symbol']; $foreignSymbol = $transaction['foreign_currency_symbol'];
if (!array_key_exists($foreignSymbol, $amounts)) { if (!array_key_exists($foreignSymbol, $amounts)) {
@@ -192,7 +192,10 @@ class ShowController extends Controller
*/ */
private function getAccounts(array $group): array private function getAccounts(array $group): array
{ {
$accounts = []; $accounts = [
'source' => [],
'destination' => [],
];
foreach ($group['transactions'] as $transaction) { foreach ($group['transactions'] as $transaction) {
$accounts['source'][] = [ $accounts['source'][] = [

View File

@@ -69,6 +69,10 @@ class Range
// ignore preference. set the range to be the current month: // ignore preference. set the range to be the current month:
if (!app('session')->has('start') && !app('session')->has('end')) { if (!app('session')->has('start') && !app('session')->has('end')) {
$viewRange = app('preferences')->get('viewRange', '1M')->data; $viewRange = app('preferences')->get('viewRange', '1M')->data;
if(is_array($viewRange)) {
$viewRange = '1M';
}
$today = today(config('app.timezone')); $today = today(config('app.timezone'));
$start = app('navigation')->updateStartDate($viewRange, $today); $start = app('navigation')->updateStartDate($viewRange, $today);
$end = app('navigation')->updateEndDate($viewRange, $start); $end = app('navigation')->updateEndDate($viewRange, $start);

View File

@@ -151,7 +151,7 @@ class ReportFormRequest extends FormRequest
// validate as date // validate as date
// if regex for YYYY-MM-DD: // if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/'; $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
if (preg_match($pattern, $string)) { if (false !== preg_match($pattern, $string)) {
try { try {
$date = new Carbon($parts[1]); $date = new Carbon($parts[1]);
} catch (Exception $e) { // intentional generic exception } catch (Exception $e) { // intentional generic exception
@@ -186,7 +186,7 @@ class ReportFormRequest extends FormRequest
// validate as date // validate as date
// if regex for YYYY-MM-DD: // if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/'; $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
if (preg_match($pattern, $string)) { if (false !== preg_match($pattern, $string)) {
try { try {
$date = new Carbon($parts[0]); $date = new Carbon($parts[0]);
} catch (Exception $e) { // intentional generic exception } catch (Exception $e) { // intentional generic exception

View File

@@ -121,6 +121,9 @@ class DownloadExchangeRates implements ShouldQueue
return; return;
} }
$date = Carbon::createFromFormat('Y-m-d', $json['date'], config('app.timezone')); $date = Carbon::createFromFormat('Y-m-d', $json['date'], config('app.timezone'));
if(false === $date) {
return;
}
$this->saveRates($currency, $date, $json['rates']); $this->saveRates($currency, $date, $json['rates']);
} }

View File

@@ -53,7 +53,7 @@ class InvitationMail extends Mailable
$this->invitee = $invitee; $this->invitee = $invitee;
$this->admin = $admin; $this->admin = $admin;
$this->url = $url; $this->url = $url;
$this->host = parse_url($url, PHP_URL_HOST); $this->host = (string) parse_url($url, PHP_URL_HOST);
} }
/** /**

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models; namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent; use Eloquent;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait; use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait; use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
@@ -33,11 +34,9 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Builder;
use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@@ -47,8 +46,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon|null $created_at * @property Carbon|null $created_at
* @property Carbon|null $updated_at * @property Carbon|null $updated_at
* @property Carbon|null $deleted_at * @property Carbon|null $deleted_at
* @property int $user_id * @property int $user_id
* @property int $transaction_currency_id * @property int $transaction_currency_id
* @property string $name * @property string $name
* @property string $match * @property string $match
* @property string $amount_min * @property string $amount_min
@@ -57,12 +56,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon|null $end_date * @property Carbon|null $end_date
* @property Carbon|null $extension_date * @property Carbon|null $extension_date
* @property string $repeat_freq * @property string $repeat_freq
* @property int|string $skip * @property int $skip
* @property bool $automatch * @property bool $automatch
* @property bool $active * @property bool $active
* @property bool $name_encrypted * @property bool $name_encrypted
* @property bool $match_encrypted * @property bool $match_encrypted
* @property int $order * @property int $order
* @property-read Collection|Attachment[] $attachments * @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count * @property-read int|null $attachments_count
* @property-read Collection|Note[] $notes * @property-read Collection|Note[] $notes
@@ -99,7 +98,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserId($value) * @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserId($value)
* @method static Builder|Bill withTrashed() * @method static Builder|Bill withTrashed()
* @method static Builder|Bill withoutTrashed() * @method static Builder|Bill withoutTrashed()
* @property int $user_group_id * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value) * @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)
* @mixin Eloquent * @mixin Eloquent
*/ */
@@ -247,6 +246,18 @@ class Bill extends Model
); );
} }
/**
* Get the skip
*
* @return Attribute
*/
protected function skip(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
);
}
/** /**
* Get the min amount * Get the min amount
* *
@@ -265,7 +276,7 @@ class Bill extends Model
protected function transactionCurrencyId(): Attribute protected function transactionCurrencyId(): Attribute
{ {
return Attribute::make( return Attribute::make(
get: static fn($value) => (int)$value, get: static fn ($value) => (int)$value,
); );
} }
@@ -275,7 +286,7 @@ class Bill extends Model
protected function order(): Attribute protected function order(): Attribute
{ {
return Attribute::make( return Attribute::make(
get: static fn($value) => (int)$value, get: static fn ($value) => (int)$value,
); );
} }

View File

@@ -94,7 +94,7 @@ class Preference extends Model
$preference = new self(); $preference = new self();
$preference->name = $value; $preference->name = $value;
$preference->data = $default[$value]; $preference->data = $default[$value];
$preference->user_id = $user->id; $preference->user_id = (int) $user->id;
$preference->save(); $preference->save();
return $preference; return $preference;

View File

@@ -95,7 +95,7 @@ class TransactionJournalMeta extends Model
{ {
$data = json_encode($value); $data = json_encode($value);
$this->attributes['data'] = $data; $this->attributes['data'] = $data;
$this->attributes['hash'] = hash('sha256', $data); $this->attributes['hash'] = (string) hash('sha256', $data);
} }
/** /**

View File

@@ -122,8 +122,11 @@ class BillReminder extends Notification
{ {
/** @var User|null $user */ /** @var User|null $user */
$user = auth()->user(); $user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) { if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string) $slackUrl)) {
return ['mail', 'slack']; return ['mail', 'slack'];
} }
return ['mail']; return ['mail'];

View File

@@ -98,8 +98,11 @@ class NewAccessToken extends Notification
{ {
/** @var User|null $user */ /** @var User|null $user */
$user = auth()->user(); $user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) { if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack']; return ['mail', 'slack'];
} }
return ['mail']; return ['mail'];

View File

@@ -106,8 +106,11 @@ class RuleActionFailed extends Notification
{ {
/** @var User|null $user */ /** @var User|null $user */
$user = auth()->user(); $user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) { if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
app('log')->debug('Will send ruleActionFailed through Slack!'); app('log')->debug('Will send ruleActionFailed through Slack!');
return ['slack']; return ['slack'];
} }

View File

@@ -125,8 +125,11 @@ class UserLogin extends Notification
{ {
/** @var User|null $user */ /** @var User|null $user */
$user = auth()->user(); $user = auth()->user();
$slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) { if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string) $slackUrl)) {
return ['mail', 'slack']; return ['mail', 'slack'];
} }
return ['mail']; return ['mail'];

View File

@@ -123,7 +123,7 @@ interface AccountRepositoryInterface
public function getAccountsById(array $accountIds): Collection; public function getAccountsById(array $accountIds): Collection;
/** /**
* @param array<int, string> $types * @param array<int, int|string> $types
* @param array|null $sort * @param array|null $sort
* *
* @return Collection * @return Collection