Skip to content

Code analyses #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .github/workflows/php-cs-fixer.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Homestead.json
Homestead.yaml
.phpstorm.meta.php
_ide_helper.php
_ide_helper_models.php

# OSX
#
Expand Down
150 changes: 0 additions & 150 deletions .php-cs-fixer.php

This file was deleted.

3 changes: 2 additions & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class CreateNewUser implements CreatesNewUsers
/**
* Validate and create a newly registered user.
*
* @param array $input
* @param array $input<string, string>
* @return \App\Models\User
*
* @throws \Illuminate\Validation\ValidationException
*/
public function create(array $input): User
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Fortify/PasswordValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait PasswordValidationRules
/**
* Get the validation rules used to validate passwords.
*
* @return array
* @return array<int, \Illuminate\Validation\Rules\Password|string>
*/
protected function passwordRules(): array
{
Expand Down
5 changes: 3 additions & 2 deletions app/Actions/Fortify/ResetUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class ResetUserPassword implements ResetsUserPasswords
/**
* Validate and reset the user's forgotten password.
*
* @param mixed $user
* @param array $input
* @param mixed $user
* @param array $input<string string>
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function reset($user, array $input)
Expand Down
7 changes: 4 additions & 3 deletions app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class UpdateUserPassword implements UpdatesUserPasswords
/**
* Validate and update the user's password.
*
* @param mixed $user
* @param array $input
* @param mixed $user
* @param array $input
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function update($user, array $input)
Expand All @@ -24,7 +25,7 @@ public function update($user, array $input)
'current_password' => ['required', 'string'],
'password' => $this->passwordRules(),
])->after(function ($validator) use ($user, $input) {
if (!isset($input['current_password']) || !Hash::check($input['current_password'], $user->password)) {
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
$validator->errors()->add('current_password', __('Le mot de passe fourni ne correspond pas à votre mot de passe actuel.'));
}
})->validateWithBag('updatePassword');
Expand Down
5 changes: 3 additions & 2 deletions app/Actions/Fortify/UpdateUserProfileInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
/**
* Validate and update the given user's profile information.
*
* @param mixed $user
* @param array $input
* @param mixed $user
* @param array $input<string, string>
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function update($user, array $input)
Expand Down
8 changes: 5 additions & 3 deletions app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ class DeleteOldUnverifiedUsers extends Command

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

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

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

if ($query->get()->isNotEmpty()) {
foreach ($query->get() as $user) {
$users = $query->get();

if ($users->isNotEmpty()) {
foreach ($users as $user) {
$user->notify((new SendEMailToDeletedUser())->delay(now()->addMinutes(5)));
}
}
Expand Down
16 changes: 3 additions & 13 deletions app/Console/Commands/CreateAdminUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;

class CreateAdminUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'lcm:admin';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create user with admin role and all permissions.';

public function handle()
public function handle(): void
{
$this->info('Create Admin User.');
$this->createUser();
Expand Down Expand Up @@ -51,10 +42,9 @@ protected function createUser(): void
'password' => Hash::make($password),
'email_verified_at' => now()->toDateTimeString(),
];
$model = config('auth.providers.users.model');

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

$user->assignRole('admin');
} catch (\Exception | QueryException $e) {
Expand Down
1 change: 1 addition & 0 deletions app/Console/Commands/UpdateUserDiscussionsPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function handle()
$this->info('Updating users discussions reputations...');

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

Expand Down
3 changes: 2 additions & 1 deletion app/Console/Commands/UpdateUserPostsPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public function handle()
{
$this->info('Updating users posts reputations...');

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

Expand Down
1 change: 1 addition & 0 deletions app/Console/Commands/UpdateUserThreadsPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function handle()
$this->info('Updating users threads reputations...');

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

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
$this->load(__DIR__ . '/Commands');
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
Expand Down
4 changes: 2 additions & 2 deletions app/Contracts/ReplyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

interface ReplyInterface
{
public function subject(): string;
public function subject(): int|string;

public function latestReplies(int $amount = 5): Collection;

public function replies(): MorphMany;

public function isConversationOld(): bool;

public function replyAbleSubject(): string;
public function replyAbleSubject(): int|string;

public function getPathUrl(): string;
}
6 changes: 3 additions & 3 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Handler extends ExceptionHandler
/**
* A list of the exception types that are not reported.
*
* @var array
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
Expand All @@ -19,7 +19,7 @@ class Handler extends ExceptionHandler
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
Expand All @@ -32,7 +32,7 @@ class Handler extends ExceptionHandler
*
* @return void
*/
public function register()
public function register(): void
{
$this->reportable(function (Throwable $e) {
if ($this->shouldReport($e) && app()->bound('sentry')) {
Expand Down
Loading