diff --git a/phpstan.neon b/phpstan.neon index 25855aed..faa85406 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 4 + level: 5 paths: - src excludePaths: diff --git a/src/User/Bootstrap.php b/src/User/Bootstrap.php index c3997035..2bd40719 100755 --- a/src/User/Bootstrap.php +++ b/src/User/Bootstrap.php @@ -61,7 +61,9 @@ public function bootstrap($app) $this->initAuthCollection($app); $this->initAuthManager($app); } else { - /* @var $app ConsoleApplication */ + if(!($app instanceof ConsoleApplication)) { + throw new InvalidConfigException(); + } $this->initConsoleCommands($app); $this->initAuthManager($app); } @@ -310,11 +312,11 @@ protected function initMailServiceConfiguration(Application $app, Module $module { $defaults = [ 'fromEmail' => 'no-reply@example.com', - 'welcomeMailSubject' => Yii::t('usuario', 'Welcome to {0}', $app->name), - 'confirmationMailSubject' => Yii::t('usuario', 'Confirm account on {0}', $app->name), - 'reconfirmationMailSubject' => Yii::t('usuario', 'Confirm email change on {0}', $app->name), - 'recoveryMailSubject' => Yii::t('usuario', 'Complete password reset on {0}', $app->name), - 'twoFactorMailSubject' => Yii::t('usuario', 'Code for two factor authentication on {0}', $app->name), + 'welcomeMailSubject' => Yii::t('usuario', 'Welcome to {0}', [$app->name]), + 'confirmationMailSubject' => Yii::t('usuario', 'Confirm account on {0}', [$app->name]), + 'reconfirmationMailSubject' => Yii::t('usuario', 'Confirm email change on {0}', [$app->name]), + 'recoveryMailSubject' => Yii::t('usuario', 'Complete password reset on {0}', [$app->name]), + 'twoFactorMailSubject' => Yii::t('usuario', 'Code for two factor authentication on {0}', [$app->name]), ]; $module->mailParams = array_merge($defaults, $module->mailParams); diff --git a/src/User/Controller/api/v1/AdminController.php b/src/User/Controller/api/v1/AdminController.php index e05a192f..351f7171 100644 --- a/src/User/Controller/api/v1/AdminController.php +++ b/src/User/Controller/api/v1/AdminController.php @@ -24,6 +24,7 @@ use Da\User\Service\UserCreateService; use Da\User\Traits\ContainerAwareTrait; use Yii; +use yii\base\Action; use yii\base\Module; use yii\db\ActiveRecord; use yii\filters\Cors; @@ -129,6 +130,7 @@ public function behaviors() /** * {@inheritdoc} + * @param string|Action $action */ public function checkAccess($action, $model = null, $params = []) { diff --git a/src/User/Search/UserSearch.php b/src/User/Search/UserSearch.php index b9367660..3155c53d 100644 --- a/src/User/Search/UserSearch.php +++ b/src/User/Search/UserSearch.php @@ -113,12 +113,12 @@ public function search($params) $userClass = $this->getClassMap()->get(User::class); if ($this->created_at !== null) { - $date = strtotime($this->created_at); + $date = strtotime((string)$this->created_at); $query->andFilterWhere(['between', $userClass::tableName().'.created_at', $date, $date + 3600 * 24]); } if ($this->last_login_at !== null) { - $date = strtotime($this->last_login_at); + $date = strtotime((string)$this->last_login_at); $query->andFilterWhere(['between', $userClass::tableName().'.last_login_at', $date, $date + 3600 * 24]); } diff --git a/src/User/Service/AuthRuleEditionService.php b/src/User/Service/AuthRuleEditionService.php index a73b09fc..3097c330 100644 --- a/src/User/Service/AuthRuleEditionService.php +++ b/src/User/Service/AuthRuleEditionService.php @@ -36,7 +36,7 @@ public function run() return false; } - /** @var Rule $rule */ + /** @var \yii\rbac\Rule $rule */ $rule = $this->make($this->model->className, [], ['name' => $this->model->name]); try { diff --git a/src/User/Service/SessionHistory/SessionHistoryDecorator.php b/src/User/Service/SessionHistory/SessionHistoryDecorator.php index 038bce3c..ebe416b6 100755 --- a/src/User/Service/SessionHistory/SessionHistoryDecorator.php +++ b/src/User/Service/SessionHistory/SessionHistoryDecorator.php @@ -245,7 +245,7 @@ public function writeSession($id, $data) ] + $this->condition->currentUserData() + $updatedAt); if (!$result = $model->save()) { throw new BaseInvalidArgumentException( - print_r($model->errors, 1) + print_r($model->errors, true) ); } diff --git a/src/User/Service/TwoFactorEmailCodeGeneratorService.php b/src/User/Service/TwoFactorEmailCodeGeneratorService.php index e311c014..917c69ce 100644 --- a/src/User/Service/TwoFactorEmailCodeGeneratorService.php +++ b/src/User/Service/TwoFactorEmailCodeGeneratorService.php @@ -46,7 +46,7 @@ public function run() : string } // generate key $code = random_int(0, 999999); - $code = str_pad($code, 6, 0, STR_PAD_LEFT); + $code = str_pad((string) $code, 6, "0", STR_PAD_LEFT); // send email $mailService = MailFactory::makeTwoFactorCodeMailerService($user, $code); // check the sending emailYii::t( diff --git a/src/User/Service/TwoFactorSmsCodeGeneratorService.php b/src/User/Service/TwoFactorSmsCodeGeneratorService.php index ce00620e..5c805e13 100644 --- a/src/User/Service/TwoFactorSmsCodeGeneratorService.php +++ b/src/User/Service/TwoFactorSmsCodeGeneratorService.php @@ -60,7 +60,7 @@ public function run() { // generate key $code = random_int(0, 999999); - $code = str_pad($code, 6, 0, STR_PAD_LEFT); + $code = str_pad((string)$code, 6, "0", STR_PAD_LEFT); // get the mobile phone of the user $user = $this->user; $mobilePhone = $user->getAuthTfMobilePhone(); diff --git a/src/User/Validator/ReCaptchaValidator.php b/src/User/Validator/ReCaptchaValidator.php index 79f6d2e8..b1ab41c6 100644 --- a/src/User/Validator/ReCaptchaValidator.php +++ b/src/User/Validator/ReCaptchaValidator.php @@ -45,7 +45,7 @@ public function init() public function clientValidateAttribute($model, $attribute, $view) { $message = addslashes( - $this->notCheckedMessage ?: Yii::t('usuario', '{0} cannot be blank.', $model->getAttributeLabel($attribute)) + $this->notCheckedMessage ?: Yii::t('usuario', '{0} cannot be blank.', [$model->getAttributeLabel($attribute)]) ); return "(function(messages){if(!grecaptcha.getResponse()){messages.push('{$message}');}})(messages);"; diff --git a/src/User/resources/views/bootstrap5/profile/show.php b/src/User/resources/views/bootstrap5/profile/show.php index 5f69dcd8..0f671b59 100644 --- a/src/User/resources/views/bootstrap5/profile/show.php +++ b/src/User/resources/views/bootstrap5/profile/show.php @@ -60,7 +60,7 @@
- = Yii::t('usuario', 'Thank you for signing up on {0}', Yii::$app->name) ?>. + = Yii::t('usuario', 'Thank you for signing up on {0}', [Yii::$app->name]) ?>. = Yii::t('usuario', 'In order to complete your registration, please click the link below') ?>.
diff --git a/src/User/resources/views/mail/reconfirmation.php b/src/User/resources/views/mail/reconfirmation.php index f41e543c..4dd05e7a 100644 --- a/src/User/resources/views/mail/reconfirmation.php +++ b/src/User/resources/views/mail/reconfirmation.php @@ -22,7 +22,7 @@ = Yii::t( 'usuario', 'We have received a request to change the email address for your account on {0}', - Yii::$app->name + [Yii::$app->name] ) ?>. = Yii::t('usuario', 'In order to complete your request, please click the link below') ?>.
diff --git a/src/User/resources/views/mail/recovery.php b/src/User/resources/views/mail/recovery.php index c06e2761..2afd464d 100644 --- a/src/User/resources/views/mail/recovery.php +++ b/src/User/resources/views/mail/recovery.php @@ -23,7 +23,7 @@ = Yii::t( 'usuario', 'We have received a request to reset the password for your account on {0}', - Yii::$app->name + [Yii::$app->name] ) ?>. = Yii::t('usuario', 'Please click the link below to complete your password reset') ?>. diff --git a/src/User/resources/views/mail/text/confirmation.php b/src/User/resources/views/mail/text/confirmation.php index 20a6928c..c7863c33 100644 --- a/src/User/resources/views/mail/text/confirmation.php +++ b/src/User/resources/views/mail/text/confirmation.php @@ -15,7 +15,7 @@ ?> = Yii::t('usuario', 'Hello') ?>, -= Yii::t('usuario', 'Thank you for signing up on {0}', Yii::$app->name) ?>. += Yii::t('usuario', 'Thank you for signing up on {0}', [Yii::$app->name]) ?>. = Yii::t('usuario', 'In order to complete your registration, please click the link below') ?>. = $token->url ?> diff --git a/src/User/resources/views/mail/text/reconfirmation.php b/src/User/resources/views/mail/text/reconfirmation.php index 808139c7..3b8e353c 100644 --- a/src/User/resources/views/mail/text/reconfirmation.php +++ b/src/User/resources/views/mail/text/reconfirmation.php @@ -18,7 +18,7 @@ = Yii::t( 'usuario', 'We have received a request to change the email address for your account on {0}', - Yii::$app->name + [Yii::$app->name] ) ?>. = Yii::t('usuario', 'In order to complete your request, please click the link below') ?>. diff --git a/src/User/resources/views/mail/text/recovery.php b/src/User/resources/views/mail/text/recovery.php index 08a7210d..4ea5ed02 100644 --- a/src/User/resources/views/mail/text/recovery.php +++ b/src/User/resources/views/mail/text/recovery.php @@ -15,7 +15,7 @@ ?> = Yii::t('usuario', 'Hello') ?>, -= Yii::t('usuario', 'We have received a request to reset the password for your account on {0}', Yii::$app->name) ?>. += Yii::t('usuario', 'We have received a request to reset the password for your account on {0}', [Yii::$app->name]) ?>. = Yii::t('usuario', 'Please click the link below to complete your password reset') ?>. = $token->url ?> diff --git a/src/User/resources/views/mail/text/welcome.php b/src/User/resources/views/mail/text/welcome.php index 0d4516b3..6e70425c 100644 --- a/src/User/resources/views/mail/text/welcome.php +++ b/src/User/resources/views/mail/text/welcome.php @@ -21,7 +21,7 @@ ?> = Yii::t('usuario', 'Hello') ?>, -= Yii::t('usuario', 'Your account on {0} has been created', Yii::$app->name) ?>. += Yii::t('usuario', 'Your account on {0} has been created', [Yii::$app->name]) ?>. generatePasswords): ?> = Yii::t('usuario', 'We have generated a password for you') ?>: = $user->password ?> diff --git a/src/User/resources/views/mail/welcome.php b/src/User/resources/views/mail/welcome.php index 8efa10a9..391ea6dc 100644 --- a/src/User/resources/views/mail/welcome.php +++ b/src/User/resources/views/mail/welcome.php @@ -25,7 +25,7 @@- = Yii::t('usuario', 'Your account on {0} has been created', Yii::$app->name) ?>. + = Yii::t('usuario', 'Your account on {0} has been created', [Yii::$app->name]) ?>. generatePasswords): ?> = Yii::t('usuario', 'We have generated a password for you') ?>: = Html::encode($user->password) ?>