From 4a511761938356271871b144157a38d299cc19b7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 3 May 2015 12:58:55 +0200 Subject: [PATCH] General cleanup. --- app/Events/JournalCreated.php | 3 ++- app/Events/JournalDeleted.php | 6 ++++- app/Events/JournalSaved.php | 7 +++++- app/Helpers/Help/Help.php | 8 ++++--- app/Helpers/Help/HelpInterface.php | 22 ++++++++++--------- app/Http/Controllers/AccountController.php | 2 +- app/Http/Controllers/BudgetController.php | 4 ++-- app/Http/Controllers/CategoryController.php | 5 ++++- app/Http/Controllers/CurrencyController.php | 5 +++++ .../Controllers/GoogleChartController.php | 7 ++++-- app/Http/Controllers/HelpController.php | 3 ++- app/Http/Controllers/JsonController.php | 12 +++++++++- app/Http/Controllers/PiggyBankController.php | 10 ++++++--- .../Controllers/PreferencesController.php | 2 ++ app/Http/Controllers/ProfileController.php | 5 +++++ app/Http/Controllers/ReminderController.php | 10 +++++++-- app/Http/Controllers/ReportController.php | 16 ++++++++------ app/Http/Controllers/SearchController.php | 4 ++++ app/Http/Controllers/TagController.php | 16 +++++++++----- .../Requests/DeleteAccountFormRequest.php | 2 +- app/Http/Requests/TagFormRequest.php | 2 +- app/Http/breadcrumbs.php | 7 +++--- app/Http/routes.php | 15 ++++++++----- app/Models/Account.php | 2 +- app/Models/Category.php | 3 ++- app/Models/PiggyBank.php | 2 +- app/Models/Reminder.php | 5 +++++ app/Models/Tag.php | 4 ++-- app/Models/TransactionJournal.php | 5 +++++ app/Providers/ConfigServiceProvider.php | 2 +- app/Providers/EventServiceProvider.php | 2 +- .../Journal/JournalRepository.php | 2 +- .../Tag/TagRepositoryInterface.php | 6 +++-- app/Support/Twig/PiggyBank.php | 3 ++- 34 files changed, 147 insertions(+), 62 deletions(-) diff --git a/app/Events/JournalCreated.php b/app/Events/JournalCreated.php index 0fc11fb491..65c8929d4b 100644 --- a/app/Events/JournalCreated.php +++ b/app/Events/JournalCreated.php @@ -19,7 +19,8 @@ class JournalCreated extends Event /** * Create a new event instance. * - * @return void + * @param TransactionJournal $journal + * @param $piggyBankId */ public function __construct(TransactionJournal $journal, $piggyBankId) { diff --git a/app/Events/JournalDeleted.php b/app/Events/JournalDeleted.php index d19937a9cd..eadf06bb81 100644 --- a/app/Events/JournalDeleted.php +++ b/app/Events/JournalDeleted.php @@ -2,6 +2,11 @@ use Illuminate\Queue\SerializesModels; +/** + * Class JournalDeleted + * + * @package FireflyIII\Events + */ class JournalDeleted extends Event { @@ -10,7 +15,6 @@ class JournalDeleted extends Event /** * Create a new event instance. * - * @return void */ public function __construct() { diff --git a/app/Events/JournalSaved.php b/app/Events/JournalSaved.php index 25471ca809..e3a8a37da0 100644 --- a/app/Events/JournalSaved.php +++ b/app/Events/JournalSaved.php @@ -3,6 +3,11 @@ use FireflyIII\Models\TransactionJournal; use Illuminate\Queue\SerializesModels; +/** + * Class JournalSaved + * + * @package FireflyIII\Events + */ class JournalSaved extends Event { @@ -13,7 +18,7 @@ class JournalSaved extends Event /** * Create a new event instance. * - * @return void + * @param TransactionJournal $journal */ public function __construct(TransactionJournal $journal) { diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php index f7bf4a7690..c7e77a5d2d 100644 --- a/app/Helpers/Help/Help.php +++ b/app/Helpers/Help/Help.php @@ -54,7 +54,9 @@ class Help implements HelpInterface } /** - * @return boolean + * @param $route + * + * @return bool */ public function hasRoute($route) { @@ -62,10 +64,10 @@ class Help implements HelpInterface } /** - * @param $title + * @param $route * @param array $content * - * @return void + * @internal param $title */ public function putInCache($route, array $content) { diff --git a/app/Helpers/Help/HelpInterface.php b/app/Helpers/Help/HelpInterface.php index c550a9faf5..b11e29b4ab 100644 --- a/app/Helpers/Help/HelpInterface.php +++ b/app/Helpers/Help/HelpInterface.php @@ -18,16 +18,25 @@ interface HelpInterface public function getFromCache($key); /** - * @return boolean + * @param $route + * + * @return array + */ + public function getFromGithub($route); + + /** + * @param $route + * + * @return bool */ public function hasRoute($route); /** * @param $route * - * @return array + * @return bool */ - public function getFromGithub($route); + public function inCache($route); /** * @param $route @@ -36,11 +45,4 @@ interface HelpInterface * @return void */ public function putInCache($route, array $content); - - /** - * @param $route - * - * @return bool - */ - public function inCache($route); } \ No newline at end of file diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 2eb8b8f47b..74a9966476 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -92,7 +92,7 @@ class AccountController extends Controller * * @return View */ - public function edit(AccountRepositoryInterface $repository,Account $account) + public function edit(AccountRepositoryInterface $repository, Account $account) { $what = Config::get('firefly.shortNamesByFullName')[$account->accountType->type]; diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index ee1e8cdceb..cacd05d40c 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -264,10 +264,10 @@ class BudgetController extends Controller */ public function updateIncome() { - $date = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); + $date = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); $amount = Preferences::get('budgetIncomeTotal' . $date, 1000); - return view('budgets.income',compact('amount')); + return view('budgets.income', compact('amount')); } } diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index ab5983980b..2dfd42cff4 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -97,8 +97,9 @@ class CategoryController extends Controller } /** - * @return $this + * @param CategoryRepositoryInterface $repository * + * @return $this */ public function index(CategoryRepositoryInterface $repository) { @@ -114,6 +115,8 @@ class CategoryController extends Controller } /** + * @param CategoryRepositoryInterface $repository + * * @return \Illuminate\View\View */ public function noCategory(CategoryRepositoryInterface $repository) diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index ec8863c481..79eb406cf9 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -133,6 +133,8 @@ class CurrencyController extends Controller } /** + * @param CurrencyRepositoryInterface $repository + * * @return \Illuminate\View\View */ public function index(CurrencyRepositoryInterface $repository) @@ -146,6 +148,9 @@ class CurrencyController extends Controller /** * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. * + * @param CurrencyFormRequest $request + * @param CurrencyRepositoryInterface $repository + * * @return $this|\Illuminate\Http\RedirectResponse */ public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository) diff --git a/app/Http/Controllers/GoogleChartController.php b/app/Http/Controllers/GoogleChartController.php index c7751d889d..21b569de47 100644 --- a/app/Http/Controllers/GoogleChartController.php +++ b/app/Http/Controllers/GoogleChartController.php @@ -243,7 +243,10 @@ class GoogleChartController extends Controller } /** - * @param GChart $chart + * @param GChart $chart + * + * @param BillRepositoryInterface $repository + * @param AccountRepositoryInterface $accounts * * @return \Symfony\Component\HttpFoundation\Response */ @@ -494,7 +497,7 @@ class GoogleChartController extends Controller * * @return \Symfony\Component\HttpFoundation\Response */ - public function yearInExp(GChart $chart, ReportQueryInterface $query,$year) + public function yearInExp(GChart $chart, ReportQueryInterface $query, $year) { $start = new Carbon('01-01-' . $year); $chart->addColumn('Month', 'date'); diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php index a1562e79cb..7220742700 100644 --- a/app/Http/Controllers/HelpController.php +++ b/app/Http/Controllers/HelpController.php @@ -13,7 +13,8 @@ class HelpController extends Controller { /** - * @param $route + * @param HelpInterface $help + * @param $route * * @return \Illuminate\Http\JsonResponse */ diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 08ac171b3b..db13db45d7 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -28,7 +28,9 @@ class JsonController extends Controller /** - * @param BillRepositoryInterface $repository + * @param BillRepositoryInterface $repository + * + * @param AccountRepositoryInterface $accountRepository * * @return \Symfony\Component\HttpFoundation\Response */ @@ -149,6 +151,8 @@ class JsonController extends Controller /** * Returns a list of categories. * + * @param CategoryRepositoryInterface $repository + * * @return \Illuminate\Http\JsonResponse */ public function categories(CategoryRepositoryInterface $repository) @@ -166,6 +170,8 @@ class JsonController extends Controller /** * Returns a JSON list of all beneficiaries. * + * @param AccountRepositoryInterface $accountRepository + * * @return \Illuminate\Http\JsonResponse */ public function expenseAccounts(AccountRepositoryInterface $accountRepository) @@ -183,6 +189,8 @@ class JsonController extends Controller /** * Returns a JSON list of all beneficiaries. * + * @param TagRepositoryInterface $tagRepository + * * @return \Illuminate\Http\JsonResponse */ public function tags(TagRepositoryInterface $tagRepository) @@ -198,6 +206,8 @@ class JsonController extends Controller } /** + * @param AccountRepositoryInterface $accountRepository + * * @return \Illuminate\Http\JsonResponse */ public function revenueAccounts(AccountRepositoryInterface $accountRepository) diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 6acb521341..f0e8543b5b 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -40,7 +40,8 @@ class PiggyBankController extends Controller /** * Add money to piggy bank * - * @param PiggyBank $piggyBank + * @param AccountRepositoryInterface $repository + * @param PiggyBank $piggyBank * * @return $this */ @@ -55,6 +56,8 @@ class PiggyBankController extends Controller } /** + * @param AccountRepositoryInterface $repository + * * @return mixed */ public function create(AccountRepositoryInterface $repository) @@ -337,10 +340,11 @@ class PiggyBankController extends Controller } /** - * @param PiggyBank $piggyBank + * @param PiggyBankRepositoryInterface $repository + * @param PiggyBankFormRequest $request + * @param PiggyBank $piggyBank * * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * * @return $this */ public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank) diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 84d2901104..0097b4a9cf 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -26,6 +26,8 @@ class PreferencesController extends Controller } /** + * @param AccountRepositoryInterface $repository + * * @return $this|\Illuminate\View\View */ public function index(AccountRepositoryInterface $repository) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 98154d6be7..c13f57894b 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -46,6 +46,8 @@ class ProfileController extends Controller } /** + * @param ProfileFormRequest $request + * * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View */ public function postChangePassword(ProfileFormRequest $request) @@ -91,7 +93,10 @@ class ProfileController extends Controller } /** + * @param DeleteAccountFormRequest $request * + * @return \Illuminate\Http\RedirectResponse + * @throws \Exception */ public function postDeleteAccount(DeleteAccountFormRequest $request) { diff --git a/app/Http/Controllers/ReminderController.php b/app/Http/Controllers/ReminderController.php index a5e0b087db..9e80c5acd0 100644 --- a/app/Http/Controllers/ReminderController.php +++ b/app/Http/Controllers/ReminderController.php @@ -1,7 +1,5 @@ tag; @@ -150,7 +150,7 @@ class TagController extends Controller $count++; } } - if($count > 1) { + if ($count > 1) { $allowToAdvancePayment = false; } @@ -170,12 +170,12 @@ class TagController extends Controller $count++; } } - if($count > 0) { + if ($count > 0) { $allowToBalancingAct = false; } - // edit tagoptions: + // edit tag options: if ($allowToAdvancePayment === false) { unset($tagOptions['advancePayment']); } @@ -195,6 +195,8 @@ class TagController extends Controller /** * @param $state + * + * @return \Symfony\Component\HttpFoundation\Response */ public function hideTagHelp($state) { @@ -234,7 +236,11 @@ class TagController extends Controller } /** - * @param TagFormRequest $request + * @param TagFormRequest $request + * + * @param TagRepositoryInterface $repository + * + * @return $this|\Illuminate\Http\RedirectResponse */ public function store(TagFormRequest $request, TagRepositoryInterface $repository) { diff --git a/app/Http/Requests/DeleteAccountFormRequest.php b/app/Http/Requests/DeleteAccountFormRequest.php index 05f928ab8b..68dbe811a3 100644 --- a/app/Http/Requests/DeleteAccountFormRequest.php +++ b/app/Http/Requests/DeleteAccountFormRequest.php @@ -26,7 +26,7 @@ class DeleteAccountFormRequest extends Request public function rules() { return [ - 'password' => 'required', + 'password' => 'required', ]; } } diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php index f82b055478..ad04f50a29 100644 --- a/app/Http/Requests/TagFormRequest.php +++ b/app/Http/Requests/TagFormRequest.php @@ -33,7 +33,7 @@ class TagFormRequest extends Request */ public function rules() { - $idRule = ''; + $idRule = ''; $tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,TRUE'; if (Tag::find(Input::get('id'))) { $idRule = 'belongsToUser:tags'; diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index ad18780bcb..7a0a504a6d 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -9,9 +9,10 @@ use FireflyIII\Models\Category; use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\Reminder; +use FireflyIII\Models\Tag; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; -use FireflyIII\Models\Tag; + /* * Back home. */ @@ -176,13 +177,13 @@ Breadcrumbs::register( Breadcrumbs::register( 'currency.edit', function (Generator $breadcrumbs, TransactionCurrency $currency) { $breadcrumbs->parent('currency.index'); - $breadcrumbs->push('Edit '.$currency->name, route('currency.edit', $currency->id)); + $breadcrumbs->push('Edit ' . $currency->name, route('currency.edit', $currency->id)); } ); Breadcrumbs::register( 'currency.delete', function (Generator $breadcrumbs, TransactionCurrency $currency) { $breadcrumbs->parent('currency.index'); - $breadcrumbs->push('Delete '.$currency->name, route('currency.delete', $currency->id)); + $breadcrumbs->push('Delete ' . $currency->name, route('currency.delete', $currency->id)); } ); diff --git a/app/Http/routes.php b/app/Http/routes.php index 9756f34614..5a6ab19d83 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -145,8 +145,8 @@ Route::bind( if (Auth::check()) { /** @var \FireflyIII\Models\Reminder $object */ $object = Reminder::find($value); - if($object) { - if($object->remindersable->account->user_id == Auth::user()->id) { + if ($object) { + if ($object->remindersable->account->user_id == Auth::user()->id) { return $object; } } @@ -177,7 +177,7 @@ Route::get('/register', ['uses' => 'Auth\AuthController@getRegister', 'as' => 'r Route::controllers( [ - 'auth' => 'Auth\AuthController', + 'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController', ] ); @@ -350,8 +350,13 @@ Route::group( // pop ups for budget report: Route::get('/reports/modal/{account}/{year}/{month}/no-budget', ['uses' => 'ReportController@modalNoBudget', 'as' => 'reports.no-budget']); - Route::get('/reports/modal/{account}/{year}/{month}/balanced-transfers', ['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers']); - Route::get('/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']); + Route::get( + '/reports/modal/{account}/{year}/{month}/balanced-transfers', + ['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers'] + ); + Route::get( + '/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced'] + ); /** * Search Controller diff --git a/app/Models/Account.php b/app/Models/Account.php index 2712aef197..77c8a66086 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -51,7 +51,7 @@ class Account extends Model $account = Account::create($fields); if (is_null($account->id)) { // could not create account: - App::abort(500, 'Could not create new account with data: ' . json_encode($fields).' because ' . json_encode($account->getErrors())); + App::abort(500, 'Could not create new account with data: ' . json_encode($fields) . ' because ' . json_encode($account->getErrors())); } diff --git a/app/Models/Category.php b/app/Models/Category.php index 60a8198571..12efc295b6 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -1,9 +1,10 @@ where('reminders.startdate', '=', $start->format('Y-m-d 00:00:00'))->where('reminders.enddate', '=', $end->format('Y-m-d 00:00:00')); } + /** + * @param EloquentBuilder $query + * + * @return $this + */ public function scopeToday(EloquentBuilder $query) { $today = new Carbon; diff --git a/app/Models/Tag.php b/app/Models/Tag.php index d965150c0a..cac823555c 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -52,9 +52,9 @@ class Tag extends Model } } // create it! - $fields['tagMode'] = 'nothing'; + $fields['tagMode'] = 'nothing'; $fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : ''; - $tag = Tag::create($fields); + $tag = Tag::create($fields); if (is_null($tag->id)) { // could not create account: App::abort(500, 'Could not create new tag with data: ' . json_encode($fields) . ' because ' . json_encode($tag->getErrors())); diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index f0873c577b..f2d65060c5 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -66,8 +66,13 @@ class TransactionJournal extends Model return floatval($t->amount); } } + + return 0; } + /** + * @return Account|mixed + */ public function getAssetAccountAttribute() { $positive = true; // the asset account is in the transaction with the positive amount. diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index bd01842727..b758d58acd 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -173,7 +173,7 @@ class ConfigServiceProvider extends ServiceProvider ], 'Form' => [ 'is_safe' => [ - 'input', 'select', 'checkbox', 'model', 'open','radio','textarea' + 'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea' ] ], ], diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index e19c145043..a9d54e9e0f 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -6,6 +6,7 @@ use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBankRepetition; +use FireflyIII\Models\Reminder; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Support\Facades\Navigation; @@ -13,7 +14,6 @@ use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use Illuminate\Database\QueryException; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Log; -use FireflyIII\Models\Reminder; /** * Class EventServiceProvider diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 330ff2fe81..9a4ab7d52f 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -231,7 +231,7 @@ class JournalRepository implements JournalRepositoryInterface DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->whereNotIn('tag_id', $ids)->delete(); } // if count is zero, delete them all: - if(count($ids) == 0) { + if (count($ids) == 0) { DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->delete(); } diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php index 4e0d31c102..e2a5c03bff 100644 --- a/app/Repositories/Tag/TagRepositoryInterface.php +++ b/app/Repositories/Tag/TagRepositoryInterface.php @@ -1,6 +1,7 @@ currentRelevantRep()->currentamount; } ); + return $functions; }