diff --git a/api/models/authentication/ConfirmEmailForm.php b/api/models/authentication/ConfirmEmailForm.php index 587ac7d..d34113e 100644 --- a/api/models/authentication/ConfirmEmailForm.php +++ b/api/models/authentication/ConfirmEmailForm.php @@ -17,7 +17,7 @@ class ConfirmEmailForm extends KeyConfirmationForm { } $confirmModel = $this->getActivationCodeModel(); - if ($confirmModel->type != EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION) { + if ($confirmModel->type !== EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION) { $confirmModel->delete(); // TODO: вот где-то здесь нужно ещё попутно сгенерировать соответствующую ошибку return false; @@ -31,7 +31,7 @@ class ConfirmEmailForm extends KeyConfirmationForm { throw new ErrorException('Unable remove activation key.'); } - if (!$account->save()) { + if (!$account->save(false)) { throw new ErrorException('Unable activate user account.'); } diff --git a/api/models/profile/ChangePasswordForm.php b/api/models/profile/ChangePasswordForm.php index a8edc50..ecc7587 100644 --- a/api/models/profile/ChangePasswordForm.php +++ b/api/models/profile/ChangePasswordForm.php @@ -77,7 +77,7 @@ class ChangePasswordForm extends ApiForm { } } - if (!$account->save()) { + if (!$account->save(false)) { throw new ErrorException('Cannot save user model'); } diff --git a/api/modules/mojang/controllers/ApiController.php b/api/modules/mojang/controllers/ApiController.php index 53967df..1545ee7 100644 --- a/api/modules/mojang/controllers/ApiController.php +++ b/api/modules/mojang/controllers/ApiController.php @@ -32,7 +32,7 @@ class ApiController extends Controller { // ник пользователь не сменил его на нечто иное $account = null; if ($record !== null) { - if ($record->findNext($at) !== null || $record->account->username === $record->username) { + if ($record->account->username === $record->username || $record->findNext($at) !== null) { $account = $record->account; } } diff --git a/common/components/UserFriendlyRandomKey.php b/common/components/UserFriendlyRandomKey.php index cae9958..ebeb111 100644 --- a/common/components/UserFriendlyRandomKey.php +++ b/common/components/UserFriendlyRandomKey.php @@ -9,7 +9,7 @@ class UserFriendlyRandomKey { $numChars = strlen($chars); $key = ''; for ($i = 0; $i < $length; $i++) { - $key .= substr($chars, rand(1, $numChars) - 1, 1); + $key .= $chars[random_int(0, $numChars - 1)]; } return $key; diff --git a/common/components/oauth/Storage/Redis/AuthCodeStorage.php b/common/components/oauth/Storage/Redis/AuthCodeStorage.php index 204027d..f3bdbdc 100644 --- a/common/components/oauth/Storage/Redis/AuthCodeStorage.php +++ b/common/components/oauth/Storage/Redis/AuthCodeStorage.php @@ -54,7 +54,7 @@ class AuthCodeStorage extends AbstractStorage implements AuthCodeInterface { * @inheritdoc */ public function getScopes(OriginalAuthCodeEntity $token) { - $result = (new Set($this->dataTable, $token->getId(), 'scopes')); + $result = new Set($this->dataTable, $token->getId(), 'scopes'); $response = []; foreach ($result as $scope) { // TODO: нужно проверить все выданные скоупы на их существование diff --git a/common/components/oauth/Util/KeyAlgorithm/UuidAlgorithm.php b/common/components/oauth/Util/KeyAlgorithm/UuidAlgorithm.php index 9fd5c72..e75580d 100644 --- a/common/components/oauth/Util/KeyAlgorithm/UuidAlgorithm.php +++ b/common/components/oauth/Util/KeyAlgorithm/UuidAlgorithm.php @@ -2,10 +2,9 @@ namespace common\components\oauth\Util\KeyAlgorithm; use League\OAuth2\Server\Util\KeyAlgorithm\DefaultAlgorithm; -use League\OAuth2\Server\Util\KeyAlgorithm\KeyAlgorithmInterface; use Ramsey\Uuid\Uuid; -class UuidAlgorithm extends DefaultAlgorithm implements KeyAlgorithmInterface { +class UuidAlgorithm extends DefaultAlgorithm { /** * @inheritdoc diff --git a/common/helpers/Amqp.php b/common/helpers/Amqp.php index 3b1f321..f0d7243 100644 --- a/common/helpers/Amqp.php +++ b/common/helpers/Amqp.php @@ -2,7 +2,6 @@ namespace common\helpers; use common\components\RabbitMQ\Helper; -use Yii; class Amqp extends Helper { diff --git a/common/mail/layouts/text.php b/common/mail/layouts/text.php index 7087cea..0b07007 100644 --- a/common/mail/layouts/text.php +++ b/common/mail/layouts/text.php @@ -1,9 +1,10 @@ beginPage() ?> beginBody() ?> diff --git a/common/models/OauthClient.php b/common/models/OauthClient.php index 8bec648..58b444b 100644 --- a/common/models/OauthClient.php +++ b/common/models/OauthClient.php @@ -1,7 +1,6 @@ getDb()->getSchema()->getRawTableName($this->tableName()), $this->id, 'scopes'); + return new Set(static::getDb()->getSchema()->getRawTableName(static::tableName()), $this->id, 'scopes'); } public function beforeDelete() { diff --git a/common/models/Textures.php b/common/models/Textures.php index 761e227..3bb3333 100644 --- a/common/models/Textures.php +++ b/common/models/Textures.php @@ -2,6 +2,8 @@ namespace common\models; use common\components\SkinSystem\Api as SkinSystemApi; +use DateInterval; +use DateTime; class Textures { @@ -38,7 +40,7 @@ class Textures { public function getTexturesValue($encrypted = true) { $array = [ - 'timestamp' => time() + 60 * 60 * 24 * 2, + 'timestamp' => (new DateTime())->add(new DateInterval('P2D'))->getTimestamp(), 'profileId' => str_replace('-', '', $this->account->uuid), 'profileName' => $this->account->username, 'textures' => $this->getTextures(), @@ -51,7 +53,7 @@ class Textures { if (!$encrypted) { return $array; } else { - return $this->encrypt($array); + return static::encrypt($array); } }