@@ -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 ])) {
0 commit comments