Various code cleanup.

This commit is contained in:
James Cole 2017-12-22 18:32:43 +01:00
parent f13a93348f
commit 8bd76d1ff0
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
188 changed files with 383 additions and 396 deletions

View File

@ -25,7 +25,6 @@ namespace FireflyIII\Console\Commands;
use Artisan;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Logging\CommandHandler;
use FireflyIII\Import\Routine\ImportRoutine;
use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
@ -75,6 +74,7 @@ class CreateImport extends Command
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five exactly.
*
* @throws FireflyException
*/
public function handle()
@ -133,7 +133,7 @@ class CreateImport extends Command
$monolog->pushHandler($handler);
// start the actual routine:
$type = $job->file_type === 'csv' ? 'file' : $job->file_type;
$type = 'csv' === $job->file_type ? 'file' : $job->file_type;
$key = sprintf('import.routine.%s', $type);
$className = config($key);
if (null === $className || !class_exists($className)) {

View File

@ -24,7 +24,6 @@ namespace FireflyIII\Console\Commands;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Logging\CommandHandler;
use FireflyIII\Import\Routine\ImportRoutine;
use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Models\ImportJob;
use Illuminate\Console\Command;
@ -60,6 +59,8 @@ class Import extends Command
/**
* Run the import routine.
*
* @throws FireflyException
*/
public function handle()
{
@ -84,7 +85,7 @@ class Import extends Command
$monolog->pushHandler($handler);
// actually start job:
$type = $job->file_type === 'csv' ? 'file' : $job->file_type;
$type = 'csv' === $job->file_type ? 'file' : $job->file_type;
$key = sprintf('import.routine.%s', $type);
$className = config($key);
if (null === $className || !class_exists($className)) {

View File

@ -26,8 +26,6 @@ use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;

View File

@ -111,10 +111,10 @@ class VerifyDatabase extends Command
$token = $user->generateAccessToken();
Preferences::setForUser($user, 'access_token', $token);
$this->line(sprintf('Generated access token for user %s', $user->email));
$count++;
++$count;
}
}
if ($count === 0) {
if (0 === $count) {
$this->info('All access tokens OK!');
}
}
@ -138,12 +138,12 @@ class VerifyDatabase extends Command
$link->name = $name;
$link->outward = $values[0];
$link->inward = $values[1];
$count++;
++$count;
}
$link->editable = false;
$link->save();
}
if ($count === 0) {
if (0 === $count) {
$this->info('All link types OK!');
}
}
@ -158,7 +158,7 @@ class VerifyDatabase extends Command
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var stdClass $entry */
foreach ($journals as $entry) {
if (bccomp(strval($entry->the_sum), '0') !== 0) {
if (0 !== bccomp(strval($entry->the_sum), '0')) {
$errored[] = $entry->transaction_journal_id;
}
}
@ -167,14 +167,14 @@ class VerifyDatabase extends Command
$res = Transaction::whereNull('deleted_at')->where('transaction_journal_id', $journalId)->groupBy('amount')->get([DB::raw('MIN(id) as first_id')]);
$ids = $res->pluck('first_id')->toArray();
DB::table('transactions')->whereIn('id', $ids)->update(['amount' => DB::raw('amount * -1')]);
$count++;
++$count;
// report about it
/** @var TransactionJournal $journal */
$journal = TransactionJournal::find($journalId);
if (is_null($journal)) {
continue;
}
if ($journal->transactionType->type === TransactionType::OPENING_BALANCE) {
if (TransactionType::OPENING_BALANCE === $journal->transactionType->type) {
$this->error(
sprintf(
'Transaction #%d was stored incorrectly. One of your asset accounts may show the wrong balance. Please visit /transactions/show/%d to verify the opening balance.',
@ -182,7 +182,7 @@ class VerifyDatabase extends Command
)
);
}
if ($journal->transactionType->type !== TransactionType::OPENING_BALANCE) {
if (TransactionType::OPENING_BALANCE !== $journal->transactionType->type) {
$this->error(
sprintf(
'Transaction #%d was stored incorrectly. Could be that the transaction shows the wrong amount. Please visit /transactions/show/%d to verify the opening balance.',
@ -191,7 +191,7 @@ class VerifyDatabase extends Command
);
}
}
if ($count === 0) {
if (0 === $count) {
$this->info('Amount integrity OK!');
}
@ -371,9 +371,9 @@ class VerifyDatabase extends Command
'Error: Transaction #' . $entry->transaction_id . ' should have been deleted, but has not.' .
' Find it in the table called "transactions" and change the "deleted_at" field to: "' . $entry->journal_deleted . '"'
);
$count++;
++$count;
}
if ($count === 0) {
if (0 === $count) {
$this->info('No orphaned transactions!');
}
}
@ -393,9 +393,9 @@ class VerifyDatabase extends Command
$this->error(
'Error: Journal #' . $entry->id . ' has zero transactions. Open table "transaction_journals" and delete the entry with id #' . $entry->id
);
$count++;
++$count;
}
if ($count === 0) {
if (0 === $count) {
$this->info('No orphaned journals!');
}
}

View File

@ -81,6 +81,7 @@ class Handler extends ExceptionHandler
* @param \Exception $exception
*
* @return mixed|void
*
* @throws Exception
*/
public function report(Exception $exception)

View File

@ -52,6 +52,7 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/**
* @return bool
*
* @throws \TypeError
*/
public function run(): bool

View File

@ -31,7 +31,6 @@ use Illuminate\Support\Collection;
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
/** @var Collection */
private $accounts;
/** @var Carbon */
@ -43,6 +42,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* @return string
*
* @throws \Throwable
*/
public function generate(): string

View File

@ -32,7 +32,8 @@ class MultiYearReportGenerator extends MonthReportGenerator
/**
* @return string
*/
protected function preferredPeriod(): string {
protected function preferredPeriod(): string
{
return 'year';
}
}

View File

@ -32,7 +32,8 @@ class YearReportGenerator extends MonthReportGenerator
/**
* @return string
*/
protected function preferredPeriod(): string {
protected function preferredPeriod(): string
{
return 'month';
}
}

View File

@ -41,6 +41,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* @return string
*
* @throws \Throwable
*/
public function generate(): string

View File

@ -40,6 +40,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* @return string
*
* @throws \Throwable
*/
public function generate(): string

View File

@ -40,6 +40,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* @return string
*
* @throws \Throwable
*/
public function generate(): string

View File

@ -86,7 +86,7 @@ class UserEventHandler
return true;
}
// user is only user but has admin role
if ($count === 1 && $user->hasRole('owner')) {
if (1 === $count && $user->hasRole('owner')) {
Log::debug(sprintf('User #%d is only user but has role owner so all is well.', $user->id));
return true;

View File

@ -41,40 +41,14 @@ class BillLine
/** @var string */
protected $min;
/** @var Carbon */
private $endOfPayDate;
/** @var Carbon */
private $lastHitDate;
/** @var Carbon */
private $payDate;
/** @var Carbon */
private $endOfPayDate;
/** @var int */
private $transactionJournalId;
/**
* @return Carbon
*/
public function getPayDate(): Carbon
{
return $this->payDate;
}
/**
* @return Carbon
*/
public function getEndOfPayDate(): Carbon
{
return $this->endOfPayDate;
}
/**
* @param Carbon $endOfPayDate
*/
public function setEndOfPayDate(Carbon $endOfPayDate): void
{
$this->endOfPayDate = $endOfPayDate;
}
/**
* BillLine constructor.
*/
@ -115,6 +89,22 @@ class BillLine
$this->bill = $bill;
}
/**
* @return Carbon
*/
public function getEndOfPayDate(): Carbon
{
return $this->endOfPayDate;
}
/**
* @param Carbon $endOfPayDate
*/
public function setEndOfPayDate(Carbon $endOfPayDate): void
{
$this->endOfPayDate = $endOfPayDate;
}
/**
* @return Carbon
*/
@ -163,6 +153,22 @@ class BillLine
$this->min = $min;
}
/**
* @return Carbon
*/
public function getPayDate(): Carbon
{
return $this->payDate;
}
/**
* @param Carbon $payDate
*/
public function setPayDate(Carbon $payDate): void
{
$this->payDate = $payDate;
}
/**
* @return int
*/
@ -202,12 +208,4 @@ class BillLine
{
$this->hit = $hit;
}
/**
* @param Carbon $payDate
*/
public function setPayDate(Carbon $payDate): void
{
$this->payDate = $payDate;
}
}

View File

@ -85,13 +85,6 @@ interface JournalCollectorInterface
*/
public function removeFilter(string $filter): JournalCollectorInterface;
/**
* @param Collection $accounts
*
* @return JournalCollectorInterface
*/
public function setOpposingAccounts(Collection $accounts): JournalCollectorInterface;
/**
* @param Collection $accounts
*
@ -167,6 +160,13 @@ interface JournalCollectorInterface
*/
public function setOffset(int $offset): JournalCollectorInterface;
/**
* @param Collection $accounts
*
* @return JournalCollectorInterface
*/
public function setOpposingAccounts(Collection $accounts): JournalCollectorInterface;
/**
* @param int $page
*

View File

@ -26,8 +26,6 @@ use Illuminate\Support\Collection;
/**
* Interface FilterInterface
*
* @package FireflyIII\Helpers\Filter
*/
interface FilterInterface
{

View File

@ -79,12 +79,12 @@ class ReportHelper implements ReportHelperInterface
/** @var Bill $bill */
foreach ($bills as $bill) {
$expectedDates = $repository->getPayDatesInRange($bill, $start, $end);
foreach($expectedDates as $payDate) {
foreach ($expectedDates as $payDate) {
$endOfPayPeriod = app('navigation')->endOfX($payDate, $bill->repeat_freq, null);
$collector = app(JournalCollectorInterface::class);
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($payDate, $endOfPayPeriod)->setBills($bills);
$journals = $collector->getJournals();
$journals = $collector->getJournals();
$billLine = new BillLine;
$billLine->setBill($bill);

View File

@ -43,6 +43,7 @@ use Session;
/**
* Class ReconcileController.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ReconcileController extends Controller
@ -72,7 +73,7 @@ class ReconcileController extends Controller
*/
public function edit(TransactionJournal $journal)
{
if ($journal->transactionType->type !== TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION !== $journal->transactionType->type) {
return redirect(route('transactions.edit', [$journal->id]));
}
// view related code
@ -99,7 +100,6 @@ class ReconcileController extends Controller
'accounts.reconcile.edit',
compact('journal', 'subTitle')
)->with('data', $preFilled);
}
/**
@ -166,6 +166,7 @@ class ReconcileController extends Controller
* @param Carbon|null $end
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*
* @throws FireflyException
*/
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
@ -226,7 +227,7 @@ class ReconcileController extends Controller
*/
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)
{
if ($journal->transactionType->type !== TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION !== $journal->transactionType->type) {
return redirect(route('transactions.show', [$journal->id]));
}
$subTitle = trans('firefly.reconciliation') . ' "' . $journal->description . '"';
@ -235,7 +236,6 @@ class ReconcileController extends Controller
$transaction = $repository->getAssetTransaction($journal);
$account = $transaction->account;
return view('accounts.reconcile.show', compact('journal', 'subTitle', 'transaction', 'account'));
}
@ -297,6 +297,7 @@ class ReconcileController extends Controller
* @param Carbon $end
*
* @return mixed
*
* @throws \Throwable
* @throws FireflyException
*/
@ -346,10 +347,10 @@ class ReconcileController extends Controller
*/
public function update(ReconciliationFormRequest $request, AccountRepositoryInterface $repository, TransactionJournal $journal)
{
if ($journal->transactionType->type !== TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION !== $journal->transactionType->type) {
return redirect(route('transactions.show', [$journal->id]));
}
if (bccomp('0', $request->get('amount')) === 0) {
if (0 === bccomp('0', $request->get('amount'))) {
Session::flash('error', trans('firefly.amount_cannot_be_zero'));
return redirect(route('accounts.reconcile.edit', [$journal->id]))->withInput();
@ -368,10 +369,8 @@ class ReconcileController extends Controller
// redirect to previous URL.
return redirect($this->getPreviousUri('reconcile.edit.uri'));
}
/**
* @param Account $account
*

View File

@ -152,6 +152,7 @@ class AccountController extends Controller
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @return View
*
* @throws FireflyException
* @throws FireflyException
* @throws FireflyException
@ -229,9 +230,9 @@ class AccountController extends Controller
$types = config('firefly.accountTypesByIdentifier.' . $what);
$collection = $repository->getAccountsByType($types);
$total = $collection->count();
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('listPageSize', 50)->data);
$accounts = $collection->slice(($page-1) * $pageSize, $pageSize);
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
unset($collection);
/** @var Carbon $start */
$start = clone session('start', Carbon::now()->startOfMonth());
@ -272,6 +273,7 @@ class AccountController extends Controller
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @throws FireflyException
*/
public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = '')

View File

@ -45,7 +45,6 @@ class HomeController extends Controller
$this->middleware(IsSandStormUser::class)->except(['index']);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/

View File

@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\LinkTypeFormRequest;
use FireflyIII\Models\LinkType;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;

View File

@ -149,6 +149,7 @@ class AttachmentController extends Controller
* @param Attachment $attachment
*
* @return \Illuminate\Http\Response
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function preview(Attachment $attachment)

View File

@ -65,6 +65,7 @@ class LoginController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response|void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function login(Request $request)

View File

@ -41,7 +41,6 @@ use Session;
*/
class RegisterController extends Controller
{
use RegistersUsers;
/**

View File

@ -69,7 +69,6 @@ class TwoFactorController extends Controller
/**
* @return mixed
*
*/
public function lostTwoFactor()
{

View File

@ -246,7 +246,6 @@ class BillController extends Controller
$transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('bills.show', [$bill->id]));
$bill->paidDates = $repository->getPaidDatesInRange($bill, $date, $end);
$bill->payDates = $repository->getPayDatesInRange($bill, $date, $end);
$lastPaidDate = $this->lastPaidDate($repository->getPaidDatesInRange($bill, $date, $end), $date);
@ -274,7 +273,6 @@ class BillController extends Controller
$request->session()->flash('success', strval(trans('firefly.stored_new_bill', ['name' => $bill->name])));
Preferences::mark();
/** @var array $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
$this->attachments->saveAttachmentsForModel($bill, $files);
@ -341,7 +339,7 @@ class BillController extends Controller
*/
private function lastPaidDate(Collection $dates, Carbon $default): Carbon
{
if ($dates->count() === 0) {
if (0 === $dates->count()) {
return $default; // @codeCoverageIgnore
}
$latest = $dates->first();
@ -353,6 +351,5 @@ class BillController extends Controller
}
return $latest;
}
}

View File

@ -85,7 +85,7 @@ class BudgetController extends Controller
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
if (bccomp($amount, '0') === 0) {
if (0 === bccomp($amount, '0')) {
$budgetLimit = null;
}
@ -302,7 +302,7 @@ class BudgetController extends Controller
$currentStart = app('navigation')->addPeriod($currentStart, $range, 0);
++$count;
}
if ($count === 0) {
if (0 === $count) {
$count = 1; // @codeCoverageIgnore
}
$result['available'] = bcdiv($total, strval($count));

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
@ -341,7 +340,6 @@ class AccountController extends Controller
* @param Carbon $start
*
* @return \Illuminate\Http\JsonResponse
*
*/
public function period(Account $account, Carbon $start)
{

View File

@ -63,7 +63,6 @@ class ExpenseReportController extends Controller
);
}
/**
* @param Collection $accounts
* @param Collection $expense
@ -74,7 +73,6 @@ class ExpenseReportController extends Controller
*/
public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
$cache = new CacheProperties;
$cache->addProperty('chart.expense.report.main');
$cache->addProperty($accounts);
@ -82,7 +80,7 @@ class ExpenseReportController extends Controller
$cache->addProperty($start);
$cache->addProperty($end);
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
return Response::json($cache->get()); // @codeCoverageIgnore
}
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);

View File

@ -104,7 +104,7 @@ class HomeController extends Controller
*/
public function displayDebug(Request $request)
{
$phpVersion = str_replace('~','\~',PHP_VERSION);
$phpVersion = str_replace('~', '\~', PHP_VERSION);
$phpOs = php_uname();
$interface = PHP_SAPI;
$now = Carbon::create()->format('Y-m-d H:i:s e');

View File

@ -18,12 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
@ -66,6 +64,7 @@ class ConfigurationController extends Controller
* @param ImportJob $job
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*
* @throws FireflyException
*/
public function index(ImportJob $job)
@ -95,6 +94,7 @@ class ConfigurationController extends Controller
* @param ImportJob $job
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function post(Request $request, ImportJob $job)
@ -141,4 +141,4 @@ class ConfigurationController extends Controller
return $configurator;
}
}
}

View File

@ -18,16 +18,13 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Import\Routine\ImportRoutine;
use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
@ -61,7 +58,7 @@ class IndexController extends Controller
}
);
$this->middleware(IsDemoUser::class)->except(['create','index']);
$this->middleware(IsDemoUser::class)->except(['create', 'index']);
}
/**
@ -70,11 +67,12 @@ class IndexController extends Controller
* @param string $bank
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function create(string $bank)
{
if (!(config(sprintf('import.enabled.%s', $bank))) === true) {
if (true === !(config(sprintf('import.enabled.%s', $bank)))) {
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank));
}
@ -82,7 +80,6 @@ class IndexController extends Controller
// from here, always go to configure step.
return redirect(route('import.configure', [$importJob->key]));
}
/**
@ -139,11 +136,11 @@ class IndexController extends Controller
* @param ImportJob $job
*
* @return \Illuminate\Http\JsonResponse
*
* @throws FireflyException
*/
public function start(ImportJob $job)
{
$type = $job->file_type;
$key = sprintf('import.routine.%s', $type);
$className = config($key);
@ -162,5 +159,4 @@ class IndexController extends Controller
throw new FireflyException('Job did not complete successfully. Please review the log files.');
}
}
}

View File

@ -18,12 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Import\Prerequisites\PrerequisitesInterface;
@ -43,11 +41,12 @@ class PrerequisitesController extends Controller
* @param string $bank
*
* @return \Illuminate\Http\RedirectResponse|null
*
* @throws FireflyException
*/
public function index(string $bank)
{
if (!(config(sprintf('import.enabled.%s', $bank))) === true) {
if (true === !(config(sprintf('import.enabled.%s', $bank)))) {
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank));
}
$class = strval(config(sprintf('import.prerequisites.%s', $bank)));
@ -83,6 +82,7 @@ class PrerequisitesController extends Controller
* @param string $bank
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function post(Request $request, string $bank)
@ -112,6 +112,4 @@ class PrerequisitesController extends Controller
return redirect(route('import.create-job', [$bank]));
}
}
}

View File

@ -18,12 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
@ -34,7 +32,6 @@ use Response;
*/
class StatusController extends Controller
{
/**
*
*/
@ -115,5 +112,4 @@ class StatusController extends Controller
return Response::json($result);
}
}
}

View File

@ -88,7 +88,6 @@ class JavascriptController extends Controller
/**
* @param Request $request
*
* @param AccountRepositoryInterface $repository
* @param CurrencyRepositoryInterface $currencyRepository
*
@ -141,7 +140,7 @@ class JavascriptController extends Controller
$end = session('end');
$first = session('first');
$title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));
$isCustom = session('is_custom_range', false) === true;
$isCustom = true === session('is_custom_range', false);
$today = new Carbon;
$ranges = [
// first range is the current range:
@ -182,7 +181,6 @@ class JavascriptController extends Controller
$index = strval(trans('firefly.everything'));
$ranges[$index] = [$first, new Carbon];
$return = [
'title' => $title,
'configuration' => [

View File

@ -36,6 +36,7 @@ class FrontpageController extends Controller
* @param PiggyBankRepositoryInterface $repository
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function piggyBanks(PiggyBankRepositoryInterface $repository)

View File

@ -46,6 +46,7 @@ class JsonController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function action(Request $request)
@ -121,6 +122,7 @@ class JsonController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function trigger(Request $request)

View File

@ -395,7 +395,6 @@ class PiggyBankController extends Controller
}
$piggyBank = $repository->store($data);
Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name])));
Preferences::mark();

View File

@ -71,6 +71,7 @@ class PreferencesController extends Controller
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Exception
* @throws \Exception
*/
@ -91,19 +92,19 @@ class PreferencesController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
$listPageSize = Preferences::get('listPageSize', 50)->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$showDeps = Preferences::get('showDepositsFrontpage', false)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
$has2faSecret = null !== Preferences::get('twoFactorAuthSecret'); // hasTwoFactorAuthSecret
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
$listPageSize = Preferences::get('listPageSize', 50)->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$showDeps = Preferences::get('showDepositsFrontpage', false)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
$has2faSecret = null !== Preferences::get('twoFactorAuthSecret'); // hasTwoFactorAuthSecret
return view(
'preferences.index',

View File

@ -97,6 +97,7 @@ class ProfileController extends Controller
* @param string $token
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function confirmEmailChange(UserRepositoryInterface $repository, string $token)
@ -286,7 +287,7 @@ class ProfileController extends Controller
// found user.
// which email address to return to?
$set = Preferences::beginsWith($user, 'previous_email_');
$set = Preferences::beginsWith($user, 'previous_email_');
/** @var string $match */
$match = null;
foreach ($set as $entry) {

View File

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

View File

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

View File

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

View File

@ -40,6 +40,7 @@ class CategoryController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function expenses(Collection $accounts, Carbon $start, Carbon $end)
@ -72,6 +73,7 @@ class CategoryController extends Controller
* @param Collection $accounts
*
* @return string
*
* @throws \Throwable
*/
public function income(Collection $accounts, Carbon $start, Carbon $end)
@ -106,6 +108,7 @@ class CategoryController extends Controller
* @return mixed|string
*
* @internal param ReportHelperInterface $helper
*
* @throws \Throwable
*/
public function operations(Collection $accounts, Carbon $start, Carbon $end)

View File

@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Report;
@ -34,7 +33,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
/**
* Class ExpenseController
*/
@ -69,6 +67,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \Throwable
*/
public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@ -116,6 +115,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \Throwable
*/
public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@ -173,6 +173,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return array|mixed|string
*
* @throws \Throwable
*/
public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@ -193,7 +194,7 @@ class ExpenseController extends Controller
foreach ($combined as $name => $combi) {
/**
* @var string $name
* @var string
* @var Collection $combi
*/
$spent = $this->spentInPeriod($accounts, $combi, $start, $end);
@ -208,7 +209,6 @@ class ExpenseController extends Controller
return $result;
// for period, get spent and earned for each account (by name)
}
/**
@ -218,6 +218,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \Throwable
*/
public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@ -254,7 +255,6 @@ class ExpenseController extends Controller
return $result;
}
/**
* @param Collection $accounts
* @param Collection $expense
@ -262,6 +262,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@ -343,17 +344,16 @@ class ExpenseController extends Controller
$categoryName = $transaction->transaction_category_name;
$categoryId = intval($transaction->transaction_category_id);
// if null, grab from journal:
if ($categoryId === 0) {
if (0 === $categoryId) {
$categoryName = $transaction->transaction_journal_category_name;
$categoryId = intval($transaction->transaction_journal_category_id);
}
if ($categoryId !== 0) {
if (0 !== $categoryId) {
$categoryName = app('steam')->tryDecrypt($categoryName);
}
// if not set, set to zero:
if (!isset($sum[$categoryId][$currencyId])) {
$sum[$categoryId] = [
'grand_total' => '0',
'name' => $categoryName,
@ -371,7 +371,6 @@ class ExpenseController extends Controller
],
],
];
}
// add amount
@ -448,17 +447,16 @@ class ExpenseController extends Controller
$budgetName = $transaction->transaction_budget_name;
$budgetId = intval($transaction->transaction_budget_id);
// if null, grab from journal:
if ($budgetId === 0) {
if (0 === $budgetId) {
$budgetName = $transaction->transaction_journal_budget_name;
$budgetId = intval($transaction->transaction_journal_budget_id);
}
if ($budgetId !== 0) {
if (0 !== $budgetId) {
$budgetName = app('steam')->tryDecrypt($budgetName);
}
// if not set, set to zero:
if (!isset($sum[$budgetId][$currencyId])) {
$sum[$budgetId] = [
'grand_total' => '0',
'name' => $budgetName,
@ -510,17 +508,16 @@ class ExpenseController extends Controller
$categoryName = $transaction->transaction_category_name;
$categoryId = intval($transaction->transaction_category_id);
// if null, grab from journal:
if ($categoryId === 0) {
if (0 === $categoryId) {
$categoryName = $transaction->transaction_journal_category_name;
$categoryId = intval($transaction->transaction_journal_category_id);
}
if ($categoryId !== 0) {
if (0 !== $categoryId) {
$categoryName = app('steam')->tryDecrypt($categoryName);
}
// if not set, set to zero:
if (!isset($sum[$categoryId][$currencyId])) {
$sum[$categoryId] = [
'grand_total' => '0',
'name' => $categoryName,
@ -591,5 +588,4 @@ class ExpenseController extends Controller
return $sum;
}
}
}

View File

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

View File

@ -75,12 +75,13 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function accountReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', trans('firefly.end_after_start_date'));// @codeCoverageIgnore
return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore
}
if ($start < session('first')) {
@ -90,7 +91,7 @@ class ReportController extends Controller
View::share(
'subTitle', trans(
'firefly.report_default',
['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat),]
['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat)]
)
);
@ -108,6 +109,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function auditReport(Collection $accounts, Carbon $start, Carbon $end)
@ -144,6 +146,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
@ -181,6 +184,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
@ -217,6 +221,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function defaultReport(Collection $accounts, Carbon $start, Carbon $end)
@ -268,6 +273,7 @@ class ReportController extends Controller
* @param string $reportType
*
* @return mixed
*
* @throws \Throwable
*/
public function options(string $reportType)
@ -297,6 +303,7 @@ class ReportController extends Controller
* @param ReportFormRequest $request
*
* @return RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \FireflyIII\Exceptions\FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
@ -373,6 +380,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
@ -405,6 +413,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function accountReportOptions(): string
@ -428,6 +437,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function budgetReportOptions(): string
@ -442,6 +452,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function categoryReportOptions(): string
@ -456,6 +467,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function noReportOptions(): string
@ -465,6 +477,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function tagReportOptions(): string

View File

@ -72,6 +72,7 @@ class RuleController extends Controller
* @param RuleGroup $ruleGroup
*
* @return View
*
* @throws \Throwable
* @throws \Throwable
*/
@ -166,6 +167,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return View
*
* @throws \Throwable
* @throws \Throwable
* @throws \Throwable
@ -362,6 +364,7 @@ class RuleController extends Controller
* @param TestRuleFormRequest $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function testTriggers(TestRuleFormRequest $request)
@ -410,6 +413,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function testTriggersByRule(Rule $rule)
@ -535,6 +539,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return array
*
* @throws \Throwable
*/
private function getCurrentActions(Rule $rule)
@ -564,6 +569,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return array
*
* @throws \Throwable
*/
private function getCurrentTriggers(Rule $rule)
@ -595,6 +601,7 @@ class RuleController extends Controller
* @param Request $request
*
* @return array
*
* @throws \Throwable
*/
private function getPreviousActions(Request $request)
@ -625,6 +632,7 @@ class RuleController extends Controller
* @param Request $request
*
* @return array
*
* @throws \Throwable
*/
private function getPreviousTriggers(Request $request)

View File

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

View File

@ -128,6 +128,7 @@ class ConvertController extends Controller
* @param TransactionJournal $journal
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
* @throws FireflyException
*/

View File

@ -257,7 +257,7 @@ class SingleController extends Controller
$assetAccounts = $this->groupedAccountList();
$budgetList = ExpandedForm::makeSelectListWithEmpty($this->budgets->getBudgets());
if ($journal->transactionType->type === TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION === $journal->transactionType->type) {
return redirect(route('accounts.reconcile.edit', [$journal->id]));
}

View File

@ -116,7 +116,6 @@ class SplitController extends Controller
$accountArray[$account->id]['currency_id'] = intval($account->getMeta('currency_id'));
}
// put previous url in session if not redirect from store (not "return_to_edit").
if (true !== session('transactions.edit-split.fromUpdate')) {
$this->rememberPreviousUri('transactions.edit-split.uri');

View File

@ -69,6 +69,7 @@ class TransactionController extends Controller
* @param string $moment
*
* @return View
*
* @throws FireflyException
*/
public function index(Request $request, JournalRepositoryInterface $repository, string $what, string $moment = '')
@ -142,7 +143,8 @@ class TransactionController extends Controller
$repository->reconcile($transaction);
}
return Response::json(['ok'=>'reconciled']);
return Response::json(['ok' => 'reconciled']);
}
/**
@ -183,7 +185,7 @@ class TransactionController extends Controller
if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal);
}
if ($journal->transactionType->type === TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION === $journal->transactionType->type) {
return redirect(route('accounts.reconcile.show', [$journal->id])); // @codeCoverageIgnore
}
$linkTypes = $linkTypeRepository->get();
@ -200,7 +202,6 @@ class TransactionController extends Controller
* @param string $what
*
* @return Collection
*
*/
private function getPeriodOverview(string $what): Collection
{

View File

@ -45,9 +45,9 @@ class IsDemoUser
public function handle(Request $request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
// don't care when not logged in, usual stuff applies:
return $next($request);
}
// don't care when not logged in, usual stuff applies:
return $next($request);
}
/** @var User $user */
$user = auth()->user();
if ($user->hasRole('demo')) {

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
use Closure;
use FireflyIII\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Session;

View File

@ -84,6 +84,7 @@ class JournalFormRequest extends Request
/**
* @return array
*
* @throws FireflyException
*/
public function rules()

View File

@ -64,5 +64,4 @@ class ReconciliationFormRequest extends Request
return $rules;
}
}

View File

@ -171,6 +171,7 @@ class SpectreConfigurator implements ConfiguratorInterface
break;
case !$this->job->configuration['has-input-mandatory']:
$class = InputMandatory::class;
// no break
default:
break;
}

View File

@ -70,7 +70,7 @@ class Amount implements ConverterInterface
if (is_null($decimal)) {
Log::debug('Decimal is still NULL, probably number with >2 decimals. Search for a dot.');
$res = strrpos($value, '.');
if (!($res === false)) {
if (!(false === $res)) {
// blandly assume this is the one.
Log::debug(sprintf('Searched from the left for "." in amount "%s", assume this is the decimal sign.', $value));
$decimal = '.';

View File

@ -70,6 +70,7 @@ class CsvProcessor implements FileProcessorInterface
* Does the actual job.
*
* @return bool
*
* @throws \League\Csv\Exception
*/
public function run(): bool
@ -160,6 +161,7 @@ class CsvProcessor implements FileProcessorInterface
/**
* @return Iterator
*
* @throws \League\Csv\Exception
* @throws \League\Csv\Exception
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
@ -174,7 +176,7 @@ class CsvProcessor implements FileProcessorInterface
$delimiter = "\t";
}
$reader->setDelimiter($delimiter);
if($config['has-headers']) {
if ($config['has-headers']) {
$reader->setHeaderOffset(0);
}
$results = $reader->getRecords();
@ -279,6 +281,7 @@ class CsvProcessor implements FileProcessorInterface
* @param array $array
*
* @return bool
*
* @throws FireflyException
*/
private function rowAlreadyImported(array $array): bool

View File

@ -337,4 +337,4 @@ class BunqPrerequisites implements PrerequisitesInterface
return $deviceServerId;
}
}
}

View File

@ -92,5 +92,4 @@ class FilePrerequisites implements PrerequisitesInterface
{
return new MessageBag;
}
}

View File

@ -28,8 +28,6 @@ use Illuminate\Support\MessageBag;
/**
* Interface PrerequisitesInterface
*
* @package FireflyIII\Import\Prerequisites
*/
interface PrerequisitesInterface
{

View File

@ -27,8 +27,6 @@ use Illuminate\Support\Collection;
/**
* Interface RoutineInterface
*
* @package FireflyIII\Import\Routine
*/
interface RoutineInterface
{
@ -58,6 +56,4 @@ interface RoutineInterface
* @return mixed
*/
public function setJob(ImportJob $job);
}

View File

@ -25,9 +25,9 @@ namespace FireflyIII\Import\Routine;
use FireflyIII\Models\ImportJob;
use FireflyIII\Services\Spectre\Object\Customer;
use FireflyIII\Services\Spectre\Request\NewCustomerRequest;
use Preferences;
use Illuminate\Support\Collection;
use Log;
use Preferences;
/**
* Class FileRoutine
@ -91,7 +91,6 @@ class SpectreRoutine implements RoutineInterface
// create customer if user does not have one:
$customer = $this->getCustomer();
return true;
}
@ -113,7 +112,6 @@ class SpectreRoutine implements RoutineInterface
echo '<pre>';
print_r($newCustomerRequest->getCustomer());
exit;
}
/**
@ -128,6 +126,4 @@ class SpectreRoutine implements RoutineInterface
var_dump($preference->data);
exit;
}
}

View File

@ -127,7 +127,7 @@ class IngDescription implements SpecificInterface
private function copyDescriptionToOpposite(): void
{
$search = ['Naar Oranje Spaarrekening ', 'Afschrijvingen'];
if (strlen($this->row[3]) === 0) {
if (0 === strlen($this->row[3])) {
$this->row[3] = trim(str_ireplace($search, '', $this->row[8]));
}
}

View File

@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Import\Specifics;

View File

@ -45,11 +45,11 @@ class ImportStorage
public $errors;
/** @var Collection */
public $journals;
/** @var BillRepositoryInterface */
/** @var BillRepositoryInterface */
protected $billRepository; // yes, hard coded
/** @var Collection */
protected $bills;
/** @var int */
/** @var int */
protected $defaultCurrencyId = 1;
/** @var ImportJob */
protected $job;
@ -96,11 +96,11 @@ class ImportStorage
$config = $job->configuration;
$this->applyRules = $config['apply_rules'] ?? false;
$this->matchBills = $config['match_bills'] ?? false;
if ($this->applyRules === true) {
if (true === $this->applyRules) {
Log::debug('applyRules seems to be true, get the rules.');
$this->rules = $this->getRules();
}
if ($this->matchBills === true) {
if (true === $this->matchBills) {
Log::debug('matchBills seems to be true, get the bills');
$this->bills = $this->getBills();
$this->billRepository = app(BillRepositoryInterface::class);
@ -226,22 +226,22 @@ class ImportStorage
$this->job->addStepsDone(1);
// run rules if config calls for it:
if ($this->applyRules === true) {
if (true === $this->applyRules) {
Log::info('Will apply rules to this journal.');
$this->applyRules($journal);
}
if (!($this->applyRules === true)) {
if (!(true === $this->applyRules)) {
Log::info('Will NOT apply rules to this journal.');
}
// match bills if config calls for it.
if ($this->matchBills === true) {
if (true === $this->matchBills) {
//$this->/applyRules($journal);
Log::info('Cannot match bills (yet).');
$this->matchBills($journal);
}
if (!($this->matchBills === true)) {
if (!(true === $this->matchBills)) {
Log::info('Cannot match bills (yet), but do not have to.');
}

View File

@ -93,8 +93,9 @@ trait ImportSupport
*/
protected function matchBills(TransactionJournal $journal): bool
{
if(!is_null($journal->bill_id)) {
if (!is_null($journal->bill_id)) {
Log::debug('Journal is already linked to a bill, will not scan.');
return true;
}
if ($this->bills->count() > 0) {
@ -264,6 +265,7 @@ trait ImportSupport
*
* @return string
*x
*
* @throws FireflyException
*
* @see ImportSupport::getOpposingAccount()
@ -412,6 +414,7 @@ trait ImportSupport
* @param array $parameters
*
* @return TransactionJournal
*
* @throws FireflyException
*/
private function storeJournal(array $parameters): TransactionJournal

View File

@ -93,6 +93,14 @@ class ExecuteRuleOnExistingTransactions extends Job implements ShouldQueue
$this->endDate = $date;
}
/**
* @return Rule
*/
public function getRule(): Rule
{
return $this->rule;
}
/**
* @return \Carbon\Carbon
*/
@ -117,15 +125,6 @@ class ExecuteRuleOnExistingTransactions extends Job implements ShouldQueue
return $this->user;
}
/**
* @return Rule
*/
public function getRule(): Rule
{
return $this->rule;
}
/**
* @param User $user
*/

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/**
* GetSpectreProviders.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
@ -92,8 +94,8 @@ class GetSpectreProviders implements ShouldQueue
$dbProvider->code = $provider['code'];
$dbProvider->mode = $provider['mode'];
$dbProvider->status = $provider['status'];
$dbProvider->interactive = $provider['interactive'] === 1;
$dbProvider->automatic_fetch = $provider['automatic_fetch'] === 1;
$dbProvider->interactive = 1 === $provider['interactive'];
$dbProvider->automatic_fetch = 1 === $provider['automatic_fetch'];
$dbProvider->country_code = $provider['country_code'];
$dbProvider->data = $provider;
$dbProvider->save();

View File

@ -18,10 +18,8 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Mail;
use Illuminate\Bus\Queueable;

View File

@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Mail;

View File

@ -18,11 +18,8 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Mail;
use Illuminate\Bus\Queueable;
@ -36,7 +33,7 @@ class UndoEmailChangeMail extends Mailable
{
use Queueable, SerializesModels;
/** @var string IP address of user*/
/** @var string IP address of user */
public $ipAddress;
/** @var string New email address */
public $newEmail;

View File

@ -63,7 +63,7 @@ class Account extends Model
* @var array
*/
protected $rules
= [
= [
'user_id' => 'required|exists:users,id',
'account_type_id' => 'required|exists:account_types,id',
'name' => 'required|between:1,200',
@ -118,7 +118,7 @@ class Account extends Model
*
* @return Account
*/
public static function routeBinder(Account $value)
public static function routeBinder(self $value)
{
if (auth()->check()) {
if (intval($value->user_id) === auth()->user()->id) {
@ -218,7 +218,6 @@ class Account extends Model
* Returns the opening balance.
*
* @return TransactionJournal
*
*/
public function getOpeningBalance(): TransactionJournal
{
@ -268,7 +267,6 @@ class Account extends Model
* Returns the date of the opening balance for this account. If no date, will return 01-01-1900.
*
* @return Carbon
*
*/
public function getOpeningBalanceDate(): Carbon
{

View File

@ -30,7 +30,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
*/
class AccountType extends Model
{
const DEFAULT = 'Default account';
const DEFAULT = 'Default account';
/**
*
*/

View File

@ -42,7 +42,7 @@ class Bill extends Model
* @var array
*/
protected $casts
= [
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
@ -57,8 +57,8 @@ class Bill extends Model
* @var array
*/
protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
'automatch', 'active',];
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip',
'automatch', 'active',];
/**
* @var array
*/

View File

@ -38,7 +38,7 @@ class Configuration extends Model
* @var array
*/
protected $casts
= [
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

View File

@ -179,6 +179,7 @@ class ImportJob extends Model
/**
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function uploadFileContents(): string

View File

@ -41,7 +41,7 @@ class PiggyBankEvent extends Model
'date' => 'datetime',
];
/** @var array */
protected $dates = ['date'];
protected $dates = ['date'];
/**
* @var array
*/

View File

@ -18,12 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
/**
@ -51,5 +49,4 @@ class SpectreProvider extends Model
* @var array
*/
protected $fillable = ['spectre_id', 'code', 'mode', 'name', 'status', 'interactive', 'automatic_fetch', 'country_code', 'data'];
}
}

View File

@ -105,6 +105,7 @@ class Tag extends Model
* @param Tag $tag
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public static function tagSum(self $tag): string

View File

@ -75,7 +75,7 @@ class Transaction extends Model
* @var array
*/
protected $casts
= [
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
@ -88,8 +88,8 @@ class Transaction extends Model
* @var array
*/
protected $fillable
= ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id',
'foreign_amount',];
= ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier', 'transaction_currency_id', 'foreign_currency_id',
'foreign_amount',];
/**
* @var array
*/
@ -98,7 +98,7 @@ class Transaction extends Model
* @var array
*/
protected $rules
= [
= [
'account_id' => 'required|exists:accounts,id',
'transaction_journal_id' => 'required|exists:transaction_journals,id',
'transaction_currency_id' => 'required|exists:transaction_currencies,id',

View File

@ -51,7 +51,7 @@ class ExportJobServiceProvider extends ServiceProvider
}
/**
*
* Register export job.
*/
private function exportJob()
{
@ -69,6 +69,9 @@ class ExportJobServiceProvider extends ServiceProvider
);
}
/**
* Register import job.
*/
private function importJob()
{
$this->app->bind(

View File

@ -73,6 +73,9 @@ use Validator;
*/
class FireflyServiceProvider extends ServiceProvider
{
/**
* Start provider.
*/
public function boot()
{
Validator::resolver(
@ -94,7 +97,7 @@ class FireflyServiceProvider extends ServiceProvider
}
/**
*
* Register stuff.
*/
public function register()
{

View File

@ -43,7 +43,6 @@ use Validator;
*/
class AccountRepository implements AccountRepositoryInterface
{
/** @var User */
private $user;
@ -72,6 +71,7 @@ class AccountRepository implements AccountRepositoryInterface
* @param Account $moveTo
*
* @return bool
*
* @throws \Exception
*/
public function destroy(Account $account, Account $moveTo): bool
@ -161,6 +161,7 @@ class AccountRepository implements AccountRepositoryInterface
* @param array $data
*
* @return Account
*
* @throws FireflyException
*/
public function store(array $data): Account
@ -222,7 +223,7 @@ class AccountRepository implements AccountRepositoryInterface
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
$transaction->amount = bcmul($data['amount'], '-1');
if ($transaction->account->accountType->type === AccountType::ASSET) {
if (AccountType::ASSET === $transaction->account->accountType->type) {
$transaction->amount = $data['amount'];
}
$transaction->save();
@ -413,6 +414,7 @@ class AccountRepository implements AccountRepositoryInterface
* @param string $name
*
* @return Account
*
* @throws FireflyException
*/
protected function storeOpposingAccount(string $name): Account
@ -511,6 +513,7 @@ class AccountRepository implements AccountRepositoryInterface
* @param array $data
*
* @return bool
*
* @throws \Exception
*/
protected function updateOpeningBalanceJournal(Account $account, TransactionJournal $journal, array $data): bool

View File

@ -33,7 +33,6 @@ use Illuminate\Support\Collection;
*/
interface AccountRepositoryInterface
{
/**
* Moved here from account CRUD.
*

View File

@ -211,6 +211,7 @@ trait FindAccountsTrait
/**
* @return Account
*
* @throws FireflyException
*/
public function getCashAccount(): Account

View File

@ -43,6 +43,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
* @param Attachment $attachment
*
* @return bool
*
* @throws \Exception
*/
public function destroy(Attachment $attachment): bool
@ -130,6 +131,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
* @param Attachment $attachment
*
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getContent(Attachment $attachment): string

View File

@ -48,6 +48,7 @@ class BillRepository implements BillRepositoryInterface
* @param Bill $bill
*
* @return bool
*
* @throws \Exception
*/
public function destroy(Bill $bill): bool
@ -391,6 +392,7 @@ class BillRepository implements BillRepositoryInterface
* @param Carbon $date
*
* @return \Carbon\Carbon
*
* @throws \FireflyIII\Support\Facades\FireflyException
* @throws \FireflyIII\Support\Facades\FireflyException
*/
@ -430,6 +432,7 @@ class BillRepository implements BillRepositoryInterface
* @param Carbon $date
*
* @return Carbon
*
* @throws \FireflyIII\Support\Facades\FireflyException
* @throws \FireflyIII\Support\Facades\FireflyException
* @throws \FireflyIII\Support\Facades\FireflyException
@ -616,10 +619,9 @@ class BillRepository implements BillRepositoryInterface
return $wordMatch;
}
/**
* @param Bill $bill
* @param string $note
* @param Bill $bill
* @param string $note
*
* @return bool
*/

View File

@ -51,6 +51,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @return bool
*
* @throws \Exception
* @throws \Exception
*/
@ -125,6 +126,7 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param Budget $budget
*
* @return bool
*
* @throws \Exception
*/
public function destroy(Budget $budget): bool
@ -607,6 +609,7 @@ class BudgetRepository implements BudgetRepositoryInterface
* @param string $amount
*
* @return BudgetLimit
*
* @throws \Exception
*/
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): BudgetLimit

View File

@ -44,6 +44,7 @@ class CategoryRepository implements CategoryRepositoryInterface
* @param Category $category
*
* @return bool
*
* @throws \Exception
*/
public function destroy(Category $category): bool

View File

@ -53,6 +53,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
/**
* @return bool
*
* @throws \Exception
*/
public function cleanup(): bool
@ -138,6 +139,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
* @param ExportJob $job
*
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getContent(ExportJob $job): string

View File

@ -129,6 +129,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
* @param null|UploadedFile $file
*
* @return bool
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function processFile(ImportJob $job, ?UploadedFile $file): bool

View File

@ -42,6 +42,8 @@ use Log;
trait CreateJournalsTrait
{
/**
* Store accounts found in parent class.
*
* @param User $user
* @param TransactionType $type
* @param array $data
@ -78,6 +80,8 @@ trait CreateJournalsTrait
}
/**
* Store a budget if found.
*
* @param Transaction $transaction
* @param int $budgetId
*/
@ -91,6 +95,8 @@ trait CreateJournalsTrait
}
/**
* Store category if found.
*
* @param Transaction $transaction
* @param string $category
*/
@ -161,6 +167,8 @@ trait CreateJournalsTrait
}
/**
* Store a transaction.
*
* @param array $data
*
* @return Transaction
@ -202,6 +210,8 @@ trait CreateJournalsTrait
}
/**
* Update note for journal.
*
* @param TransactionJournal $journal
* @param string $note
*

View File

@ -99,6 +99,7 @@ class JournalRepository implements JournalRepositoryInterface
* @param TransactionJournal $journal
*
* @return bool
*
* @throws \Exception
*/
public function delete(TransactionJournal $journal): bool
@ -180,7 +181,7 @@ class JournalRepository implements JournalRepositoryInterface
{
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
if ($transaction->account->accountType->type === AccountType::ASSET) {
if (AccountType::ASSET === $transaction->account->accountType->type) {
return $transaction;
}
}
@ -274,6 +275,7 @@ class JournalRepository implements JournalRepositoryInterface
* @param array $data
*
* @return TransactionJournal
*
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \FireflyIII\Exceptions\FireflyException
*/
@ -361,6 +363,7 @@ class JournalRepository implements JournalRepositoryInterface
* @param array $data
*
* @return TransactionJournal
*
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \FireflyIII\Exceptions\FireflyException
@ -418,7 +421,6 @@ class JournalRepository implements JournalRepositoryInterface
return $journal;
}
/**
* Same as above but for transaction journal with multiple transactions.
*

View File

@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;

View File

@ -119,6 +119,7 @@ trait SupportJournalsTrait
* @param array $data
*
* @return array
*
* @throws FireflyException
* @throws FireflyException
*/
@ -167,6 +168,7 @@ trait SupportJournalsTrait
* @param array $data
*
* @return array
*
* @throws FireflyException
* @throws FireflyException
*/

View File

@ -71,6 +71,8 @@ trait UpdateJournalsTrait
}
/**
* Update destination transaction.
*
* @param TransactionJournal $journal
* @param Account $account
* @param array $data
@ -94,6 +96,8 @@ trait UpdateJournalsTrait
}
/**
* Update source transaction.
*
* @param TransactionJournal $journal
* @param Account $account
* @param array $data
@ -118,6 +122,8 @@ trait UpdateJournalsTrait
}
/**
* Update tags.
*
* @param TransactionJournal $journal
* @param array $array
*

View File

@ -51,6 +51,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
* @param LinkType $moveTo
*
* @return bool
*
* @throws \Exception
*/
public function destroy(LinkType $linkType, LinkType $moveTo): bool
@ -67,6 +68,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
* @param TransactionJournalLink $link
*
* @return bool
*
* @throws \Exception
*/
public function destroyLink(TransactionJournalLink $link): bool

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