PHP7 compatible function definitions.

This commit is contained in:
James Cole
2016-04-06 09:27:45 +02:00
parent 37fe2d22b0
commit c8440af9a5
77 changed files with 278 additions and 345 deletions

View File

@@ -16,7 +16,6 @@ use Illuminate\Queue\SerializesModels;
/** /**
* Class TransactionJournalStored * Class TransactionJournalStored
* *
* @codeCoverageIgnore
* @package FireflyIII\Events * @package FireflyIII\Events
*/ */
class TransactionJournalStored extends Event class TransactionJournalStored extends Event

View File

@@ -9,7 +9,6 @@ use Illuminate\Queue\SerializesModels;
/** /**
* Class TransactionJournalUpdated * Class TransactionJournalUpdated
* *
* @codeCoverageIgnore
* @package FireflyIII\Events * @package FireflyIII\Events
*/ */
class TransactionJournalUpdated extends Event class TransactionJournalUpdated extends Event

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
/** /**
* Class FireflyException * Class FireflyException
* *
* @codeCoverageIgnore
* @package FireflyIII\Exceptions * @package FireflyIII\Exceptions
*/ */
class FireflyException extends \Exception class FireflyException extends \Exception

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
/** /**
* Class NotImplementedException * Class NotImplementedException
* *
* @codeCoverageIgnore
* @package FireflyIII\Exceptions * @package FireflyIII\Exceptions
*/ */
class NotImplementedException extends \Exception class NotImplementedException extends \Exception

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Exceptions;
/** /**
* Class ValidationExceptions * Class ValidationExceptions
* *
* @codeCoverageIgnore
* @package FireflyIII\Exception * @package FireflyIII\Exception
*/ */
class ValidationException extends \Exception class ValidationException extends \Exception

View File

@@ -50,7 +50,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
} }
/** /**
* @codeCoverageIgnore
* *
* @param Collection $entries * @param Collection $entries
* *

View File

@@ -148,7 +148,6 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
} }
/** /**
* @codeCoverageIgnore
* *
* @param Collection $entries * @param Collection $entries
* *

View File

@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
/** /**
* Class RescanJournal * Class RescanJournal
* *
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events * @package FireflyIII\Handlers\Events
*/ */
class ScanForBillsAfterStore class ScanForBillsAfterStore

View File

@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
/** /**
* Class RescanJournal * Class RescanJournal
* *
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events * @package FireflyIII\Handlers\Events
*/ */
class ScanForBillsAfterUpdate class ScanForBillsAfterUpdate

View File

@@ -10,7 +10,6 @@ use FireflyIII\Models\TransactionJournal;
/** /**
* Class UpdateJournalConnection * Class UpdateJournalConnection
* *
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events * @package FireflyIII\Handlers\Events
*/ */
class UpdateJournalConnection class UpdateJournalConnection

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* Class Account * Class Account
* *
* @package FireflyIII\Helpers\Collection * @package FireflyIII\Helpers\Collection

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class Balance * Class Balance
* *

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Account as AccountModel; use FireflyIII\Models\Account as AccountModel;
/** /**
* @codeCoverageIgnore
* *
* Class BalanceEntry * Class BalanceEntry
* *

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Account as AccountModel;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class BalanceHeader * Class BalanceHeader
* *

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class BalanceLine * Class BalanceLine
* *

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* Class Bill * Class Bill
* *
* @package FireflyIII\Helpers\Collection * @package FireflyIII\Helpers\Collection

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Bill as BillModel; use FireflyIII\Models\Bill as BillModel;
/** /**
* @codeCoverageIgnore
* *
* Class BillLine * Class BillLine
* *
@@ -111,7 +110,7 @@ class BillLine
} }
/** /**
* @return boolean * @return bool
*/ */
public function isActive(): bool public function isActive(): bool
{ {
@@ -127,7 +126,7 @@ class BillLine
} }
/** /**
* @return boolean * @return bool
*/ */
public function isHit(): bool public function isHit(): bool
{ {

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class Budget * Class Budget
* *

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
/** /**
* @codeCoverageIgnore
* *
* Class BudgetLine * Class BudgetLine
* *

View File

@@ -7,7 +7,6 @@ use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class Category * Class Category
* *

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
use stdClass; use stdClass;
/** /**
* @codeCoverageIgnore
* *
* Class Expense * Class Expense
* *

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
use stdClass; use stdClass;
/** /**
* @codeCoverageIgnore
* *
* Class Income * Class Income
* *

View File

@@ -65,7 +65,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description with costs from ABN AMRO itself * Parses the current description with costs from ABN AMRO itself
* *
* @return boolean true if the description is GEA/BEA-format, false otherwise * @return bool true if the description is GEA/BEA-format, false otherwise
*/ */
protected function parseABNAMRODescription() protected function parseABNAMRODescription()
{ {
@@ -85,7 +85,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description in GEA/BEA format * Parses the current description in GEA/BEA format
* *
* @return boolean true if the description is GEA/BEAformat, false otherwise * @return bool true if the description is GEA/BEAformat, false otherwise
*/ */
protected function parseGEABEADescription() protected function parseGEABEADescription()
{ {
@@ -111,7 +111,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description in SEPA format * Parses the current description in SEPA format
* *
* @return boolean true if the description is SEPA format, false otherwise * @return bool true if the description is SEPA format, false otherwise
*/ */
protected function parseSepaDescription() protected function parseSepaDescription()
{ {
@@ -168,7 +168,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description in TRTP format * Parses the current description in TRTP format
* *
* @return boolean true if the description is TRTP format, false otherwise * @return bool true if the description is TRTP format, false otherwise
*/ */
protected function parseTRTPDescription() protected function parseTRTPDescription()
{ {

View File

@@ -20,7 +20,6 @@ class FiscalHelper implements FiscalHelperInterface
/** /**
* FiscalHelper constructor. * FiscalHelper constructor.
* *
* @codeCoverageIgnore
* *
*/ */
public function __construct() public function __construct()

View File

@@ -17,7 +17,6 @@ class Help implements HelpInterface
{ {
/** /**
* @codeCoverageIgnore
* *
* @param string $key * @param string $key
* *
@@ -68,7 +67,6 @@ class Help implements HelpInterface
} }
/** /**
* @codeCoverageIgnore
* *
* @param string $route * @param string $route
* *
@@ -80,7 +78,6 @@ class Help implements HelpInterface
} }
/** /**
* @codeCoverageIgnore
* *
* @param string $route * @param string $route
* *
@@ -92,7 +89,6 @@ class Help implements HelpInterface
} }
/** /**
* @codeCoverageIgnore
* *
* @param string $route * @param string $route
* @param array $content * @param array $content

View File

@@ -40,7 +40,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
/** /**
* ReportHelper constructor. * ReportHelper constructor.
* *
* @codeCoverageIgnore
* *
* @param BudgetRepositoryInterface $budgetRepository * @param BudgetRepositoryInterface $budgetRepository
* @param TagRepositoryInterface $tagRepository * @param TagRepositoryInterface $tagRepository

View File

@@ -37,7 +37,6 @@ class ReportHelper implements ReportHelperInterface
/** /**
* ReportHelper constructor. * ReportHelper constructor.
* *
* @codeCoverageIgnore
* *
* @param ReportQueryInterface $query * @param ReportQueryInterface $query
* @param BudgetRepositoryInterface $budgetRepository * @param BudgetRepositoryInterface $budgetRepository

View File

@@ -56,7 +56,7 @@ class AccountController extends Controller
$cache->addProperty($reportType); $cache->addProperty($reportType);
$cache->addProperty($accounts); $cache->addProperty($accounts);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
// make chart: // make chart:
@@ -86,7 +86,7 @@ class AccountController extends Controller
$cache->addProperty('expenseAccounts'); $cache->addProperty('expenseAccounts');
$cache->addProperty('accounts'); $cache->addProperty('accounts');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$data = $this->generator->expenseAccounts($accounts, $start, $end); $data = $this->generator->expenseAccounts($accounts, $start, $end);
@@ -117,7 +117,7 @@ class AccountController extends Controller
$cache->addProperty('frontpage'); $cache->addProperty('frontpage');
$cache->addProperty('accounts'); $cache->addProperty('accounts');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$data = $this->generator->frontpage($accounts, $start, $end); $data = $this->generator->frontpage($accounts, $start, $end);
@@ -149,7 +149,7 @@ class AccountController extends Controller
$cache->addProperty('single'); $cache->addProperty('single');
$cache->addProperty($account->id); $cache->addProperty($account->id);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$data = $this->generator->single($account, $start, $end); $data = $this->generator->single($account, $start, $end);

View File

@@ -78,7 +78,7 @@ class BillController extends Controller
$cache->addProperty('bill'); $cache->addProperty('bill');
$cache->addProperty($bill->id); $cache->addProperty($bill->id);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
// get first transaction or today for start: // get first transaction or today for start:

View File

@@ -57,7 +57,7 @@ class BudgetController extends Controller
$cache->addProperty('budget'); $cache->addProperty('budget');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$final = clone $last; $final = clone $last;
@@ -108,7 +108,7 @@ class BudgetController extends Controller
$cache->addProperty($budget->id); $cache->addProperty($budget->id);
$cache->addProperty($repetition->id); $cache->addProperty($repetition->id);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$set = $repository->getExpensesPerDay($budget, $start, $end); $set = $repository->getExpensesPerDay($budget, $start, $end);
@@ -161,7 +161,7 @@ class BudgetController extends Controller
$cache->addProperty('budget'); $cache->addProperty('budget');
$cache->addProperty('all'); $cache->addProperty('all');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$budgets = $repository->getBudgetsAndLimitsInRange($start, $end); $budgets = $repository->getBudgetsAndLimitsInRange($start, $end);
@@ -230,7 +230,7 @@ class BudgetController extends Controller
$cache->addProperty('multiYearBudget'); $cache->addProperty('multiYearBudget');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
/* /*
@@ -310,7 +310,7 @@ class BudgetController extends Controller
$cache->addProperty('budget'); $cache->addProperty('budget');
$cache->addProperty('year'); $cache->addProperty('year');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$budgetInformation = $repository->getBudgetsAndExpensesPerMonth($accounts, $start, $end); $budgetInformation = $repository->getBudgetsAndExpensesPerMonth($accounts, $start, $end);

View File

@@ -67,7 +67,7 @@ class CategoryController extends Controller
$cache->addProperty('all'); $cache->addProperty('all');
$cache->addProperty('categories'); $cache->addProperty('categories');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$spentArray = $repository->spentPerDay($category, $start, $end); $spentArray = $repository->spentPerDay($category, $start, $end);
$earnedArray = $repository->earnedPerDay($category, $start, $end); $earnedArray = $repository->earnedPerDay($category, $start, $end);
@@ -130,7 +130,7 @@ class CategoryController extends Controller
$cache->addProperty('category'); $cache->addProperty('category');
$cache->addProperty('earned-in-period'); $cache->addProperty('earned-in-period');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$set = $repository->earnedForAccountsPerMonth($accounts, $start, $end); $set = $repository->earnedForAccountsPerMonth($accounts, $start, $end);
@@ -169,7 +169,7 @@ class CategoryController extends Controller
$cache->addProperty('category'); $cache->addProperty('category');
$cache->addProperty('frontpage'); $cache->addProperty('frontpage');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
// get data for categories (and "no category"): // get data for categories (and "no category"):
@@ -215,7 +215,7 @@ class CategoryController extends Controller
$cache->addProperty('multiYearCategory'); $cache->addProperty('multiYearCategory');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$entries = new Collection; $entries = new Collection;
@@ -321,7 +321,7 @@ class CategoryController extends Controller
$cache->addProperty('category'); $cache->addProperty('category');
$cache->addProperty('spent-in-period'); $cache->addProperty('spent-in-period');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }

View File

@@ -47,7 +47,7 @@ class PiggyBankController extends Controller
$cache->addProperty('piggy-history'); $cache->addProperty('piggy-history');
$cache->addProperty($piggyBank->id); $cache->addProperty($piggyBank->id);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
/** @var Collection $set */ /** @var Collection $set */

View File

@@ -54,7 +54,7 @@ class ReportController extends Controller
$cache->addProperty($accounts); $cache->addProperty($accounts);
$cache->addProperty($end); $cache->addProperty($end);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$ids = $accounts->pluck('id')->toArray(); $ids = $accounts->pluck('id')->toArray();
$current = clone $start; $current = clone $start;
@@ -102,7 +102,7 @@ class ReportController extends Controller
$cache->addProperty($accounts); $cache->addProperty($accounts);
$cache->addProperty($end); $cache->addProperty($end);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
// spent per month, and earned per month. For a specific set of accounts // spent per month, and earned per month. For a specific set of accounts
@@ -146,7 +146,7 @@ class ReportController extends Controller
$cache->addProperty($reportType); $cache->addProperty($reportType);
$cache->addProperty($accounts); $cache->addProperty($accounts);
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
// spent per month, and earned per month. For a specific set of accounts // spent per month, and earned per month. For a specific set of accounts
// grouped by month // grouped by month

View File

@@ -114,7 +114,7 @@ class JsonController extends Controller
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty('box-in'); $cache->addProperty('box-in');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']); $accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
$amount = $reportQuery->income($accounts, $start, $end)->sum('journalAmount'); $amount = $reportQuery->income($accounts, $start, $end)->sum('journalAmount');
@@ -145,7 +145,7 @@ class JsonController extends Controller
$cache->addProperty($end); $cache->addProperty($end);
$cache->addProperty('box-out'); $cache->addProperty('box-out');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore return Response::json($cache->get());
} }
$amount = $reportQuery->expense($accounts, $start, $end)->sum('journalAmount'); $amount = $reportQuery->expense($accounts, $start, $end)->sum('journalAmount');

View File

@@ -44,7 +44,7 @@ class ExecuteRuleGroupOnExistingTransactions extends Job implements ShouldQueue
/** /**
* @return Collection * @return Collection
*/ */
public function getAccounts() public function getAccounts(): Collection
{ {
return $this->accounts; return $this->accounts;
} }
@@ -61,7 +61,7 @@ class ExecuteRuleGroupOnExistingTransactions extends Job implements ShouldQueue
/** /**
* @return \Carbon\Carbon * @return \Carbon\Carbon
*/ */
public function getEndDate() public function getEndDate(): Carbon
{ {
return $this->endDate; return $this->endDate;
} }
@@ -78,7 +78,7 @@ class ExecuteRuleGroupOnExistingTransactions extends Job implements ShouldQueue
/** /**
* @return \Carbon\Carbon * @return \Carbon\Carbon
*/ */
public function getStartDate() public function getStartDate(): Carbon
{ {
return $this->startDate; return $this->startDate;
} }
@@ -95,7 +95,7 @@ class ExecuteRuleGroupOnExistingTransactions extends Job implements ShouldQueue
/** /**
* @return User * @return User
*/ */
public function getUser() public function getUser(): User
{ {
return $this->user; return $this->user;
} }

View File

@@ -4,6 +4,8 @@ use Auth;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -146,36 +148,39 @@ class Account extends Model
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function accountMeta() public function accountMeta(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\AccountMeta'); return $this->hasMany('FireflyIII\Models\AccountMeta');
} }
/** /**
* @codeCoverageIgnore * @return BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function accountType() public function accountType(): BelongsTo
{ {
return $this->belongsTo('FireflyIII\Models\AccountType'); return $this->belongsTo('FireflyIII\Models\AccountType');
} }
/** /**
* @codeCoverageIgnore * FIXME can return null
* *
* @param $value * @param $value
* *
* @return string * @return string
*/ */
public function getIbanAttribute($value) public function getIbanAttribute($value): string
{ {
if (is_null($value)) { if (is_null($value)) {
return null; return '';
}
$result = Crypt::decrypt($value);
if (is_null($result)) {
return '';
} }
return Crypt::decrypt($value); return $result;
} }
/** /**
@@ -184,7 +189,7 @@ class Account extends Model
* *
* @return string * @return string
*/ */
public function getMeta($fieldName): string public function getMeta(string $fieldName): string
{ {
foreach ($this->accountMeta as $meta) { foreach ($this->accountMeta as $meta) {
if ($meta->name == $fieldName) { if ($meta->name == $fieldName) {
@@ -196,13 +201,12 @@ class Account extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
* @return string * @return string
*/ */
public function getNameAttribute($value) public function getNameAttribute($value): string
{ {
if (intval($this->encrypted) == 1) { if (intval($this->encrypted) == 1) {
@@ -216,7 +220,7 @@ class Account extends Model
* *
* @return string * @return string
*/ */
public function getNameForEditformAttribute() public function getNameForEditformAttribute(): string
{ {
$name = $this->name; $name = $this->name;
if ($this->accountType->type == 'Cash account') { if ($this->accountType->type == 'Cash account') {
@@ -227,16 +231,14 @@ class Account extends Model
} }
/** /**
* @codeCoverageIgnore * @return HasMany
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function piggyBanks() public function piggyBanks(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\PiggyBank'); return $this->hasMany('FireflyIII\Models\PiggyBank');
} }
/** /**
* @codeCoverageIgnore
* *
* @param EloquentBuilder $query * @param EloquentBuilder $query
* @param array $types * @param array $types
@@ -251,7 +253,6 @@ class Account extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param EloquentBuilder $query * @param EloquentBuilder $query
* @param string $name * @param string $name
@@ -269,7 +270,6 @@ class Account extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
*/ */
@@ -279,7 +279,6 @@ class Account extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
*/ */
@@ -292,7 +291,6 @@ class Account extends Model
/** /**
* @param $value * @param $value
* *
* @codeCoverageIgnore
*/ */
public function setVirtualBalanceAttribute($value) public function setVirtualBalanceAttribute($value)
{ {
@@ -300,19 +298,17 @@ class Account extends Model
} }
/** /**
* @codeCoverageIgnore * @return HasMany
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function transactions() public function transactions(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Transaction'); return $this->hasMany('FireflyIII\Models\Transaction');
} }
/** /**
* @codeCoverageIgnore * @return BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user(): BelongsTo
{ {
return $this->belongsTo('FireflyIII\User'); return $this->belongsTo('FireflyIII\User');
} }

View File

@@ -1,6 +1,7 @@
<?php namespace FireflyIII\Models; <?php namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** /**
* FireflyIII\Models\AccountMeta * FireflyIII\Models\AccountMeta
@@ -29,9 +30,9 @@ class AccountMeta extends Model
/** /**
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function account() public function account(): BelongsTo
{ {
return $this->belongsTo('FireflyIII\Models\Account'); return $this->belongsTo('FireflyIII\Models\Account');
} }

View File

@@ -1,6 +1,7 @@
<?php namespace FireflyIII\Models; <?php namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
/** /**
* FireflyIII\Models\AccountType * FireflyIII\Models\AccountType
@@ -25,9 +26,9 @@ class AccountType extends Model
// //
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function accounts() public function accounts(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Account'); return $this->hasMany('FireflyIII\Models\Account');
} }

View File

@@ -6,6 +6,8 @@ namespace FireflyIII\Models;
use Auth; use Auth;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -70,8 +72,10 @@ class Attachment extends Model
/** /**
* Get all of the owning imageable models. * Get all of the owning imageable models.
*
* @return MorphTo
*/ */
public function attachable() public function attachable(): MorphTo
{ {
return $this->morphTo(); return $this->morphTo();
} }
@@ -87,8 +91,6 @@ class Attachment extends Model
} }
/** /**
* @codeCoverageIgnore
*
* @param $value * @param $value
* *
* @return null|string * @return null|string
@@ -103,8 +105,6 @@ class Attachment extends Model
} }
/** /**
* @codeCoverageIgnore
*
* @param $value * @param $value
* *
* @return null|string * @return null|string
@@ -119,8 +119,6 @@ class Attachment extends Model
} }
/** /**
* @codeCoverageIgnore
*
* @param $value * @param $value
* *
* @return null|string * @return null|string
@@ -135,7 +133,6 @@ class Attachment extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -151,7 +148,6 @@ class Attachment extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -169,7 +165,7 @@ class Attachment extends Model
/** /**
* @param string $value * @param string $value
*/ */
public function setDescriptionAttribute($value) public function setDescriptionAttribute(string $value)
{ {
$this->attributes['description'] = Crypt::encrypt($value); $this->attributes['description'] = Crypt::encrypt($value);
} }
@@ -177,7 +173,7 @@ class Attachment extends Model
/** /**
* @param string $value * @param string $value
*/ */
public function setFilenameAttribute($value) public function setFilenameAttribute(string $value)
{ {
$this->attributes['filename'] = Crypt::encrypt($value); $this->attributes['filename'] = Crypt::encrypt($value);
} }
@@ -185,7 +181,7 @@ class Attachment extends Model
/** /**
* @param string $value * @param string $value
*/ */
public function setMimeAttribute($value) public function setMimeAttribute(string $value)
{ {
$this->attributes['mime'] = Crypt::encrypt($value); $this->attributes['mime'] = Crypt::encrypt($value);
} }
@@ -193,7 +189,7 @@ class Attachment extends Model
/** /**
* @param string $value * @param string $value
*/ */
public function setNotesAttribute($value) public function setNotesAttribute(string $value)
{ {
$this->attributes['notes'] = Crypt::encrypt($value); $this->attributes['notes'] = Crypt::encrypt($value);
} }
@@ -201,16 +197,15 @@ class Attachment extends Model
/** /**
* @param string $value * @param string $value
*/ */
public function setTitleAttribute($value) public function setTitleAttribute(string $value)
{ {
$this->attributes['title'] = Crypt::encrypt($value); $this->attributes['title'] = Crypt::encrypt($value);
} }
/** /**
* @codeCoverageIgnore * @return BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user(): BelongsTo
{ {
return $this->belongsTo('FireflyIII\User'); return $this->belongsTo('FireflyIII\User');
} }

View File

@@ -3,6 +3,8 @@
use Auth; use Auth;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@@ -135,17 +137,17 @@ class Bill extends Model
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function transactionjournals() public function transactionjournals(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\TransactionJournal'); return $this->hasMany('FireflyIII\Models\TransactionJournal');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function user() public function user(): BelongsTo
{ {
return $this->belongsTo('FireflyIII\User'); return $this->belongsTo('FireflyIII\User');
} }

View File

@@ -3,6 +3,7 @@
use Auth; use Auth;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -136,9 +137,9 @@ class Budget extends Model
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function user() public function user(): BelongsTo
{ {
return $this->belongsTo('FireflyIII\User'); return $this->belongsTo('FireflyIII\User');
} }

View File

@@ -3,6 +3,7 @@
use Auth; use Auth;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -83,7 +84,6 @@ class Category extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -100,7 +100,6 @@ class Category extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
*/ */
@@ -111,7 +110,6 @@ class Category extends Model
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function transactionjournals() public function transactionjournals()
@@ -120,10 +118,9 @@ class Category extends Model
} }
/** /**
* @codeCoverageIgnore * @return BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user(): BelongsTo
{ {
return $this->belongsTo('FireflyIII\User'); return $this->belongsTo('FireflyIII\User');
} }

View File

@@ -25,14 +25,7 @@ use Illuminate\Database\Eloquent\Model;
*/ */
class Component extends Model class Component extends Model
{ {
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $fillable = ['user_id', 'name', 'class']; protected $fillable = ['user_id', 'name', 'class'];
/**
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'deleted_at'];
}
} }

View File

@@ -64,7 +64,6 @@ class ExportJob extends Model
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user()

View File

@@ -109,7 +109,6 @@ class Tag extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -125,7 +124,6 @@ class Tag extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -155,7 +153,6 @@ class Tag extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
*/ */
@@ -165,7 +162,6 @@ class Tag extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
*/ */
@@ -175,7 +171,6 @@ class Tag extends Model
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function transactionjournals() public function transactionjournals()
@@ -184,7 +179,6 @@ class Tag extends Model
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user()

View File

@@ -158,7 +158,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function bill() public function bill()
@@ -167,7 +166,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function budgets() public function budgets()
@@ -176,7 +174,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function categories() public function categories()
@@ -185,7 +182,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
* *
@@ -298,7 +294,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function piggyBankEvents() public function piggyBankEvents()
@@ -322,7 +317,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* *
* @param EloquentBuilder $query * @param EloquentBuilder $query
* @param Carbon $date * @param Carbon $date
@@ -335,7 +329,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* *
* @param EloquentBuilder $query * @param EloquentBuilder $query
* @param Carbon $date * @param Carbon $date
@@ -391,7 +384,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* *
* @param EloquentBuilder $query * @param EloquentBuilder $query
* @param array $types * @param array $types
@@ -406,7 +398,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* *
* @param $value * @param $value
*/ */
@@ -417,7 +408,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function tags() public function tags()
@@ -426,7 +416,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function transactionCurrency() public function transactionCurrency()
@@ -435,7 +424,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function transactionType() public function transactionType()
@@ -444,7 +432,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function transactiongroups() public function transactiongroups()
@@ -461,7 +448,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function transactions() public function transactions()
@@ -470,7 +456,6 @@ class TransactionJournal extends TransactionJournalSupport
} }
/** /**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user()

View File

@@ -63,7 +63,6 @@ class TransactionType extends Model
} }
/** /**
* @codeCoverageIgnore
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */

View File

@@ -84,7 +84,7 @@ class EventServiceProvider extends ServiceProvider
try { try {
$repetition->save(); $repetition->save();
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage()); // @codeCoverageIgnore Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage());
} }
} else { } else {
if ($set->count() == 1) { if ($set->count() == 1) {

View File

@@ -24,7 +24,6 @@ use Validator;
* Class FireflyServiceProvider * Class FireflyServiceProvider
* *
* @package FireflyIII\Providers * @package FireflyIII\Providers
* @codeCoverageIgnore
*/ */
class FireflyServiceProvider extends ServiceProvider class FireflyServiceProvider extends ServiceProvider
{ {

View File

@@ -62,7 +62,7 @@ class AccountRepository implements AccountRepositoryInterface
* @param Account $account * @param Account $account
* @param Account $moveTo * @param Account $moveTo
* *
* @return boolean * @return bool
*/ */
public function destroy(Account $account, Account $moveTo = null): bool public function destroy(Account $account, Account $moveTo = null): bool
{ {
@@ -542,9 +542,7 @@ class AccountRepository implements AccountRepositoryInterface
if (!$existingAccount) { if (!$existingAccount) {
Log::error('Account create error: ' . $newAccount->getErrors()->toJson()); Log::error('Account create error: ' . $newAccount->getErrors()->toJson());
abort(500); abort(500);
// @codeCoverageIgnoreStart
} }
// @codeCoverageIgnoreEnd
$newAccount = $existingAccount; $newAccount = $existingAccount;
} }

View File

@@ -31,7 +31,7 @@ interface AccountRepositoryInterface
* @param Account $account * @param Account $account
* @param Account $moveTo * @param Account $moveTo
* *
* @return boolean * @return bool
*/ */
public function destroy(Account $account, Account $moveTo): bool; public function destroy(Account $account, Account $moveTo): bool;

View File

@@ -40,7 +40,7 @@ class BillRepository implements BillRepositoryInterface
/** /**
* @param Bill $bill * @param Bill $bill
* *
* @return boolean * @return bool
*/ */
public function destroy(Bill $bill): bool public function destroy(Bill $bill): bool
{ {

View File

@@ -44,7 +44,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function delete(TransactionJournal $journal) public function delete(TransactionJournal $journal): bool
{ {
$journal->delete(); $journal->delete();
@@ -56,7 +56,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public function first() public function first(): TransactionJournal
{ {
$entry = $this->user->transactionjournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); $entry = $this->user->transactionjournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
@@ -67,9 +67,9 @@ class JournalRepository implements JournalRepositoryInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param Transaction $transaction * @param Transaction $transaction
* *
* @return integer * @return string
*/ */
public function getAmountBefore(TransactionJournal $journal, Transaction $transaction) public function getAmountBefore(TransactionJournal $journal, Transaction $transaction): string
{ {
$set = $transaction->account->transactions()->leftJoin( $set = $transaction->account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
@@ -94,7 +94,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getCollectionOfTypes(array $types, int $offset, int $count) public function getCollectionOfTypes(array $types, int $offset, int $count): Collection
{ {
$set = $this->user->transactionJournals() $set = $this->user->transactionJournals()
->expanded() ->expanded()
@@ -113,7 +113,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getJournalsOfType(TransactionType $dbType) public function getJournalsOfType(TransactionType $dbType): Collection
{ {
return $this->user->transactionjournals()->where('transaction_type_id', $dbType->id)->orderBy('id', 'DESC')->take(50)->get(); return $this->user->transactionjournals()->where('transaction_type_id', $dbType->id)->orderBy('id', 'DESC')->take(50)->get();
} }
@@ -127,7 +127,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return LengthAwarePaginator * @return LengthAwarePaginator
*/ */
public function getJournalsOfTypes(array $types, int $offset, int $page, int $pagesize = 50) public function getJournalsOfTypes(array $types, int $offset, int $page, int $pagesize = 50): LengthAwarePaginator
{ {
$set = $this->user $set = $this->user
->transactionJournals() ->transactionJournals()
@@ -151,7 +151,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return TransactionType * @return TransactionType
*/ */
public function getTransactionType(string $type) public function getTransactionType(string $type): TransactionType
{ {
return TransactionType::whereType($type)->first(); return TransactionType::whereType($type)->first();
} }
@@ -162,7 +162,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public function getWithDate(int $journalId, Carbon $date) public function getWithDate(int $journalId, Carbon $date): TransactionJournal
{ {
return $this->user->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first(); return $this->user->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first();
} }
@@ -175,9 +175,9 @@ class JournalRepository implements JournalRepositoryInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param array $array * @param array $array
* *
* @return void * @return bool
*/ */
public function saveTags(TransactionJournal $journal, array $array) public function saveTags(TransactionJournal $journal, array $array): bool
{ {
/** @var \FireflyIII\Repositories\Tag\TagRepositoryInterface $tagRepository */ /** @var \FireflyIII\Repositories\Tag\TagRepositoryInterface $tagRepository */
$tagRepository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface'); $tagRepository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');
@@ -190,6 +190,8 @@ class JournalRepository implements JournalRepositoryInterface
} }
} }
} }
return true;
} }
/** /**
@@ -197,7 +199,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public function store(array $data) public function store(array $data): TransactionJournal
{ {
// find transaction type. // find transaction type.
$transactionType = TransactionType::where('type', ucfirst($data['what']))->first(); $transactionType = TransactionType::where('type', ucfirst($data['what']))->first();
@@ -269,7 +271,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public function update(TransactionJournal $journal, array $data) public function update(TransactionJournal $journal, array $data): TransactionJournal
{ {
// update actual journal. // update actual journal.
$journal->transaction_currency_id = $data['amount_currency_id_amount']; $journal->transaction_currency_id = $data['amount_currency_id_amount'];
@@ -329,9 +331,9 @@ class JournalRepository implements JournalRepositoryInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param array $array * @param array $array
* *
* @return void * @return bool
*/ */
public function updateTags(TransactionJournal $journal, array $array) public function updateTags(TransactionJournal $journal, array $array): bool
{ {
// create tag repository // create tag repository
/** @var \FireflyIII\Repositories\Tag\TagRepositoryInterface $tagRepository */ /** @var \FireflyIII\Repositories\Tag\TagRepositoryInterface $tagRepository */
@@ -363,6 +365,8 @@ class JournalRepository implements JournalRepositoryInterface
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tagRepository->connect($journal, $tag); $tagRepository->connect($journal, $tag);
} }
return true;
} }
/** /**
@@ -373,7 +377,7 @@ class JournalRepository implements JournalRepositoryInterface
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
protected function storeAccounts(TransactionType $type, array $data) protected function storeAccounts(TransactionType $type, array $data): array
{ {
$fromAccount = null; $fromAccount = null;
$toAccount = null; $toAccount = null;
@@ -395,18 +399,14 @@ class JournalRepository implements JournalRepositoryInterface
if (is_null($toAccount)) { if (is_null($toAccount)) {
Log::error('"to"-account is null, so we cannot continue!'); Log::error('"to"-account is null, so we cannot continue!');
throw new FireflyException('"to"-account is null, so we cannot continue!'); throw new FireflyException('"to"-account is null, so we cannot continue!');
// @codeCoverageIgnoreStart
} }
// @codeCoverageIgnoreEnd
if (is_null($fromAccount)) { if (is_null($fromAccount)) {
Log::error('"from"-account is null, so we cannot continue!'); Log::error('"from"-account is null, so we cannot continue!');
throw new FireflyException('"from"-account is null, so we cannot continue!'); throw new FireflyException('"from"-account is null, so we cannot continue!');
// @codeCoverageIgnoreStart
} }
// @codeCoverageIgnoreEnd
return [$fromAccount, $toAccount]; return [$fromAccount, $toAccount];
} }
@@ -416,7 +416,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return array * @return array
*/ */
protected function storeDepositAccounts(array $data) protected function storeDepositAccounts(array $data): array
{ {
$toAccount = Account::find($data['account_id']); $toAccount = Account::find($data['account_id']);
@@ -440,7 +440,7 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return array * @return array
*/ */
protected function storeWithdrawalAccounts(array $data) protected function storeWithdrawalAccounts(array $data): array
{ {
$fromAccount = Account::find($data['account_id']); $fromAccount = Account::find($data['account_id']);

View File

@@ -22,38 +22,22 @@ interface JournalRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function delete(TransactionJournal $journal); public function delete(TransactionJournal $journal): bool;
/** /**
* Get users first transaction journal * Get users first transaction journal
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public function first(); public function first(): TransactionJournal;
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param Transaction $transaction * @param Transaction $transaction
* *
* @return float * @return string
*/ */
public function getAmountBefore(TransactionJournal $journal, Transaction $transaction); public function getAmountBefore(TransactionJournal $journal, Transaction $transaction): string;
/**
* @param TransactionType $dbType
*
* @return Collection
*/
public function getJournalsOfType(TransactionType $dbType);
/**
* @param array $types
* @param int $offset
* @param int $page
*
* @return LengthAwarePaginator
*/
public function getJournalsOfTypes(array $types, int $offset, int $page);
/** /**
* @param array $types * @param array $types
@@ -62,14 +46,30 @@ interface JournalRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getCollectionOfTypes(array $types, int $offset, int $count); public function getCollectionOfTypes(array $types, int $offset, int $count):Collection;
/**
* @param TransactionType $dbType
*
* @return Collection
*/
public function getJournalsOfType(TransactionType $dbType): Collection;
/**
* @param array $types
* @param int $offset
* @param int $page
*
* @return LengthAwarePaginator
*/
public function getJournalsOfTypes(array $types, int $offset, int $page): LengthAwarePaginator;
/** /**
* @param string $type * @param string $type
* *
* @return TransactionType * @return TransactionType
*/ */
public function getTransactionType(string $type); public function getTransactionType(string $type): TransactionType;
/** /**
* @param int $journalId * @param int $journalId
@@ -77,7 +77,7 @@ interface JournalRepositoryInterface
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public function getWithDate(int $journalId, Carbon $date); public function getWithDate(int $journalId, Carbon $date): TransactionJournal;
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
@@ -90,30 +90,30 @@ interface JournalRepositoryInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param array $array * @param array $array
* *
* @return void * @return bool
*/ */
public function saveTags(TransactionJournal $journal, array $array); public function saveTags(TransactionJournal $journal, array $array): bool;
/** /**
* @param array $data * @param array $data
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public function store(array $data); public function store(array $data): TransactionJournal;
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param array $data * @param array $data
* *
* @return mixed * @return TransactionJournal
*/ */
public function update(TransactionJournal $journal, array $data); public function update(TransactionJournal $journal, array $data): TransactionJournal;
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param array $array * @param array $array
* *
* @return mixed * @return bool
*/ */
public function updateTags(TransactionJournal $journal, array $array); public function updateTags(TransactionJournal $journal, array $array): bool;
} }

View File

@@ -35,23 +35,24 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* @param string $amount * @param string $amount
* *
* @return bool * @return PiggyBankEvent
*/ */
public function createEvent(PiggyBank $piggyBank, string $amount) public function createEvent(PiggyBank $piggyBank, string $amount): PiggyBankEvent
{ {
PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]); $event = PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
return true; return $event;
} }
/** /**
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* *
* @return boolean|null * @return bool
*/ */
public function destroy(PiggyBank $piggyBank) public function destroy(PiggyBank $piggyBank): bool
{ {
return $piggyBank->delete(); $piggyBank->delete();
return true;
} }
/** /**
@@ -59,7 +60,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getEventSummarySet(PiggyBank $piggyBank) public function getEventSummarySet(PiggyBank $piggyBank): Collection
{ {
return DB::table('piggy_bank_events')->where('piggy_bank_id', $piggyBank->id)->groupBy('date')->get(['date', DB::raw('SUM(`amount`) AS `sum`')]); return DB::table('piggy_bank_events')->where('piggy_bank_id', $piggyBank->id)->groupBy('date')->get(['date', DB::raw('SUM(`amount`) AS `sum`')]);
} }
@@ -69,7 +70,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function getEvents(PiggyBank $piggyBank) public function getEvents(PiggyBank $piggyBank): Collection
{ {
return $piggyBank->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get(); return $piggyBank->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
} }
@@ -77,7 +78,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** /**
* @return int * @return int
*/ */
public function getMaxOrder() public function getMaxOrder(): int
{ {
return intval($this->user->piggyBanks()->max('order')); return intval($this->user->piggyBanks()->max('order'));
} }
@@ -85,7 +86,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** /**
* @return Collection * @return Collection
*/ */
public function getPiggyBanks() public function getPiggyBanks(): Collection
{ {
/** @var Collection $set */ /** @var Collection $set */
$set = $this->user->piggyBanks()->orderBy('order', 'ASC')->get(); $set = $this->user->piggyBanks()->orderBy('order', 'ASC')->get();
@@ -96,9 +97,9 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** /**
* Set all piggy banks to order 0. * Set all piggy banks to order 0.
* *
* @return boolean * @return bool
*/ */
public function reset() public function reset(): bool
{ {
// split query to make it work in sqlite: // split query to make it work in sqlite:
$set = PiggyBank:: $set = PiggyBank::
@@ -119,9 +120,9 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* @param int $piggyBankId * @param int $piggyBankId
* @param int $order * @param int $order
* *
* @return void * @return bool
*/ */
public function setOrder(int $piggyBankId, int $order) public function setOrder(int $piggyBankId, int $order): bool
{ {
$piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', $this->user->id) $piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', $this->user->id)
->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']); ->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
@@ -129,6 +130,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
$piggyBank->order = $order; $piggyBank->order = $order;
$piggyBank->save(); $piggyBank->save();
} }
return true;
} }
/** /**
@@ -136,7 +138,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* *
* @return PiggyBank * @return PiggyBank
*/ */
public function store(array $data) public function store(array $data): PiggyBank
{ {
$data['remind_me'] = false; $data['remind_me'] = false;
$data['reminder_skip'] = 0; $data['reminder_skip'] = 0;
@@ -152,7 +154,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* *
* @return PiggyBank * @return PiggyBank
*/ */
public function update(PiggyBank $piggyBank, array $data) public function update(PiggyBank $piggyBank, array $data): PiggyBank
{ {
$piggyBank->name = $data['name']; $piggyBank->name = $data['name'];

View File

@@ -4,6 +4,7 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\PiggyBank; namespace FireflyIII\Repositories\PiggyBank;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@@ -18,47 +19,47 @@ interface PiggyBankRepositoryInterface
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* @param string $amount * @param string $amount
* *
* @return bool * @return PiggyBankEvent
*/ */
public function createEvent(PiggyBank $piggyBank, string $amount); public function createEvent(PiggyBank $piggyBank, string $amount): PiggyBankEvent;
/** /**
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* *
* @return bool * @return bool
*/ */
public function destroy(PiggyBank $piggyBank); public function destroy(PiggyBank $piggyBank): bool;
/** /**
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* *
* @return Collection * @return Collection
*/ */
public function getEventSummarySet(PiggyBank $piggyBank); public function getEventSummarySet(PiggyBank $piggyBank) : Collection;
/** /**
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* *
* @return Collection * @return Collection
*/ */
public function getEvents(PiggyBank $piggyBank); public function getEvents(PiggyBank $piggyBank) : Collection;
/** /**
* @return int * @return int
*/ */
public function getMaxOrder(); public function getMaxOrder(): int;
/** /**
* @return Collection * @return Collection
*/ */
public function getPiggyBanks(); public function getPiggyBanks() : Collection;
/** /**
* Set all piggy banks to order 0. * Set all piggy banks to order 0.
* *
* @return void * @return bool
*/ */
public function reset(); public function reset(): bool;
/** /**
* *
@@ -67,9 +68,9 @@ interface PiggyBankRepositoryInterface
* @param int $piggyBankId * @param int $piggyBankId
* @param int $order * @param int $order
* *
* @return void * @return bool
*/ */
public function setOrder(int $piggyBankId, int $order); public function setOrder(int $piggyBankId, int $order): bool;
/** /**
@@ -77,7 +78,7 @@ interface PiggyBankRepositoryInterface
* *
* @return PiggyBank * @return PiggyBank
*/ */
public function store(array $data); public function store(array $data): PiggyBank;
/** /**
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
@@ -85,5 +86,5 @@ interface PiggyBankRepositoryInterface
* *
* @return PiggyBank * @return PiggyBank
*/ */
public function update(PiggyBank $piggyBank, array $data); public function update(PiggyBank $piggyBank, array $data): PiggyBank;
} }

View File

@@ -40,7 +40,7 @@ class RuleRepository implements RuleRepositoryInterface
/** /**
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return $this->user->rules()->count(); return $this->user->rules()->count();
} }
@@ -50,7 +50,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function destroy(Rule $rule) public function destroy(Rule $rule): bool
{ {
foreach ($rule->ruleTriggers as $trigger) { foreach ($rule->ruleTriggers as $trigger) {
$trigger->delete(); $trigger->delete();
@@ -64,9 +64,11 @@ class RuleRepository implements RuleRepositoryInterface
} }
/** /**
* FIXME can return null
*
* @return RuleGroup * @return RuleGroup
*/ */
public function getFirstRuleGroup() public function getFirstRuleGroup(): RuleGroup
{ {
return $this->user->ruleGroups()->first(); return $this->user->ruleGroups()->first();
} }
@@ -76,7 +78,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return int * @return int
*/ */
public function getHighestOrderInRuleGroup(RuleGroup $ruleGroup) public function getHighestOrderInRuleGroup(RuleGroup $ruleGroup): int
{ {
return intval($ruleGroup->rules()->max('order')); return intval($ruleGroup->rules()->max('order'));
} }
@@ -102,7 +104,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function moveDown(Rule $rule) public function moveDown(Rule $rule): bool
{ {
$order = $rule->order; $order = $rule->order;
@@ -117,6 +119,7 @@ class RuleRepository implements RuleRepositoryInterface
$rule->order = ($rule->order + 1); $rule->order = ($rule->order + 1);
$rule->save(); $rule->save();
$this->resetRulesInGroupOrder($rule->ruleGroup); $this->resetRulesInGroupOrder($rule->ruleGroup);
return true;
} }
/** /**
@@ -124,7 +127,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function moveUp(Rule $rule) public function moveUp(Rule $rule): bool
{ {
$order = $rule->order; $order = $rule->order;
@@ -138,6 +141,7 @@ class RuleRepository implements RuleRepositoryInterface
$rule->order = ($rule->order - 1); $rule->order = ($rule->order - 1);
$rule->save(); $rule->save();
$this->resetRulesInGroupOrder($rule->ruleGroup); $this->resetRulesInGroupOrder($rule->ruleGroup);
return true;
} }
/** /**
@@ -146,7 +150,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function reorderRuleActions(Rule $rule, array $ids) public function reorderRuleActions(Rule $rule, array $ids): bool
{ {
$order = 1; $order = 1;
foreach ($ids as $actionId) { foreach ($ids as $actionId) {
@@ -168,7 +172,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function reorderRuleTriggers(Rule $rule, array $ids) public function reorderRuleTriggers(Rule $rule, array $ids): bool
{ {
$order = 1; $order = 1;
foreach ($ids as $triggerId) { foreach ($ids as $triggerId) {
@@ -189,7 +193,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function resetRulesInGroupOrder(RuleGroup $ruleGroup) public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool
{ {
$ruleGroup->rules()->whereNotNull('deleted_at')->update(['order' => 0]); $ruleGroup->rules()->whereNotNull('deleted_at')->update(['order' => 0]);
@@ -214,7 +218,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return Rule * @return Rule
*/ */
public function store(array $data) public function store(array $data): Rule
{ {
/** @var RuleGroup $ruleGroup */ /** @var RuleGroup $ruleGroup */
$ruleGroup = $this->user->ruleGroups()->find($data['rule_group_id']); $ruleGroup = $this->user->ruleGroups()->find($data['rule_group_id']);
@@ -250,7 +254,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return RuleAction * @return RuleAction
*/ */
public function storeAction(Rule $rule, array $values) public function storeAction(Rule $rule, array $values): RuleAction
{ {
$ruleAction = new RuleAction; $ruleAction = new RuleAction;
$ruleAction->rule()->associate($rule); $ruleAction->rule()->associate($rule);
@@ -271,7 +275,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return RuleTrigger * @return RuleTrigger
*/ */
public function storeTrigger(Rule $rule, array $values) public function storeTrigger(Rule $rule, array $values): RuleTrigger
{ {
$ruleTrigger = new RuleTrigger; $ruleTrigger = new RuleTrigger;
$ruleTrigger->rule()->associate($rule); $ruleTrigger->rule()->associate($rule);
@@ -291,7 +295,7 @@ class RuleRepository implements RuleRepositoryInterface
* *
* @return Rule * @return Rule
*/ */
public function update(Rule $rule, array $data) public function update(Rule $rule, array $data): Rule
{ {
// update rule: // update rule:
$rule->active = $data['active']; $rule->active = $data['active'];
@@ -319,8 +323,10 @@ class RuleRepository implements RuleRepositoryInterface
/** /**
* @param Rule $rule * @param Rule $rule
* @param array $data * @param array $data
*
* @return bool
*/ */
private function storeActions(Rule $rule, array $data) private function storeActions(Rule $rule, array $data): bool
{ {
$order = 1; $order = 1;
foreach ($data['rule-actions'] as $index => $action) { foreach ($data['rule-actions'] as $index => $action) {
@@ -336,14 +342,16 @@ class RuleRepository implements RuleRepositoryInterface
$this->storeAction($rule, $actionValues); $this->storeAction($rule, $actionValues);
} }
return true;
} }
/** /**
* @param Rule $rule * @param Rule $rule
* @param array $data * @param array $data
* @return bool
*/ */
private function storeTriggers(Rule $rule, array $data) private function storeTriggers(Rule $rule, array $data): bool
{ {
$order = 1; $order = 1;
$stopProcessing = false; $stopProcessing = false;
@@ -370,5 +378,6 @@ class RuleRepository implements RuleRepositoryInterface
$this->storeTrigger($rule, $triggerValues); $this->storeTrigger($rule, $triggerValues);
$order++; $order++;
} }
return true;
} }
} }

View File

@@ -26,26 +26,26 @@ interface RuleRepositoryInterface
/** /**
* @return int * @return int
*/ */
public function count(); public function count(): int;
/** /**
* @param Rule $rule * @param Rule $rule
* *
* @return bool * @return bool
*/ */
public function destroy(Rule $rule); public function destroy(Rule $rule): bool;
/** /**
* @return RuleGroup * @return RuleGroup
*/ */
public function getFirstRuleGroup(); public function getFirstRuleGroup(): RuleGroup;
/** /**
* @param RuleGroup $ruleGroup * @param RuleGroup $ruleGroup
* *
* @return int * @return int
*/ */
public function getHighestOrderInRuleGroup(RuleGroup $ruleGroup); public function getHighestOrderInRuleGroup(RuleGroup $ruleGroup): int;
/** /**
* @param Rule $rule * @param Rule $rule
@@ -59,14 +59,14 @@ interface RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function moveDown(Rule $rule); public function moveDown(Rule $rule): bool;
/** /**
* @param Rule $rule * @param Rule $rule
* *
* @return bool * @return bool
*/ */
public function moveUp(Rule $rule); public function moveUp(Rule $rule): bool;
/** /**
* @param Rule $rule * @param Rule $rule
@@ -74,7 +74,7 @@ interface RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function reorderRuleActions(Rule $rule, array $ids); public function reorderRuleActions(Rule $rule, array $ids): bool;
/** /**
* @param Rule $rule * @param Rule $rule
@@ -82,21 +82,21 @@ interface RuleRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function reorderRuleTriggers(Rule $rule, array $ids); public function reorderRuleTriggers(Rule $rule, array $ids): bool;
/** /**
* @param RuleGroup $ruleGroup * @param RuleGroup $ruleGroup
* *
* @return bool * @return bool
*/ */
public function resetRulesInGroupOrder(RuleGroup $ruleGroup); public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool;
/** /**
* @param array $data * @param array $data
* *
* @return Rule * @return Rule
*/ */
public function store(array $data); public function store(array $data): Rule;
/** /**
* @param Rule $rule * @param Rule $rule
@@ -104,7 +104,7 @@ interface RuleRepositoryInterface
* *
* @return RuleAction * @return RuleAction
*/ */
public function storeAction(Rule $rule, array $values); public function storeAction(Rule $rule, array $values): RuleAction;
/** /**
* @param Rule $rule * @param Rule $rule
@@ -112,7 +112,7 @@ interface RuleRepositoryInterface
* *
* @return RuleTrigger * @return RuleTrigger
*/ */
public function storeTrigger(Rule $rule, array $values); public function storeTrigger(Rule $rule, array $values): RuleTrigger;
/** /**
* @param Rule $rule * @param Rule $rule
@@ -120,6 +120,6 @@ interface RuleRepositoryInterface
* *
* @return Rule * @return Rule
*/ */
public function update(Rule $rule, array $data); public function update(Rule $rule, array $data): Rule;
} }

View File

@@ -33,7 +33,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
/** /**
* @return int * @return int
*/ */
public function count() public function count(): int
{ {
return $this->user->ruleGroups()->count(); return $this->user->ruleGroups()->count();
} }
@@ -42,9 +42,9 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
* @param RuleGroup $ruleGroup * @param RuleGroup $ruleGroup
* @param RuleGroup $moveTo * @param RuleGroup $moveTo
* *
* @return boolean * @return bool
*/ */
public function destroy(RuleGroup $ruleGroup, RuleGroup $moveTo = null) public function destroy(RuleGroup $ruleGroup, RuleGroup $moveTo = null): bool
{ {
/** @var Rule $rule */ /** @var Rule $rule */
foreach ($ruleGroup->rules as $rule) { foreach ($ruleGroup->rules as $rule) {
@@ -72,7 +72,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
/** /**
* @return Collection * @return Collection
*/ */
public function get() public function get(): Collection
{ {
return $this->user->ruleGroups()->orderBy('order', 'ASC')->get(); return $this->user->ruleGroups()->orderBy('order', 'ASC')->get();
} }
@@ -80,7 +80,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
/** /**
* @return int * @return int
*/ */
public function getHighestOrderRuleGroup() public function getHighestOrderRuleGroup(): int
{ {
$entry = $this->user->ruleGroups()->max('order'); $entry = $this->user->ruleGroups()->max('order');
@@ -119,7 +119,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function moveDown(RuleGroup $ruleGroup) public function moveDown(RuleGroup $ruleGroup): bool
{ {
$order = $ruleGroup->order; $order = $ruleGroup->order;
@@ -133,6 +133,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$ruleGroup->order = ($ruleGroup->order + 1); $ruleGroup->order = ($ruleGroup->order + 1);
$ruleGroup->save(); $ruleGroup->save();
$this->resetRuleGroupOrder(); $this->resetRuleGroupOrder();
return true;
} }
/** /**
@@ -140,7 +141,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function moveUp(RuleGroup $ruleGroup) public function moveUp(RuleGroup $ruleGroup): bool
{ {
$order = $ruleGroup->order; $order = $ruleGroup->order;
@@ -159,7 +160,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
/** /**
* @return bool * @return bool
*/ */
public function resetRuleGroupOrder() public function resetRuleGroupOrder(): bool
{ {
$this->user->ruleGroups()->whereNotNull('deleted_at')->update(['order' => 0]); $this->user->ruleGroups()->whereNotNull('deleted_at')->update(['order' => 0]);
@@ -181,7 +182,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function resetRulesInGroupOrder(RuleGroup $ruleGroup) public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool
{ {
$ruleGroup->rules()->whereNotNull('deleted_at')->update(['order' => 0]); $ruleGroup->rules()->whereNotNull('deleted_at')->update(['order' => 0]);
@@ -206,7 +207,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
* *
* @return RuleGroup * @return RuleGroup
*/ */
public function store(array $data) public function store(array $data): RuleGroup
{ {
$order = $this->getHighestOrderRuleGroup(); $order = $this->getHighestOrderRuleGroup();
@@ -233,7 +234,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
* *
* @return RuleGroup * @return RuleGroup
*/ */
public function update(RuleGroup $ruleGroup, array $data) public function update(RuleGroup $ruleGroup, array $data): RuleGroup
{ {
// update the account: // update the account:
$ruleGroup->title = $data['title']; $ruleGroup->title = $data['title'];

View File

@@ -20,7 +20,7 @@ interface RuleGroupRepositoryInterface
/** /**
* @return int * @return int
*/ */
public function count(); public function count(): int;
/** /**
* @param RuleGroup $ruleGroup * @param RuleGroup $ruleGroup
@@ -28,17 +28,17 @@ interface RuleGroupRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function destroy(RuleGroup $ruleGroup, RuleGroup $moveTo = null); public function destroy(RuleGroup $ruleGroup, RuleGroup $moveTo = null): bool;
/** /**
* @return Collection * @return Collection
*/ */
public function get(); public function get(): Collection;
/** /**
* @return int * @return int
*/ */
public function getHighestOrderRuleGroup(); public function getHighestOrderRuleGroup(): int;
/** /**
* @param User $user * @param User $user
@@ -52,33 +52,33 @@ interface RuleGroupRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function moveDown(RuleGroup $ruleGroup); public function moveDown(RuleGroup $ruleGroup): bool;
/** /**
* @param RuleGroup $ruleGroup * @param RuleGroup $ruleGroup
* *
* @return bool * @return bool
*/ */
public function moveUp(RuleGroup $ruleGroup); public function moveUp(RuleGroup $ruleGroup): bool;
/** /**
* @return bool * @return bool
*/ */
public function resetRuleGroupOrder(); public function resetRuleGroupOrder(): bool;
/** /**
* @param RuleGroup $ruleGroup * @param RuleGroup $ruleGroup
* *
* @return bool * @return bool
*/ */
public function resetRulesInGroupOrder(RuleGroup $ruleGroup); public function resetRulesInGroupOrder(RuleGroup $ruleGroup): bool;
/** /**
* @param array $data * @param array $data
* *
* @return RuleGroup * @return RuleGroup
*/ */
public function store(array $data); public function store(array $data): RuleGroup;
/** /**
* @param RuleGroup $ruleGroup * @param RuleGroup $ruleGroup
@@ -86,7 +86,7 @@ interface RuleGroupRepositoryInterface
* *
* @return RuleGroup * @return RuleGroup
*/ */
public function update(RuleGroup $ruleGroup, array $data); public function update(RuleGroup $ruleGroup, array $data): RuleGroup;
} }

View File

@@ -42,7 +42,7 @@ class TagRepository implements TagRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function allCoveredByBalancingActs(Collection $accounts, Carbon $start, Carbon $end) public function allCoveredByBalancingActs(Collection $accounts, Carbon $start, Carbon $end): Collection
{ {
$ids = $accounts->pluck('id')->toArray(); $ids = $accounts->pluck('id')->toArray();
$set = $this->user->tags() $set = $this->user->tags()
@@ -84,9 +84,9 @@ class TagRepository implements TagRepositoryInterface
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
* *
* @return boolean * @return bool
*/ */
public function connect(TransactionJournal $journal, Tag $tag) public function connect(TransactionJournal $journal, Tag $tag): Collection
{ {
/* /*
* Already connected: * Already connected:
@@ -125,7 +125,7 @@ class TagRepository implements TagRepositoryInterface
* *
* @return string * @return string
*/ */
public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end) public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end): string
{ {
// the quickest way to do this is by scanning all balancingAct tags // the quickest way to do this is by scanning all balancingAct tags
// because there will be less of them any way. // because there will be less of them any way.
@@ -152,20 +152,19 @@ class TagRepository implements TagRepositoryInterface
/** /**
* @param Tag $tag * @param Tag $tag
* *
* @return boolean * @return bool
*/ */
public function destroy(Tag $tag) public function destroy(Tag $tag): bool
{ {
$tag->delete(); $tag->delete();
return true; return true;
} }
// @codeCoverageIgnoreEnd
/** /**
* @return Collection * @return Collection
*/ */
public function get() public function get(): Collection
{ {
/** @var Collection $tags */ /** @var Collection $tags */
$tags = $this->user->tags()->get(); $tags = $this->user->tags()->get();
@@ -183,7 +182,7 @@ class TagRepository implements TagRepositoryInterface
* *
* @return Tag * @return Tag
*/ */
public function store(array $data) public function store(array $data): Tag
{ {
$tag = new Tag; $tag = new Tag;
$tag->tag = $data['tag']; $tag->tag = $data['tag'];
@@ -208,7 +207,7 @@ class TagRepository implements TagRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function tagAllowAdvance(Tag $tag) public function tagAllowAdvance(Tag $tag): bool
{ {
/* /*
* If this tag is a balancing act, and it contains transfers, it cannot be * If this tag is a balancing act, and it contains transfers, it cannot be
@@ -247,7 +246,7 @@ class TagRepository implements TagRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function tagAllowBalancing(Tag $tag) public function tagAllowBalancing(Tag $tag): bool
{ {
/* /*
* If has more than two transactions already, cannot become a balancing act: * If has more than two transactions already, cannot become a balancing act:
@@ -275,7 +274,7 @@ class TagRepository implements TagRepositoryInterface
* *
* @return Tag * @return Tag
*/ */
public function update(Tag $tag, array $data) public function update(Tag $tag, array $data): Tag
{ {
$tag->tag = $data['tag']; $tag->tag = $data['tag'];
$tag->date = $data['date']; $tag->date = $data['date'];
@@ -295,9 +294,9 @@ class TagRepository implements TagRepositoryInterface
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
* *
* @return boolean * @return bool
*/ */
protected function connectAdvancePayment(TransactionJournal $journal, Tag $tag) protected function connectAdvancePayment(TransactionJournal $journal, Tag $tag): bool
{ {
/** @var TransactionType $transfer */ /** @var TransactionType $transfer */
$transfer = TransactionType::whereType(TransactionType::TRANSFER)->first(); $transfer = TransactionType::whereType(TransactionType::TRANSFER)->first();
@@ -332,7 +331,7 @@ class TagRepository implements TagRepositoryInterface
} }
// this statement is unreachable. // this statement is unreachable.
return false; // @codeCoverageIgnore return false;
} }
@@ -340,9 +339,9 @@ class TagRepository implements TagRepositoryInterface
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param Tag $tag * @param Tag $tag
* *
* @return boolean * @return bool
*/ */
protected function connectBalancingAct(TransactionJournal $journal, Tag $tag) protected function connectBalancingAct(TransactionJournal $journal, Tag $tag): bool
{ {
/** @var TransactionType $withdrawal */ /** @var TransactionType $withdrawal */
$withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first(); $withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
@@ -380,7 +379,7 @@ class TagRepository implements TagRepositoryInterface
* *
* @return bool * @return bool
*/ */
protected function matchAll(TransactionJournal $journal, Tag $tag) protected function matchAll(TransactionJournal $journal, Tag $tag): bool
{ {
$match = true; $match = true;
/** @var TransactionJournal $check */ /** @var TransactionJournal $check */

View File

@@ -24,15 +24,15 @@ interface TagRepositoryInterface
* *
* @return Collection * @return Collection
*/ */
public function allCoveredByBalancingActs(Collection $accounts, Carbon $start, Carbon $end); public function allCoveredByBalancingActs(Collection $accounts, Carbon $start, Carbon $end): Collection;
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param Tag $tag * @param Tag $tag
* *
* @return boolean * @return bool
*/ */
public function connect(TransactionJournal $journal, Tag $tag); public function connect(TransactionJournal $journal, Tag $tag): bool;
/** /**
* @deprecated * @deprecated
@@ -49,26 +49,26 @@ interface TagRepositoryInterface
* *
* @return string * @return string
*/ */
public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end); public function coveredByBalancingActs(Account $account, Carbon $start, Carbon $end): string;
/** /**
* @param Tag $tag * @param Tag $tag
* *
* @return boolean * @return bool
*/ */
public function destroy(Tag $tag); public function destroy(Tag $tag): bool;
/** /**
* @return Collection * @return Collection
*/ */
public function get(); public function get(): Collection;
/** /**
* @param array $data * @param array $data
* *
* @return Tag * @return Tag
*/ */
public function store(array $data); public function store(array $data): Tag;
/** /**
* Can a tag become an advance payment? * Can a tag become an advance payment?
@@ -77,7 +77,7 @@ interface TagRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function tagAllowAdvance(Tag $tag); public function tagAllowAdvance(Tag $tag): bool;
/** /**
* Can a tag become a balancing act? * Can a tag become a balancing act?
@@ -86,7 +86,7 @@ interface TagRepositoryInterface
* *
* @return bool * @return bool
*/ */
public function tagAllowBalancing(Tag $tag); public function tagAllowBalancing(Tag $tag): bool;
/** /**
* @param Tag $tag * @param Tag $tag
@@ -94,5 +94,5 @@ interface TagRepositoryInterface
* *
* @return Tag * @return Tag
*/ */
public function update(Tag $tag, array $data); public function update(Tag $tag, array $data): Tag;
} }

View File

@@ -139,7 +139,7 @@ class Amount
} }
$cache->store(env('DEFAULT_CURRENCY', 'EUR')); $cache->store(env('DEFAULT_CURRENCY', 'EUR'));
return env('DEFAULT_CURRENCY', 'EUR'); // @codeCoverageIgnore return env('DEFAULT_CURRENCY', 'EUR');
} }
} }

View File

@@ -14,7 +14,6 @@ use Preferences as Prefs;
/** /**
* Class CacheProperties * Class CacheProperties
* *
* @codeCoverageIgnore
* @package FireflyIII\Support * @package FireflyIII\Support
*/ */
class CacheProperties class CacheProperties

View File

@@ -250,13 +250,11 @@ class ExpandedForm
{ {
$previousValue = null; $previousValue = null;
// @codeCoverageIgnoreStart
try { try {
$previousValue = Input::old('post_submit_action'); $previousValue = Input::old('post_submit_action');
} catch (RuntimeException $e) { } catch (RuntimeException $e) {
// don't care // don't care
} }
// @codeCoverageIgnoreEnd
$previousValue = is_null($previousValue) ? 'store' : $previousValue; $previousValue = is_null($previousValue) ? 'store' : $previousValue;
$html = view('form.options', compact('type', 'name', 'previousValue'))->render(); $html = view('form.options', compact('type', 'name', 'previousValue'))->render();
@@ -391,7 +389,6 @@ class ExpandedForm
$preFilled = session('preFilled'); $preFilled = session('preFilled');
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value; $value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
} }
// @codeCoverageIgnoreStart
try { try {
if (!is_null(Input::old($name))) { if (!is_null(Input::old($name))) {
$value = Input::old($name); $value = Input::old($name);
@@ -400,7 +397,6 @@ class ExpandedForm
// don't care about session errors. // don't care about session errors.
} }
// @codeCoverageIgnoreEnd
return $value; return $value;
} }

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Facade;
/** /**
* Class Amount * Class Amount
* *
* @codeCoverageIgnore
* @package FireflyIII\Support\Facades * @package FireflyIII\Support\Facades
*/ */
class Amount extends Facade class Amount extends Facade

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Facade;
/** /**
* Class Amount * Class Amount
* *
* @codeCoverageIgnore
* @package FireflyIII\Support\Facades * @package FireflyIII\Support\Facades
*/ */
class ExpandedForm extends Facade class ExpandedForm extends Facade

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Facade;
/** /**
* Class Navigation * Class Navigation
* *
* @codeCoverageIgnore
* @package FireflyIII\Support\Facades * @package FireflyIII\Support\Facades
*/ */
class Navigation extends Facade class Navigation extends Facade

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Facade;
/** /**
* Class Preferences * Class Preferences
* *
* @codeCoverageIgnore
* @package FireflyIII\Support\Facades * @package FireflyIII\Support\Facades
*/ */
class Preferences extends Facade class Preferences extends Facade

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Facade;
/** /**
* Class Steam * Class Steam
* *
* @codeCoverageIgnore
* @package FireflyIII\Support\Facades * @package FireflyIII\Support\Facades
*/ */
class Steam extends Facade class Steam extends Facade

View File

@@ -39,7 +39,7 @@ class TransactionJournalSupport extends Model
$cache->addProperty('transaction-journal'); $cache->addProperty('transaction-journal');
$cache->addProperty('amount'); $cache->addProperty('amount');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$transaction = $journal->transactions->sortByDesc('amount')->first(); $transaction = $journal->transactions->sortByDesc('amount')->first();
@@ -66,7 +66,7 @@ class TransactionJournalSupport extends Model
$cache->addProperty('transaction-journal'); $cache->addProperty('transaction-journal');
$cache->addProperty('amount-positive'); $cache->addProperty('amount-positive');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$amount = '0'; $amount = '0';
@@ -143,7 +143,7 @@ class TransactionJournalSupport extends Model
$cache->addProperty('transaction-journal'); $cache->addProperty('transaction-journal');
$cache->addProperty('destination-account'); $cache->addProperty('destination-account');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$transaction = $journal->transactions()->where('amount', '>', 0)->first(); $transaction = $journal->transactions()->where('amount', '>', 0)->first();
if (!is_null($transaction)) { if (!is_null($transaction)) {
@@ -168,7 +168,7 @@ class TransactionJournalSupport extends Model
$cache->addProperty('transaction-journal'); $cache->addProperty('transaction-journal');
$cache->addProperty('destination-account-type-str'); $cache->addProperty('destination-account-type-str');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$account = self::destinationAccount($journal); $account = self::destinationAccount($journal);
@@ -225,7 +225,7 @@ class TransactionJournalSupport extends Model
$cache->addProperty('transaction-journal'); $cache->addProperty('transaction-journal');
$cache->addProperty('source-account'); $cache->addProperty('source-account');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$transaction = $journal->transactions()->where('amount', '<', 0)->first(); $transaction = $journal->transactions()->where('amount', '<', 0)->first();
if (!is_null($transaction)) { if (!is_null($transaction)) {
@@ -250,7 +250,7 @@ class TransactionJournalSupport extends Model
$cache->addProperty('transaction-journal'); $cache->addProperty('transaction-journal');
$cache->addProperty('source-account-type-str'); $cache->addProperty('source-account-type-str');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$account = self::sourceAccount($journal); $account = self::sourceAccount($journal);
@@ -272,7 +272,7 @@ class TransactionJournalSupport extends Model
$cache->addProperty('transaction-journal'); $cache->addProperty('transaction-journal');
$cache->addProperty('type-string'); $cache->addProperty('type-string');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$typeStr = $journal->transaction_type_type ?? $journal->transactionType->type; $typeStr = $journal->transaction_type_type ?? $journal->transactionType->type;

View File

@@ -110,7 +110,11 @@ class Preferences
{ {
$user = Auth::user(); $user = Auth::user();
if (is_null($user)) { if (is_null($user)) {
return $value; // make new preference, return it:
$pref = new Preference;
$pref->name = $name;
$pref->data = $value;
return $pref;
} }
return $this->setForUser(Auth::user(), $name, $value); return $this->setForUser(Auth::user(), $name, $value);

View File

@@ -35,7 +35,7 @@ class Steam
$cache->addProperty($date); $cache->addProperty($date);
$cache->addProperty($ignoreVirtualBalance); $cache->addProperty($ignoreVirtualBalance);
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$balance = strval( $balance = strval(
@@ -72,7 +72,7 @@ class Steam
$cache->addProperty($start); $cache->addProperty($start);
$cache->addProperty($end); $cache->addProperty($end);
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$balances = []; $balances = [];
@@ -119,7 +119,7 @@ class Steam
$cache->addProperty('balances'); $cache->addProperty('balances');
$cache->addProperty($date); $cache->addProperty($date);
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$balances = Transaction:: $balances = Transaction::

View File

@@ -10,7 +10,6 @@ use Twig_Extension;
use Twig_SimpleFunction; use Twig_SimpleFunction;
/** /**
* @codeCoverageIgnore
* Class Budget * Class Budget
* *
* @package FireflyIII\Support\Twig * @package FireflyIII\Support\Twig
@@ -29,7 +28,7 @@ class Budget extends Twig_Extension
$cache->addProperty($repetition->id); $cache->addProperty($repetition->id);
$cache->addProperty('spentInRepetition'); $cache->addProperty('spentInRepetition');
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get();
} }
$sum $sum
= Auth::user()->transactionjournals() = Auth::user()->transactionjournals()

View File

@@ -14,7 +14,6 @@ use Twig_SimpleFilter;
use Twig_SimpleFunction; use Twig_SimpleFunction;
/** /**
* @codeCoverageIgnore
* *
* Class TwigSupport * Class TwigSupport
* *

View File

@@ -8,7 +8,6 @@ use Twig_Extension;
use Twig_SimpleFunction; use Twig_SimpleFunction;
/** /**
* @codeCoverageIgnore
* *
* Class PiggyBank * Class PiggyBank
* *

View File

@@ -7,7 +7,6 @@ use Twig_Extension;
use Twig_SimpleFilter; use Twig_SimpleFilter;
/** /**
* @codeCoverageIgnore
* *
* Class Budget * Class Budget
* *