Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various code cleanup.
James Coled2ab03061f97
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 316ac51876..955ecc88d7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -277,8 +277,8 @@ This will be the last release to support PHP 7.0.- Can now make rules for attachments, see [issue 608](https://github.com/firefly-iii/firefly-iii/issues/608), as suggested by [dzaikos](https://github.com/dzaikos).### Fixed-- Fixed [issue 629](https://github.com/firefly-iii/firefly-iii/issues/629), reported by forcaeluz-- Fixed [issue 630](https://github.com/firefly-iii/firefly-iii/issues/630), reported by welbert+- Fixed [issue 629](https://github.com/firefly-iii/firefly-iii/issues/629), reported by @forcaeluz+- Fixed [issue 630](https://github.com/firefly-iii/firefly-iii/issues/630), reported by @welbert- And more various bug fixes.## [4.3.8] - 2017-04-08diff --git a/app/Helpers/Collector/JournalCollectorInterface.php b/app/Helpers/Collector/JournalCollectorInterface.phpindex f6fafd77f4..cb9dbe444f 100644--- a/app/Helpers/Collector/JournalCollectorInterface.php+++ b/app/Helpers/Collector/JournalCollectorInterface.php@@ -50,7 +50,7 @@ interface JournalCollectorInterface** @return JournalCollectorInterface*/- public function amountMore(string $amount): JournalCollectorInterface;+ public function amountIs(string $amount): JournalCollectorInterface;/*** @param string $amount@@ -64,7 +64,7 @@ interface JournalCollectorInterface** @return JournalCollectorInterface*/- public function amountIs(string $amount): JournalCollectorInterface;+ public function amountMore(string $amount): JournalCollectorInterface;/*** @return intdiff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.phpindex 2d37d26888..6a46a47549 100644--- a/app/Http/Controllers/AccountController.php+++ b/app/Http/Controllers/AccountController.php@@ -282,7 +282,7 @@ class AccountController extends Controller$currencyId = intval($account->getMeta('currency_id'));$currency = $currencyRepos->find($currencyId);if ($currencyId === 0) {- $currency = app('amount')->getDefaultCurrency();+ $currency = app('amount')->getDefaultCurrency();}diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.phpindex a29d0aabda..58f650150b 100644--- a/app/Http/Controllers/Chart/BudgetController.php+++ b/app/Http/Controllers/Chart/BudgetController.php@@ -94,7 +94,7 @@ class BudgetController extends Controller$cache->addProperty('chart.budget.budget');if ($cache->has()) {- return Response::json($cache->get()); // @codeCoverageIgnore+ return Response::json($cache->get()); // @codeCoverageIgnore}$final = clone $last;diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.phpindex 933bedb124..f06a710c71 100644--- a/app/Http/Controllers/CurrencyController.php+++ b/app/Http/Controllers/CurrencyController.php@@ -217,13 +217,13 @@ class CurrencyController extends Controller{$currencies = $this->repository->get();$defaultCurrency = $this->repository->getCurrencyByPreference(Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR')));- $isOwner = true;+ $isOwner = true;if (!$this->userRepository->hasRole(auth()->user(), 'owner')) {$request->session()->flash('info', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')]));$isOwner = false;}- return view('currencies.index', compact('currencies', 'defaultCurrency','isOwner'));+ return view('currencies.index', compact('currencies', 'defaultCurrency', 'isOwner'));}/**diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.phpindex 1b7d02b3b6..5b040fd429 100644--- a/app/Http/Controllers/HomeController.php+++ b/app/Http/Controllers/HomeController.php@@ -116,7 +116,7 @@ class HomeController extends Controller}}// last few lines- $logContent = 'Truncated from this point <----|'.substr($logContent, -4096);+ $logContent = 'Truncated from this point <----|' . substr($logContent, -4096);return view('debug', compact('phpVersion', 'extensions', 'carbon', 'now', 'drivers', 'currentDriver', 'userAgent', 'phpOs', 'interface', 'logContent'));diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.phpindex fe97ee0501..565330c229 100644--- a/app/Http/Controllers/JavascriptController.php+++ b/app/Http/Controllers/JavascriptController.php@@ -24,7 +24,6 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;use Carbon\Carbon;-use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use FireflyIII\Models\TransactionCurrency;diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.phpindex 3d46778d37..cc41dd4273 100644--- a/app/Http/Controllers/NewUserController.php+++ b/app/Http/Controllers/NewUserController.php@@ -93,7 +93,7 @@ class NewUserController extends Controller// also store currency preference from input:$currency = $currencyRepository->find(intval($request->input('amount_currency_id_bank_balance')));- if(!is_null($currency->id)) {+ if (!is_null($currency->id)) {// store currency preference:Preferences::set('currencyPreference', $currency->code);Preferences::mark();diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.phpindex c8d055556e..256e15c9eb 100644--- a/app/Http/Controllers/Transaction/SplitController.php+++ b/app/Http/Controllers/Transaction/SplitController.php@@ -232,13 +232,13 @@ class SplitController extends Controller{$sourceAccounts = $journal->sourceAccountList();$destinationAccounts = $journal->destinationAccountList();- $notes = '';+ $notes = '';/** @var Note $note */$note = $journal->notes()->first();if (!is_null($note)) {$notes = $note->text;}- $array = [+ $array = ['journal_description' => $request->old('journal_description', $journal->description),'journal_amount' => $journal->amountPositive(),'sourceAccounts' => $sourceAccounts,diff --git a/app/Http/Middleware/StartFireflySession.php b/app/Http/Middleware/StartFireflySession.phpindex e354451512..2ad495e6d7 100644--- a/app/Http/Middleware/StartFireflySession.php+++ b/app/Http/Middleware/StartFireflySession.php@@ -43,10 +43,10 @@ class StartFireflySession extends StartSession** @return mixed*/-// public function handle($request, Closure $next)-// {-// return parent::handle($request, $next); // defer to the right stuff-// }+ // public function handle($request, Closure $next)+ // {+ // return parent::handle($request, $next); // defer to the right stuff+ // }/*** Store the current URL for the request if necessary.diff --git a/app/Import/Specifics/AbnAmroDescription.php b/app/Import/Specifics/AbnAmroDescription.phpindex 59d30ffc00..0472179b51 100644--- a/app/Import/Specifics/AbnAmroDescription.php+++ b/app/Import/Specifics/AbnAmroDescription.php@@ -126,6 +126,7 @@ class AbnAmroDescription implements SpecificInterface/*** Parses the current description in SEPA format* @SuppressWarnings(PHPMD.CyclomaticComplexity)+ ** @return bool true if the description is SEPA format, false otherwise*/protected function parseSepaDescription()diff --git a/app/Import/Specifics/SnsDescription.php b/app/Import/Specifics/SnsDescription.phpindex ab6c941580..d36aefa82e 100644--- a/app/Import/Specifics/SnsDescription.php+++ b/app/Import/Specifics/SnsDescription.php@@ -33,8 +33,6 @@ declare(strict_types=1);namespace FireflyIII\Import\Specifics;-use Log;-/*** Class SnsDescription*@@ -65,8 +63,9 @@ class SnsDescription implements SpecificInterface*/public function run(array $row): array{- $row[17] = ltrim($row[17],"'");- $row[17] = rtrim($row[17],"'");+ $row[17] = ltrim($row[17], "'");+ $row[17] = rtrim($row[17], "'");+return $row;}}diff --git a/app/Models/Bill.php b/app/Models/Bill.phpindex f681a0915c..2f399fbbb5 100644--- a/app/Models/Bill.php+++ b/app/Models/Bill.php@@ -46,7 +46,7 @@ class Bill extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','deleted_at' => 'datetime',diff --git a/app/Models/Budget.php b/app/Models/Budget.phpindex b0680f3b85..b1aae74667 100644--- a/app/Models/Budget.php+++ b/app/Models/Budget.php@@ -53,12 +53,12 @@ class Budget extends Model'active' => 'boolean','encrypted' => 'boolean',];- /** @var array */+ /** @var array */protected $fillable = ['user_id', 'name', 'active'];- /** @var array */- protected $hidden = ['encrypted'];- /** @var array */- protected $rules = ['name' => 'required|between:1,200',];+ /** @var array */+ protected $hidden = ['encrypted'];+ /** @var array */+ protected $rules = ['name' => 'required|between:1,200',];/*** @param array $fieldsdiff --git a/app/Models/Configuration.php b/app/Models/Configuration.phpindex f00654ec0f..16492e0762 100644--- a/app/Models/Configuration.php+++ b/app/Models/Configuration.php@@ -41,7 +41,7 @@ class Configuration extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime',];diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.phpindex 37a94593e0..15d34a06b9 100644--- a/app/Models/CurrencyExchangeRate.php+++ b/app/Models/CurrencyExchangeRate.php@@ -36,7 +36,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;class CurrencyExchangeRate extends Model{- /** @var array */+ /** @var array */protected $dates = ['date'];/**diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.phpindex f2c541cedb..ab2fb1cf61 100644--- a/app/Models/LimitRepetition.php+++ b/app/Models/LimitRepetition.php@@ -42,15 +42,15 @@ class LimitRepetition extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','startdate' => 'date','enddate' => 'date',];- /** @var array */- protected $dates = ['startdate', 'enddate'];- /** @var array */+ /** @var array */+ protected $dates = ['startdate', 'enddate'];+ /** @var array */protected $hidden = ['amount_encrypted'];/**diff --git a/app/Models/Note.php b/app/Models/Note.phpindex f1c2202fa9..c55efef879 100644--- a/app/Models/Note.php+++ b/app/Models/Note.php@@ -39,12 +39,12 @@ class Note extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','deleted_at' => 'datetime',];- /** @var array */+ /** @var array */protected $fillable = ['title', 'text'];/**diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.phpindex 3325f2c282..44426cd6a2 100644--- a/app/Models/PiggyBank.php+++ b/app/Models/PiggyBank.php@@ -46,7 +46,7 @@ class PiggyBank extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','deleted_at' => 'datetime',@@ -56,12 +56,12 @@ class PiggyBank extends Model'active' => 'boolean','encrypted' => 'boolean',];- /** @var array */- protected $dates = ['startdate', 'targetdate'];- /** @var array */+ /** @var array */+ protected $dates = ['startdate', 'targetdate'];+ /** @var array */protected $fillable = ['name', 'account_id', 'order', 'targetamount', 'startdate', 'targetdate'];- /** @var array */- protected $hidden = ['targetamount_encrypted', 'encrypted'];+ /** @var array */+ protected $hidden = ['targetamount_encrypted', 'encrypted'];/*** @param PiggyBank $valuediff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.phpindex 13088c60c3..69bcd531a8 100644--- a/app/Models/PiggyBankEvent.php+++ b/app/Models/PiggyBankEvent.php@@ -39,12 +39,12 @@ class PiggyBankEvent extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','date' => 'datetime',];- /** @var array */+ /** @var array */protected $dates = ['date'];protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];protected $hidden = ['amount_encrypted'];diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.phpindex 6073e3c108..7970cfaf3a 100644--- a/app/Models/PiggyBankRepetition.php+++ b/app/Models/PiggyBankRepetition.php@@ -41,16 +41,16 @@ class PiggyBankRepetition extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','deleted_at' => 'datetime','startdate' => 'date','targetdate' => 'date',];- /** @var array */- protected $dates = ['startdate', 'targetdate'];- /** @var array */+ /** @var array */+ protected $dates = ['startdate', 'targetdate'];+ /** @var array */protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];/**diff --git a/app/Models/Preference.php b/app/Models/Preference.phpindex 9d66c0ac85..16f9dbaeb6 100644--- a/app/Models/Preference.php+++ b/app/Models/Preference.php@@ -44,12 +44,12 @@ class Preference extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime',];- /** @var array */+ /** @var array */protected $fillable = ['user_id', 'data', 'name', 'data'];/**diff --git a/app/Models/Role.php b/app/Models/Role.phpindex c117329c6a..97e03192a2 100644--- a/app/Models/Role.php+++ b/app/Models/Role.php@@ -40,7 +40,7 @@ class Role extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime',];diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.phpindex 3b4c0eb607..7737175352 100644--- a/app/Models/TransactionCurrency.php+++ b/app/Models/TransactionCurrency.php@@ -26,7 +26,6 @@ namespace FireflyIII\Models;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\SoftDeletes;use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;-use Watson\Validating\ValidatingTrait;/*** Class TransactionCurrency@@ -43,15 +42,15 @@ class TransactionCurrency extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','deleted_at' => 'datetime','decimal_places' => 'int',];- /** @var array */- protected $dates = ['date'];- /** @var array */+ /** @var array */+ protected $dates = ['date'];+ /** @var array */protected $fillable = ['name', 'code', 'symbol', 'decimal_places'];/**diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.phpindex b6df84bbd7..43b43deb1f 100644--- a/app/Models/TransactionJournal.php+++ b/app/Models/TransactionJournal.php@@ -66,7 +66,7 @@ class TransactionJournal extends Model'completed' => 'boolean',];/** @var array */- protected $dates = ['date','interest_date', 'book_date', 'process_date'];+ protected $dates = ['date', 'interest_date', 'book_date', 'process_date'];/** @var array */protected $fillable= ['user_id', 'transaction_type_id', 'bill_id', 'interest_date', 'book_date', 'process_date',diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 7926b18778..34adbd971c 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -297,7 +297,7 @@ class AccountRepository implements AccountRepositoryInterfaceprotected function storeInitialBalance(Account $account, array $data): TransactionJournal{$amount = strval($data['openingBalance']);- Log::debug(sprintf('Submitted amount is %s',$amount));+ Log::debug(sprintf('Submitted amount is %s', $amount));if (bccomp($amount, '0') === 0) {return new TransactionJournal;@@ -326,7 +326,7 @@ class AccountRepository implements AccountRepositoryInterface$secondAmount = bcmul($amount, '-1');Log::debug(sprintf('First amount is %s, second amount is %s', $firstAmount, $secondAmount));- if (bccomp($amount,'0') === -1) {+ if (bccomp($amount, '0') === -1) {Log::debug(sprintf('%s is a negative number.', $amount));$firstAccount = $opposing;$secondAccount = $account;@@ -508,8 +508,8 @@ class AccountRepository implements AccountRepositoryInterfaceprotected function validOpeningBalanceData(array $data): bool{$data['openingBalance'] = strval($data['openingBalance'] ?? '');- if (isset($data['openingBalance']) && !is_null($data['openingBalance']) && strlen($data['openingBalance']) > 0 &&- isset($data['openingBalanceDate'])) {+ if (isset($data['openingBalance']) && !is_null($data['openingBalance']) && strlen($data['openingBalance']) > 0+ && isset($data['openingBalanceDate'])) {Log::debug('Array has valid opening balance data.');return true;diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex 493184c3f9..767d2acc56 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -24,10 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support;use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Models\Transaction as TransactionModel;use FireflyIII\Models\TransactionCurrency;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Models\TransactionType;use FireflyIII\User;use Illuminate\Support\Collection;use Preferences as Prefs;diff --git a/app/Support/Preferences.php b/app/Support/Preferences.phpindex 74d59ad23e..bec81b756a 100644--- a/app/Support/Preferences.php+++ b/app/Support/Preferences.php@@ -176,7 +176,7 @@ class Preferences/*** @param $name- * @param $value+ * @param $value** @return Preference*/diff --git a/app/Support/Search/Modifier.php b/app/Support/Search/Modifier.phpindex fddddb9d8d..c5ad8dd986 100644--- a/app/Support/Search/Modifier.php+++ b/app/Support/Search/Modifier.php@@ -28,7 +28,6 @@ use Carbon\Carbon;use Exception;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Transaction;-use Illuminate\Support\Str;use Log;use Steam;@@ -75,16 +74,16 @@ class ModifierLog::debug(sprintf('Destination is %s? %s', $modifier['value'], var_export($res, true)));break;case 'category':- $res = self::category($transaction, $modifier['value']);+ $res = self::category($transaction, $modifier['value']);Log::debug(sprintf('Category is %s? %s', $modifier['value'], var_export($res, true)));break;case 'budget':- $res = self::budget($transaction, $modifier['value']);+ $res = self::budget($transaction, $modifier['value']);Log::debug(sprintf('Budget is %s? %s', $modifier['value'], var_export($res, true)));break;case 'bill':$name = Steam::tryDecrypt($transaction->bill_name);- $res = self::stringCompare($name, $modifier['value']);+ $res = self::stringCompare($name, $modifier['value']);Log::debug(sprintf('Bill is %s? %s', $modifier['value'], var_export($res, true)));break;}diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.phpindex 551caf3ee5..96022ca313 100644--- a/app/Support/Twig/AmountFormat.php+++ b/app/Support/Twig/AmountFormat.php@@ -25,9 +25,7 @@ namespace FireflyIII\Support\Twig;use FireflyIII\Models\Account as AccountModel;-use FireflyIII\Models\Transaction as TransactionModel;use FireflyIII\Models\TransactionCurrency;-use FireflyIII\Models\TransactionJournal;use Twig_Extension;use Twig_SimpleFilter;use Twig_SimpleFunction;diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.phpindex f39c307d54..cad069fd36 100644--- a/app/Support/Twig/Journal.php+++ b/app/Support/Twig/Journal.php@@ -29,10 +29,11 @@ use FireflyIII\Models\AccountType;use FireflyIII\Models\Category;use FireflyIII\Models\TransactionJournal;use FireflyIII\Support\CacheProperties;+use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;use Twig_Extension;use Twig_SimpleFilter;use Twig_SimpleFunction;-use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;+/*** Class Journal*@@ -82,7 +83,6 @@ class Journal extends Twig_Extensionpublic function getFilters(): array{$filters = [- $this->typeIcon(),new Twig_SimpleFilter('journalTotalAmount', [TransactionJournalExtension::class, 'totalAmount'], ['is_safe' => ['html']]),];@@ -227,38 +227,4 @@ class Journal extends Twig_Extension});}-- /**- * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 5.- *- * @return Twig_SimpleFilter- */- protected function typeIcon(): Twig_SimpleFilter- {- return new Twig_SimpleFilter(- 'typeIcon', function (TransactionJournal $journal): string {-- switch (true) {- case $journal->isWithdrawal():- $txt = sprintf('<i class="fa fa-long-arrow-left fa-fw" title="%s"></i>', trans('firefly.withdrawal'));- break;- case $journal->isDeposit():- $txt = sprintf('<i class="fa fa-long-arrow-right fa-fw" title="%s"></i>', trans('firefly.deposit'));- break;- case $journal->isTransfer():- $txt = sprintf('<i class="fa fa-fw fa-exchange" title="%s"></i>', trans('firefly.transfer'));- break;- case $journal->isOpeningBalance():- $txt = sprintf('<i class="fa-fw fa fa-star-o" title="%s"></i>', trans('firefly.openingBalance'));- break;- default:- $txt = '';- break;- }-- return $txt;- }, ['is_safe' => ['html']]- );- }-}diff --git a/app/Support/Twig/Transaction.php b/app/Support/Twig/Transaction.phpindex 7fe539adbf..fa1f8a76ba 100644--- a/app/Support/Twig/Transaction.php+++ b/app/Support/Twig/Transaction.php@@ -23,12 +23,9 @@ declare(strict_types=1);namespace FireflyIII\Support\Twig;-use FireflyIII\Models\Transaction as TransactionModel;use FireflyIII\Support\Twig\Extension\Transaction as TransactionExtension;-use Steam;use Twig_Extension;use Twig_SimpleFilter;-use Twig_SimpleFunction;/*** Class Transaction@@ -46,6 +43,7 @@ class Transaction extends Twig_Extensionnew Twig_SimpleFilter('transactionIcon', [TransactionExtension::class, 'icon'], ['is_safe' => ['html']]),new Twig_SimpleFilter('transactionDescription', [TransactionExtension::class, 'description']),new Twig_SimpleFilter('transactionIsSplit', [TransactionExtension::class, 'isSplit'], ['is_safe' => ['html']]),+ new Twig_SimpleFilter('transactionReconciled', [TransactionExtension::class, 'isReconciled'], ['is_safe' => ['html']]),new Twig_SimpleFilter('transactionHasAtt', [TransactionExtension::class, 'hasAttachments'], ['is_safe' => ['html']]),new Twig_SimpleFilter('transactionAmount', [TransactionExtension::class, 'amount'], ['is_safe' => ['html']]),new Twig_SimpleFilter('transactionArrayAmount', [TransactionExtension::class, 'amountArray'], ['is_safe' => ['html']]),@@ -58,19 +56,6 @@ class Transaction extends Twig_Extensionreturn $filters;}- /**- * @return array- */- public function getFunctions(): array- {- $functions = [- $this->transactionIdBudgets(),- $this->transactionIdCategories(),- ];-- return $functions;- }-/*** Returns the name of the extension.*@@ -80,110 +65,4 @@ class Transaction extends Twig_Extension{return 'transaction';}--- /**- * @return Twig_SimpleFunction- */- public function transactionIdBudgets(): Twig_SimpleFunction- {- return new Twig_SimpleFunction(- 'transactionIdBudgets', function (int $transactionId): string {- $transaction = TransactionModel::find($transactionId);-- return $this->getTransactionBudgets($transaction);- }, ['is_safe' => ['html']]- );- }-- /**- * @return Twig_SimpleFunction- */- public function transactionIdCategories(): Twig_SimpleFunction- {- return new Twig_SimpleFunction(- 'transactionIdCategories', function (int $transactionId): string {- $transaction = TransactionModel::find($transactionId);-- return $this->getTransactionCategories($transaction);- }, ['is_safe' => ['html']]- );- }-- /**- * @param TransactionModel $transaction- *- * @return string- */- private function getTransactionBudgets(TransactionModel $transaction): string- {- // journal has a budget:- if (isset($transaction->transaction_journal_budget_id)) {- $name = Steam::decrypt(intval($transaction->transaction_journal_budget_encrypted), $transaction->transaction_journal_budget_name);-- return sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_journal_budget_id]), $name, $name);- }-- // transaction has a budget- if (isset($transaction->transaction_budget_id)) {- $name = Steam::decrypt(intval($transaction->transaction_budget_encrypted), $transaction->transaction_budget_name);-- return sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name);- }-- // see if the transaction has a budget:- $budgets = $transaction->budgets()->get();- if ($budgets->count() === 0) {- $budgets = $transaction->transactionJournal()->first()->budgets()->get();- }- if ($budgets->count() > 0) {- $str = [];- foreach ($budgets as $budget) {- $str[] = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$budget->id]), $budget->name, $budget->name);- }-- return join(', ', $str);- }--- return '';- }-- /**- * @param TransactionModel $transaction- *- * @return string- */- private function getTransactionCategories(TransactionModel $transaction): string- {- // journal has a category:- if (isset($transaction->transaction_journal_category_id)) {- $name = Steam::decrypt(intval($transaction->transaction_journal_category_encrypted), $transaction->transaction_journal_category_name);-- return sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_journal_category_id]), $name, $name);- }-- // transaction has a category:- if (isset($transaction->transaction_category_id)) {- $name = Steam::decrypt(intval($transaction->transaction_category_encrypted), $transaction->transaction_category_name);-- return sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_category_id]), $name, $name);- }-- // see if the transaction has a category:- $categories = $transaction->categories()->get();- if ($categories->count() === 0) {- $categories = $transaction->transactionJournal()->first()->categories()->get();- }- if ($categories->count() > 0) {- $str = [];- foreach ($categories as $category) {- $str[] = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$category->id]), $category->name, $category->name);- }-- return join(', ', $str);- }-- return '';- }}diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.phpindex a832e7d5f4..1f91664926 100644--- a/app/TransactionRules/Actions/SetBudget.php+++ b/app/TransactionRules/Actions/SetBudget.php@@ -62,9 +62,9 @@ class SetBudget implements ActionInterface/** @var BudgetRepositoryInterface $repository */$repository = app(BudgetRepositoryInterface::class);$repository->setUser($journal->user);- $search = $this->action->action_value;+ $search = $this->action->action_value;$budgets = $repository->getActiveBudgets();- $budget = $budgets->filter(+ $budget = $budgets->filter(function (Budget $current) use ($search) {return $current->name === $search;}@@ -76,7 +76,12 @@ class SetBudget implements ActionInterface}if ($journal->transactionType->type !== TransactionType::WITHDRAWAL) {- Log::debug(sprintf('RuleAction SetBudget could not set budget of journal #%d to "%s" because journal is a %s.', $journal->id, $search, $journal->transactionType->type));+ Log::debug(+ sprintf(+ 'RuleAction SetBudget could not set budget of journal #%d to "%s" because journal is a %s.', $journal->id, $search,+ $journal->transactionType->type+ )+ );return true;}diff --git a/app/TransactionRules/Triggers/AbstractTrigger.php b/app/TransactionRules/Triggers/AbstractTrigger.phpindex 15368bd015..d917dd1a84 100644--- a/app/TransactionRules/Triggers/AbstractTrigger.php+++ b/app/TransactionRules/Triggers/AbstractTrigger.php@@ -48,6 +48,7 @@ class AbstractTrigger/*** AbstractTrigger constructor.+ ** @codeCoverageIgnore*/private function __construct()@@ -57,6 +58,7 @@ class AbstractTrigger/*** @codeCoverageIgnore+ ** @param string $triggerValue* @param bool $stopProcessing*@@ -73,6 +75,7 @@ class AbstractTrigger/*** @codeCoverageIgnore+ ** @param RuleTrigger $trigger** @return AbstractTrigger@@ -89,6 +92,7 @@ class AbstractTrigger/*** @codeCoverageIgnore+ ** @param string $triggerValue** @return AbstractTriggerdiff --git a/app/TransactionRules/Triggers/HasAttachment.php b/app/TransactionRules/Triggers/HasAttachment.phpindex 86aed103ab..691197d8b1 100644--- a/app/TransactionRules/Triggers/HasAttachment.php+++ b/app/TransactionRules/Triggers/HasAttachment.php@@ -63,7 +63,7 @@ class HasAttachment extends AbstractTrigger implements TriggerInterface*/public function triggered(TransactionJournal $journal): bool{- $minimum = intval($this->triggerValue);+ $minimum = intval($this->triggerValue);$attachments = $journal->attachments()->count();if ($attachments >= $minimum) {Log::debug(diff --git a/app/TransactionRules/Triggers/UserAction.php b/app/TransactionRules/Triggers/UserAction.phpindex cd327c26d3..6a3bacca20 100644--- a/app/TransactionRules/Triggers/UserAction.php+++ b/app/TransactionRules/Triggers/UserAction.php@@ -47,6 +47,7 @@ final class UserAction extends AbstractTrigger implements TriggerInterface* false.** @param null $value+ ** @codeCoverageIgnore** @return bool@@ -60,6 +61,7 @@ final class UserAction extends AbstractTrigger implements TriggerInterface* This trigger is always triggered, because the rule that it is a part of has been pre-selected on this condition.** @param TransactionJournal $journal+ ** @codeCoverageIgnore** @return booldiff --git a/composer.lock b/composer.lockindex aefd8fccb3..f56ec43671 100644--- a/composer.lock+++ b/composer.lock@@ -3952,16 +3952,16 @@},{"name": "phpunit/php-code-coverage",- "version": "5.2.2",+ "version": "5.2.3","source": {"type": "git","url": "https://github.com/sebastianbergmann/php-code-coverage.git",- "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b"+ "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b",- "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b",+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",+ "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d","shasum": ""},"require": {@@ -3970,7 +3970,7 @@"php": "^7.0","phpunit/php-file-iterator": "^1.4.2","phpunit/php-text-template": "^1.2.1",- "phpunit/php-token-stream": "^1.4.11 || ^2.0",+ "phpunit/php-token-stream": "^2.0","sebastian/code-unit-reverse-lookup": "^1.0.1","sebastian/environment": "^3.0","sebastian/version": "^2.0.1",@@ -4012,7 +4012,7 @@"testing","xunit"],- "time": "2017-08-03T12:40:43+00:00"+ "time": "2017-11-03T13:47:33+00:00"},{"name": "phpunit/php-file-iterator",@@ -4390,30 +4390,30 @@},{"name": "sebastian/comparator",- "version": "2.0.2",+ "version": "2.1.0","source": {"type": "git","url": "https://github.com/sebastianbergmann/comparator.git",- "reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a"+ "reference": "1174d9018191e93cb9d719edec01257fc05f8158"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/ae068fede81d06e7bb9bb46a367210a3d3e1fe6a",- "reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a",+ "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1174d9018191e93cb9d719edec01257fc05f8158",+ "reference": "1174d9018191e93cb9d719edec01257fc05f8158","shasum": ""},"require": {"php": "^7.0","sebastian/diff": "^2.0",- "sebastian/exporter": "^3.0"+ "sebastian/exporter": "^3.1"},"require-dev": {- "phpunit/phpunit": "^6.0"+ "phpunit/phpunit": "^6.4"},"type": "library","extra": {"branch-alias": {- "dev-master": "2.0.x-dev"+ "dev-master": "2.1.x-dev"}},"autoload": {@@ -4444,13 +4444,13 @@}],"description": "Provides the functionality to compare PHP values for equality",- "homepage": "http://www.github.com/sebastianbergmann/comparator",+ "homepage": "https://github.com/sebastianbergmann/comparator","keywords": ["comparator","compare","equality"],- "time": "2017-08-03T07:14:59+00:00"+ "time": "2017-11-03T07:16:52+00:00"},{"name": "sebastian/diff",