Add typehints to object parameters

This commit is contained in:
James Cole 2015-03-29 07:43:20 +02:00
parent 907933f3df
commit ba9877c9b4
10 changed files with 29 additions and 21 deletions

View File

@ -272,15 +272,15 @@ class ReportQuery implements ReportQueryInterface
// only get deposits not to a shared account // only get deposits not to a shared account
// and transfers to a shared account. // and transfers to a shared account.
$query->where( $query->where(
function ($query) { function (Builder $query) {
$query->where( $query->where(
function ($q) { function (Builder $q) {
$q->where('transaction_types.type', 'Deposit'); $q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedAsset"'); $q->where('acm_to.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function ($q) { function (Builder $q) {
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_from.data', '=', '"sharedAsset"'); $q->where('acm_from.data', '=', '"sharedAsset"');
} }
@ -427,15 +427,15 @@ class ReportQuery implements ReportQueryInterface
// get all withdrawals not from a shared accounts // get all withdrawals not from a shared accounts
// and all transfers to a shared account // and all transfers to a shared account
$query->where( $query->where(
function ($query) { function (Builder $query) {
$query->where( $query->where(
function ($q) { function (Builder $q) {
$q->where('transaction_types.type', 'Withdrawal'); $q->where('transaction_types.type', 'Withdrawal');
$q->where('acm_from.data', '!=', '"sharedAsset"'); $q->where('acm_from.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function ($q) { function (Builder $q) {
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_to.data', '=', '"sharedAsset"'); $q->where('acm_to.data', '=', '"sharedAsset"');
} }
@ -495,15 +495,15 @@ class ReportQuery implements ReportQueryInterface
// show queries where transfer type is deposit, and its not to a shared account // show queries where transfer type is deposit, and its not to a shared account
// or where its a transfer and its from a shared account (both count as incomes) // or where its a transfer and its from a shared account (both count as incomes)
$query->where( $query->where(
function ($query) { function (Builder $query) {
$query->where( $query->where(
function ($q) { function (Builder $q) {
$q->where('transaction_types.type', 'Deposit'); $q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedAsset"'); $q->where('acm_to.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function ($q) { function (Builder $q) {
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_from.data', '=', '"sharedAsset"'); $q->where('acm_from.data', '=', '"sharedAsset"');
} }

View File

@ -7,6 +7,7 @@ use FireflyIII\Http\Requests;
use FireflyIII\Http\Requests\AccountFormRequest; use FireflyIII\Http\Requests\AccountFormRequest;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Input; use Input;
use Redirect; use Redirect;
@ -124,7 +125,7 @@ class AccountController extends Controller
// move to repository: // move to repository:
$set = Auth::user()->accounts()->with( $set = Auth::user()->accounts()->with(
['accountmeta' => function ($query) { ['accountmeta' => function (HasMany $query) {
$query->where('name', 'accountRole'); $query->where('name', 'accountRole');
}] }]
)->accountTypeIn($types)->take($size)->offset($offset)->orderBy('accounts.name', 'ASC')->get(['accounts.*']); )->accountTypeIn($types)->take($size)->offset($offset)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);

View File

@ -5,6 +5,7 @@ use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar; use Illuminate\Contracts\Auth\Registrar;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Mail\Message;
use Mail; use Mail;
use Session; use Session;
@ -73,7 +74,7 @@ class AuthController extends Controller
// send email. // send email.
Mail::send( Mail::send(
'emails.registered', [], function ($message) use ($email) { 'emails.registered', [], function (Message $message) use ($email) {
$message->to($email, $email)->subject('Welcome to Firefly III!'); $message->to($email, $email)->subject('Welcome to Firefly III!');
} }
); );

View File

@ -2,6 +2,7 @@
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
/** /**
* Class Authenticate * Class Authenticate
@ -37,7 +38,7 @@ class Authenticate
* *
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle(Request $request, Closure $next)
{ {
if ($this->auth->guest()) { if ($this->auth->guest()) {
if ($request->ajax()) { if ($request->ajax()) {

View File

@ -10,6 +10,7 @@ use FireflyIII\Models\PiggyBankRepetition;
use FireflyIII\Models\Reminder; use FireflyIII\Models\Reminder;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Illuminate\Http\Request;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Navigation; use Navigation;
use Session; use Session;
@ -48,7 +49,7 @@ class PiggyBanks
* *
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle(Request $request, Closure $next)
{ {
if ($this->auth->check() && !$request->isXmlHttpRequest()) { if ($this->auth->check() && !$request->isXmlHttpRequest()) {
// get piggy banks without a repetition: // get piggy banks without a repetition:

View File

@ -6,6 +6,7 @@ namespace FireflyIII\Http\Middleware;
use Carbon\Carbon; use Carbon\Carbon;
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Session; use Session;
@ -44,7 +45,7 @@ class Range
* *
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $theNext) public function handle(Request $request, Closure $theNext)
{ {
if ($this->auth->check()) { if ($this->auth->check()) {

View File

@ -3,6 +3,7 @@
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
/** /**
* Class RedirectIfAuthenticated * Class RedirectIfAuthenticated
@ -38,7 +39,7 @@ class RedirectIfAuthenticated
* *
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle(Request $request, Closure $next)
{ {
if ($this->auth->check()) { if ($this->auth->check()) {
return new RedirectResponse(url('/')); return new RedirectResponse(url('/'));

View File

@ -8,6 +8,7 @@ use Closure;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Reminder; use FireflyIII\Models\Reminder;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use View; use View;
/** /**
@ -43,7 +44,7 @@ class Reminders
* *
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle(Request $request, Closure $next)
{ {
if ($this->auth->check() && !$request->isXmlHttpRequest()) { if ($this->auth->check() && !$request->isXmlHttpRequest()) {
// do reminders stuff. // do reminders stuff.

View File

@ -5,14 +5,15 @@ namespace FireflyIII\Http\Middleware;
use Closure; use Closure;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\Middleware; use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Request;
use Log; use Log;
/** /**
* Class ReplaceTestVars * Class ReplaceTestVars
* *
* @package App\Http\Middleware * @package FireflyIII\Http\Middleware
*/ */
class ReplaceTestVars implements Middleware class ReplaceTestVars
{ {
/** /**
* The application implementation. * The application implementation.
@ -40,7 +41,7 @@ class ReplaceTestVars implements Middleware
* *
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle(Request $request, Closure $next)
{ {
if ('testing' === $this->app->environment() && $request->has('_token')) { if ('testing' === $this->app->environment() && $request->has('_token')) {
$input = $request->all(); $input = $request->all();

View File

@ -5,7 +5,7 @@ namespace FireflyIII\Http\Requests;
use Auth; use Auth;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use Input; use Input;
use Exception;
/** /**
* Class JournalFormRequest * Class JournalFormRequest
* *
@ -62,7 +62,7 @@ class JournalFormRequest extends Request
$rules['category'] = 'between:1,255'; $rules['category'] = 'between:1,255';
break; break;
default: default:
die('Cannot handle ' . $what); throw new Exception('Cannot handle ' . $what);
break; break;
} }