From 9c33e1b563f452987f06aa91ed3b630821d2262a Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 15:59:21 +0200 Subject: [PATCH 1/8] drop php7 support --- .github/workflows/php.yml | 2 +- composer.json | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 880f9ee3..f59998fe 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: operating-system: ['ubuntu-latest'] - php-versions: ['8.3', '8.2','8.1', '8.0','7.4'] + php-versions: ['8.3', '8.2','8.1', '8.0'] services: mariadb: diff --git a/composer.json b/composer.json index d28fd1cb..b2fe0849 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=5.5", + "php": ">=8.0", "yiisoft/yii2-authclient": "^2.1", "yiisoft/yii2-httpclient": "^2.0", "yetopen/yii2-sms-sender-interface": "^0.1.1" @@ -54,7 +54,6 @@ "2amigos/qrcode-library": "Needed if you want to enable 2FA with QR Code generation. Require version ^1.1" }, "require-dev": { - "php": ">=7.4", "kartik-v/yii2-widget-select2": "^2.2", "yiisoft/yii2-bootstrap5": "^2.0", "2amigos/2fa-library": "^2.0", @@ -83,7 +82,7 @@ }, "config": { "platform": { - "php": "7.4" + "php": "8.0" }, "preferred-install": { "*": "auto" From 5da799d3d444ded4a2b65eb7f3bb6c7438fccdf6 Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 16:00:08 +0200 Subject: [PATCH 2/8] code inspection: remove all unused imports --- src/User/Controller/RegistrationController.php | 1 - src/User/Controller/SecurityController.php | 2 -- src/User/Controller/SettingsController.php | 4 ---- src/User/Filter/AccessRuleFilter.php | 1 - src/User/Filter/TwoFactorAuthenticationEnforceFilter.php | 1 - src/User/Form/LoginForm.php | 4 ---- src/User/Form/RegistrationForm.php | 1 - src/User/Helper/AuthHelper.php | 1 - src/User/Service/MailService.php | 1 - src/User/resources/views/bootstrap3/admin/index.php | 1 - src/User/resources/views/bootstrap3/rule/index.php | 1 - src/User/resources/views/bootstrap3/security/confirm.php | 1 - src/User/resources/views/bootstrap5/admin/index.php | 1 - src/User/resources/views/bootstrap5/rule/index.php | 1 - src/User/resources/views/bootstrap5/security/confirm.php | 1 - src/User/resources/views/bootstrap5/settings/_menu.php | 1 - src/User/resources/views/mail/twofactorcode.php | 2 -- 17 files changed, 25 deletions(-) diff --git a/src/User/Controller/RegistrationController.php b/src/User/Controller/RegistrationController.php index 0463b319..8dbe925f 100644 --- a/src/User/Controller/RegistrationController.php +++ b/src/User/Controller/RegistrationController.php @@ -17,7 +17,6 @@ use Da\User\Factory\MailFactory; use Da\User\Form\RegistrationForm; use Da\User\Form\ResendForm; -use Da\User\Helper\SecurityHelper; use Da\User\Model\SocialNetworkAccount; use Da\User\Model\User; use Da\User\Query\SocialNetworkAccountQuery; diff --git a/src/User/Controller/SecurityController.php b/src/User/Controller/SecurityController.php index d3bae0e1..4148d335 100644 --- a/src/User/Controller/SecurityController.php +++ b/src/User/Controller/SecurityController.php @@ -21,8 +21,6 @@ use Da\User\Service\SocialNetworkAuthenticateService; use Da\User\Traits\ContainerAwareTrait; use Da\User\Traits\ModuleAwareTrait; -use Da\User\Validator\TwoFactorEmailValidator; -use Da\User\Validator\TwoFactorTextMessageValidator; use Yii; use yii\authclient\AuthAction; use yii\base\InvalidConfigException; diff --git a/src/User/Controller/SettingsController.php b/src/User/Controller/SettingsController.php index e3ee6b84..8e82b971 100644 --- a/src/User/Controller/SettingsController.php +++ b/src/User/Controller/SettingsController.php @@ -35,13 +35,9 @@ use Da\User\Traits\ContainerAwareTrait; use Da\User\Traits\ModuleAwareTrait; use Da\User\Validator\AjaxRequestModelValidator; -use Da\User\Validator\TwoFactorCodeValidator; -use Da\User\Validator\TwoFactorEmailValidator; -use Da\User\Validator\TwoFactorTextMessageValidator; use http\Exception\InvalidArgumentException; use Yii; use yii\base\DynamicModel; -use yii\base\InvalidParamException; use yii\filters\AccessControl; use yii\filters\VerbFilter; use yii\helpers\ArrayHelper; diff --git a/src/User/Filter/AccessRuleFilter.php b/src/User/Filter/AccessRuleFilter.php index cb658262..74914e13 100644 --- a/src/User/Filter/AccessRuleFilter.php +++ b/src/User/Filter/AccessRuleFilter.php @@ -11,7 +11,6 @@ namespace Da\User\Filter; -use Closure; use Da\User\Model\User; use Da\User\Traits\ModuleAwareTrait; use Yii; diff --git a/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php b/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php index 933972c3..e29a30fe 100644 --- a/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php +++ b/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php @@ -12,7 +12,6 @@ namespace Da\User\Filter; use Da\User\Model\User; -use Da\User\Module; use Da\User\Traits\AuthManagerAwareTrait; use Da\User\Traits\ModuleAwareTrait; use Yii; diff --git a/src/User/Form/LoginForm.php b/src/User/Form/LoginForm.php index 0b613ab1..510763a1 100644 --- a/src/User/Form/LoginForm.php +++ b/src/User/Form/LoginForm.php @@ -16,14 +16,10 @@ use Da\User\Query\UserQuery; use Da\User\Traits\ContainerAwareTrait; use Da\User\Traits\ModuleAwareTrait; -use Da\User\Validator\TwoFactorCodeValidator; -use Da\User\Validator\TwoFactorEmailValidator; -use Da\User\Validator\TwoFactorTextMessageValidator; use Yii; use yii\base\InvalidParamException; use yii\base\Model; use yii\helpers\ArrayHelper; -use yii\web\IdentityInterface; class LoginForm extends Model { diff --git a/src/User/Form/RegistrationForm.php b/src/User/Form/RegistrationForm.php index b727c4b4..84fd59d5 100644 --- a/src/User/Form/RegistrationForm.php +++ b/src/User/Form/RegistrationForm.php @@ -16,7 +16,6 @@ use Da\User\Traits\ModuleAwareTrait; use Yii; use yii\base\Model; -use yii\helpers\Html; class RegistrationForm extends Model { diff --git a/src/User/Helper/AuthHelper.php b/src/User/Helper/AuthHelper.php index e8b6e683..17e1a219 100644 --- a/src/User/Helper/AuthHelper.php +++ b/src/User/Helper/AuthHelper.php @@ -12,7 +12,6 @@ namespace Da\User\Helper; use Da\User\Model\AbstractAuthItem; -use Da\User\Module; use Da\User\Traits\AuthManagerAwareTrait; use Da\User\Traits\ModuleAwareTrait; use Yii; diff --git a/src/User/Service/MailService.php b/src/User/Service/MailService.php index 910a7519..a578f0e8 100644 --- a/src/User/Service/MailService.php +++ b/src/User/Service/MailService.php @@ -15,7 +15,6 @@ use Da\User\Traits\ModuleAwareTrait; use Yii; use yii\mail\BaseMailer; -use yii\mail\MailerInterface; class MailService implements ServiceInterface { diff --git a/src/User/resources/views/bootstrap3/admin/index.php b/src/User/resources/views/bootstrap3/admin/index.php index a991fda0..3f203936 100644 --- a/src/User/resources/views/bootstrap3/admin/index.php +++ b/src/User/resources/views/bootstrap3/admin/index.php @@ -11,7 +11,6 @@ use yii\grid\GridView; use yii\helpers\Html; -use yii\web\View; use yii\widgets\Pjax; /** diff --git a/src/User/resources/views/bootstrap3/rule/index.php b/src/User/resources/views/bootstrap3/rule/index.php index b2fd066a..7dcae035 100644 --- a/src/User/resources/views/bootstrap3/rule/index.php +++ b/src/User/resources/views/bootstrap3/rule/index.php @@ -3,7 +3,6 @@ use yii\grid\ActionColumn; use yii\grid\GridView; use yii\helpers\Url; -use yii\rbac\Rule; /** * @var \yii\data\ActiveDataProvider $dataProvider diff --git a/src/User/resources/views/bootstrap3/security/confirm.php b/src/User/resources/views/bootstrap3/security/confirm.php index ed064742..e4e5e23b 100644 --- a/src/User/resources/views/bootstrap3/security/confirm.php +++ b/src/User/resources/views/bootstrap3/security/confirm.php @@ -9,7 +9,6 @@ * the LICENSE file that was distributed with this source code. */ -use Da\User\Widget\ConnectWidget; use yii\helpers\Html; use yii\widgets\ActiveForm; diff --git a/src/User/resources/views/bootstrap5/admin/index.php b/src/User/resources/views/bootstrap5/admin/index.php index 44a362ed..5675a1b4 100644 --- a/src/User/resources/views/bootstrap5/admin/index.php +++ b/src/User/resources/views/bootstrap5/admin/index.php @@ -11,7 +11,6 @@ use yii\grid\GridView; use yii\helpers\Html; -use yii\web\View; use yii\widgets\Pjax; /** diff --git a/src/User/resources/views/bootstrap5/rule/index.php b/src/User/resources/views/bootstrap5/rule/index.php index b2fd066a..7dcae035 100644 --- a/src/User/resources/views/bootstrap5/rule/index.php +++ b/src/User/resources/views/bootstrap5/rule/index.php @@ -3,7 +3,6 @@ use yii\grid\ActionColumn; use yii\grid\GridView; use yii\helpers\Url; -use yii\rbac\Rule; /** * @var \yii\data\ActiveDataProvider $dataProvider diff --git a/src/User/resources/views/bootstrap5/security/confirm.php b/src/User/resources/views/bootstrap5/security/confirm.php index 73fb81b5..72b7d0f4 100644 --- a/src/User/resources/views/bootstrap5/security/confirm.php +++ b/src/User/resources/views/bootstrap5/security/confirm.php @@ -9,7 +9,6 @@ * the LICENSE file that was distributed with this source code. */ -use Da\User\Widget\ConnectWidget; use yii\helpers\Html; use yii\bootstrap5\ActiveForm; diff --git a/src/User/resources/views/bootstrap5/settings/_menu.php b/src/User/resources/views/bootstrap5/settings/_menu.php index a646cca6..074e8f70 100755 --- a/src/User/resources/views/bootstrap5/settings/_menu.php +++ b/src/User/resources/views/bootstrap5/settings/_menu.php @@ -10,7 +10,6 @@ */ use yii\helpers\Html; -use yii\widgets\Menu; use Da\User\Module as UserModule; use Da\User\Model\User; diff --git a/src/User/resources/views/mail/twofactorcode.php b/src/User/resources/views/mail/twofactorcode.php index 210f84c2..bc272254 100644 --- a/src/User/resources/views/mail/twofactorcode.php +++ b/src/User/resources/views/mail/twofactorcode.php @@ -9,8 +9,6 @@ * the LICENSE file that was distributed with this source code. */ -use yii\helpers\Html; - /** * @var String $code * @var \Da\User\Model\Token $token From f07475b9b6cb1cb4463af3503d135ecb172ec830 Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 16:13:19 +0200 Subject: [PATCH 3/8] fixed codeception tests config to match newer version --- codeception.dist.yml | 2 +- src/User/Factory/MailFactory.php | 3 +-- src/User/resources/views/bootstrap3/settings/profile.php | 2 +- tests/functional.suite.yml | 2 +- tests/unit.suite.yml | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/codeception.dist.yml b/codeception.dist.yml index b9a5a10a..650da5f2 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -1,7 +1,7 @@ actor: Tester paths: tests: tests - log: tests/_output + output: tests/_output data: tests/_data helpers: tests/_support bootstrap: _bootstrap.php diff --git a/src/User/Factory/MailFactory.php b/src/User/Factory/MailFactory.php index be0c99b8..c792aa25 100644 --- a/src/User/Factory/MailFactory.php +++ b/src/User/Factory/MailFactory.php @@ -47,12 +47,11 @@ public static function makeWelcomeMailerService(User $user, $showPassword = fals /** * @param string $email - * @param Token $token * * @throws InvalidConfigException * @return MailService */ - public static function makeRecoveryMailerService($email, Token $token = null) + public static function makeRecoveryMailerService($email, ?Token $token = null) { /** @var Module $module */ $module = Yii::$app->getModule('user'); diff --git a/src/User/resources/views/bootstrap3/settings/profile.php b/src/User/resources/views/bootstrap3/settings/profile.php index 0237aa02..f3ca1095 100644 --- a/src/User/resources/views/bootstrap3/settings/profile.php +++ b/src/User/resources/views/bootstrap3/settings/profile.php @@ -71,7 +71,7 @@ ->hint( Html::a( Yii::t('usuario', 'Change your avatar at Gravatar.com'), - 'http://gravatar.com', + 'https://gravatar.com', ['target' => '_blank'] ) ) ?> diff --git a/tests/functional.suite.yml b/tests/functional.suite.yml index 455237e0..86d7da7c 100644 --- a/tests/functional.suite.yml +++ b/tests/functional.suite.yml @@ -1,4 +1,4 @@ -class_name: FunctionalTester +actor: FunctionalTester modules: enabled: - Filesystem diff --git a/tests/unit.suite.yml b/tests/unit.suite.yml index 8f7db555..ada30270 100644 --- a/tests/unit.suite.yml +++ b/tests/unit.suite.yml @@ -1,4 +1,4 @@ -class_name: UnitTester +actor: UnitTester modules: enabled: - Asserts From 3ccedbd8dce08b043a04489ee1da92c68cf952c6 Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 16:22:57 +0200 Subject: [PATCH 4/8] update gh actions checkout version --- .github/workflows/php.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index f59998fe..0c53cf52 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -38,7 +38,7 @@ jobs: ini-values: post_max_size=256M, max_execution_time=180 coverage: xdebug - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Verify MariaDB connection diff --git a/composer.json b/composer.json index b2fe0849..38e9474b 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "yiisoft/yii2-symfonymailer": "^2|^3", "squizlabs/php_codesniffer": "*", "phpmd/phpmd": "@stable", - "codeception/codeception": "^4|^5", + "codeception/codeception": "^5", "roave/security-advisories": "dev-master", "codeception/module-filesystem": "^2|^3", "codeception/module-yii2": "^1.1", From f2ead680f638d0dd54cb0a2a24c973214e22f9e6 Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 16:32:12 +0200 Subject: [PATCH 5/8] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65e1d172..064efa5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Enh: Keycloak auth client (e.luhr) - Fix: Social Network Auth (eluhr) +- Enh: Added Bootstrap 5 UI, UI related dependencies are suggested not required (you may choose your UI frmawork) (TonisOrmisson) +- Enh: Raised phpstan static code analyzer level 1=>5 with fixes (TonisOrmisson) +- Enh: raised minimum PHP version 7.4=>8.0 ## 1.6.2 Jan 4th, 2024 From 255040b5f1805b8d36b8d91667e0a6c19ef1e22e Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 16:34:25 +0200 Subject: [PATCH 6/8] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 064efa5f..c070b71f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Fix: Social Network Auth (eluhr) - Enh: Added Bootstrap 5 UI, UI related dependencies are suggested not required (you may choose your UI frmawork) (TonisOrmisson) - Enh: Raised phpstan static code analyzer level 1=>5 with fixes (TonisOrmisson) -- Enh: raised minimum PHP version 7.4=>8.0 +- Enh: Raised minimum PHP version 7.4=>8.0 (TonisOrmisson) ## 1.6.2 Jan 4th, 2024 From 551cc5fdba64853bbafb8a75a4ec8cf38538be84 Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 16:56:58 +0200 Subject: [PATCH 7/8] inspection: remove returns on parent:void methods --- .../SessionHistoryDecorator.php | 52 +++++++++---------- .../Validator/TwoFactorEmailValidator.php | 4 +- .../TwoFactorTextMessageValidator.php | 5 +- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/User/Service/SessionHistory/SessionHistoryDecorator.php b/src/User/Service/SessionHistory/SessionHistoryDecorator.php index ebe416b6..177bae99 100755 --- a/src/User/Service/SessionHistory/SessionHistoryDecorator.php +++ b/src/User/Service/SessionHistory/SessionHistoryDecorator.php @@ -73,9 +73,9 @@ public function getHasSessionId() } /** @inheritdoc */ - public function setHasSessionId($value) + public function setHasSessionId($value) : void { - return $this->session->setHasSessionId($value); + $this->session->setHasSessionId($value); } /** @inheritdoc */ @@ -85,9 +85,9 @@ public function getId() } /** @inheritdoc */ - public function setId($value) + public function setId($value) : void { - return $this->session->setId($value); + $this->session->setId($value); } /** @inheritdoc */ @@ -125,9 +125,9 @@ public function getName() } /** @inheritdoc */ - public function setName($value) + public function setName($value) : void { - return $this->session->setName($value); + $this->session->setName($value); } /** @inheritdoc */ @@ -137,9 +137,9 @@ public function getSavePath() } /** @inheritdoc */ - public function setSavePath($value) + public function setSavePath($value) : void { - return $this->session->setSavePath($value); + $this->session->setSavePath($value); } /** @inheritdoc */ @@ -149,9 +149,9 @@ public function getCookieParams() } /** @inheritdoc */ - public function setCookieParams(array $value) + public function setCookieParams(array $value) : void { - return $this->session->setCookieParams($value); + $this->session->setCookieParams($value); } /** @inheritdoc */ @@ -161,9 +161,9 @@ public function getUseCookies() } /** @inheritdoc */ - public function setUseCookies($value) + public function setUseCookies($value) : void { - return $this->session->setUseCookies($value); + $this->session->setUseCookies($value); } /** @inheritdoc */ @@ -173,9 +173,9 @@ public function getGCProbability() } /** @inheritdoc */ - public function setGCProbability($value) + public function setGCProbability($value) : void { - return $this->session->setGCProbability($value); + $this->session->setGCProbability($value); } /** @inheritdoc */ @@ -185,9 +185,9 @@ public function getUseTransparentSessionID() } /** @inheritdoc */ - public function setUseTransparentSessionID($value) + public function setUseTransparentSessionID($value) : void { - return $this->session->setUseTransparentSessionID($value); + $this->session->setUseTransparentSessionID($value); } /** @inheritdoc */ @@ -197,9 +197,9 @@ public function getTimeout() } /** @inheritdoc */ - public function setTimeout($value) + public function setTimeout($value) : void { - return $this->session->setTimeout($value); + $this->session->setTimeout($value); } /** @inheritdoc */ @@ -313,9 +313,9 @@ public function remove($key) } /** @inheritdoc */ - public function removeAll() + public function removeAll() : void { - return $this->session->removeAll(); + $this->session->removeAll(); } /** @inheritdoc */ @@ -337,15 +337,15 @@ public function getAllFlashes($delete = false) } /** @inheritdoc */ - public function setFlash($key, $value = true, $removeAfterAccess = true) + public function setFlash($key, $value = true, $removeAfterAccess = true) : void { - return $this->session->setFlash($key, $value, $removeAfterAccess); + $this->session->setFlash($key, $value, $removeAfterAccess); } /** @inheritdoc */ - public function addFlash($key, $value = true, $removeAfterAccess = true) + public function addFlash($key, $value = true, $removeAfterAccess = true) : void { - return $this->session->addFlash($key, $value, $removeAfterAccess); + $this->session->addFlash($key, $value, $removeAfterAccess); } /** @inheritdoc */ @@ -355,9 +355,9 @@ public function removeFlash($key) } /** @inheritdoc */ - public function removeAllFlashes() + public function removeAllFlashes() : void { - return $this->session->removeAllFlashes(); + $this->session->removeAllFlashes(); } /** @inheritdoc */ diff --git a/src/User/Validator/TwoFactorEmailValidator.php b/src/User/Validator/TwoFactorEmailValidator.php index a45c723d..41559e72 100644 --- a/src/User/Validator/TwoFactorEmailValidator.php +++ b/src/User/Validator/TwoFactorEmailValidator.php @@ -38,9 +38,7 @@ class TwoFactorEmailValidator extends TwoFactorCodeValidator */ public function __construct(User $user, $code, $cycles = 0) { - $this->user = $user; - $this->code = $code; - $this->cycles = $cycles; + parent::__construct($user, $code, $cycles); $this->type = 'email'; } diff --git a/src/User/Validator/TwoFactorTextMessageValidator.php b/src/User/Validator/TwoFactorTextMessageValidator.php index 1770229c..f199e592 100644 --- a/src/User/Validator/TwoFactorTextMessageValidator.php +++ b/src/User/Validator/TwoFactorTextMessageValidator.php @@ -38,10 +38,7 @@ class TwoFactorTextMessageValidator extends TwoFactorCodeValidator */ public function __construct(User $user, $code, $cycles = 0) { - $this->user = $user; - - $this->code = $code; - $this->cycles = $cycles; + parent::__construct($user, $code, $cycles); $this->type = 'sms'; } From 184bff9ea2363bffe25a6a011406b63d3d59c6e6 Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 27 Feb 2024 16:59:32 +0200 Subject: [PATCH 8/8] updated gh actions modules versions to stop warnings --- .github/workflows/php.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 0c53cf52..ed07f188 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -52,7 +52,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} @@ -76,7 +76,7 @@ jobs: run: vendor/bin/phpstan analyse - name: Archive failed tests artifacts - test output & log - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: test-outputs-php-${{ matrix.php-versions }}