diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 41535f86..88d5449f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -8,11 +8,16 @@ $finder = PhpCsFixer\Finder::create() $config = new PhpCsFixer\Config(); return $config->setRules([ - '@Symfony' => true, - 'align_multiline_comment' => true, - 'array_syntax' => ['syntax' => 'short'], - 'increment_style' => ['style' => 'post'], - 'list_syntax' => ['syntax' => 'short'], - 'yoda_style' => false, - ]) + '@Symfony' => true, + 'align_multiline_comment' => true, + 'array_syntax' => ['syntax' => 'short'], + 'increment_style' => ['style' => 'post'], + 'list_syntax' => ['syntax' => 'short'], + 'yoda_style' => false, + 'global_namespace_import' => [ + 'import_constants' => true, + 'import_functions' => true, + 'import_classes' => null, + ], +]) ->setFinder($finder); diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 24ec0c55..32849c2e 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -53,7 +53,7 @@ class AdminController extends Controller $grouping = fn ($field) => fn ($item) => Carbon::parse($item->$field)->isoFormat('l'); $mapping = fn ($item) => count($item); - $aligning = fn ($data) => fn ($day) => ($data->get($day) ?? 0); + $aligning = fn ($data) => fn ($day) => $data->get($day) ?? 0; /** @var Collection */ $userRegistration = User::where('register_at', '>=', $oneMonthAgo) diff --git a/tests/HttpTest/ControllersTest/AuthControllerTest.php b/tests/HttpTest/ControllersTest/AuthControllerTest.php index 33762c41..518aaa7d 100644 --- a/tests/HttpTest/ControllersTest/AuthControllerTest.php +++ b/tests/HttpTest/ControllersTest/AuthControllerTest.php @@ -142,9 +142,9 @@ class AuthControllerTest extends TestCase // Should check captcha if there are too many fails Cache::put($loginFailsCacheKey, 4); $this->postJson( - '/auth/login', [ - 'identification' => $user->email, - 'password' => '12345678', + '/auth/login', [ + 'identification' => $user->email, + 'password' => '12345678', ])->assertJsonValidationErrors('captcha'); Cache::flush(); diff --git a/tests/HttpTest/ControllersTest/PlayerControllerTest.php b/tests/HttpTest/ControllersTest/PlayerControllerTest.php index d0abaf02..ee70116c 100644 --- a/tests/HttpTest/ControllersTest/PlayerControllerTest.php +++ b/tests/HttpTest/ControllersTest/PlayerControllerTest.php @@ -249,23 +249,23 @@ class PlayerControllerTest extends TestCase // Only A-Za-z0-9_ are allowed option(['player_name_rule' => 'official']); $this->putJson( - route('user.player.rename', ['player' => $player]), - ['name' => '角色名'] - )->assertJsonValidationErrors('name'); + route('user.player.rename', ['player' => $player]), + ['name' => '角色名'] + )->assertJsonValidationErrors('name'); // Other invalid characters option(['player_name_rule' => 'cjk']); $this->putJson( - route('user.player.rename', ['player' => $player]), - ['name' => '\\'] - )->assertJsonValidationErrors('name'); + route('user.player.rename', ['player' => $player]), + ['name' => '\\'] + )->assertJsonValidationErrors('name'); // with an existed player name $existed = Player::factory()->create(); $this->putJson( - route('user.player.rename', ['player' => $player]), - ['name' => $existed->name] - )->assertJsonValidationErrors('name'); + route('user.player.rename', ['player' => $player]), + ['name' => $existed->name] + )->assertJsonValidationErrors('name'); // Rejected by filter $filter = Fakes\Filter::fake(); @@ -350,12 +350,12 @@ class PlayerControllerTest extends TestCase // set a private texture $private = Texture::factory()->private()->create(); $this->putJson( - route('user.player.set', ['player' => $player]), - ['skin' => $private->tid] - )->assertJson([ - 'code' => 1, - 'message' => trans('user.closet.remove.non-existent'), - ]); + route('user.player.set', ['player' => $player]), + ['skin' => $private->tid] + )->assertJson([ + 'code' => 1, + 'message' => trans('user.closet.remove.non-existent'), + ]); // set for "skin" type Event::fake();