Code cleanup.

This commit is contained in:
James Cole
2018-04-02 14:17:11 +02:00
parent 4cea5d65a6
commit f96f38b172
44 changed files with 87 additions and 100 deletions

View File

@@ -35,16 +35,6 @@ use League\Fractal\Serializer\JsonApiSerializer;
*/ */
class AboutController extends Controller class AboutController extends Controller
{ {
/**
* AccountController constructor.
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function __construct()
{
parent::__construct();
}
/** /**
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */

View File

@@ -103,7 +103,7 @@ class AccountController extends Controller
// types to get, page size: // types to get, page size:
$types = $this->mapTypes($this->parameters->get('type')); $types = $this->mapTypes($this->parameters->get('type'));
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it. // get list of accounts. Count it and split it.
$collection = $this->repository->getAccountsByType($types); $collection = $this->repository->getAccountsByType($types);
@@ -154,7 +154,7 @@ class AccountController extends Controller
// if currency ID is 0, find the currency by the code: // if currency ID is 0, find the currency by the code:
if (0 === $data['currency_id']) { if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']); $currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id; $data['currency_id'] = null === $currency ? 0 : $currency->id;
} }
$account = $this->repository->store($data); $account = $this->repository->store($data);
$manager = new Manager(); $manager = new Manager();
@@ -180,7 +180,7 @@ class AccountController extends Controller
// if currency ID is 0, find the currency by the code: // if currency ID is 0, find the currency by the code:
if (0 === $data['currency_id']) { if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']); $currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id; $data['currency_id'] = null === $currency ? 0 : $currency->id;
} }
// set correct type: // set correct type:
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type); $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);

View File

@@ -85,7 +85,7 @@ class BillController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
$paginator = $this->repository->getPaginator($pageSize); $paginator = $this->repository->getPaginator($pageSize);
/** @var Collection $bills */ /** @var Collection $bills */
$bills = $paginator->getCollection(); $bills = $paginator->getCollection();

View File

@@ -107,7 +107,7 @@ class Controller extends BaseController
foreach ($dates as $field) { foreach ($dates as $field) {
$date = request()->get($field); $date = request()->get($field);
$obj = null; $obj = null;
if (!is_null($date)) { if (null !== $date) {
try { try {
$obj = new Carbon($date); $obj = new Carbon($date);
} catch (InvalidDateException $e) { } catch (InvalidDateException $e) {

View File

@@ -91,7 +91,7 @@ class TransactionController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// read type from URI // read type from URI
$type = $request->get('type') ?? 'default'; $type = $request->get('type') ?? 'default';
@@ -115,7 +115,7 @@ class TransactionController extends Controller
$collector->removeFilter(InternalTransferFilter::class); $collector->removeFilter(InternalTransferFilter::class);
} }
if (!is_null($this->parameters->get('start')) && !is_null($this->parameters->get('end'))) { if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); $collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
} }
$collector->setLimit($pageSize)->setPage($this->parameters->get('page')); $collector->setLimit($pageSize)->setPage($this->parameters->get('page'));

View File

@@ -92,7 +92,7 @@ class UserController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
// user preferences // user preferences
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// make manager // make manager
$manager = new Manager(); $manager = new Manager();

View File

@@ -108,8 +108,8 @@ class BillRequest extends Request
$validator->after( $validator->after(
function (Validator $validator) { function (Validator $validator) {
$data = $validator->getData(); $data = $validator->getData();
$min = floatval($data['amount_min'] ?? 0); $min = (float)($data['amount_min'] ?? 0);
$max = floatval($data['amount_max'] ?? 0); $max = (float)($data['amount_max'] ?? 0);
if ($min > $max) { if ($min > $max) {
$validator->errors()->add('amount_min', trans('validation.amount_min_over_max')); $validator->errors()->add('amount_min', trans('validation.amount_min_over_max'));
} }

View File

@@ -76,14 +76,14 @@ class User extends Authenticatable
* @param string $value * @param string $value
* *
* @return User * @return User
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @throws NotFoundHttpException
*/ */
public static function routeBinder(string $value): User public static function routeBinder(string $value): User
{ {
if (auth()->check()) { if (auth()->check()) {
$userId = intval($value); $userId = (int)$value;
$user = self::find($userId); $user = self::find($userId);
if (!is_null($user)) { if (null !== $user) {
return $user; return $user;
} }
} }
@@ -212,7 +212,7 @@ class User extends Authenticatable
{ {
$bytes = random_bytes(16); $bytes = random_bytes(16);
return strval(bin2hex($bytes)); return (string)bin2hex($bytes);
} }
/** /**

View File

@@ -239,8 +239,8 @@ $factory->define(
FireflyIII\Models\Transaction::class, FireflyIII\Models\Transaction::class,
function (Faker\Generator $faker) { function (Faker\Generator $faker) {
return [ return [
'transaction_amount' => strval($faker->randomFloat(2, -100, 100)), 'transaction_amount' => (string)$faker->randomFloat(2, -100, 100),
'destination_amount' => strval($faker->randomFloat(2, -100, 100)), 'destination_amount' => (string)$faker->randomFloat(2, -100, 100),
'opposing_account_id' => $faker->numberBetween(1, 10), 'opposing_account_id' => $faker->numberBetween(1, 10),
'source_account_id' => $faker->numberBetween(1, 10), 'source_account_id' => $faker->numberBetween(1, 10),
'opposing_account_name' => $faker->words(3, true), 'opposing_account_name' => $faker->words(3, true),
@@ -249,7 +249,7 @@ $factory->define(
'destination_account_id' => $faker->numberBetween(1, 10), 'destination_account_id' => $faker->numberBetween(1, 10),
'date' => new Carbon, 'date' => new Carbon,
'destination_account_name' => $faker->words(3, true), 'destination_account_name' => $faker->words(3, true),
'amount' => strval($faker->randomFloat(2, -100, 100)), 'amount' => (string)$faker->randomFloat(2, -100, 100),
'budget_id' => 0, 'budget_id' => 0,
'category' => $faker->words(3, true), 'category' => $faker->words(3, true),
'transaction_journal_id' => $faker->numberBetween(1, 10), 'transaction_journal_id' => $faker->numberBetween(1, 10),

View File

@@ -14,7 +14,7 @@ class ConfigSeeder extends Seeder
public function run() public function run()
{ {
$entry = Configuration::where('name', 'db_version')->first(); $entry = Configuration::where('name', 'db_version')->first();
if (is_null($entry)) { if (null === $entry) {
Log::warning('No database version entry is present. Database is assumed to be OLD (version 1).'); Log::warning('No database version entry is present. Database is assumed to be OLD (version 1).');
// FF old or no version present. Put at 1: // FF old or no version present. Put at 1:
Configuration::create( Configuration::create(
@@ -24,8 +24,8 @@ class ConfigSeeder extends Seeder
] ]
); );
} }
if (!is_null($entry)) { if (null !== $entry) {
$version = intval(config('firefly.db_version')); $version = (int)config('firefly.db_version');
$entry->data = $version; $entry->data = $version;
$entry->save(); $entry->save();

View File

@@ -54,6 +54,7 @@ require __DIR__ . '/../vendor/autoload.php';
| |
*/ */
/** @noinspection UsingInclusionOnceReturnValueInspection */
$app = require_once __DIR__ . '/../bootstrap/app.php'; $app = require_once __DIR__ . '/../bootstrap/app.php';
/* /*

View File

@@ -127,6 +127,5 @@ function getBalanceBox() {
$('#box-balance-list').html(current + '<span title="' + string + '">' + string + '</span>' + '<br>'); $('#box-balance-list').html(current + '<span title="' + string + '">' + string + '</span>' + '<br>');
count++; count++;
} }
return;
}); });
} }

View File

@@ -83,8 +83,6 @@ function selectsDifferentSource() {
$('.currency-option[data-id="' + sourceCurrency + '"]').click(); $('.currency-option[data-id="' + sourceCurrency + '"]').click();
$('[data-toggle="dropdown"]').parent().removeClass('open'); $('[data-toggle="dropdown"]').parent().removeClass('open');
$('select[name="source_account_id"]').focus(); $('select[name="source_account_id"]').focus();
return;
} }
/** /**
@@ -107,8 +105,6 @@ function selectsDifferentDestination() {
$('.currency-option[data-id="' + destinationCurrency + '"]').click(); $('.currency-option[data-id="' + destinationCurrency + '"]').click();
$('[data-toggle="dropdown"]').parent().removeClass('open'); $('[data-toggle="dropdown"]').parent().removeClass('open');
$('select[name="destination_account_id"]').focus(); $('select[name="destination_account_id"]').focus();
return;
} }

View File

@@ -784,6 +784,7 @@ return [
'opt_group_sharedAsset' => 'Shared asset accounts', 'opt_group_sharedAsset' => 'Shared asset accounts',
'opt_group_ccAsset' => 'Credit cards', 'opt_group_ccAsset' => 'Credit cards',
'notes' => 'Notes', 'notes' => 'Notes',
'unknown_journal_error' => 'Could not store the transaction. Please check the log files.',
// new user: // new user:
'welcome' => 'Welcome to Firefly III!', 'welcome' => 'Welcome to Firefly III!',
@@ -1136,6 +1137,7 @@ return [
'import_index_title' => 'Import data into Firefly III', 'import_index_title' => 'Import data into Firefly III',
'import_index_sub_title' => 'Index', 'import_index_sub_title' => 'Index',
'import_general_index_intro' => 'Welcome to Firefly III\'s import routine. There are a few ways of importing data into Firefly III, displayed here as buttons.', 'import_general_index_intro' => 'Welcome to Firefly III\'s import routine. There are a few ways of importing data into Firefly III, displayed here as buttons.',
'upload_error' => 'The file you have uploaded could not be processed. Possibly it is of an invalid file type or encoding. The log files will have more information.',
// sandstorm.io errors and messages: // sandstorm.io errors and messages:
'sandstorm_not_available' => 'This function is not available when you are using Firefly III within a Sandstorm.io environment.', 'sandstorm_not_available' => 'This function is not available when you are using Firefly III within a Sandstorm.io environment.',

View File

@@ -81,11 +81,11 @@ Breadcrumbs::register(
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push($account->name, route('accounts.show', [$account->id])); $breadcrumbs->push($account->name, route('accounts.show', [$account->id]));
if (!is_null($start) && !is_null($end)) { if (null !== $start && null !== $end) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start ? $start->formatLocalized(strval(trans('config.month_and_day'))) : '', ['start' => $start ? $start->formatLocalized((string)trans('config.month_and_day')) : '',
'end' => $end ? $end->formatLocalized(strval(trans('config.month_and_day'))) : '',] 'end' => $end ? $end->formatLocalized((string)trans('config.month_and_day')) : '',]
); );
$breadcrumbs->push($title, route('accounts.show', $account)); $breadcrumbs->push($title, route('accounts.show', $account));
} }
@@ -357,8 +357,8 @@ Breadcrumbs::register(
if ('all' !== $moment && '(nothing)' !== $moment) { if ('all' !== $moment && '(nothing)' !== $moment) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), ['start' => $start->formatLocalized((string)trans('config.month_and_day')),
'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] 'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
); );
$breadcrumbs->push($title, route('budgets.no-budget', [$moment])); $breadcrumbs->push($title, route('budgets.no-budget', [$moment]));
} }
@@ -382,8 +382,8 @@ Breadcrumbs::register(
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $budgetLimit->start_date->formatLocalized(strval(trans('config.month_and_day'))), ['start' => $budgetLimit->start_date->formatLocalized((string)trans('config.month_and_day')),
'end' => $budgetLimit->end_date->formatLocalized(strval(trans('config.month_and_day'))),] 'end' => $budgetLimit->end_date->formatLocalized((string)trans('config.month_and_day')),]
); );
$breadcrumbs->push( $breadcrumbs->push(
@@ -438,8 +438,8 @@ Breadcrumbs::register(
if ('all' !== $moment && '(nothing)' !== $moment) { if ('all' !== $moment && '(nothing)' !== $moment) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), ['start' => $start->formatLocalized((string)trans('config.month_and_day')),
'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] 'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
); );
$breadcrumbs->push($title, route('categories.show', [$category->id, $moment])); $breadcrumbs->push($title, route('categories.show', [$category->id, $moment]));
} }
@@ -460,8 +460,8 @@ Breadcrumbs::register(
if ('all' !== $moment && '(nothing)' !== $moment) { if ('all' !== $moment && '(nothing)' !== $moment) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), ['start' => $start->formatLocalized((string)trans('config.month_and_day')),
'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] 'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
); );
$breadcrumbs->push($title, route('categories.no-category', [$moment])); $breadcrumbs->push($title, route('categories.no-category', [$moment]));
} }
@@ -878,8 +878,8 @@ Breadcrumbs::register(
if ('all' !== $moment && '(nothing)' !== $moment) { if ('all' !== $moment && '(nothing)' !== $moment) {
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), ['start' => $start->formatLocalized((string)trans('config.month_and_day')),
'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] 'end' => $end->formatLocalized((string)trans('config.month_and_day')),]
); );
$breadcrumbs->push($title, route('tags.show', [$tag->id, $moment])); $breadcrumbs->push($title, route('tags.show', [$tag->id, $moment]));
} }

View File

@@ -2395,7 +2395,7 @@ class TransactionControllerTest extends TestCase
'description' => 'Some transaction #' . random_int(1, 1000), 'description' => 'Some transaction #' . random_int(1, 1000),
'date' => '2018-01-01', 'date' => '2018-01-01',
'type' => 'withdrawal', 'type' => 'withdrawal',
'tags' => join(',', $tags), 'tags' => implode(',', $tags),
'transactions' => [ 'transactions' => [
[ [
'amount' => '10', 'amount' => '10',

View File

@@ -370,7 +370,7 @@ class ProfileControllerTest extends TestCase
{ {
$token = ''; $token = '';
$currentToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first(); $currentToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first();
if (!is_null($currentToken)) { if (null !== $currentToken) {
$token = $currentToken->data; $token = $currentToken->data;
} }
$this->be($this->user()); $this->be($this->user());

View File

@@ -97,7 +97,7 @@ class BulkControllerTest extends TestCase
// default transactions // default transactions
$collection = $this->user()->transactionJournals()->take(4)->get(); $collection = $this->user()->transactionJournals()->take(4)->get();
$allIds = $collection->pluck('id')->toArray(); $allIds = $collection->pluck('id')->toArray();
$route = route('transactions.bulk.edit', join(',', $allIds)); $route = route('transactions.bulk.edit', implode(',', $allIds));
$this->be($this->user()); $this->be($this->user());
$response = $this->get($route); $response = $this->get($route);
$response->assertStatus(200); $response->assertStatus(200);
@@ -133,7 +133,7 @@ class BulkControllerTest extends TestCase
// default transactions // default transactions
$collection = $this->user()->transactionJournals()->take(4)->get(); $collection = $this->user()->transactionJournals()->take(4)->get();
$allIds = $collection->pluck('id')->toArray(); $allIds = $collection->pluck('id')->toArray();
$route = route('transactions.bulk.edit', join(',', $allIds)); $route = route('transactions.bulk.edit', implode(',', $allIds));
$this->be($this->user()); $this->be($this->user());
$response = $this->get($route); $response = $this->get($route);
$response->assertStatus(200); $response->assertStatus(200);

View File

@@ -162,7 +162,7 @@ class MassControllerTest extends TestCase
// default transactions // default transactions
$collection = $this->user()->transactionJournals()->take(4)->get(); $collection = $this->user()->transactionJournals()->take(4)->get();
$allIds = $collection->pluck('id')->toArray(); $allIds = $collection->pluck('id')->toArray();
$route = route('transactions.mass.edit', join(',', $allIds)); $route = route('transactions.mass.edit', implode(',', $allIds));
$this->be($this->user()); $this->be($this->user());
$response = $this->get($route); $response = $this->get($route);
$response->assertStatus(200); $response->assertStatus(200);
@@ -204,7 +204,7 @@ class MassControllerTest extends TestCase
$allIds = $collection->pluck('id')->toArray(); $allIds = $collection->pluck('id')->toArray();
$this->be($this->user()); $this->be($this->user());
$response = $this->get(route('transactions.mass.edit', join(',', $allIds))); $response = $this->get(route('transactions.mass.edit', implode(',', $allIds)));
$response->assertStatus(200); $response->assertStatus(200);
$response->assertSee('Edit a number of transactions'); $response->assertSee('Edit a number of transactions');
$response->assertSessionHas('error', 'You have selected no valid transactions to edit.'); $response->assertSessionHas('error', 'You have selected no valid transactions to edit.');

View File

@@ -99,9 +99,7 @@ abstract class TestCase extends BaseTestCase
*/ */
public function demoUser(): User public function demoUser(): User
{ {
$user = User::find(4); return User::find(4);
return $user;
} }
/** /**
@@ -109,9 +107,7 @@ abstract class TestCase extends BaseTestCase
*/ */
public function emptyUser(): User public function emptyUser(): User
{ {
$user = User::find(2); return User::find(2);
return $user;
} }
/** /**
@@ -119,9 +115,7 @@ abstract class TestCase extends BaseTestCase
*/ */
public function user(): User public function user(): User
{ {
$user = User::find(1); return User::find(1);
return $user;
} }
/** /**
@@ -145,10 +139,8 @@ abstract class TestCase extends BaseTestCase
*/ */
protected function overload(string $class) protected function overload(string $class)
{ {
$externalMock = Mockery::mock('overload:' . $class);
//$this->app->instance($class, $externalMock); //$this->app->instance($class, $externalMock);
return $externalMock; return Mockery::mock('overload:' . $class);
} }
/** /**

View File

@@ -212,7 +212,7 @@ class AccountFactoryTest extends TestCase
// find opening balance: // find opening balance:
$this->assertEquals(1, $account->transactions()->count()); $this->assertEquals(1, $account->transactions()->count());
$this->assertEquals(100, floatval($account->transactions()->first()->amount)); $this->assertEquals(100, (float)$account->transactions()->first()->amount);
} }
/** /**
@@ -361,7 +361,7 @@ class AccountFactoryTest extends TestCase
// find opening balance: // find opening balance:
$this->assertEquals(1, $account->transactions()->count()); $this->assertEquals(1, $account->transactions()->count());
$this->assertEquals(-100, floatval($account->transactions()->first()->amount)); $this->assertEquals(-100, (float)$account->transactions()->first()->amount);
} }
/** /**

View File

@@ -45,7 +45,7 @@ class AttachmentHelperTest extends TestCase
{ {
$attachment = Attachment::first(); $attachment = Attachment::first();
$helper = new AttachmentHelper; $helper = new AttachmentHelper;
$path = $path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, intval($attachment->id)); $path = $path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, (int)$attachment->id);
$this->assertEquals($helper->getAttachmentLocation($attachment), $path); $this->assertEquals($helper->getAttachmentLocation($attachment), $path);
} }

View File

@@ -57,7 +57,7 @@ class AssetAccountIbansTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
53 => 'Else', 53 => 'Else',
17 => 'IBAN (Something)', 17 => 'IBAN (Something)',
]; ];

View File

@@ -57,7 +57,7 @@ class AssetAccountsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
19 => 'Else', 19 => 'Else',
23 => 'Something (IBAN)', 23 => 'Something (IBAN)',

View File

@@ -58,7 +58,7 @@ class BillsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
9 => 'Else [match]', 9 => 'Else [match]',
5 => 'Something [hi,bye]', 5 => 'Something [hi,bye]',
]; ];

View File

@@ -55,7 +55,7 @@ class BudgetsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
4 => 'Else', 4 => 'Else',
8 => 'Something', 8 => 'Something',

View File

@@ -55,7 +55,7 @@ class CategoriesTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
17 => 'Else', 17 => 'Else',
9 => 'Something', 9 => 'Something',

View File

@@ -59,7 +59,7 @@ class OpposingAccountIbansTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
17 => 'Else', 17 => 'Else',
21 => 'IBAN (Something)', 21 => 'IBAN (Something)',
]; ];

View File

@@ -59,7 +59,7 @@ class OpposingAccountsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
9 => 'Else', 9 => 'Else',
13 => 'Something (IBAN)', 13 => 'Something (IBAN)',
]; ];

View File

@@ -55,7 +55,7 @@ class TagsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
14 => 'Else', 14 => 'Else',
12 => 'Something', 12 => 'Something',
]; ];

View File

@@ -57,7 +57,7 @@ class TransactionCurrenciesTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => (string)trans('import.map_do_not_map'),
11 => 'Else (DEF)', 11 => 'Else (DEF)',
9 => 'Something (ABC)', 9 => 'Something (ABC)',

View File

@@ -27,7 +27,7 @@ use FireflyIII\Import\Object\ImportAccount;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Support\Collection;
use Mockery; use Mockery;
use Tests\TestCase; use Tests\TestCase;

View File

@@ -77,7 +77,7 @@ class AuthenticateTest extends TestCase
$this->be($user); $this->be($user);
$response = $this->get('/_test/authenticate'); $response = $this->get('/_test/authenticate');
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
$response->assertSessionHas('logoutMessage', strval(trans('firefly.block_account_logout'))); $response->assertSessionHas('logoutMessage', (string)trans('firefly.block_account_logout'));
$response->assertRedirect(route('login')); $response->assertRedirect(route('login'));
} }
@@ -94,7 +94,7 @@ class AuthenticateTest extends TestCase
$this->be($user); $this->be($user);
$response = $this->get('/_test/authenticate'); $response = $this->get('/_test/authenticate');
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
$response->assertSessionHas('logoutMessage', strval(trans('firefly.email_changed_logout'))); $response->assertSessionHas('logoutMessage', (string)trans('firefly.email_changed_logout'));
$response->assertRedirect(route('login')); $response->assertRedirect(route('login'));
} }

View File

@@ -1241,7 +1241,7 @@ class BinderTest extends TestCase
} }
); );
$names = join(',', $tags->pluck('tag')->toArray()); $names = implode(',', $tags->pluck('tag')->toArray());
$this->be($this->user()); $this->be($this->user());

View File

@@ -65,7 +65,7 @@ class IsSandstormUserTest extends TestCase
$response = $this->get('/_test/is-sandstorm'); $response = $this->get('/_test/is-sandstorm');
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
$response->assertSessionHas('warning', strval(trans('firefly.sandstorm_not_available'))); $response->assertSessionHas('warning', (string)trans('firefly.sandstorm_not_available'));
$response->assertRedirect(route('index')); $response->assertRedirect(route('index'));
putenv('SANDSTORM=0'); putenv('SANDSTORM=0');
} }

View File

@@ -128,7 +128,7 @@ class TransactionUpdateServiceTest extends TestCase
'foreign_amount' => null, 'foreign_amount' => null,
'budget_id' => null, 'budget_id' => null,
'budget_name' => null, 'budget_name' => null,
'destination_id' => intval($source->account_id), 'destination_id' => (int)$source->account_id,
'destination_name' => null, 'destination_name' => null,
'category_id' => null, 'category_id' => null,
'category_name' => null, 'category_name' => null,
@@ -167,7 +167,7 @@ class TransactionUpdateServiceTest extends TestCase
'foreign_amount' => '12.34', 'foreign_amount' => '12.34',
'budget_id' => null, 'budget_id' => null,
'budget_name' => null, 'budget_name' => null,
'destination_id' => intval($source->account_id), 'destination_id' => (int)$source->account_id,
'destination_name' => null, 'destination_name' => null,
'category_id' => null, 'category_id' => null,
'category_name' => null, 'category_name' => null,
@@ -210,7 +210,7 @@ class TransactionUpdateServiceTest extends TestCase
'foreign_amount' => null, 'foreign_amount' => null,
'budget_id' => null, 'budget_id' => null,
'budget_name' => null, 'budget_name' => null,
'source_id' => intval($source->account_id), 'source_id' => (int)$source->account_id,
'source_name' => null, 'source_name' => null,
'category_id' => null, 'category_id' => null,
'category_name' => null, 'category_name' => null,

View File

@@ -44,7 +44,7 @@ class AppendNotesTest extends TestCase
$note = $journal->notes()->first(); $note = $journal->notes()->first();
$start = 'Default note text'; $start = 'Default note text';
$toAppend = 'This is appended'; $toAppend = 'This is appended';
if (is_null($note)) { if (null === $note) {
$note = new Note(); $note = new Note();
$note->noteable()->associate($journal); $note->noteable()->associate($journal);
} }
@@ -71,7 +71,7 @@ class AppendNotesTest extends TestCase
// give journal some notes. // give journal some notes.
$journal = TransactionJournal::find(4); $journal = TransactionJournal::find(4);
$note = $journal->notes()->first(); $note = $journal->notes()->first();
if (!is_null($note)) { if (null !== $note) {
$note->forceDelete(); $note->forceDelete();
} }
$toAppend = 'This is appended'; $toAppend = 'This is appended';

View File

@@ -42,7 +42,7 @@ class ClearNotesTest extends TestCase
// give journal a note: // give journal a note:
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$note = $journal->notes()->first(); $note = $journal->notes()->first();
if (is_null($note)) { if (null === $note) {
$note = new Note; $note = new Note;
$note->noteable()->associate($journal); $note->noteable()->associate($journal);
} }

View File

@@ -44,7 +44,7 @@ class PrependNotesTest extends TestCase
$note = $journal->notes()->first(); $note = $journal->notes()->first();
$start = 'Default note text'; $start = 'Default note text';
$toPrepend = 'This is prepended'; $toPrepend = 'This is prepended';
if (is_null($note)) { if (null === $note) {
$note = new Note(); $note = new Note();
$note->noteable()->associate($journal); $note->noteable()->associate($journal);
} }
@@ -71,7 +71,7 @@ class PrependNotesTest extends TestCase
// give journal some notes. // give journal some notes.
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$note = $journal->notes()->first(); $note = $journal->notes()->first();
if (!is_null($note)) { if (null !== $note) {
$note->forceDelete(); $note->forceDelete();
} }
$toPrepend = 'This is appended'; $toPrepend = 'This is appended';

View File

@@ -41,7 +41,7 @@ class RemoveAllTagsTest extends TestCase
{ {
// find journal with at least one tag // find journal with at least one tag
$journalIds = DB::table('tag_transaction_journal')->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); $journalIds = DB::table('tag_transaction_journal')->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
$journalId = intval($journalIds[0]); $journalId = (int)$journalIds[0];
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
$journal = TransactionJournal::find($journalId); $journal = TransactionJournal::find($journalId);

View File

@@ -42,7 +42,7 @@ class RemoveTagTest extends TestCase
// find journal with at least one tag // find journal with at least one tag
$journalIds = DB::table('tag_transaction_journal')->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); $journalIds = DB::table('tag_transaction_journal')->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
$journalId = intval($journalIds[0]); $journalId = (int)$journalIds[0];
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
$journal = TransactionJournal::find($journalId); $journal = TransactionJournal::find($journalId);
$originalCount = $journal->tags()->count(); $originalCount = $journal->tags()->count();

View File

@@ -42,7 +42,7 @@ class SetNotesTest extends TestCase
// give journal a note: // give journal a note:
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$note = $journal->notes()->first(); $note = $journal->notes()->first();
if (is_null($note)) { if (null === $note) {
$note = new Note; $note = new Note;
$note->noteable()->associate($journal); $note->noteable()->associate($journal);
} }

View File

@@ -36,9 +36,12 @@ class FromAccountStartsTest extends TestCase
*/ */
public function testTriggered() public function testTriggered()
{ {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $transaction = null;
$transaction = $journal->transactions()->where('amount', '<', 0)->first(); do {
$account = $transaction->account; $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
} while (null === $transaction);
$account = $transaction->account;
$trigger = FromAccountStarts::makeFromStrings(substr($account->name, 0, -3), false); $trigger = FromAccountStarts::makeFromStrings(substr($account->name, 0, -3), false);
$result = $trigger->triggered($journal); $result = $trigger->triggered($journal);
@@ -50,8 +53,12 @@ class FromAccountStartsTest extends TestCase
*/ */
public function testTriggeredLonger() public function testTriggeredLonger()
{ {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $transaction = null;
$transaction = $journal->transactions()->where('amount', '<', 0)->first(); do {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
} while (null === $transaction);
$account = $transaction->account; $account = $transaction->account;
$trigger = FromAccountStarts::makeFromStrings('bla-bla-bla' . $account->name, false); $trigger = FromAccountStarts::makeFromStrings('bla-bla-bla' . $account->name, false);

View File

@@ -74,7 +74,7 @@ class ToAccountEndsTest extends TestCase
{ {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = ToAccountEnds::makeFromStrings(strval(random_int(1, 234)), false); $trigger = ToAccountEnds::makeFromStrings((string)random_int(1, 234), false);
$result = $trigger->triggered($journal); $result = $trigger->triggered($journal);
$this->assertFalse($result); $this->assertFalse($result);
} }