Skip to content

Commit 5b87f0b

Browse files
author
Igor Chepurnoy
committed
require php 7.1
1 parent 491f66a commit 5b87f0b

File tree

8 files changed

+38
-38
lines changed

8 files changed

+38
-38
lines changed

Bootstrap.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace yii2mod\cms;
44

55
use yii\base\BootstrapInterface;
6-
use yii\console\Application as ConsoleApplication;
76

87
/**
98
* Class Bootstrap
@@ -15,7 +14,7 @@ class Bootstrap implements BootstrapInterface
1514
/**
1615
* @inheritdoc
1716
*/
18-
public function bootstrap($app)
17+
public function bootstrap($app): void
1918
{
2019
if (!isset($app->get('i18n')->translations['yii2mod.cms'])) {
2120
$app->get('i18n')->translations['yii2mod.cms'] = [
@@ -24,7 +23,7 @@ public function bootstrap($app)
2423
];
2524
}
2625

27-
if (!$app->hasModule('comment') && !($app instanceof ConsoleApplication)) {
26+
if (!$app->hasModule('comment')) {
2827
$app->setModule('comment', ['class' => 'yii2mod\comments\Module']);
2928
}
3029

Widget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Widget extends FroalaEditorWidget
1515
/**
1616
* @inheritdoc
1717
*/
18-
public function init()
18+
public function init(): void
1919
{
2020
parent::init();
2121

actions/PageAction.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class PageAction extends Action
4141
public $commentWidgetParams = [];
4242

4343
/**
44-
* Initializes the object.
44+
* @inheritdoc
4545
*/
46-
public function init()
46+
public function init(): void
4747
{
4848
parent::init();
4949

@@ -81,7 +81,7 @@ public function run()
8181
*
8282
* @return string
8383
*/
84-
protected function parseBaseTemplateParams($pageContent)
84+
protected function parseBaseTemplateParams(string $pageContent)
8585
{
8686
$params = $this->getBaseTemplateParams();
8787
$p = [];
@@ -110,11 +110,11 @@ protected function getBaseTemplateParams()
110110
/**
111111
* Find CmsModel
112112
*
113-
* @return null|CmsModel
113+
* @return CmsModel
114114
*
115115
* @throws NotFoundHttpException
116116
*/
117-
protected function findModel()
117+
protected function findModel(): CmsModel
118118
{
119119
if (($model = CmsModel::findOne($this->pageId)) !== null) {
120120
return $model;

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
"email": "disemx@gmail.com"
1515
},
1616
{
17-
"name": "Igor Chepurnoy",
17+
"name": "Igor Chepurnoi",
1818
"email": "chepurnoi.igor@gmail.com"
1919
}
2020
],
2121
"require": {
22-
"php": ">=5.6",
23-
"yiisoft/yii2": "~2.0.11",
22+
"php": ">=7.1",
23+
"yiisoft/yii2": "~2.0.12",
2424
"yiisoft/yii2-bootstrap": "*",
2525
"yii2mod/yii2-enum": "*",
2626
"yii2mod/yii2-editable": "*",

controllers/ManageController.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use yii\db\ActiveRecord;
77
use yii\web\Controller;
88
use yii\web\NotFoundHttpException;
9+
use yii\web\Response;
910
use yii\web\UnprocessableEntityHttpException;
1011
use yii\web\UploadedFile;
1112
use yii2mod\cms\models\AttachmentModel;
@@ -81,7 +82,7 @@ class ManageController extends Controller
8182
/**
8283
* @inheritdoc
8384
*/
84-
public function behaviors()
85+
public function behaviors(): array
8586
{
8687
return [
8788
'verbs' => $this->verbFilterConfig,
@@ -92,7 +93,7 @@ public function behaviors()
9293
/**
9394
* @inheritdoc
9495
*/
95-
public function actions()
96+
public function actions(): array
9697
{
9798
return [
9899
'edit-page' => [
@@ -149,7 +150,7 @@ public function actionCreate()
149150
*
150151
* @return mixed
151152
*/
152-
public function actionUpdate($id)
153+
public function actionUpdate(int $id)
153154
{
154155
$model = $this->findModel($this->modelClass, $id);
155156

@@ -173,7 +174,7 @@ public function actionUpdate($id)
173174
*
174175
* @return mixed
175176
*/
176-
public function actionDelete($id)
177+
public function actionDelete(int $id)
177178
{
178179
$this->findModel($this->modelClass, $id)->delete();
179180
Yii::$app->session->setFlash('success', Yii::t('yii2mod.cms', 'Page has been deleted.'));
@@ -184,11 +185,11 @@ public function actionDelete($id)
184185
/**
185186
* Upload an image
186187
*
187-
* @return \yii\web\Response
188+
* @return Response
188189
*
189190
* @throws UnprocessableEntityHttpException
190191
*/
191-
public function actionUploadImage()
192+
public function actionUploadImage(): Response
192193
{
193194
$model = Yii::createObject($this->attachmentModelClass);
194195
$model->file = UploadedFile::getInstanceByName('file');
@@ -205,11 +206,11 @@ public function actionUploadImage()
205206
/**
206207
* Delete the image
207208
*
208-
* @return \yii\web\Response
209+
* @return Response
209210
*
210211
* @throws UnprocessableEntityHttpException
211212
*/
212-
public function actionDeleteImage()
213+
public function actionDeleteImage(): Response
213214
{
214215
$model = $this->findModel($this->attachmentModelClass, Yii::$app->request->post('id'));
215216

@@ -223,9 +224,9 @@ public function actionDeleteImage()
223224
/**
224225
* Return list of all images
225226
*
226-
* @return \yii\web\Response
227+
* @return Response
227228
*/
228-
public function actionImages()
229+
public function actionImages(): Response
229230
{
230231
$result = [];
231232

models/AttachmentModel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class AttachmentModel extends ActiveRecord
1818
/**
1919
* @inheritdoc
2020
*/
21-
public static function tableName()
21+
public static function tableName(): string
2222
{
2323
return '{{%attachment}}';
2424
}
2525

2626
/**
2727
* @inheritdoc
2828
*/
29-
public function rules()
29+
public function rules(): array
3030
{
3131
return [
3232
[['file_version'], 'integer'],
@@ -38,7 +38,7 @@ public function rules()
3838
/**
3939
* @inheritdoc
4040
*/
41-
public function attributeLabels()
41+
public function attributeLabels(): array
4242
{
4343
return [
4444
'id' => Yii::t('yii2mod.cms', 'ID'),
@@ -50,7 +50,7 @@ public function attributeLabels()
5050
/**
5151
* @inheritdoc
5252
*/
53-
public function behaviors()
53+
public function behaviors(): array
5454
{
5555
return [
5656
'file' => [

models/CmsModel.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class CmsModel extends ActiveRecord
3030
/**
3131
* @inheritdoc
3232
*/
33-
public static function tableName()
33+
public static function tableName(): string
3434
{
3535
return '{{%cms}}';
3636
}
3737

3838
/**
3939
* @inheritdoc
4040
*/
41-
public function rules()
41+
public function rules(): array
4242
{
4343
return [
4444
[['title', 'content', 'markdown_content', 'url', 'meta_title', 'meta_description', 'meta_keywords'], 'trim'],
@@ -60,7 +60,7 @@ public function rules()
6060
/**
6161
* @inheritdoc
6262
*/
63-
public function attributeLabels()
63+
public function attributeLabels(): array
6464
{
6565
return [
6666
'id' => Yii::t('yii2mod.cms', 'ID'),
@@ -81,7 +81,7 @@ public function attributeLabels()
8181
/**
8282
* @inheritdoc
8383
*/
84-
public function behaviors()
84+
public function behaviors(): array
8585
{
8686
return [
8787
TimestampBehavior::class,
@@ -91,15 +91,15 @@ public function behaviors()
9191
/**
9292
* @return CmsQuery
9393
*/
94-
public static function find()
94+
public static function find(): CmsQuery
9595
{
9696
return new CmsQuery(get_called_class());
9797
}
9898

9999
/**
100100
* @inheritdoc
101101
*/
102-
public function beforeValidate()
102+
public function beforeValidate(): bool
103103
{
104104
if (parent::beforeDelete()) {
105105
if (Yii::$app->getModule('cms')->enableMarkdown) {
@@ -117,9 +117,9 @@ public function beforeValidate()
117117
*
118118
* @param $url
119119
*
120-
* @return array|null|ActiveRecord
120+
* @return null|ActiveRecord
121121
*/
122-
public function findPage($url)
122+
public function findPage(string $url): ?ActiveRecord
123123
{
124124
return self::find()->byUrl($url)->enabled()->one();
125125
}
@@ -131,7 +131,7 @@ public function findPage($url)
131131
*
132132
* @return string
133133
*/
134-
public function getContent()
134+
public function getContent(): string
135135
{
136136
$content = preg_replace_callback('/\[\[([^(\[\[)]+:[^(\[\[)]+)\]\]/is', [$this, 'replace'], $this->content);
137137

@@ -145,7 +145,7 @@ public function getContent()
145145
*
146146
* @return string
147147
*/
148-
private function replace($data)
148+
private function replace(array $data): string
149149
{
150150
$widget = explode(':', $data[1]);
151151
if (class_exists($class = $widget[0]) && method_exists($class, $method = $widget[1])) {

models/search/CmsSearch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CmsSearch extends CmsModel
2020
/**
2121
* @inheritdoc
2222
*/
23-
public function rules()
23+
public function rules(): array
2424
{
2525
return [
2626
[['id', 'status', 'comment_available'], 'integer'],
@@ -35,7 +35,7 @@ public function rules()
3535
*
3636
* @return ActiveDataProvider
3737
*/
38-
public function search(array $params)
38+
public function search(array $params): ActiveDataProvider
3939
{
4040
$query = CmsModel::find();
4141

0 commit comments

Comments
 (0)