Skip to content

Commit

Permalink
up: format codes by php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 29, 2020
1 parent fddc78e commit d931822
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 13 deletions.
8 changes: 8 additions & 0 deletions src/Annotaion/Mapping/Cron.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Annotaion\Mapping;

Expand Down
8 changes: 8 additions & 0 deletions src/Annotaion/Mapping/Scheduled.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Annotaion\Mapping;

Expand Down
8 changes: 8 additions & 0 deletions src/Annotaion/Parser/CronParser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Annotaion\Parser;

Expand Down
9 changes: 8 additions & 1 deletion src/Annotaion/Parser/ScheduledParser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Annotaion\Parser;

Expand All @@ -8,7 +16,6 @@
use Swoft\Crontab\Annotaion\Mapping\Scheduled;
use Swoft\Crontab\CrontabRegister;


/**
* Class ScheduledParser
*
Expand Down
8 changes: 8 additions & 0 deletions src/AutoLoader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab;

Expand Down
12 changes: 10 additions & 2 deletions src/Crontab.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab;

Expand Down Expand Up @@ -52,7 +60,7 @@ public function init(): void
*/
public function tick(): void
{
Timer::tick($this->tickTime * 1000, function () {
Timer::tick($this->tickTime * 1000, function (): void {
// All task
$tasks = CrontabRegister::getCronTasks(time());

Expand All @@ -71,7 +79,7 @@ public function dispatch(): void
while (true) {
$task = $this->channel->pop();

Coroutine::create(function () use ($task) {
Coroutine::create(function () use ($task): void {
[$beanName, $methodName] = $task;

// Before
Expand Down
8 changes: 8 additions & 0 deletions src/CrontabContext.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab;

Expand Down
11 changes: 9 additions & 2 deletions src/CrontabEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php declare(strict_types=1);

/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab;

Expand All @@ -19,4 +26,4 @@ class CrontabEvent
* After
*/
public const AFTER_CRONTAB = 'swoft.crontab.crontab.after';
}
}
20 changes: 14 additions & 6 deletions src/CrontabExpression.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab;

Expand Down Expand Up @@ -89,7 +97,7 @@ protected static function checkCronItem(string $value, int $rangeStart, int $ran
}
if (strpos($value, '/') !== false) {
str_replace('*', '0', '$value');
list($start, $end) = explode('/', $value);
[$start, $end] = explode('/', $value);
if (!ctype_digit($start) || !ctype_digit($end)) {
return false;
}
Expand All @@ -98,7 +106,7 @@ protected static function checkCronItem(string $value, int $rangeStart, int $ran
}
}
if (strpos($value, '-') !== false) {
list($start, $end) = explode('-', $value);
[$start, $end] = explode('-', $value);
if (!ctype_digit($start) || !ctype_digit($end)) {
return false;
}
Expand Down Expand Up @@ -135,18 +143,18 @@ public static function parseCronItem(string $cronExpress): array
$maxLimit = [59, 59, 23, 31, 12, 6];
foreach ($cronItems as $k => $item) {
if ('*' === $item || '?' === $item) {
$times [$k] = $item;
$times[$k] = $item;
}
if (strpos($item, '/') !== false) {
str_replace('*', '0', '$value');
list($start, $end) = explode('/', $item);
[$start, $end] = explode('/', $item);
while ($start <= $maxLimit[$k]) {
$times [$k][] = $start;
$times[$k][] = $start;
$start += $end;
}
}
if (strpos($item, '-') !== false) {
list($start, $end) = explode('-', $item);
[$start, $end] = explode('-', $item);
$times[$k] = range($start, $end);
}
if (strpos($item, ',') !== false) {
Expand Down
15 changes: 13 additions & 2 deletions src/CrontabRegister.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab;

Expand Down Expand Up @@ -54,8 +62,11 @@ public static function registerCron(string $className, string $methodName, $objA

$cronExpression = $objAnnotation->getValue();
if (!CrontabExpression::parse($cronExpression)) {
throw new CrontabException(sprintf('`%s::%s()` `@Cron()` expression format is error', $className,
$methodName));
throw new CrontabException(sprintf(
'`%s::%s()` `@Cron()` expression format is error',
$className,
$methodName
));
}


Expand Down
8 changes: 8 additions & 0 deletions src/Exception/CrontabException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Exception;

Expand Down
8 changes: 8 additions & 0 deletions src/Listener/AfterCrontabListener.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Listener;

Expand Down
8 changes: 8 additions & 0 deletions src/Listener/BeforeCrontabListener.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Listener;

Expand Down
8 changes: 8 additions & 0 deletions src/Process/CrontabProcess.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/

namespace Swoft\Crontab\Process;

Expand Down

0 comments on commit d931822

Please sign in to comment.