diff --git a/apps/advanced/backend/controllers/SiteController.php b/apps/advanced/backend/controllers/SiteController.php index baa8dbe1117..d5fe2d5b847 100644 --- a/apps/advanced/backend/controllers/SiteController.php +++ b/apps/advanced/backend/controllers/SiteController.php @@ -72,4 +72,4 @@ public function actionLogout() Yii::$app->user->logout(); return $this->goHome(); } -} +} \ No newline at end of file diff --git a/apps/advanced/common/models/LoginForm.php b/apps/advanced/common/models/LoginForm.php index 70c0ffd04e6..b752e133390 100644 --- a/apps/advanced/common/models/LoginForm.php +++ b/apps/advanced/common/models/LoginForm.php @@ -67,4 +67,4 @@ private function getUser() } return $this->_user; } -} +} \ No newline at end of file diff --git a/apps/advanced/common/models/User.php b/apps/advanced/common/models/User.php index 948bc8637cc..10787da5755 100644 --- a/apps/advanced/common/models/User.php +++ b/apps/advanced/common/models/User.php @@ -27,6 +27,12 @@ class User extends ActiveRecord implements IdentityInterface const ROLE_USER = 10; + /** + * Creates a new user + * + * @param $attributes + * @return static|null + */ public static function create($attributes) { /** @var User $user */ @@ -69,18 +75,18 @@ public static function findIdentity($id) * Finds user by username * * @param string $username - * @return self + * @return static|null */ public static function findByUsername($username) { - return static::find(['username' => $username, 'status' => static::STATUS_ACTIVE]); + return static::find(['username' => $username, 'status' => self::STATUS_ACTIVE]); } /** * Finds user by password reset token * * @param string $token password reset token - * @return self + * @return static|null */ public static function findByPasswordResetToken($token) { @@ -92,9 +98,9 @@ public static function findByPasswordResetToken($token) return null; } - return User::find([ + return static::find([ 'password_reset_token' => $token, - 'status' => User::STATUS_ACTIVE, + 'status' => self::STATUS_ACTIVE, ]); } @@ -189,4 +195,4 @@ public function rules() ['email', 'unique'], ]; } -} +} \ No newline at end of file diff --git a/apps/advanced/frontend/controllers/SiteController.php b/apps/advanced/frontend/controllers/SiteController.php index 50d77201680..c6e7cab094e 100644 --- a/apps/advanced/frontend/controllers/SiteController.php +++ b/apps/advanced/frontend/controllers/SiteController.php @@ -86,7 +86,7 @@ public function actionLogout() public function actionContact() { - $model = new ContactForm; + $model = new ContactForm(); if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) { Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); return $this->refresh(); @@ -153,4 +153,4 @@ public function actionResetPassword($token) 'model' => $model, ]); } -} +} \ No newline at end of file diff --git a/apps/advanced/frontend/models/ContactForm.php b/apps/advanced/frontend/models/ContactForm.php index 0a664ad1cab..779e5ee9074 100644 --- a/apps/advanced/frontend/models/ContactForm.php +++ b/apps/advanced/frontend/models/ContactForm.php @@ -17,7 +17,7 @@ class ContactForm extends Model public $verifyCode; /** - * @return array the validation rules. + * @inheritdoc */ public function rules() { @@ -32,7 +32,7 @@ public function rules() } /** - * @return array customized attribute labels + * @inheritdoc */ public function attributeLabels() { @@ -43,6 +43,7 @@ public function attributeLabels() /** * Sends an email to the specified email address using the information collected by this model. + * * @param string $email the target email address * @return boolean whether the model passes validation */ @@ -60,4 +61,4 @@ public function contact($email) return false; } } -} +} \ No newline at end of file diff --git a/apps/advanced/frontend/models/PasswordResetRequestForm.php b/apps/advanced/frontend/models/PasswordResetRequestForm.php index 942e2e10cfa..7c907ffbde8 100644 --- a/apps/advanced/frontend/models/PasswordResetRequestForm.php +++ b/apps/advanced/frontend/models/PasswordResetRequestForm.php @@ -25,8 +25,9 @@ public function rules() } /** + * Sends an email with a link, for resetting the password. * - * @return boolean sends an email + * @return boolean whether the email was send */ public function sendEmail() { @@ -51,5 +52,4 @@ public function sendEmail() return false; } -} - \ No newline at end of file +} \ No newline at end of file diff --git a/apps/advanced/frontend/models/ResetPasswordForm.php b/apps/advanced/frontend/models/ResetPasswordForm.php index f2cf77619b9..7c82b6e59bc 100644 --- a/apps/advanced/frontend/models/ResetPasswordForm.php +++ b/apps/advanced/frontend/models/ResetPasswordForm.php @@ -19,7 +19,7 @@ class ResetPasswordForm extends Model private $_user; /** - * Creates a form model given a token + * Creates a form model given a token. * * @param string $token * @param array $config name-value pairs that will be used to initialize the object properties @@ -38,7 +38,7 @@ public function __construct($token, $config = []) } /** - * @return array the validation rules. + * @inheritdoc */ public function rules() { @@ -50,6 +50,7 @@ public function rules() /** * Resets password. + * * @return boolean if password was reset. */ public function resetPassword() @@ -59,5 +60,4 @@ public function resetPassword() $user->removePasswordResetToken(); return $user->save(); } -} - \ No newline at end of file +} \ No newline at end of file diff --git a/apps/advanced/frontend/models/SignupForm.php b/apps/advanced/frontend/models/SignupForm.php index afb7d2e45d9..8a87f0a6aec 100644 --- a/apps/advanced/frontend/models/SignupForm.php +++ b/apps/advanced/frontend/models/SignupForm.php @@ -36,7 +36,8 @@ public function rules() /** * Signs user up. - * @return User saved model + * + * @return User|null the saved model or null if saving fails */ public function signup() { @@ -45,5 +46,4 @@ public function signup() } return null; } -} - \ No newline at end of file +} \ No newline at end of file diff --git a/apps/basic/controllers/SiteController.php b/apps/basic/controllers/SiteController.php index e538dcc4e6b..36e1eccbca8 100644 --- a/apps/basic/controllers/SiteController.php +++ b/apps/basic/controllers/SiteController.php @@ -76,7 +76,7 @@ public function actionLogout() public function actionContact() { - $model = new ContactForm; + $model = new ContactForm(); if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) { Yii::$app->session->setFlash('contactFormSubmitted'); return $this->refresh(); @@ -91,4 +91,4 @@ public function actionAbout() { return $this->render('about'); } -} +} \ No newline at end of file diff --git a/apps/basic/models/User.php b/apps/basic/models/User.php index af4c42e75d2..b890e6934e2 100644 --- a/apps/basic/models/User.php +++ b/apps/basic/models/User.php @@ -24,11 +24,20 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface ], ]; + /** + * @inheritdoc + */ public static function findIdentity($id) { return isset(self::$users[$id]) ? new static(self::$users[$id]) : null; } + /** + * Finds user by username + * + * @param string $username + * @return static|null + */ public static function findByUsername($username) { foreach (self::$users as $user) { @@ -39,21 +48,36 @@ public static function findByUsername($username) return null; } + /** + * @inheritdoc + */ public function getId() { return $this->id; } + /** + * @inheritdoc + */ public function getAuthKey() { return $this->authKey; } + /** + * @inheritdoc + */ public function validateAuthKey($authKey) { return $this->authKey === $authKey; } + /** + * Validates password + * + * @param string $password password to validate + * @return bool if password provided is valid for current user + */ public function validatePassword($password) { return $this->password === $password;