mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix all level 2 issues.
This commit is contained in:
parent
9002365e6d
commit
1b978d41e0
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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'),
|
||||
],
|
||||
];
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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'));
|
||||
|
@ -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[] = '<span title="Has reconciled">:ledger:</span>';
|
||||
}
|
||||
|
||||
|
@ -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')) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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' => [
|
||||
|
@ -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 */
|
||||
|
@ -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();
|
||||
|
||||
|
@ -190,7 +190,7 @@ class Account extends Model
|
||||
->where('name', 'account_number')
|
||||
->first();
|
||||
|
||||
return $metaValue ? $metaValue->data : '';
|
||||
return null !== $metaValue ? $metaValue->data : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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',
|
||||
]
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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,
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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' => [
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user