mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -9,6 +9,9 @@
|
||||
|
||||
class CreateUser
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function create(array $input): User
|
||||
{
|
||||
$this->validate($input);
|
||||
@ -25,11 +28,17 @@ public function create(array $input): User
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
private function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, self::rules())->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
|
@ -7,9 +7,7 @@
|
||||
trait PasswordValidationRules
|
||||
{
|
||||
/**
|
||||
* Get the validation rules used to validate passwords.
|
||||
*
|
||||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array|string>
|
||||
* @return array<int, mixed>
|
||||
*/
|
||||
protected function passwordRules(): array
|
||||
{
|
||||
|
@ -5,9 +5,15 @@
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UpdateProjects
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function update(User $user, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
@ -20,7 +26,7 @@ public function update(User $user, array $input): void
|
||||
|
||||
$user->refresh();
|
||||
|
||||
/** @var Project $firstProject */
|
||||
/** @var ?Project $firstProject */
|
||||
$firstProject = $user->projects->first();
|
||||
if (! $user->currentProject && $firstProject) {
|
||||
$user->current_project_id = $firstProject->id;
|
||||
@ -28,11 +34,19 @@ public function update(User $user, array $input): void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validate(array $input): void
|
||||
{
|
||||
validator($input, self::rules())->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string>>
|
||||
*/
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
|
@ -9,6 +9,9 @@
|
||||
|
||||
class UpdateUser
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function update(User $user, array $input): User
|
||||
{
|
||||
$this->validate($user, $input);
|
||||
@ -27,11 +30,17 @@ public function update(User $user, array $input): User
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
private function validate(User $user, array $input): void
|
||||
{
|
||||
Validator::make($input, self::rules($user))->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function rules(User $user): array
|
||||
{
|
||||
return [
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
class UpdateUserPassword
|
||||
{
|
||||
/**
|
||||
* @param mixed $user
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function update($user, array $input): void
|
||||
{
|
||||
$user->forceFill([
|
||||
@ -13,6 +17,9 @@ public function update($user, array $input): void
|
||||
])->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string>>
|
||||
*/
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
|
@ -4,9 +4,15 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UpdateUserProfileInformation
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function update(User $user, array $input): void
|
||||
{
|
||||
if ($input['email'] !== $user->email) {
|
||||
@ -20,6 +26,9 @@ public function update(User $user, array $input): void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string>>
|
||||
*/
|
||||
public static function rules(User $user): array
|
||||
{
|
||||
return [
|
||||
@ -33,7 +42,7 @@ public static function rules(User $user): array
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the given verified user's profile information.
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
protected function updateVerifiedUser(User $user, array $input): void
|
||||
{
|
||||
|
Reference in New Issue
Block a user