Code cleanup.

This commit is contained in:
James Cole 2015-05-05 10:23:01 +02:00
parent 67fdd27499
commit 23a09b7081
37 changed files with 112 additions and 62 deletions

View File

@ -49,8 +49,7 @@ class Handler extends ExceptionHandler
*/
public function report(Exception $e)
{
/** @noinspection PhpInconsistentReturnPointsInspection */
return parent::report($e);
parent::report($e);
}
}

View File

@ -19,7 +19,6 @@ class ConnectJournalToPiggyBank
/**
* Create the event handler.
*
* @return void
*/
public function __construct()
{

View File

@ -15,7 +15,6 @@ class RescanJournal
/**
* Create the event handler.
*
* @return void
*/
public function __construct()
{
@ -41,7 +40,7 @@ class RescanJournal
Log::debug('Found ' . $list->count() . ' bills to check.');
/** @var Bill $bill */
/** @var \FireflyIII\Models\Bill $bill */
foreach ($list as $bill) {
Log::debug('Now calling bill #' . $bill->id . ' (' . $bill->name . ')');
$repository->scan($bill, $journal);

View File

@ -15,7 +15,6 @@ class UpdateJournalConnection
/**
* Create the event handler.
*
* @return void
*/
public function __construct()
{

View File

@ -90,8 +90,9 @@ class BillController extends Controller
Session::put('bills.create.url', URL::previous());
}
Session::forget('bills.create.fromStore');
$subTitle = 'Create new bill';
return view('bills.create')->with('periods', $periods)->with('subTitle', 'Create new');
return view('bills.create', compact('periods', 'subTitle'));
}
/**
@ -103,8 +104,9 @@ class BillController extends Controller
{
// put previous url in session
Session::put('bills.delete.url', URL::previous());
$subTitle = 'Delete "' . e($bill->name) . '"';
return view('bills.delete')->with('bill', $bill)->with('subTitle', 'Delete "' . e($bill->name) . '"');
return view('bills.delete', compact('bill', 'subTitle'));
}
/**
@ -130,7 +132,8 @@ class BillController extends Controller
*/
public function edit(Bill $bill)
{
$periods = Config::get('firefly.periods_to_text');
$periods = Config::get('firefly.periods_to_text');
$subTitle = 'Edit "' . e($bill->name) . '"';
// put previous url in session if not redirect from store (not "return_to_edit").
if (Session::get('bills.edit.fromUpdate') !== true) {
@ -138,7 +141,7 @@ class BillController extends Controller
}
Session::forget('bills.edit.fromUpdate');
return view('bills.edit')->with('periods', $periods)->with('bill', $bill)->with('subTitle', 'Edit "' . e($bill->name) . '"');
return view('bills.edit', compact('subTitle', 'periods', 'bill'));
}
/**
@ -196,8 +199,9 @@ class BillController extends Controller
$journals = $repository->getJournals($bill);
$bill->nextExpectedMatch = $repository->nextExpectedMatch($bill);
$hideBill = true;
$subTitle = e($bill->name);
return view('bills.show', compact('journals', 'hideBill', 'bill'))->with('subTitle', e($bill->name));
return view('bills.show', compact('journals', 'hideBill', 'bill', 'subTitle'));
}
/**

View File

@ -61,8 +61,9 @@ class BudgetController extends Controller
Session::put('budgets.create.url', URL::previous());
}
Session::forget('budgets.create.fromStore');
$subTitle = 'Create a new budget';
return view('budgets.create')->with('subTitle', 'Create a new budget');
return view('budgets.create', compact('subTitle'));
}
/**
@ -190,7 +191,9 @@ class BudgetController extends Controller
public function show(BudgetRepositoryInterface $repository, Budget $budget, LimitRepetition $repetition = null)
{
if (!is_null($repetition->id) && $repetition->budgetLimit->budget->id != $budget->id) {
return view('error')->with('message', 'Invalid selection.');
$message = 'Invalid selection.';
return view('error', compact('message'));
}
$journals = $repository->getJournals($budget, $repetition);

View File

@ -2,7 +2,6 @@
use Auth;
use Carbon\Carbon;
use FireflyIII\Http\Requests;
use FireflyIII\Http\Requests\CategoryFormRequest;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
@ -41,8 +40,9 @@ class CategoryController extends Controller
Session::put('categories.create.url', URL::previous());
}
Session::forget('categories.create.fromStore');
$subTitle = 'Create a new category';
return view('categories.create')->with('subTitle', 'Create a new category');
return view('categories.create', compact('subTitle'));
}
/**

View File

@ -5,6 +5,7 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportQueryInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@ -227,6 +228,7 @@ class JsonController extends Controller
*/
public function setSharedReports()
{
/** @var Preference $pref */
$pref = Preferences::get('showSharedReports', false);
$new = !$pref->data;
Preferences::set('showSharedReports', $new);

View File

@ -32,16 +32,14 @@ class PreferencesController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
$viewRange = Preferences::get('viewRange', '1M');
$viewRangeValue = $viewRange->data;
$frontPage = Preferences::get('frontPageAccounts', []);
$budgetMax = Preferences::get('budgetMaximum', 1000);
$budgetMaximum = $budgetMax->data;
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$budgetMax = Preferences::get('budgetMaximum', 1000);
$budgetMaximum = $budgetMax->data;
return view('preferences.index', compact('budgetMaximum'))->with('accounts', $accounts)->with('frontPageAccounts', $frontPage)->with(
'viewRange', $viewRangeValue
);
return view('preferences.index', compact('budgetMaximum', 'accounts', 'frontPageAccounts', 'viewRange'));
}
/**

View File

@ -75,6 +75,7 @@ class ReportController extends Controller
// should always hide account
$hide = true;
// loop all budgets
/** @var \FireflyIII\Models\Budget $budget */
foreach ($budgets as $budget) {
$id = intval($budget->id);
$data = $budget->toArray();

View File

@ -249,11 +249,9 @@ class TransactionController extends Controller
$t->after = $t->before + $t->amount;
}
);
$subTitle = e($journal->transactiontype->type) . ' "' . e($journal->description) . '"';
return view('transactions.show', compact('journal'))->with(
'subTitle', e($journal->transactiontype->type) . ' "' . e($journal->description) . '"'
);
return view('transactions.show', compact('journal', 'subTitle'));
}
/**

View File

@ -413,6 +413,6 @@ Breadcrumbs::register(
Breadcrumbs::register(
'tags.show', function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.index');
$breadcrumbs->push(e($tag->tag), route('tags.show', $tag));
$breadcrumbs->push(e($tag->tag), route('tags.show', $tag->id));
}
);

View File

@ -13,6 +13,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
// models
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'account',
function ($value, $route) {
@ -30,6 +31,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'tj', function ($value, $route) {
if (Auth::check()) {
@ -43,6 +45,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'currency', function ($value, $route) {
if (Auth::check()) {
@ -55,6 +58,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'bill', function ($value, $route) {
if (Auth::check()) {
@ -68,6 +72,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'budget', function ($value, $route) {
if (Auth::check()) {
@ -81,6 +86,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'reminder', function ($value, $route) {
if (Auth::check()) {
@ -94,6 +100,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'limitrepetition', function ($value, $route) {
if (Auth::check()) {
@ -111,6 +118,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'piggyBank', function ($value, $route) {
if (Auth::check()) {
@ -127,6 +135,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'category', function ($value, $route) {
if (Auth::check()) {
@ -140,6 +149,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'reminder', function ($value, $route) {
if (Auth::check()) {
@ -156,6 +166,7 @@ Route::bind(
}
);
/** @noinspection PhpUnusedParameterInspection */
Route::bind(
'tag', function ($value, $route) {
if (Auth::check()) {

View File

@ -374,6 +374,8 @@ class AccountRepository implements AccountRepositoryInterface
/**
* @param Account $account
* @param array $data
*
* @return Account
*/
public function update(Account $account, array $data)
{

View File

@ -88,7 +88,7 @@ interface AccountRepositoryInterface
/**
* @param Account $account
* @param string $range
* @param $page
*
* @return LengthAwarePaginator
*/

View File

@ -211,10 +211,12 @@ class BillRepository implements BillRepositoryInterface
* $today is the start of the next period, to make sure FF3 won't miss anything
* when the current period has a transaction journal.
*/
$today = Navigation::addPeriod(new Carbon, $bill->repeat_freq, 0);
/** @var \Carbon\Carbon $obj */
$obj = new Carbon;
$today = Navigation::addPeriod($obj, $bill->repeat_freq, 0);
$skip = $bill->skip + 1;
$start = Navigation::startOfPeriod(new Carbon, $bill->repeat_freq);
$start = Navigation::startOfPeriod($obj, $bill->repeat_freq);
/*
* go back exactly one month/week/etc because FF3 does not care about 'next'
* bills if they're too far into the past.

View File

@ -72,8 +72,8 @@ interface CategoryRepositoryInterface
/**
* @param Category $category
* @param Carbon $start
* @param Carbon $end
* @param \Carbon\Carbon $start
* @param \Carbon\Carbon $end
*
* @return float
*/

View File

@ -27,13 +27,13 @@ class JournalRepository implements JournalRepositoryInterface
{
/**
* @param int $id
* @param int $reminderId
*
* @return bool
*/
public function deactivateReminder($id)
public function deactivateReminder($reminderId)
{
$reminder = Auth::user()->reminders()->find($id);
$reminder = Auth::user()->reminders()->find($reminderId);
if ($reminder) {
$reminder->active = 0;
$reminder->save();
@ -195,6 +195,7 @@ class JournalRepository implements JournalRepositoryInterface
// store or get budget
if (intval($data['budget_id']) > 0) {
/** @var \FireflyIII\Models\Budget $budget */
$budget = Budget::find($data['budget_id']);
$journal->budgets()->save($budget);
}
@ -254,6 +255,7 @@ class JournalRepository implements JournalRepositoryInterface
// unlink all budgets and recreate them:
$journal->budgets()->detach();
if (intval($data['budget_id']) > 0) {
/** @var \FireflyIII\Models\Budget $budget */
$budget = Budget::find($data['budget_id']);
$journal->budgets()->save($budget);
}

View File

@ -17,11 +17,11 @@ use Illuminate\Support\Collection;
interface JournalRepositoryInterface
{
/**
* @param int $id
* @param int $reminderId
*
* @return bool
*/
public function deactivateReminder($id);
public function deactivateReminder($reminderId);
/**
* @param TransactionJournal $journal

View File

@ -188,10 +188,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
}
/**
* @param PiggyBank $account
* @param PiggyBank $piggyBank
* @param array $data
*
* @return PiggyBank
* @internal param PiggyBank $account
*/
public function update(PiggyBank $piggyBank, array $data)
{

View File

@ -94,7 +94,7 @@ interface PiggyBankRepositoryInterface
public function store(array $data);
/**
* @param PiggyBank $account
* @param PiggyBank $piggyBank
* @param array $data
*
* @return PiggyBank

View File

@ -84,9 +84,11 @@ class Amount
}
/**
* @return string
*
* @param TransactionJournal $journal
* @param bool $coloured
*
* @return string
*/
public function formatJournal(TransactionJournal $journal, $coloured = true)
{
@ -167,6 +169,9 @@ class Amount
return 'EUR';
}
/**
* @return mixed|static
*/
public function getDefaultCurrency()
{
$currencyPreference = Prefs::get('currencyPreference', 'EUR');

View File

@ -240,8 +240,8 @@ class ExpandedForm
*
* Takes any collection and tries to make a sensible select list compatible array of it.
*
* @param Collection $set
* @param bool $addEmpty
* @param \Illuminate\Support\Collection $set
* @param bool $addEmpty
*
* @return mixed
*/
@ -288,10 +288,12 @@ class ExpandedForm
/**
* @param $name
* @param null $value
* @param array $list
* @param null $selected
* @param array $options
*
* @return string
* @internal param null $value
*/
public function multiRadio($name, array $list = [], $selected = null, array $options = [])
{

View File

@ -15,7 +15,7 @@ class Navigation
/**
* @param Carbon $theDate
* @param \Carbon\Carbon $theDate
* @param $repeatFreq
* @param $skip
*
@ -64,10 +64,10 @@ class Navigation
}
/**
* @param Carbon $theCurrentEnd
* @param \Carbon\Carbon $theCurrentEnd
* @param $repeatFreq
*
* @return Carbon
* @return \Carbon\Carbon
* @throws FireflyException
*/
public function endOfPeriod(Carbon $theCurrentEnd, $repeatFreq)
@ -301,10 +301,10 @@ class Navigation
}
/**
* @param Carbon $theDate
* @param \Carbon\Carbon $theDate
* @param $repeatFreq
*
* @return Carbon
* @return \Carbon\Carbon
* @throws FireflyException
*/
public function startOfPeriod(Carbon $theDate, $repeatFreq)
@ -388,9 +388,9 @@ class Navigation
/**
* @param $range
* @param Carbon $start
* @param \Carbon\Carbon $start
*
* @return Carbon
* @return \Carbon\Carbon
* @throws FireflyException
*/
public function updateEndDate($range, Carbon $start)
@ -423,10 +423,10 @@ class Navigation
}
/**
* @param $range
* @param Carbon $start
* @param $range
* @param \Carbon\Carbon $start
*
* @return Carbon
* @return \Carbon\Carbon
* @throws FireflyException
*/
public function updateStartDate($range, Carbon $start)

View File

@ -16,7 +16,7 @@ class Preferences
* @param $name
* @param null $default
*
* @return null|Preference
* @return null|\FireflyIII\Models\Preference
*/
public function get($name, $default = null)
{

View File

@ -121,6 +121,7 @@ class Search implements SearchInterface
return $journal;
}
}
return null;
}
);

View File

@ -17,8 +17,8 @@ class Steam
{
/**
*
* @param Account $account
* @param Carbon $date
* @param \FireflyIII\Models\Account $account
* @param \Carbon\Carbon $date
* @param bool $ignoreVirtualBalance
*
* @return float
@ -91,7 +91,7 @@ class Steam
* Turns a collection into an array. Needs the field 'id' for the key,
* and saves only 'name' and 'amount' as a sub array.
*
* @param Collection $collection
* @param \Illuminate\Support\Collection $collection
*
* @return array
*/

View File

@ -39,7 +39,7 @@ class Journal extends Twig_Extension
if ($type == 'Opening balance') {
return '<span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>';
}
return '';
}, ['is_safe' => ['html']]
);

View File

@ -4,6 +4,8 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class CreatePasswordResetsTable
*/
class CreatePasswordResetsTable extends Migration

View File

@ -5,7 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
* @SuppressWarnings("MethodLength") // I don't mind this in case of migrations.
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
*
* Class ChangesForV322
*/

View File

@ -5,7 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
* @SuppressWarnings("MethodLength") // I don't mind this in case of migrations.
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
*
* Class ChangesForV325
*/

View File

@ -4,6 +4,8 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class ChangesForV332
*/
class ChangesForV332 extends Migration

View File

@ -3,6 +3,11 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class ChangesForV333
*/
class ChangesForV333 extends Migration
{

View File

@ -4,6 +4,9 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
*
* Class ChangesForV336
*/
class ChangesForV336 extends Migration

View File

@ -3,6 +3,12 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
*
* Class ChangesForV3310
*/
class ChangesForV3310 extends Migration
{

View File

@ -4,6 +4,8 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class ChangesForV3310a
*/
class ChangesForV3310a extends Migration

View File

@ -3,6 +3,8 @@
use Illuminate\Database\Migrations\Migration;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class ChangesForV3310b
*/
class ChangesForV3310b extends Migration