Strict comparisons.

This commit is contained in:
James Cole 2017-07-15 16:41:07 +02:00
parent c03ab269f0
commit 22144b78ea
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
59 changed files with 110 additions and 107 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ Homestead.json
Homestead.yaml
.env
public/google*.html
report.html

View File

@ -50,10 +50,10 @@ class UpgradeFireflyInstructions extends Command
public function handle()
{
if ($this->argument('task') == 'update') {
if ($this->argument('task') === 'update') {
$this->updateInstructions();
}
if ($this->argument('task') == 'install') {
if ($this->argument('task') === 'install') {
$this->installInstructions();
}
}

View File

@ -259,7 +259,7 @@ class VerifyDatabase extends Command
{
$plural = str_plural($name);
$class = sprintf('FireflyIII\Models\%s', ucfirst($name));
$field = $name == 'tag' ? 'tag' : 'name';
$field = $name === 'tag' ? 'tag' : 'name';
$set = $class::leftJoin($name . '_transaction_journal', $plural . '.id', '=', $name . '_transaction_journal.' . $name . '_id')
->leftJoin('users', $plural . '.user_id', '=', 'users.id')
->distinct()

View File

@ -88,7 +88,7 @@ final class Entry
$entry->budget_name = $object->budget_name ?? '';
// update description when transaction description is different:
if (!is_null($object->description) && $object->description != $entry->description) {
if (!is_null($object->description) && $object->description !== $entry->description) {
$entry->description = $entry->description . ' (' . $object->description . ')';
}

View File

@ -147,13 +147,13 @@ class BalanceLine
if ($this->getBudget() instanceof BudgetModel && !is_null($this->getBudget()->id)) {
return $this->getBudget()->name;
}
if ($this->getRole() == self::ROLE_DEFAULTROLE) {
if ($this->getRole() === self::ROLE_DEFAULTROLE) {
return strval(trans('firefly.no_budget'));
}
if ($this->getRole() == self::ROLE_TAGROLE) {
if ($this->getRole() === self::ROLE_TAGROLE) {
return strval(trans('firefly.coveredWithTags'));
}
if ($this->getRole() == self::ROLE_DIFFROLE) {
if ($this->getRole() === self::ROLE_DIFFROLE) {
return strval(trans('firefly.leftUnbalanced'));
}

View File

@ -96,7 +96,7 @@ class Bill
{
$set = $this->bills->sortBy(
function (BillLine $bill) {
$active = intval($bill->getBill()->active) == 0 ? 1 : 0;
$active = intval($bill->getBill()->active) === 0 ? 1 : 0;
$name = $bill->getBill()->name;
return $active . $name;

View File

@ -244,7 +244,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
foreach ($accounts as $account) {
$leftEntry = $tagsLeft->filter(
function (Tag $tag) use ($account) {
return $tag->account_id == $account->id;
return $tag->account_id === $account->id;
}
);
$left = '0';

View File

@ -56,7 +56,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
/** @var Budget $budget */
foreach ($set as $budget) {
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
if ($budgetLimits->count() == 0) { // no budget limit(s) for this budget
if ($budgetLimits->count() === 0) { // no budget limit(s) for this budget
$spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);// spent for budget in time range
if (bccomp($spent, '0') === -1) {

View File

@ -316,7 +316,7 @@ class AccountController extends Controller
}
}
if ($moment != 'all' && $loop > 1) {
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
'end' => $end->formatLocalized($this->monthAndDayFormat)]

View File

@ -153,7 +153,7 @@ class AttachmentController extends Controller
$image = 'images/page_green.png';
if ($attachment->mime == 'application/pdf') {
if ($attachment->mime === 'application/pdf') {
$image = 'images/page_white_acrobat.png';
}
$file = public_path($image);

View File

@ -175,7 +175,7 @@ class BillController extends Controller
*/
public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill)
{
if (intval($bill->active) == 0) {
if (intval($bill->active) === 0) {
$request->session()->flash('warning', strval(trans('firefly.cannot_scan_inactive_bill')));
return redirect(URL::previous());
@ -206,7 +206,7 @@ class BillController extends Controller
/** @var Carbon $date */
$date = session('start');
$year = $date->year;
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$yearAverage = $repository->getYearAverage($bill, $date);
$overallAverage = $repository->getOverallAverage($bill);

View File

@ -81,7 +81,7 @@ class BudgetController extends Controller
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
if ($amount == 0) {
if ($amount === 0) {
$budgetLimit = null;
}
Preferences::mark();
@ -293,7 +293,7 @@ class BudgetController extends Controller
);
}
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0;
@ -318,7 +318,7 @@ class BudgetController extends Controller
}
}
if ($moment != 'all' && $loop > 1) {
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.without_budget_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
@ -357,7 +357,7 @@ class BudgetController extends Controller
/** @var Carbon $start */
$start = session('first', Carbon::create()->startOfYear());
$end = new Carbon;
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$limits = $this->getLimits($budget, $start, $end);
$repetition = null;
@ -384,11 +384,11 @@ class BudgetController extends Controller
*/
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
{
if ($budgetLimit->budget->id != $budget->id) {
if ($budgetLimit->budget->id !== $budget->id) {
throw new FireflyException('This budget limit is not part of this budget.');
}
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$subTitle = trans(
'firefly.budget_in_period', [

View File

@ -199,7 +199,7 @@ class CategoryController extends Controller
);
}
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0;
@ -224,7 +224,7 @@ class CategoryController extends Controller
}
}
if ($moment != 'all' && $loop > 1) {
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.without_category_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
@ -247,7 +247,7 @@ class CategoryController extends Controller
// default values:
$subTitle = $category->name;
$subTitleIcon = 'fa-bar-chart';
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0;
$loop = 0;
@ -308,7 +308,7 @@ class CategoryController extends Controller
}
}
if ($moment != 'all' && $loop > 1) {
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.journals_in_period_for_category',
['name' => $category->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
@ -463,7 +463,7 @@ class CategoryController extends Controller
$accountRepository = app(AccountRepositoryInterface::class);
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$first = $repository->firstUseDate($category);
if ($first->year == 1900) {
if ($first->year === 1900) {
$first = new Carbon;
}
$range = Preferences::get('viewRange', '1M')->data;

View File

@ -124,7 +124,7 @@ class BudgetController extends Controller
*/
public function budgetLimit(Budget $budget, BudgetLimit $budgetLimit)
{
if ($budgetLimit->budget->id != $budget->id) {
if ($budgetLimit->budget->id !== $budget->id) {
throw new FireflyException('This budget limit is not part of this budget.');
}

View File

@ -67,7 +67,7 @@ class CategoryController extends Controller
$start = $repository->firstUseDate($category);
if ($start->year == 1900) {
if ($start->year === 1900) {
$start = new Carbon;
}

View File

@ -247,7 +247,7 @@ class CategoryReportController extends Controller
// remove all empty entries to prevent cluttering:
$newSet = [];
foreach ($chartData as $key => $entry) {
if (!array_sum($entry['entries']) == 0) {
if (!array_sum($entry['entries']) === 0) {
$newSet[$key] = $chartData[$key];
}
}

View File

@ -231,7 +231,7 @@ class TagReportController extends Controller
// remove all empty entries to prevent cluttering:
$newSet = [];
foreach ($chartData as $key => $entry) {
if (!array_sum($entry['entries']) == 0) {
if (!array_sum($entry['entries']) === 0) {
$newSet[$key] = $chartData[$key];
}
}

View File

@ -107,7 +107,7 @@ class HomeController extends Controller
$types = config('firefly.accountTypesByIdentifier.asset');
$count = $repository->count($types);
if ($count == 0) {
if ($count === 0) {
return redirect(route('new-user.index'));
}

View File

@ -365,7 +365,7 @@ class JsonController extends Controller
$keys = array_keys(config('firefly.rule-triggers'));
$triggers = [];
foreach ($keys as $key) {
if ($key != 'user_action') {
if ($key !== 'user_action') {
$triggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
}
}

View File

@ -93,7 +93,7 @@ class NewUserController extends Controller
$count++;
}
$message = strval(trans('firefly.stored_new_accounts_new_user'));
if ($count == 1) {
if ($count === 1) {
$message = strval(trans('firefly.stored_new_account_new_user'));
}

View File

@ -282,7 +282,7 @@ class RuleController extends Controller
// build trigger array from response
$triggers = $this->getValidTriggerList($request);
if (count($triggers) == 0) {
if (count($triggers) === 0) {
return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]);
}
@ -298,10 +298,10 @@ class RuleController extends Controller
// Warn the user if only a subset of transactions is returned
$warning = '';
if (count($matchingTransactions) == $limit) {
if (count($matchingTransactions) === $limit) {
$warning = trans('firefly.warning_transaction_subset', ['max_num_transactions' => $limit]);
}
if (count($matchingTransactions) == 0) {
if (count($matchingTransactions) === 0) {
$warning = trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]);
}
@ -440,7 +440,7 @@ class RuleController extends Controller
/** @var RuleTrigger $entry */
foreach ($rule->ruleTriggers as $entry) {
if ($entry->trigger_type != 'user_action') {
if ($entry->trigger_type !== 'user_action') {
$count = ($index + 1);
$triggers[] = view(
'rules.partials.trigger',

View File

@ -253,7 +253,7 @@ class RuleGroupController extends Controller
$data = [
'title' => $request->input('title'),
'description' => $request->input('description'),
'active' => intval($request->input('active')) == 1,
'active' => intval($request->input('active')) === 1,
];
$repository->update($ruleGroup, $data);

View File

@ -51,6 +51,10 @@ class SearchController extends Controller
*/
public function index(Request $request, SearchInterface $searcher)
{
$query = $request->get('q');
return view('search.index',compact('query'));
// yes, hard coded values:
$minSearchLen = 1;
$limit = 20;

View File

@ -236,7 +236,7 @@ class TagController extends Controller
// default values:
$subTitle = $tag->tag;
$subTitleIcon = 'fa-tag';
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0;
$loop = 0;
@ -301,7 +301,7 @@ class TagController extends Controller
}
}
if ($moment != 'all' && $loop > 1) {
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.journals_in_period_for_tag',
['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]

View File

@ -86,7 +86,7 @@ class MassController extends Controller
foreach ($ids as $journalId) {
/** @var TransactionJournal $journal */
$journal = $repository->find(intval($journalId));
if (!is_null($journal->id) && $journalId == $journal->id) {
if (!is_null($journal->id) && $journalId === $journal->id) {
$set->push($journal);
}
}

View File

@ -70,7 +70,7 @@ class TransactionController extends Controller
// default values:
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
$types = config('firefly.transactionTypesByWhat.' . $what);
$page = intval($request->get('page')) == 0 ? 1 : intval($request->get('page'));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
$count = 0;
$loop = 0;
@ -131,7 +131,7 @@ class TransactionController extends Controller
}
}
if ($moment != 'all' && $loop > 1) {
if ($moment !== 'all' && $loop > 1) {
$subTitle = trans(
'firefly.title_' . $what . '_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]

View File

@ -37,7 +37,7 @@ class TagFormRequest extends Request
*/
public function collectTagData(): array
{
if ($this->get('setTag') == 'true') {
if ($this->get('setTag') === 'true') {
$latitude = $this->string('latitude');
$longitude = $this->string('longitude');
$zoomLevel = $this->integer('zoomLevel');

View File

@ -36,10 +36,10 @@ class Amount implements ConverterInterface
$decimalPosition = $len - 3;
$decimal = null;
if (($len > 2 && $value{$decimalPosition} == '.') || ($len > 2 && strpos($value, '.') > $decimalPosition)) {
if (($len > 2 && $value{$decimalPosition} === '.') || ($len > 2 && strpos($value, '.') > $decimalPosition)) {
$decimal = '.';
}
if ($len > 2 && $value{$decimalPosition} == ',') {
if ($len > 2 && $value{$decimalPosition} === ',') {
$decimal = ',';
}

View File

@ -42,7 +42,7 @@ class AssetAccountIbans implements MapperInterface
if (strlen($iban) > 0) {
$topList[$account->id] = $account->iban . ' (' . $account->name . ')';
}
if (strlen($iban) == 0) {
if (strlen($iban) === 0) {
$list[$account->id] = $account->name;
}
}

View File

@ -48,7 +48,7 @@ class OpposingAccountIbans implements MapperInterface
if (strlen($iban) > 0) {
$topList[$account->id] = $account->iban . ' (' . $account->name . ')';
}
if (strlen($iban) == 0) {
if (strlen($iban) === 0) {
$list[$account->id] = $account->name;
}
}

View File

@ -152,11 +152,9 @@ class ImportRoutine
Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId));
DB::table('tag_transaction_journal')->insert(['transaction_journal_id' => $journalId, 'tag_id' => $tagId]);
}
Log::debug('Done!');
Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $this->journals->count(), $tag->id, $tag->tag));
return $tag;
}
/**

View File

@ -103,7 +103,7 @@ class AbnAmroDescription implements SpecificInterface
$this->row[8] = $matches[4]; // 'opposing-account-name'
$this->row[7] = $matches[4]; // 'description'
if ($matches[1] == 'GEA') {
if ($matches[1] === 'GEA') {
$this->row[7] = 'GEA ' . $matches[4]; // 'description'
}

View File

@ -80,7 +80,7 @@ class MailError extends Job implements ShouldQueue
Mail::send(
['emails.error-html', 'emails.error-text'], $args,
function (Message $message) use ($email) {
if ($email != 'mail@example.com') {
if ($email !== 'mail@example.com') {
$message->to($email, $email)->subject('Caught an error in Firely III');
}
}

View File

@ -95,7 +95,7 @@ class Account extends Model
/** @var Account $account */
foreach ($set as $account) {
if ($account->name == $fields['name']) {
if ($account->name === $fields['name']) {
return $account;
}
}
@ -116,7 +116,7 @@ class Account extends Model
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}
@ -187,7 +187,7 @@ class Account extends Model
public function getMeta(string $fieldName): string
{
foreach ($this->accountMeta as $meta) {
if ($meta->name == $fieldName) {
if ($meta->name === $fieldName) {
return strval($meta->data);
}
}

View File

@ -55,7 +55,7 @@ class Attachment extends Model
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}

View File

@ -62,7 +62,7 @@ class Bill extends Model
public static function routeBinder(Bill $value)
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}
@ -77,7 +77,7 @@ class Bill extends Model
public function getMatchAttribute($value)
{
if (intval($this->match_encrypted) == 1) {
if (intval($this->match_encrypted) === 1) {
return Crypt::decrypt($value);
}
@ -92,7 +92,7 @@ class Bill extends Model
public function getNameAttribute($value)
{
if (intval($this->name_encrypted) == 1) {
if (intval($this->name_encrypted) === 1) {
return Crypt::decrypt($value);
}

View File

@ -66,7 +66,7 @@ class Budget extends Model
$set = $query->get(['budgets.*']);
/** @var Budget $budget */
foreach ($set as $budget) {
if ($budget->name == $fields['name']) {
if ($budget->name === $fields['name']) {
return $budget;
}
}
@ -85,7 +85,7 @@ class Budget extends Model
public static function routeBinder(Budget $value)
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}

View File

@ -67,7 +67,7 @@ class Category extends Model
$set = $query->get(['categories.*']);
/** @var Category $category */
foreach ($set as $category) {
if ($category->name == $fields['name']) {
if ($category->name === $fields['name']) {
return $category;
}
}
@ -86,7 +86,7 @@ class Category extends Model
public static function routeBinder(Category $value)
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}

View File

@ -124,7 +124,7 @@ class ImportJob extends Model
if (is_null($value)) {
return [];
}
if (strlen($value) == 0) {
if (strlen($value) === 0) {
return [];
}
@ -138,7 +138,7 @@ class ImportJob extends Model
*/
public function getExtendedStatusAttribute($value)
{
if (strlen($value) == 0) {
if (strlen($value) === 0) {
return [];
}

View File

@ -58,7 +58,7 @@ class PiggyBank extends Model
public static function routeBinder(PiggyBank $value)
{
if (auth()->check()) {
if ($value->account->user_id == auth()->user()->id) {
if ($value->account->user_id === auth()->user()->id) {
return $value;
}
}

View File

@ -51,7 +51,7 @@ class Rule extends Model
public static function routeBinder(Rule $value)
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}

View File

@ -52,7 +52,7 @@ class RuleGroup extends Model
public static function routeBinder(RuleGroup $value)
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}

View File

@ -66,7 +66,7 @@ class Tag extends Model
$set = $query->get(['tags.*']);
/** @var Tag $tag */
foreach ($set as $tag) {
if ($tag->tag == $fields['tag']) {
if ($tag->tag === $fields['tag']) {
return $tag;
}
}
@ -87,7 +87,7 @@ class Tag extends Model
public static function routeBinder(Tag $value)
{
if (auth()->check()) {
if ($value->user_id == auth()->user()->id) {
if ($value->user_id === auth()->user()->id) {
return $value;
}
}

View File

@ -207,7 +207,7 @@ class TransactionJournal extends Model
public function isDeposit(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::DEPOSIT;
return $this->transaction_type_type === TransactionType::DEPOSIT;
}
return $this->transactionType->isDeposit();
@ -220,7 +220,7 @@ class TransactionJournal extends Model
public function isOpeningBalance(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::OPENING_BALANCE;
return $this->transaction_type_type === TransactionType::OPENING_BALANCE;
}
return $this->transactionType->isOpeningBalance();
@ -233,7 +233,7 @@ class TransactionJournal extends Model
public function isTransfer(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::TRANSFER;
return $this->transaction_type_type === TransactionType::TRANSFER;
}
return $this->transactionType->isTransfer();
@ -246,7 +246,7 @@ class TransactionJournal extends Model
public function isWithdrawal(): bool
{
if (!is_null($this->transaction_type_type)) {
return $this->transaction_type_type == TransactionType::WITHDRAWAL;
return $this->transaction_type_type === TransactionType::WITHDRAWAL;
}
return $this->transactionType->isWithdrawal();

View File

@ -179,7 +179,7 @@ class AccountRepository implements AccountRepositoryInterface
{
// update the account:
$account->name = $data['name'];
$account->active = $data['active'] == '1' ? true : false;
$account->active = $data['active'] === '1' ? true : false;
$account->virtual_balance = $data['virtualBalance'];
$account->iban = $data['iban'];
$account->save();
@ -460,12 +460,12 @@ class AccountRepository implements AccountRepositoryInterface
// update transactions:
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
if ($account->id == $transaction->account_id) {
if ($account->id === $transaction->account_id) {
$transaction->amount = $amount;
$transaction->transaction_currency_id = $currencyId;
$transaction->save();
}
if ($account->id != $transaction->account_id) {
if ($account->id !== $transaction->account_id) {
$transaction->amount = bcmul($amount, '-1');
$transaction->transaction_currency_id = $currencyId;
$transaction->save();

View File

@ -116,7 +116,7 @@ class BillRepository implements BillRepositoryInterface
$set = $set->sortBy(
function (Bill $bill) {
$int = $bill->active == 1 ? 0 : 1;
$int = $bill->active === 1 ? 0 : 1;
return $int . strtolower($bill->name);
}
@ -168,7 +168,7 @@ class BillRepository implements BillRepositoryInterface
$set = $set->sortBy(
function (Bill $bill) {
$int = $bill->active == 1 ? 0 : 1;
$int = $bill->active === 1 ? 0 : 1;
return $int . strtolower($bill->name);
}
@ -500,7 +500,7 @@ class BillRepository implements BillRepositoryInterface
return true;
}
if ($bill->id == $journal->bill_id) {
if ($bill->id === $journal->bill_id) {
// if no match, but bill used to match, remove it:
$journal->bill_id = null;
$journal->save();

View File

@ -73,7 +73,7 @@ trait UpdateJournalsTrait
protected function updateDestinationTransaction(TransactionJournal $journal, Account $account, array $data)
{
$set = $journal->transactions()->where('amount', '>', 0)->get();
if ($set->count() != 1) {
if ($set->count() !== 1) {
throw new FireflyException(sprintf('Journal #%d has %d transactions with an amount more than zero.', $journal->id, $set->count()));
}
/** @var Transaction $transaction */
@ -98,7 +98,7 @@ trait UpdateJournalsTrait
{
// should be one:
$set = $journal->transactions()->where('amount', '<', 0)->get();
if ($set->count() != 1) {
if ($set->count() !== 1) {
throw new FireflyException(sprintf('Journal #%d has %d transactions with an amount more than zero.', $journal->id, $set->count()));
}
/** @var Transaction $transaction */
@ -140,7 +140,7 @@ trait UpdateJournalsTrait
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->whereNotIn('tag_id', $ids)->delete();
}
// if count is zero, delete them all:
if (count($ids) == 0) {
if (count($ids) === 0) {
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->delete();
}

View File

@ -236,7 +236,7 @@ class RuleRepository implements RuleRepositoryInterface
$rule->rule_group_id = $data['rule_group_id'];
$rule->order = ($order + 1);
$rule->active = 1;
$rule->stop_processing = intval($data['stop_processing']) == 1;
$rule->stop_processing = intval($data['stop_processing']) === 1;
$rule->title = $data['title'];
$rule->description = strlen($data['description']) > 0 ? $data['description'] : null;

View File

@ -282,7 +282,7 @@ class TagRepository implements TagRepositoryInterface
* changed to an advancePayment.
*/
if ($tag->tagMode == 'balancingAct' || $tag->tagMode == 'nothing') {
if ($tag->tagMode === 'balancingAct' || $tag->tagMode === 'nothing') {
foreach ($tag->transactionjournals as $journal) {
if ($journal->isTransfer()) {
return false;
@ -394,7 +394,7 @@ class TagRepository implements TagRepositoryInterface
}
// if already has transaction journals, must match ALL asset account id's:
if ($deposits > 0 || $withdrawals == 1) {
if ($deposits > 0 || $withdrawals === 1) {
Log::debug('Need to match all asset accounts.');
return $this->matchAll($journal, $tag);

View File

@ -52,7 +52,7 @@ class RemoveTag implements ActionInterface
/** @var Tag $tag */
$tag = $journal->user->tags()->get()->filter(
function (Tag $tag) use ($name) {
return $tag->tag == $name;
return $tag->tag === $name;
}
)->first();

View File

@ -56,7 +56,7 @@ class SetBudget implements ActionInterface
$budgets = $repository->getActiveBudgets();
$budget = $budgets->filter(
function (Budget $current) use ($search) {
return $current->name == $search;
return $current->name === $search;
}
)->first();
if (is_null($budget)) {
@ -65,7 +65,7 @@ class SetBudget implements ActionInterface
return true;
}
if ($journal->transactionType->type == TransactionType::TRANSFER) {
if ($journal->transactionType->type === TransactionType::TRANSFER) {
Log::debug(sprintf('RuleAction SetBudget could not set budget of journal #%d to "%s" because journal is a transfer.', $journal->id, $search));
return true;

View File

@ -254,7 +254,7 @@ final class Processor
}
}
$result = ($hitTriggers == $foundTriggers && $foundTriggers > 0);
$result = ($hitTriggers === $foundTriggers && $foundTriggers > 0);
Log::debug('Result of triggered()', ['hitTriggers' => $hitTriggers, 'foundTriggers' => $foundTriggers, 'result' => $result]);
return $result;

View File

@ -75,7 +75,7 @@ class CacheProperties
*/
public function has(): bool
{
if (getenv('APP_ENV') == 'testing') {
if (getenv('APP_ENV') === 'testing') {
return false;
}
$this->md5();

View File

@ -96,7 +96,7 @@ class Navigation
// if the range is custom, the end of the period
// is another X days (x is the difference between start)
// and end added to $theCurrentEnd
if ($repeatFreq == 'custom') {
if ($repeatFreq === 'custom') {
/** @var Carbon $tStart */
$tStart = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $tEnd */
@ -393,7 +393,7 @@ class Navigation
return $date;
}
if ($repeatFreq == 'half-year' || $repeatFreq == '6M') {
if ($repeatFreq === 'half-year' || $repeatFreq === '6M') {
$month = $date->month;
$date->startOfYear();
if ($month >= 7) {
@ -496,7 +496,7 @@ class Navigation
return $end;
}
if ($range == '6M') {
if ($range === '6M') {
if ($start->month >= 7) {
$end->endOfYear();
@ -532,7 +532,7 @@ class Navigation
return $start;
}
if ($range == '6M') {
if ($range === '6M') {
if ($start->month >= 7) {
$start->startOfYear()->addMonths(6);

View File

@ -110,7 +110,7 @@ class General extends Twig_Extension
$what = $args[2]; // name of the route.
$activeWhat = $context['what'] ?? false;
if ($what == $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
if ($what === $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active';
}
@ -132,7 +132,7 @@ class General extends Twig_Extension
$args = func_get_args();
$route = $args[0]; // name of the route.
if (Route::getCurrentRoute()->getName() == $route) {
if (Route::getCurrentRoute()->getName() === $route) {
return 'active';
}

View File

@ -51,7 +51,7 @@ class Journal extends Twig_Extension
$array = [];
/** @var Account $entry */
foreach ($list as $entry) {
if ($entry->accountType->type == AccountType::CASH) {
if ($entry->accountType->type === AccountType::CASH) {
$array[] = '<span class="text-success">(cash)</span>';
continue;
}
@ -123,7 +123,7 @@ class Journal extends Twig_Extension
$array = [];
/** @var Account $entry */
foreach ($list as $entry) {
if ($entry->accountType->type == 'Cash account') {
if ($entry->accountType->type === AccountType::CASH) {
$array[] = '<span class="text-success">(cash)</span>';
continue;
}

View File

@ -70,7 +70,7 @@ class Rule extends Twig_Extension
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));
$possibleTriggers = [];
foreach ($ruleTriggers as $key) {
if ($key != 'user_action') {
if ($key !== 'user_action') {
$possibleTriggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
}
}

View File

@ -149,7 +149,7 @@ class User extends Authenticatable
{
foreach ($this->roles as $role) {
if ($role->name == $name) {
if ($role->name === $name) {
return true;
}
}

View File

@ -211,7 +211,7 @@ class FireflyValidator extends Validator
// count budgets, should have at least one
$count = $budgets->filter(
function (Budget $budget) use ($value) {
return $budget->name == $value;
return $budget->name === $value;
}
)->count();
@ -329,7 +329,7 @@ class FireflyValidator extends Validator
/** @var AccountMeta $entry */
foreach ($set as $entry) {
if ($entry->data == $value) {
if ($entry->data === $value) {
return false;
}
@ -398,7 +398,7 @@ class FireflyValidator extends Validator
/** @var PiggyBank $entry */
foreach ($set as $entry) {
$fieldValue = $this->tryDecrypt($entry->name);
if ($fieldValue == $value) {
if ($fieldValue === $value) {
return false;
}
}
@ -460,7 +460,7 @@ class FireflyValidator extends Validator
$set = $user->accounts()->where('account_type_id', $type->id)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
if ($entry->name === $value) {
return false;
}
}
@ -486,7 +486,7 @@ class FireflyValidator extends Validator
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
if ($entry->name === $value) {
return false;
}
}
@ -510,7 +510,7 @@ class FireflyValidator extends Validator
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
if ($entry->name === $value) {
return false;
}
}
@ -534,7 +534,7 @@ class FireflyValidator extends Validator
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
if ($entry->name === $value) {
return false;
}
}