Various code cleanup.

This commit is contained in:
James Cole
2021-04-07 07:53:05 +02:00
parent 49013264d5
commit eddf0c1200
50 changed files with 138 additions and 152 deletions

View File

@@ -151,4 +151,13 @@ class RecurrenceFactory
$this->user = $user;
}
/**
* @return MessageBag
*/
public function getErrors(): MessageBag
{
return $this->errors;
}
}

View File

@@ -192,7 +192,7 @@ class CreateController extends Controller
*/
public function createFromJournal(Request $request, TransactionJournal $journal)
{
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_journal', ['name' => e($journal->name)]));
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));
$subTitleIcon = 'fa-clone';
$subTitle = (string)trans('firefly.make_new_rule_no_group');

View File

@@ -85,9 +85,9 @@ class CreateController extends Controller
/**
* Create a new transaction group.
*
* @param string|null objectType
* @param string|null $objectType
*
* @return Factory|View
* @return Factory|\Illuminate\Contracts\View\View
*/
public function create(?string $objectType)
{

View File

@@ -37,8 +37,7 @@ use URL;
*/
class DeleteController extends Controller
{
/** @var TransactionGroupRepositoryInterface */
private $repository;
private TransactionGroupRepositoryInterface $repository;
/**
* IndexController constructor.
@@ -67,7 +66,7 @@ class DeleteController extends Controller
*
* @param TransactionGroup $group
*
* @return RedirectResponse|Redirector|View
* @return mixed
*/
public function delete(TransactionGroup $group)
{

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Auth\Factory as Auth;
use Illuminate\Database\QueryException;
@@ -77,8 +78,8 @@ class Authenticate
/**
* Determine if the user is logged in to any of the given guards.
*
* @param $request
* @param array $guards
* @param mixed $request
* @param array $guards
*
* @return mixed
* @throws FireflyException
@@ -95,6 +96,7 @@ class Authenticate
// do an extra check on user object.
/** @noinspection PhpUndefinedMethodInspection */
/** @var User $user */
$user = $this->auth->authenticate();
if (1 === (int)$user->blocked) {
$message = (string)trans('firefly.block_account_logout');
@@ -127,7 +129,7 @@ class Authenticate
foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) {
/** @noinspection PhpVoidFunctionResultUsedInspection */
return $this->auth->shouldUse($guard);
return $this->auth->shouldUse($guard); // @phpstan-ignore-line
}
}

View File

@@ -81,9 +81,9 @@ class Binder
/**
* Do the binding.
*
* @param $key
* @param $value
* @param $route
* @param string $key
* @param string $value
* @param Route $route
*
* @return mixed
*/

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Http\Request;
@@ -93,7 +94,7 @@ class InterestingMessage
$accountId = $request->get('account_id');
$message = $request->get('message');
/** @var TransactionGroup $group */
/** @var Account $account */
$account = auth()->user()->accounts()->withTrashed()->find($accountId);
if (null === $account) {

View File

@@ -53,9 +53,8 @@ class ObjectGroupFormRequest extends FormRequest
*/
public function rules(): array
{
/** @var ObjectGroup $piggy */
/** @var ObjectGroup $objectGroup */
$objectGroup = $this->route()->parameter('objectGroup');
$titleRule = 'required|between:1,255|uniqueObjectGroup';
if (null !== $objectGroup) {

View File

@@ -239,9 +239,9 @@ class CreateRecurringTransactions implements ShouldQueue
}
/**
* Has the reuccrence started yet.
* Has the recurrence started yet?
*
* @param $recurrence
* @param Recurrence $recurrence
*
* @return bool
*/

View File

@@ -246,7 +246,7 @@ class Account extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*
* @codeCoverageIgnore
*/

View File

@@ -76,7 +76,7 @@ class AccountMeta extends Model
}
/**
* @param $value
* @param mixed $value
*
* @codeCoverageIgnore
* @return mixed
@@ -87,7 +87,7 @@ class AccountMeta extends Model
}
/**
* @param $value
* @param mixed $value
*
* @codeCoverageIgnore
*/

View File

@@ -176,7 +176,7 @@ class Bill extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*/
public function setAmountMaxAttribute($value): void
{
@@ -184,7 +184,7 @@ class Bill extends Model
}
/**
* @param $value
* @param mixed $value
*
* @codeCoverageIgnore
*/

View File

@@ -84,7 +84,7 @@ class BudgetLimit extends Model
*
* @param string $value
*
* @return mixed
* @return BudgetLimit
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): BudgetLimit

View File

@@ -70,9 +70,10 @@ class Configuration extends Model
protected $table = 'configuration';
/**
* TODO can be replaced by native laravel code
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*
* @return mixed
*/
@@ -84,7 +85,7 @@ class Configuration extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*/
public function setDataAttribute($value): void
{

View File

@@ -81,7 +81,7 @@ class LinkType extends Model
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param $value
* @param string $value
*
* @throws NotFoundHttpException
* @return LinkType

View File

@@ -181,7 +181,7 @@ class PiggyBank extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*/
public function setTargetamountAttribute($value): void
{

View File

@@ -37,7 +37,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property int|null $transaction_journal_id
* @property \Illuminate\Support\Carbon $date
* @property string $amount
* @property-read \FireflyIII\Models\PiggyBank $piggyBank
* @property \FireflyIII\Models\PiggyBank $piggyBank
* @property-read \FireflyIII\Models\TransactionJournal|null $transactionJournal
* @method static Builder|PiggyBankEvent newModelQuery()
* @method static Builder|PiggyBankEvent newQuery()
@@ -81,7 +81,7 @@ class PiggyBankEvent extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*/
public function setAmountAttribute($value): void
{

View File

@@ -120,7 +120,7 @@ class PiggyBankRepetition extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*/
public function setCurrentamountAttribute($value): void
{

View File

@@ -48,10 +48,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property bool $active
* @property bool $stop_processing
* @property bool $strict
* @property-read string $action_value
* @property-read Collection|RuleAction[] $ruleActions
* @property-read int|null $rule_actions_count
* @property-read RuleGroup $ruleGroup
* @property-read Collection|RuleTrigger[] $ruleTriggers
* @property Collection|RuleTrigger[] $ruleTriggers
* @property-read int|null $rule_triggers_count
* @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Rule newModelQuery()
@@ -148,7 +149,7 @@ class Rule extends Model
}
/**
* @param $value
* @param mixed $value
*
* @codeCoverageIgnore
*/

View File

@@ -230,7 +230,7 @@ class Transaction extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*/
public function setAmountAttribute($value): void
{

View File

@@ -81,7 +81,7 @@ class TransactionJournalLink extends Model
* @param string $value
*
* @throws NotFoundHttpException
* @return mixed
* @return TransactionJournalLink
*
*/
public static function routeBinder(string $value): TransactionJournalLink

View File

@@ -79,7 +79,7 @@ class TransactionJournalMeta extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*
* @return mixed
*/
@@ -91,7 +91,7 @@ class TransactionJournalMeta extends Model
/**
* @codeCoverageIgnore
*
* @param $value
* @param mixed $value
*/
public function setDataAttribute($value): void
{

View File

@@ -79,7 +79,7 @@ class TransactionType extends Model
* @param string $type
*
* @throws NotFoundHttpException
* @return Model|null|static
* @return TransactionType
*/
public static function routeBinder(string $type): TransactionType
{

View File

@@ -64,7 +64,7 @@ class AccountServiceProvider extends ServiceProvider
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -78,7 +78,7 @@ class AccountServiceProvider extends ServiceProvider
/** @var OperationsRepository $repository */
$repository = app(OperationsRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -98,7 +98,7 @@ class AccountServiceProvider extends ServiceProvider
/** @var AccountTaskerInterface $tasker */
$tasker = app(AccountTasker::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$tasker->setUser(auth()->user());
}

View File

@@ -58,7 +58,7 @@ class AdminServiceProvider extends ServiceProvider
function (Application $app) {
/** @var LinkTypeRepository $repository */
$repository = app(LinkTypeRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -50,7 +50,7 @@ class AttachmentServiceProvider extends ServiceProvider
function (Application $app) {
/** @var AttachmentRepositoryInterface $repository */
$repository = app(AttachmentRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -51,7 +51,7 @@ class BillServiceProvider extends ServiceProvider
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -58,7 +58,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -72,7 +72,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var AvailableBudgetRepositoryInterface $repository */
$repository = app(AvailableBudgetRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -86,7 +86,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var BudgetLimitRepositoryInterface $repository */
$repository = app(BudgetLimitRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -100,7 +100,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var NoBudgetRepositoryInterface $repository */
$repository = app(NoBudgetRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -114,7 +114,7 @@ class BudgetServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var OperationsRepositoryInterface $repository */
$repository = app(OperationsRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -54,7 +54,7 @@ class CategoryServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var CategoryRepository $repository */
$repository = app(CategoryRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -67,7 +67,7 @@ class CategoryServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var OperationsRepository $repository */
$repository = app(OperationsRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -80,7 +80,7 @@ class CategoryServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var NoCategoryRepository $repository */
$repository = app(NoCategoryRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -50,7 +50,7 @@ class CurrencyServiceProvider extends ServiceProvider
function (Application $app) {
/** @var CurrencyRepository $repository */
$repository = app(CurrencyRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -186,7 +186,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var ObjectGroupRepository $repository */
$repository = app(ObjectGroupRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -199,7 +199,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var WebhookRepository $repository */
$repository = app(WebhookRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -212,7 +212,7 @@ class FireflyServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var SearchRuleEngine $engine */
$engine = app(SearchRuleEngine::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$engine->setUser(auth()->user());
}

View File

@@ -68,7 +68,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -82,7 +82,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var JournalAPIRepositoryInterface $repository */
$repository = app(JournalAPIRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -96,7 +96,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var JournalCLIRepositoryInterface $repository */
$repository = app(JournalCLIRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -115,7 +115,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var TransactionGroupRepositoryInterface $repository */
$repository = app(TransactionGroupRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -134,7 +134,7 @@ class JournalServiceProvider extends ServiceProvider
static function (Application $app) {
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollector::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$collector->setUser(auth()->user());
}

View File

@@ -50,7 +50,7 @@ class PiggyBankServiceProvider extends ServiceProvider
function (Application $app) {
/** @var PiggyBankRepository $repository */
$repository = app(PiggyBankRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -51,7 +51,7 @@ class RecurringServiceProvider extends ServiceProvider
/** @var RecurringRepositoryInterface $repository */
$repository = app(RecurringRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -50,7 +50,7 @@ class RuleGroupServiceProvider extends ServiceProvider
function (Application $app) {
/** @var RuleGroupRepository $repository */
$repository = app(RuleGroupRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -50,7 +50,7 @@ class RuleServiceProvider extends ServiceProvider
function (Application $app) {
/** @var RuleRepository $repository */
$repository = app(RuleRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -50,7 +50,7 @@ class SearchServiceProvider extends ServiceProvider
function (Application $app) {
/** @var OperatorQuerySearch $search */
$search = app(OperatorQuerySearch::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$search->setUser(auth()->user());
}

View File

@@ -53,7 +53,7 @@ class TagServiceProvider extends ServiceProvider
/** @var TagRepository $repository */
$repository = app(TagRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}
@@ -67,7 +67,7 @@ class TagServiceProvider extends ServiceProvider
/** @var OperationsRepository $repository */
$repository = app(OperationsRepository::class);
if ($app->auth->check()) {
if ($app->auth->check()) { // @phpstan-ignore-line
$repository->setUser(auth()->user());
}

View File

@@ -220,7 +220,6 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function getAccountsById(array $accountIds): Collection
{
/** @var Collection $result */
$query = $this->user->accounts();
if (0 !== count($accountIds)) {
@@ -240,7 +239,6 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function getAccountsByType(array $types): Collection
{
/** @var Collection $result */
$query = $this->user->accounts();
if (0 !== count($types)) {
$query->accountTypeIn($types);
@@ -263,7 +261,6 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function getActiveAccountsByType(array $types): Collection
{
/** @var Collection $result */
$query = $this->user->accounts()->with(
['accountmeta' => function (HasMany $query) {
$query->where('name', 'account_role');
@@ -324,7 +321,6 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function getInactiveAccountsByType(array $types): Collection
{
/** @var Collection $result */
$query = $this->user->accounts()->with(
['accountmeta' => function (HasMany $query) {
$query->where('name', 'account_role');

View File

@@ -29,6 +29,7 @@ use FireflyIII\Factory\BillFactory;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Note;
use FireflyIII\Models\Rule;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -200,7 +201,6 @@ class BillRepository implements BillRepositoryInterface
*/
public function getBills(): Collection
{
/** @var Collection $set */
return $this->user->bills()
->orderBy('order', 'ASC')
->orderBy('active', 'DESC')
@@ -549,6 +549,7 @@ class BillRepository implements BillRepositoryInterface
->where('rule_actions.action_type', 'link_to_bill')
->get(['rules.id', 'rules.title', 'rule_actions.action_value', 'rules.active']);
$array = [];
/** @var Rule $rule */
foreach ($rules as $rule) {
$array[$rule->action_value] = $array[$rule->action_value] ?? [];
$array[$rule->action_value][] = ['id' => $rule->id, 'title' => $rule->title, 'active' => $rule->active];

View File

@@ -432,25 +432,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return null;
}
/**
* Return a list of exchange rates with this currency.
*
* @param TransactionCurrency $currency
*
* @return Collection
*/
public function getExchangeRates(TransactionCurrency $currency): Collection
{
/** @var CurrencyExchangeRate $rate */
return $this->user->currencyExchangeRates()
->where(
function (Builder $query) use ($currency) {
$query->where('from_currency_id', $currency->id);
$query->orWhere('to_currency_id', $currency->id);
}
)->get();
}
/**
* @inheritDoc
*/

View File

@@ -207,15 +207,6 @@ interface CurrencyRepositoryInterface
*/
public function getExchangeRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date): ?CurrencyExchangeRate;
/**
* Return a list of exchange rates with this currency.
*
* @param TransactionCurrency $currency
*
* @return Collection
*/
public function getExchangeRates(TransactionCurrency $currency): Collection;
/**
* @param TransactionCurrency $currency
*

View File

@@ -97,7 +97,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
*/
public function getPiggyBankEvents(TransactionJournal $journal): Collection
{
/** @var Collection $set */
/** @var Collection $events */
$events = $journal->piggyBankEvents()->get();
$events->each(
function (PiggyBankEvent $event) {

View File

@@ -278,7 +278,7 @@ class JournalRepository implements JournalRepositoryInterface
}
/**
* @param int $transactionId
* @param int $journalId
*/
public function reconcileById(int $journalId): void
{

View File

@@ -169,7 +169,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
/**
* Returns all the journal links (of a specific type).
*
* @param $linkType
* @param LinkType|null $linkType
*
* @return Collection
*/

View File

@@ -43,7 +43,6 @@ trait CreatesObjectGroups
}
/**
* @param User $user
* @param string $title
*
* @return ObjectGroup|null