update php-cs-fixer config & apply fixes

This commit is contained in:
Pig Fang 2023-01-16 23:15:41 +08:00
parent 64dea61ec9
commit eff859a864
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2
4 changed files with 31 additions and 26 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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();

View File

@ -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();