diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index b3c1c33320..2098c6788b 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -90,6 +90,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property int $opposing_id // ID of the opposing transaction, used in collector * @property bool $encrypted // is the journal encrypted * @property bool reconciled + * @property string transaction_category_encrypted + * @property string transaction_journal_category_encrypted + * @property string transaction_budget_encrypted + * @property string transaction_journal_budget_encrypted + * @property string type + * @property string name * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class Transaction extends Model diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 77478c8be1..8e5b29f661 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -50,18 +50,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property Collection $tags * @property mixed user_id * @property mixed transactions - * @property int transaction_count - * @property Carbon interest_date - * @property Carbon book_date - * @property Carbon process_date - * @property bool encrypted - * @property int order - * @property int budget_id - * @property string period_marker - * @property Carbon $date - * @property string $transaction_type_type - * @property int $id + * @property int transaction_count + * @property Carbon interest_date + * @property Carbon book_date + * @property Carbon process_date + * @property bool encrypted + * @property int order + * @property int budget_id + * @property string period_marker + * @property Carbon $date + * @property string $transaction_type_type + * @property int $id * @property TransactionType $transactionType + * @property Collection budgets * * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.php index 6dc8113d4d..d33e0ef412 100644 --- a/app/Rules/BelongsUser.php +++ b/app/Rules/BelongsUser.php @@ -155,7 +155,7 @@ class BelongsUser implements Rule */ private function validateAccountId(int $value): bool { - $count = Account::where('id', '=', (int)$value)->where('user_id', '=', auth()->user()->id)->count(); + $count = Account::where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); return 1 === $count; } diff --git a/app/Services/Currency/FixerIOv2.php b/app/Services/Currency/FixerIOv2.php index 5e296f5de4..2d5f250f8a 100644 --- a/app/Services/Currency/FixerIOv2.php +++ b/app/Services/Currency/FixerIOv2.php @@ -72,7 +72,6 @@ class FixerIOv2 implements ExchangeRateInterface 'http://data.fixer.io/api/%s?access_key=%s&base=%s&symbols=%s', $date->format('Y-m-d'), $apiKey, $fromCurrency->code, $toCurrency->code ); - $statusCode = -1; Log::debug(sprintf('Going to request exchange rate using URI %s', str_replace($apiKey, 'xxxx', $uri))); $client = new Client; try { diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 01973c203d..17dff88a69 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -33,6 +33,7 @@ use Preferences as Prefs; */ class Amount { + /** @noinspection MoreThanThreeArgumentsInspection */ /** * bool $sepBySpace is $localeconv['n_sep_by_space'] * int $signPosn = $localeconv['n_sign_posn'] @@ -116,10 +117,11 @@ class Amount * * @return string */ - public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true): string + public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = null): string { - $locale = explode(',', (string)trans('config.locale')); - $locale = array_map('trim', $locale); + $coloured = $coloured ?? true; + $locale = explode(',', (string)trans('config.locale')); + $locale = array_map('trim', $locale); setlocale(LC_MONETARY, $locale); $float = round($amount, 12); $info = localeconv(); @@ -205,6 +207,7 @@ class Amount */ public function getDefaultCurrency(): TransactionCurrency { + /** @var User $user */ $user = auth()->user(); return $this->getDefaultCurrencyByUser($user); diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index 2c1baab334..b63b8f2c5d 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -47,14 +47,14 @@ class AccountList implements BinderInterface if (auth()->check()) { $collection = new Collection; - if ($value === 'allAssetAccounts') { + if ('allAssetAccounts' === $value) { /** @var \Illuminate\Support\Collection $collection */ $collection = auth()->user()->accounts() ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') ->where('account_types.type', AccountType::ASSET) ->get(['accounts.*']); } - if ($value !== 'allAssetAccounts') { + if ('allAssetAccounts' !== $value) { $list = []; $incoming = explode(',', $value); @@ -62,7 +62,7 @@ class AccountList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (\count($list) === 0) { + if (0 === \count($list)) { Log::error('Account list is empty.'); throw new NotFoundHttpException; // @codeCoverageIgnore } diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php index 374640b127..3c6da0ce92 100644 --- a/app/Support/Binder/BudgetList.php +++ b/app/Support/Binder/BudgetList.php @@ -48,7 +48,7 @@ class BudgetList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (\count($list) === 0) { + if (0 === \count($list)) { throw new NotFoundHttpException; // @codeCoverageIgnore } @@ -59,7 +59,7 @@ class BudgetList implements BinderInterface ->get(); // add empty budget if applicable. - if (\in_array(0, $list)) { + if (\in_array(0, $list, true)) { $collection->push(new Budget); } diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php index 90bb36dfff..bd6997423d 100644 --- a/app/Support/Binder/CategoryList.php +++ b/app/Support/Binder/CategoryList.php @@ -48,7 +48,7 @@ class CategoryList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (\count($list) === 0) { + if (0 === \count($list)) { throw new NotFoundHttpException; // @codeCoverageIgnore } @@ -58,7 +58,7 @@ class CategoryList implements BinderInterface ->get(); // add empty category if applicable. - if (\in_array(0, $list)) { + if (\in_array(0, $list, true)) { $collection->push(new Category); } diff --git a/app/Support/Binder/Date.php b/app/Support/Binder/Date.php index 39ee1a704f..e075179b61 100644 --- a/app/Support/Binder/Date.php +++ b/app/Support/Binder/Date.php @@ -51,7 +51,7 @@ class Date implements BinderInterface try { $date = new Carbon($value); } catch (Exception $e) { - Log::error('Could not parse date "' . $value . '" for user #' . auth()->user()->id); + Log::error(sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage())); throw new NotFoundHttpException; } diff --git a/app/Support/Binder/ImportProvider.php b/app/Support/Binder/ImportProvider.php index 149e38cb84..7e5917f50c 100644 --- a/app/Support/Binder/ImportProvider.php +++ b/app/Support/Binder/ImportProvider.php @@ -27,30 +27,14 @@ use FireflyIII\Import\Prerequisites\PrerequisitesInterface; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\User; use Illuminate\Routing\Route; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Log; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class ImportProvider. */ class ImportProvider implements BinderInterface { - /** - * @param string $value - * @param Route $route - * - * @return Carbon - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ - public static function routeBinder(string $value, Route $route): string - { - $providers = array_keys(self::getProviders()); - if (\in_array($value, $providers, true)) { - return $value; - } - throw new NotFoundHttpException; - } - /** * @return array */ @@ -99,4 +83,20 @@ class ImportProvider implements BinderInterface return $providers; } + + /** + * @param string $value + * @param Route $route + * + * @return Carbon + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + */ + public static function routeBinder(string $value, Route $route): string + { + $providers = array_keys(self::getProviders()); + if (\in_array($value, $providers, true)) { + return $value; + } + throw new NotFoundHttpException; + } } diff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.php index e86774d871..5c034c242c 100644 --- a/app/Support/Binder/JournalList.php +++ b/app/Support/Binder/JournalList.php @@ -47,7 +47,7 @@ class JournalList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (\count($list) === 0) { + if (0 === \count($list)) { throw new NotFoundHttpException; // @codeCoverageIgnore } diff --git a/app/Support/Binder/SimpleJournalList.php b/app/Support/Binder/SimpleJournalList.php index 6375208c1c..b33ac2fc9a 100644 --- a/app/Support/Binder/SimpleJournalList.php +++ b/app/Support/Binder/SimpleJournalList.php @@ -51,7 +51,7 @@ class SimpleJournalList implements BinderInterface $list[] = (int)$entry; } $list = array_unique($list); - if (\count($list) === 0) { + if (0 === \count($list)) { throw new NotFoundHttpException; // @codeCoverageIgnore } diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php index 1b9eb74aa6..b4131e0eea 100644 --- a/app/Support/Binder/TagList.php +++ b/app/Support/Binder/TagList.php @@ -50,7 +50,7 @@ class TagList implements BinderInterface $list[] = strtolower(trim($entry)); } $list = array_unique($list); - if (\count($list) === 0) { + if (0 === \count($list)) { Log::error('Tag list is empty.'); throw new NotFoundHttpException; // @codeCoverageIgnore } @@ -61,7 +61,7 @@ class TagList implements BinderInterface $collection = $allTags->filter( function (Tag $tag) use ($list) { - return \in_array(strtolower($tag->tag), $list); + return \in_array(strtolower($tag->tag), $list, true); } ); diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.php index d6d34aa8ed..52d7e7d22f 100644 --- a/app/Support/CacheProperties.php +++ b/app/Support/CacheProperties.php @@ -50,7 +50,7 @@ class CacheProperties /** * @param $property */ - public function addProperty($property) + public function addProperty($property): void { $this->properties->push($property); } @@ -87,14 +87,14 @@ class CacheProperties /** * @param $data */ - public function store($data) + public function store($data): void { Cache::forever($this->hash, $data); } /** */ - private function hash() + private function hash(): void { $content = ''; foreach ($this->properties as $property) { diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index ea4747bc96..e7edc728f2 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -36,6 +36,7 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; use Form; use Illuminate\Support\Collection; +use Illuminate\Support\HtmlString; use Illuminate\Support\MessageBag; use Log; use RuntimeException; @@ -251,7 +252,7 @@ class ExpandedForm { $options = $options ?? []; $value = $value ?? 1; - $options['checked'] = true === $checked ? true : false; + $options['checked'] = true === $checked; if (Session::has('preFilled')) { $preFilled = session('preFilled'); @@ -688,13 +689,13 @@ class ExpandedForm } /** - * @param string $name - * @param mixed $value - * @param array $options + * @param string $name + * @param null $value + * @param array|null $options * - * @return \Illuminate\Support\HtmlString + * @return HtmlString */ - public function ruleGroupListWithEmpty(string $name, $value = null, array $options = null) + public function ruleGroupListWithEmpty(string $name, $value = null, array $options = null): HtmlString { $options = $options ?? []; $options['class'] = 'form-control'; @@ -877,6 +878,7 @@ class ExpandedForm } } catch (RuntimeException $e) { // don't care about session errors. + Log::debug(sprintf('Run time: %s', $e->getMessage())); } if ($value instanceof Carbon) { $value = $value->format('Y-m-d'); @@ -929,6 +931,8 @@ class ExpandedForm * @param array $options * * @return string + * @throws \FireflyIII\Exceptions\FireflyException + * @throws \FireflyIII\Exceptions\FireflyException */ private function currencyField(string $name, string $view, $value = null, array $options = null): string { diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index 9e7ecf23fd..1c9a1c9d3c 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -51,11 +51,11 @@ class FireflyConfig /** * @param string $name - * @param mixed $default + * @param mixed $default * * @return \FireflyIII\Models\Configuration|null */ - public function get(string $name, $default = null): ?Configuration + public function get(string $name, $default = null): ?Configuration { $fullName = 'ff-config-' . $name; if (Cache::has($fullName)) { @@ -79,7 +79,7 @@ class FireflyConfig /** * @param string $name - * @param mixed $default + * @param mixed $default * * @return \FireflyIII\Models\Configuration|null */ diff --git a/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php b/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php index 22d1cd7983..6a801deccc 100644 --- a/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php +++ b/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php @@ -58,7 +58,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface $config = $this->repository->getConfiguration($this->importJob); $mapping = $config['mapping'] ?? []; $complete = \count($mapping) > 0; - if ($complete === true) { + if (true === $complete) { // move job to correct stage to download transactions $this->repository->setStage($this->importJob, 'go-for-import'); } @@ -79,12 +79,12 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface $config = $this->repository->getConfiguration($this->importJob); $accounts = $config['accounts'] ?? []; $mapping = $data['account_mapping'] ?? []; - $applyRules = (int)$data['apply_rules'] === 1; + $applyRules = 1 === (int)$data['apply_rules']; $final = []; - if (\count($accounts) === 0) { + if (0 === \count($accounts)) { throw new FireflyException('No bunq accounts found. Import cannot continue.'); // @codeCoverageIgnore } - if (\count($mapping) === 0) { + if (0 === \count($mapping)) { $messages = new MessageBag; $messages->add('nomap', (string)trans('import.bunq_no_mapping')); @@ -116,7 +116,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface { $config = $this->repository->getConfiguration($this->importJob); $accounts = $config['accounts'] ?? []; - if (\count($accounts) === 0) { + if (0 === \count($accounts)) { throw new FireflyException('No bunq accounts found. Import cannot continue.'); // @codeCoverageIgnore } // list the users accounts: diff --git a/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php index 5e4c6df1f2..4d16537a19 100644 --- a/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php +++ b/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php @@ -183,7 +183,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface { $canBeMapped = config('csv.import_roles.' . $name . '.mappable'); - return $canBeMapped === true && $requested === true; + return true === $canBeMapped && true === $requested; } /** @@ -247,7 +247,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface $collection = $this->repository->getAttachments($this->importJob); /** @var Attachment $attachment */ foreach ($collection as $attachment) { - if ($attachment->filename === 'import_file') { + if ('import_file' === $attachment->filename) { $content = $this->attachments->getAttachmentContent($attachment); break; } @@ -274,7 +274,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface */ public function getValuesForMapping(Reader $reader, array $config, array $columnConfig): array { - $offset = isset($config['has-headers']) && $config['has-headers'] === true ? 1 : 0; + $offset = isset($config['has-headers']) && true === $config['has-headers'] ? 1 : 0; try { $stmt = (new Statement)->offset($offset); // @codeCoverageIgnoreStart @@ -295,7 +295,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface continue; } $value = trim($line[$columnIndex]); - if (\strlen($value) === 0) { + if ('' === $value) { // value is empty, ignore it. continue; } @@ -309,7 +309,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface $columnConfig[$columnIndex]['values'] = array_unique($columnConfig[$columnIndex]['values']); asort($columnConfig[$columnIndex]['values']); // if the count of this array is zero, there is nothing to map. - if (\count($columnConfig[$columnIndex]['values']) === 0) { + if (0 === \count($columnConfig[$columnIndex]['values'])) { unset($columnConfig[$columnIndex]); } } diff --git a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php index e93af258cf..16a45137f9 100644 --- a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php +++ b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php @@ -76,10 +76,10 @@ class ConfigureRolesHandler implements FileConfigurationInterface if (\in_array($role, ['amount', 'amount_credit', 'amount_debit'])) { $hasAmount = true; } - if ($role === 'foreign-currency-code') { + if ('foreign-currency-code' === $role) { $hasForeignCode = true; } - if ($role === 'amount_foreign') { + if ('amount_foreign' === $role) { $hasForeignAmount = true; } } @@ -122,7 +122,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface $count = $config['column-count']; for ($i = 0; $i < $count; ++$i) { $role = $data['role'][$i] ?? '_ignore'; - $mapping = (isset($data['map'][$i]) && $data['map'][$i] === '1'); + $mapping = (isset($data['map'][$i]) && '1' === $data['map'][$i]); $config['column-roles'][$i] = $role; $config['column-do-mapping'][$i] = $mapping; Log::debug(sprintf('Column %d has been given role %s (mapping: %s)', $i, $role, var_export($mapping, true))); @@ -130,7 +130,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface $config = $this->ignoreUnmappableColumns($config); $messages = $this->configurationComplete($config); - if ($messages->count() === 0) { + if (0 === $messages->count()) { $this->repository->setStage($this->importJob, 'ready_to_run'); if ($this->isMappingNecessary($config)) { $this->repository->setStage($this->importJob, 'map'); @@ -175,7 +175,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface public function getExamplesFromFile(Reader $reader, array $config): void { $limit = (int)config('csv.example_rows', 5); - $offset = isset($config['has-headers']) && $config['has-headers'] === true ? 1 : 0; + $offset = isset($config['has-headers']) && true === $config['has-headers'] ? 1 : 0; // make statement. try { @@ -214,7 +214,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface public function getHeaders(Reader $reader, array $config): array { $headers = []; - if (isset($config['has-headers']) && $config['has-headers'] === true) { + if (isset($config['has-headers']) && true === $config['has-headers']) { try { $stmt = (new Statement)->limit(1)->offset(0); $records = $stmt->process($reader); @@ -273,7 +273,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface $collection = $this->repository->getAttachments($this->importJob); /** @var Attachment $attachment */ foreach ($collection as $attachment) { - if ($attachment->filename === 'import_file') { + if ('import_file' === $attachment->filename) { $content = $this->attachments->getAttachmentContent($attachment); break; } diff --git a/app/Support/Import/JobConfiguration/File/ConfigureUploadHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureUploadHandler.php index 7e521e527c..0c205ca4a2 100644 --- a/app/Support/Import/JobConfiguration/File/ConfigureUploadHandler.php +++ b/app/Support/Import/JobConfiguration/File/ConfigureUploadHandler.php @@ -57,10 +57,10 @@ class ConfigureUploadHandler implements FileConfigurationInterface // collect values: $importId = isset($data['csv_import_account']) ? (int)$data['csv_import_account'] : 0; $delimiter = (string)$data['csv_delimiter']; - $config['has-headers'] = (int)($data['has_headers'] ?? 0.0) === 1; + $config['has-headers'] = 1 === (int)($data['has_headers'] ?? 0.0); $config['date-format'] = (string)$data['date_format']; $config['delimiter'] = 'tab' === $delimiter ? "\t" : $delimiter; - $config['apply-rules'] = (int)($data['apply_rules'] ?? 0.0) === 1; + $config['apply-rules'] = 1 === (int)($data['apply_rules'] ?? 0.0); $config['specifics'] = $this->getSpecifics($data); // validate values: $account = $this->accountRepos->findNull($importId); diff --git a/app/Support/Import/JobConfiguration/File/NewFileJobHandler.php b/app/Support/Import/JobConfiguration/File/NewFileJobHandler.php index 34f79e92c9..047f8c5d39 100644 --- a/app/Support/Import/JobConfiguration/File/NewFileJobHandler.php +++ b/app/Support/Import/JobConfiguration/File/NewFileJobHandler.php @@ -123,7 +123,7 @@ class NewFileJobHandler implements FileConfigurationInterface /** @var Attachment $attachment */ foreach ($attachments as $attachment) { // if file is configuration file, store it into the job. - if ($attachment->filename === 'configuration_file') { + if ('configuration_file' === $attachment->filename) { $this->storeConfig($attachment); } } @@ -162,7 +162,7 @@ class NewFileJobHandler implements FileConfigurationInterface } // if file is configuration file, store it into the job. - if ($attachment->filename === 'configuration_file') { + if ('configuration_file' === $attachment->filename) { $this->storeConfig($attachment); } } @@ -179,10 +179,10 @@ class NewFileJobHandler implements FileConfigurationInterface { $content = $this->attachments->getAttachmentContent($attachment); $result = mb_detect_encoding($content, 'UTF-8', true); - if ($result === false) { + if (false === $result) { return false; } - if ($result !== 'ASCII' && $result !== 'UTF-8') { + if ('ASCII' !== $result && 'UTF-8' !== $result) { return false; // @codeCoverageIgnore } @@ -194,7 +194,6 @@ class NewFileJobHandler implements FileConfigurationInterface * * @param Attachment $attachment * - * @throws FireflyException */ private function storeConfig(Attachment $attachment): void { diff --git a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php index f1ccd1b25b..8f42ac6ea0 100644 --- a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php +++ b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php @@ -98,7 +98,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface $config['account_mapping'] = $final; $config['apply-rules'] = $applyRules; $this->repository->setConfiguration($this->importJob, $config); - if ($final === [0 => 0] || \count($final) === 0) { + if ($final === [0 => 0] || 0 === \count($final)) { $messages->add('count', (string)trans('import.spectre_no_mapping')); } @@ -116,7 +116,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface Log::debug('Now in ChooseAccountsHandler::getnextData()'); $config = $this->importJob->configuration; $accounts = $config['accounts'] ?? []; - if (\count($accounts) === 0) { + if (0 === \count($accounts)) { throw new FireflyException('It seems you have no accounts with this bank. The import cannot continue.'); // @codeCoverageIgnore } $converted = []; @@ -128,15 +128,15 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface $login = null; $logins = $config['all-logins'] ?? []; $selected = $config['selected-login'] ?? 0; - if (\count($logins) === 0) { + if (0 === \count($logins)) { throw new FireflyException('It seems you have no configured logins in this import job. The import cannot continue.'); // @codeCoverageIgnore } Log::debug(sprintf('Selected login to use is %d', $selected)); - if ($selected === 0) { + if (0 === $selected) { $login = new Login($logins[0]); Log::debug(sprintf('Will use login %d (%s %s)', $login->getId(), $login->getProviderName(), $login->getCountryCode())); } - if ($selected !== 0) { + if (0 !== $selected) { foreach ($logins as $loginArray) { $loginId = $loginArray['id'] ?? -1; if ($loginId === $selected) { diff --git a/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php b/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php index d2d2027538..39b6e5b565 100644 --- a/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php +++ b/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php @@ -82,7 +82,7 @@ class ChooseLoginHandler implements SpectreJobConfigurationInterface Log::debug(sprintf('The selected login by the user is #%d', $selectedLogin)); // if selected login is zero, create a new one. - if ($selectedLogin === 0) { + if (0 === $selectedLogin) { Log::debug('Login is zero, get Spectre customer + token and store it in config.'); $customer = $this->getCustomer($this->importJob); // get a token for the user and redirect to next stage diff --git a/app/Support/Import/Placeholder/ImportTransaction.php b/app/Support/Import/Placeholder/ImportTransaction.php index 6a2344fed9..c97f3f8f7e 100644 --- a/app/Support/Import/Placeholder/ImportTransaction.php +++ b/app/Support/Import/Placeholder/ImportTransaction.php @@ -226,7 +226,6 @@ class ImportTransaction * Calculate the amount of this transaction. * * @return string - * @throws FireflyException */ public function calculateAmount(): string { @@ -258,7 +257,7 @@ class ImportTransaction if ($conversion === -1) { $result = app('steam')->negative($result); } - if ($conversion === 1) { + if (1 === $conversion) { $result = app('steam')->positive($result); } Log::debug(sprintf('convertedAmount after conversion is %s', $result)); @@ -301,7 +300,7 @@ class ImportTransaction if ($conversion === -1) { $result = app('steam')->negative($result); } - if ($conversion === 1) { + if (1 === $conversion) { $result = app('steam')->positive($result); } Log::debug(sprintf('Foreign amount after conversion is %s', $result)); diff --git a/app/Support/Import/Routine/Bunq/StageImportDataHandler.php b/app/Support/Import/Routine/Bunq/StageImportDataHandler.php index 102135f87f..f0067b57dd 100644 --- a/app/Support/Import/Routine/Bunq/StageImportDataHandler.php +++ b/app/Support/Import/Routine/Bunq/StageImportDataHandler.php @@ -80,7 +80,7 @@ class StageImportDataHandler $bunqAccountId = $bunqAccount['id'] ?? 0; $localId = $mapping[$bunqAccountId] ?? 0; Log::debug(sprintf('Looping accounts, now at bunq account #%d and local account #%d', $bunqAccountId, $localId)); - if ($localId !== 0 && $bunqAccountId !== 0) { + if (0 !== $localId && 0 !== $bunqAccountId) { $localAccount = $this->getLocalAccount((int)$localId); $collection[] = $this->getTransactionsFromBunq($bunqAccountId, $localAccount); } @@ -122,7 +122,7 @@ class StageImportDataHandler Log::debug(sprintf('Amount is %s %s', $amount->getCurrency(), $amount->getValue())); $expected = AccountType::EXPENSE; - if (bccomp($amount->getValue(), '0') === 1) { + if (1 === bccomp($amount->getValue(), '0')) { // amount + means that its a deposit. $expected = AccountType::REVENUE; $type = TransactionType::DEPOSIT; @@ -131,7 +131,7 @@ class StageImportDataHandler $destination = $this->convertToAccount($counterParty, $expected); // switch source and destination if necessary. - if (bccomp($amount->getValue(), '0') === 1) { + if (1 === bccomp($amount->getValue(), '0')) { Log::debug('Will make it a deposit.'); [$source, $destination] = [$destination, $source]; } @@ -187,11 +187,12 @@ class StageImportDataHandler * @param string $expectedType * * @return LocalAccount + * @throws FireflyException */ private function convertToAccount(LabelMonetaryAccount $party, string $expectedType): LocalAccount { Log::debug('in convertToAccount()'); - if ($party->getIban() !== null) { + if (null !== $party->getIban()) { // find opposing party by IBAN first. $result = $this->accountRepository->findByIbanNull($party->getIban(), [$expectedType]); if (null !== $result) { diff --git a/app/Support/Import/Routine/Fake/StageAhoyHandler.php b/app/Support/Import/Routine/Fake/StageAhoyHandler.php index 8c4bb211c0..b7084e0423 100644 --- a/app/Support/Import/Routine/Fake/StageAhoyHandler.php +++ b/app/Support/Import/Routine/Fake/StageAhoyHandler.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Support\Import\Routine\Fake; -use FireflyIII\Exceptions\FireflyException; use Log; /** @@ -33,7 +32,6 @@ use Log; class StageAhoyHandler { /** - * @throws FireflyException */ public function run(): void { diff --git a/app/Support/Import/Routine/Fake/StageNewHandler.php b/app/Support/Import/Routine/Fake/StageNewHandler.php index 2c0f7cdd3c..111378042a 100644 --- a/app/Support/Import/Routine/Fake/StageNewHandler.php +++ b/app/Support/Import/Routine/Fake/StageNewHandler.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Support\Import\Routine\Fake; -use FireflyIII\Exceptions\FireflyException; use Log; /** @@ -33,7 +32,6 @@ use Log; class StageNewHandler { /** - * @throws FireflyException */ public function run(): void { diff --git a/app/Support/Import/Routine/File/ImportableConverter.php b/app/Support/Import/Routine/File/ImportableConverter.php index e0ec2ba022..17fcfe2b46 100644 --- a/app/Support/Import/Routine/File/ImportableConverter.php +++ b/app/Support/Import/Routine/File/ImportableConverter.php @@ -205,7 +205,7 @@ class ImportableConverter $transactionType = $this->getTransactionType($source->accountType->type, $destination->accountType->type); $currency = $currency ?? $this->getCurrency($source, $destination); - if ($transactionType === 'unknown') { + if ('unknown' === $transactionType) { $message = sprintf( 'Cannot determine transaction type. Source account is a %s, destination is a %s', $source->accountType->type, $destination->accountType->type ); @@ -282,14 +282,14 @@ class ImportableConverter if ($destination->accountType->type === AccountType::ASSET) { // destination is asset, might have currency preference: $destinationCurrencyId = (int)$this->accountRepository->getMetaValue($destination, 'currency_id'); - $currency = $destinationCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($destinationCurrencyId, []); + $currency = 0 === $destinationCurrencyId ? $this->defaultCurrency : $this->currencyMapper->map($destinationCurrencyId, []); Log::debug(sprintf('Destination is an asset account, and has currency preference %s', $currency->code)); } if ($source->accountType->type === AccountType::ASSET) { // source is asset, might have currency preference: $sourceCurrencyId = (int)$this->accountRepository->getMetaValue($source, 'currency_id'); - $currency = $sourceCurrencyId === 0 ? $this->defaultCurrency : $this->currencyMapper->map($sourceCurrencyId, []); + $currency = 0 === $sourceCurrencyId ? $this->defaultCurrency : $this->currencyMapper->map($sourceCurrencyId, []); Log::debug(sprintf('Source is an asset account, and has currency preference %s', $currency->code)); } if (null === $currency) { diff --git a/app/Support/Import/Routine/File/LineReader.php b/app/Support/Import/Routine/File/LineReader.php index 2391ff8af0..0953ec1ad8 100644 --- a/app/Support/Import/Routine/File/LineReader.php +++ b/app/Support/Import/Routine/File/LineReader.php @@ -123,7 +123,7 @@ class LineReader /** @var array $config */ $config = $this->importJob->configuration; Log::debug('now in getLines()'); - $offset = isset($config['has-headers']) && $config['has-headers'] === true ? 1 : 0; + $offset = isset($config['has-headers']) && true === $config['has-headers'] ? 1 : 0; try { $stmt = (new Statement)->offset($offset); // @codeCoverageIgnoreStart @@ -151,7 +151,7 @@ class LineReader $collection = $this->repository->getAttachments($this->importJob); /** @var Attachment $attachment */ foreach ($collection as $attachment) { - if ($attachment->filename === 'import_file') { + if ('import_file' === $attachment->filename) { $content = $this->attachments->getAttachmentContent($attachment); break; } diff --git a/app/Support/Import/Routine/File/MappingConverger.php b/app/Support/Import/Routine/File/MappingConverger.php index e2768ae8f2..57d70522ad 100644 --- a/app/Support/Import/Routine/File/MappingConverger.php +++ b/app/Support/Import/Routine/File/MappingConverger.php @@ -195,7 +195,7 @@ class MappingConverger $value = trim($value); $originalRole = $this->roles[$columnIndex] ?? '_ignore'; Log::debug(sprintf('Now at column #%d (%s), value "%s"', $columnIndex, $originalRole, $value)); - if ($originalRole !== '_ignore' && \strlen($value) > 0) { + if ('_ignore' !== $originalRole && \strlen($value) > 0) { // is a mapped value present? $mapped = $this->mapping[$columnIndex][$value] ?? 0; diff --git a/app/Support/Import/Routine/File/OpposingAccountMapper.php b/app/Support/Import/Routine/File/OpposingAccountMapper.php index da1b6b9fa0..5f67428d7e 100644 --- a/app/Support/Import/Routine/File/OpposingAccountMapper.php +++ b/app/Support/Import/Routine/File/OpposingAccountMapper.php @@ -53,7 +53,7 @@ class OpposingAccountMapper $expectedType = AccountType::EXPENSE; $result = null; Log::debug(sprintf('Going to search for accounts of type %s', $expectedType)); - if (bccomp($amount, '0') === 1) { + if (1 === bccomp($amount, '0')) { // more than zero. $expectedType = AccountType::REVENUE; Log::debug(sprintf('Because amount is %s, will instead search for accounts of type %s', $amount, $expectedType)); diff --git a/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php b/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php index b247a230e0..c4b08e7af1 100644 --- a/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php +++ b/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php @@ -57,7 +57,7 @@ class StageAuthenticatedHandler $config = $this->importJob->configuration; $logins = $config['all-logins'] ?? []; Log::debug(sprintf('%d logins in config', \count($logins))); - if (\count($logins) === 0) { + if (0 === \count($logins)) { // get logins from Spectre. $logins = $this->getLogins(); $config['all-logins'] = $logins; diff --git a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php index 4f2eff2872..789aa6c664 100644 --- a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php +++ b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php @@ -60,7 +60,7 @@ class StageImportDataHandler $config = $this->importJob->configuration; $accounts = $config['accounts'] ?? []; Log::debug(sprintf('Count of accounts in array is %d', \count($accounts))); - if (\count($accounts) === 0) { + if (0 === \count($accounts)) { throw new FireflyException('There are no accounts in this import job. Cannot continue.'); // @codeCoverageIgnore } $toImport = $config['account_mapping'] ?? []; @@ -124,14 +124,14 @@ class StageImportDataHandler $amount = $transaction->getAmount(); $source = $originalSource; $destination = $this->mapper->map(null, $amount, $destinationData); - $notes = (string)trans('import.imported_from_account', ['account' => $spectreAccount->getName()]) . ' ' . "\n"; + $notes = trans('import.imported_from_account', ['account' => $spectreAccount->getName()]) . ' ' . "\n"; $foreignAmount = null; $foreignCurrencyCode = null; $currencyCode = $transaction->getCurrencyCode(); $type = 'withdrawal'; // switch source and destination if amount is greater than zero. - if (bccomp($amount, '0') === 1) { + if (1 === bccomp($amount, '0')) { [$source, $destination] = [$destination, $source]; $type = 'deposit'; } diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 3e1fc6b818..a539793d17 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -73,7 +73,7 @@ class Navigation // if period is 1M and diff in month is 2 and new DOM = 1, sub a day: $months = ['1M', 'month', 'monthly']; $difference = $date->month - $theDate->month; - if (\in_array($repeatFreq, $months) && 2 === $difference && 1 === $date->day) { + if (2 === $difference && 1 === $date->day && \in_array($repeatFreq, $months, true)) { $date->subDay(); } @@ -199,14 +199,14 @@ class Navigation if (isset($modifierMap[$repeatFreq])) { $currentEnd->$function($modifierMap[$repeatFreq]); - if (\in_array($repeatFreq, $subDay)) { + if (\in_array($repeatFreq, $subDay, true)) { $currentEnd->subDay(); } return $currentEnd; } $currentEnd->$function(); - if (\in_array($repeatFreq, $subDay)) { + if (\in_array($repeatFreq, $subDay, true)) { $currentEnd->subDay(); } diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 69a4a41e8a..a27ab81001 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -62,6 +62,7 @@ class Preferences try { Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete(); } catch (Exception $e) { + Log::debug(sprintf('Not interesting: %s', $e->getMessage())); // don't care. } @@ -80,7 +81,7 @@ class Preferences /** * @param string $name - * @param mixed $default + * @param mixed $default * * @return \FireflyIII\Models\Preference|null */ @@ -137,7 +138,7 @@ class Preferences try { $preference->delete(); } catch (Exception $e) { - Log::debug(sprintf('Could not delete preference #%d', $preference->id)); + Log::debug(sprintf('Could not delete preference #%d: %s', $preference->id, $e->getMessage())); } $preference = null; } diff --git a/app/Support/Search/Modifier.php b/app/Support/Search/Modifier.php index 56a3a13755..5b6972c46b 100644 --- a/app/Support/Search/Modifier.php +++ b/app/Support/Search/Modifier.php @@ -101,6 +101,8 @@ class Modifier try { $compareDate = new Carbon($compare); } catch (Exception $e) { + Log::debug(sprintf('Not interesting: %s', $e->getMessage())); + return false; } @@ -118,6 +120,8 @@ class Modifier try { $compareDate = new Carbon($compare); } catch (Exception $e) { + Log::debug(sprintf('Not interesting: %s', $e->getMessage())); + return false; } @@ -135,6 +139,8 @@ class Modifier try { $compareDate = new Carbon($compare); } catch (Exception $e) { + Log::debug(sprintf('Not interesting: %s', $e->getMessage())); + return false; } diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index d8e6b72c0c..ff47407573 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -63,7 +63,7 @@ class Search implements SearchInterface public function getWordsAsString(): string { $string = implode(' ', $this->words); - if (0 === \strlen($string)) { + if ('' === $string) { return \is_string($this->originalQuery) ? $this->originalQuery : ''; } @@ -81,7 +81,7 @@ class Search implements SearchInterface /** * @param string $query */ - public function parseQuery(string $query) + public function parseQuery(string $query): void { $filteredQuery = $query; $this->originalQuery = $query; @@ -171,7 +171,7 @@ class Search implements SearchInterface /** * @param int $limit */ - public function setLimit(int $limit) + public function setLimit(int $limit): void { $this->limit = $limit; } @@ -179,7 +179,7 @@ class Search implements SearchInterface /** * @param User $user */ - public function setUser(User $user) + public function setUser(User $user): void { $this->user = $user; } @@ -242,13 +242,13 @@ class Search implements SearchInterface /** * @param string $string */ - private function extractModifier(string $string) + private function extractModifier(string $string): void { $parts = explode(':', $string); - if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && \strlen(trim((string)$parts[1]))) { + if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && '' !== trim((string)$parts[1])) { $type = trim((string)$parts[0]); $value = trim((string)$parts[1]); - if (\in_array($type, $this->validModifiers)) { + if (\in_array($type, $this->validModifiers, true)) { // filter for valid type $this->modifiers->push(['type' => $type, 'value' => $value]); } @@ -292,9 +292,9 @@ class Search implements SearchInterface * * @return bool */ - private function strposArray(string $haystack, array $needle) + private function strposArray(string $haystack, array $needle): bool { - if (0 === \strlen($haystack)) { + if ('' === $haystack) { return false; } foreach ($needle as $what) { diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 42df4918af..3256f37f0a 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -30,6 +30,7 @@ use FireflyIII\Models\Transaction; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Support\Collection; +use Log; /** * Class Steam. @@ -249,7 +250,7 @@ class Steam * @return string * @throws \Illuminate\Contracts\Encryption\DecryptException */ - public function decrypt(int $isEncrypted, string $value) + public function decrypt(int $isEncrypted, string $value): string { if (1 === $isEncrypted) { return Crypt::decrypt($value); @@ -366,6 +367,7 @@ class Steam $value = Crypt::decrypt($value); } catch (DecryptException $e) { // do not care. + Log::debug(sprintf('Not interesting: %s', $e->getMessage())); } return $value; diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php index 7cc70d7dd4..52a7554885 100644 --- a/app/Support/Twig/AmountFormat.php +++ b/app/Support/Twig/AmountFormat.php @@ -83,7 +83,8 @@ class AmountFormat extends Twig_Extension { return new Twig_SimpleFunction( 'formatAmountByAccount', - function (AccountModel $account, string $amount, bool $coloured = true): string { + function (AccountModel $account, string $amount, bool $coloured = null): string { + $coloured = $coloured ?? true; /** @var AccountRepositoryInterface $accountRepos */ $accountRepos = app(AccountRepositoryInterface::class); /** @var CurrencyRepositoryInterface $currencyRepos */ @@ -113,7 +114,9 @@ class AmountFormat extends Twig_Extension { return new Twig_SimpleFunction( 'formatAmountByCurrency', - function (TransactionCurrency $currency, string $amount, bool $coloured = true): string { + function (TransactionCurrency $currency, string $amount, bool $coloured = null): string { + $coloured = $coloured ?? true; + return app('amount')->formatAnything($currency, $amount, $coloured); }, ['is_safe' => ['html']] @@ -129,7 +132,9 @@ class AmountFormat extends Twig_Extension { return new Twig_SimpleFunction( 'formatAmountBySymbol', - function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string { + function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string { + $decimalPlaces = $decimalPlaces ?? 2; + $coloured = $coloured ?? true; $currency = new TransactionCurrency; $currency->symbol = $symbol; $currency->decimal_places = $decimalPlaces; diff --git a/app/Support/Twig/Extension/Transaction.php b/app/Support/Twig/Extension/Transaction.php index 2eda973b52..327c7af1d6 100644 --- a/app/Support/Twig/Extension/Transaction.php +++ b/app/Support/Twig/Extension/Transaction.php @@ -136,12 +136,12 @@ class Transaction extends Twig_Extension } // transaction has a budget - if (null !== $transaction->transaction_budget_id && $txt === '') { + if (null !== $transaction->transaction_budget_id && '' === $txt) { $name = app('steam')->tryDecrypt($transaction->transaction_budget_name); $txt = sprintf('%s', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name); } - if ($txt === '') { + if ('' === $txt) { // see if the transaction has a budget: $budgets = $transaction->budgets()->get(); if (0 === $budgets->count()) { @@ -174,12 +174,12 @@ class Transaction extends Twig_Extension } // transaction has a category: - if (null !== $transaction->transaction_category_id && $txt === '') { + if (null !== $transaction->transaction_category_id && '' === $txt) { $name = app('steam')->tryDecrypt($transaction->transaction_category_name); $txt = sprintf('%s', route('categories.show', [$transaction->transaction_category_id]), $name, $name); } - if ($txt === '') { + if ('' === $txt) { // see if the transaction has a category: $categories = $transaction->categories()->get(); if (0 === $categories->count()) { @@ -229,14 +229,14 @@ class Transaction extends Twig_Extension $type = $transaction->account_type; // name is present in object, use that one: - if (bccomp($transaction->transaction_amount, '0') === -1 && null !== $transaction->opposing_account_id) { + if (null !== $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) { $name = $transaction->opposing_account_name; $transactionId = (int)$transaction->opposing_account_id; $type = $transaction->opposing_account_type; } // Find the opposing account and use that one: - if (bccomp($transaction->transaction_amount, '0') === -1 && null === $transaction->opposing_account_id) { + if (null === $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) { // if the amount is negative, find the opposing account and use that one: $journalId = $transaction->journal_id; /** @var TransactionModel $other */ @@ -259,7 +259,7 @@ class Transaction extends Twig_Extension } if (AccountType::CASH === $type) { - $txt = '(' . (string)trans('firefly.cash') . ')'; + $txt = '(' . trans('firefly.cash') . ')'; return $txt; } @@ -285,7 +285,7 @@ class Transaction extends Twig_Extension ) ); } - if ($transaction->attachmentCount === null) { + if (null === $transaction->attachmentCount) { $journalId = (int)$transaction->journal_id; $count = Attachment::whereNull('deleted_at') ->where('attachable_type', TransactionJournal::class) @@ -355,11 +355,11 @@ class Transaction extends Twig_Extension public function isSplit(TransactionModel $transaction): string { $res = ''; - if ($transaction->is_split === true) { + if (true === $transaction->is_split) { $res = ''; } - if ($transaction->is_split === null) { + if (null === $transaction->is_split) { $journalId = (int)$transaction->journal_id; $count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count(); if ($count > 2) { @@ -387,13 +387,13 @@ class Transaction extends Twig_Extension $type = $transaction->account_type; // name is present in object, use that one: - if (1 === bccomp($transaction->transaction_amount, '0') && null !== $transaction->opposing_account_id) { + if (null !== $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) { $name = $transaction->opposing_account_name; $transactionId = (int)$transaction->opposing_account_id; $type = $transaction->opposing_account_type; } // Find the opposing account and use that one: - if (1 === bccomp($transaction->transaction_amount, '0') && null === $transaction->opposing_account_id) { + if (null === $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) { $journalId = $transaction->journal_id; /** @var TransactionModel $other */ $other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id) @@ -410,7 +410,7 @@ class Transaction extends Twig_Extension } if (AccountType::CASH === $type) { - $txt = '(' . (string)trans('firefly.cash') . ')'; + $txt = '(' . trans('firefly.cash') . ')'; return $txt; } diff --git a/app/Support/Twig/Extension/TransactionJournal.php b/app/Support/Twig/Extension/TransactionJournal.php index 5e4ec2b1a2..32bfa25f3a 100644 --- a/app/Support/Twig/Extension/TransactionJournal.php +++ b/app/Support/Twig/Extension/TransactionJournal.php @@ -83,7 +83,7 @@ class TransactionJournal extends Twig_Extension if (null === $result) { return false; } - if (\strlen((string)$result) === 0) { + if ('' === (string)$result) { return false; } diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index d7e3d16355..633de8f1c3 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -174,7 +174,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFunction */ - protected function formatDate() + protected function formatDate(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'formatDate', @@ -330,7 +330,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFunction */ - protected function phpdate() + protected function phpdate(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'phpdate', diff --git a/app/Support/Twig/Rule.php b/app/Support/Twig/Rule.php index 72d531796c..83a403bc0f 100644 --- a/app/Support/Twig/Rule.php +++ b/app/Support/Twig/Rule.php @@ -45,7 +45,7 @@ class Rule extends Twig_Extension foreach ($ruleActions as $key) { $possibleActions[$key] = (string)trans('firefly.rule_action_' . $key . '_choice'); } - unset($key, $ruleActions); + unset($ruleActions); asort($possibleActions); return $possibleActions; @@ -84,7 +84,7 @@ class Rule extends Twig_Extension $possibleTriggers[$key] = (string)trans('firefly.rule_trigger_' . $key . '_choice'); } } - unset($key, $ruleTriggers); + unset($ruleTriggers); asort($possibleTriggers); return $possibleTriggers;