diff --git a/app/Api/V1/Controllers/AboutController.php b/app/Api/V1/Controllers/AboutController.php index 721ec068fe..e7fcc291c3 100644 --- a/app/Api/V1/Controllers/AboutController.php +++ b/app/Api/V1/Controllers/AboutController.php @@ -35,16 +35,6 @@ use League\Fractal\Serializer\JsonApiSerializer; */ class AboutController extends Controller { - /** - * AccountController constructor. - * - * @throws \FireflyIII\Exceptions\FireflyException - */ - public function __construct() - { - parent::__construct(); - } - /** * @return \Illuminate\Http\JsonResponse */ diff --git a/app/Api/V1/Controllers/AccountController.php b/app/Api/V1/Controllers/AccountController.php index 7fa157ff1d..cff7969f6f 100644 --- a/app/Api/V1/Controllers/AccountController.php +++ b/app/Api/V1/Controllers/AccountController.php @@ -103,7 +103,7 @@ class AccountController extends Controller // types to get, page size: $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. $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 (0 === $data['currency_id']) { $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); $manager = new Manager(); @@ -180,7 +180,7 @@ class AccountController extends Controller // if currency ID is 0, find the currency by the code: if (0 === $data['currency_id']) { $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: $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type); diff --git a/app/Api/V1/Controllers/BillController.php b/app/Api/V1/Controllers/BillController.php index e26b96bbf5..562ff6d395 100644 --- a/app/Api/V1/Controllers/BillController.php +++ b/app/Api/V1/Controllers/BillController.php @@ -85,7 +85,7 @@ class BillController extends Controller */ 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); /** @var Collection $bills */ $bills = $paginator->getCollection(); diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index 68f0d0c91d..047b3c5342 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -107,7 +107,7 @@ class Controller extends BaseController foreach ($dates as $field) { $date = request()->get($field); $obj = null; - if (!is_null($date)) { + if (null !== $date) { try { $obj = new Carbon($date); } catch (InvalidDateException $e) { diff --git a/app/Api/V1/Controllers/TransactionController.php b/app/Api/V1/Controllers/TransactionController.php index 4ecec57436..987536ee0b 100644 --- a/app/Api/V1/Controllers/TransactionController.php +++ b/app/Api/V1/Controllers/TransactionController.php @@ -91,7 +91,7 @@ class TransactionController extends Controller */ 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 $type = $request->get('type') ?? 'default'; @@ -115,7 +115,7 @@ class TransactionController extends Controller $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->setLimit($pageSize)->setPage($this->parameters->get('page')); diff --git a/app/Api/V1/Controllers/UserController.php b/app/Api/V1/Controllers/UserController.php index 4af7e7b7d8..850f6fe3a3 100644 --- a/app/Api/V1/Controllers/UserController.php +++ b/app/Api/V1/Controllers/UserController.php @@ -92,7 +92,7 @@ class UserController extends Controller public function index(Request $request) { // user preferences - $pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); + $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data; // make manager $manager = new Manager(); diff --git a/app/Api/V1/Requests/BillRequest.php b/app/Api/V1/Requests/BillRequest.php index 9c701e8502..9cc6a848ed 100644 --- a/app/Api/V1/Requests/BillRequest.php +++ b/app/Api/V1/Requests/BillRequest.php @@ -108,8 +108,8 @@ class BillRequest extends Request $validator->after( function (Validator $validator) { $data = $validator->getData(); - $min = floatval($data['amount_min'] ?? 0); - $max = floatval($data['amount_max'] ?? 0); + $min = (float)($data['amount_min'] ?? 0); + $max = (float)($data['amount_max'] ?? 0); if ($min > $max) { $validator->errors()->add('amount_min', trans('validation.amount_min_over_max')); } diff --git a/app/User.php b/app/User.php index c5dbe49ad7..641bbc70dc 100644 --- a/app/User.php +++ b/app/User.php @@ -76,14 +76,14 @@ class User extends Authenticatable * @param string $value * * @return User - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException */ public static function routeBinder(string $value): User { if (auth()->check()) { - $userId = intval($value); + $userId = (int)$value; $user = self::find($userId); - if (!is_null($user)) { + if (null !== $user) { return $user; } } @@ -212,7 +212,7 @@ class User extends Authenticatable { $bytes = random_bytes(16); - return strval(bin2hex($bytes)); + return (string)bin2hex($bytes); } /** diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index bcd5edae50..5a1e9ee90d 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -239,8 +239,8 @@ $factory->define( FireflyIII\Models\Transaction::class, function (Faker\Generator $faker) { return [ - 'transaction_amount' => strval($faker->randomFloat(2, -100, 100)), - 'destination_amount' => strval($faker->randomFloat(2, -100, 100)), + 'transaction_amount' => (string)$faker->randomFloat(2, -100, 100), + 'destination_amount' => (string)$faker->randomFloat(2, -100, 100), 'opposing_account_id' => $faker->numberBetween(1, 10), 'source_account_id' => $faker->numberBetween(1, 10), 'opposing_account_name' => $faker->words(3, true), @@ -249,7 +249,7 @@ $factory->define( 'destination_account_id' => $faker->numberBetween(1, 10), 'date' => new Carbon, 'destination_account_name' => $faker->words(3, true), - 'amount' => strval($faker->randomFloat(2, -100, 100)), + 'amount' => (string)$faker->randomFloat(2, -100, 100), 'budget_id' => 0, 'category' => $faker->words(3, true), 'transaction_journal_id' => $faker->numberBetween(1, 10), diff --git a/database/seeds/ConfigSeeder.php b/database/seeds/ConfigSeeder.php index 73a3955c03..e37857aa81 100644 --- a/database/seeds/ConfigSeeder.php +++ b/database/seeds/ConfigSeeder.php @@ -14,7 +14,7 @@ class ConfigSeeder extends Seeder public function run() { $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).'); // FF old or no version present. Put at 1: Configuration::create( @@ -24,8 +24,8 @@ class ConfigSeeder extends Seeder ] ); } - if (!is_null($entry)) { - $version = intval(config('firefly.db_version')); + if (null !== $entry) { + $version = (int)config('firefly.db_version'); $entry->data = $version; $entry->save(); diff --git a/public/index.php b/public/index.php index eedd6e418e..86d14aca18 100644 --- a/public/index.php +++ b/public/index.php @@ -54,6 +54,7 @@ require __DIR__ . '/../vendor/autoload.php'; | */ +/** @noinspection UsingInclusionOnceReturnValueInspection */ $app = require_once __DIR__ . '/../bootstrap/app.php'; /* diff --git a/public/js/ff/index.js b/public/js/ff/index.js index 34f743f1e8..d9cc68cf54 100644 --- a/public/js/ff/index.js +++ b/public/js/ff/index.js @@ -127,6 +127,5 @@ function getBalanceBox() { $('#box-balance-list').html(current + '' + string + '' + '
'); count++; } - return; }); } \ No newline at end of file diff --git a/public/js/ff/transactions/single/create.js b/public/js/ff/transactions/single/create.js index 6c73e8dd46..189f7f7b08 100644 --- a/public/js/ff/transactions/single/create.js +++ b/public/js/ff/transactions/single/create.js @@ -83,8 +83,6 @@ function selectsDifferentSource() { $('.currency-option[data-id="' + sourceCurrency + '"]').click(); $('[data-toggle="dropdown"]').parent().removeClass('open'); $('select[name="source_account_id"]').focus(); - - return; } /** @@ -107,8 +105,6 @@ function selectsDifferentDestination() { $('.currency-option[data-id="' + destinationCurrency + '"]').click(); $('[data-toggle="dropdown"]').parent().removeClass('open'); $('select[name="destination_account_id"]').focus(); - - return; } diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 5080e9f348..61c34451dd 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -784,6 +784,7 @@ return [ 'opt_group_sharedAsset' => 'Shared asset accounts', 'opt_group_ccAsset' => 'Credit cards', 'notes' => 'Notes', + 'unknown_journal_error' => 'Could not store the transaction. Please check the log files.', // new user: 'welcome' => 'Welcome to Firefly III!', @@ -1136,6 +1137,7 @@ return [ 'import_index_title' => 'Import data into Firefly III', '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.', + '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_not_available' => 'This function is not available when you are using Firefly III within a Sandstorm.io environment.', diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php index eb617e8d9c..38440d7474 100644 --- a/routes/breadcrumbs.php +++ b/routes/breadcrumbs.php @@ -81,11 +81,11 @@ Breadcrumbs::register( $breadcrumbs->parent('accounts.index', $what); $breadcrumbs->push($account->name, route('accounts.show', [$account->id])); - if (!is_null($start) && !is_null($end)) { + if (null !== $start && null !== $end) { $title = trans( 'firefly.between_dates_breadcrumb', - ['start' => $start ? $start->formatLocalized(strval(trans('config.month_and_day'))) : '', - 'end' => $end ? $end->formatLocalized(strval(trans('config.month_and_day'))) : '',] + ['start' => $start ? $start->formatLocalized((string)trans('config.month_and_day')) : '', + 'end' => $end ? $end->formatLocalized((string)trans('config.month_and_day')) : '',] ); $breadcrumbs->push($title, route('accounts.show', $account)); } @@ -357,8 +357,8 @@ Breadcrumbs::register( if ('all' !== $moment && '(nothing)' !== $moment) { $title = trans( 'firefly.between_dates_breadcrumb', - ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), - 'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] + ['start' => $start->formatLocalized((string)trans('config.month_and_day')), + 'end' => $end->formatLocalized((string)trans('config.month_and_day')),] ); $breadcrumbs->push($title, route('budgets.no-budget', [$moment])); } @@ -382,8 +382,8 @@ Breadcrumbs::register( $title = trans( 'firefly.between_dates_breadcrumb', - ['start' => $budgetLimit->start_date->formatLocalized(strval(trans('config.month_and_day'))), - 'end' => $budgetLimit->end_date->formatLocalized(strval(trans('config.month_and_day'))),] + ['start' => $budgetLimit->start_date->formatLocalized((string)trans('config.month_and_day')), + 'end' => $budgetLimit->end_date->formatLocalized((string)trans('config.month_and_day')),] ); $breadcrumbs->push( @@ -438,8 +438,8 @@ Breadcrumbs::register( if ('all' !== $moment && '(nothing)' !== $moment) { $title = trans( 'firefly.between_dates_breadcrumb', - ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), - 'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] + ['start' => $start->formatLocalized((string)trans('config.month_and_day')), + 'end' => $end->formatLocalized((string)trans('config.month_and_day')),] ); $breadcrumbs->push($title, route('categories.show', [$category->id, $moment])); } @@ -460,8 +460,8 @@ Breadcrumbs::register( if ('all' !== $moment && '(nothing)' !== $moment) { $title = trans( 'firefly.between_dates_breadcrumb', - ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), - 'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] + ['start' => $start->formatLocalized((string)trans('config.month_and_day')), + 'end' => $end->formatLocalized((string)trans('config.month_and_day')),] ); $breadcrumbs->push($title, route('categories.no-category', [$moment])); } @@ -878,8 +878,8 @@ Breadcrumbs::register( if ('all' !== $moment && '(nothing)' !== $moment) { $title = trans( 'firefly.between_dates_breadcrumb', - ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), - 'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] + ['start' => $start->formatLocalized((string)trans('config.month_and_day')), + 'end' => $end->formatLocalized((string)trans('config.month_and_day')),] ); $breadcrumbs->push($title, route('tags.show', [$tag->id, $moment])); } diff --git a/tests/Api/V1/Controllers/TransactionControllerTest.php b/tests/Api/V1/Controllers/TransactionControllerTest.php index 1ca6805406..f03ccf2fb1 100644 --- a/tests/Api/V1/Controllers/TransactionControllerTest.php +++ b/tests/Api/V1/Controllers/TransactionControllerTest.php @@ -2395,7 +2395,7 @@ class TransactionControllerTest extends TestCase 'description' => 'Some transaction #' . random_int(1, 1000), 'date' => '2018-01-01', 'type' => 'withdrawal', - 'tags' => join(',', $tags), + 'tags' => implode(',', $tags), 'transactions' => [ [ 'amount' => '10', diff --git a/tests/Feature/Controllers/ProfileControllerTest.php b/tests/Feature/Controllers/ProfileControllerTest.php index 4183b48054..23a9edfb7c 100644 --- a/tests/Feature/Controllers/ProfileControllerTest.php +++ b/tests/Feature/Controllers/ProfileControllerTest.php @@ -370,7 +370,7 @@ class ProfileControllerTest extends TestCase { $token = ''; $currentToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first(); - if (!is_null($currentToken)) { + if (null !== $currentToken) { $token = $currentToken->data; } $this->be($this->user()); diff --git a/tests/Feature/Controllers/Transaction/BulkControllerTest.php b/tests/Feature/Controllers/Transaction/BulkControllerTest.php index a5bff5aa42..056d284552 100644 --- a/tests/Feature/Controllers/Transaction/BulkControllerTest.php +++ b/tests/Feature/Controllers/Transaction/BulkControllerTest.php @@ -97,7 +97,7 @@ class BulkControllerTest extends TestCase // default transactions $collection = $this->user()->transactionJournals()->take(4)->get(); $allIds = $collection->pluck('id')->toArray(); - $route = route('transactions.bulk.edit', join(',', $allIds)); + $route = route('transactions.bulk.edit', implode(',', $allIds)); $this->be($this->user()); $response = $this->get($route); $response->assertStatus(200); @@ -133,7 +133,7 @@ class BulkControllerTest extends TestCase // default transactions $collection = $this->user()->transactionJournals()->take(4)->get(); $allIds = $collection->pluck('id')->toArray(); - $route = route('transactions.bulk.edit', join(',', $allIds)); + $route = route('transactions.bulk.edit', implode(',', $allIds)); $this->be($this->user()); $response = $this->get($route); $response->assertStatus(200); diff --git a/tests/Feature/Controllers/Transaction/MassControllerTest.php b/tests/Feature/Controllers/Transaction/MassControllerTest.php index eb1f66957c..260f710d9c 100644 --- a/tests/Feature/Controllers/Transaction/MassControllerTest.php +++ b/tests/Feature/Controllers/Transaction/MassControllerTest.php @@ -162,7 +162,7 @@ class MassControllerTest extends TestCase // default transactions $collection = $this->user()->transactionJournals()->take(4)->get(); $allIds = $collection->pluck('id')->toArray(); - $route = route('transactions.mass.edit', join(',', $allIds)); + $route = route('transactions.mass.edit', implode(',', $allIds)); $this->be($this->user()); $response = $this->get($route); $response->assertStatus(200); @@ -204,7 +204,7 @@ class MassControllerTest extends TestCase $allIds = $collection->pluck('id')->toArray(); $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->assertSee('Edit a number of transactions'); $response->assertSessionHas('error', 'You have selected no valid transactions to edit.'); diff --git a/tests/TestCase.php b/tests/TestCase.php index 29cd8605d6..797ee78792 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -99,9 +99,7 @@ abstract class TestCase extends BaseTestCase */ public function demoUser(): User { - $user = User::find(4); - - return $user; + return User::find(4); } /** @@ -109,9 +107,7 @@ abstract class TestCase extends BaseTestCase */ public function emptyUser(): User { - $user = User::find(2); - - return $user; + return User::find(2); } /** @@ -119,9 +115,7 @@ abstract class TestCase extends BaseTestCase */ public function user(): User { - $user = User::find(1); - - return $user; + return User::find(1); } /** @@ -145,10 +139,8 @@ abstract class TestCase extends BaseTestCase */ protected function overload(string $class) { - $externalMock = Mockery::mock('overload:' . $class); - //$this->app->instance($class, $externalMock); - return $externalMock; + return Mockery::mock('overload:' . $class); } /** diff --git a/tests/Unit/Factory/AccountFactoryTest.php b/tests/Unit/Factory/AccountFactoryTest.php index 82da337182..06bfd5df98 100644 --- a/tests/Unit/Factory/AccountFactoryTest.php +++ b/tests/Unit/Factory/AccountFactoryTest.php @@ -212,7 +212,7 @@ class AccountFactoryTest extends TestCase // find opening balance: $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: $this->assertEquals(1, $account->transactions()->count()); - $this->assertEquals(-100, floatval($account->transactions()->first()->amount)); + $this->assertEquals(-100, (float)$account->transactions()->first()->amount); } /** diff --git a/tests/Unit/Helpers/AttachmentHelperTest.php b/tests/Unit/Helpers/AttachmentHelperTest.php index f40d677aa2..bc9900e767 100644 --- a/tests/Unit/Helpers/AttachmentHelperTest.php +++ b/tests/Unit/Helpers/AttachmentHelperTest.php @@ -45,7 +45,7 @@ class AttachmentHelperTest extends TestCase { $attachment = Attachment::first(); $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); } diff --git a/tests/Unit/Import/Mapper/AssetAccountIbansTest.php b/tests/Unit/Import/Mapper/AssetAccountIbansTest.php index c6fcdb43e6..c5ccb40bb3 100644 --- a/tests/Unit/Import/Mapper/AssetAccountIbansTest.php +++ b/tests/Unit/Import/Mapper/AssetAccountIbansTest.php @@ -57,7 +57,7 @@ class AssetAccountIbansTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 53 => 'Else', 17 => 'IBAN (Something)', ]; diff --git a/tests/Unit/Import/Mapper/AssetAccountsTest.php b/tests/Unit/Import/Mapper/AssetAccountsTest.php index f4ae748fd4..97d9741383 100644 --- a/tests/Unit/Import/Mapper/AssetAccountsTest.php +++ b/tests/Unit/Import/Mapper/AssetAccountsTest.php @@ -57,7 +57,7 @@ class AssetAccountsTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 19 => 'Else', 23 => 'Something (IBAN)', diff --git a/tests/Unit/Import/Mapper/BillsTest.php b/tests/Unit/Import/Mapper/BillsTest.php index 14bf7e0401..355bc43a98 100644 --- a/tests/Unit/Import/Mapper/BillsTest.php +++ b/tests/Unit/Import/Mapper/BillsTest.php @@ -58,7 +58,7 @@ class BillsTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 9 => 'Else [match]', 5 => 'Something [hi,bye]', ]; diff --git a/tests/Unit/Import/Mapper/BudgetsTest.php b/tests/Unit/Import/Mapper/BudgetsTest.php index e2be64d65b..3c0b996ed6 100644 --- a/tests/Unit/Import/Mapper/BudgetsTest.php +++ b/tests/Unit/Import/Mapper/BudgetsTest.php @@ -55,7 +55,7 @@ class BudgetsTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 4 => 'Else', 8 => 'Something', diff --git a/tests/Unit/Import/Mapper/CategoriesTest.php b/tests/Unit/Import/Mapper/CategoriesTest.php index 6603b2d83c..c2697fcd97 100644 --- a/tests/Unit/Import/Mapper/CategoriesTest.php +++ b/tests/Unit/Import/Mapper/CategoriesTest.php @@ -55,7 +55,7 @@ class CategoriesTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 17 => 'Else', 9 => 'Something', diff --git a/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php b/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php index 1623318287..621c9432d5 100644 --- a/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php +++ b/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php @@ -59,7 +59,7 @@ class OpposingAccountIbansTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 17 => 'Else', 21 => 'IBAN (Something)', ]; diff --git a/tests/Unit/Import/Mapper/OpposingAccountsTest.php b/tests/Unit/Import/Mapper/OpposingAccountsTest.php index 6cd92bfdaf..765108a471 100644 --- a/tests/Unit/Import/Mapper/OpposingAccountsTest.php +++ b/tests/Unit/Import/Mapper/OpposingAccountsTest.php @@ -59,7 +59,7 @@ class OpposingAccountsTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 9 => 'Else', 13 => 'Something (IBAN)', ]; diff --git a/tests/Unit/Import/Mapper/TagsTest.php b/tests/Unit/Import/Mapper/TagsTest.php index 007a0bc28c..ad03c5b59e 100644 --- a/tests/Unit/Import/Mapper/TagsTest.php +++ b/tests/Unit/Import/Mapper/TagsTest.php @@ -55,7 +55,7 @@ class TagsTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 14 => 'Else', 12 => 'Something', ]; diff --git a/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php b/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php index 940edc2ece..61a37a8207 100644 --- a/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php +++ b/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php @@ -57,7 +57,7 @@ class TransactionCurrenciesTest extends TestCase $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ - 0 => strval(trans('import.map_do_not_map')), + 0 => (string)trans('import.map_do_not_map'), 11 => 'Else (DEF)', 9 => 'Something (ABC)', diff --git a/tests/Unit/Import/Object/ImportAccountTest.php b/tests/Unit/Import/Object/ImportAccountTest.php index 56a57b5a34..b527883ba7 100644 --- a/tests/Unit/Import/Object/ImportAccountTest.php +++ b/tests/Unit/Import/Object/ImportAccountTest.php @@ -27,7 +27,7 @@ use FireflyIII\Import\Object\ImportAccount; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use Illuminate\Support\Collection; + use Mockery; use Tests\TestCase; diff --git a/tests/Unit/Middleware/AuthenticateTest.php b/tests/Unit/Middleware/AuthenticateTest.php index 33051d6112..6e6eacf55c 100644 --- a/tests/Unit/Middleware/AuthenticateTest.php +++ b/tests/Unit/Middleware/AuthenticateTest.php @@ -77,7 +77,7 @@ class AuthenticateTest extends TestCase $this->be($user); $response = $this->get('/_test/authenticate'); $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')); } @@ -94,7 +94,7 @@ class AuthenticateTest extends TestCase $this->be($user); $response = $this->get('/_test/authenticate'); $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')); } diff --git a/tests/Unit/Middleware/BinderTest.php b/tests/Unit/Middleware/BinderTest.php index 95192d6e8c..10f6b780cf 100644 --- a/tests/Unit/Middleware/BinderTest.php +++ b/tests/Unit/Middleware/BinderTest.php @@ -1241,7 +1241,7 @@ class BinderTest extends TestCase } ); - $names = join(',', $tags->pluck('tag')->toArray()); + $names = implode(',', $tags->pluck('tag')->toArray()); $this->be($this->user()); diff --git a/tests/Unit/Middleware/IsSandstormUserTest.php b/tests/Unit/Middleware/IsSandstormUserTest.php index 8b8167566f..60cf2b68ad 100644 --- a/tests/Unit/Middleware/IsSandstormUserTest.php +++ b/tests/Unit/Middleware/IsSandstormUserTest.php @@ -65,7 +65,7 @@ class IsSandstormUserTest extends TestCase $response = $this->get('/_test/is-sandstorm'); $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')); putenv('SANDSTORM=0'); } diff --git a/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php b/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php index 602316b1eb..9396579f2c 100644 --- a/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php +++ b/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php @@ -128,7 +128,7 @@ class TransactionUpdateServiceTest extends TestCase 'foreign_amount' => null, 'budget_id' => null, 'budget_name' => null, - 'destination_id' => intval($source->account_id), + 'destination_id' => (int)$source->account_id, 'destination_name' => null, 'category_id' => null, 'category_name' => null, @@ -167,7 +167,7 @@ class TransactionUpdateServiceTest extends TestCase 'foreign_amount' => '12.34', 'budget_id' => null, 'budget_name' => null, - 'destination_id' => intval($source->account_id), + 'destination_id' => (int)$source->account_id, 'destination_name' => null, 'category_id' => null, 'category_name' => null, @@ -210,7 +210,7 @@ class TransactionUpdateServiceTest extends TestCase 'foreign_amount' => null, 'budget_id' => null, 'budget_name' => null, - 'source_id' => intval($source->account_id), + 'source_id' => (int)$source->account_id, 'source_name' => null, 'category_id' => null, 'category_name' => null, diff --git a/tests/Unit/TransactionRules/Actions/AppendNotesTest.php b/tests/Unit/TransactionRules/Actions/AppendNotesTest.php index dd19691526..f796ebe2ca 100644 --- a/tests/Unit/TransactionRules/Actions/AppendNotesTest.php +++ b/tests/Unit/TransactionRules/Actions/AppendNotesTest.php @@ -44,7 +44,7 @@ class AppendNotesTest extends TestCase $note = $journal->notes()->first(); $start = 'Default note text'; $toAppend = 'This is appended'; - if (is_null($note)) { + if (null === $note) { $note = new Note(); $note->noteable()->associate($journal); } @@ -71,7 +71,7 @@ class AppendNotesTest extends TestCase // give journal some notes. $journal = TransactionJournal::find(4); $note = $journal->notes()->first(); - if (!is_null($note)) { + if (null !== $note) { $note->forceDelete(); } $toAppend = 'This is appended'; diff --git a/tests/Unit/TransactionRules/Actions/ClearNotesTest.php b/tests/Unit/TransactionRules/Actions/ClearNotesTest.php index 4670eca624..4a4a53f229 100644 --- a/tests/Unit/TransactionRules/Actions/ClearNotesTest.php +++ b/tests/Unit/TransactionRules/Actions/ClearNotesTest.php @@ -42,7 +42,7 @@ class ClearNotesTest extends TestCase // give journal a note: $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $note = $journal->notes()->first(); - if (is_null($note)) { + if (null === $note) { $note = new Note; $note->noteable()->associate($journal); } diff --git a/tests/Unit/TransactionRules/Actions/PrependNotesTest.php b/tests/Unit/TransactionRules/Actions/PrependNotesTest.php index 25f7bf0e4e..cd08f9f60b 100644 --- a/tests/Unit/TransactionRules/Actions/PrependNotesTest.php +++ b/tests/Unit/TransactionRules/Actions/PrependNotesTest.php @@ -44,7 +44,7 @@ class PrependNotesTest extends TestCase $note = $journal->notes()->first(); $start = 'Default note text'; $toPrepend = 'This is prepended'; - if (is_null($note)) { + if (null === $note) { $note = new Note(); $note->noteable()->associate($journal); } @@ -71,7 +71,7 @@ class PrependNotesTest extends TestCase // give journal some notes. $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $note = $journal->notes()->first(); - if (!is_null($note)) { + if (null !== $note) { $note->forceDelete(); } $toPrepend = 'This is appended'; diff --git a/tests/Unit/TransactionRules/Actions/RemoveAllTagsTest.php b/tests/Unit/TransactionRules/Actions/RemoveAllTagsTest.php index 4e41471013..fa0b305f99 100644 --- a/tests/Unit/TransactionRules/Actions/RemoveAllTagsTest.php +++ b/tests/Unit/TransactionRules/Actions/RemoveAllTagsTest.php @@ -41,7 +41,7 @@ class RemoveAllTagsTest extends TestCase { // find journal with at least one tag $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 */ $journal = TransactionJournal::find($journalId); diff --git a/tests/Unit/TransactionRules/Actions/RemoveTagTest.php b/tests/Unit/TransactionRules/Actions/RemoveTagTest.php index 9753b25317..637f1ebbe0 100644 --- a/tests/Unit/TransactionRules/Actions/RemoveTagTest.php +++ b/tests/Unit/TransactionRules/Actions/RemoveTagTest.php @@ -42,7 +42,7 @@ class RemoveTagTest extends TestCase // find journal with at least one tag $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 */ $journal = TransactionJournal::find($journalId); $originalCount = $journal->tags()->count(); diff --git a/tests/Unit/TransactionRules/Actions/SetNotesTest.php b/tests/Unit/TransactionRules/Actions/SetNotesTest.php index bbe6c8702d..ad6ec7400a 100644 --- a/tests/Unit/TransactionRules/Actions/SetNotesTest.php +++ b/tests/Unit/TransactionRules/Actions/SetNotesTest.php @@ -42,7 +42,7 @@ class SetNotesTest extends TestCase // give journal a note: $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); $note = $journal->notes()->first(); - if (is_null($note)) { + if (null === $note) { $note = new Note; $note->noteable()->associate($journal); } diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php index 324dca9719..0d9742099e 100644 --- a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php +++ b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php @@ -36,9 +36,12 @@ class FromAccountStartsTest extends TestCase */ public function testTriggered() { - $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); - $transaction = $journal->transactions()->where('amount', '<', 0)->first(); - $account = $transaction->account; + $transaction = null; + do { + $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); $result = $trigger->triggered($journal); @@ -50,8 +53,12 @@ class FromAccountStartsTest extends TestCase */ public function testTriggeredLonger() { - $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); - $transaction = $journal->transactions()->where('amount', '<', 0)->first(); + $transaction = null; + do { + $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first(); + $transaction = $journal->transactions()->where('amount', '<', 0)->first(); + } while (null === $transaction); + $account = $transaction->account; $trigger = FromAccountStarts::makeFromStrings('bla-bla-bla' . $account->name, false); diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php index 15b0ff8ded..0f8666c2a9 100644 --- a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php +++ b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php @@ -74,7 +74,7 @@ class ToAccountEndsTest extends TestCase { $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); $this->assertFalse($result); }