Skip to content

Commit d14d653

Browse files
author
igor-chepurnoi
committed
fix code style, require php version >= 5.5
1 parent 0ab0f7b commit d14d653

22 files changed

+129
-81
lines changed

.php_cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
$finder = Symfony\CS\Finder::create()
4+
->exclude('vendor')
5+
->in([__DIR__]);
6+
7+
$config = Symfony\CS\Config::create()
8+
->fixers([
9+
'-phpdoc_params',
10+
'-phpdoc_short_description',
11+
'-phpdoc_inline_tag',
12+
'-pre_increment',
13+
'-heredoc_to_nowdoc',
14+
'-spaces_cast',
15+
'-include',
16+
'-phpdoc_no_package',
17+
'concat_with_spaces',
18+
'ordered_use',
19+
'short_array_syntax',
20+
])
21+
->finder($finder);
22+
23+
return $config;

.travis.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
language: php
22

33
php:
4-
- 5.4
54
- 5.5
65
- 5.6
76
- 7.0
8-
- hhvm
9-
10-
# run build against hhvm but allow them to fail
11-
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail
12-
matrix:
13-
fast_finish: true
14-
allow_failures:
15-
- php: hhvm
167

178
# faster builds on new travis setup not using sudo
189
sudo: false
@@ -21,6 +12,7 @@ sudo: false
2112
cache:
2213
directories:
2314
- $HOME/.composer/cache
15+
- vendor
2416

2517
install:
2618
- travis_retry composer self-update && composer --version
@@ -29,4 +21,5 @@ install:
2921
- travis_retry composer install --prefer-dist --no-interaction
3022

3123
script:
32-
- phpunit --verbose $PHPUNIT_FLAGS
24+
- vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff
25+
- phpunit --verbose $PHPUNIT_FLAGS

actions/PageAction.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
/**
1212
* Class PageAction
13+
*
1314
* @package yii2mod\cms\actions
1415
*/
1516
class PageAction extends Action
@@ -39,21 +40,22 @@ class PageAction extends Action
3940
*/
4041
public function init()
4142
{
43+
parent::init();
44+
4245
if (empty($this->pageId)) {
4346
$this->pageId = Yii::$app->request->get('pageId');
4447
}
4548

4649
if (!empty($this->layout)) {
4750
$this->controller->layout = $this->layout;
4851
}
49-
50-
parent::init();
5152
}
5253

5354
/**
5455
* Run action
5556
*
5657
* @throws \yii\web\NotFoundHttpException
58+
*
5759
* @return string
5860
*/
5961
public function run()
@@ -70,6 +72,7 @@ public function run()
7072
* Parse base template params, like {homeUrl}
7173
*
7274
* @param $pageContent
75+
*
7376
* @return string
7477
*/
7578
protected function parseBaseTemplateParams($pageContent)
@@ -94,14 +97,15 @@ protected function getBaseTemplateParams()
9497
{
9598
return ArrayHelper::merge($this->baseTemplateParams, [
9699
'homeUrl' => Yii::$app->urlManager->baseUrl,
97-
'siteName' => Yii::$app->name
100+
'siteName' => Yii::$app->name,
98101
]);
99102
}
100103

101104
/**
102105
* Find CmsModel
103106
*
104107
* @return null|CmsModel
108+
*
105109
* @throws NotFoundHttpException
106110
*/
107111
protected function findModel()
@@ -112,4 +116,4 @@ protected function findModel()
112116

113117
throw new NotFoundHttpException(Yii::t('yii2mod.cms', 'The requested page does not exist.'));
114118
}
115-
}
119+
}

components/PageUrlRule.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
/**
99
* Class PageUrlRule
10+
*
1011
* @package yii2mod\cms\components
1112
*/
1213
class PageUrlRule extends UrlRule
1314
{
1415
/**
15-
* @var string the pattern used to parse and create the path info part of a URL.
16+
* @var string the pattern used to parse and create the path info part of a URL
1617
*/
1718
public $pattern = '<\w+>';
1819

@@ -32,15 +33,16 @@ class PageUrlRule extends UrlRule
3233
public function parseRequest($manager, $request)
3334
{
3435
$pathInfo = $request->getPathInfo();
35-
$url = preg_replace("#/$#", "", $pathInfo);
36+
$url = preg_replace('#/$#', '', $pathInfo);
3637
$page = (new CmsModel())->findPage($url);
3738

3839
if (!empty($page)) {
3940
$params['pageAlias'] = $url;
4041
$params['pageId'] = $page->id;
42+
4143
return [$this->route, $params];
4244
}
4345

4446
return parent::parseRequest($manager, $request);
4547
}
46-
}
48+
}

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818
}
1919
],
2020
"require": {
21+
"php": ">=5.5",
2122
"yiisoft/yii2": "*",
2223
"yii2mod/yii2-enum": "*",
2324
"asofter/yii2-imperavi-redactor": "*",
2425
"yii2mod/yii2-editable": "*",
2526
"yii2mod/yii2-toggle-column": "*",
2627
"yii2mod/yii2-comments": "*"
2728
},
29+
"require-dev": {
30+
"friendsofphp/php-cs-fixer": "~1.7"
31+
},
2832
"autoload": {
2933
"psr-4": {
3034
"yii2mod\\cms\\": ""

controllers/CmsController.php

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
namespace yii2mod\cms\controllers;
44

55
use Yii;
6-
use yii2mod\cms\models\CmsModel;
6+
use yii\filters\VerbFilter;
77
use yii\web\Controller;
88
use yii\web\NotFoundHttpException;
9-
use yii\filters\VerbFilter;
9+
use yii2mod\cms\models\CmsModel;
1010
use yii2mod\editable\EditableAction;
1111
use yii2mod\toggle\actions\ToggleAction;
1212

1313
/**
1414
* Class CmsController
15+
*
1516
* @package yii2mod\cms\controllers
1617
*/
1718
class CmsController extends Controller
@@ -48,14 +49,14 @@ public function behaviors()
4849
{
4950
return [
5051
'verbs' => [
51-
'class' => VerbFilter::className(),
52+
'class' => VerbFilter::class,
5253
'actions' => [
5354
'index' => ['get'],
5455
'create' => ['get', 'post'],
5556
'update' => ['get', 'post'],
56-
'delete' => ['post']
57+
'delete' => ['post'],
5758
],
58-
]
59+
],
5960
];
6061
}
6162

@@ -66,14 +67,14 @@ public function actions()
6667
{
6768
return [
6869
'edit-page' => [
69-
'class' => EditableAction::className(),
70-
'modelClass' => CmsModel::className(),
71-
'forceCreate' => false
70+
'class' => EditableAction::class,
71+
'modelClass' => CmsModel::class,
72+
'forceCreate' => false,
7273
],
7374
'toggle' => [
74-
'class' => ToggleAction::className(),
75-
'modelClass' => CmsModel::className(),
76-
]
75+
'class' => ToggleAction::class,
76+
'modelClass' => CmsModel::class,
77+
],
7778
];
7879
}
7980

@@ -89,7 +90,7 @@ public function actionIndex()
8990

9091
return $this->render($this->indexView, [
9192
'dataProvider' => $dataProvider,
92-
'searchModel' => $searchModel
93+
'searchModel' => $searchModel,
9394
]);
9495
}
9596

@@ -106,11 +107,12 @@ public function actionCreate()
106107

107108
if ($model->load(Yii::$app->request->post()) && $model->save()) {
108109
Yii::$app->session->setFlash('success', Yii::t('yii2mod.cms', 'Page has been created.'));
110+
109111
return $this->redirect(['index']);
110112
}
111113

112114
return $this->render($this->createView, [
113-
'model' => $model
115+
'model' => $model,
114116
]);
115117
}
116118

@@ -119,7 +121,7 @@ public function actionCreate()
119121
*
120122
* If update is successful, the browser will be redirected to the 'index' page.
121123
*
122-
* @param integer $id
124+
* @param int $id
123125
*
124126
* @return mixed
125127
*/
@@ -129,11 +131,12 @@ public function actionUpdate($id)
129131

130132
if ($model->load(Yii::$app->request->post()) && $model->save()) {
131133
Yii::$app->session->setFlash('success', Yii::t('yii2mod.cms', 'Page has been updated.'));
134+
132135
return $this->redirect(['index']);
133136
}
134137

135138
return $this->render($this->updateView, [
136-
'model' => $model
139+
'model' => $model,
137140
]);
138141
}
139142

@@ -142,22 +145,23 @@ public function actionUpdate($id)
142145
*
143146
* If deletion is successful, the browser will be redirected to the 'index' page.
144147
*
145-
* @param integer $id
148+
* @param int $id
146149
*
147150
* @return mixed
148151
*/
149152
public function actionDelete($id)
150153
{
151154
$this->findModel($id)->delete();
152155
Yii::$app->session->setFlash('success', Yii::t('yii2mod.cms', 'Page has been deleted.'));
156+
153157
return $this->redirect(['index']);
154158
}
155159

156160
/**
157161
* Finds the CmsModel model based on its primary key value.
158162
* If the model is not found, a 404 HTTP exception will be thrown.
159163
*
160-
* @param integer $id
164+
* @param int $id
161165
*
162166
* @return CmsModel the loaded model
163167
*
@@ -173,4 +177,4 @@ protected function findModel($id)
173177
throw new NotFoundHttpException(Yii::t('yii2mod.cms', 'The requested page does not exist.'));
174178
}
175179
}
176-
}
180+
}

messages/en/yii2mod.cms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
'Page has been created.' => 'Page has been created.',
4747
'Page has been updated.' => 'Page has been updated.',
4848
'Page has been deleted.' => 'Page has been deleted.',
49-
'The requested page does not exist.' => 'The requested page does not exist.'
49+
'The requested page does not exist.' => 'The requested page does not exist.',
5050
];

messages/ru/yii2mod.cms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
'Page has been created.' => 'Страница была сохранён.',
4747
'Page has been updated.' => 'Страница был обновлена.',
4848
'Page has been deleted.' => 'Страница был удалена.',
49-
'The requested page does not exist.' => 'Ошибка 404 - страница не найдена!'
49+
'The requested page does not exist.' => 'Ошибка 404 - страница не найдена!',
5050
];

migrations/m150212_182851_init_cms.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ public function up()
2626
'metaDescription' => $this->text(),
2727
'metaKeywords' => $this->text(),
2828
'createdAt' => $this->integer()->notNull(),
29-
'updatedAt' => $this->integer()->notNull()
29+
'updatedAt' => $this->integer()->notNull(),
3030
], $tableOptions);
31-
3231
}
3332

3433
public function down()
3534
{
3635
$this->dropTable('{{%Cms}}');
3736
}
38-
}
37+
}

migrations/m161109_105445_rename_cms_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public function down()
1717
$this->renameTable('{{%cms}}', '{{%Cms}}');
1818
}
1919
}
20-
}
20+
}

0 commit comments

Comments
 (0)