Code cleanup

This commit is contained in:
James Cole
2018-04-28 06:23:13 +02:00
parent 6f0e1c79ac
commit 13b78bdc20
218 changed files with 621 additions and 681 deletions

View File

@@ -48,18 +48,9 @@ class Controller extends BaseController
/** /**
* Controller constructor. * Controller constructor.
* *
* @throws FireflyException
*/ */
public function __construct() public function __construct()
{ {
// is site a demo site?
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
// do not expose API on demo site:
if (true === $isDemoSite) {
//throw new FireflyException('The API is not available on the demo site.');
}
// get global parameters // get global parameters
$this->parameters = $this->getParameters(); $this->parameters = $this->getParameters();
} }
@@ -83,7 +74,7 @@ class Controller extends BaseController
} }
} }
$return .= http_build_query($params); $return .= http_build_query($params);
if (strlen($return) === 1) { if (\strlen($return) === 1) {
return ''; return '';
} }

View File

@@ -111,7 +111,7 @@ class TransactionController extends Controller
$collector->setAllAssetAccounts(); $collector->setAllAssetAccounts();
// remove internal transfer filter: // remove internal transfer filter:
if (in_array(TransactionType::TRANSFER, $types)) { if (\in_array(TransactionType::TRANSFER, $types)) {
$collector->removeFilter(InternalTransferFilter::class); $collector->removeFilter(InternalTransferFilter::class);
} }

View File

@@ -168,7 +168,6 @@ class TransactionRequest extends Request
* @param Validator $validator * @param Validator $validator
* *
* @return void * @return void
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function withValidator(Validator $validator): void public function withValidator(Validator $validator): void
{ {
@@ -202,7 +201,7 @@ class TransactionRequest extends Request
$accountId = (int)$accountId; $accountId = (int)$accountId;
$accountName = (string)$accountName; $accountName = (string)$accountName;
// both empty? hard exit. // both empty? hard exit.
if ($accountId < 1 && strlen($accountName) === 0) { if ($accountId < 1 && \strlen($accountName) === 0) {
$validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField])); $validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField]));
return null; return null;
@@ -245,7 +244,7 @@ class TransactionRequest extends Request
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
// need at least one transaction // need at least one transaction
if (count($transactions) === 0) { if (\count($transactions) === 0) {
$validator->errors()->add('description', trans('validation.at_least_one_transaction')); $validator->errors()->add('description', trans('validation.at_least_one_transaction'));
} }
} }
@@ -263,13 +262,13 @@ class TransactionRequest extends Request
$journalDescription = (string)($data['description'] ?? ''); $journalDescription = (string)($data['description'] ?? '');
$validDescriptions = 0; $validDescriptions = 0;
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
if (strlen((string)($transaction['description'] ?? '')) > 0) { if (\strlen((string)($transaction['description'] ?? '')) > 0) {
$validDescriptions++; $validDescriptions++;
} }
} }
// no valid descriptions and empty journal description? error. // no valid descriptions and empty journal description? error.
if ($validDescriptions === 0 && strlen($journalDescription) === 0) { if ($validDescriptions === 0 && \strlen($journalDescription) === 0) {
$validator->errors()->add('description', trans('validation.filled', ['attribute' => trans('validation.attributes.description')])); $validator->errors()->add('description', trans('validation.filled', ['attribute' => trans('validation.attributes.description')]));
} }
@@ -288,7 +287,7 @@ class TransactionRequest extends Request
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$description = (string)($transaction['description'] ?? ''); $description = (string)($transaction['description'] ?? '');
// filled description is mandatory for split transactions. // filled description is mandatory for split transactions.
if (count($transactions) > 1 && strlen($description) === 0) { if (\count($transactions) > 1 && \strlen($description) === 0) {
$validator->errors()->add( $validator->errors()->add(
'transactions.' . $index . '.description', 'transactions.' . $index . '.description',
trans('validation.filled', ['attribute' => trans('validation.attributes.transaction_description')]) trans('validation.filled', ['attribute' => trans('validation.attributes.transaction_description')])
@@ -355,7 +354,7 @@ class TransactionRequest extends Request
$accountId = (int)$accountId; $accountId = (int)$accountId;
$accountName = (string)$accountName; $accountName = (string)$accountName;
// both empty? done! // both empty? done!
if ($accountId < 1 && strlen($accountName) === 0) { if ($accountId < 1 && \strlen($accountName) === 0) {
return null; return null;
} }
if ($accountId !== 0) { if ($accountId !== 0) {
@@ -457,7 +456,7 @@ class TransactionRequest extends Request
protected function validateSplitAccounts(Validator $validator) protected function validateSplitAccounts(Validator $validator)
{ {
$data = $validator->getData(); $data = $validator->getData();
$count = isset($data['transactions']) ? count($data['transactions']) : 0; $count = isset($data['transactions']) ? \count($data['transactions']) : 0;
if ($count < 2) { if ($count < 2) {
return; return;
} }
@@ -487,17 +486,17 @@ class TransactionRequest extends Request
// switch on type: // switch on type:
switch ($data['type']) { switch ($data['type']) {
case 'withdrawal': case 'withdrawal':
if (count($sources) > 1) { if (\count($sources) > 1) {
$validator->errors()->add('transactions.0.source_id', trans('validation.all_accounts_equal')); $validator->errors()->add('transactions.0.source_id', trans('validation.all_accounts_equal'));
} }
break; break;
case 'deposit': case 'deposit':
if (count($destinations) > 1) { if (\count($destinations) > 1) {
$validator->errors()->add('transactions.0.destination_id', trans('validation.all_accounts_equal')); $validator->errors()->add('transactions.0.destination_id', trans('validation.all_accounts_equal'));
} }
break; break;
case 'transfer': case 'transfer':
if (count($sources) > 1 || count($destinations) > 1) { if (\count($sources) > 1 || \count($destinations) > 1) {
$validator->errors()->add('transactions.0.source_id', trans('validation.all_accounts_equal')); $validator->errors()->add('transactions.0.source_id', trans('validation.all_accounts_equal'));
$validator->errors()->add('transactions.0.destination_id', trans('validation.all_accounts_equal')); $validator->errors()->add('transactions.0.destination_id', trans('validation.all_accounts_equal'));
} }

View File

@@ -89,9 +89,9 @@ class CreateExport extends Command
$accountRepository->setUser($user); $accountRepository->setUser($user);
// first date // first date
$firstJournal = $journalRepository->first(); $firstJournal = $journalRepository->firstNull();
$first = new Carbon; $first = new Carbon;
if (null !== $firstJournal->id) { if (null !== $firstJournal) {
$first = $firstJournal->date; $first = $firstJournal->date;
} }

View File

@@ -100,6 +100,5 @@ class DecryptAttachment extends Command
} }
$this->info(sprintf('%d bytes written. Exiting now..', $result)); $this->info(sprintf('%d bytes written. Exiting now..', $result));
return;
} }
} }

View File

@@ -93,7 +93,6 @@ class Import extends Command
sprintf('The import has finished. %d transactions have been imported out of %d records.', $routine->getJournals()->count(), $routine->getLines()) sprintf('The import has finished. %d transactions have been imported out of %d records.', $routine->getJournals()->count(), $routine->getLines())
); );
return;
} }
/** /**

View File

@@ -106,7 +106,7 @@ class UpgradeDatabase extends Command
if ($ruleGroup === null) { if ($ruleGroup === null) {
$array = RuleGroup::get(['order'])->pluck('order')->toArray(); $array = RuleGroup::get(['order'])->pluck('order')->toArray();
$order = count($array) > 0 ? max($array) + 1 : 1; $order = \count($array) > 0 ? max($array) + 1 : 1;
$ruleGroup = RuleGroup::create( $ruleGroup = RuleGroup::create(
[ [
'user_id' => $user->id, 'user_id' => $user->id,
@@ -240,7 +240,6 @@ class UpgradeDatabase extends Command
$this->updateJournalidentifiers((int)$journalId); $this->updateJournalidentifiers((int)$journalId);
} }
return;
} }
/** /**
@@ -294,7 +293,6 @@ class UpgradeDatabase extends Command
} }
); );
return;
} }
/** /**
@@ -352,7 +350,6 @@ class UpgradeDatabase extends Command
} }
); );
return;
} }
/** /**
@@ -413,7 +410,7 @@ class UpgradeDatabase extends Command
// move description: // move description:
$description = (string)$att->description; $description = (string)$att->description;
if (strlen($description) > 0) { if (\strlen($description) > 0) {
// find or create note: // find or create note:
$note = $att->notes()->first(); $note = $att->notes()->first();
if (null === $note) { if (null === $note) {
@@ -484,7 +481,6 @@ class UpgradeDatabase extends Command
$journal->save(); $journal->save();
} }
return;
} }
/** /**
@@ -530,7 +526,6 @@ class UpgradeDatabase extends Command
++$identifier; ++$identifier;
} }
return;
} }
/** /**
@@ -663,7 +658,6 @@ class UpgradeDatabase extends Command
$opposing->save(); $opposing->save();
} }
return;
} }
} }

View File

@@ -92,7 +92,7 @@ class UpgradeFireflyInstructions extends Command
$text = ''; $text = '';
foreach (array_keys($config) as $compare) { foreach (array_keys($config) as $compare) {
// if string starts with: // if string starts with:
$len = strlen($compare); $len = \strlen($compare);
if (substr($version, 0, $len) === $compare) { if (substr($version, 0, $len) === $compare) {
$text = $config[$compare]; $text = $config[$compare];
} }
@@ -139,7 +139,7 @@ class UpgradeFireflyInstructions extends Command
$text = ''; $text = '';
foreach (array_keys($config) as $compare) { foreach (array_keys($config) as $compare) {
// if string starts with: // if string starts with:
$len = strlen($compare); $len = \strlen($compare);
if (substr($version, 0, $len) === $compare) { if (substr($version, 0, $len) === $compare) {
$text = $config[$compare]; $text = $config[$compare];
} }

View File

@@ -85,7 +85,7 @@ class Handler extends ExceptionHandler
return response()->json( return response()->json(
[ [
'message' => $exception->getMessage(), 'message' => $exception->getMessage(),
'exception' => get_class($exception), 'exception' => \get_class($exception),
'line' => $exception->getLine(), 'line' => $exception->getLine(),
'file' => $exception->getFile(), 'file' => $exception->getFile(),
'trace' => $exception->getTrace(), 'trace' => $exception->getTrace(),
@@ -93,7 +93,7 @@ class Handler extends ExceptionHandler
); );
} }
return response()->json(['message' => 'Internal Firefly III Exception. See log files.', 'exception' => get_class($exception)], 500); return response()->json(['message' => 'Internal Firefly III Exception. See log files.', 'exception' => \get_class($exception)], 500);
} }
if ($exception instanceof FireflyException || $exception instanceof ErrorException) { if ($exception instanceof FireflyException || $exception instanceof ErrorException) {
@@ -131,7 +131,7 @@ class Handler extends ExceptionHandler
$userData['email'] = auth()->user()->email; $userData['email'] = auth()->user()->email;
} }
$data = [ $data = [
'class' => get_class($exception), 'class' => \get_class($exception),
'errorMessage' => $exception->getMessage(), 'errorMessage' => $exception->getMessage(),
'time' => date('r'), 'time' => date('r'),
'stackTrace' => $exception->getTraceAsString(), 'stackTrace' => $exception->getTraceAsString(),

View File

@@ -97,14 +97,16 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
$file = $attachment->fileName(); $file = $attachment->fileName();
if ($this->uploadDisk->exists($file)) { if ($this->uploadDisk->exists($file)) {
try { try {
$decrypted = Crypt::decrypt($this->uploadDisk->get($file)); $decrypted = Crypt::decrypt($this->uploadDisk->get($file));
$exportFile = $this->exportFileName($attachment);
$this->exportDisk->put($exportFile, $decrypted);
$this->getEntries()->push($exportFile);
} catch (DecryptException $e) { } catch (DecryptException $e) {
Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage()); Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage());
return false;
} }
} }
$exportFile = $this->exportFileName($attachment);
$this->exportDisk->put($exportFile, $decrypted);
$this->getEntries()->push($exportFile);
return true; return true;
} }

View File

@@ -103,7 +103,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
Log::error(sprintf('Could not decrypt old import file "%s". Skipped because: %s', $key, $e->getMessage())); Log::error(sprintf('Could not decrypt old import file "%s". Skipped because: %s', $key, $e->getMessage()));
} }
if (strlen($content) > 0) { if (\strlen($content) > 0) {
// add to export disk. // add to export disk.
$date = $job->created_at->format('Y-m-d'); $date = $job->created_at->format('Y-m-d');
$file = sprintf('%s-Old %s import dated %s.%s', $this->job->key, strtoupper($job->file_type), $date, $job->file_type); $file = sprintf('%s-Old %s import dated %s.%s', $this->job->key, strtoupper($job->file_type), $date, $job->file_type);

View File

@@ -199,7 +199,7 @@ final class Entry
$entry->transaction_id = $transaction->id; $entry->transaction_id = $transaction->id;
$entry->date = $transaction->date->format('Ymd'); $entry->date = $transaction->date->format('Ymd');
$entry->description = $transaction->description; $entry->description = $transaction->description;
if (strlen((string)$transaction->transaction_description) > 0) { if (\strlen((string)$transaction->transaction_description) > 0) {
$entry->description = $transaction->transaction_description . '(' . $transaction->description . ')'; $entry->description = $transaction->transaction_description . '(' . $transaction->description . ')';
} }
$entry->currency_code = $transaction->transactionCurrency->code; $entry->currency_code = $transaction->transactionCurrency->code;

View File

@@ -39,6 +39,7 @@ use Illuminate\Support\Collection;
use Log; use Log;
use Storage; use Storage;
use ZipArchive; use ZipArchive;
use FireflyIII\Models\TransactionJournal;
/** /**
* Class ExpandedProcessor. * Class ExpandedProcessor.
@@ -310,13 +311,13 @@ class ExpandedProcessor implements ProcessorInterface
private function getNotes(array $array): array private function getNotes(array $array): array
{ {
$array = array_unique($array); $array = array_unique($array);
$notes = Note::where('notes.noteable_type', 'FireflyIII\\Models\\TransactionJournal') $notes = Note::where('notes.noteable_type', TransactionJournal::class)
->whereIn('notes.noteable_id', $array) ->whereIn('notes.noteable_id', $array)
->get(['notes.*']); ->get(['notes.*']);
$return = []; $return = [];
/** @var Note $note */ /** @var Note $note */
foreach ($notes as $note) { foreach ($notes as $note) {
if (strlen(trim((string)$note->text)) > 0) { if (\strlen(trim((string)$note->text)) > 0) {
$id = (int)$note->noteable_id; $id = (int)$note->noteable_id;
$return[$id] = $note->text; $return[$id] = $note->text;
} }

View File

@@ -47,7 +47,7 @@ class BudgetFactory
$budgetId = (int)$budgetId; $budgetId = (int)$budgetId;
$budgetName = (string)$budgetName; $budgetName = (string)$budgetName;
if (strlen($budgetName) === 0 && $budgetId === 0) { if (\strlen($budgetName) === 0 && $budgetId === 0) {
return null; return null;
} }
@@ -60,7 +60,7 @@ class BudgetFactory
} }
} }
if (strlen($budgetName) > 0) { if (\strlen($budgetName) > 0) {
$budget = $this->findByName($budgetName); $budget = $this->findByName($budgetName);
if (null !== $budget) { if (null !== $budget) {
return $budget; return $budget;

View File

@@ -71,7 +71,7 @@ class CategoryFactory
Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName)); Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName));
if (strlen($categoryName) === 0 && $categoryId === 0) { if (\strlen($categoryName) === 0 && $categoryId === 0) {
return null; return null;
} }
// first by ID: // first by ID:
@@ -83,7 +83,7 @@ class CategoryFactory
} }
} }
if (strlen($categoryName) > 0) { if (\strlen($categoryName) > 0) {
$category = $this->findByName($categoryName); $category = $this->findByName($categoryName);
if (null !== $category) { if (null !== $category) {
return $category; return $category;

View File

@@ -45,7 +45,7 @@ class PiggyBankFactory
{ {
$piggyBankId = (int)$piggyBankId; $piggyBankId = (int)$piggyBankId;
$piggyBankName = (string)$piggyBankName; $piggyBankName = (string)$piggyBankName;
if (strlen($piggyBankName) === 0 && $piggyBankId === 0) { if (\strlen($piggyBankName) === 0 && $piggyBankId === 0) {
return null; return null;
} }
// first find by ID: // first find by ID:
@@ -58,7 +58,7 @@ class PiggyBankFactory
} }
// then find by name: // then find by name:
if (strlen($piggyBankName) > 0) { if (\strlen($piggyBankName) > 0) {
/** @var PiggyBank $piggyBank */ /** @var PiggyBank $piggyBank */
$piggyBank = $this->findByName($piggyBankName); $piggyBank = $this->findByName($piggyBankName);
if (null !== $piggyBank) { if (null !== $piggyBank) {

View File

@@ -68,7 +68,7 @@ class TransactionCurrencyFactory
$currencyCode = (string)$currencyCode; $currencyCode = (string)$currencyCode;
$currencyId = (int)$currencyId; $currencyId = (int)$currencyId;
if (strlen($currencyCode) === 0 && (int)$currencyId === 0) { if (\strlen($currencyCode) === 0 && (int)$currencyId === 0) {
return null; return null;
} }
@@ -80,7 +80,7 @@ class TransactionCurrencyFactory
} }
} }
// then by code: // then by code:
if (strlen($currencyCode) > 0) { if (\strlen($currencyCode) > 0) {
$currency = TransactionCurrency::whereCode($currencyCode)->first(); $currency = TransactionCurrency::whereCode($currencyCode)->first();
if (null !== $currency) { if (null !== $currency) {
return $currency; return $currency;

View File

@@ -66,10 +66,10 @@ class ChartJsGenerator implements GeneratorInterface
{ {
reset($data); reset($data);
$first = current($data); $first = current($data);
$labels = is_array($first['entries']) ? array_keys($first['entries']) : []; $labels = \is_array($first['entries']) ? array_keys($first['entries']) : [];
$chartData = [ $chartData = [
'count' => count($data), 'count' => \count($data),
'labels' => $labels, // take ALL labels from the first set. 'labels' => $labels, // take ALL labels from the first set.
'datasets' => [], 'datasets' => [],
]; ];
@@ -119,7 +119,7 @@ class ChartJsGenerator implements GeneratorInterface
// different sort when values are positive and when they're negative. // different sort when values are positive and when they're negative.
asort($data); asort($data);
$next = next($data); $next = next($data);
if (!is_bool($next) && 1 === bccomp($next, '0')) { if (!\is_bool($next) && 1 === bccomp($next, '0')) {
// next is positive, sort other way around. // next is positive, sort other way around.
arsort($data); arsort($data);
} }

View File

@@ -42,7 +42,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
*
*/ */
public function generate(): string public function generate(): string
{ {

View File

@@ -41,8 +41,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
*
*/ */
public function generate(): string public function generate(): string
{ {

View File

@@ -40,8 +40,6 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
*
*/ */
public function generate(): string public function generate(): string
{ {

View File

@@ -40,8 +40,6 @@ class YearReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
*
*/ */
public function generate(): string public function generate(): string
{ {

View File

@@ -108,8 +108,8 @@ class AttachmentHelper implements AttachmentHelperInterface
*/ */
public function saveAttachmentsForModel(Model $model, ?array $files): bool public function saveAttachmentsForModel(Model $model, ?array $files): bool
{ {
Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', get_class($model))); Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', \get_class($model)));
if (is_array($files)) { if (\is_array($files)) {
Log::debug('$files is an array.'); Log::debug('$files is an array.');
/** @var UploadedFile $entry */ /** @var UploadedFile $entry */
foreach ($files as $entry) { foreach ($files as $entry) {
@@ -136,7 +136,7 @@ class AttachmentHelper implements AttachmentHelperInterface
{ {
$md5 = md5_file($file->getRealPath()); $md5 = md5_file($file->getRealPath());
$name = $file->getClientOriginalName(); $name = $file->getClientOriginalName();
$class = get_class($model); $class = \get_class($model);
$count = $model->user->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count(); $count = $model->user->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
if ($count > 0) { if ($count > 0) {
@@ -180,8 +180,8 @@ class AttachmentHelper implements AttachmentHelperInterface
$fileObject->rewind(); $fileObject->rewind();
$content = $fileObject->fread($file->getSize()); $content = $fileObject->fread($file->getSize());
$encrypted = Crypt::encrypt($content); $encrypted = Crypt::encrypt($content);
Log::debug(sprintf('Full file length is %d and upload size is %d.', strlen($content), $file->getSize())); Log::debug(sprintf('Full file length is %d and upload size is %d.', \strlen($content), $file->getSize()));
Log::debug(sprintf('Encrypted content is %d', strlen($encrypted))); Log::debug(sprintf('Encrypted content is %d', \strlen($encrypted)));
// store it: // store it:
$this->uploadDisk->put($attachment->fileName(), $encrypted); $this->uploadDisk->put($attachment->fileName(), $encrypted);
@@ -210,7 +210,7 @@ class AttachmentHelper implements AttachmentHelperInterface
Log::debug(sprintf('Name is %s, and mime is %s', $name, $mime)); Log::debug(sprintf('Name is %s, and mime is %s', $name, $mime));
Log::debug('Valid mimes are', $this->allowedMimes); Log::debug('Valid mimes are', $this->allowedMimes);
if (!in_array($mime, $this->allowedMimes)) { if (!\in_array($mime, $this->allowedMimes)) {
$msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]); $msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);
$this->errors->add('attachments', $msg); $this->errors->add('attachments', $msg);
Log::error($msg); Log::error($msg);

View File

@@ -298,7 +298,7 @@ class MetaPieChart implements MetaPieChartInterface
*/ */
protected function groupByFields(Collection $set, array $fields): array protected function groupByFields(Collection $set, array $fields): array
{ {
if (0 === count($fields) && $this->tags->count() > 0) { if (0 === \count($fields) && $this->tags->count() > 0) {
// do a special group on tags: // do a special group on tags:
return $this->groupByTag($set); // @codeCoverageIgnore return $this->groupByTag($set); // @codeCoverageIgnore
} }

View File

@@ -136,7 +136,7 @@ class JournalCollector implements JournalCollectorInterface
public function addFilter(string $filter): JournalCollectorInterface public function addFilter(string $filter): JournalCollectorInterface
{ {
$interfaces = class_implements($filter); $interfaces = class_implements($filter);
if (in_array(FilterInterface::class, $interfaces) && !in_array($filter, $this->filters)) { if (\in_array(FilterInterface::class, $interfaces) && !\in_array($filter, $this->filters)) {
Log::debug(sprintf('Enabled filter %s', $filter)); Log::debug(sprintf('Enabled filter %s', $filter));
$this->filters[] = $filter; $this->filters[] = $filter;
} }
@@ -444,7 +444,7 @@ class JournalCollector implements JournalCollectorInterface
public function setBudgets(Collection $budgets): JournalCollectorInterface public function setBudgets(Collection $budgets): JournalCollectorInterface
{ {
$budgetIds = $budgets->pluck('id')->toArray(); $budgetIds = $budgets->pluck('id')->toArray();
if (0 === count($budgetIds)) { if (0 === \count($budgetIds)) {
return $this; return $this;
} }
$this->joinBudgetTables(); $this->joinBudgetTables();
@@ -468,7 +468,7 @@ class JournalCollector implements JournalCollectorInterface
public function setCategories(Collection $categories): JournalCollectorInterface public function setCategories(Collection $categories): JournalCollectorInterface
{ {
$categoryIds = $categories->pluck('id')->toArray(); $categoryIds = $categories->pluck('id')->toArray();
if (0 === count($categoryIds)) { if (0 === \count($categoryIds)) {
return $this; return $this;
} }
$this->joinCategoryTables(); $this->joinCategoryTables();
@@ -643,7 +643,7 @@ class JournalCollector implements JournalCollectorInterface
*/ */
public function setTypes(array $types): JournalCollectorInterface public function setTypes(array $types): JournalCollectorInterface
{ {
if (count($types) > 0) { if (\count($types) > 0) {
Log::debug('Set query collector types', $types); Log::debug('Set query collector types', $types);
$this->query->whereIn('transaction_types.type', $types); $this->query->whereIn('transaction_types.type', $types);
} }
@@ -769,7 +769,7 @@ class JournalCollector implements JournalCollectorInterface
SplitIndicatorFilter::class => new SplitIndicatorFilter, SplitIndicatorFilter::class => new SplitIndicatorFilter,
CountAttachmentsFilter::class => new CountAttachmentsFilter, CountAttachmentsFilter::class => new CountAttachmentsFilter,
]; ];
Log::debug(sprintf('Will run %d filters on the set.', count($this->filters))); Log::debug(sprintf('Will run %d filters on the set.', \count($this->filters)));
foreach ($this->filters as $enabled) { foreach ($this->filters as $enabled) {
if (isset($filters[$enabled])) { if (isset($filters[$enabled])) {
Log::debug(sprintf('Before filter %s: %d', $enabled, $set->count())); Log::debug(sprintf('Before filter %s: %d', $enabled, $set->count()));

View File

@@ -61,7 +61,7 @@ class InternalTransferFilter implements FilterInterface
return $transaction; return $transaction;
} }
// both id's in $parameters? // both id's in $parameters?
if (in_array($transaction->account_id, $this->accounts) && in_array($transaction->opposing_account_id, $this->accounts)) { if (\in_array($transaction->account_id, $this->accounts) && \in_array($transaction->opposing_account_id, $this->accounts)) {
Log::debug( Log::debug(
sprintf( sprintf(
'Transaction #%d has #%d and #%d in set, so removed', 'Transaction #%d has #%d and #%d in set, so removed',

View File

@@ -58,7 +58,7 @@ class OpposingAccountFilter implements FilterInterface
function (Transaction $transaction) { function (Transaction $transaction) {
$opposing = $transaction->opposing_account_id; $opposing = $transaction->opposing_account_id;
// remove internal transfer // remove internal transfer
if (in_array($opposing, $this->accounts)) { if (\in_array($opposing, $this->accounts)) {
Log::debug(sprintf('Filtered #%d because its opposite is in accounts.', $transaction->id), $this->accounts); Log::debug(sprintf('Filtered #%d because its opposite is in accounts.', $transaction->id), $this->accounts);
return null; return null;

View File

@@ -80,7 +80,7 @@ class Help implements HelpInterface
$content = trim($result->body); $content = trim($result->body);
} }
if (strlen($content) > 0) { if (\strlen($content) > 0) {
Log::debug('Content is longer than zero. Expect something.'); Log::debug('Content is longer than zero. Expect something.');
$converter = new CommonMarkConverter(); $converter = new CommonMarkConverter();
$content = $converter->convertToHtml($content); $content = $converter->convertToHtml($content);
@@ -127,7 +127,7 @@ class Help implements HelpInterface
public function putInCache(string $route, string $language, string $content) public function putInCache(string $route, string $language, string $content)
{ {
$key = sprintf(self::CACHEKEY, $route, $language); $key = sprintf(self::CACHEKEY, $route, $language);
if (strlen($content) > 0) { if (\strlen($content) > 0) {
Log::debug(sprintf('Will store entry in cache: %s', $key)); Log::debug(sprintf('Will store entry in cache: %s', $key));
Cache::put($key, $content, 10080); // a week. Cache::put($key, $content, 10080); // a week.

View File

@@ -122,6 +122,7 @@ class ReconcileController extends Controller
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* *
* @throws FireflyException * @throws FireflyException
* @throws \Throwable
*/ */
public function overview(Request $request, Account $account, Carbon $start, Carbon $end) public function overview(Request $request, Account $account, Carbon $start, Carbon $end)
{ {
@@ -339,6 +340,7 @@ class ReconcileController extends Controller
* @return mixed * @return mixed
* *
* @throws FireflyException * @throws FireflyException
* @throws \Throwable
*/ */
public function transactions(Account $account, Carbon $start, Carbon $end) public function transactions(Account $account, Carbon $start, Carbon $end)
{ {

View File

@@ -380,7 +380,7 @@ class AccountController extends Controller
// update preferences if necessary: // update preferences if necessary:
$frontPage = Preferences::get('frontPageAccounts', [])->data; $frontPage = Preferences::get('frontPageAccounts', [])->data;
if (count($frontPage) > 0 && AccountType::ASSET === $account->accountType->type) { if (AccountType::ASSET === $account->accountType->type && \count($frontPage) > 0) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$frontPage[] = $account->id; $frontPage[] = $account->id;
Preferences::set('frontPageAccounts', $frontPage); Preferences::set('frontPageAccounts', $frontPage);

View File

@@ -62,7 +62,6 @@ class UpdateController extends Controller
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \Psr\Container\NotFoundExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\ContainerExceptionInterface
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
public function index() public function index()
{ {

View File

@@ -174,7 +174,7 @@ class UserController extends Controller
$data = $request->getUserData(); $data = $request->getUserData();
// update password // update password
if (strlen($data['password']) > 0) { if (\strlen($data['password']) > 0) {
$repository->changePassword($user, $data['password']); $repository->changePassword($user, $data['password']);
} }

View File

@@ -117,7 +117,7 @@ class AttachmentController extends Controller
->header('Expires', '0') ->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public') ->header('Pragma', 'public')
->header('Content-Length', strlen($content)); ->header('Content-Length', \strlen($content));
return $response; return $response;
} }

View File

@@ -59,7 +59,7 @@ class TwoFactorController extends Controller
return redirect(route('index')); return redirect(route('index'));
} }
if (0 === strlen((string)$secret)) { if (0 === \strlen((string)$secret)) {
throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.'); throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.');
} }
$request->session()->flash('two-factor-secret', $secret); $request->session()->flash('two-factor-secret', $secret);

View File

@@ -75,7 +75,9 @@ class BillController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
*
* @param CurrencyRepositoryInterface $repository
* *
* @return View * @return View
*/ */
@@ -131,8 +133,9 @@ class BillController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param Bill $bill * @param CurrencyRepositoryInterface $repository
* @param Bill $bill
* *
* @return View * @return View
*/ */
@@ -293,9 +296,10 @@ class BillController extends Controller
} }
/** /**
* @param BillFormRequest $request * @param BillFormRequest $request
* @param BillRepositoryInterface $repository * @param BillRepositoryInterface $repository
* *
* @param RuleGroupRepositoryInterface $ruleGroupRepository
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function store(BillFormRequest $request, BillRepositoryInterface $repository, RuleGroupRepositoryInterface $ruleGroupRepository) public function store(BillFormRequest $request, BillRepositoryInterface $repository, RuleGroupRepositoryInterface $ruleGroupRepository)
@@ -315,7 +319,7 @@ class BillController extends Controller
$this->attachments->saveAttachmentsForModel($bill, $files); $this->attachments->saveAttachmentsForModel($bill, $files);
// flash messages // flash messages
if (count($this->attachments->getMessages()->get('attachments')) > 0) { if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
} }
@@ -364,7 +368,7 @@ class BillController extends Controller
$this->attachments->saveAttachmentsForModel($bill, $files); $this->attachments->saveAttachmentsForModel($bill, $files);
// flash messages // flash messages
if (count($this->attachments->getMessages()->get('attachments')) > 0) { if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
} }

View File

@@ -417,13 +417,13 @@ class BudgetController extends Controller
// prep for "all" view. // prep for "all" view.
if ('all' === $moment) { if ('all' === $moment) {
$subTitle = trans('firefly.all_journals_without_budget'); $subTitle = trans('firefly.all_journals_without_budget');
$first = $repository->first(); $first = $repository->firstNull();
$start = $first->date ?? new Carbon; $start = null === $first ? new Carbon : $first->date;
$end = new Carbon; $end = new Carbon;
} }
// prep for "specific date" view. // prep for "specific date" view.
if (strlen($moment) > 0 && 'all' !== $moment) { if ('all' !== $moment && \strlen($moment) > 0) {
$start = new Carbon($moment); $start = new Carbon($moment);
$end = app('navigation')->endOfPeriod($start, $range); $end = app('navigation')->endOfPeriod($start, $range);
$subTitle = trans( $subTitle = trans(
@@ -434,7 +434,7 @@ class BudgetController extends Controller
} }
// prep for current period // prep for current period
if (0 === strlen($moment)) { if ('' === $moment) {
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range)); $end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range));
$periods = $this->getPeriodOverview(); $periods = $this->getPeriodOverview();

View File

@@ -185,13 +185,13 @@ class CategoryController extends Controller
// prep for "all" view. // prep for "all" view.
if ('all' === $moment) { if ('all' === $moment) {
$subTitle = trans('firefly.all_journals_without_category'); $subTitle = trans('firefly.all_journals_without_category');
$first = $this->journalRepos->first(); $first = $this->journalRepos->firstNull();
$start = $first->date ?? new Carbon; $start = null === $first ? new Carbon : $first->date;
$end = new Carbon; $end = new Carbon;
} }
// prep for "specific date" view. // prep for "specific date" view.
if (strlen($moment) > 0 && 'all' !== $moment) { if ('all' !== $moment && \strlen($moment) > 0) {
$start = app('navigation')->startOfPeriod(new Carbon($moment), $range); $start = app('navigation')->startOfPeriod(new Carbon($moment), $range);
$end = app('navigation')->endOfPeriod($start, $range); $end = app('navigation')->endOfPeriod($start, $range);
$subTitle = trans( $subTitle = trans(
@@ -202,7 +202,7 @@ class CategoryController extends Controller
} }
// prep for current period // prep for current period
if (0 === strlen($moment)) { if ('' === $moment) {
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range)); $end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range));
$periods = $this->getNoCategoryPeriodOverview($start); $periods = $this->getNoCategoryPeriodOverview($start);
@@ -255,7 +255,7 @@ class CategoryController extends Controller
} }
// prep for "specific date" view. // prep for "specific date" view.
if (strlen($moment) > 0 && 'all' !== $moment) { if (\strlen($moment) > 0 && 'all' !== $moment) {
$start = app('navigation')->startOfPeriod(new Carbon($moment), $range); $start = app('navigation')->startOfPeriod(new Carbon($moment), $range);
$end = app('navigation')->endOfPeriod($start, $range); $end = app('navigation')->endOfPeriod($start, $range);
$subTitle = trans( $subTitle = trans(
@@ -268,7 +268,7 @@ class CategoryController extends Controller
} }
// prep for current period // prep for current period
if (0 === strlen($moment)) { if (0 === \strlen($moment)) {
/** @var Carbon $start */ /** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
/** @var Carbon $end */ /** @var Carbon $end */
@@ -351,8 +351,8 @@ class CategoryController extends Controller
private function getNoCategoryPeriodOverview(Carbon $theDate): Collection private function getNoCategoryPeriodOverview(Carbon $theDate): Collection
{ {
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$first = $this->journalRepos->first(); $first = $this->journalRepos->firstNull();
$start = $first->date ?? new Carbon; $start = null === $first ? new Carbon : $first->date;
$end = $theDate ?? new Carbon; $end = $theDate ?? new Carbon;
// properties for cache // properties for cache
@@ -431,8 +431,8 @@ class CategoryController extends Controller
private function getPeriodOverview(Category $category, Carbon $date): Collection private function getPeriodOverview(Category $category, Carbon $date): Collection
{ {
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$first = $this->journalRepos->first(); $first = $this->journalRepos->firstNull();
$start = $first->date ?? new Carbon; $start = null === $first ? new Carbon : $first->date;
$end = $date ?? new Carbon; $end = $date ?? new Carbon;
$accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); $accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);

View File

@@ -228,7 +228,7 @@ class AccountController extends Controller
Log::debug('Default set is ', $defaultSet); Log::debug('Default set is ', $defaultSet);
$frontPage = Preferences::get('frontPageAccounts', $defaultSet); $frontPage = Preferences::get('frontPageAccounts', $defaultSet);
Log::debug('Frontpage preference set is ', $frontPage->data); Log::debug('Frontpage preference set is ', $frontPage->data);
if (0 === count($frontPage->data)) { if (0 === \count($frontPage->data)) {
$frontPage->data = $defaultSet; $frontPage->data = $defaultSet;
Log::debug('frontpage set is empty!'); Log::debug('frontpage set is empty!');
$frontPage->save(); $frontPage->save();

View File

@@ -180,7 +180,7 @@ class BudgetReportController extends Controller
$chartData[$budget->id]['entries'][$label] = bcmul($currentExpenses, '-1'); $chartData[$budget->id]['entries'][$label] = bcmul($currentExpenses, '-1');
$chartData[$budget->id . '-sum']['entries'][$label] = bcmul($sumOfExpenses[$budget->id], '-1'); $chartData[$budget->id . '-sum']['entries'][$label] = bcmul($sumOfExpenses[$budget->id], '-1');
if (count($budgetLimits) > 0) { if (\count($budgetLimits) > 0) {
$budgetLimitId = $budgetLimits->first()->id; $budgetLimitId = $budgetLimits->first()->id;
$leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? (string)$budgetLimits->sum('amount'); $leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? (string)$budgetLimits->sum('amount');
$leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses); $leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses);

View File

@@ -251,7 +251,7 @@ class CategoryReportController extends Controller
$newSet[$key] = $chartData[$key]; $newSet[$key] = $chartData[$key];
} }
} }
if (0 === count($newSet)) { if (0 === \count($newSet)) {
$newSet = $chartData; $newSet = $chartData;
} }
$data = $this->generator->multiSet($newSet); $data = $this->generator->multiSet($newSet);

View File

@@ -173,7 +173,7 @@ class ExpenseReportController extends Controller
$newSet[$key] = $chartData[$key]; $newSet[$key] = $chartData[$key];
} }
} }
if (0 === count($newSet)) { if (0 === \count($newSet)) {
$newSet = $chartData; // @codeCoverageIgnore $newSet = $chartData; // @codeCoverageIgnore
} }
$data = $this->generator->multiSet($newSet); $data = $this->generator->multiSet($newSet);

View File

@@ -245,7 +245,7 @@ class TagReportController extends Controller
$newSet[$key] = $chartData[$key]; $newSet[$key] = $chartData[$key];
} }
} }
if (0 === count($newSet)) { if (0 === \count($newSet)) {
$newSet = $chartData; // @codeCoverageIgnore $newSet = $chartData; // @codeCoverageIgnore
} }
$data = $this->generator->multiSet($newSet); $data = $this->generator->multiSet($newSet);

View File

@@ -92,7 +92,7 @@ class Controller extends BaseController
$shownDemo = true; $shownDemo = true;
// either must be array and either must be > 0 // either must be array and either must be > 0
if ((is_array($intro) || is_array($specialIntro)) && (count($intro) > 0 || count($specialIntro) > 0)) { if ((\is_array($intro) || \is_array($specialIntro)) && (\count($intro) > 0 || \count($specialIntro) > 0)) {
$shownDemo = Preferences::get($key, false)->data; $shownDemo = Preferences::get($key, false)->data;
Log::debug(sprintf('Check if user has already seen intro with key "%s". Result is %d', $key, $shownDemo)); Log::debug(sprintf('Check if user has already seen intro with key "%s". Result is %d', $key, $shownDemo));
} }
@@ -157,7 +157,7 @@ class Controller extends BaseController
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$account = $transaction->account; $account = $transaction->account;
if (in_array($account->accountType->type, $valid)) { if (\in_array($account->accountType->type, $valid)) {
return redirect(route('accounts.show', [$account->id])); return redirect(route('accounts.show', [$account->id]));
} }
} }

View File

@@ -91,7 +91,7 @@ class ExportController extends Controller
->header('Expires', '0') ->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public') ->header('Pragma', 'public')
->header('Content-Length', strlen($content)); ->header('Content-Length', \strlen($content));
return $response; return $response;
} }

View File

@@ -93,7 +93,7 @@ class HelpController extends Controller
$content = $this->help->getFromGithub($route, $language); $content = $this->help->getFromGithub($route, $language);
// content will have 0 length when Github failed. Try en_US when it does: // content will have 0 length when Github failed. Try en_US when it does:
if (0 === strlen($content)) { if (0 === \strlen($content)) {
$language = 'en_US'; $language = 'en_US';
// also check cache first: // also check cache first:
@@ -108,7 +108,7 @@ class HelpController extends Controller
} }
// help still empty? // help still empty?
if (0 !== strlen($content)) { if (0 !== \strlen($content)) {
$this->help->putInCache($route, $language, $content); $this->help->putInCache($route, $language, $content);
return $content; return $content;

View File

@@ -211,7 +211,7 @@ class HomeController extends Controller
/** @var Route $route */ /** @var Route $route */
foreach ($set as $route) { foreach ($set as $route) {
$name = $route->getName(); $name = $route->getName();
if (null !== $name && in_array('GET', $route->methods()) && strlen($name) > 0) { if (null !== $name && \in_array('GET', $route->methods()) && \strlen($name) > 0) {
$found = false; $found = false;
foreach ($ignore as $string) { foreach ($ignore as $string) {

View File

@@ -114,7 +114,7 @@ class ConfigurationController extends Controller
// get possible warning from configurator: // get possible warning from configurator:
$warning = $configurator->getWarningMessage(); $warning = $configurator->getWarningMessage();
if (strlen($warning) > 0) { if (\strlen($warning) > 0) {
$request->session()->flash('warning', $warning); $request->session()->flash('warning', $warning);
} }

View File

@@ -115,7 +115,7 @@ class IndexController extends Controller
->header('Expires', '0') ->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public') ->header('Pragma', 'public')
->header('Content-Length', strlen($result)); ->header('Content-Length', \strlen($result));
return $response; return $response;
} }

View File

@@ -59,7 +59,7 @@ class StatusController extends Controller
public function index(ImportJob $job) public function index(ImportJob $job)
{ {
$statuses = ['configured', 'running', 'finished', 'error']; $statuses = ['configured', 'running', 'finished', 'error'];
if (!in_array($job->status, $statuses)) { if (!\in_array($job->status, $statuses)) {
return redirect(route('import.configure', [$job->key])); return redirect(route('import.configure', [$job->key]));
} }
$subTitle = trans('import.status_sub_title'); $subTitle = trans('import.status_sub_title');

View File

@@ -158,7 +158,7 @@ class BoxController extends Controller
'incomes' => $incomes, 'incomes' => $incomes,
'expenses' => $expenses, 'expenses' => $expenses,
'sums' => $sums, 'sums' => $sums,
'size' => count($sums), 'size' => \count($sums),
]; ];
$cache->store($response); $cache->store($response);

View File

@@ -35,8 +35,7 @@ class FrontpageController extends Controller
* @param PiggyBankRepositoryInterface $repository * @param PiggyBankRepositoryInterface $repository
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* * @throws \Throwable
*/ */
public function piggyBanks(PiggyBankRepositoryInterface $repository) public function piggyBanks(PiggyBankRepositoryInterface $repository)
{ {
@@ -61,7 +60,7 @@ class FrontpageController extends Controller
} }
} }
$html = ''; $html = '';
if (count($info) > 0) { if (\count($info) > 0) {
$html = view('json.piggy-banks', compact('info'))->render(); $html = view('json.piggy-banks', compact('info'))->render();
} }

View File

@@ -43,7 +43,7 @@ class IntroController
Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage)); Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
$steps = $this->getBasicSteps($route); $steps = $this->getBasicSteps($route);
$specificSteps = $this->getSpecificSteps($route, $specificPage); $specificSteps = $this->getSpecificSteps($route, $specificPage);
if (0 === count($specificSteps)) { if (0 === \count($specificSteps)) {
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage)); Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
return response()->json($steps); return response()->json($steps);
@@ -51,7 +51,7 @@ class IntroController
if ($this->hasOutroStep($route)) { if ($this->hasOutroStep($route)) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
// save last step: // save last step:
$lastStep = $steps[count($steps) - 1]; $lastStep = $steps[\count($steps) - 1];
// remove last step: // remove last step:
array_pop($steps); array_pop($steps);
// merge arrays and add last step again // merge arrays and add last step again
@@ -136,7 +136,7 @@ class IntroController
$routeKey = str_replace('.', '_', $route); $routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey)); $elements = config(sprintf('intro.%s', $routeKey));
$steps = []; $steps = [];
if (is_array($elements) && count($elements) > 0) { if (\is_array($elements) && \count($elements) > 0) {
foreach ($elements as $key => $options) { foreach ($elements as $key => $options) {
$currentStep = $options; $currentStep = $options;
@@ -147,7 +147,7 @@ class IntroController
$steps[] = $currentStep; $steps[] = $currentStep;
} }
} }
Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps))); Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, \count($steps)));
return $steps; return $steps;
} }
@@ -164,10 +164,10 @@ class IntroController
$routeKey = ''; $routeKey = '';
// user is on page with specific instructions: // user is on page with specific instructions:
if (strlen($specificPage) > 0) { if (\strlen($specificPage) > 0) {
$routeKey = str_replace('.', '_', $route); $routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage)); $elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));
if (is_array($elements) && count($elements) > 0) { if (\is_array($elements) && \count($elements) > 0) {
foreach ($elements as $key => $options) { foreach ($elements as $key => $options) {
$currentStep = $options; $currentStep = $options;
@@ -179,7 +179,7 @@ class IntroController
} }
} }
} }
Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps))); Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, \count($steps)));
return $steps; return $steps;
} }

View File

@@ -33,8 +33,7 @@ class JsonController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* * @throws \Throwable
*/ */
public function action(Request $request) public function action(Request $request)
{ {
@@ -53,6 +52,7 @@ class JsonController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws \Throwable
*/ */
public function trigger(Request $request) public function trigger(Request $request)
{ {

View File

@@ -273,7 +273,7 @@ class PiggyBankController extends Controller
// set all users piggy banks to zero: // set all users piggy banks to zero:
$this->piggyRepos->reset(); $this->piggyRepos->reset();
if (is_array($data)) { if (\is_array($data)) {
foreach ($data as $order => $id) { foreach ($data as $order => $id) {
$this->piggyRepos->setOrder((int)$id, $order + 1); $this->piggyRepos->setOrder((int)$id, $order + 1);
} }

View File

@@ -114,11 +114,12 @@ class ReportController extends Controller
} }
/** /**
* @param $attributes * @param array $attributes
* *
* @return string * @return string
* *
* @throws FireflyException * @throws FireflyException
* @throws \Throwable
*/ */
private function balanceAmount(array $attributes): string private function balanceAmount(array $attributes): string
{ {
@@ -155,8 +156,7 @@ class ReportController extends Controller
* @param array $attributes * @param array $attributes
* *
* @return string * @return string
* * @throws \Throwable
*/ */
private function budgetSpentAmount(array $attributes): string private function budgetSpentAmount(array $attributes): string
{ {
@@ -173,8 +173,7 @@ class ReportController extends Controller
* @param array $attributes * @param array $attributes
* *
* @return string * @return string
* * @throws \Throwable
*/ */
private function categoryEntry(array $attributes): string private function categoryEntry(array $attributes): string
{ {
@@ -191,8 +190,7 @@ class ReportController extends Controller
* @param array $attributes * @param array $attributes
* *
* @return string * @return string
* * @throws \Throwable
*/ */
private function expenseEntry(array $attributes): string private function expenseEntry(array $attributes): string
{ {
@@ -209,8 +207,7 @@ class ReportController extends Controller
* @param array $attributes * @param array $attributes
* *
* @return string * @return string
* * @throws \Throwable
*/ */
private function incomeEntry(array $attributes): string private function incomeEntry(array $attributes): string
{ {

View File

@@ -94,7 +94,7 @@ class PreferencesController extends Controller
{ {
// front page accounts // front page accounts
$frontPageAccounts = []; $frontPageAccounts = [];
if (is_array($request->get('frontPageAccounts'))) { if (\is_array($request->get('frontPageAccounts'))) {
foreach ($request->get('frontPageAccounts') as $id) { foreach ($request->get('frontPageAccounts') as $id) {
$frontPageAccounts[] = (int)$id; $frontPageAccounts[] = (int)$id;
} }

View File

@@ -40,7 +40,7 @@ class AccountController extends Controller
* *
* @return mixed|string * @return mixed|string
* *
* @throws \Throwable
*/ */
public function general(Collection $accounts, Carbon $start, Carbon $end) public function general(Collection $accounts, Carbon $start, Carbon $end)
{ {

View File

@@ -40,8 +40,7 @@ class BalanceController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return mixed|string * @return mixed|string
* * @throws \Throwable
*/ */
public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end) public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
{ {

View File

@@ -41,8 +41,7 @@ class BudgetController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return mixed|string * @return mixed|string
* * @throws \Throwable
*/ */
public function general(BudgetReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end) public function general(BudgetReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
{ {
@@ -70,8 +69,7 @@ class BudgetController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return mixed|string * @return mixed|string
* * @throws \Throwable
*/ */
public function period(Collection $accounts, Carbon $start, Carbon $end) public function period(Collection $accounts, Carbon $start, Carbon $end)
{ {

View File

@@ -40,8 +40,7 @@ class CategoryController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return mixed|string * @return mixed|string
* * @throws \Throwable
*/ */
public function expenses(Collection $accounts, Carbon $start, Carbon $end) public function expenses(Collection $accounts, Carbon $start, Carbon $end)
{ {
@@ -68,13 +67,13 @@ class CategoryController extends Controller
} }
/** /**
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
* *
* @return string * @param Carbon $start
* @param Carbon $end
* *
* @return string
* @throws \Throwable
*/ */
public function income(Collection $accounts, Carbon $start, Carbon $end) public function income(Collection $accounts, Carbon $start, Carbon $end)
{ {
@@ -107,9 +106,8 @@ class CategoryController extends Controller
* *
* @return mixed|string * @return mixed|string
* *
* @throws \Throwable
* @internal param ReportHelperInterface $helper * @internal param ReportHelperInterface $helper
*
*/ */
public function operations(Collection $accounts, Carbon $start, Carbon $end) public function operations(Collection $accounts, Carbon $start, Carbon $end)
{ {

View File

@@ -67,8 +67,7 @@ class ExpenseController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return string * @return string
* * @throws \Throwable
*/ */
public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{ {
@@ -115,8 +114,7 @@ class ExpenseController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return string * @return string
* * @throws \Throwable
*/ */
public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{ {
@@ -173,8 +171,7 @@ class ExpenseController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return array|mixed|string * @return array|mixed|string
* * @throws \Throwable
*/ */
public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{ {
@@ -218,8 +215,7 @@ class ExpenseController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return string * @return string
* * @throws \Throwable
*/ */
public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{ {
@@ -262,8 +258,7 @@ class ExpenseController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return mixed|string * @return mixed|string
* * @throws \Throwable
*/ */
public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{ {

View File

@@ -40,8 +40,7 @@ class OperationsController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return mixed|string * @return mixed|string
* * @throws \Throwable
*/ */
public function expenses(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end) public function expenses(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
{ {
@@ -69,8 +68,7 @@ class OperationsController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return string * @return string
* * @throws \Throwable
*/ */
public function income(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end) public function income(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
{ {
@@ -99,8 +97,7 @@ class OperationsController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return mixed|string * @return mixed|string
* * @throws \Throwable
*/ */
public function operations(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end) public function operations(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
{ {

View File

@@ -415,8 +415,7 @@ class ReportController extends Controller
/** /**
* @return string * @return string
* * @throws \Throwable
*/ */
private function accountReportOptions(): string private function accountReportOptions(): string
{ {
@@ -427,7 +426,7 @@ class ReportController extends Controller
$set = new Collection; $set = new Collection;
$names = $revenue->pluck('name')->toArray(); $names = $revenue->pluck('name')->toArray();
foreach ($expense as $exp) { foreach ($expense as $exp) {
if (in_array($exp->name, $names)) { if (\in_array($exp->name, $names)) {
$set->push($exp); $set->push($exp);
} }
} }
@@ -437,8 +436,7 @@ class ReportController extends Controller
/** /**
* @return string * @return string
* * @throws \Throwable
*/ */
private function budgetReportOptions(): string private function budgetReportOptions(): string
{ {
@@ -451,8 +449,7 @@ class ReportController extends Controller
/** /**
* @return string * @return string
* * @throws \Throwable
*/ */
private function categoryReportOptions(): string private function categoryReportOptions(): string
{ {
@@ -465,8 +462,7 @@ class ReportController extends Controller
/** /**
* @return string * @return string
* * @throws \Throwable
*/ */
private function noReportOptions(): string private function noReportOptions(): string
{ {
@@ -475,8 +471,7 @@ class ReportController extends Controller
/** /**
* @return string * @return string
* * @throws \Throwable
*/ */
private function tagReportOptions(): string private function tagReportOptions(): string
{ {

View File

@@ -310,9 +310,8 @@ class RuleController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param RuleRepositoryInterface $repository * @param Rule $rule
* @param Rule $rule
* *
* @return JsonResponse * @return JsonResponse
*/ */
@@ -452,7 +451,7 @@ class RuleController extends Controller
{ {
$triggers = $rule->ruleTriggers; $triggers = $rule->ruleTriggers;
if (0 === count($triggers)) { if (0 === \count($triggers)) {
return response()->json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore return response()->json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
} }
@@ -682,7 +681,7 @@ class RuleController extends Controller
$newIndex = 0; $newIndex = 0;
$actions = []; $actions = [];
/** @var array $oldActions */ /** @var array $oldActions */
$oldActions = is_array($request->old('rule-action')) ? $request->old('rule-action') : []; $oldActions = \is_array($request->old('rule-action')) ? $request->old('rule-action') : [];
foreach ($oldActions as $index => $entry) { foreach ($oldActions as $index => $entry) {
$count = ($newIndex + 1); $count = ($newIndex + 1);
$checked = isset($request->old('rule-action-stop')[$index]) ? true : false; $checked = isset($request->old('rule-action-stop')[$index]) ? true : false;
@@ -718,7 +717,7 @@ class RuleController extends Controller
$newIndex = 0; $newIndex = 0;
$triggers = []; $triggers = [];
/** @var array $oldTriggers */ /** @var array $oldTriggers */
$oldTriggers = is_array($request->old('rule-trigger')) ? $request->old('rule-trigger') : []; $oldTriggers = \is_array($request->old('rule-trigger')) ? $request->old('rule-trigger') : [];
foreach ($oldTriggers as $index => $entry) { foreach ($oldTriggers as $index => $entry) {
$count = ($newIndex + 1); $count = ($newIndex + 1);
$oldChecked = isset($request->old('rule-trigger-stop')[$index]) ? true : false; $oldChecked = isset($request->old('rule-trigger-stop')[$index]) ? true : false;

View File

@@ -73,8 +73,7 @@ class SearchController extends Controller
* @param SearchInterface $searcher * @param SearchInterface $searcher
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* * @throws \Throwable
*/ */
public function search(Request $request, SearchInterface $searcher) public function search(Request $request, SearchInterface $searcher)
{ {

View File

@@ -213,7 +213,7 @@ class TagController extends Controller
} }
// prep for "specific date" view. // prep for "specific date" view.
if (strlen($moment) > 0 && 'all' !== $moment) { if (\strlen($moment) > 0 && 'all' !== $moment) {
$start = new Carbon($moment); $start = new Carbon($moment);
$end = app('navigation')->endOfPeriod($start, $range); $end = app('navigation')->endOfPeriod($start, $range);
$subTitle = trans( $subTitle = trans(
@@ -226,7 +226,7 @@ class TagController extends Controller
} }
// prep for current period // prep for current period
if (0 === strlen($moment)) { if (0 === \strlen($moment)) {
/** @var Carbon $start */ /** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
/** @var Carbon $end */ /** @var Carbon $end */

View File

@@ -120,7 +120,7 @@ class MassController extends Controller
/** /**
* @param Collection $journals * @param Collection $journals
* *
* @return View * @return IlluminateView
*/ */
public function edit(Collection $journals): IlluminateView public function edit(Collection $journals): IlluminateView
{ {
@@ -173,7 +173,7 @@ class MassController extends Controller
{ {
$journalIds = $request->get('journals'); $journalIds = $request->get('journals');
$count = 0; $count = 0;
if (is_array($journalIds)) { if (\is_array($journalIds)) {
foreach ($journalIds as $journalId) { foreach ($journalIds as $journalId) {
$journal = $repository->find((int)$journalId); $journal = $repository->find((int)$journalId);
if (null !== $journal) { if (null !== $journal) {

View File

@@ -408,10 +408,10 @@ class SingleController extends Controller
$this->attachments->saveAttachmentsForModel($journal, $files); $this->attachments->saveAttachmentsForModel($journal, $files);
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if (count($this->attachments->getErrors()->get('attachments')) > 0) { if (\count($this->attachments->getErrors()->get('attachments')) > 0) {
session()->flash('error', $this->attachments->getErrors()->get('attachments')); session()->flash('error', $this->attachments->getErrors()->get('attachments'));
} }
if (count($this->attachments->getMessages()->get('attachments')) > 0) { if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
session()->flash('info', $this->attachments->getMessages()->get('attachments')); session()->flash('info', $this->attachments->getMessages()->get('attachments'));
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd

View File

@@ -157,7 +157,7 @@ class SplitController extends Controller
// flash messages // flash messages
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if (count($this->attachments->getMessages()->get('attachments')) > 0) { if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
session()->flash('info', $this->attachments->getMessages()->get('attachments')); session()->flash('info', $this->attachments->getMessages()->get('attachments'));
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
@@ -253,7 +253,7 @@ class SplitController extends Controller
$res = $transformer->transform($transaction); $res = $transformer->transform($transaction);
} }
if (count($res) > 0) { if (\count($res) > 0) {
$res['amount'] = app('steam')->positive((string)$res['amount']); $res['amount'] = app('steam')->positive((string)$res['amount']);
$res['foreign_amount'] = app('steam')->positive((string)$res['foreign_amount']); $res['foreign_amount'] = app('steam')->positive((string)$res['foreign_amount']);
$transactions[] = $res; $transactions[] = $res;
@@ -271,7 +271,7 @@ class SplitController extends Controller
*/ */
private function updateWithPrevious($array, $old): array private function updateWithPrevious($array, $old): array
{ {
if (0 === count($old) || !isset($old['transactions'])) { if (0 === \count($old) || !isset($old['transactions'])) {
return $array; return $array;
} }
$old = $old['transactions']; $old = $old['transactions'];

View File

@@ -175,7 +175,7 @@ class TransactionController extends Controller
{ {
$ids = $request->get('items'); $ids = $request->get('items');
$date = new Carbon($request->get('date')); $date = new Carbon($request->get('date'));
if (count($ids) > 0) { if (\count($ids) > 0) {
$order = 0; $order = 0;
$ids = array_unique($ids); $ids = array_unique($ids);
foreach ($ids as $id) { foreach ($ids as $id) {

View File

@@ -62,7 +62,8 @@ class Authenticate
* *
* @return mixed * @return mixed
* *
* @throws \Illuminate\Auth\AuthenticationException * @throws AuthenticationException
* @throws FireflyException
*/ */
public function handle($request, Closure $next, ...$guards) public function handle($request, Closure $next, ...$guards)
{ {

View File

@@ -71,7 +71,7 @@ class Sandstorm
// access the same data so we have no choice but to simply login // access the same data so we have no choice but to simply login
// the new user to the same account and just forget about Bob and Alice // the new user to the same account and just forget about Bob and Alice
// and any other differences there may be between these users. // and any other differences there may be between these users.
if (1 === $count && strlen($userId) > 0) { if (1 === $count && \strlen($userId) > 0) {
// login as first user user. // login as first user user.
$user = $repository->first(); $user = $repository->first();
Auth::guard($guard)->login($user); Auth::guard($guard)->login($user);
@@ -80,7 +80,7 @@ class Sandstorm
return $next($request); return $next($request);
} }
if (1 === $count && 0 === strlen($userId)) { if (1 === $count && 0 === \strlen($userId)) {
// login but indicate anonymous // login but indicate anonymous
$user = User::first(); $user = User::first();
Auth::guard($guard)->login($user); Auth::guard($guard)->login($user);
@@ -89,7 +89,7 @@ class Sandstorm
return $next($request); return $next($request);
} }
if (0 === $count && strlen($userId) > 0) { if (0 === $count && \strlen($userId) > 0) {
// create new user. // create new user.
$email = $userId . '@firefly'; $email = $userId . '@firefly';
/** @var User $user */ /** @var User $user */
@@ -111,7 +111,7 @@ class Sandstorm
return $next($request); return $next($request);
} }
if (0 === $count && 0 === strlen($userId)) { if (0 === $count && 0 === \strlen($userId)) {
throw new FireflyException('The first visit to a new Firefly III administration cannot be by a guest user.'); throw new FireflyException('The first visit to a new Firefly III administration cannot be by a guest user.');
} }
@@ -121,7 +121,7 @@ class Sandstorm
} }
// if in Sandstorm, user logged in, still must check if user is anon. // if in Sandstorm, user logged in, still must check if user is anon.
$userId = (string)$request->header('X-Sandstorm-User-Id'); $userId = (string)$request->header('X-Sandstorm-User-Id');
if (strlen($userId) === 0) { if (\strlen($userId) === 0) {
View::share('SANDSTORM_ANON', true); View::share('SANDSTORM_ANON', true);
return $next($request); return $next($request);

View File

@@ -48,7 +48,7 @@ class JournalLinkRequest extends Request
$parts = explode('_', $linkType); $parts = explode('_', $linkType);
$return['link_type_id'] = (int)$parts[0]; $return['link_type_id'] = (int)$parts[0];
$return['transaction_journal_id'] = $this->integer('link_journal_id'); $return['transaction_journal_id'] = $this->integer('link_journal_id');
$return['notes'] = strlen($this->string('notes')) > 0 ? $this->string('notes') : ''; $return['notes'] = \strlen($this->string('notes')) > 0 ? $this->string('notes') : '';
$return['direction'] = $parts[1]; $return['direction'] = $parts[1];
if (0 === $return['transaction_journal_id'] && ctype_digit($this->string('link_other'))) { if (0 === $return['transaction_journal_id'] && ctype_digit($this->string('link_other'))) {
$return['transaction_journal_id'] = $this->integer('link_other'); $return['transaction_journal_id'] = $this->integer('link_other');

View File

@@ -46,7 +46,7 @@ class ReconciliationStoreRequest extends Request
public function getAll(): array public function getAll(): array
{ {
$transactions = $this->get('transactions'); $transactions = $this->get('transactions');
if (!is_array($transactions)) { if (!\is_array($transactions)) {
$transactions = []; // @codeCoverageIgnore $transactions = []; // @codeCoverageIgnore
} }
$data = [ $data = [

View File

@@ -56,7 +56,7 @@ class ReportFormRequest extends Request
$repository = app(AccountRepositoryInterface::class); $repository = app(AccountRepositoryInterface::class);
$set = $this->get('accounts'); $set = $this->get('accounts');
$collection = new Collection; $collection = new Collection;
if (is_array($set)) { if (\is_array($set)) {
foreach ($set as $accountId) { foreach ($set as $accountId) {
$account = $repository->findNull((int)$accountId); $account = $repository->findNull((int)$accountId);
if (null !== $account) { if (null !== $account) {
@@ -77,7 +77,7 @@ class ReportFormRequest extends Request
$repository = app(BudgetRepositoryInterface::class); $repository = app(BudgetRepositoryInterface::class);
$set = $this->get('budget'); $set = $this->get('budget');
$collection = new Collection; $collection = new Collection;
if (is_array($set)) { if (\is_array($set)) {
foreach ($set as $budgetId) { foreach ($set as $budgetId) {
$budget = $repository->findNull((int)$budgetId); $budget = $repository->findNull((int)$budgetId);
if (null !== $budget) { if (null !== $budget) {
@@ -98,7 +98,7 @@ class ReportFormRequest extends Request
$repository = app(CategoryRepositoryInterface::class); $repository = app(CategoryRepositoryInterface::class);
$set = $this->get('category'); $set = $this->get('category');
$collection = new Collection; $collection = new Collection;
if (is_array($set)) { if (\is_array($set)) {
foreach ($set as $categoryId) { foreach ($set as $categoryId) {
$category = $repository->findNull((int)$categoryId); $category = $repository->findNull((int)$categoryId);
if (null !== $category) { if (null !== $category) {
@@ -120,7 +120,7 @@ class ReportFormRequest extends Request
$date = new Carbon; $date = new Carbon;
$range = $this->get('daterange'); $range = $this->get('daterange');
$parts = explode(' - ', (string)$range); $parts = explode(' - ', (string)$range);
if (2 === count($parts)) { if (2 === \count($parts)) {
try { try {
$date = new Carbon($parts[1]); $date = new Carbon($parts[1]);
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
@@ -145,7 +145,7 @@ class ReportFormRequest extends Request
$repository = app(AccountRepositoryInterface::class); $repository = app(AccountRepositoryInterface::class);
$set = $this->get('exp_rev'); $set = $this->get('exp_rev');
$collection = new Collection; $collection = new Collection;
if (is_array($set)) { if (\is_array($set)) {
foreach ($set as $accountId) { foreach ($set as $accountId) {
$account = $repository->findNull((int)$accountId); $account = $repository->findNull((int)$accountId);
if (null !== $account) { if (null !== $account) {
@@ -167,7 +167,7 @@ class ReportFormRequest extends Request
$date = new Carbon; $date = new Carbon;
$range = $this->get('daterange'); $range = $this->get('daterange');
$parts = explode(' - ', (string)$range); $parts = explode(' - ', (string)$range);
if (2 === count($parts)) { if (2 === \count($parts)) {
try { try {
$date = new Carbon($parts[0]); $date = new Carbon($parts[0]);
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
@@ -190,7 +190,7 @@ class ReportFormRequest extends Request
$repository = app(TagRepositoryInterface::class); $repository = app(TagRepositoryInterface::class);
$set = $this->get('tag'); $set = $this->get('tag');
$collection = new Collection; $collection = new Collection;
if (is_array($set)) { if (\is_array($set)) {
foreach ($set as $tagTag) { foreach ($set as $tagTag) {
$tag = $repository->findByTag($tagTag); $tag = $repository->findByTag($tagTag);
if (null !== $tag->id) { if (null !== $tag->id) {

View File

@@ -198,7 +198,6 @@ class BunqConfigurator implements ConfiguratorInterface
$job = $this->repository->setExtendedStatus($job, $extendedStatus); $job = $this->repository->setExtendedStatus($job, $extendedStatus);
$this->job = $job; $this->job = $job;
return;
} }
/** /**

View File

@@ -237,7 +237,7 @@ class FileConfigurator implements ConfiguratorInterface
break; break;
} }
if (false === $class || 0 === strlen($class)) { if (false === $class || 0 === \strlen($class)) {
throw new FireflyException(sprintf('Cannot handle job stage "%s" in getConfigurationClass().', $stage)); throw new FireflyException(sprintf('Cannot handle job stage "%s" in getConfigurationClass().', $stage));
} }
if (!class_exists($class)) { if (!class_exists($class)) {
@@ -271,6 +271,5 @@ class FileConfigurator implements ConfiguratorInterface
{ {
$this->repository->setExtendedStatus($this->job, $extended); $this->repository->setExtendedStatus($this->job, $extended);
return;
} }
} }

View File

@@ -219,7 +219,6 @@ class SpectreConfigurator implements ConfiguratorInterface
$job = $this->repository->setExtendedStatus($job, $extendedStatus); $job = $this->repository->setExtendedStatus($job, $extendedStatus);
$this->job = $job; $this->job = $job;
return;
} }
/** /**

View File

@@ -49,7 +49,7 @@ class Amount implements ConverterInterface
$original = $value; $original = $value;
$value = (string)$value; $value = (string)$value;
$value = $this->stripAmount($value); $value = $this->stripAmount($value);
$len = strlen($value); $len = \strlen($value);
$decimalPosition = $len - 3; $decimalPosition = $len - 3;
$altPosition = $len - 2; $altPosition = $len - 2;
$decimal = null; $decimal = null;
@@ -99,7 +99,7 @@ class Amount implements ConverterInterface
Log::debug(sprintf('No decimal character found. Converted amount from "%s" to "%s".', $original, $value)); Log::debug(sprintf('No decimal character found. Converted amount from "%s" to "%s".', $original, $value));
} }
return strval(number_format(round(floatval($value), 12), 12, '.', '')); return (string)number_format(round(floatval($value), 12), 12, '.', '');
} }
/** /**
@@ -110,7 +110,7 @@ class Amount implements ConverterInterface
private function stripAmount(string $value): string private function stripAmount(string $value): string
{ {
$str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value); $str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value);
$len = strlen($str); $len = \strlen($str);
if ('(' === $str[0] && ')' === $str[$len - 1]) { if ('(' === $str[0] && ')' === $str[$len - 1]) {
$str = '-' . substr($str, 1, $len - 2); $str = '-' . substr($str, 1, $len - 2);
} }

View File

@@ -176,7 +176,7 @@ class CsvProcessor implements FileProcessorInterface
$mapped = $config['column-mapping-config'][$index][$value] ?? null; $mapped = $config['column-mapping-config'][$index][$value] ?? null;
// throw error when not a valid converter. // throw error when not a valid converter.
if (!in_array($role, $this->validConverters)) { if (!\in_array($role, $this->validConverters)) {
throw new FireflyException(sprintf('"%s" is not a valid role.', $role)); throw new FireflyException(sprintf('"%s" is not a valid role.', $role));
} }
@@ -313,7 +313,7 @@ class CsvProcessor implements FileProcessorInterface
*/ */
foreach ($row as $rowIndex => $value) { foreach ($row as $rowIndex => $value) {
$value = trim((string)$value); $value = trim((string)$value);
if (strlen($value) > 0) { if (\strlen($value) > 0) {
$annotated = $this->annotateValue($rowIndex, $value); $annotated = $this->annotateValue($rowIndex, $value);
Log::debug('Annotated value', $annotated); Log::debug('Annotated value', $annotated);
$journal->setValue($annotated); $journal->setValue($annotated);
@@ -358,7 +358,7 @@ class CsvProcessor implements FileProcessorInterface
$config = $this->getConfig(); $config = $this->getConfig();
$names = array_keys($config['specifics'] ?? []); $names = array_keys($config['specifics'] ?? []);
foreach ($names as $name) { foreach ($names as $name) {
if (!in_array($name, $this->validSpecifics)) { if (!\in_array($name, $this->validSpecifics)) {
throw new FireflyException(sprintf('"%s" is not a valid class name', $name)); throw new FireflyException(sprintf('"%s" is not a valid class name', $name));
} }

View File

@@ -64,8 +64,8 @@ class CommandHandler extends AbstractProcessingHandler
{ {
$level = strtoupper($level); $level = strtoupper($level);
$reference = sprintf('\Monolog\Logger::%s', $level); $reference = sprintf('\Monolog\Logger::%s', $level);
if (defined($reference)) { if (\defined($reference)) {
$this->setLevel(constant($reference)); $this->setLevel(\constant($reference));
} }
} }
} }

View File

@@ -46,10 +46,10 @@ class AssetAccountIbans implements MapperInterface
foreach ($set as $account) { foreach ($set as $account) {
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
$accountId = (int)$account->id; $accountId = (int)$account->id;
if (strlen($iban) > 0) { if (\strlen($iban) > 0) {
$topList[$accountId] = $account->iban . ' (' . $account->name . ')'; $topList[$accountId] = $account->iban . ' (' . $account->name . ')';
} }
if (0 === strlen($iban)) { if (0 === \strlen($iban)) {
$list[$accountId] = $account->name; $list[$accountId] = $account->name;
} }
} }

View File

@@ -46,7 +46,7 @@ class AssetAccounts implements MapperInterface
$accountId = (int)$account->id; $accountId = (int)$account->id;
$name = $account->name; $name = $account->name;
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
if (strlen($iban) > 0) { if (\strlen($iban) > 0) {
$name .= ' (' . $iban . ')'; $name .= ' (' . $iban . ')';
} }
$list[$accountId] = $name; $list[$accountId] = $name;

View File

@@ -52,10 +52,10 @@ class OpposingAccountIbans implements MapperInterface
foreach ($set as $account) { foreach ($set as $account) {
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
$accountId = (int)$account->id; $accountId = (int)$account->id;
if (strlen($iban) > 0) { if (\strlen($iban) > 0) {
$topList[$accountId] = $account->iban . ' (' . $account->name . ')'; $topList[$accountId] = $account->iban . ' (' . $account->name . ')';
} }
if (0 === strlen($iban)) { if (0 === \strlen($iban)) {
$list[$accountId] = $account->name; $list[$accountId] = $account->name;
} }
} }

View File

@@ -52,7 +52,7 @@ class OpposingAccounts implements MapperInterface
$accountId = (int)$account->id; $accountId = (int)$account->id;
$name = $account->name; $name = $account->name;
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
if (strlen($iban) > 0) { if (\strlen($iban) > 0) {
$name .= ' (' . $iban . ')'; $name .= ' (' . $iban . ')';
} }
$list[$accountId] = $name; $list[$accountId] = $name;

View File

@@ -36,7 +36,7 @@ class TagsComma implements PreProcessorInterface
{ {
$set = explode(',', $value); $set = explode(',', $value);
$set = array_map('trim', $set); $set = array_map('trim', $set);
$set = array_filter($set, 'strlen'); $set = array_filter($set, '\strlen');
return array_values($set); return array_values($set);
} }

View File

@@ -36,7 +36,7 @@ class TagsSpace implements PreProcessorInterface
{ {
$set = explode(' ', $value); $set = explode(' ', $value);
$set = array_map('trim', $set); $set = array_map('trim', $set);
$set = array_filter($set, 'strlen'); $set = array_filter($set, '\strlen');
return array_values($set); return array_values($set);
} }

View File

@@ -195,7 +195,7 @@ class ImportAccount
*/ */
private function findByIBAN(AccountType $type): ?Account private function findByIBAN(AccountType $type): ?Account
{ {
if (3 === count($this->accountIban)) { if (3 === \count($this->accountIban)) {
$accounts = $this->repository->getAccountsByType([$type->type]); $accounts = $this->repository->getAccountsByType([$type->type]);
$iban = $this->accountIban['value']; $iban = $this->accountIban['value'];
Log::debug(sprintf('Finding account of type %d and IBAN %s', $type->id, $iban)); Log::debug(sprintf('Finding account of type %d and IBAN %s', $type->id, $iban));
@@ -233,7 +233,7 @@ class ImportAccount
*/ */
private function findById(AccountType $type): ?Account private function findById(AccountType $type): ?Account
{ {
if (3 === count($this->accountId)) { if (3 === \count($this->accountId)) {
Log::debug(sprintf('Finding account of type %d and ID %d', $type->id, $this->accountId['value'])); Log::debug(sprintf('Finding account of type %d and ID %d', $type->id, $this->accountId['value']));
/** @var Account $account */ /** @var Account $account */
$account = $this->user->accounts() $account = $this->user->accounts()
@@ -263,7 +263,7 @@ class ImportAccount
private function findByName(AccountType $type): ?Account private function findByName(AccountType $type): ?Account
{ {
// Three: find by name (and type): // Three: find by name (and type):
if (3 === count($this->accountName)) { if (3 === \count($this->accountName)) {
$accounts = $this->repository->getAccountsByType([$type->type]); $accounts = $this->repository->getAccountsByType([$type->type]);
$name = $this->accountName['value']; $name = $this->accountName['value'];
Log::debug(sprintf('Finding account of type %d and name %s', $type->id, $name)); Log::debug(sprintf('Finding account of type %d and name %s', $type->id, $name));
@@ -351,7 +351,7 @@ class ImportAccount
private function getMappedObject(array $array): ?Account private function getMappedObject(array $array): ?Account
{ {
Log::debug('In getMappedObject() for Account'); Log::debug('In getMappedObject() for Account');
if (0 === count($array)) { if (0 === \count($array)) {
Log::debug('Array is empty, nothing will come of this.'); Log::debug('Array is empty, nothing will come of this.');
return null; return null;

View File

@@ -105,7 +105,7 @@ class ImportBill
*/ */
private function findById(): ?Bill private function findById(): ?Bill
{ {
if (3 === count($this->id)) { if (3 === \count($this->id)) {
Log::debug(sprintf('Finding bill with ID #%d', $this->id['value'])); Log::debug(sprintf('Finding bill with ID #%d', $this->id['value']));
/** @var Bill $bill */ /** @var Bill $bill */
$bill = $this->repository->find((int)$this->id['value']); $bill = $this->repository->find((int)$this->id['value']);
@@ -125,7 +125,7 @@ class ImportBill
*/ */
private function findByName(): ?Bill private function findByName(): ?Bill
{ {
if (3 === count($this->name)) { if (3 === \count($this->name)) {
$bills = $this->repository->getBills(); $bills = $this->repository->getBills();
$name = $this->name['value']; $name = $this->name['value'];
Log::debug(sprintf('Finding bill with name %s', $name)); Log::debug(sprintf('Finding bill with name %s', $name));
@@ -201,7 +201,7 @@ class ImportBill
private function getMappedObject(array $array): ?Bill private function getMappedObject(array $array): ?Bill
{ {
Log::debug('In getMappedObject() for Bill'); Log::debug('In getMappedObject() for Bill');
if (0 === count($array)) { if (0 === \count($array)) {
Log::debug('Array is empty, nothing will come of this.'); Log::debug('Array is empty, nothing will come of this.');
return null; return null;
@@ -250,7 +250,7 @@ class ImportBill
} }
$name = $this->name['value'] ?? ''; $name = $this->name['value'] ?? '';
if (0 === strlen($name)) { if (0 === \strlen($name)) {
return true; return true;
} }

View File

@@ -94,7 +94,7 @@ class ImportBudget
*/ */
private function findById(): ?Budget private function findById(): ?Budget
{ {
if (3 === count($this->id)) { if (3 === \count($this->id)) {
Log::debug(sprintf('Finding budget with ID #%d', $this->id['value'])); Log::debug(sprintf('Finding budget with ID #%d', $this->id['value']));
/** @var Budget $budget */ /** @var Budget $budget */
$budget = $this->repository->findNull((int)$this->id['value']); $budget = $this->repository->findNull((int)$this->id['value']);
@@ -114,7 +114,7 @@ class ImportBudget
*/ */
private function findByName(): ?Budget private function findByName(): ?Budget
{ {
if (3 === count($this->name)) { if (3 === \count($this->name)) {
$budgets = $this->repository->getBudgets(); $budgets = $this->repository->getBudgets();
$name = $this->name['value']; $name = $this->name['value'];
Log::debug(sprintf('Finding budget with name %s', $name)); Log::debug(sprintf('Finding budget with name %s', $name));
@@ -190,7 +190,7 @@ class ImportBudget
private function getMappedObject(array $array): ?Budget private function getMappedObject(array $array): ?Budget
{ {
Log::debug('In getMappedObject() for Budget'); Log::debug('In getMappedObject() for Budget');
if (0 === count($array)) { if (0 === \count($array)) {
Log::debug('Array is empty, nothing will come of this.'); Log::debug('Array is empty, nothing will come of this.');
return null; return null;
@@ -239,7 +239,7 @@ class ImportBudget
} }
$name = $this->name['value'] ?? ''; $name = $this->name['value'] ?? '';
if (0 === strlen($name)) { if (0 === \strlen($name)) {
return true; return true;
} }

View File

@@ -96,7 +96,7 @@ class ImportCategory
*/ */
private function findById(): ?Category private function findById(): ?Category
{ {
if (3 === count($this->id)) { if (3 === \count($this->id)) {
Log::debug(sprintf('Finding category with ID #%d', $this->id['value'])); Log::debug(sprintf('Finding category with ID #%d', $this->id['value']));
/** @var Category $category */ /** @var Category $category */
$category = $this->repository->findNull((int)$this->id['value']); $category = $this->repository->findNull((int)$this->id['value']);
@@ -118,7 +118,7 @@ class ImportCategory
*/ */
private function findByName(): ?Category private function findByName(): ?Category
{ {
if (3 === count($this->name)) { if (3 === \count($this->name)) {
$categories = $this->repository->getCategories(); $categories = $this->repository->getCategories();
$name = $this->name['value']; $name = $this->name['value'];
Log::debug(sprintf('Finding category with name %s', $name)); Log::debug(sprintf('Finding category with name %s', $name));
@@ -195,7 +195,7 @@ class ImportCategory
private function getMappedObject(array $array): ?Category private function getMappedObject(array $array): ?Category
{ {
Log::debug('In getMappedObject() for Category'); Log::debug('In getMappedObject() for Category');
if (0 === count($array)) { if (0 === \count($array)) {
Log::debug('Array is empty, nothing will come of this.'); Log::debug('Array is empty, nothing will come of this.');
return null; return null;
@@ -244,7 +244,7 @@ class ImportCategory
} }
$name = $this->name['value'] ?? ''; $name = $this->name['value'] ?? '';
if (0 === strlen($name)) { if (0 === \strlen($name)) {
return true; return true;
} }

View File

@@ -201,7 +201,7 @@ class ImportCurrency
private function getMappedObject(array $array): ?TransactionCurrency private function getMappedObject(array $array): ?TransactionCurrency
{ {
Log::debug('In getMappedObject()'); Log::debug('In getMappedObject()');
if (0 === count($array)) { if (0 === \count($array)) {
Log::debug('Array is empty, nothing will come of this.'); Log::debug('Array is empty, nothing will come of this.');
return null; return null;

View File

@@ -224,7 +224,7 @@ class ImportJournal
*/ */
public function getMetaString(string $field): ?string public function getMetaString(string $field): ?string
{ {
if (isset($this->metaFields[$field]) && strlen($this->metaFields[$field]) > 0) { if (isset($this->metaFields[$field]) && \strlen($this->metaFields[$field]) > 0) {
return (string)$this->metaFields[$field]; return (string)$this->metaFields[$field];
} }
@@ -278,7 +278,7 @@ class ImportJournal
case 'sepa-ep': case 'sepa-ep':
case 'sepa-ci': case 'sepa-ci':
$value = trim((string)$array['value']); $value = trim((string)$array['value']);
if (strlen($value) > 0) { if (\strlen($value) > 0) {
$this->metaFields[$array['role']] = $value; $this->metaFields[$array['role']] = $value;
} }
break; break;
@@ -411,11 +411,11 @@ class ImportJournal
$info = $this->selectAmountInput(); $info = $this->selectAmountInput();
if (0 === count($info)) { if (0 === \count($info)) {
throw new FireflyException('No amount information for this row.'); throw new FireflyException('No amount information for this row.');
} }
$class = $info['class'] ?? ''; $class = $info['class'] ?? '';
if (0 === strlen($class)) { if (0 === \strlen($class)) {
throw new FireflyException('No amount information (conversion class) for this row.'); throw new FireflyException('No amount information (conversion class) for this row.');
} }

View File

@@ -84,7 +84,6 @@ class FilePrerequisites implements PrerequisitesInterface
{ {
$this->user = $user; $this->user = $user;
return;
} }
/** /**

View File

@@ -96,7 +96,6 @@ class SpectrePrerequisites implements PrerequisitesInterface
{ {
$this->user = $user; $this->user = $user;
return;
} }
/** /**
@@ -144,7 +143,6 @@ class SpectrePrerequisites implements PrerequisitesInterface
Preferences::setForUser($this->user, 'spectre_public_key', $pubKey['key']); Preferences::setForUser($this->user, 'spectre_public_key', $pubKey['key']);
Log::debug('Created key pair'); Log::debug('Created key pair');
return;
} }
/** /**

View File

@@ -314,8 +314,6 @@ class BunqRoutine implements RoutineInterface
* @param string $expectedType * @param string $expectedType
* *
* @return Account * @return Account
* @throws \FireflyIII\Exceptions\FireflyException
* @throws FireflyException
*/ */
private function convertToAccount(LabelMonetaryAccount $party, string $expectedType): Account private function convertToAccount(LabelMonetaryAccount $party, string $expectedType): Account
{ {
@@ -541,7 +539,6 @@ class BunqRoutine implements RoutineInterface
* *
* @return string * @return string
* *
* @throws FireflyException
*/ */
private function getRemoteIp(): ?string private function getRemoteIp(): ?string
{ {
@@ -602,7 +599,7 @@ class BunqRoutine implements RoutineInterface
$journals = new Collection; $journals = new Collection;
$config = $this->getConfig(); $config = $this->getConfig();
foreach ($payments as $accountId => $data) { foreach ($payments as $accountId => $data) {
Log::debug(sprintf('Now running for bunq account #%d with %d payment(s).', $accountId, count($data['payments']))); Log::debug(sprintf('Now running for bunq account #%d with %d payment(s).', $accountId, \count($data['payments'])));
/** @var Payment $payment */ /** @var Payment $payment */
foreach ($data['payments'] as $index => $payment) { foreach ($data['payments'] as $index => $payment) {
Log::debug(sprintf('Now at payment #%d with ID #%d', $index, $payment->getId())); Log::debug(sprintf('Now at payment #%d with ID #%d', $index, $payment->getId()));
@@ -808,7 +805,7 @@ class BunqRoutine implements RoutineInterface
Log::debug(sprintf('Will try to get transactions for company #%d', $user->getId())); Log::debug(sprintf('Will try to get transactions for company #%d', $user->getId()));
} }
$this->addTotalSteps(count($config['accounts']) * 2); $this->addTotalSteps(\count($config['accounts']) * 2);
foreach ($config['accounts'] as $accountData) { foreach ($config['accounts'] as $accountData) {
$this->addStep(); $this->addStep();

View File

@@ -505,7 +505,7 @@ class SpectreRoutine implements RoutineInterface
Log::debug('Looping journals...'); Log::debug('Looping journals...');
$journalIds = $storage->journals->pluck('id')->toArray(); $journalIds = $storage->journals->pluck('id')->toArray();
$tagId = $tag->id; $tagId = $tag->id;
$this->addTotalSteps(count($journalIds)); $this->addTotalSteps(\count($journalIds));
foreach ($journalIds as $journalId) { foreach ($journalIds as $journalId) {
Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId)); Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId));
@@ -551,7 +551,7 @@ class SpectreRoutine implements RoutineInterface
'import_id' => $importId, 'import_id' => $importId,
'transactions' => $transactions, 'transactions' => $transactions,
]; ];
$count += count($transactions); $count += \count($transactions);
} }
Log::debug(sprintf('Total number of transactions: %d', $count)); Log::debug(sprintf('Total number of transactions: %d', $count));
$this->addStep(); $this->addStep();

View File

@@ -136,7 +136,7 @@ class AbnAmroDescription implements SpecificInterface
// SEPA plain descriptions contain several key-value pairs, split by a colon // SEPA plain descriptions contain several key-value pairs, split by a colon
preg_match_all('/([A-Za-z]+(?=:\s)):\s([A-Za-z 0-9._#-]+(?=\s|$))/', $this->row[7], $matches, PREG_SET_ORDER); preg_match_all('/([A-Za-z]+(?=:\s)):\s([A-Za-z 0-9._#-]+(?=\s|$))/', $this->row[7], $matches, PREG_SET_ORDER);
if (is_array($matches)) { if (\is_array($matches)) {
foreach ($matches as $match) { foreach ($matches as $match) {
$key = $match[1]; $key = $match[1];
$value = trim($match[2]); $value = trim($match[2]);
@@ -163,7 +163,7 @@ class AbnAmroDescription implements SpecificInterface
// Set a new description for the current transaction. If none was given // Set a new description for the current transaction. If none was given
// set the description to type, name and reference // set the description to type, name and reference
$this->row[7] = $newDescription; $this->row[7] = $newDescription;
if (0 === strlen($newDescription)) { if (0 === \strlen($newDescription)) {
$this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference); $this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference);
} }
@@ -189,7 +189,7 @@ class AbnAmroDescription implements SpecificInterface
// Search for properties specified in the TRTP format. If no description // Search for properties specified in the TRTP format. If no description
// is provided, use the type, name and reference as new description // is provided, use the type, name and reference as new description
if (is_array($matches)) { if (\is_array($matches)) {
foreach ($matches as $match) { foreach ($matches as $match) {
$key = $match[1]; $key = $match[1];
$value = trim($match[2]); $value = trim($match[2]);
@@ -218,7 +218,7 @@ class AbnAmroDescription implements SpecificInterface
// Set a new description for the current transaction. If none was given // Set a new description for the current transaction. If none was given
// set the description to type, name and reference // set the description to type, name and reference
$this->row[7] = $newDescription; $this->row[7] = $newDescription;
if (0 === strlen($newDescription)) { if (0 === \strlen($newDescription)) {
$this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference); $this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference);
} }
} }

View File

@@ -61,7 +61,7 @@ class IngDescription implements SpecificInterface
public function run(array $row): array public function run(array $row): array
{ {
$this->row = array_values($row); $this->row = array_values($row);
if (count($this->row) >= 8) { // check if the array is correct if (\count($this->row) >= 8) { // check if the array is correct
switch ($this->row[4]) { // Get value for the mutation type switch ($this->row[4]) { // Get value for the mutation type
case 'GT': // InternetBankieren case 'GT': // InternetBankieren
case 'OV': // Overschrijving case 'OV': // Overschrijving
@@ -127,7 +127,7 @@ class IngDescription implements SpecificInterface
private function copyDescriptionToOpposite(): void private function copyDescriptionToOpposite(): void
{ {
$search = ['Naar Oranje Spaarrekening ', 'Afschrijvingen']; $search = ['Naar Oranje Spaarrekening ', 'Afschrijvingen'];
if (0 === strlen($this->row[3])) { if (0 === \strlen($this->row[3])) {
$this->row[3] = trim(str_ireplace($search, '', $this->row[8])); $this->row[3] = trim(str_ireplace($search, '', $this->row[8]));
} }
} }

View File

@@ -53,7 +53,7 @@ class PresidentsChoice implements SpecificInterface
$row = array_values($row); $row = array_values($row);
// first, if column 2 is empty and 3 is not, do nothing. // first, if column 2 is empty and 3 is not, do nothing.
// if column 3 is empty and column 2 is not, move amount to column 3, *-1 // if column 3 is empty and column 2 is not, move amount to column 3, *-1
if (isset($row[3]) && 0 === strlen($row[3])) { if (isset($row[3]) && 0 === \strlen($row[3])) {
$row[3] = bcmul($row[2], '-1'); $row[3] = bcmul($row[2], '-1');
} }
if (isset($row[1])) { if (isset($row[1])) {

Some files were not shown because too many files have changed in this diff Show More