mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Upgrade project to PHP 8.3, add PHPStan, upgrade almost every dependency (#36)
* start updating to PHP 8.3 * taking off! Co-authored-by: ErickSkrauch <erickskrauch@yandex.ru> Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * dropped this Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * migrate to symfonymailer Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * this is so stupid 😭 Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * ah, free, at last. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * oh, Gabriel. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * now dawns thy reckoning. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * and thy gore shall GLISTEN before the temples of man. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * creature of steel. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * my gratitude upon thee for my freedom. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * but the crimes thy kind has committed against humanity Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * Upgrade PHP-CS-Fixer and do fix the codebase * First review round (maybe I have broken something) * are NOT forgotten. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> * Enable parallel PHP-CS-Fixer runner * PHPStan level 1 * PHPStan level 2 * PHPStan level 3 * PHPStan level 4 * PHPStan level 5 * Levels 6 and 7 takes too much effort. Generate a baseline and fix them eventually * Resolve TODO's related to the php-mock * Drastically reduce baseline size with the Rector * More code modernization with help of the Rector * Update GitLab CI --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com> Co-authored-by: ErickSkrauch <erickskrauch@yandex.ru>
This commit is contained in:
@@ -7,12 +7,9 @@ use common\models\Account;
|
||||
use Yii;
|
||||
use yii\queue\RetryableJobInterface;
|
||||
|
||||
final class ClearAccountSessions implements RetryableJobInterface {
|
||||
final readonly class ClearAccountSessions implements RetryableJobInterface {
|
||||
|
||||
private int $accountId;
|
||||
|
||||
public function __construct(int $accountId) {
|
||||
$this->accountId = $accountId;
|
||||
public function __construct(private int $accountId) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,16 +9,13 @@ use yii\queue\RetryableJobInterface;
|
||||
|
||||
final class ClearOauthSessions implements RetryableJobInterface {
|
||||
|
||||
public string $clientId;
|
||||
|
||||
/**
|
||||
* @var int|null unix timestamp, that allows to limit this task to clear only some old sessions
|
||||
*/
|
||||
public ?int $notSince;
|
||||
|
||||
public function __construct(string $clientId, int $notSince = null) {
|
||||
$this->clientId = $clientId;
|
||||
$this->notSince = $notSince;
|
||||
public function __construct(
|
||||
public string $clientId,
|
||||
/**
|
||||
* @var int|null unix timestamp, that allows to limit this task to clear only some old sessions
|
||||
*/
|
||||
public ?int $notSince = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public static function createFromOauthClient(OauthClient $client, int $notSince = null): self {
|
||||
@@ -26,7 +23,7 @@ final class ClearOauthSessions implements RetryableJobInterface {
|
||||
}
|
||||
|
||||
public function getTtr(): int {
|
||||
return 60/*sec*/ * 5/*min*/;
|
||||
return 60/* sec */ * 5/* min */;
|
||||
}
|
||||
|
||||
public function canRetry($attempt, $error): bool {
|
||||
|
||||
@@ -8,12 +8,9 @@ use common\notifications\NotificationInterface;
|
||||
use yii\db\Expression;
|
||||
use yii\queue\RetryableJobInterface;
|
||||
|
||||
final class CreateWebHooksDeliveries implements RetryableJobInterface {
|
||||
final readonly class CreateWebHooksDeliveries implements RetryableJobInterface {
|
||||
|
||||
private NotificationInterface $notification;
|
||||
|
||||
public function __construct(NotificationInterface $notification) {
|
||||
$this->notification = $notification;
|
||||
public function __construct(private NotificationInterface $notification) {
|
||||
}
|
||||
|
||||
public function getTtr(): int {
|
||||
|
||||
@@ -7,12 +7,9 @@ use common\models\Account;
|
||||
use Yii;
|
||||
use yii\queue\RetryableJobInterface;
|
||||
|
||||
final class DeleteAccount implements RetryableJobInterface {
|
||||
final readonly class DeleteAccount implements RetryableJobInterface {
|
||||
|
||||
private int $accountId;
|
||||
|
||||
public function __construct(int $accountId) {
|
||||
$this->accountId = $accountId;
|
||||
public function __construct(private int $accountId) {
|
||||
}
|
||||
|
||||
public function getTtr(): int {
|
||||
|
||||
@@ -20,7 +20,7 @@ class DeliveryWebHook implements RetryableJobInterface {
|
||||
|
||||
public string $url;
|
||||
|
||||
public ?string $secret;
|
||||
public ?string $secret = null;
|
||||
|
||||
public array $payloads;
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ use Webmozart\Assert\Assert;
|
||||
use Yii;
|
||||
use yii\queue\JobInterface;
|
||||
|
||||
class PullMojangUsername implements JobInterface {
|
||||
final class PullMojangUsername implements JobInterface {
|
||||
|
||||
public $username;
|
||||
|
||||
public static function createFromAccount(Account $account): self {
|
||||
$result = new static();
|
||||
$result = new self();
|
||||
$result->username = $account->username;
|
||||
|
||||
return $result;
|
||||
@@ -29,17 +29,17 @@ class PullMojangUsername implements JobInterface {
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute($queue) {
|
||||
public function execute($queue): void {
|
||||
Yii::$app->statsd->inc('queue.pullMojangUsername.attempt');
|
||||
/** @var MojangApi $mojangApi */
|
||||
$mojangApi = Yii::$container->get(MojangApi::class);
|
||||
try {
|
||||
$response = $mojangApi->usernameToUUID($this->username);
|
||||
Yii::$app->statsd->inc('queue.pullMojangUsername.found');
|
||||
} catch (NoContentException $e) {
|
||||
} catch (NoContentException) {
|
||||
$response = false;
|
||||
Yii::$app->statsd->inc('queue.pullMojangUsername.not_found');
|
||||
} catch (GuzzleException | MojangApiException $e) {
|
||||
} catch (GuzzleException|MojangApiException) {
|
||||
Yii::$app->statsd->inc('queue.pullMojangUsername.error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,18 +7,22 @@ use common\emails\EmailHelper;
|
||||
use common\emails\templates\ChangeEmail;
|
||||
use common\models\confirmations\CurrentEmailConfirmation;
|
||||
use Yii;
|
||||
use yii\mail\MailerInterface;
|
||||
use yii\queue\RetryableJobInterface;
|
||||
|
||||
class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||
|
||||
public $email;
|
||||
public mixed $email = null;
|
||||
|
||||
public $username;
|
||||
public mixed $username = null;
|
||||
|
||||
public $code;
|
||||
public mixed $code = null;
|
||||
|
||||
public function __construct(public MailerInterface $mailer) {
|
||||
}
|
||||
|
||||
public static function createFromConfirmation(CurrentEmailConfirmation $confirmation): self {
|
||||
$result = new self();
|
||||
$result = new self(Yii::$app->mailer);
|
||||
$result->email = $confirmation->account->email;
|
||||
$result->username = $confirmation->account->username;
|
||||
$result->code = $confirmation->key;
|
||||
@@ -38,9 +42,9 @@ class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||
* @param \yii\queue\Queue $queue
|
||||
* @throws \common\emails\exceptions\CannotSendEmailException
|
||||
*/
|
||||
public function execute($queue) {
|
||||
public function execute($queue): void {
|
||||
Yii::$app->statsd->inc('queue.sendCurrentEmailConfirmation.attempt');
|
||||
$template = new ChangeEmail(Yii::$app->mailer);
|
||||
$template = new ChangeEmail($this->mailer);
|
||||
$template->setKey($this->code);
|
||||
$template->send(EmailHelper::buildTo($this->username, $this->email));
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class SendNewEmailConfirmation implements RetryableJobInterface {
|
||||
* @param \yii\queue\Queue $queue
|
||||
* @throws \common\emails\exceptions\CannotSendEmailException
|
||||
*/
|
||||
public function execute($queue) {
|
||||
public function execute($queue): void {
|
||||
Yii::$app->statsd->inc('queue.sendNewEmailConfirmation.attempt');
|
||||
$template = new ConfirmNewEmail(Yii::$app->mailer);
|
||||
$template->setKey($this->code);
|
||||
|
||||
@@ -47,7 +47,7 @@ class SendPasswordRecoveryEmail implements RetryableJobInterface {
|
||||
* @param \yii\queue\Queue $queue
|
||||
* @throws \common\emails\exceptions\CannotSendEmailException
|
||||
*/
|
||||
public function execute($queue) {
|
||||
public function execute($queue): void {
|
||||
Yii::$app->statsd->inc('queue.sendPasswordRecovery.attempt');
|
||||
$template = new ForgotPasswordEmail(Yii::$app->mailer, Yii::$app->emailsRenderer);
|
||||
$template->setLocale($this->locale);
|
||||
|
||||
@@ -47,7 +47,7 @@ class SendRegistrationEmail implements RetryableJobInterface {
|
||||
* @param \yii\queue\Queue $queue
|
||||
* @throws \common\emails\exceptions\CannotSendEmailException
|
||||
*/
|
||||
public function execute($queue) {
|
||||
public function execute($queue): void {
|
||||
Yii::$app->statsd->inc('queue.sendRegistrationEmail.attempt');
|
||||
$template = new RegistrationEmail(Yii::$app->mailer, Yii::$app->emailsRenderer);
|
||||
$template->setLocale($this->locale);
|
||||
|
||||
Reference in New Issue
Block a user