@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | -$db = require __DIR__ . '/db.php'; |
|
| 2 | +$db = require __DIR__.'/db.php'; |
|
| 3 | 3 | // test database! Important not to run tests on production or development databases |
| 4 | -$db['dsn'] = 'mysql:host=localhost;dbname=yii2_basic_tests'; |
|
| 4 | +$db[ 'dsn' ] = 'mysql:host=localhost;dbname=yii2_basic_tests'; |
|
| 5 | 5 | |
| 6 | 6 | return $db; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -$params = require __DIR__ . '/params.php'; |
|
| 3 | -$db = require __DIR__ . '/test_db.php'; |
|
| 2 | +$params = require __DIR__.'/params.php'; |
|
| 3 | +$db = require __DIR__.'/test_db.php'; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Application configuration shared by all test types |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | 'useFileTransport' => true, |
| 20 | 20 | ], |
| 21 | 21 | 'assetManager' => [ |
| 22 | - 'basePath' => __DIR__ . '/../web/assets', |
|
| 22 | + 'basePath' => __DIR__.'/../web/assets', |
|
| 23 | 23 | ], |
| 24 | 24 | 'urlManager' => [ |
| 25 | 25 | 'showScriptName' => true, |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | int $statusCode = 200): array { |
| 53 | 53 | |
| 54 | 54 | if (null === $data) { |
| 55 | - $data = (object)[]; |
|
| 55 | + $data = (object)[ ]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | \Yii::$app->response->statusCode = $statusCode; |
@@ -34,24 +34,24 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public function beforeAction($action) |
| 36 | 36 | { |
| 37 | - $this->view->mainMenuConfig = require __DIR__ . '/../config/admin/main-menu.php'; |
|
| 37 | + $this->view->mainMenuConfig = require __DIR__.'/../config/admin/main-menu.php'; |
|
| 38 | 38 | |
| 39 | - $this->view->homeUrl = '/' . $this->shortLanguage . '/admin'; |
|
| 39 | + $this->view->homeUrl = '/'.$this->shortLanguage.'/admin'; |
|
| 40 | 40 | |
| 41 | - $this->view->signOutLink = '/' . $this->shortLanguage . '/logout'; |
|
| 41 | + $this->view->signOutLink = '/'.$this->shortLanguage.'/logout'; |
|
| 42 | 42 | |
| 43 | - $this->view->profileLink = '/' . $this->shortLanguage . '/admin/users/view?id='.Yii::$app->getUser()->id; |
|
| 43 | + $this->view->profileLink = '/'.$this->shortLanguage.'/admin/users/view?id='.Yii::$app->getUser()->id; |
|
| 44 | 44 | |
| 45 | - Yii::$app->getUser()->loginUrl = '/' . $this->shortLanguage . '/login'; |
|
| 45 | + Yii::$app->getUser()->loginUrl = '/'.$this->shortLanguage.'/login'; |
|
| 46 | 46 | |
| 47 | - $this->urlPrefix = '/' . $this->shortLanguage . '/' . $this->module->id . '/' . $action->controller->id . '/'; |
|
| 47 | + $this->urlPrefix = '/'.$this->shortLanguage.'/'.$this->module->id.'/'.$action->controller->id.'/'; |
|
| 48 | 48 | |
| 49 | 49 | if (array_key_exists($action->controller->id, $this->neighborControllers)) { |
| 50 | - $this->urlPrefixNeighbor = '/' . $this->shortLanguage . '/' . $this->module->id . '/' . |
|
| 51 | - $this->neighborControllers[$action->controller->id] . '/'; |
|
| 50 | + $this->urlPrefixNeighbor = '/'.$this->shortLanguage.'/'.$this->module->id.'/'. |
|
| 51 | + $this->neighborControllers[ $action->controller->id ].'/'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $this->view->userBody = ArrayHelper::map($this->languages, 'name', function ($item) { |
|
| 54 | + $this->view->userBody = ArrayHelper::map($this->languages, 'name', function($item) { |
|
| 55 | 55 | /* @var Language $item */ |
| 56 | 56 | return BaseHelper::getSwitchLanguageLink($item->getShortName(), Yii::$app->request); |
| 57 | 57 | }); |
@@ -41,9 +41,9 @@ |
||
| 41 | 41 | '!=', 'shortName', $this->shortLanguage |
| 42 | 42 | ])->all(); |
| 43 | 43 | |
| 44 | - $this->view->params['languages'] = $this->languages; |
|
| 44 | + $this->view->params[ 'languages' ] = $this->languages; |
|
| 45 | 45 | |
| 46 | - $this->view->params['shortLanguage'] = $this->shortLanguage; |
|
| 46 | + $this->view->params[ 'shortLanguage' ] = $this->shortLanguage; |
|
| 47 | 47 | |
| 48 | 48 | parent::init(); |
| 49 | 49 | } |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $urlArray = explode('/', $url); |
| 41 | 41 | |
| 42 | - $urlArray[0] = $newShortLanguage; |
|
| 42 | + $urlArray[ 0 ] = $newShortLanguage; |
|
| 43 | 43 | |
| 44 | - return '/' . implode('/', $urlArray); |
|
| 44 | + return '/'.implode('/', $urlArray); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -73,19 +73,19 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public static function detectClientShortLanguage() |
| 75 | 75 | { |
| 76 | - if (!isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) || empty($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { |
|
| 76 | + if (!isset($_SERVER[ "HTTP_ACCEPT_LANGUAGE" ]) || empty($_SERVER[ "HTTP_ACCEPT_LANGUAGE" ])) { |
|
| 77 | 77 | return null; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | preg_match_all('/([a-z]{1,8}(?:-[a-z]{1,8})?)(?:;q=([0-9.]+))?/', |
| 81 | - strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]), |
|
| 81 | + strtolower($_SERVER[ "HTTP_ACCEPT_LANGUAGE" ]), |
|
| 82 | 82 | $matches |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - $langs = array_combine($matches[1], $matches[2]); |
|
| 85 | + $langs = array_combine($matches[ 1 ], $matches[ 2 ]); |
|
| 86 | 86 | |
| 87 | 87 | foreach ($langs as $n => $v) { |
| 88 | - $langs[$n] = $v ? $v : 1; // If no q, then set q = 1 |
|
| 88 | + $langs[ $n ] = $v ? $v : 1; // If no q, then set q = 1 |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | arsort($langs); // Sort descending q |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | $fields = array('HTTP_CLIENT_IP', 'HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR'); |
| 104 | 104 | |
| 105 | 105 | $ip = "0.0.0.0"; |
| 106 | - foreach($fields as $k) |
|
| 106 | + foreach ($fields as $k) |
|
| 107 | 107 | { |
| 108 | - if(!empty($_SERVER[$k]) && ip2long($_SERVER[$k]) != false) |
|
| 108 | + if (!empty($_SERVER[ $k ]) && ip2long($_SERVER[ $k ]) != false) |
|
| 109 | 109 | { |
| 110 | - $ip = $_SERVER[$k]; |
|
| 110 | + $ip = $_SERVER[ $k ]; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | private static function setUserStatus(TableSchema $settingsTableSchema, $settings, IdentityInterface $user): void |
| 64 | 64 | { |
| 65 | 65 | if (in_array('initUserStatus', $settingsTableSchema->columnNames)) { |
| 66 | - $user->status = is_array($settings) && null !== $settings['initUserStatus'] ? |
|
| 67 | - $settings['initUserStatus'] : self::INIT_USER_STATUS; |
|
| 66 | + $user->status = is_array($settings) && null !== $settings[ 'initUserStatus' ] ? |
|
| 67 | + $settings[ 'initUserStatus' ] : self::INIT_USER_STATUS; |
|
| 68 | 68 | $user->save(); |
| 69 | 69 | } else { |
| 70 | 70 | Yii::error('Field "initUserStatus" does not exists in "settings" table to set initial user status.'); |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | ]); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if (!is_array($settings) || null === $settings['initUserRole']) { |
|
| 96 | + if (!is_array($settings) || null === $settings[ 'initUserRole' ]) { |
|
| 97 | 97 | $initUserRole = self::INIT_USER_ROLE; |
| 98 | 98 | Yii::error('Can not get field value of "initUserRole" from "settings" table to set initial user role.'); |
| 99 | 99 | } else { |
| 100 | - $initUserRole = $settings['initUserRole']; |
|
| 100 | + $initUserRole = $settings[ 'initUserRole' ]; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $authManager->assign( |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | public function verbs() |
| 59 | 59 | { |
| 60 | 60 | return [ |
| 61 | - 'send' => ['POST'] |
|
| 61 | + 'send' => [ 'POST' ] |
|
| 62 | 62 | ]; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $feedback->setScenario(Feedback::SCENARIO_FEEDBACK); |
| 103 | 103 | $feedback->setAttributes($request->post(), false); |
| 104 | 104 | |
| 105 | - if ($feedback->contact(Yii::$app->params['adminEmail'])) { |
|
| 105 | + if ($feedback->contact(Yii::$app->params[ 'adminEmail' ])) { |
|
| 106 | 106 | |
| 107 | 107 | return $this->getSuccessResponse(Yii::t('feedback', 'You have successfully sent your message.')); |
| 108 | 108 | } else { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function init() |
| 36 | 36 | { |
| 37 | - $this->recaptchaDriver = new ReCaptcha(Yii::$app->params['captcha']['secret_key']); |
|
| 37 | + $this->recaptchaDriver = new ReCaptcha(Yii::$app->params[ 'captcha' ][ 'secret_key' ]); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public function verbs() |
| 72 | 72 | { |
| 73 | 73 | return [ |
| 74 | - 'validate' => ['POST'] |
|
| 74 | + 'validate' => [ 'POST' ] |
|
| 75 | 75 | ]; |
| 76 | 76 | } |
| 77 | 77 | |