Skip to content

Commit

Permalink
[minor] fixcs
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Jun 4, 2020
1 parent 76636e5 commit a7cce5e
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 150 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ return PhpCsFixer\Config::create()
'allow_unused_params' => true,
'remove_inheritdoc' => true,
],
'function_declaration' => ['closure_function_spacing' => 'none'],
))
->setRiskyAllowed(true)
->setFinder($finder)
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private function renderDefinitionList(SymfonyStyle $io, array $list): void
}

$io->listing(\array_map(
function (array $line) {
function(array $line) {
return \sprintf('<info>%s:</info> %s', \array_keys($line)[0], \array_values($line)[0]);
},
$list
Expand Down Expand Up @@ -186,7 +186,7 @@ private function renderExtenstions(SymfonyStyle $io, string $type, array $extens

$io->comment(\sprintf('<info>%d</info> %s Extension%s:', $count, $type, $count > 1 ? 's' : ''));
$io->listing(\array_map(
function (object $extension) {
function(object $extension) {
if (\method_exists($extension, '__toString')) {
return \sprintf('%s <comment>(%s)</comment>',
\strtr($extension, self::extensionHighlightMap()),
Expand Down
14 changes: 7 additions & 7 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static function taskConfiguration(): ArrayNodeDefinition
])
->arrayPrototype()
->validate()
->ifTrue(function ($v) {
->ifTrue(function($v) {
return [null] === $v['task'] && !$v['description'];
})
->thenInvalid('"null" tasks must have a description.')
Expand All @@ -129,7 +129,7 @@ private static function taskConfiguration(): ArrayNodeDefinition
->info('Defaults to CommandTask, prefix with "bash:" to create ProcessTask, prefix url with "ping:" to create PingTask, pass array of commands to create CompoundTask (optionally keyed by description)')
->example('"my:command arg1 --option1=value", "bash:/bin/my-script" or "ping:https://example.com"')
->validate()
->ifTrue(function ($v) {
->ifTrue(function($v) {
foreach ($v as $item) {
if ('' === (string) $item) {
return true;
Expand All @@ -153,7 +153,7 @@ private static function taskConfiguration(): ArrayNodeDefinition
->isRequired()
->cannotBeEmpty()
->validate()
->ifTrue(function ($v) {
->ifTrue(function($v) {
try {
new CronExpression($v, 'context');
} catch (\InvalidArgumentException $e) {
Expand Down Expand Up @@ -193,7 +193,7 @@ private static function taskConfiguration(): ArrayNodeDefinition
->canBeEnabled()
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(function($v) {
[$start, $end] = \explode('-', $v);

return [
Expand All @@ -219,7 +219,7 @@ private static function taskConfiguration(): ArrayNodeDefinition
->canBeEnabled()
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(function($v) {
[$start, $end] = \explode('-', $v);

return [
Expand Down Expand Up @@ -263,7 +263,7 @@ private static function createEmailExtension(string $name, string $description):
->canBeEnabled()
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(function($v) {
return [
'enabled' => true,
'to' => $v,
Expand Down Expand Up @@ -296,7 +296,7 @@ private static function createPingExtension(string $name, string $description):
->canBeEnabled()
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(function($v) {
return [
'enabled' => true,
'url' => $v,
Expand Down
10 changes: 5 additions & 5 deletions src/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class Schedule
public function getId(): string
{
$tasks = \array_map(
function (Task $task) {
function(Task $task) {
return $task->getId();
},
$this->all()
Expand Down Expand Up @@ -101,11 +101,11 @@ public function filter(callable $callback): self
*/
public function when(string $description, $callback): self
{
$callback = \is_callable($callback) ? $callback : function () use ($callback) {
$callback = \is_callable($callback) ? $callback : function() use ($callback) {
return (bool) $callback;
};

return $this->filter(function (ScheduleRunContext $context) use ($callback, $description) {
return $this->filter(function(ScheduleRunContext $context) use ($callback, $description) {
if (!$callback($context)) {
throw new SkipSchedule($description);
}
Expand All @@ -120,11 +120,11 @@ public function when(string $description, $callback): self
*/
public function skip(string $description, $callback): self
{
$callback = \is_callable($callback) ? $callback : function () use ($callback) {
$callback = \is_callable($callback) ? $callback : function() use ($callback) {
return (bool) $callback;
};

return $this->filter(function (ScheduleRunContext $context) use ($callback, $description) {
return $this->filter(function(ScheduleRunContext $context) use ($callback, $description) {
if ($callback($context)) {
throw new SkipSchedule($description);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Schedule/Extension/EmailExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __toString(): string
return "{$this->hook}, email output";
}

$to = \array_map(function (Address $address) { return $address->toString(); }, $to);
$to = \array_map(function(Address $address) { return $address->toString(); }, $to);
$to = \implode('; ', $to);

return "{$this->hook}, email output to \"{$to}\"";
Expand Down
2 changes: 1 addition & 1 deletion src/Schedule/ScheduleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function createRunContext(array $taskIds): ScheduleRunContext
{
$schedule = $this->buildSchedule();

$tasks = \array_map(function (string $id) use ($schedule) {
$tasks = \array_map(function(string $id) use ($schedule) {
return $schedule->getTask($id);
}, $taskIds);

Expand Down
8 changes: 4 additions & 4 deletions src/Schedule/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ final public function filter(callable $callback): self
*/
final public function when(string $description, $callback): self
{
$callback = \is_callable($callback) ? $callback : function () use ($callback) {
$callback = \is_callable($callback) ? $callback : function() use ($callback) {
return (bool) $callback;
};

return $this->filter(function (TaskRunContext $context) use ($callback, $description) {
return $this->filter(function(TaskRunContext $context) use ($callback, $description) {
if (!$callback($context)) {
throw new SkipTask($description);
}
Expand All @@ -144,11 +144,11 @@ final public function when(string $description, $callback): self
*/
final public function skip(string $description, $callback): self
{
$callback = \is_callable($callback) ? $callback : function () use ($callback) {
$callback = \is_callable($callback) ? $callback : function() use ($callback) {
return (bool) $callback;
};

return $this->filter(function (TaskRunContext $context) use ($callback, $description) {
return $this->filter(function(TaskRunContext $context) use ($callback, $description) {
if ($callback($context)) {
throw new SkipTask($description);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/EventListener/ScheduleLoggerSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function run_schedule_that_skips()
{
$context = $this->createRunnerBuilder()
->addTask(new MockTask())
->addExtension(CallbackExtension::scheduleFilter(function () {
->addExtension(CallbackExtension::scheduleFilter(function() {
throw new SkipSchedule('the schedule has skipped');
}))
->run()
Expand Down
6 changes: 3 additions & 3 deletions tests/Schedule/Extension/EmailExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function sends_schedule_failure_email_with_overrides()
->addBuilder(new class() implements ScheduleBuilder {
public function buildSchedule(Schedule $schedule): void
{
$schedule->emailOnFailure('[email protected]', 'my subject', function (Email $email) {
$schedule->emailOnFailure('[email protected]', 'my subject', function(Email $email) {
$email->cc('[email protected]');
});
}
Expand Down Expand Up @@ -139,7 +139,7 @@ public function sends_task_failure_email_with_overrides()
(new MockScheduleBuilder())
->addHandler(new EmailHandler($mailer, '[email protected]', '[email protected]'))
->addTask(MockTask::failure('Exit 127: Command not found', 'my task', 'sh: 1: sdsdsd: not found')
->emailOnFailure('[email protected]', 'my subject', function (Email $email) {
->emailOnFailure('[email protected]', 'my subject', function(Email $email) {
$email->cc('[email protected]');
})
)
Expand Down Expand Up @@ -201,7 +201,7 @@ public function sends_after_task_email_with_overrides()
(new MockScheduleBuilder())
->addHandler(new EmailHandler($mailer, '[email protected]', '[email protected]'))
->addTask(MockTask::success('my task', 'my task output')
->emailAfter('[email protected]', 'my subject', function (Email $email) {
->emailAfter('[email protected]', 'my subject', function(Email $email) {
$email->cc('[email protected]');
})
)
Expand Down
66 changes: 33 additions & 33 deletions tests/Schedule/Extension/ScheduleCallbackHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ScheduleCallbackHandlerTest extends TestCase
*/
public function false_when_filter_skips_schedule()
{
$context = self::createBuilder(function (Schedule $schedule) {
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->when('boolean value', false);
})->run();

Expand All @@ -32,8 +32,8 @@ public function false_when_filter_skips_schedule()
*/
public function callback_returning_false_when_filter_skips_schedule()
{
$context = self::createBuilder(function (Schedule $schedule) {
$schedule->when('callback value', function () { return false; });
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->when('callback value', function() { return false; });
})->run();

$this->assertFalse($context->hasRun());
Expand All @@ -46,7 +46,7 @@ public function callback_returning_false_when_filter_skips_schedule()
*/
public function true_when_filter_allows_schedule_to_run()
{
$context = self::createBuilder(function (Schedule $schedule) {
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->when('boolean value', true);
})->run();

Expand All @@ -59,8 +59,8 @@ public function true_when_filter_allows_schedule_to_run()
*/
public function callback_returning_true_when_filter_allows_schedule_to_run()
{
$context = self::createBuilder(function (Schedule $schedule) {
$schedule->when('callback value', function () { return true; });
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->when('callback value', function() { return true; });
})->run();

$this->assertTrue($context->hasRun());
Expand All @@ -72,7 +72,7 @@ public function callback_returning_true_when_filter_allows_schedule_to_run()
*/
public function true_skip_filter_skips_schedule()
{
$context = self::createBuilder(function (Schedule $schedule) {
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->skip('boolean value', true);
})->run();

Expand All @@ -86,8 +86,8 @@ public function true_skip_filter_skips_schedule()
*/
public function callback_returning_true_skip_filter_skips_schedule()
{
$context = self::createBuilder(function (Schedule $schedule) {
$schedule->skip('callback value', function () { return true; });
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->skip('callback value', function() { return true; });
})->run();

$this->assertFalse($context->hasRun());
Expand All @@ -100,7 +100,7 @@ public function callback_returning_true_skip_filter_skips_schedule()
*/
public function false_skip_filter_allows_schedule_to_run()
{
$context = self::createBuilder(function (Schedule $schedule) {
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->skip('boolean value', false);
})->run();

Expand All @@ -113,8 +113,8 @@ public function false_skip_filter_allows_schedule_to_run()
*/
public function callback_returning_false_skip_filter_allows_schedule_to_run()
{
$context = self::createBuilder(function (Schedule $schedule) {
$schedule->skip('callback value', function () { return false; });
$context = self::createBuilder(function(Schedule $schedule) {
$schedule->skip('callback value', function() { return false; });
})->run();

$this->assertTrue($context->hasRun());
Expand All @@ -128,13 +128,13 @@ public function no_due_tasks_calls_runs_proper_callbacks()
{
$calls = [];

self::createBuilder(function (Schedule $schedule) use (&$calls) {
$schedule->filter(function () use (&$calls) { $calls[] = 'filter'; });
$schedule->before(function () use (&$calls) { $calls[] = 'before'; });
$schedule->after(function () use (&$calls) { $calls[] = 'after'; });
$schedule->then(function () use (&$calls) { $calls[] = 'then'; });
$schedule->onSuccess(function () use (&$calls) { $calls[] = 'onSuccess'; });
$schedule->onFailure(function () use (&$calls) { $calls[] = 'onFailure'; });
self::createBuilder(function(Schedule $schedule) use (&$calls) {
$schedule->filter(function() use (&$calls) { $calls[] = 'filter'; });
$schedule->before(function() use (&$calls) { $calls[] = 'before'; });
$schedule->after(function() use (&$calls) { $calls[] = 'after'; });
$schedule->then(function() use (&$calls) { $calls[] = 'then'; });
$schedule->onSuccess(function() use (&$calls) { $calls[] = 'onSuccess'; });
$schedule->onFailure(function() use (&$calls) { $calls[] = 'onFailure'; });
})->run();

$this->assertSame([
Expand All @@ -153,13 +153,13 @@ public function all_successful_tasks_calls_runs_proper_callbacks()
{
$calls = [];

self::createBuilder(function (Schedule $schedule) use (&$calls) {
$schedule->filter(function () use (&$calls) { $calls[] = 'filter'; });
$schedule->before(function () use (&$calls) { $calls[] = 'before'; });
$schedule->after(function () use (&$calls) { $calls[] = 'after'; });
$schedule->then(function () use (&$calls) { $calls[] = 'then'; });
$schedule->onSuccess(function () use (&$calls) { $calls[] = 'onSuccess'; });
$schedule->onFailure(function () use (&$calls) { $calls[] = 'onFailure'; });
self::createBuilder(function(Schedule $schedule) use (&$calls) {
$schedule->filter(function() use (&$calls) { $calls[] = 'filter'; });
$schedule->before(function() use (&$calls) { $calls[] = 'before'; });
$schedule->after(function() use (&$calls) { $calls[] = 'after'; });
$schedule->then(function() use (&$calls) { $calls[] = 'then'; });
$schedule->onSuccess(function() use (&$calls) { $calls[] = 'onSuccess'; });
$schedule->onFailure(function() use (&$calls) { $calls[] = 'onFailure'; });
})->addTask(MockTask::success())->run();

$this->assertSame([
Expand All @@ -178,13 +178,13 @@ public function single_failed_task_calls_runs_proper_callbacks()
{
$calls = [];

self::createBuilder(function (Schedule $schedule) use (&$calls) {
$schedule->filter(function () use (&$calls) { $calls[] = 'filter'; });
$schedule->before(function () use (&$calls) { $calls[] = 'before'; });
$schedule->after(function () use (&$calls) { $calls[] = 'after'; });
$schedule->then(function () use (&$calls) { $calls[] = 'then'; });
$schedule->onSuccess(function () use (&$calls) { $calls[] = 'onSuccess'; });
$schedule->onFailure(function () use (&$calls) { $calls[] = 'onFailure'; });
self::createBuilder(function(Schedule $schedule) use (&$calls) {
$schedule->filter(function() use (&$calls) { $calls[] = 'filter'; });
$schedule->before(function() use (&$calls) { $calls[] = 'before'; });
$schedule->after(function() use (&$calls) { $calls[] = 'after'; });
$schedule->then(function() use (&$calls) { $calls[] = 'then'; });
$schedule->onSuccess(function() use (&$calls) { $calls[] = 'onSuccess'; });
$schedule->onFailure(function() use (&$calls) { $calls[] = 'onFailure'; });
})->addTask(MockTask::success())->addTask(MockTask::failure())->run();

$this->assertSame([
Expand Down
Loading

0 comments on commit a7cce5e

Please sign in to comment.