Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-chepurnoi committed Nov 22, 2016
1 parent 062fd0a commit 42d0543
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 60 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;
12 changes: 3 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ php:
- 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 +13,7 @@ sudo: false
cache:
directories:
- $HOME/.composer/cache
- vendor

install:
- travis_retry composer self-update && composer --version
Expand All @@ -29,4 +22,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
7 changes: 4 additions & 3 deletions actions/CronLogAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

/**
* Class CronLogAction
*
* @package yii2mod\cron\actions
*/
class CronLogAction extends Action
{
/**
* @var string name of the view, which should be rendered.
* @var string name of the view, which should be rendered
*/
public $view = '@vendor/yii2mod/yii2-cron-log/views/index';

Expand All @@ -31,7 +32,7 @@ public function run()

return $this->controller->render($this->view, [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider
'dataProvider' => $dataProvider,
]);
}
}
}
8 changes: 5 additions & 3 deletions behaviors/CronLoggerBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CronLoggerBehavior extends Behavior
protected $schedule;

/**
* @var array list of action names, which should be logged.
* @var array list of action names, which should be logged
*/
public $actions = [];

Expand All @@ -52,7 +52,7 @@ class CronLoggerBehavior extends Behavior
/**
* Declares event handlers for the [[owner]]'s events.
*
* @return array events (array keys) and the corresponding event handler methods (array values).
* @return array events (array keys) and the corresponding event handler methods (array values)
*/
public function events()
{
Expand All @@ -64,6 +64,7 @@ public function events()

/**
* Before action
*
* @param $event \yii\base\ActionEvent
*/
public function beforeAction($event)
Expand All @@ -79,6 +80,7 @@ public function beforeAction($event)

/**
* After action
*
* @param $event \yii\base\ActionEvent
*/
public function afterAction($event)
Expand Down Expand Up @@ -124,4 +126,4 @@ private function getActionParams()

return $result;
}
}
}
19 changes: 11 additions & 8 deletions behaviors/MutexConsoleCommandBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@
* ```
*
* Class MutexConsoleCommandBehavior
*
* @package yii2mod\cron\behaviors
*/
class MutexConsoleCommandBehavior extends Behavior
{
/**
* @var string name of the mutex application component.
* @var string name of the mutex application component
*/
public $mutex = 'mutex';

/**
* @var array list of action names, which mutex should be applied to.
* @var array list of action names, which mutex should be applied to
*/
public $mutexActions = [];

Expand All @@ -53,7 +54,7 @@ public function events()
}

/**
* @return Mutex mutex application component instance.
* @return Mutex mutex application component instance
*/
public function getMutex()
{
Expand All @@ -63,9 +64,9 @@ public function getMutex()
/**
* Composes the mutex name.
*
* @param string $action command action name.
* @param string $action command action name
*
* @return string mutex name.
* @return string mutex name
*/
protected function composeMutexName($action)
{
Expand All @@ -75,9 +76,9 @@ protected function composeMutexName($action)
/**
* Checks if specified action is among mutex actions.
*
* @param string $action action name.
* @param string $action action name
*
* @return boolean whether action should be under mutex.
* @return bool whether action should be under mutex
*/
public function checkIsMutexAction($action)
{
Expand All @@ -86,6 +87,7 @@ public function checkIsMutexAction($action)

/**
* @param $event
*
* @return bool
*/
public function beforeAction($event)
Expand All @@ -95,6 +97,7 @@ public function beforeAction($event)
if (!$this->getMutex()->acquire($mutexName)) {
echo "Execution terminated: command is already running.\n";
$event->isValid = false;

return false;
}
}
Expand All @@ -110,4 +113,4 @@ public function afterAction($event)
$this->getMutex()->release($mutexName);
}
}
}
}
3 changes: 2 additions & 1 deletion components/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* Class ErrorHandler
*
* @package yii2mod\cron\components
*/
class ErrorHandler extends \yii\console\ErrorHandler
Expand Down Expand Up @@ -36,4 +37,4 @@ public function logException($exception)
}
\Yii::error((string)$exception, $category);
}
}
}
35 changes: 21 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,32 @@
"name": "yii2mod/yii2-cron-log",
"description": "Component for logging cron jobs",
"type": "yii2-extension",
"keywords": ["yii2 cron log", "cron log", "logging cron jobs"],
"keywords": [
"yii2 cron log",
"cron log",
"logging cron jobs"
],
"license": "MIT",
"authors": [
{
"name": "Dmitry Semenov",
"email": "disemx@gmail.com"
},
{
"name": "Igor Chepurnoy",
"email": "igorzfort@gmail.com"
}
{
"name": "Dmitry Semenov",
"email": "disemx@gmail.com"
},
{
"name": "Igor Chepurnoy",
"email": "igorzfort@gmail.com"
}
],
"require": {
"yiisoft/yii2": ">=2.0.8",
"yii2mod/yii2-enum": ">=1.1"
"yiisoft/yii2": ">=2.0.8",
"yii2mod/yii2-enum": ">=1.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.7"
},
"autoload": {
"psr-4": {
"yii2mod\\cron\\": ""
}
"psr-4": {
"yii2mod\\cron\\": ""
}
}
}
2 changes: 1 addition & 1 deletion messages/en/yii2mod-cron-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
'Status' => 'Status',
'Success' => 'Success',
'Error' => 'Error',
'Run' => 'Run'
'Run' => 'Run',
];
2 changes: 1 addition & 1 deletion messages/ru/yii2mod-cron-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
'Status' => 'Статус',
'Success' => 'Успешное завершение',
'Error' => 'Ошибка',
'Run' => 'Выполняется'
'Run' => 'Выполняется',
];
5 changes: 3 additions & 2 deletions models/CronScheduleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function attributeLabels()
* @param string $jobCode
* @param int $status
* @param null $messages
*
* @return bool
*/
public function startCronSchedule($jobCode, $status = CronScheduleStatus::RUN, $messages = null)
Expand All @@ -78,7 +79,7 @@ public function startCronSchedule($jobCode, $status = CronScheduleStatus::RUN, $
* @param string $status
* @param null $messages
*
* @return boolean
* @return bool
*/
public function endCronSchedule($status, $messages = null)
{
Expand All @@ -92,4 +93,4 @@ public function endCronSchedule($status, $messages = null)

return false;
}
}
}
5 changes: 3 additions & 2 deletions models/enumerables/CronScheduleStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* Class CronScheduleStatus
*
* @package yii2mod\cron\models\enumerables
*/
class CronScheduleStatus extends BaseEnum
Expand All @@ -25,6 +26,6 @@ class CronScheduleStatus extends BaseEnum
public static $list = [
self::SUCCESS => 'Success',
self::ERROR => 'Error',
self::RUN => 'Run'
self::RUN => 'Run',
];
}
}
9 changes: 5 additions & 4 deletions models/search/CronScheduleSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

/**
* Class CronScheduleSearch
*
* @package yii2mod\cron\models\search
*/
class CronScheduleSearch extends CronScheduleModel
{
/**
* @var int the default page size.
* @var int the default page size
*/
public $pageSize = 25;

Expand Down Expand Up @@ -41,8 +42,8 @@ public function search($params)
'query' => $query,
'sort' => ['defaultOrder' => ['id' => SORT_DESC]],
'pagination' => [
'pageSize' => $this->pageSize
]
'pageSize' => $this->pageSize,
],
]);

if (!($this->load($params) && $this->validate())) {
Expand All @@ -56,4 +57,4 @@ public function search($params)

return $dataProvider;
}
}
}
3 changes: 2 additions & 1 deletion tests/CronLoggerBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* Class CronLoggerBehaviorTest
*
* @package yii2mod\cron\tests
*/
class CronLoggerBehaviorTest extends TestCase
Expand All @@ -20,4 +21,4 @@ public function testCronLog()
$this->assertNotEmpty($cronScheduleModel, 'Cron log is empty!');
$this->assertEquals(Controller::EXIT_CODE_NORMAL, $cronScheduleModel->status, 'Invalid cron status!');
}
}
}

0 comments on commit 42d0543

Please sign in to comment.