Various code cleanup.

This commit is contained in:
James Cole
2023-11-04 17:41:28 +01:00
parent 1059da8a2a
commit fe0a205a05
7 changed files with 37 additions and 13 deletions

View File

@@ -1,8 +1,20 @@
includes:
- ../vendor/nunomaduro/larastan/extension.neon
- ../vendor/ergebnis/phpstan-rules/rules.neon
- ../vendor/phpstan/phpstan-deprecation-rules/rules.neon
- ../vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
- ../vendor/symplify/phpstan-rules/config/code-complexity-rules.neon
- ../vendor/symplify/phpstan-rules/config/collector-rules.neon
- ../vendor/symplify/phpstan-rules/config/naming-rules.neon
- ../vendor/symplify/phpstan-rules/config/regex-rules.neon
- ../vendor/symplify/phpstan-rules/config/static-rules.neon
- ../vendor/symplify/phpstan-rules/config/configurable-rules.neon
services:
-
class: Symplify\PHPStanRules\Rules\ForbiddenNodeRule
tags: [phpstan.rules.rule]
arguments:
forbiddenNodes:
- PhpParser\Node\Expr\Empty_
- PhpParser\Node\Expr\ErrorSuppress
parameters:
universalObjectCratesClasses:
@@ -10,9 +22,15 @@ parameters:
reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false # remove this rule when all other issues are solved.
ignoreErrors:
- '#Use value object over return of values#' # from simplify, ignore it.
- '#Use explicit names over dynamic ones#' # from simplify, ignore it.
- '#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#'
- '#switch is forbidden to use#'
- '#is neither abstract nor final#'
- '#has a nullable return type declaration#'
- '#with a nullable type declaration#'
@@ -76,5 +94,5 @@ parameters:
- ../bootstrap/app.php
# The level 8 is the highest level. original was 5
level: 6
level: 1

View File

@@ -76,7 +76,7 @@ class TransactionController extends Controller
// this deserves better code, but for now a loop of basic if-statements
// to respond to what is in the $query.
// this is OK because only one thing can be in the query at the moment.
if ($this->updatesTransactionAccount($params)) {
if ($this->isUpdateTransactionAccount($params)) {
$original = $this->repository->find((int)$params['where']['account_id']);
$destination = $this->repository->find((int)$params['update']['account_id']);
@@ -93,7 +93,7 @@ class TransactionController extends Controller
*
* @return bool
*/
private function updatesTransactionAccount(array $params): bool
private function isUpdateTransactionAccount(array $params): bool
{
return array_key_exists('account_id', $params['where']) && array_key_exists('account_id', $params['update']);
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
@@ -33,13 +34,12 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Budget
*
* @property int|string $id
* @property int|string $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at

View File

@@ -40,7 +40,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int|string $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property int $budget_id
* @property int|string $budget_id
* @property int|null $transaction_currency_id
* @property Carbon $start_date
* @property Carbon|null $end_date

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\UserGroups\Currency;
use FireflyIII\Api\V1\Controllers\Data\Bulk\TransactionController;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
@@ -121,7 +122,7 @@ interface CurrencyRepositoryInterface
/**
* Get the user group's currencies.
*
* @return Collection
* @return Collection<TransactionCurrency>
*/
public function get(): Collection;

View File

@@ -57,8 +57,8 @@ class CurrencyUpdateService
if (array_key_exists('decimal_places', $data) && is_int($data['decimal_places'])) {
$currency->decimal_places = (int)$data['decimal_places'];
}
$currency->userEnabled = null;
$currency->userDefault = null;
unset($currency->userEnabled);
unset($currency->userDefault);
$currency->save();
return $currency;

View File

@@ -147,6 +147,11 @@
"includes": [
"extension.neon"
]
},
"phpstan/extension-installer": {
"ignore": [
"symplify/phpstan-rules"
]
}
},
"scripts": {