Skip to content

Commit

Permalink
fix code style, require php version >= 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-chepurnoi committed Nov 22, 2016
1 parent ef8d752 commit 0c91602
Show file tree
Hide file tree
Showing 22 changed files with 139 additions and 87 deletions.
23 changes: 23 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

$finder = Symfony\CS\Finder::create()
->exclude('vendor')
->in([__DIR__]);

$config = Symfony\CS\Config::create()
->fixers([
'-phpdoc_params',
'-phpdoc_short_description',
'-phpdoc_inline_tag',
'-pre_increment',
'-heredoc_to_nowdoc',
'-spaces_cast',
'-include',
'-phpdoc_no_package',
'concat_with_spaces',
'ordered_use',
'short_array_syntax',
])
->finder($finder);

return $config;
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

# run build against hhvm but allow them to fail
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail
matrix:
fast_finish: true
allow_failures:
- php: hhvm

# faster builds on new travis setup not using sudo
sudo: false
Expand All @@ -21,6 +12,7 @@ sudo: false
cache:
directories:
- $HOME/.composer/cache
- vendor

install:
- travis_retry composer self-update && composer --version
Expand All @@ -29,4 +21,5 @@ install:
- travis_retry composer install --prefer-dist --no-interaction

script:
- phpunit --verbose $PHPUNIT_FLAGS
- vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff
- phpunit --verbose $PHPUNIT_FLAGS
5 changes: 3 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

/**
* Class Module
*
* @package yii2mod\settings
*/
class Module extends \yii\base\Module
{
/**
* @var string the namespace that controller classes are in.
* @var string the namespace that controller classes are in
*/
public $controllerNamespace = 'yii2mod\settings\controllers';
}
}
16 changes: 11 additions & 5 deletions components/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace yii2mod\settings\components;

use Yii;
use yii\helpers\ArrayHelper;
use yii\base\Component;
use yii\caching\Cache;
use yii\di\Instance;
use yii\helpers\ArrayHelper;
use yii2mod\settings\models\enumerables\SettingType;

/**
* Class Settings
*
* @package yii2mod\settings\components
*/
class Settings extends Component
Expand All @@ -27,8 +28,7 @@ class Settings extends Component
* - a configuration array
* - a [[yii\caching\Cache]] object
*
* When this is not set, it means caching is not enabled.
*
* When this is not set, it means caching is not enabled
*/
public $cache = 'cache';

Expand Down Expand Up @@ -60,7 +60,7 @@ public function init()
parent::init();

if ($this->cache !== null) {
$this->cache = Instance::ensure($this->cache, Cache::className());
$this->cache = Instance::ensure($this->cache, Cache::class);
}

$this->model = Yii::createObject($this->modelClass);
Expand All @@ -72,6 +72,7 @@ public function init()
* @param string $section
* @param string $key
* @param null $default
*
* @return mixed
*/
public function get($section, $key, $default = null)
Expand All @@ -96,6 +97,7 @@ public function get($section, $key, $default = null)
* @param string $key
* @param string $value
* @param null $type
*
* @return bool
*/
public function set($section, $key, $value, $type = null)
Expand All @@ -114,6 +116,7 @@ public function set($section, $key, $value, $type = null)
*
* @param string $section
* @param string $key
*
* @return bool
*/
public function has($section, $key)
Expand All @@ -128,6 +131,7 @@ public function has($section, $key)
*
* @param string $section
* @param string $key
*
* @return bool
*/
public function remove($section, $key)
Expand Down Expand Up @@ -156,6 +160,7 @@ public function removeAll()
*
* @param string $key
* @param string $section
*
* @return bool
*/
public function activate($section, $key)
Expand All @@ -168,6 +173,7 @@ public function activate($section, $key)
*
* @param string $key
* @param string $section
*
* @return bool
*/
public function deactivate($section, $key)
Expand Down Expand Up @@ -225,4 +231,4 @@ protected function convertSettingType($type)
settype($this->setting, $type);
}
}
}
}
49 changes: 29 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
{
"name": "yii2mod/yii2-settings",
"description": "Yii2 Settings Module",
"type": "yii2-extension",
"keywords": ["yii2", "settings", "config", "storage"],
"license": "MIT",
"authors": [
{
"name": "Igor Chepurnoy",
"email": "[email protected]"
"name": "yii2mod/yii2-settings",
"description": "Yii2 Settings Module",
"type": "yii2-extension",
"keywords": [
"yii2",
"settings",
"config",
"storage"
],
"license": "MIT",
"authors": [
{
"name": "Igor Chepurnoy",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5",
"yiisoft/yii2": ">=2.0.8",
"yii2mod/yii2-editable": "*",
"yii2mod/yii2-enum": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.7"
},
"autoload": {
"psr-4": {
"yii2mod\\settings\\": ""
}
}
],
"require": {
"yiisoft/yii2": ">=2.0.8",
"yii2mod/yii2-editable": "*",
"yii2mod/yii2-enum": "*"
},
"autoload": {
"psr-4": {
"yii2mod\\settings\\": ""
}
}
}
37 changes: 22 additions & 15 deletions controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace yii2mod\settings\controllers;

use Yii;
use yii2mod\editable\EditableAction;
use yii2mod\settings\models\SettingModel;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii2mod\editable\EditableAction;
use yii2mod\settings\models\SettingModel;

/**
* Class SettingController
*
* @package yii2mod\settings\controllers
*/
class DefaultController extends Controller
Expand Down Expand Up @@ -49,14 +50,14 @@ public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'class' => VerbFilter::class,
'actions' => [
'index' => ['get'],
'create' => ['get', 'post'],
'update' => ['get', 'post'],
'delete' => ['post']
]
]
'delete' => ['post'],
],
],
];
}

Expand All @@ -69,10 +70,10 @@ public function actions()
{
return [
'edit-setting' => [
'class' => EditableAction::className(),
'modelClass' => SettingModel::className(),
'forceCreate' => false
]
'class' => EditableAction::class,
'modelClass' => SettingModel::class,
'forceCreate' => false,
],
];
}

Expand Down Expand Up @@ -105,6 +106,7 @@ public function actionCreate()

if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('yii2mod.settings', 'Setting has been created.'));

return $this->redirect(['index']);
} else {
return $this->render($this->createView, [
Expand All @@ -118,7 +120,8 @@ public function actionCreate()
*
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
* @param int $id
*
* @return mixed
*/
public function actionUpdate($id)
Expand All @@ -127,6 +130,7 @@ public function actionUpdate($id)

if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('yii2mod.settings', 'Setting has been updated.'));

return $this->redirect(['index']);
} else {
return $this->render($this->updateView, [
Expand All @@ -140,13 +144,15 @@ public function actionUpdate($id)
*
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
* @param int $id
*
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
Yii::$app->session->setFlash('success', Yii::t('yii2mod.settings', 'Setting has been deleted.'));

return $this->redirect(['index']);
}

Expand All @@ -155,7 +161,8 @@ public function actionDelete($id)
*
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @param integer $id
* @param int $id
*
* @return SettingModel the loaded model
*
* @throws NotFoundHttpException if the model cannot be found
Expand All @@ -170,4 +177,4 @@ protected function findModel($id)
throw new NotFoundHttpException(Yii::t('yii2mod.settings', 'The requested page does not exist.'));
}
}
}
}
2 changes: 1 addition & 1 deletion messages/en/yii2mod.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
'Setting has been created.' => 'Setting has been created.',
'Setting has been updated.' => 'Setting has been updated.',
'Setting has been deleted.' => 'Setting has been deleted.',
'The requested page does not exist.' => 'The requested page does not exist.'
'The requested page does not exist.' => 'The requested page does not exist.',
];
2 changes: 1 addition & 1 deletion messages/ru/yii2mod.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
'Setting has been created.' => 'Настройка была сохранена.',
'Setting has been updated.' => 'Настройка была обновлена.',
'Setting has been deleted.' => 'Настройка была удалена.',
'The requested page does not exist.' => 'Ошибка 404 - страница не найдена!'
'The requested page does not exist.' => 'Ошибка 404 - страница не найдена!',
];
2 changes: 1 addition & 1 deletion messages/uk/yii2mod.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
'Setting has been created.' => 'Налаштування було створено.',
'Setting has been updated.' => 'Налаштування було оновлено.',
'Setting has been deleted.' => 'Налаштування було видалено.',
'The requested page does not exist.' => 'Помилка 404 - сторінка не знайдена!'
'The requested page does not exist.' => 'Помилка 404 - сторінка не знайдена!',
];
2 changes: 1 addition & 1 deletion migrations/m150227_114524_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function up()
'value' => $this->text()->notNull(),
'status' => $this->smallInteger()->notNull()->defaultValue(1),
'createdAt' => $this->integer()->notNull(),
'updatedAt' => $this->integer()->notNull()
'updatedAt' => $this->integer()->notNull(),
], $tableOptions);
}

Expand Down
2 changes: 1 addition & 1 deletion migrations/m161109_104201_rename_setting_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function down()
$this->renameTable('{{%setting}}', '{{%Setting}}');
}
}
}
}
Loading

0 comments on commit 0c91602

Please sign in to comment.