From c00bcd78ccddc2df84fc051250b456dc25ab58d2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 7 Jul 2015 19:09:45 +0200 Subject: [PATCH] Some dependency clean up. --- .../Chart/Bill/GoogleBillChartGenerator.php | 3 ++- app/Handlers/Events/RescanJournal.php | 3 +-- app/Helpers/Csv/Importer.php | 7 +++---- app/Helpers/Csv/Wizard.php | 3 +-- app/Helpers/Report/ReportHelper.php | 15 +++++++-------- app/Helpers/Report/ReportHelperInterface.php | 4 ++-- app/Http/Controllers/Auth/AuthController.php | 3 +-- app/Http/Controllers/Chart/AccountController.php | 3 +-- app/Http/Controllers/Chart/BillController.php | 3 +-- app/Http/Controllers/Chart/BudgetController.php | 3 +-- app/Http/Controllers/Chart/CategoryController.php | 3 +-- .../Controllers/Chart/PiggyBankController.php | 3 +-- app/Http/Controllers/Chart/ReportController.php | 3 +-- app/Http/Controllers/CsvController.php | 5 ++--- app/Http/Controllers/HomeController.php | 1 - app/Http/Controllers/JsonController.php | 2 +- app/Http/Middleware/Range.php | 3 +-- app/Http/Requests/JournalFormRequest.php | 3 +-- app/Providers/FireflyServiceProvider.php | 3 +-- app/Repositories/Account/AccountRepository.php | 3 +-- app/Repositories/Journal/JournalRepository.php | 10 +++++----- app/Support/Twig/General.php | 15 +++++++-------- app/Support/Twig/Journal.php | 9 ++++----- 23 files changed, 46 insertions(+), 64 deletions(-) diff --git a/app/Generator/Chart/Bill/GoogleBillChartGenerator.php b/app/Generator/Chart/Bill/GoogleBillChartGenerator.php index 87960405ec..d77a9a5f8f 100644 --- a/app/Generator/Chart/Bill/GoogleBillChartGenerator.php +++ b/app/Generator/Chart/Bill/GoogleBillChartGenerator.php @@ -83,7 +83,8 @@ class GoogleBillChartGenerator implements BillChartGenerator clone $result->date, floatval($bill->amount_max), floatval($bill->amount_min), - floatval($result->amount)); + floatval($result->amount) + ); } $chart->generate(); diff --git a/app/Handlers/Events/RescanJournal.php b/app/Handlers/Events/RescanJournal.php index b44924b6d8..02926a1102 100644 --- a/app/Handlers/Events/RescanJournal.php +++ b/app/Handlers/Events/RescanJournal.php @@ -1,6 +1,5 @@ id . ' (' . $journal->description . ')'); /** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */ - $repository = App::make('FireflyIII\Repositories\Bill\BillRepositoryInterface'); + $repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface'); $list = $journal->user->bills()->where('active', 1)->where('automatch', 1)->get(); Log::debug('Found ' . $list->count() . ' bills to check.'); diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index fe8ca0f7dc..268fa0bb6d 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -2,7 +2,6 @@ namespace FireflyIII\Helpers\Csv; -use App; use Auth; use Config; use FireflyIII\Exceptions\FireflyException; @@ -125,7 +124,7 @@ class Importer $field = Config::get('csv.roles.' . $role . '.field'); /** @var ConverterInterface $converter */ - $converter = App::make('FireflyIII\Helpers\Csv\Converter\\' . $class); + $converter = app('FireflyIII\Helpers\Csv\Converter\\' . $class); $converter->setData($data); // the complete array so far. $converter->setField($field); $converter->setIndex($index); @@ -186,7 +185,7 @@ class Importer foreach ($this->getSpecifix() as $className) { /** @var SpecifixInterface $specifix */ - $specifix = App::make('FireflyIII\Helpers\Csv\Specifix\\' . $className); + $specifix = app('FireflyIII\Helpers\Csv\Specifix\\' . $className); $specifix->setData($this->importData); $specifix->setRow($this->importRow); $this->importData = $specifix->fix(); @@ -196,7 +195,7 @@ class Importer $set = Config::get('csv.post_processors'); foreach ($set as $className) { /** @var PostProcessorInterface $postProcessor */ - $postProcessor = App::make('FireflyIII\Helpers\Csv\PostProcessing\\' . $className); + $postProcessor = app('FireflyIII\Helpers\Csv\PostProcessing\\' . $className); $postProcessor->setData($this->importData); $this->importData = $postProcessor->process(); } diff --git a/app/Helpers/Csv/Wizard.php b/app/Helpers/Csv/Wizard.php index 24dc382795..f701e0a022 100644 --- a/app/Helpers/Csv/Wizard.php +++ b/app/Helpers/Csv/Wizard.php @@ -1,7 +1,6 @@ getBills(); $collection = new BillCollection; @@ -253,7 +252,7 @@ class ReportHelper implements ReportHelperInterface { $object = new BudgetCollection; /** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */ - $repository = App::make('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); + $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $set = $repository->getBudgets(); foreach ($set as $budget) { @@ -323,7 +322,7 @@ class ReportHelper implements ReportHelperInterface * GET CATEGORIES: */ /** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */ - $repository = App::make('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); + $repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); $set = $repository->getCategories(); foreach ($set as $category) { $spent = $repository->spentInPeriodCorrected($category, $start, $end, $shared); diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php index f3dbf42546..91f9c8d0f5 100644 --- a/app/Helpers/Report/ReportHelperInterface.php +++ b/app/Helpers/Report/ReportHelperInterface.php @@ -35,8 +35,8 @@ interface ReportHelperInterface * This method generates a full report for the given period on all * the users bills and their payments. * - * @param Carbon $start - * @param Carbon $end + * @param Carbon $start + * @param Carbon $end * * @return BillCollection */ diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index c930633b20..af4fa3e0ba 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -1,6 +1,5 @@ redirectPath()); } // @codeCoverageIgnoreStart - App::abort(500, 'Not a user!'); + abort(500, 'Not a user!'); return redirect('/'); // @codeCoverageIgnoreEnd diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index c60cf458f4..e1447488e9 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -2,7 +2,6 @@ namespace FireflyIII\Http\Controllers\Chart; -use App; use Carbon\Carbon; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Account; @@ -31,7 +30,7 @@ class AccountController extends Controller { parent::__construct(); // create chart generator: - $this->generator = App::make('FireflyIII\Generator\Chart\Account\AccountChartGenerator'); + $this->generator = app('FireflyIII\Generator\Chart\Account\AccountChartGenerator'); } diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index a17e14049a..522df0d2e2 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -2,7 +2,6 @@ namespace FireflyIII\Http\Controllers\Chart; -use App; use Carbon\Carbon; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Bill; @@ -33,7 +32,7 @@ class BillController extends Controller { parent::__construct(); // create chart generator: - $this->generator = App::make('FireflyIII\Generator\Chart\Bill\BillChartGenerator'); + $this->generator = app('FireflyIII\Generator\Chart\Bill\BillChartGenerator'); } /** diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index ad7192415d..039d04308d 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -2,7 +2,6 @@ namespace FireflyIII\Http\Controllers\Chart; -use App; use Carbon\Carbon; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Budget; @@ -33,7 +32,7 @@ class BudgetController extends Controller { parent::__construct(); // create chart generator: - $this->generator = App::make('FireflyIII\Generator\Chart\Budget\BudgetChartGenerator'); + $this->generator = app('FireflyIII\Generator\Chart\Budget\BudgetChartGenerator'); } /** diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 917bb76b08..f1fde920dc 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -3,7 +3,6 @@ namespace FireflyIII\Http\Controllers\Chart; -use App; use Carbon\Carbon; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Category; @@ -32,7 +31,7 @@ class CategoryController extends Controller { parent::__construct(); // create chart generator: - $this->generator = App::make('FireflyIII\Generator\Chart\Category\CategoryChartGenerator'); + $this->generator = app('FireflyIII\Generator\Chart\Category\CategoryChartGenerator'); } diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.php index e73437bd21..a6972d2a75 100644 --- a/app/Http/Controllers/Chart/PiggyBankController.php +++ b/app/Http/Controllers/Chart/PiggyBankController.php @@ -2,7 +2,6 @@ namespace FireflyIII\Http\Controllers\Chart; -use App; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\PiggyBank; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; @@ -29,7 +28,7 @@ class PiggyBankController extends Controller { parent::__construct(); // create chart generator: - $this->generator = App::make('FireflyIII\Generator\Chart\PiggyBank\PiggyBankChartGenerator'); + $this->generator = app('FireflyIII\Generator\Chart\PiggyBank\PiggyBankChartGenerator'); } /** diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index 4026d222ae..5906517934 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -3,7 +3,6 @@ namespace FireflyIII\Http\Controllers\Chart; -use App; use Carbon\Carbon; use FireflyIII\Helpers\Report\ReportQueryInterface; use FireflyIII\Http\Controllers\Controller; @@ -29,7 +28,7 @@ class ReportController extends Controller { parent::__construct(); // create chart generator: - $this->generator = App::make('FireflyIII\Generator\Chart\Report\ReportChartGenerator'); + $this->generator = app('FireflyIII\Generator\Chart\Report\ReportChartGenerator'); } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 6349b0a47a..e1f25acb1f 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -2,7 +2,6 @@ namespace FireflyIII\Http\Controllers; -use App; use Config; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Csv\Data; @@ -41,8 +40,8 @@ class CsvController extends Controller throw new FireflyException('CSV Import is not enabled.'); } - $this->wizard = App::make('FireflyIII\Helpers\Csv\WizardInterface'); - $this->data = App::make('FireflyIII\Helpers\Csv\Data'); + $this->wizard = app('FireflyIII\Helpers\Csv\WizardInterface'); + $this->data = app('FireflyIII\Helpers\Csv\Data'); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 78db6cc105..6828e43cc0 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -72,7 +72,6 @@ class HomeController extends Controller $count = $repository->countAccounts($types); bcscale(2); - if ($count == 0) { return redirect(route('new-user.index')); } diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index e543534751..5f53c708f7 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -133,7 +133,7 @@ class JsonController extends Controller /** @var Bill $entry */ foreach ($unpaid as $entry) { $current = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; - $amount = bcadd($amount, $current); + $amount = bcadd($amount, $current); } $data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index 64ceaff4c4..ac2017b182 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -3,7 +3,6 @@ namespace FireflyIII\Http\Middleware; -use App; use Carbon\Carbon; use Closure; use Illuminate\Contracts\Auth\Guard; @@ -65,7 +64,7 @@ class Range } if (!Session::has('first')) { /** @var \FireflyIII\Repositories\Journal\JournalRepositoryInterface $repository */ - $repository = App::make('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); + $repository = app('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); $journal = $repository->first(); if ($journal) { Session::put('first', $journal->date); diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php index 3f9e4341de..3bcc2b1a75 100644 --- a/app/Http/Requests/JournalFormRequest.php +++ b/app/Http/Requests/JournalFormRequest.php @@ -2,7 +2,6 @@ namespace FireflyIII\Http\Requests; -use App; use Auth; use Carbon\Carbon; use Exception; @@ -85,7 +84,7 @@ class JournalFormRequest extends Request $rules['category'] = 'between:1,255'; break; default: - App::abort(500, 'Cannot handle ' . $what); + abort(500, 'Cannot handle ' . $what); break; } diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index c528ab0bb6..5f3b310017 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -2,7 +2,6 @@ namespace FireflyIII\Providers; -use App; use FireflyIII\Support\Amount; use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; @@ -38,7 +37,7 @@ class FireflyServiceProvider extends ServiceProvider * Default Twig configuration: */ - $config = App::make('config'); + $config = app('config'); Twig::addExtension(new Functions($config)); Twig::addExtension(new PiggyBank); Twig::addExtension(new General); diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 39b601a1c9..ad4ee43f01 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -2,7 +2,6 @@ namespace FireflyIII\Repositories\Account; -use App; use Auth; use Carbon\Carbon; use Config; @@ -505,7 +504,7 @@ class AccountRepository implements AccountRepositoryInterface $existingAccount = Account::firstOrNullEncrypted($searchData); if (!$existingAccount) { Log::error('Account create error: ' . $newAccount->getErrors()->toJson()); - App::abort(500); + abort(500); // @codeCoverageIgnoreStart } // @codeCoverageIgnoreEnd diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 169a746e40..ab71355313 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -2,7 +2,6 @@ namespace FireflyIII\Repositories\Journal; -use App; use Auth; use Carbon\Carbon; use DB; @@ -138,7 +137,7 @@ class JournalRepository implements JournalRepositoryInterface public function saveTags(TransactionJournal $journal, array $array) { /** @var \FireflyIII\Repositories\Tag\TagRepositoryInterface $tagRepository */ - $tagRepository = App::make('FireflyIII\Repositories\Tag\TagRepositoryInterface'); + $tagRepository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface'); foreach ($array as $name) { if (strlen(trim($name)) > 0) { @@ -287,7 +286,7 @@ class JournalRepository implements JournalRepositoryInterface { // create tag repository /** @var \FireflyIII\Repositories\Tag\TagRepositoryInterface $tagRepository */ - $tagRepository = App::make('FireflyIII\Repositories\Tag\TagRepositoryInterface'); + $tagRepository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface'); // find or create all tags: @@ -344,14 +343,15 @@ class JournalRepository implements JournalRepositoryInterface if (is_null($toAccount)) { Log::error('"to"-account is null, so we cannot continue!'); - App::abort(500, '"to"-account is null, so we cannot continue!'); + abort(500, '"to"-account is null, so we cannot continue!'); // @codeCoverageIgnoreStart } // @codeCoverageIgnoreEnd if (is_null($fromAccount)) { Log::error('"from"-account is null, so we cannot continue!'); - App::abort(500, '"from"-account is null, so we cannot continue!'); + abort(500, '"from"-account is null, so we cannot continue!'); + // @codeCoverageIgnoreStart } diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index ae446bc5ce..b42350a579 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -2,7 +2,6 @@ namespace FireflyIII\Support\Twig; -use App; use Carbon\Carbon; use Config; use FireflyIII\Models\Account; @@ -74,7 +73,7 @@ class General extends Twig_Extension { return new Twig_SimpleFilter( 'formatAmount', function ($string) { - return App::make('amount')->format($string); + return app('amount')->format($string); }, ['is_safe' => ['html']] ); } @@ -86,7 +85,7 @@ class General extends Twig_Extension { return new Twig_SimpleFilter( 'formatTransaction', function (Transaction $transaction) { - return App::make('amount')->formatTransaction($transaction); + return app('amount')->formatTransaction($transaction); }, ['is_safe' => ['html']] ); } @@ -98,7 +97,7 @@ class General extends Twig_Extension { return new Twig_SimpleFilter( 'formatAmountPlain', function ($string) { - return App::make('amount')->format($string, false); + return app('amount')->format($string, false); }, ['is_safe' => ['html']] ); } @@ -110,7 +109,7 @@ class General extends Twig_Extension { return new Twig_SimpleFilter( 'formatJournal', function ($journal) { - return App::make('amount')->formatJournal($journal); + return app('amount')->formatJournal($journal); }, ['is_safe' => ['html']] ); } @@ -127,7 +126,7 @@ class General extends Twig_Extension } $date = Session::get('end', Carbon::now()->endOfMonth()); - return App::make('steam')->balance($account, $date); + return app('steam')->balance($account, $date); } ); } @@ -151,7 +150,7 @@ class General extends Twig_Extension { return new Twig_SimpleFunction( 'getCurrencyCode', function () { - return App::make('amount')->getCurrencyCode(); + return app('amount')->getCurrencyCode(); } ); } @@ -163,7 +162,7 @@ class General extends Twig_Extension { return new Twig_SimpleFunction( 'getCurrencySymbol', function () { - return App::make('amount')->getCurrencySymbol(); + return app('amount')->getCurrencySymbol(); } ); } diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index 5c36723ee0..1be638061d 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -3,7 +3,6 @@ namespace FireflyIII\Support\Twig; -use App; use FireflyIII\Models\Tag; use FireflyIII\Models\TransactionJournal; use FireflyIII\Support\CacheProperties; @@ -156,7 +155,7 @@ class Journal extends Twig_Extension */ protected function relevantTagsNoTags(TransactionJournal $journal) { - return App::make('amount')->formatJournal($journal); + return app('amount')->formatJournal($journal); } /** @@ -182,7 +181,7 @@ class Journal extends Twig_Extension if ($tag->tagMode == 'balancingAct') { // return tag formatted for a "balancing act", even if other // tags are present. - $amount = App::make('amount')->format($journal->actual_amount, false); + $amount = app('amount')->format($journal->actual_amount, false); $string = ' ' . $tag->tag . ''; @@ -191,7 +190,7 @@ class Journal extends Twig_Extension if ($tag->tagMode == 'advancePayment') { if ($journal->transactionType->type == 'Deposit') { - $amount = App::make('amount')->formatJournal($journal, false); + $amount = app('amount')->formatJournal($journal, false); $string = ' ' . $tag->tag . ''; @@ -203,7 +202,7 @@ class Journal extends Twig_Extension * the tag. The TransactionJournal should properly calculate the amount. */ if ($journal->transactionType->type == 'Withdrawal') { - $amount = App::make('amount')->formatJournal($journal); + $amount = app('amount')->formatJournal($journal); $string = '' . $amount . '';