apply rules rector up to php82

This commit is contained in:
2023-05-01 21:39:45 +02:00
parent 81e8928344
commit 6d63177ff4
733 changed files with 1257 additions and 1322 deletions

View File

@@ -16,22 +16,21 @@ use Symfony\Component\EventDispatcher\Event;
class PasswordRecoverEvent extends Event
{
public const ASK_TOKEN_INVALID_FORM = 'chill_main.ask_token_invalid_form';
final public const ASK_TOKEN_INVALID_FORM = 'chill_main.ask_token_invalid_form';
public const ASK_TOKEN_SUCCESS = 'chill_main.ask_token_success';
final public const ASK_TOKEN_SUCCESS = 'chill_main.ask_token_success';
public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token';
final public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token';
/**
* @param bool $safelyGenerated true if generated safely (from console command, etc.)
*/
public function __construct(
private ?string $token = null,
private ?User $user = null,
private readonly ?string $token = null,
private readonly ?User $user = null,
private $ip = null,
private bool $safelyGenerated = false,
)
{
private readonly bool $safelyGenerated = false,
) {
}
public function getIp()

View File

@@ -18,28 +18,28 @@ use UnexpectedValueException;
class PasswordRecoverLocker
{
public const ASK_TOKEN_INVALID_FORM_TTL = 3600;
final public const ASK_TOKEN_INVALID_FORM_TTL = 3600;
/**
* TTL to keep invalid token recorded.
*/
public const INVALID_TOKEN_TTL = 3600;
final public const INVALID_TOKEN_TTL = 3600;
public const MAX_ASK_TOKEN_BY_USER = 10;
final public const MAX_ASK_TOKEN_BY_USER = 10;
public const MAX_ASK_TOKEN_INVALID_FORM_BY_IP = 10;
final public const MAX_ASK_TOKEN_INVALID_FORM_BY_IP = 10;
public const MAX_ASK_TOKEN_INVALID_FORM_GLOBAL = 50;
final public const MAX_ASK_TOKEN_INVALID_FORM_GLOBAL = 50;
/**
* The maximum of invalid token by ip.
*/
public const MAX_INVALID_TOKEN_BY_IP = 10;
final public const MAX_INVALID_TOKEN_BY_IP = 10;
/**
* The maximum of invalid token globally (across all ip).
*/
public const MAX_INVALID_TOKEN_GLOBAL = 50;
final public const MAX_INVALID_TOKEN_GLOBAL = 50;
/**
* @var ChillRedis

View File

@@ -20,9 +20,9 @@ use function in_array;
class PasswordRecoverVoter extends Voter
{
public const ASK_TOKEN = 'CHILL_PASSWORD_ASK_TOKEN';
final public const ASK_TOKEN = 'CHILL_PASSWORD_ASK_TOKEN';
public const TRY_TOKEN = 'CHILL_PASSWORD_TRY_TOKEN';
final public const TRY_TOKEN = 'CHILL_PASSWORD_TRY_TOKEN';
/**
* @var PasswordRecoverLocker

View File

@@ -22,9 +22,9 @@ use function array_merge;
class RecoverPasswordHelper
{
public const RECOVER_PASSWORD_ROUTE = 'password_recover';
final public const RECOVER_PASSWORD_ROUTE = 'password_recover';
public function __construct(private TokenManager $tokenManager, private UrlGeneratorInterface $urlGenerator, private MailerInterface $mailer)
public function __construct(private readonly TokenManager $tokenManager, private readonly UrlGeneratorInterface $urlGenerator, private readonly MailerInterface $mailer)
{
}

View File

@@ -27,15 +27,15 @@ use function trim;
class TokenManager
{
public const HASH = 'h';
final public const HASH = 'h';
public const TIMESTAMP = 'ts';
final public const TIMESTAMP = 'ts';
public const TOKEN = 't';
final public const TOKEN = 't';
public const TOKEN_LENGTH = 24;
final public const TOKEN_LENGTH = 24;
public const USERNAME_CANONICAL = 'u';
final public const USERNAME_CANONICAL = 'u';
/**
* @var LoggerInterface
@@ -72,7 +72,7 @@ class TokenManager
public function verify($hash, $token, User $user, string $timestamp)
{
$token = hex2bin(trim($token));
$token = hex2bin(trim((string) $token));
if (strlen($token) !== self::TOKEN_LENGTH) {
return false;