Skip to content

Commit 63b9873

Browse files
committed
📈 ajout de phpstan pour la validation statique du code
1 parent 5b93f4a commit 63b9873

Some content is hidden

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

62 files changed

+1464
-175
lines changed

.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
#

app/Actions/Fortify/CreateNewUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ 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
2121
*
2222
* @throws \Illuminate\Validation\ValidationException

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ResetUserPassword implements ResetsUserPasswords
1414
* Validate and reset the user's forgotten password.
1515
*
1616
* @param mixed $user
17-
* @param array $input
17+
* @param array $input<string string>
1818
* @return void
1919
*
2020
* @throws \Illuminate\Validation\ValidationException

app/Actions/Fortify/UpdateUserProfileInformation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
1313
* Validate and update the given user's profile information.
1414
*
1515
* @param mixed $user
16-
* @param array $input
16+
* @param array $input<string, string>
1717
* @return void
1818
*
1919
* @throws \Illuminate\Validation\ValidationException

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

app/Console/Commands/UpdateUserDiscussionsPoints.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public function handle()
1717
$this->info('Updating users discussions reputations...');
1818

1919
foreach (Discussion::all() as $discussion) {
20+
// @phpstan-ignore-next-line
2021
givePoint(new DiscussionCreated($discussion), $discussion->author);
2122
}
2223

app/Console/Commands/UpdateUserPostsPoints.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public function handle()
1616
{
1717
$this->info('Updating users posts reputations...');
1818

19-
foreach (Article::all() as $article) {
19+
foreach (Article::published()->get() as $article) {
20+
// @phpstan-ignore-next-line
2021
givePoint(new PostCreated($article), $article->author);
2122
}
2223

app/Console/Commands/UpdateUserThreadsPoints.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public function handle()
1717
$this->info('Updating users threads reputations...');
1818

1919
foreach (Thread::all() as $thread) {
20+
// @phpstan-ignore-next-line
2021
givePoint(new ThreadCreated($thread), $thread->author);
2122
}
2223

0 commit comments

Comments
 (0)