diff --git a/apps/advanced/backend/controllers/SiteController.php b/apps/advanced/backend/controllers/SiteController.php index 28f2310..ebfb484 100644 --- a/apps/advanced/backend/controllers/SiteController.php +++ b/apps/advanced/backend/controllers/SiteController.php @@ -10,32 +10,32 @@ class SiteController extends Controller { public function behaviors() { - return array( - 'access' => array( + return [ + 'access' => [ 'class' => \yii\web\AccessControl::className(), - 'rules' => array( - array( - 'actions' => array('login'), + 'rules' => [ + [ + 'actions' => ['login'], 'allow' => true, - 'roles' => array('?'), - ), - array( - 'actions' => array('logout', 'index'), + 'roles' => ['?'], + ], + [ + 'actions' => ['logout', 'index'], 'allow' => true, - 'roles' => array('@'), - ), - ), - ), - ); + 'roles' => ['@'], + ], + ], + ], + ]; } public function actions() { - return array( - 'error' => array( + return [ + 'error' => [ 'class' => 'yii\web\ErrorAction', - ), - ); + ], + ]; } public function actionIndex() @@ -49,9 +49,9 @@ class SiteController extends Controller if ($model->load($_POST) && $model->login()) { return $this->goHome(); } else { - return $this->render('login', array( + return $this->render('login', [ 'model' => $model, - )); + ]); } } diff --git a/apps/advanced/backend/views/layouts/main.php b/apps/advanced/backend/views/layouts/main.php index 928f990..6d958cb 100644 --- a/apps/advanced/backend/views/layouts/main.php +++ b/apps/advanced/backend/views/layouts/main.php @@ -22,32 +22,32 @@ AppAsset::register($this); beginBody(); ?> 'My Company', 'brandUrl' => Yii::$app->homeUrl, - 'options' => array( + 'options' => [ 'class' => 'navbar-inverse navbar-fixed-top', - ), - )); - $menuItems = array( - array('label' => 'Home', 'url' => array('/site/index')), - ); + ], + ]); + $menuItems = [ + ['label' => 'Home', 'url' => ['/site/index']], + ]; if (Yii::$app->user->isGuest) { - $menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); + $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { - $menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); + $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => ['/site/logout']]; } - echo Nav::widget(array( - 'options' => array('class' => 'navbar-nav pull-right'), + echo Nav::widget([ + 'options' => ['class' => 'navbar-nav pull-right'], 'items' => $menuItems, - )); + ]); NavBar::end(); ?>
- isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), - )); ?> + isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], + ]); ?>
diff --git a/apps/advanced/backend/views/site/login.php b/apps/advanced/backend/views/site/login.php index 0c16570..bcb673d 100644 --- a/apps/advanced/backend/views/site/login.php +++ b/apps/advanced/backend/views/site/login.php @@ -17,12 +17,12 @@ $this->params['breadcrumbs'][] = $this->title;
- 'login-form')); ?> + 'login-form']); ?> field($model, 'username'); ?> field($model, 'password')->passwordInput(); ?> field($model, 'rememberMe')->checkbox(); ?>
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/advanced/common/config/params.php b/apps/advanced/common/config/params.php index 2dff87b..7dab548 100644 --- a/apps/advanced/common/config/params.php +++ b/apps/advanced/common/config/params.php @@ -4,19 +4,19 @@ Yii::setAlias('common', __DIR__ . '/../'); Yii::setAlias('frontend', __DIR__ . '/../../frontend'); Yii::setAlias('backend', __DIR__ . '/../../backend'); -return array( +return [ 'adminEmail' => 'admin@example.com', 'supportEmail' => 'support@example.com', - 'components.cache' => array( + 'components.cache' => [ 'class' => 'yii\caching\FileCache', - ), + ], - 'components.db' => array( + 'components.db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=yii2advanced', 'username' => 'root', 'password' => '', 'charset' => 'utf8', - ), -); + ], +]; diff --git a/apps/advanced/common/models/LoginForm.php b/apps/advanced/common/models/LoginForm.php index 4631dbd..339005b 100644 --- a/apps/advanced/common/models/LoginForm.php +++ b/apps/advanced/common/models/LoginForm.php @@ -19,14 +19,14 @@ class LoginForm extends Model */ public function rules() { - return array( + return [ // username and password are both required - array('username, password', 'required'), + ['username, password', 'required'], // password is validated by validatePassword() - array('password', 'validatePassword'), + ['password', 'validatePassword'], // rememberMe must be a boolean value - array('rememberMe', 'boolean'), - ); + ['rememberMe', 'boolean'], + ]; } /** diff --git a/apps/advanced/common/models/User.php b/apps/advanced/common/models/User.php index 62baf48..17bd630 100644 --- a/apps/advanced/common/models/User.php +++ b/apps/advanced/common/models/User.php @@ -34,15 +34,15 @@ class User extends ActiveRecord implements IdentityInterface public function behaviors() { - return array( - 'timestamp' => array( + return [ + 'timestamp' => [ 'class' => 'yii\behaviors\AutoTimestamp', - 'attributes' => array( - ActiveRecord::EVENT_BEFORE_INSERT => array('create_time', 'update_time'), + 'attributes' => [ + ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'], ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time', - ), - ), - ); + ], + ], + ]; } /** @@ -64,7 +64,7 @@ class User extends ActiveRecord implements IdentityInterface */ public static function findByUsername($username) { - return static::find(array('username' => $username, 'status' => static::STATUS_ACTIVE)); + return static::find(['username' => $username, 'status' => static::STATUS_ACTIVE]); } /** @@ -103,29 +103,29 @@ class User extends ActiveRecord implements IdentityInterface public function rules() { - return array( - array('username', 'filter', 'filter' => 'trim'), - array('username', 'required'), - array('username', 'string', 'min' => 2, 'max' => 255), - - array('email', 'filter', 'filter' => 'trim'), - array('email', 'required'), - array('email', 'email'), - array('email', 'unique', 'message' => 'This email address has already been taken.', 'on' => 'signup'), - array('email', 'exist', 'message' => 'There is no user with such email.', 'on' => 'requestPasswordResetToken'), - - array('password', 'required'), - array('password', 'string', 'min' => 6), - ); + return [ + ['username', 'filter', 'filter' => 'trim'], + ['username', 'required'], + ['username', 'string', 'min' => 2, 'max' => 255], + + ['email', 'filter', 'filter' => 'trim'], + ['email', 'required'], + ['email', 'email'], + ['email', 'unique', 'message' => 'This email address has already been taken.', 'on' => 'signup'], + ['email', 'exist', 'message' => 'There is no user with such email.', 'on' => 'requestPasswordResetToken'], + + ['password', 'required'], + ['password', 'string', 'min' => 6], + ]; } public function scenarios() { - return array( - 'signup' => array('username', 'email', 'password'), - 'resetPassword' => array('password'), - 'requestPasswordResetToken' => array('email'), - ); + return [ + 'signup' => ['username', 'email', 'password'], + 'resetPassword' => ['password'], + 'requestPasswordResetToken' => ['email'], + ]; } public function beforeSave($insert) diff --git a/apps/advanced/console/config/main.php b/apps/advanced/console/config/main.php index 7a223c3..fbf452a 100644 --- a/apps/advanced/console/config/main.php +++ b/apps/advanced/console/config/main.php @@ -8,24 +8,24 @@ $params = array_merge( require(__DIR__ . '/params-local.php') ); -return array( +return [ 'id' => 'app-console', 'basePath' => dirname(__DIR__), 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'controllerNamespace' => 'console\controllers', - 'modules' => array( - ), - 'components' => array( + 'modules' => [ + ], + 'components' => [ 'db' => $params['components.db'], 'cache' => $params['components.cache'], - 'log' => array( - 'targets' => array( - array( + 'log' => [ + 'targets' => [ + [ 'class' => 'yii\log\FileTarget', - 'levels' => array('error', 'warning'), - ), - ), - ), - ), + 'levels' => ['error', 'warning'], + ], + ], + ], + ], 'params' => $params, -); +]; diff --git a/apps/advanced/console/config/params.php b/apps/advanced/console/config/params.php index 1643a70..0e625dc 100644 --- a/apps/advanced/console/config/params.php +++ b/apps/advanced/console/config/params.php @@ -1,4 +1,4 @@ 'admin@example.com', -); +]; diff --git a/apps/advanced/environments/dev/backend/config/main-local.php b/apps/advanced/environments/dev/backend/config/main-local.php index 2689ed1..0c1f40e 100644 --- a/apps/advanced/environments/dev/backend/config/main-local.php +++ b/apps/advanced/environments/dev/backend/config/main-local.php @@ -1,11 +1,11 @@ array( +return [ + 'preload' => [ //'debug', - ), - 'modules' => array( + ], + 'modules' => [ // 'debug' => array( // 'class' => 'yii\debug\Module', // ), - ), -); + ], +]; diff --git a/apps/advanced/environments/dev/backend/config/params-local.php b/apps/advanced/environments/dev/backend/config/params-local.php index 5b61b0e..d0b9c34 100644 --- a/apps/advanced/environments/dev/backend/config/params-local.php +++ b/apps/advanced/environments/dev/backend/config/params-local.php @@ -1,3 +1,3 @@ array( +return [ + 'preload' => [ //'debug', - ), - 'modules' => array( + ], + 'modules' => [ // 'debug' => array( // 'class' => 'yii\debug\Module', // ), - ), -); + ], +]; diff --git a/apps/advanced/environments/dev/frontend/config/params-local.php b/apps/advanced/environments/dev/frontend/config/params-local.php index 5b61b0e..d0b9c34 100644 --- a/apps/advanced/environments/dev/frontend/config/params-local.php +++ b/apps/advanced/environments/dev/frontend/config/params-local.php @@ -1,3 +1,3 @@ array( +return [ + 'Development' => [ 'path' => 'dev', - 'writable' => array( + 'writable' => [ // handled by composer.json already - ), - 'executable' => array( + ], + 'executable' => [ 'yii', - ), - ), - 'Production' => array( + ], + ], + 'Production' => [ 'path' => 'prod', - 'writable' => array( + 'writable' => [ // handled by composer.json already - ), - 'executable' => array( + ], + 'executable' => [ 'yii', - ), - ), -); + ], + ], +]; diff --git a/apps/advanced/environments/prod/backend/config/main-local.php b/apps/advanced/environments/prod/backend/config/main-local.php index 5b61b0e..d0b9c34 100644 --- a/apps/advanced/environments/prod/backend/config/main-local.php +++ b/apps/advanced/environments/prod/backend/config/main-local.php @@ -1,3 +1,3 @@ 'app-frontend', 'basePath' => dirname(__DIR__), 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'controllerNamespace' => 'frontend\controllers', - 'modules' => array( + 'modules' => [ 'gii' => 'yii\gii\Module' - ), - 'components' => array( - 'request' => array( + ], + 'components' => [ + 'request' => [ 'enableCsrfValidation' => true, - ), + ], 'db' => $params['components.db'], 'cache' => $params['components.cache'], - 'user' => array( + 'user' => [ 'identityClass' => 'common\models\User', - ), - 'log' => array( + ], + 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, - 'targets' => array( - array( + 'targets' => [ + [ 'class' => 'yii\log\FileTarget', - 'levels' => array('error', 'warning'), - ), - ), - ), - 'errorHandler' => array( + 'levels' => ['error', 'warning'], + ], + ], + ], + 'errorHandler' => [ 'errorAction' => 'site/error', - ), - ), + ], + ], 'params' => $params, -); +]; diff --git a/apps/advanced/frontend/config/params.php b/apps/advanced/frontend/config/params.php index 1643a70..0e625dc 100644 --- a/apps/advanced/frontend/config/params.php +++ b/apps/advanced/frontend/config/params.php @@ -1,4 +1,4 @@ 'admin@example.com', -); +]; diff --git a/apps/advanced/frontend/controllers/SiteController.php b/apps/advanced/frontend/controllers/SiteController.php index a9413de..26aa300 100644 --- a/apps/advanced/frontend/controllers/SiteController.php +++ b/apps/advanced/frontend/controllers/SiteController.php @@ -14,37 +14,37 @@ class SiteController extends Controller { public function behaviors() { - return array( - 'access' => array( + return [ + 'access' => [ 'class' => \yii\web\AccessControl::className(), - 'only' => array('login', 'logout', 'signup'), - 'rules' => array( - array( - 'actions' => array('login', 'signup'), + 'only' => ['login', 'logout', 'signup'], + 'rules' => [ + [ + 'actions' => ['login', 'signup'], 'allow' => true, - 'roles' => array('?'), - ), - array( - 'actions' => array('logout'), + 'roles' => ['?'], + ], + [ + 'actions' => ['logout'], 'allow' => true, - 'roles' => array('@'), - ), - ), - ), - ); + 'roles' => ['@'], + ], + ], + ], + ]; } public function actions() { - return array( - 'error' => array( + return [ + 'error' => [ 'class' => 'yii\web\ErrorAction', - ), - 'captcha' => array( + ], + 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, - ), - ); + ], + ]; } public function actionIndex() @@ -58,9 +58,9 @@ class SiteController extends Controller if ($model->load($_POST) && $model->login()) { return $this->goHome(); } else { - return $this->render('login', array( + return $this->render('login', [ 'model' => $model, - )); + ]); } } @@ -77,9 +77,9 @@ class SiteController extends Controller Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); return $this->refresh(); } else { - return $this->render('contact', array( + return $this->render('contact', [ 'model' => $model, - )); + ]); } } @@ -98,9 +98,9 @@ class SiteController extends Controller } } - return $this->render('signup', array( + return $this->render('signup', [ 'model' => $model, - )); + ]); } public function actionRequestPasswordReset() @@ -115,17 +115,17 @@ class SiteController extends Controller Yii::$app->getSession()->setFlash('error', 'There was an error sending email.'); } } - return $this->render('requestPasswordResetToken', array( + return $this->render('requestPasswordResetToken', [ 'model' => $model, - )); + ]); } public function actionResetPassword($token) { - $model = User::find(array( + $model = User::find([ 'password_reset_token' => $token, 'status' => User::STATUS_ACTIVE, - )); + ]); if (!$model) { throw new HttpException(400, 'Wrong password reset token.'); @@ -137,17 +137,17 @@ class SiteController extends Controller return $this->goHome(); } - return $this->render('resetPassword', array( + return $this->render('resetPassword', [ 'model' => $model, - )); + ]); } private function sendPasswordResetEmail($email) { - $user = User::find(array( + $user = User::find([ 'status' => User::STATUS_ACTIVE, 'email' => $email, - )); + ]); if (!$user) { return false; @@ -158,9 +158,9 @@ class SiteController extends Controller $fromEmail = \Yii::$app->params['supportEmail']; $name = '=?UTF-8?B?' . base64_encode(\Yii::$app->name . ' robot') . '?='; $subject = '=?UTF-8?B?' . base64_encode('Password reset for ' . \Yii::$app->name) . '?='; - $body = $this->renderPartial('/emails/passwordResetToken', array( + $body = $this->renderPartial('/emails/passwordResetToken', [ 'user' => $user, - )); + ]); $headers = "From: $name <{$fromEmail}>\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8"; diff --git a/apps/advanced/frontend/models/ContactForm.php b/apps/advanced/frontend/models/ContactForm.php index b3d8682..ddb622b 100644 --- a/apps/advanced/frontend/models/ContactForm.php +++ b/apps/advanced/frontend/models/ContactForm.php @@ -20,14 +20,14 @@ class ContactForm extends Model */ public function rules() { - return array( + return [ // name, email, subject and body are required - array('name, email, subject, body', 'required'), + ['name, email, subject, body', 'required'], // email has to be a valid email address - array('email', 'email'), + ['email', 'email'], // verifyCode needs to be entered correctly - array('verifyCode', 'captcha'), - ); + ['verifyCode', 'captcha'], + ]; } /** @@ -35,9 +35,9 @@ class ContactForm extends Model */ public function attributeLabels() { - return array( + return [ 'verifyCode' => 'Verification Code', - ); + ]; } /** diff --git a/apps/advanced/frontend/views/emails/passwordResetToken.php b/apps/advanced/frontend/views/emails/passwordResetToken.php index 1e7a855..134dc08 100644 --- a/apps/advanced/frontend/views/emails/passwordResetToken.php +++ b/apps/advanced/frontend/views/emails/passwordResetToken.php @@ -6,7 +6,7 @@ use yii\helpers\Html; * @var common\models\User $user; */ -$resetLink = Yii::$app->urlManager->createAbsoluteUrl('site/reset-password', array('token' => $user->password_reset_token)); +$resetLink = Yii::$app->urlManager->createAbsoluteUrl('site/reset-password', ['token' => $user->password_reset_token]); ?> Hello username)?>, diff --git a/apps/advanced/frontend/views/layouts/main.php b/apps/advanced/frontend/views/layouts/main.php index 0165ba0..d3e05a7 100644 --- a/apps/advanced/frontend/views/layouts/main.php +++ b/apps/advanced/frontend/views/layouts/main.php @@ -23,35 +23,35 @@ AppAsset::register($this); beginBody(); ?> 'My Company', 'brandUrl' => Yii::$app->homeUrl, - 'options' => array( + 'options' => [ 'class' => 'navbar-inverse navbar-fixed-top', - ), - )); - $menuItems = array( - array('label' => 'Home', 'url' => array('/site/index')), - array('label' => 'About', 'url' => array('/site/about')), - array('label' => 'Contact', 'url' => array('/site/contact')), - ); + ], + ]); + $menuItems = [ + ['label' => 'Home', 'url' => ['/site/index']], + ['label' => 'About', 'url' => ['/site/about']], + ['label' => 'Contact', 'url' => ['/site/contact']], + ]; if (Yii::$app->user->isGuest) { - $menuItems[] = array('label' => 'Signup', 'url' => array('/site/signup')); - $menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); + $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; + $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { - $menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); + $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => ['/site/logout']]; } - echo Nav::widget(array( - 'options' => array('class' => 'navbar-nav pull-right'), + echo Nav::widget([ + 'options' => ['class' => 'navbar-nav pull-right'], 'items' => $menuItems, - )); + ]); NavBar::end(); ?>
- isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), - )); ?> + isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], + ]); ?>
diff --git a/apps/advanced/frontend/views/site/contact.php b/apps/advanced/frontend/views/site/contact.php index 851deda..9b1b392 100644 --- a/apps/advanced/frontend/views/site/contact.php +++ b/apps/advanced/frontend/views/site/contact.php @@ -20,17 +20,17 @@ $this->params['breadcrumbs'][] = $this->title;
- 'contact-form')); ?> + 'contact-form']); ?> field($model, 'name'); ?> field($model, 'email'); ?> field($model, 'subject'); ?> - field($model, 'body')->textArea(array('rows' => 6)); ?> - field($model, 'verifyCode')->widget(Captcha::className(), array( - 'options' => array('class' => 'form-control'), + field($model, 'body')->textArea(['rows' => 6]); ?> + field($model, 'verifyCode')->widget(Captcha::className(), [ + 'options' => ['class' => 'form-control'], 'template' => '
{image}
{input}
', - )); ?> + ]); ?>
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/advanced/frontend/views/site/login.php b/apps/advanced/frontend/views/site/login.php index 5e7f6f6..22b5db5 100644 --- a/apps/advanced/frontend/views/site/login.php +++ b/apps/advanced/frontend/views/site/login.php @@ -17,15 +17,15 @@ $this->params['breadcrumbs'][] = $this->title;
- 'login-form')); ?> + 'login-form']); ?> field($model, 'username'); ?> field($model, 'password')->passwordInput(); ?> field($model, 'rememberMe')->checkbox(); ?>
- If you forgot your password you can . + If you forgot your password you can .
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/advanced/frontend/views/site/requestPasswordResetToken.php b/apps/advanced/frontend/views/site/requestPasswordResetToken.php index c754948..0b0ace4 100644 --- a/apps/advanced/frontend/views/site/requestPasswordResetToken.php +++ b/apps/advanced/frontend/views/site/requestPasswordResetToken.php @@ -17,10 +17,10 @@ $this->params['breadcrumbs'][] = $this->title;
- 'request-password-reset-form')); ?> + 'request-password-reset-form']); ?> field($model, 'email'); ?>
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/advanced/frontend/views/site/resetPassword.php b/apps/advanced/frontend/views/site/resetPassword.php index 2c38028..92a1363 100644 --- a/apps/advanced/frontend/views/site/resetPassword.php +++ b/apps/advanced/frontend/views/site/resetPassword.php @@ -17,10 +17,10 @@ $this->params['breadcrumbs'][] = $this->title;
- 'reset-password-form')); ?> + 'reset-password-form']); ?> field($model, 'password')->passwordInput(); ?>
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/advanced/frontend/views/site/signup.php b/apps/advanced/frontend/views/site/signup.php index 92525bf..7f6c2ad 100644 --- a/apps/advanced/frontend/views/site/signup.php +++ b/apps/advanced/frontend/views/site/signup.php @@ -17,12 +17,12 @@ $this->params['breadcrumbs'][] = $this->title;
- 'form-signup')); ?> + 'form-signup']); ?> field($model, 'username'); ?> field($model, 'email'); ?> field($model, 'password')->passwordInput(); ?>
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/advanced/init b/apps/advanced/init index 3a8f6a6..f5d2691 100755 --- a/apps/advanced/init +++ b/apps/advanced/init @@ -73,7 +73,7 @@ echo "\n ... initialization completed.\n\n"; function getFileList($root, $basePath = '') { - $files = array(); + $files = []; $handle = opendir($root); while (($path = readdir($handle)) !== false) { if ($path === '.svn' || $path === '.' || $path === '..') { @@ -135,13 +135,13 @@ function copyFile($root, $source, $target, &$all) function getParams() { - $rawParams = array(); + $rawParams = []; if (isset($_SERVER['argv'])) { $rawParams = $_SERVER['argv']; array_shift($rawParams); } - $params = array(); + $params = []; foreach ($rawParams as $param) { if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) { $name = $matches[1]; diff --git a/apps/advanced/requirements.php b/apps/advanced/requirements.php index c9e6493..139284f 100644 --- a/apps/advanced/requirements.php +++ b/apps/advanced/requirements.php @@ -26,78 +26,78 @@ $requirementsChecker = new YiiRequirementChecker(); /** * Adjust requirements according to your application specifics. */ -$requirements = array( +$requirements = [ // Database : - array( + [ 'name' => 'PDO extension', 'mandatory' => true, 'condition' => extension_loaded('pdo'), 'by' => 'All DB-related classes', - ), - array( + ], + [ 'name' => 'PDO SQLite extension', 'mandatory' => false, 'condition' => extension_loaded('pdo_sqlite'), 'by' => 'All DB-related classes', 'memo' => 'Required for SQLite database.', - ), - array( + ], + [ 'name' => 'PDO MySQL extension', 'mandatory' => false, 'condition' => extension_loaded('pdo_mysql'), 'by' => 'All DB-related classes', 'memo' => 'Required for MySQL database.', - ), + ], // Cache : - array( + [ 'name' => 'Memcache extension', 'mandatory' => false, 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'by' => 'CMemCache', 'memo' => extension_loaded('memcached') ? 'To use memcached set CMemCache::useMemcached to true.' : '' - ), - array( + ], + [ 'name' => 'APC extension', 'mandatory' => false, 'condition' => extension_loaded('apc') || extension_loaded('apc'), 'by' => 'CApcCache', - ), + ], // Additional PHP extensions : - array( + [ 'name' => 'Mcrypt extension', 'mandatory' => false, 'condition' => extension_loaded('mcrypt'), 'by' => 'CSecurityManager', 'memo' => 'Required by encrypt and decrypt methods.' - ), + ], // PHP ini : - 'phpSafeMode' => array( + 'phpSafeMode' => [ 'name' => 'PHP safe mode', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), 'by' => 'File uploading and console command execution', 'memo' => '"safe_mode" should be disabled at php.ini', - ), - 'phpExposePhp' => array( + ], + 'phpExposePhp' => [ 'name' => 'Expose PHP', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 'by' => 'Security reasons', 'memo' => '"expose_php" should be disabled at php.ini', - ), - 'phpAllowUrlInclude' => array( + ], + 'phpAllowUrlInclude' => [ 'name' => 'PHP allow url include', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 'by' => 'Security reasons', 'memo' => '"allow_url_include" should be disabled at php.ini', - ), - 'phpSmtp' => array( + ], + 'phpSmtp' => [ 'name' => 'PHP mail SMTP', 'mandatory' => false, 'condition' => strlen(ini_get('SMTP'))>0, 'by' => 'Email sending', 'memo' => 'PHP mail SMTP server required', - ), -); + ], +]; $requirementsChecker->checkYii()->check($requirements)->render(); diff --git a/apps/basic/config/console.php b/apps/basic/config/console.php index 8d50bd2..cc1cdb8 100644 --- a/apps/basic/config/console.php +++ b/apps/basic/config/console.php @@ -3,7 +3,7 @@ $params = require(__DIR__ . '/params.php'); return [ 'id' => 'bootstrap-console', 'basePath' => dirname(__DIR__), - 'preload' => array('log'), + 'preload' => ['log'], 'controllerPath' => dirname(__DIR__) . '/commands', 'controllerNamespace' => 'app\commands', 'modules' => [ diff --git a/apps/basic/requirements.php b/apps/basic/requirements.php index c9e6493..139284f 100644 --- a/apps/basic/requirements.php +++ b/apps/basic/requirements.php @@ -26,78 +26,78 @@ $requirementsChecker = new YiiRequirementChecker(); /** * Adjust requirements according to your application specifics. */ -$requirements = array( +$requirements = [ // Database : - array( + [ 'name' => 'PDO extension', 'mandatory' => true, 'condition' => extension_loaded('pdo'), 'by' => 'All DB-related classes', - ), - array( + ], + [ 'name' => 'PDO SQLite extension', 'mandatory' => false, 'condition' => extension_loaded('pdo_sqlite'), 'by' => 'All DB-related classes', 'memo' => 'Required for SQLite database.', - ), - array( + ], + [ 'name' => 'PDO MySQL extension', 'mandatory' => false, 'condition' => extension_loaded('pdo_mysql'), 'by' => 'All DB-related classes', 'memo' => 'Required for MySQL database.', - ), + ], // Cache : - array( + [ 'name' => 'Memcache extension', 'mandatory' => false, 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'by' => 'CMemCache', 'memo' => extension_loaded('memcached') ? 'To use memcached set CMemCache::useMemcached to true.' : '' - ), - array( + ], + [ 'name' => 'APC extension', 'mandatory' => false, 'condition' => extension_loaded('apc') || extension_loaded('apc'), 'by' => 'CApcCache', - ), + ], // Additional PHP extensions : - array( + [ 'name' => 'Mcrypt extension', 'mandatory' => false, 'condition' => extension_loaded('mcrypt'), 'by' => 'CSecurityManager', 'memo' => 'Required by encrypt and decrypt methods.' - ), + ], // PHP ini : - 'phpSafeMode' => array( + 'phpSafeMode' => [ 'name' => 'PHP safe mode', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), 'by' => 'File uploading and console command execution', 'memo' => '"safe_mode" should be disabled at php.ini', - ), - 'phpExposePhp' => array( + ], + 'phpExposePhp' => [ 'name' => 'Expose PHP', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 'by' => 'Security reasons', 'memo' => '"expose_php" should be disabled at php.ini', - ), - 'phpAllowUrlInclude' => array( + ], + 'phpAllowUrlInclude' => [ 'name' => 'PHP allow url include', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 'by' => 'Security reasons', 'memo' => '"allow_url_include" should be disabled at php.ini', - ), - 'phpSmtp' => array( + ], + 'phpSmtp' => [ 'name' => 'PHP mail SMTP', 'mandatory' => false, 'condition' => strlen(ini_get('SMTP'))>0, 'by' => 'Email sending', 'memo' => 'PHP mail SMTP server required', - ), -); + ], +]; $requirementsChecker->checkYii()->check($requirements)->render(); diff --git a/apps/basic/tests/acceptance/ContactCept.php b/apps/basic/tests/acceptance/ContactCept.php index 73527ab..5ec5641 100644 --- a/apps/basic/tests/acceptance/ContactCept.php +++ b/apps/basic/tests/acceptance/ContactCept.php @@ -4,7 +4,7 @@ $I->wantTo('ensure that contact works'); $I->amOnPage('?r=site/contact'); $I->see('Contact', 'h1'); -$I->submitForm('#contact-form', array()); +$I->submitForm('#contact-form', []); $I->see('Contact', 'h1'); $I->see('Name cannot be blank'); $I->see('Email cannot be blank'); @@ -12,25 +12,25 @@ $I->see('Subject cannot be blank'); $I->see('Body cannot be blank'); $I->see('The verification code is incorrect'); -$I->submitForm('#contact-form', array( +$I->submitForm('#contact-form', [ 'ContactForm[name]' => 'tester', 'ContactForm[email]' => 'tester.email', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme', -)); +]); $I->dontSee('Name cannot be blank', '.help-inline'); $I->see('Email is not a valid email address.'); $I->dontSee('Subject cannot be blank', '.help-inline'); $I->dontSee('Body cannot be blank', '.help-inline'); $I->dontSee('The verification code is incorrect', '.help-inline'); -$I->submitForm('#contact-form', array( +$I->submitForm('#contact-form', [ 'ContactForm[name]' => 'tester', 'ContactForm[email]' => 'tester@example.com', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme', -)); +]); $I->dontSeeElement('#contact-form'); $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); diff --git a/apps/basic/tests/acceptance/LoginCept.php b/apps/basic/tests/acceptance/LoginCept.php index 77c4a07..5621b15 100644 --- a/apps/basic/tests/acceptance/LoginCept.php +++ b/apps/basic/tests/acceptance/LoginCept.php @@ -4,20 +4,20 @@ $I->wantTo('ensure that login works'); $I->amOnPage('?r=site/login'); $I->see('Login', 'h1'); -$I->submitForm('#login-form', array()); +$I->submitForm('#login-form', []); $I->dontSee('Logout (admin)'); $I->see('Username cannot be blank'); $I->see('Password cannot be blank'); -$I->submitForm('#login-form', array( +$I->submitForm('#login-form', [ 'LoginForm[username]' => 'admin', 'LoginForm[password]' => 'wrong', -)); +]); $I->dontSee('Logout (admin)'); $I->see('Incorrect username or password'); -$I->submitForm('#login-form', array( +$I->submitForm('#login-form', [ 'LoginForm[username]' => 'admin', 'LoginForm[password]' => 'admin', -)); +]); $I->see('Logout (admin)'); diff --git a/apps/basic/tests/functional/ContactCept.php b/apps/basic/tests/functional/ContactCept.php index 6feafd9..b58361a 100644 --- a/apps/basic/tests/functional/ContactCept.php +++ b/apps/basic/tests/functional/ContactCept.php @@ -4,7 +4,7 @@ $I->wantTo('ensure that contact works'); $I->amOnPage('?r=site/contact'); $I->see('Contact', 'h1'); -$I->submitForm('#contact-form', array()); +$I->submitForm('#contact-form', []); $I->see('Contact', 'h1'); $I->see('Name cannot be blank'); $I->see('Email cannot be blank'); @@ -12,25 +12,25 @@ $I->see('Subject cannot be blank'); $I->see('Body cannot be blank'); $I->see('The verification code is incorrect'); -$I->submitForm('#contact-form', array( +$I->submitForm('#contact-form', [ 'ContactForm[name]' => 'tester', 'ContactForm[email]' => 'tester.email', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme', -)); +]); $I->dontSee('Name cannot be blank', '.help-inline'); $I->see('Email is not a valid email address.'); $I->dontSee('Subject cannot be blank', '.help-inline'); $I->dontSee('Body cannot be blank', '.help-inline'); $I->dontSee('The verification code is incorrect', '.help-inline'); -$I->submitForm('#contact-form', array( +$I->submitForm('#contact-form', [ 'ContactForm[name]' => 'tester', 'ContactForm[email]' => 'tester@example.com', 'ContactForm[subject]' => 'test subject', 'ContactForm[body]' => 'test content', 'ContactForm[verifyCode]' => 'testme', -)); +]); $I->dontSeeElement('#contact-form'); $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); diff --git a/apps/basic/tests/functional/LoginCept.php b/apps/basic/tests/functional/LoginCept.php index 11f8f6b..9d71378 100644 --- a/apps/basic/tests/functional/LoginCept.php +++ b/apps/basic/tests/functional/LoginCept.php @@ -4,20 +4,20 @@ $I->wantTo('ensure that login works'); $I->amOnPage('?r=site/login'); $I->see('Login', 'h1'); -$I->submitForm('#login-form', array()); +$I->submitForm('#login-form', []); $I->dontSee('Logout (admin)'); $I->see('Username cannot be blank'); $I->see('Password cannot be blank'); -$I->submitForm('#login-form', array( +$I->submitForm('#login-form', [ 'LoginForm[username]' => 'admin', 'LoginForm[password]' => 'wrong', -)); +]); $I->dontSee('Logout (admin)'); $I->see('Incorrect username or password'); -$I->submitForm('#login-form', array( +$I->submitForm('#login-form', [ 'LoginForm[username]' => 'admin', 'LoginForm[password]' => 'admin', -)); +]); $I->see('Logout (admin)'); diff --git a/apps/basic/views/layouts/main.php b/apps/basic/views/layouts/main.php index 1b7083d..30246b1 100644 --- a/apps/basic/views/layouts/main.php +++ b/apps/basic/views/layouts/main.php @@ -21,33 +21,33 @@ app\config\AppAsset::register($this); beginBody(); ?> 'My Company', 'brandUrl' => Yii::$app->homeUrl, - 'options' => array( + 'options' => [ 'class' => 'navbar-inverse navbar-fixed-top', - ), - )); - echo Nav::widget(array( - 'options' => array('class' => 'navbar-nav pull-right'), - 'items' => array( - array('label' => 'Home', 'url' => array('/site/index')), - array('label' => 'About', 'url' => array('/site/about')), - array('label' => 'Contact', 'url' => array('/site/contact')), + ], + ]); + echo Nav::widget([ + 'options' => ['class' => 'navbar-nav pull-right'], + 'items' => [ + ['label' => 'Home', 'url' => ['/site/index']], + ['label' => 'About', 'url' => ['/site/about']], + ['label' => 'Contact', 'url' => ['/site/contact']], Yii::$app->user->isGuest ? - array('label' => 'Login', 'url' => array('/site/login')) : - array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , - 'url' => array('/site/logout'), - 'linkOptions' => array('data-method' => 'post')), - ), - )); + ['label' => 'Login', 'url' => ['/site/login']] : + ['label' => 'Logout (' . Yii::$app->user->identity->username .')' , + 'url' => ['/site/logout'], + 'linkOptions' => ['data-method' => 'post']], + ], + ]); NavBar::end(); ?>
- isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), - )); ?> + isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], + ]); ?>
diff --git a/apps/basic/views/site/contact.php b/apps/basic/views/site/contact.php index d1411c0..55113cc 100644 --- a/apps/basic/views/site/contact.php +++ b/apps/basic/views/site/contact.php @@ -28,17 +28,17 @@ $this->params['breadcrumbs'][] = $this->title;
- 'contact-form')); ?> + 'contact-form']); ?> field($model, 'name'); ?> field($model, 'email'); ?> field($model, 'subject'); ?> - field($model, 'body')->textArea(array('rows' => 6)); ?> - field($model, 'verifyCode')->widget(Captcha::className(), array( - 'options' => array('class' => 'form-control'), + field($model, 'body')->textArea(['rows' => 6]); ?> + field($model, 'verifyCode')->widget(Captcha::className(), [ + 'options' => ['class' => 'form-control'], 'template' => '
{image}
{input}
', - )); ?> + ]); ?>
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/basic/views/site/login.php b/apps/basic/views/site/login.php index f61d9d7..7efb8b7 100644 --- a/apps/basic/views/site/login.php +++ b/apps/basic/views/site/login.php @@ -15,26 +15,26 @@ $this->params['breadcrumbs'][] = $this->title;

Please fill out the following fields to login:

- 'login-form', - 'options' => array('class' => 'form-horizontal'), - 'fieldConfig' => array( + 'options' => ['class' => 'form-horizontal'], + 'fieldConfig' => [ 'template' => "{label}\n
{input}
\n
{error}
", - 'labelOptions' => array('class' => 'col-lg-1 control-label'), - ), - )); ?> + 'labelOptions' => ['class' => 'col-lg-1 control-label'], + ], + ]); ?> field($model, 'username'); ?> field($model, 'password')->passwordInput(); ?> - field($model, 'rememberMe', array( + field($model, 'rememberMe', [ 'template' => "
{input}
\n
{error}
", - ))->checkbox(); ?> + ])->checkbox(); ?>
- 'btn btn-primary')); ?> + 'btn btn-primary']); ?>
diff --git a/apps/basic/web/index-test.php b/apps/basic/web/index-test.php index 79273ae..c9bd338 100644 --- a/apps/basic/web/index-test.php +++ b/apps/basic/web/index-test.php @@ -1,6 +1,6 @@