From 2cb837e4b58e55fee20812d0e2563f77efce276b Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 16 Feb 2024 21:13:13 +0000 Subject: [PATCH] Add type hints for Laravel 10 --- app/Console/Commands/RegisterApp.php | 2 +- app/Console/Kernel.php | 4 ++-- app/Http/Middleware/CheckAllowed.php | 3 ++- app/Http/Middleware/RedirectIfAuthenticated.php | 3 ++- app/Jobs/ProcessApps.php | 2 +- app/Jobs/UpdateApps.php | 2 +- app/Providers/AppServiceProvider.php | 4 ++-- app/Providers/AuthServiceProvider.php | 2 +- app/Providers/EventServiceProvider.php | 4 ++-- app/Providers/RouteServiceProvider.php | 2 +- database/factories/UserFactory.php | 2 +- .../2018_01_27_155922_create_items_table.php | 4 ++-- .../2018_02_04_185524_create_settings_table.php | 4 ++-- .../2018_02_04_185802_create_setting_groups_table.php | 4 ++-- ...18_02_16_175830_add_columns_to_items_for_groups.php | 4 ++-- database/migrations/2018_02_16_193703_item_tag.php | 4 ++-- .../2018_10_12_122907_create_users_table.php | 4 ++-- .../2018_10_12_123036_create_password_resets_table.php | 4 ++-- .../2018_10_12_131222_add_user_id_to_items_table.php | 4 ++-- ...18_10_12_140451_create_setting_user_pivot_table.php | 4 ++-- .../2018_10_18_110905_create_applications_table.php | 4 ++-- .../2018_10_23_132008_add_class_to_items_table.php | 4 ++-- .../migrations/2018_10_31_191604_create_jobs_table.php | 4 ++-- .../2018_11_06_112434_create_failed_jobs_table.php | 4 ++-- .../2022_03_15_140911_add_appid_to_items.php | 4 ++-- .../2022_03_16_093044_add_class_to_application.php | 4 ++-- .../2022_03_16_181343_add_app_description_to_items.php | 4 ++-- .../2024_02_16_000000_rename_password_resets_table.php | 4 ++-- database/seeders/DatabaseSeeder.php | 2 +- database/seeders/SettingsSeeder.php | 2 +- database/seeders/UsersSeeder.php | 2 +- tests/CreatesApplication.php | 3 ++- tests/Feature/DashTest.php | 6 +++--- tests/Feature/ItemCreateTest.php | 8 ++++---- tests/Feature/ItemDeleteTest.php | 4 ++-- tests/Feature/ItemExportTest.php | 10 +++++----- tests/Feature/ItemListTest.php | 4 ++-- tests/Feature/SettingsTest.php | 2 +- tests/Feature/TagListTest.php | 4 ++-- tests/Feature/UserListTest.php | 4 ++-- tests/Unit/database/seeders/SettingsSeederTest.php | 2 +- tests/Unit/helpers/IsImageTest.php | 6 +++--- tests/Unit/helpers/SlugTest.php | 2 +- tests/Unit/lang/LangTest.php | 2 +- 44 files changed, 82 insertions(+), 79 deletions(-) diff --git a/app/Console/Commands/RegisterApp.php b/app/Console/Commands/RegisterApp.php index 37f13461..c10a7a35 100644 --- a/app/Console/Commands/RegisterApp.php +++ b/app/Console/Commands/RegisterApp.php @@ -38,7 +38,7 @@ class RegisterApp extends Command * * @return void */ - public function handle() + public function handle(): void { $folder = $this->argument('folder'); if ($folder == 'all') { diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 6b665f66..a702d9ee 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel * @param Schedule $schedule * @return void */ - protected function schedule(Schedule $schedule) + protected function schedule(Schedule $schedule): void { // $schedule->command('inspire') // ->hourly(); @@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel * * @return void */ - protected function commands() + protected function commands(): void { $this->load(__DIR__.'/Commands'); diff --git a/app/Http/Middleware/CheckAllowed.php b/app/Http/Middleware/CheckAllowed.php index eaae0d57..1ab898a0 100644 --- a/app/Http/Middleware/CheckAllowed.php +++ b/app/Http/Middleware/CheckAllowed.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use Symfony\Component\HttpFoundation\Response; use App\User; use Closure; use Illuminate\Auth\AuthenticationException; @@ -20,7 +21,7 @@ class CheckAllowed * @return mixed * @throws AuthenticationException */ - public function handle(Request $request, Closure $next) + public function handle(Request $request, Closure $next): Response { $route = Route::currentRouteName(); $current_user = User::currentUser(); diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 153bec91..0f0674e0 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use Symfony\Component\HttpFoundation\Response; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -16,7 +17,7 @@ class RedirectIfAuthenticated * @param string|null $guard * @return mixed */ - public function handle(Request $request, Closure $next, string $guard = null) + public function handle(Request $request, Closure $next, string $guard = null): Response { if (Auth::guard($guard)->check()) { return redirect()->intended(); diff --git a/app/Jobs/ProcessApps.php b/app/Jobs/ProcessApps.php index 73db5dc8..1ce0a4d3 100644 --- a/app/Jobs/ProcessApps.php +++ b/app/Jobs/ProcessApps.php @@ -35,7 +35,7 @@ class ProcessApps implements ShouldQueue, ShouldBeUnique * @return void * @throws GuzzleException */ - public function handle() + public function handle(): void { Log::debug('Process Apps dispatched'); $localapps = Application::whereNull('class')->get(); diff --git a/app/Jobs/UpdateApps.php b/app/Jobs/UpdateApps.php index dccc2188..e034ae81 100644 --- a/app/Jobs/UpdateApps.php +++ b/app/Jobs/UpdateApps.php @@ -33,7 +33,7 @@ class UpdateApps implements ShouldQueue, ShouldBeUnique * @return void * @throws GuzzleException */ - public function handle() + public function handle(): void { Log::debug('Update of all apps triggered!'); $apps = Application::all('appid')->toArray(); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 75c4e207..ed917bbc 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -22,7 +22,7 @@ class AppServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { if (! class_exists('ZipArchive')) { die('You are missing php-zip'); @@ -122,7 +122,7 @@ class AppServiceProvider extends ServiceProvider * * @return void */ - public function register() + public function register(): void { if ($this->app->isLocal()) { $this->app->register(IdeHelperServiceProvider::class); diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 78b7ad0a..a119d6f9 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -20,7 +20,7 @@ class AuthServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { // } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 6df9c2b0..072aa29e 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -22,7 +22,7 @@ class EventServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { parent::boot(); @@ -34,7 +34,7 @@ class EventServiceProvider extends ServiceProvider * * @return bool */ - public function shouldDiscoverEvents() + public function shouldDiscoverEvents(): bool { return false; } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index f037a80b..8c99db06 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -20,7 +20,7 @@ class RouteServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { // diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index f684efbc..bc3533a3 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -16,7 +16,7 @@ class UserFactory extends Factory */ protected static ?string $password; - public function definition() + public function definition(): array { return [ 'username' => $this->faker->name(), diff --git a/database/migrations/2018_01_27_155922_create_items_table.php b/database/migrations/2018_01_27_155922_create_items_table.php index ed4eecfe..e6c9267a 100644 --- a/database/migrations/2018_01_27_155922_create_items_table.php +++ b/database/migrations/2018_01_27_155922_create_items_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('items', function (Blueprint $table) { $table->increments('id'); @@ -32,7 +32,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('items'); } diff --git a/database/migrations/2018_02_04_185524_create_settings_table.php b/database/migrations/2018_02_04_185524_create_settings_table.php index 4c3049f6..a18660bf 100644 --- a/database/migrations/2018_02_04_185524_create_settings_table.php +++ b/database/migrations/2018_02_04_185524_create_settings_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('settings', function (Blueprint $table) { $table->increments('id'); @@ -31,7 +31,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('settings'); } diff --git a/database/migrations/2018_02_04_185802_create_setting_groups_table.php b/database/migrations/2018_02_04_185802_create_setting_groups_table.php index 5eada09a..acc80592 100644 --- a/database/migrations/2018_02_04_185802_create_setting_groups_table.php +++ b/database/migrations/2018_02_04_185802_create_setting_groups_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('setting_groups', function (Blueprint $table) { $table->increments('id'); @@ -25,7 +25,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('setting_groups'); } diff --git a/database/migrations/2018_02_16_175830_add_columns_to_items_for_groups.php b/database/migrations/2018_02_16_175830_add_columns_to_items_for_groups.php index 7edbf44d..09575c4f 100644 --- a/database/migrations/2018_02_16_175830_add_columns_to_items_for_groups.php +++ b/database/migrations/2018_02_16_175830_add_columns_to_items_for_groups.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::table('items', function (Blueprint $table) { $table->integer('type')->default(0)->index(); // 0 = item, 1 = category @@ -23,7 +23,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('items', function (Blueprint $table) { $table->dropColumn(['type']); diff --git a/database/migrations/2018_02_16_193703_item_tag.php b/database/migrations/2018_02_16_193703_item_tag.php index 48e0cb11..0bc65ddf 100644 --- a/database/migrations/2018_02_16_193703_item_tag.php +++ b/database/migrations/2018_02_16_193703_item_tag.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('item_tag', function (Blueprint $table) { $table->integer('item_id')->unsigned()->index(); @@ -28,7 +28,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('item_tag'); } diff --git a/database/migrations/2018_10_12_122907_create_users_table.php b/database/migrations/2018_10_12_122907_create_users_table.php index c9ac830d..396ca29c 100644 --- a/database/migrations/2018_10_12_122907_create_users_table.php +++ b/database/migrations/2018_10_12_122907_create_users_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('users', function (Blueprint $table) { $table->increments('id'); @@ -31,7 +31,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } diff --git a/database/migrations/2018_10_12_123036_create_password_resets_table.php b/database/migrations/2018_10_12_123036_create_password_resets_table.php index fcacb80b..b4d45de2 100644 --- a/database/migrations/2018_10_12_123036_create_password_resets_table.php +++ b/database/migrations/2018_10_12_123036_create_password_resets_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('password_resets', function (Blueprint $table) { $table->string('email')->index(); @@ -25,7 +25,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('password_resets'); } diff --git a/database/migrations/2018_10_12_131222_add_user_id_to_items_table.php b/database/migrations/2018_10_12_131222_add_user_id_to_items_table.php index c5a7302c..abf267a1 100644 --- a/database/migrations/2018_10_12_131222_add_user_id_to_items_table.php +++ b/database/migrations/2018_10_12_131222_add_user_id_to_items_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::table('items', function (Blueprint $table) { $table->integer('user_id')->default(1)->index(); // 0 = item, 1 = category @@ -23,7 +23,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('items', function (Blueprint $table) { $table->dropColumn(['user_id']); diff --git a/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php b/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php index 54dfc992..26f92076 100644 --- a/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php +++ b/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('setting_user', function (Blueprint $table) { $table->integer('setting_id')->unsigned()->index(); @@ -28,7 +28,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('setting_user'); } diff --git a/database/migrations/2018_10_18_110905_create_applications_table.php b/database/migrations/2018_10_18_110905_create_applications_table.php index 460db7a7..f4bb3cc8 100644 --- a/database/migrations/2018_10_18_110905_create_applications_table.php +++ b/database/migrations/2018_10_18_110905_create_applications_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('applications', function (Blueprint $table) { $table->string('appid')->unique(); @@ -33,7 +33,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('applications'); } diff --git a/database/migrations/2018_10_23_132008_add_class_to_items_table.php b/database/migrations/2018_10_23_132008_add_class_to_items_table.php index 6877440d..63c63e7d 100644 --- a/database/migrations/2018_10_23_132008_add_class_to_items_table.php +++ b/database/migrations/2018_10_23_132008_add_class_to_items_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::table('items', function (Blueprint $table) { $table->string('class')->nullable(); @@ -23,7 +23,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('items', function (Blueprint $table) { $table->dropColumn(['class']); diff --git a/database/migrations/2018_10_31_191604_create_jobs_table.php b/database/migrations/2018_10_31_191604_create_jobs_table.php index a786a891..560ae54b 100644 --- a/database/migrations/2018_10_31_191604_create_jobs_table.php +++ b/database/migrations/2018_10_31_191604_create_jobs_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('jobs', function (Blueprint $table) { $table->bigIncrements('id'); @@ -29,7 +29,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('jobs'); } diff --git a/database/migrations/2018_11_06_112434_create_failed_jobs_table.php b/database/migrations/2018_11_06_112434_create_failed_jobs_table.php index 23a0faa3..3bafc3bf 100644 --- a/database/migrations/2018_11_06_112434_create_failed_jobs_table.php +++ b/database/migrations/2018_11_06_112434_create_failed_jobs_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::create('failed_jobs', function (Blueprint $table) { $table->bigIncrements('id'); @@ -28,7 +28,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('failed_jobs'); } diff --git a/database/migrations/2022_03_15_140911_add_appid_to_items.php b/database/migrations/2022_03_15_140911_add_appid_to_items.php index b099b695..d89f014a 100644 --- a/database/migrations/2022_03_15_140911_add_appid_to_items.php +++ b/database/migrations/2022_03_15_140911_add_appid_to_items.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::table('items', function (Blueprint $table) { $table->string('appid')->nullable(); @@ -23,7 +23,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('items', function (Blueprint $table) { $table->dropColumn(['appid']); diff --git a/database/migrations/2022_03_16_093044_add_class_to_application.php b/database/migrations/2022_03_16_093044_add_class_to_application.php index bace6a2e..11fc36b1 100644 --- a/database/migrations/2022_03_16_093044_add_class_to_application.php +++ b/database/migrations/2022_03_16_093044_add_class_to_application.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::table('applications', function (Blueprint $table) { $table->string('class')->nullable()->index(); @@ -23,7 +23,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('applications', function (Blueprint $table) { $table->dropColumn(['class']); diff --git a/database/migrations/2022_03_16_181343_add_app_description_to_items.php b/database/migrations/2022_03_16_181343_add_app_description_to_items.php index ed9dafb7..250e35bb 100644 --- a/database/migrations/2022_03_16_181343_add_app_description_to_items.php +++ b/database/migrations/2022_03_16_181343_add_app_description_to_items.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::table('items', function (Blueprint $table) { $table->text('appdescription')->nullable(); @@ -23,7 +23,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::table('items', function (Blueprint $table) { // diff --git a/database/migrations/2024_02_16_000000_rename_password_resets_table.php b/database/migrations/2024_02_16_000000_rename_password_resets_table.php index 7ea51cef..ab300e6e 100644 --- a/database/migrations/2024_02_16_000000_rename_password_resets_table.php +++ b/database/migrations/2024_02_16_000000_rename_password_resets_table.php @@ -11,7 +11,7 @@ return new class extends Migration * * @return void */ - public function up() + public function up(): void { Schema::rename('password_resets', 'password_reset_tokens'); } @@ -21,7 +21,7 @@ return new class extends Migration * * @return void */ - public function down() + public function down(): void { Schema::rename('password_reset_tokens', 'password_resets'); } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 561eac29..5a983e90 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -11,7 +11,7 @@ class DatabaseSeeder extends Seeder * * @return void */ - public function run() + public function run(): void { $this->call(SettingsSeeder::class); $this->call(UsersSeeder::class); diff --git a/database/seeders/SettingsSeeder.php b/database/seeders/SettingsSeeder.php index df11f8f3..47704ab0 100644 --- a/database/seeders/SettingsSeeder.php +++ b/database/seeders/SettingsSeeder.php @@ -55,7 +55,7 @@ class SettingsSeeder extends Seeder * * @return void */ - public function run() + public function run(): void { // Groups if (! $setting_group = SettingGroup::find(1)) { diff --git a/database/seeders/UsersSeeder.php b/database/seeders/UsersSeeder.php index 198258b2..69230021 100644 --- a/database/seeders/UsersSeeder.php +++ b/database/seeders/UsersSeeder.php @@ -12,7 +12,7 @@ class UsersSeeder extends Seeder * * @return void */ - public function run() + public function run(): void { // Groups if (!User::find(1)) { diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index 36b3659e..ebba2703 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -2,6 +2,7 @@ namespace Tests; +use Illuminate\Foundation\Application; use Illuminate\Contracts\Console\Kernel; trait CreatesApplication @@ -11,7 +12,7 @@ trait CreatesApplication * * @return \Illuminate\Foundation\Application */ - public function createApplication() + public function createApplication(): Application { $app = require __DIR__.'/../bootstrap/app.php'; diff --git a/tests/Feature/DashTest.php b/tests/Feature/DashTest.php index 2c631b76..189436b7 100644 --- a/tests/Feature/DashTest.php +++ b/tests/Feature/DashTest.php @@ -42,7 +42,7 @@ class DashTest extends TestCase * Test Cases */ - public function test_loads_empty_dash() + public function test_loads_empty_dash(): void { $this->seed(); @@ -51,7 +51,7 @@ class DashTest extends TestCase $response->assertStatus(200); } - public function test_displays_items_on_the_dash() + public function test_displays_items_on_the_dash(): void { $this->seed(); @@ -67,7 +67,7 @@ class DashTest extends TestCase $response->assertSee('Item 3'); } - public function test_displays_tags_on_the_dash() + public function test_displays_tags_on_the_dash(): void { $this->seed(); diff --git a/tests/Feature/ItemCreateTest.php b/tests/Feature/ItemCreateTest.php index f166face..2d7d681b 100644 --- a/tests/Feature/ItemCreateTest.php +++ b/tests/Feature/ItemCreateTest.php @@ -9,7 +9,7 @@ class ItemCreateTest extends TestCase { use RefreshDatabase; - public function test_displays_the_item_create_page() + public function test_displays_the_item_create_page(): void { $this->seed(); @@ -18,7 +18,7 @@ class ItemCreateTest extends TestCase $response->assertStatus(200); } - public function test_display_the_home_dashboard_tag() + public function test_display_the_home_dashboard_tag(): void { $this->seed(); @@ -27,7 +27,7 @@ class ItemCreateTest extends TestCase $response->assertSee('Home dashboard'); } - public function test_creates_a_new_item() + public function test_creates_a_new_item(): void { $this->seed(); $item = [ @@ -46,7 +46,7 @@ class ItemCreateTest extends TestCase $response->assertSee('Redirecting to'); } - public function test_redirects_to_dash_when_adding_a_new_item() + public function test_redirects_to_dash_when_adding_a_new_item(): void { $this->seed(); $item = [ diff --git a/tests/Feature/ItemDeleteTest.php b/tests/Feature/ItemDeleteTest.php index 13a1263b..63974c96 100644 --- a/tests/Feature/ItemDeleteTest.php +++ b/tests/Feature/ItemDeleteTest.php @@ -10,7 +10,7 @@ class ItemDeleteTest extends TestCase { use RefreshDatabase; - public function test_deletes_an_item() + public function test_deletes_an_item(): void { $this->seed(); $item = Item::factory() @@ -23,7 +23,7 @@ class ItemDeleteTest extends TestCase $response->assertStatus(302); } - public function test_redirects_to_item_list_page_when_deleting_an_item() + public function test_redirects_to_item_list_page_when_deleting_an_item(): void { $this->seed(); $item = Item::factory() diff --git a/tests/Feature/ItemExportTest.php b/tests/Feature/ItemExportTest.php index c56015a0..77baf32c 100644 --- a/tests/Feature/ItemExportTest.php +++ b/tests/Feature/ItemExportTest.php @@ -12,14 +12,14 @@ class ItemExportTest extends TestCase use RefreshDatabase; - public function test_returns_empty_jsonarray_when_there_are_no_items_in_the_db() + public function test_returns_empty_jsonarray_when_there_are_no_items_in_the_db(): void { $response = $this->get('api/item'); $response->assertJsonCount(0); } - public function test_returns_exactly_the_defined_fields() + public function test_returns_exactly_the_defined_fields(): void { $exampleItem = [ "appdescription" => "Description", @@ -37,7 +37,7 @@ class ItemExportTest extends TestCase $response->assertExactJson([(object)$exampleItem]); } - public function test_returns_all_items() + public function test_returns_all_items(): void { Item::factory() ->count(3) @@ -48,7 +48,7 @@ class ItemExportTest extends TestCase $response->assertJsonCount(3); } - public function test_does_not_return_deleted_item() + public function test_does_not_return_deleted_item(): void { Item::factory() ->create([ @@ -62,7 +62,7 @@ class ItemExportTest extends TestCase $response->assertJsonCount(1); } - public function test_does_not_return_tags() + public function test_does_not_return_tags(): void { Item::factory() ->create([ diff --git a/tests/Feature/ItemListTest.php b/tests/Feature/ItemListTest.php index 2d806d88..561ec8fb 100644 --- a/tests/Feature/ItemListTest.php +++ b/tests/Feature/ItemListTest.php @@ -18,7 +18,7 @@ class ItemListTest extends TestCase ]); } - public function test_displays_items_on_the_item_list_page() + public function test_displays_items_on_the_item_list_page(): void { $this->addItemWithTitleToDB('Item 1'); $this->addItemWithTitleToDB('Item 2'); @@ -32,7 +32,7 @@ class ItemListTest extends TestCase $response->assertSee('Item 3'); } - public function test_escapes_xss_on_the_item_list_page() + public function test_escapes_xss_on_the_item_list_page(): void { $this->addItemWithTitleToDB(''); diff --git a/tests/Feature/SettingsTest.php b/tests/Feature/SettingsTest.php index 8293dc2f..4afe6a54 100644 --- a/tests/Feature/SettingsTest.php +++ b/tests/Feature/SettingsTest.php @@ -9,7 +9,7 @@ class SettingsTest extends TestCase { use RefreshDatabase; - public function test_displays_the_settings_page() + public function test_displays_the_settings_page(): void { $this->seed(); diff --git a/tests/Feature/TagListTest.php b/tests/Feature/TagListTest.php index 54a52f9b..3b1332d1 100644 --- a/tests/Feature/TagListTest.php +++ b/tests/Feature/TagListTest.php @@ -19,7 +19,7 @@ class TagListTest extends TestCase ]); } - public function test_displays_the_tags_on_the_tag_list_page() + public function test_displays_the_tags_on_the_tag_list_page(): void { $this->addTagWithTitleToDB('Tag 1'); $this->addTagWithTitleToDB('Tag 2'); @@ -33,7 +33,7 @@ class TagListTest extends TestCase $response->assertSee('Tag 3'); } - public function test_escapes_xss_on_the_tag_list_page() + public function test_escapes_xss_on_the_tag_list_page(): void { $this->addTagWithTitleToDB(''); diff --git a/tests/Feature/UserListTest.php b/tests/Feature/UserListTest.php index e297f6fa..9f92edbc 100644 --- a/tests/Feature/UserListTest.php +++ b/tests/Feature/UserListTest.php @@ -18,7 +18,7 @@ class UserListTest extends TestCase ]); } - public function test_displays_admin_on_user_list_page_when_default_install() + public function test_displays_admin_on_user_list_page_when_default_install(): void { $this->seed(); @@ -28,7 +28,7 @@ class UserListTest extends TestCase $response->assertSee('admin'); } - public function test_displays_users_on_user_list_page() + public function test_displays_users_on_user_list_page(): void { $this->seed(); diff --git a/tests/Unit/database/seeders/SettingsSeederTest.php b/tests/Unit/database/seeders/SettingsSeederTest.php index 88532764..25320f26 100644 --- a/tests/Unit/database/seeders/SettingsSeederTest.php +++ b/tests/Unit/database/seeders/SettingsSeederTest.php @@ -12,7 +12,7 @@ class SettingsSeederTest extends TestCase * * @return void */ - public function test_returns_a_jsonmap_with_same_amount_of_items_as_language_directories_present() + public function test_returns_a_jsonmap_with_same_amount_of_items_as_language_directories_present(): void { $languageDirectories = array_filter(glob(resource_path().'/lang/*'), 'is_dir'); diff --git a/tests/Unit/helpers/IsImageTest.php b/tests/Unit/helpers/IsImageTest.php index 8b14a794..189d097b 100644 --- a/tests/Unit/helpers/IsImageTest.php +++ b/tests/Unit/helpers/IsImageTest.php @@ -9,7 +9,7 @@ class IsImageTest extends TestCase /** * @return void */ - public function test_returns_true_when_file_is_image() + public function test_returns_true_when_file_is_image(): void { $file = file_get_contents(__DIR__ . '/fixtures/heimdall-icon-small.png'); @@ -21,7 +21,7 @@ class IsImageTest extends TestCase /** * @return void */ - public function test_returns_false_when_file_extension_is_image_but_content_is_not() + public function test_returns_false_when_file_extension_is_image_but_content_is_not(): void { $actual = isImage("", "png"); @@ -31,7 +31,7 @@ class IsImageTest extends TestCase /** * @return void */ - public function test_returns_false_when_file_extension_is_not_image_but_content_is() + public function test_returns_false_when_file_extension_is_not_image_but_content_is(): void { $file = file_get_contents(__DIR__ . '/fixtures/heimdall-icon-small.png'); diff --git a/tests/Unit/helpers/SlugTest.php b/tests/Unit/helpers/SlugTest.php index a12bd8be..fdb63203 100644 --- a/tests/Unit/helpers/SlugTest.php +++ b/tests/Unit/helpers/SlugTest.php @@ -9,7 +9,7 @@ class SlugTest extends TestCase /** * @return void */ - public function test_slug_returns_valid_tag_for_cn_characters_when_language_is_set_to_en_US() + public function test_slug_returns_valid_tag_for_cn_characters_when_language_is_set_to_en_US(): void { $tag = str_slug('中文測試', '-', 'en_US'); diff --git a/tests/Unit/lang/LangTest.php b/tests/Unit/lang/LangTest.php index 33d2105a..dc84c8e8 100644 --- a/tests/Unit/lang/LangTest.php +++ b/tests/Unit/lang/LangTest.php @@ -11,7 +11,7 @@ class LangTest extends TestCase * * @return void */ - public function test_all_language_keys_are_defined() + public function test_all_language_keys_are_defined(): void { $this->markTestSkipped('2022-11-14 Lot of keys missing. Enable this test to see them all.'); $languageDirectories = array_filter(glob(resource_path().'/lang/*'), 'is_dir');