Skip to content

Commit 4881678

Browse files
authored
Merge pull request #58 from laravelcm/code-analyses
Code analyses
2 parents 62d7b1d + 537935b commit 4881678

File tree

114 files changed

+1937
-1256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1937
-1256
lines changed

.github/workflows/php-cs-fixer.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Homestead.json
4343
Homestead.yaml
4444
.phpstorm.meta.php
4545
_ide_helper.php
46+
_ide_helper_models.php
4647

4748
# OSX
4849
#

.php-cs-fixer.php

Lines changed: 0 additions & 150 deletions
This file was deleted.

app/Actions/Fortify/CreateNewUser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class CreateNewUser implements CreatesNewUsers
1616
/**
1717
* Validate and create a newly registered user.
1818
*
19-
* @param array $input
19+
* @param array $input<string, string>
2020
* @return \App\Models\User
21+
*
2122
* @throws \Illuminate\Validation\ValidationException
2223
*/
2324
public function create(array $input): User

app/Actions/Fortify/PasswordValidationRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait PasswordValidationRules
99
/**
1010
* Get the validation rules used to validate passwords.
1111
*
12-
* @return array
12+
* @return array<int, \Illuminate\Validation\Rules\Password|string>
1313
*/
1414
protected function passwordRules(): array
1515
{

app/Actions/Fortify/ResetUserPassword.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ class ResetUserPassword implements ResetsUserPasswords
1313
/**
1414
* Validate and reset the user's forgotten password.
1515
*
16-
* @param mixed $user
17-
* @param array $input
16+
* @param mixed $user
17+
* @param array $input<string string>
1818
* @return void
19+
*
1920
* @throws \Illuminate\Validation\ValidationException
2021
*/
2122
public function reset($user, array $input)

app/Actions/Fortify/UpdateUserPassword.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ class UpdateUserPassword implements UpdatesUserPasswords
1313
/**
1414
* Validate and update the user's password.
1515
*
16-
* @param mixed $user
17-
* @param array $input
16+
* @param mixed $user
17+
* @param array $input
1818
* @return void
19+
*
1920
* @throws \Illuminate\Validation\ValidationException
2021
*/
2122
public function update($user, array $input)
@@ -24,7 +25,7 @@ public function update($user, array $input)
2425
'current_password' => ['required', 'string'],
2526
'password' => $this->passwordRules(),
2627
])->after(function ($validator) use ($user, $input) {
27-
if (!isset($input['current_password']) || !Hash::check($input['current_password'], $user->password)) {
28+
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
2829
$validator->errors()->add('current_password', __('Le mot de passe fourni ne correspond pas à votre mot de passe actuel.'));
2930
}
3031
})->validateWithBag('updatePassword');

app/Actions/Fortify/UpdateUserProfileInformation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
1212
/**
1313
* Validate and update the given user's profile information.
1414
*
15-
* @param mixed $user
16-
* @param array $input
15+
* @param mixed $user
16+
* @param array $input<string, string>
1717
* @return void
18+
*
1819
* @throws \Illuminate\Validation\ValidationException
1920
*/
2021
public function update($user, array $input)

app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ class DeleteOldUnverifiedUsers extends Command
1212

1313
protected $description = 'Removed all unverified users.';
1414

15-
public function handle()
15+
public function handle(): void
1616
{
1717
$this->info('Deleting old unverified users...');
1818

1919
$query = User::query()
2020
->whereNull('email_verified_at')
2121
->where('created_at', '<', now()->subDays(10));
2222

23-
if ($query->get()->isNotEmpty()) {
24-
foreach ($query->get() as $user) {
23+
$users = $query->get();
24+
25+
if ($users->isNotEmpty()) {
26+
foreach ($users as $user) {
2527
$user->notify((new SendEMailToDeletedUser())->delay(now()->addMinutes(5)));
2628
}
2729
}

app/Console/Commands/CreateAdminUser.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,18 @@
22

33
namespace App\Console\Commands;
44

5+
use App\Models\User;
56
use Illuminate\Console\Command;
67
use Illuminate\Database\QueryException;
78
use Illuminate\Support\Facades\Hash;
89

910
class CreateAdminUser extends Command
1011
{
11-
/**
12-
* The name and signature of the console command.
13-
*
14-
* @var string
15-
*/
1612
protected $signature = 'lcm:admin';
1713

18-
/**
19-
* The console command description.
20-
*
21-
* @var string
22-
*/
2314
protected $description = 'Create user with admin role and all permissions.';
2415

25-
public function handle()
16+
public function handle(): void
2617
{
2718
$this->info('Create Admin User.');
2819
$this->createUser();
@@ -51,10 +42,9 @@ protected function createUser(): void
5142
'password' => Hash::make($password),
5243
'email_verified_at' => now()->toDateTimeString(),
5344
];
54-
$model = config('auth.providers.users.model');
5545

5646
try {
57-
$user = tap((new $model)->forceFill($userData))->save();
47+
$user = User::query()->create($userData);
5848

5949
$user->assignRole('admin');
6050
} catch (\Exception | QueryException $e) {

0 commit comments

Comments
 (0)