From 1b978d41e0234c05f69f1b12193225827d087fa8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 5 Nov 2023 09:40:45 +0100 Subject: [PATCH] Fix all level 2 issues. --- .ci/phpstan.neon | 7 ++----- .../Correction/DeleteOrphanedTransactions.php | 2 +- app/Console/Commands/Correction/FixUnevenAmount.php | 2 +- .../Commands/Upgrade/UpgradeLiabilitiesEight.php | 2 +- app/Helpers/Update/UpdateTrait.php | 2 +- app/Http/Controllers/Account/EditController.php | 12 ++++++------ app/Http/Controllers/Bill/EditController.php | 2 +- app/Http/Controllers/Budget/EditController.php | 2 +- app/Http/Controllers/Controller.php | 2 +- app/Http/Controllers/DebugController.php | 2 +- app/Http/Controllers/PiggyBank/EditController.php | 2 +- app/Http/Controllers/Recurring/CreateController.php | 6 +++--- app/Http/Controllers/Rule/CreateController.php | 8 ++++---- app/Http/Controllers/TagController.php | 6 +++--- app/Http/Controllers/Transaction/IndexController.php | 4 ++-- app/Http/Middleware/Range.php | 2 +- app/Models/Account.php | 2 +- app/Models/TransactionJournalLink.php | 6 +++--- app/Repositories/Account/AccountRepository.php | 2 +- app/Repositories/Bill/BillRepository.php | 6 +++--- app/Repositories/Budget/BudgetRepository.php | 2 +- app/Repositories/Category/CategoryRepository.php | 2 +- app/Repositories/Journal/JournalAPIRepository.php | 2 +- app/Repositories/PiggyBank/PiggyBankRepository.php | 2 +- app/Repositories/User/UserRepository.php | 2 +- app/Support/FireflyConfig.php | 2 +- app/Support/Request/AppendsLocationData.php | 4 ++-- app/Support/Steam.php | 4 ++-- app/Transformers/BillTransformer.php | 2 +- app/Transformers/PiggyBankEventTransformer.php | 4 ++-- app/Transformers/PiggyBankTransformer.php | 2 +- app/Validation/RecurrenceValidation.php | 2 +- 32 files changed, 53 insertions(+), 56 deletions(-) diff --git a/.ci/phpstan.neon b/.ci/phpstan.neon index d72945c553..2f266733a7 100644 --- a/.ci/phpstan.neon +++ b/.ci/phpstan.neon @@ -4,10 +4,8 @@ parameters: reportUnmatchedIgnoredErrors: false checkGenericClassInNonGenericObjectType: false # remove this rule when all other issues are solved. ignoreErrors: + - '#Dynamic call to static method#' # all the Laravel ORM things depend on this. - '#Control structures using switch should not be used.#' # switch is fine insome cases. - - '#Use unique name to make classes easy to recognize#' - - '#Do not name "e", shorter than 2 chars#' - - '#Do not name "q", shorter than 2 chars#' - '#with no value type specified in iterable type array#' # remove this rule when all other issues are solved. - '#has no value type specified in iterable type array#' # remove this rule when all other issues are solved. - '#is not allowed to extend#' @@ -16,7 +14,6 @@ parameters: - '#has a nullable return type declaration#' - '#with a nullable type declaration#' - '#with null as default value#' - - '#is not covariant with PHPDoc type array#' - message: '#Constructor in [a-zA-Z0-9\\_]+ has parameter \$[a-zA-Z0-9\\_]+ with default value#' paths: @@ -56,5 +53,5 @@ parameters: - ../bootstrap/app.php # The level 8 is the highest level. original was 5 - level: 1 + level: 2 diff --git a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php index 802609decd..333ff91fe1 100644 --- a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php +++ b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php @@ -145,7 +145,7 @@ class DeleteOrphanedTransactions extends Command foreach ($set as $transaction) { // delete journals $journal = TransactionJournal::find((int)$transaction->transaction_journal_id); - if ($journal) { + if (null !== $journal) { $journal->delete(); } Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete(); diff --git a/app/Console/Commands/Correction/FixUnevenAmount.php b/app/Console/Commands/Correction/FixUnevenAmount.php index 7f3668368c..62b95de6dd 100644 --- a/app/Console/Commands/Correction/FixUnevenAmount.php +++ b/app/Console/Commands/Correction/FixUnevenAmount.php @@ -95,7 +95,7 @@ class FixUnevenAmount extends Command { // one of the transactions is bad. $journal = TransactionJournal::find($param); - if (!$journal) { + if (null === $journal) { return; } /** @var Transaction|null $source */ diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php index 8e3699eaab..bd75d43ca9 100644 --- a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php +++ b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php @@ -205,7 +205,7 @@ class UpgradeLiabilitiesEight extends Command $source = $openingJournal->transactions()->where('amount', '<', 0)->first(); /** @var Transaction|null $dest */ $dest = $openingJournal->transactions()->where('amount', '>', 0)->first(); - if ($source && $dest) { + if (null !== $source && null !== $dest) { $sourceId = $source->account_id; $destId = $dest->account_id; $dest->account_id = $sourceId; diff --git a/app/Helpers/Update/UpdateTrait.php b/app/Helpers/Update/UpdateTrait.php index b76eafc99d..832623daf9 100644 --- a/app/Helpers/Update/UpdateTrait.php +++ b/app/Helpers/Update/UpdateTrait.php @@ -48,7 +48,7 @@ trait UpdateTrait /** @var UpdateRequestInterface $checker */ $checker = app(UpdateRequestInterface::class); $channelConfig = app('fireflyconfig')->get('update_channel', 'stable'); - $channel = $channelConfig ? $channelConfig->data : 'stable'; + $channel = (string)$channelConfig->data; return $checker->getUpdateInformation($channel); } diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php index 292c00ec8c..384a6a2318 100644 --- a/app/Http/Controllers/Account/EditController.php +++ b/app/Http/Controllers/Account/EditController.php @@ -88,15 +88,15 @@ class EditController extends Controller $roles = $this->getRoles(); $liabilityTypes = $this->getLiabilityTypes(); $location = $repository->getLocation($account); - $latitude = $location ? $location->latitude : config('firefly.default_location.latitude'); - $longitude = $location ? $location->longitude : config('firefly.default_location.longitude'); - $zoomLevel = $location ? $location->zoom_level : config('firefly.default_location.zoom_level'); + $latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude'); + $longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude'); + $zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level'); $hasLocation = null !== $location; $locations = [ 'location' => [ - 'latitude' => old('location_latitude') ?? $latitude, - 'longitude' => old('location_longitude') ?? $longitude, - 'zoom_level' => old('location_zoom_level') ?? $zoomLevel, + 'latitude' => null !== old('location_latitude') ? old('location_latitude'): $latitude, + 'longitude' => null !== old('location_longitude') ? old('location_longitude') : $longitude, + 'zoom_level' => null !== old('location_zoom_level') ? old('location_zoom_level') : $zoomLevel, 'has_location' => $hasLocation || 'true' === old('location_has_location'), ], ]; diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php index f3f9e935cb..d9b692e825 100644 --- a/app/Http/Controllers/Bill/EditController.php +++ b/app/Http/Controllers/Bill/EditController.php @@ -103,7 +103,7 @@ class EditController extends Controller 'notes' => $this->repository->getNoteText($bill), 'transaction_currency_id' => $bill->transaction_currency_id, 'active' => $hasOldInput ? (bool)$request->old('active') : $bill->active, - 'object_group' => $bill->objectGroups->first() ? $bill->objectGroups->first()->title : '', + 'object_group' => null !== $bill->objectGroups->first() ? $bill->objectGroups->first()->title : '', ]; $request->session()->flash('preFilled', $preFilled); diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.php index 76a2bedbcd..cba15a857d 100644 --- a/app/Http/Controllers/Budget/EditController.php +++ b/app/Http/Controllers/Budget/EditController.php @@ -100,7 +100,7 @@ class EditController extends Controller 'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active, 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id, ]; - if ($autoBudget) { + if (null !== $autoBudget) { $amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount; $preFilled['auto_budget_amount'] = app('steam')->bcround($amount, $autoBudget->transactionCurrency->decimal_places); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index bccf11d3a2..6b89c0464b 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -57,7 +57,7 @@ abstract class Controller extends BaseController { // is site a demo site? $isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false)); - $isDemoSite = $isDemoSiteConfig ? $isDemoSiteConfig->data : false; + $isDemoSite = (bool) $isDemoSiteConfig->data; app('view')->share('IS_DEMO_SITE', $isDemoSite); app('view')->share('DEMO_USERNAME', config('firefly.demo_username')); app('view')->share('DEMO_PASSWORD', config('firefly.demo_password')); diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index 002222f5ac..3badb00404 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -314,7 +314,7 @@ class DebugController extends Controller // has stored reconciliations $type = TransactionType::whereType(TransactionType::RECONCILIATION)->first(); - if ($user->transactionJournals()->where('transaction_type_id', $type->id)->count()) { + if ($user->transactionJournals()->where('transaction_type_id', $type->id)->count() > 0) { $flags[] = ':ledger:'; } diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.php index d6c11b841f..a8605716be 100644 --- a/app/Http/Controllers/PiggyBank/EditController.php +++ b/app/Http/Controllers/PiggyBank/EditController.php @@ -93,7 +93,7 @@ class EditController extends Controller 'targetamount' => app('steam')->bcround($piggyBank->targetamount, $currency->decimal_places), 'targetdate' => $targetDate, 'startdate' => $startDate, - 'object_group' => $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '', + 'object_group' => null !== $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '', 'notes' => null === $note ? '' : $note->text, ]; if (0 === bccomp($piggyBank->targetamount, '0')) { diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php index ac51114be3..71fe0dd453 100644 --- a/app/Http/Controllers/Recurring/CreateController.php +++ b/app/Http/Controllers/Recurring/CreateController.php @@ -163,9 +163,9 @@ class CreateController extends Controller $source = $journal->transactions()->where('amount', '<', 0)->first(); /** @var Transaction $dest */ $dest = $journal->transactions()->where('amount', '>', 0)->first(); - $category = $journal->categories()->first() ? $journal->categories()->first()->name : ''; - $budget = $journal->budgets()->first() ? $journal->budgets()->first()->id : 0; - $bill = $journal->bill ? $journal->bill->id : 0; + $category = null !== $journal->categories()->first() ? $journal->categories()->first()->name : ''; + $budget = null !== $journal->budgets()->first() ? $journal->budgets()->first()->id : 0; + $bill = null !== $journal->bill ? $journal->bill->id : 0; $hasOldInput = null !== $request->old('_token'); // flash some data $preFilled = []; if (true === $hasOldInput) { diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php index 9268c3f2b7..49dcf5ebc6 100644 --- a/app/Http/Controllers/Rule/CreateController.php +++ b/app/Http/Controllers/Rule/CreateController.php @@ -106,7 +106,7 @@ class CreateController extends Controller } // restore actions and triggers from old input: - if ($request->old()) { + if (null !== $request->old()) { $oldTriggers = $this->getPreviousTriggers($request); $oldActions = $this->getPreviousActions($request); } @@ -163,7 +163,7 @@ class CreateController extends Controller $oldActions = $this->getActionsForBill($bill); // restore actions and triggers from old input: - if ($request->old()) { + if (null !== $request->old()) { $oldTriggers = $this->getPreviousTriggers($request); $oldActions = $this->getPreviousActions($request); } @@ -172,7 +172,7 @@ class CreateController extends Controller $actionCount = count($oldActions); $subTitleIcon = 'fa-clone'; - // title depends on whether or not there is a rule group: + // title depends on whether there is a rule group: $subTitle = (string)trans('firefly.make_new_rule_no_group'); // flash old data @@ -218,7 +218,7 @@ class CreateController extends Controller ]; // restore actions and triggers from old input: - if ($request->old()) { + if (null !== $request->old()) { $oldTriggers = $this->getPreviousTriggers($request); $oldActions = $this->getPreviousActions($request); } diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index c5a320e5d4..691b36446f 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -129,9 +129,9 @@ class TagController extends Controller $subTitleIcon = 'fa-tag'; $location = $this->repository->getLocation($tag); - $latitude = $location ? $location->latitude : config('firefly.default_location.latitude'); - $longitude = $location ? $location->longitude : config('firefly.default_location.longitude'); - $zoomLevel = $location ? $location->zoom_level : config('firefly.default_location.zoom_level'); + $latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude'); + $longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude'); + $zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level'); $hasLocation = null !== $location; $locations = [ 'location' => [ diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.php index 74636f6fb2..895e2f5b93 100644 --- a/app/Http/Controllers/Transaction/IndexController.php +++ b/app/Http/Controllers/Transaction/IndexController.php @@ -96,7 +96,7 @@ class IndexController extends Controller if (null === $end) { // get last transaction ever? $last = $this->repository->getLast(); - $end = $last ? $last->date : session('end'); + $end = null !== $last ? $last->date : session('end'); } [$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; @@ -147,7 +147,7 @@ class IndexController extends Controller $first = $this->repository->firstNull(); $start = null === $first ? new Carbon() : $first->date; $last = $this->repository->getLast(); - $end = $last ? $last->date : today(config('app.timezone')); + $end = null !== $last ? $last->date : today(config('app.timezone')); $subTitle = (string)trans('firefly.all_' . $objectType); /** @var GroupCollectorInterface $collector */ diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index cea497895e..602ad020c6 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -47,7 +47,7 @@ class Range */ public function handle(Request $request, Closure $next) { - if ($request->user()) { + if (null !== $request->user()) { // set start, end and finish: $this->setRange(); diff --git a/app/Models/Account.php b/app/Models/Account.php index 85bf92b8c1..b44c7ecac2 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -190,7 +190,7 @@ class Account extends Model ->where('name', 'account_number') ->first(); - return $metaValue ? $metaValue->data : ''; + return null !== $metaValue ? $metaValue->data : ''; } /** diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php index fc7bcb5eae..69299ca605 100644 --- a/app/Models/TransactionJournalLink.php +++ b/app/Models/TransactionJournalLink.php @@ -23,22 +23,22 @@ declare(strict_types=1); namespace FireflyIII\Models; +use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphMany; -use Carbon\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * FireflyIII\Models\TransactionJournalLink * - * @property int|string $id + * @property int|string $id * @property Carbon|null $created_at * @property Carbon|null $updated_at - * @property |stringint $link_type_id + * @property string|int $link_type_id * @property int $source_id * @property int $destination_id * @property string|null $comment diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 52111fb3ee..e8d357ffe2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -250,7 +250,7 @@ class AccountRepository implements AccountRepositoryInterface static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); - $attachment->notes_text = $notes ? $notes->text : ''; + $attachment->notes_text = null !== $notes ? $notes->text : ''; return $attachment; } diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index df765dd005..59f212f5a0 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -199,7 +199,7 @@ class BillRepository implements BillRepositoryInterface static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); - $attachment->notes_text = $notes ? $notes->text : ''; + $attachment->notes_text = null !== $notes ? $notes->text : ''; return $attachment; } @@ -373,12 +373,12 @@ class BillRepository implements BillRepositoryInterface return $bill->transactionJournals() ->before($end)->after($start)->get( - [ + [ 'transaction_journals.id', 'transaction_journals.date', 'transaction_journals.transaction_group_id', ] - ); + ); } /** diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index a99b8769f7..b2451853f8 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -589,7 +589,7 @@ class BudgetRepository implements BudgetRepositoryInterface static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); - $attachment->notes_text = $notes ? $notes->text : ''; + $attachment->notes_text = null !== $notes ? $notes->text : ''; return $attachment; } diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 06422c0bde..d3d67b281a 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -306,7 +306,7 @@ class CategoryRepository implements CategoryRepositoryInterface static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); - $attachment->notes_text = $notes ? $notes->text : ''; + $attachment->notes_text = null !== $notes ? $notes->text : ''; return $attachment; } diff --git a/app/Repositories/Journal/JournalAPIRepository.php b/app/Repositories/Journal/JournalAPIRepository.php index b3d6e43710..55b3020092 100644 --- a/app/Repositories/Journal/JournalAPIRepository.php +++ b/app/Repositories/Journal/JournalAPIRepository.php @@ -74,7 +74,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); - $attachment->notes_text = $notes ? $notes->text : ''; // TODO should not set notes like this. + $attachment->notes_text = null !== $notes ? $notes->text : ''; // TODO should not set notes like this. return $attachment; } diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 7f8e943f06..a1e95044ba 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -125,7 +125,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface static function (Attachment $attachment) use ($disk) { $notes = $attachment->notes()->first(); $attachment->file_exists = $disk->exists($attachment->fileName()); - $attachment->notes_text = $notes ? $notes->text : ''; + $attachment->notes_text = null !== $notes ? $notes->text : ''; return $attachment; } diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index 08be427390..b2430d05ed 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -335,7 +335,7 @@ class UserRepository implements UserRepositoryInterface public function redeemCode(string $code): void { $obj = InvitedUser::where('invite_code', $code)->where('redeemed', 0)->first(); - if ($obj) { + if (null !== $obj) { $obj->redeemed = true; $obj->save(); } diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index cc863b3c3f..5f5e7026a7 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -136,7 +136,7 @@ class FireflyConfig public function getFresh(string $name, $default = null): ?Configuration { $config = Configuration::where('name', $name)->first(['id', 'name', 'data']); - if ($config) { + if (null !== $config) { return $config; } // no preference found and default is null: diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.php index 0157c03fb7..2ab227f431 100644 --- a/app/Support/Request/AppendsLocationData.php +++ b/app/Support/Request/AppendsLocationData.php @@ -134,7 +134,7 @@ trait AppendsLocationData return true; } // if is POST and route does not contain API, must also have "has_location" = true - if ('POST' === $this->method() && $this->routeIs('*.store') && !$this->routeIs('api.v1.*') && $hasLocationKey) { + if ('POST' === $this->method() && $this->routeIs('*.store') && !$this->routeIs('api.v1.*') && '' !== $hasLocationKey) { app('log')->debug('Is POST + store route.'); $hasLocation = $this->boolean($hasLocationKey); if (true === $hasLocation) { @@ -205,7 +205,7 @@ trait AppendsLocationData } // if POST and not API route, must also have "has_location" // if is POST and route does not contain API, must also have "has_location" = true - if ('POST' === $this->method() && $this->routeIs('*.update') && !$this->routeIs('api.v1.*') && $hasLocationKey) { + if ('POST' === $this->method() && $this->routeIs('*.update') && !$this->routeIs('api.v1.*') && '' !== $hasLocationKey) { app('log')->debug('Is POST + store route.'); $hasLocation = $this->boolean($hasLocationKey); if (true === $hasLocation) { diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 6461055fbb..c741f58a8e 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -117,7 +117,7 @@ class Steam $cache = new CacheProperties(); $cache->addProperty($account->id); $cache->addProperty('balance-in-range'); - $cache->addProperty($currency ? $currency->id : 0); + $cache->addProperty(null !== $currency ? $currency->id : 0); $cache->addProperty($start); $cache->addProperty($end); if ($cache->has()) { @@ -204,7 +204,7 @@ class Steam $cache->addProperty($account->id); $cache->addProperty('balance'); $cache->addProperty($date); - $cache->addProperty($currency ? $currency->id : 0); + $cache->addProperty(null !== $currency ? $currency->id : 0); if ($cache->has()) { return $cache->get(); } diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php index f5d13ec85a..a1ed960e7f 100644 --- a/app/Transformers/BillTransformer.php +++ b/app/Transformers/BillTransformer.php @@ -123,7 +123,7 @@ class BillTransformer extends AbstractTransformer 'active' => $bill->active, 'order' => (int)$bill->order, 'notes' => $notes, - 'object_group_id' => $objectGroupId ? (string)$objectGroupId : null, + 'object_group_id' => null !== $objectGroupId ? (string)$objectGroupId : null, 'object_group_order' => $objectGroupOrder, 'object_group_title' => $objectGroupTitle, diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php index 3706b1c362..f1e8511e4b 100644 --- a/app/Transformers/PiggyBankEventTransformer.php +++ b/app/Transformers/PiggyBankEventTransformer.php @@ -86,8 +86,8 @@ class PiggyBankEventTransformer extends AbstractTransformer 'currency_code' => $currency->code, 'currency_symbol' => $currency->symbol, 'currency_decimal_places' => (int)$currency->decimal_places, - 'transaction_journal_id' => $journalId ? (string)$journalId : null, - 'transaction_group_id' => $groupId ? (string)$groupId : null, + 'transaction_journal_id' => null !== $journalId ? (string)$journalId : null, + 'transaction_group_id' => null !== $groupId ? (string)$groupId : null, 'links' => [ [ 'rel' => 'self', diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php index de320841b2..33eb503b19 100644 --- a/app/Transformers/PiggyBankTransformer.php +++ b/app/Transformers/PiggyBankTransformer.php @@ -123,7 +123,7 @@ class PiggyBankTransformer extends AbstractTransformer 'order' => (int)$piggyBank->order, 'active' => true, 'notes' => $notes, - 'object_group_id' => $objectGroupId ? (string)$objectGroupId : null, + 'object_group_id' => null !== $objectGroupId ? (string)$objectGroupId : null, 'object_group_order' => $objectGroupOrder, 'object_group_title' => $objectGroupTitle, 'links' => [ diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.php index 1e85e391e5..0c245d5c47 100644 --- a/app/Validation/RecurrenceValidation.php +++ b/app/Validation/RecurrenceValidation.php @@ -61,7 +61,7 @@ trait RecurrenceValidation /** @var RecurrenceTransaction|null $first */ $first = $recurrence->recurrenceTransactions()->first(); if (null !== $first) { - $transactionType = $first->transactionType ? $first->transactionType->type : 'withdrawal'; + $transactionType = null !== $first->transactionType ? $first->transactionType->type : 'withdrawal'; app('log')->debug(sprintf('Determined type to be %s.', $transactionType)); } if (null === $first) {