From be34542b9c3ef9cc7554787cb77badc9b92301ea Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 28 Oct 2023 11:36:43 -0300 Subject: [PATCH 1/9] Fix config parameters. --- config/params.php | 38 +++++++++++++++++++------------------ config/tests/params-web.php | 4 +++- config/tests/web/app.php | 2 +- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/config/params.php b/config/params.php index cecb459..8eda117 100644 --- a/config/params.php +++ b/config/params.php @@ -26,25 +26,27 @@ 'app.events' => [ __DIR__ . '/events/AccountModel.php', ], - 'app.menu.isguest' => [ - [ - 'label' => \Yii::t('yii.user', 'Register'), - 'url' => ['/register/index'], - 'order' => 1, - ], - [ - 'label' => \Yii::t('yii.user', 'Login'), - 'url' => ['/login/index'], - 'order' => 2, + 'app.params' => [ + 'app.menu.isguest' => [ + [ + 'label' => \Yii::t('yii.user', 'Register'), + 'url' => ['/register/index'], + 'order' => 1, + ], + [ + 'label' => \Yii::t('yii.user', 'Login'), + 'url' => ['/login/index'], + 'order' => 2, + ], ], - ], - 'app.menu.islogged' => [ - [ - 'label' => \Yii::t('yii.user', 'Logout'), - 'url' => ['/logout/index'], - 'order' => 1, - 'linkOptions' => [ - 'data-method' => 'post', + 'app.menu.islogged' => [ + [ + 'label' => \Yii::t('yii.user', 'Logout'), + 'url' => ['/logout/index'], + 'order' => 1, + 'linkOptions' => [ + 'data-method' => 'post', + ], ], ], ], diff --git a/config/tests/params-web.php b/config/tests/params-web.php index 71b296a..f36dbc2 100644 --- a/config/tests/params-web.php +++ b/config/tests/params-web.php @@ -10,5 +10,7 @@ 'class' => SiteController::class, ], ], - 'icons' => '@npm/fortawesome--fontawesome-free/svgs/{family}/{name}.svg', + 'app.params' => [ + 'icons' => '@npm/fortawesome--fontawesome-free/svgs/{family}/{name}.svg', + ], ]; diff --git a/config/tests/web/app.php b/config/tests/web/app.php index 96a6474..13d29ab 100644 --- a/config/tests/web/app.php +++ b/config/tests/web/app.php @@ -39,6 +39,6 @@ 'on beforeAction' => static function (): void { $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; }, - 'params' => $params, + 'params' => $params['app.params'] ?? [], 'runtimePath' => dirname(__DIR__, 3) . '/tests/Support/Data/public/runtime', ]; From 29234926b1e6ee8bcf4bbf820f9402f535fb1488 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 28 Oct 2023 11:38:43 -0300 Subject: [PATCH 2/9] Fix order. --- config/params.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/params.php b/config/params.php index 8eda117..715c6f5 100644 --- a/config/params.php +++ b/config/params.php @@ -31,12 +31,12 @@ [ 'label' => \Yii::t('yii.user', 'Register'), 'url' => ['/register/index'], - 'order' => 1, + 'order' => 3, ], [ 'label' => \Yii::t('yii.user', 'Login'), 'url' => ['/login/index'], - 'order' => 2, + 'order' => 4, ], ], 'app.menu.islogged' => [ From bf0dbef56008a8d4426b3679a4dcf1f7dfba1665 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 28 Oct 2023 13:20:49 -0300 Subject: [PATCH 3/9] Add aliases to console config. --- config/params.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/params.php b/config/params.php index 715c6f5..3ae9b06 100644 --- a/config/params.php +++ b/config/params.php @@ -50,4 +50,7 @@ ], ], ], + 'console.aliases' => [ + '@yii-user/migration' => '@yii-user/src/Framework/Migration', + ], ]; From 11bb8b5caaae16160ca88934e38daf70d9fd5b2f Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 28 Oct 2023 13:23:04 -0300 Subject: [PATCH 4/9] Fix console params again. --- config/params.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/params.php b/config/params.php index 3ae9b06..eb48b47 100644 --- a/config/params.php +++ b/config/params.php @@ -51,6 +51,7 @@ ], ], 'console.aliases' => [ + '@yii-user' => '@vendor/yii2-extensions/user', '@yii-user/migration' => '@yii-user/src/Framework/Migration', ], ]; From 12ffcffb3654cc6e8aced398fc30b2a4e7c897e0 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Thu, 2 Nov 2023 08:40:45 -0300 Subject: [PATCH 5/9] Clean code. --- config/params-console.php | 10 +++++ config/params.php | 12 ++--- .../Migration/M211126112534Identity.php | 4 +- .../Migration/M211126112600Account.php | 4 +- .../Migration/M211126112801Token.php | 4 +- .../Migration/M211126112850SocialAccount.php | 4 +- .../Migration/M211126113053Profile.php | 4 +- .../{BaseMigration.php => Migration.php} | 3 +- .../Repository/AbstractRepository.php | 4 +- src/Model/Identity.php | 11 ++++- src/UseCase/Controller.php | 6 ++- src/UseCase/Login/view/index.php | 4 +- src/UseCase/Register/RegisterForm.php | 44 +++++++------------ src/UseCase/Register/RegisterService.php | 2 + src/UseCase/Register/view/index.php | 10 ++--- 15 files changed, 68 insertions(+), 58 deletions(-) create mode 100644 config/params-console.php rename src/Framework/Migration/{BaseMigration.php => Migration.php} (91%) diff --git a/config/params-console.php b/config/params-console.php new file mode 100644 index 0000000..abe242d --- /dev/null +++ b/config/params-console.php @@ -0,0 +1,10 @@ + [ + '@yii-user' => '@vendor/yii2-extensions/user', + '@yii-user/migration' => '@yii-user/src/Framework/Migration', + ], +]; diff --git a/config/params.php b/config/params.php index eb48b47..59ac889 100644 --- a/config/params.php +++ b/config/params.php @@ -23,27 +23,27 @@ 'class' => RegisterController::class, ], ], - 'app.events' => [ - __DIR__ . '/events/AccountModel.php', - ], 'app.params' => [ 'app.menu.isguest' => [ [ - 'label' => \Yii::t('yii.user', 'Register'), + 'label' => 'Register', 'url' => ['/register/index'], 'order' => 3, + 'category' =>'yii.user', ], [ - 'label' => \Yii::t('yii.user', 'Login'), + 'label' => 'Login', 'url' => ['/login/index'], 'order' => 4, + 'category' =>'yii.user', ], ], 'app.menu.islogged' => [ [ - 'label' => \Yii::t('yii.user', 'Logout'), + 'label' => 'Logout', 'url' => ['/logout/index'], 'order' => 1, + 'category' =>'yii.user', 'linkOptions' => [ 'data-method' => 'post', ], diff --git a/src/Framework/Migration/M211126112534Identity.php b/src/Framework/Migration/M211126112534Identity.php index 8720f3a..f135446 100644 --- a/src/Framework/Migration/M211126112534Identity.php +++ b/src/Framework/Migration/M211126112534Identity.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use Yii\User\Framework\Migration\BaseMigration; +namespace Yii\User\Framework\Migration; -final class M211126112534Identity extends BaseMigration +final class M211126112534Identity extends Migration { public function up(): bool { diff --git a/src/Framework/Migration/M211126112600Account.php b/src/Framework/Migration/M211126112600Account.php index bb09645..ddab58c 100644 --- a/src/Framework/Migration/M211126112600Account.php +++ b/src/Framework/Migration/M211126112600Account.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use Yii\User\Framework\Migration\BaseMigration; +namespace Yii\User\Framework\Migration; -final class M211126112600Account extends BaseMigration +final class M211126112600Account extends Migration { public function up(): bool { diff --git a/src/Framework/Migration/M211126112801Token.php b/src/Framework/Migration/M211126112801Token.php index 43bc7fe..6f651ba 100644 --- a/src/Framework/Migration/M211126112801Token.php +++ b/src/Framework/Migration/M211126112801Token.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use Yii\User\Framework\Migration\BaseMigration; +namespace Yii\User\Framework\Migration; -final class M211126112801Token extends BaseMigration +final class M211126112801Token extends Migration { public function up(): bool { diff --git a/src/Framework/Migration/M211126112850SocialAccount.php b/src/Framework/Migration/M211126112850SocialAccount.php index 2a8ed4d..6afae3c 100644 --- a/src/Framework/Migration/M211126112850SocialAccount.php +++ b/src/Framework/Migration/M211126112850SocialAccount.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use Yii\User\Framework\Migration\BaseMigration; +namespace Yii\User\Framework\Migration; -final class M211126112850SocialAccount extends BaseMigration +final class M211126112850SocialAccount extends Migration { public function up(): bool { diff --git a/src/Framework/Migration/M211126113053Profile.php b/src/Framework/Migration/M211126113053Profile.php index 90993da..ad9f52e 100644 --- a/src/Framework/Migration/M211126113053Profile.php +++ b/src/Framework/Migration/M211126113053Profile.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use Yii\User\Framework\Migration\BaseMigration; +namespace Yii\User\Framework\Migration; -final class M211126113053Profile extends BaseMigration +final class M211126113053Profile extends Migration { public function up(): bool { diff --git a/src/Framework/Migration/BaseMigration.php b/src/Framework/Migration/Migration.php similarity index 91% rename from src/Framework/Migration/BaseMigration.php rename to src/Framework/Migration/Migration.php index 094c02e..5af9491 100644 --- a/src/Framework/Migration/BaseMigration.php +++ b/src/Framework/Migration/Migration.php @@ -5,9 +5,8 @@ namespace Yii\User\Framework\Migration; use RuntimeException; -use yii\db\Migration; -class BaseMigration extends Migration +class Migration extends \yii\db\Migration { protected string $tableOptions = ''; protected string $restrict = 'RESTRICT'; diff --git a/src/Framework/Repository/AbstractRepository.php b/src/Framework/Repository/AbstractRepository.php index 1b88470..1137eb1 100644 --- a/src/Framework/Repository/AbstractRepository.php +++ b/src/Framework/Repository/AbstractRepository.php @@ -21,11 +21,11 @@ protected function execute(Connection $db, Closure $operation): bool try { /** @var bool $result */ $result = $operation(); - $transaction->commit(); + $transaction?->commit(); return $result; } catch (Exception $e) { - $transaction->rollBack(); + $transaction?->rollBack(); Yii::error($e->getMessage(), __METHOD__); } diff --git a/src/Model/Identity.php b/src/Model/Identity.php index 56a3652..61fd2bc 100644 --- a/src/Model/Identity.php +++ b/src/Model/Identity.php @@ -4,6 +4,7 @@ namespace Yii\User\Model; +use Exception; use yii\base\NotSupportedException; use yii\db\ActiveQueryInterface; use yii\db\ActiveRecord; @@ -27,18 +28,24 @@ public function getAccount(): ActiveQueryInterface } /** - * @param int|string $id the user ID to be looked for (primary key) in the database. + * @param int|string $id the user ID to be looked for (a primary key) in the database. */ public static function findIdentity($id): IdentityInterface|null { return self::findOne($id); } - public static function findIdentityByAccessToken(mixed $token, mixed $type = null) + /** + * @throws NotSupportedException + */ + public static function findIdentityByAccessToken(mixed $token, mixed $type = null): void { throw new NotSupportedException('Method "' . __CLASS__ . '::findIdentityByAccessToken" is not implemented.'); } + /** + * @throws Exception + */ public function generateAuthKey(): void { $this->setAttribute('auth_key', Random::string()); diff --git a/src/UseCase/Controller.php b/src/UseCase/Controller.php index 6ca63f6..8c82cc9 100644 --- a/src/UseCase/Controller.php +++ b/src/UseCase/Controller.php @@ -5,6 +5,7 @@ namespace Yii\User\UseCase; use Yii; +use yii\base\ExitException; use yii\base\Model; use yii\bootstrap5\ActiveForm; use yii\web\Request; @@ -12,7 +13,10 @@ class Controller extends \yii\web\Controller { - protected function performAjaxValidation(Model $model) + /** + * @throws ExitException + */ + protected function performAjaxValidation(Model $model): void { if ( $this->request instanceof Request && diff --git a/src/UseCase/Login/view/index.php b/src/UseCase/Login/view/index.php index 4c8bbce..a6affcc 100644 --- a/src/UseCase/Login/view/index.php +++ b/src/UseCase/Login/view/index.php @@ -44,7 +44,7 @@ 'autofocus' => true, 'oninput' => 'this.setCustomValidity("")', 'oninvalid' => 'this.setCustomValidity("' . Yii::t('yii.user', 'Enter Login Here') . '")', - 'required' => (YII_ENV === 'tests') ? false : true, + 'required' => !((YII_ENV === 'tests')), 'tabindex' => '1', ] ) ?> @@ -53,7 +53,7 @@ [ 'oninput' => 'this.setCustomValidity("")', 'oninvalid' => 'this.setCustomValidity("' . Yii::t('yii.user', 'Enter Password Here') . '")', - 'required' => (YII_ENV === 'tests') ? false : true, + 'required' => !((YII_ENV === 'tests')), 'tabindex' => '2', ], ) ?> diff --git a/src/UseCase/Register/RegisterForm.php b/src/UseCase/Register/RegisterForm.php index f1369be..8a138c6 100644 --- a/src/UseCase/Register/RegisterForm.php +++ b/src/UseCase/Register/RegisterForm.php @@ -40,55 +40,43 @@ public function rules(): array { return [ // acceptTerms rules - 'acceptTermsRequired' => [ + [ 'accept_terms', 'compare', 'compareValue' => true, 'message' => Yii::t('yii.user', 'You must accept the terms and conditions.'), ], // create_at only first register - 'createdAtDefault' => ['created_at', 'default', 'value' => time()], + ['created_at', 'default', 'value' => time()], // confirmed_at only if $this->userModule->confirmation === false - 'confirmedAtDefault' => [ - 'confirmed_at', - 'default', - 'value' => $this->userModule->confirmation ? 0 : time(), - ], + ['confirmed_at', 'default', 'value' => $this->userModule->confirmation ? 0 : time()], // username rules - 'usernameTrim' => ['username', 'trim'], - 'usernameLength' => ['username', 'string', 'min' => 3, 'max' => 255], - 'usernamePattern' => ['username', 'match', 'pattern' => $this->userModule->usernameRegex], - 'usernameRequired' => ['username', 'required'], - 'usernameUnique' => [ + ['username', 'trim'], + ['username', 'string', 'min' => 3, 'max' => 255], + ['username', 'match', 'pattern' => $this->userModule->usernameRegex], + ['username', 'required'], + [ 'username', 'unique', 'targetClass' => Account::class, 'message' => Yii::t('yii.user', 'This username has already been taken.'), ], // email rules - 'emailTrim' => ['email', 'trim'], - 'emailRequired' => ['email', 'required'], - 'emailPattern' => ['email', 'email'], - 'emailUnique' => [ + ['email', 'trim'], + ['email', 'required'], + ['email', 'email'], + [ 'email', 'unique', 'targetClass' => Account::class, 'message' => Yii::t('yii.user', 'This email address has already been taken.'), ], // password rules - 'passwordRequired' => [ - 'password', - 'required', - 'skipOnEmpty' => $this->userModule->generatePassword, - ], - 'passwordLength' => ['password', 'string', 'min' => 6, 'max' => 72], + ['password', 'required', 'skipOnEmpty' => $this->userModule->generatePassword], + ['password', 'string', 'min' => 6, 'max' => 72], // password repeat rules - 'passwordRepeatRequired' => [ - 'passwordRepeat', - 'required', - 'skipOnEmpty' => $this->userModule->generatePassword, - ], - 'passwordRepeatCompare' => [ + ['passwordRepeat', 'required', 'skipOnEmpty' => $this->userModule->generatePassword], + [ 'passwordRepeat', 'compare', 'compareAttribute' => 'password', diff --git a/src/UseCase/Register/RegisterService.php b/src/UseCase/Register/RegisterService.php index d120931..29677d6 100644 --- a/src/UseCase/Register/RegisterService.php +++ b/src/UseCase/Register/RegisterService.php @@ -24,7 +24,9 @@ public function __construct( private readonly Profile $profile, private readonly SocialAccount $socialAccount, private readonly UserModule $userModule, + array $config = [], ) { + parent::__construct($config); } public function run(RegisterForm $registerForm): bool diff --git a/src/UseCase/Register/view/index.php b/src/UseCase/Register/view/index.php index c62d466..9e0389d 100644 --- a/src/UseCase/Register/view/index.php +++ b/src/UseCase/Register/view/index.php @@ -48,7 +48,7 @@ 'oninput' => 'this.setCustomValidity("")', 'oninvalid' => 'this.setCustomValidity("' . Yii::t('yii.user', 'Enter Email Here.') . '")', 'placeholder' => Yii::t('yii.user', 'Email'), - 'required' => (YII_ENV === 'tests') ? false : true, + 'required' => !((YII_ENV === 'tests')), 'tabindex' => '1', ], ) @@ -59,7 +59,7 @@ 'oninput' => 'this.setCustomValidity("")', 'oninvalid' => 'this.setCustomValidity("' . Yii::t('yii.user', 'Enter Username Here.') . '")', 'placeholder' => Yii::t('yii.user', 'Username'), - 'required' => (YII_ENV === 'tests') ? false : true, + 'required' => !((YII_ENV === 'tests')), 'tabindex' => '2', ], ) @@ -71,7 +71,7 @@ 'oninput' => 'this.setCustomValidity("")', 'oninvalid' => 'this.setCustomValidity("' . Yii::t('yii.user', 'Enter Password Here.') . '")', 'placeholder' => Yii::t('yii.user', 'Password'), - 'required' => (YII_ENV === 'tests') ? false : true, + 'required' => !((YII_ENV === 'tests')), 'tabindex' => '3', ] ) @@ -82,7 +82,7 @@ 'oninput' => 'this.setCustomValidity("")', 'oninvalid' => 'this.setCustomValidity("' . Yii::t('yii.user', 'Enter Password Here.') . '")', 'placeholder' => Yii::t('yii.user', 'Password'), - 'required' => (YII_ENV === 'tests') ? false : true, + 'required' => !((YII_ENV === 'tests')), 'tabindex' => '4', ] ) @@ -93,7 +93,7 @@ [ 'class' => 'form-check-input', 'oninvalid' => 'this.setCustomValidity("' . Yii::t('yii.user', 'You must accept the terms and conditions.') . '")', - 'required' => (YII_ENV === 'tests') ? false : true, + 'required' => !((YII_ENV === 'tests')), 'tabindex' => '5', 'template' => "
\n{input}\n{label}\n{error}\n{hint}\n
", ], From b9cd2a6e084db08c4e53bcc8fc91c8f1a6094cad Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 2 Nov 2023 11:41:08 +0000 Subject: [PATCH 6/9] Apply fixes from StyleCI --- config/params.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/params.php b/config/params.php index 59ac889..1728253 100644 --- a/config/params.php +++ b/config/params.php @@ -29,13 +29,13 @@ 'label' => 'Register', 'url' => ['/register/index'], 'order' => 3, - 'category' =>'yii.user', + 'category' => 'yii.user', ], [ 'label' => 'Login', 'url' => ['/login/index'], 'order' => 4, - 'category' =>'yii.user', + 'category' => 'yii.user', ], ], 'app.menu.islogged' => [ @@ -43,7 +43,7 @@ 'label' => 'Logout', 'url' => ['/logout/index'], 'order' => 1, - 'category' =>'yii.user', + 'category' => 'yii.user', 'linkOptions' => [ 'data-method' => 'post', ], From 0a38b1402f894e171819d088d7bf72c0fd7810df Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Thu, 2 Nov 2023 08:45:10 -0300 Subject: [PATCH 7/9] Update tests. --- composer.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c2687f6..841b7ac 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,8 @@ }, "config-plugin": { "web": "web/*.php", - "params": "params.php" + "params": "params.php", + "params-console": "params-console.php" }, "config-plugin-options": { "source-directory": "config" @@ -69,6 +70,10 @@ "tests/web/*.php" ], "params": "params.php", + "params-console": [ + "$params", + "tests/params-console.php" + ], "params-web": [ "$params", "tests/params-web.php" From 087d5aefc09143bf062751e7ec1c67f7ffb260b6 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Thu, 2 Nov 2023 08:48:30 -0300 Subject: [PATCH 8/9] Fix tests again. --- src/Framework/Migration/M211126112534Identity.php | 2 +- src/Framework/Migration/M211126112600Account.php | 2 +- src/Framework/Migration/M211126112801Token.php | 2 +- src/Framework/Migration/M211126112850SocialAccount.php | 2 +- src/Framework/Migration/M211126113053Profile.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Framework/Migration/M211126112534Identity.php b/src/Framework/Migration/M211126112534Identity.php index f135446..820617b 100644 --- a/src/Framework/Migration/M211126112534Identity.php +++ b/src/Framework/Migration/M211126112534Identity.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Yii\User\Framework\Migration; +use Yii\User\Framework\Migration\Migration; final class M211126112534Identity extends Migration { diff --git a/src/Framework/Migration/M211126112600Account.php b/src/Framework/Migration/M211126112600Account.php index ddab58c..37a9204 100644 --- a/src/Framework/Migration/M211126112600Account.php +++ b/src/Framework/Migration/M211126112600Account.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Yii\User\Framework\Migration; +use Yii\User\Framework\Migration\Migration; final class M211126112600Account extends Migration { diff --git a/src/Framework/Migration/M211126112801Token.php b/src/Framework/Migration/M211126112801Token.php index 6f651ba..f574cc8 100644 --- a/src/Framework/Migration/M211126112801Token.php +++ b/src/Framework/Migration/M211126112801Token.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Yii\User\Framework\Migration; +use Yii\User\Framework\Migration\Migration; final class M211126112801Token extends Migration { diff --git a/src/Framework/Migration/M211126112850SocialAccount.php b/src/Framework/Migration/M211126112850SocialAccount.php index 6afae3c..743b71e 100644 --- a/src/Framework/Migration/M211126112850SocialAccount.php +++ b/src/Framework/Migration/M211126112850SocialAccount.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Yii\User\Framework\Migration; +use Yii\User\Framework\Migration\Migration; final class M211126112850SocialAccount extends Migration { diff --git a/src/Framework/Migration/M211126113053Profile.php b/src/Framework/Migration/M211126113053Profile.php index ad9f52e..96ac2c7 100644 --- a/src/Framework/Migration/M211126113053Profile.php +++ b/src/Framework/Migration/M211126113053Profile.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Yii\User\Framework\Migration; +use Yii\User\Framework\Migration\Migration; final class M211126113053Profile extends Migration { From 6478b9899bef680a61ec45305ab2883d2ec638c3 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Thu, 2 Nov 2023 08:50:57 -0300 Subject: [PATCH 9/9] Fix tests again. --- src/Framework/Repository/AbstractRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Framework/Repository/AbstractRepository.php b/src/Framework/Repository/AbstractRepository.php index 1137eb1..1b88470 100644 --- a/src/Framework/Repository/AbstractRepository.php +++ b/src/Framework/Repository/AbstractRepository.php @@ -21,11 +21,11 @@ protected function execute(Connection $db, Closure $operation): bool try { /** @var bool $result */ $result = $operation(); - $transaction?->commit(); + $transaction->commit(); return $result; } catch (Exception $e) { - $transaction?->rollBack(); + $transaction->rollBack(); Yii::error($e->getMessage(), __METHOD__); }