Skip to content

Commit

Permalink
[minor] cs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Oct 30, 2020
1 parent 2f788a6 commit cd6bba4
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ return PhpCsFixer\Config::create()
'remove_inheritdoc' => true,
],
'function_declaration' => ['closure_function_spacing' => 'none'],
'nullable_type_declaration_for_default_null_value' => true,
))
->setRiskyAllowed(true)
->setFinder($finder)
Expand Down
2 changes: 1 addition & 1 deletion src/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function pingOnFailure(string $url, string $method = 'GET', array $option
* @param callable|null $callback Add your own headers etc
* Receives an instance of \Symfony\Component\Mime\Email
*/
public function emailOnFailure($to = null, string $subject = null, callable $callback = null): self
public function emailOnFailure($to = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->addExtension(EmailExtension::scheduleFailure($to, $subject, $callback));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Schedule/CronExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public function isHashed(): bool
return $this->getRawValue() !== $this->getParsedValue();
}

public function getNextRun(string $timezone = null): \DateTimeInterface
public function getNextRun(?string $timezone = null): \DateTimeInterface
{
return CronSchedule::factory($this->getParsedValue())->getNextRunDate('now', 0, false, $timezone);
}

public function isDue(\DateTimeInterface $timestamp, string $timezone = null): bool
public function isDue(\DateTimeInterface $timestamp, ?string $timezone = null): bool
{
return CronSchedule::factory($this->getParsedValue())->isDue($timestamp, $timezone);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Schedule/Extension/EmailExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class EmailExtension implements HasMissingDependencyMessage
/**
* @param string|Address|string[]|Address[]|null $to
*/
private function __construct(string $hook, $to = null, string $subject = null, callable $callback = null)
private function __construct(string $hook, $to = null, ?string $subject = null, ?callable $callback = null)
{
$this->hook = $hook;

Expand Down Expand Up @@ -54,17 +54,17 @@ public function __toString(): string
return "{$this->hook}, email output to \"{$to}\"";
}

public static function taskAfter($to = null, string $subject = null, callable $callback = null): self
public static function taskAfter($to = null, ?string $subject = null, ?callable $callback = null): self
{
return new self(Task::AFTER, $to, $subject, $callback);
}

public static function taskFailure($to = null, string $subject = null, callable $callback = null): self
public static function taskFailure($to = null, ?string $subject = null, ?callable $callback = null): self
{
return new self(Task::FAILURE, $to, $subject, $callback);
}

public static function scheduleFailure($to = null, string $subject = null, callable $callback = null): self
public static function scheduleFailure($to = null, ?string $subject = null, ?callable $callback = null): self
{
return new self(Schedule::FAILURE, $to, $subject, $callback);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Schedule/Extension/Handler/EmailHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class EmailHandler extends ExtensionHandler
private $defaultTo;
private $subjectPrefix;

public function __construct(MailerInterface $mailer, string $defaultFrom = null, string $defaultTo = null, string $subjectPrefix = null)
public function __construct(MailerInterface $mailer, ?string $defaultFrom = null, ?string $defaultTo = null, ?string $subjectPrefix = null)
{
$this->mailer = $mailer;
$this->defaultFrom = $defaultFrom;
Expand Down
2 changes: 1 addition & 1 deletion src/Schedule/Extension/Handler/PingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class PingHandler extends ExtensionHandler
{
private $httpClient;

public function __construct(HttpClientInterface $httpClient = null)
public function __construct(?HttpClientInterface $httpClient = null)
{
if (null === $httpClient && !\class_exists(HttpClient::class)) {
throw new MissingDependency(PingExtension::getMissingDependencyMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class WithoutOverlappingHandler extends ExtensionHandler
{
private $lockFactory;

public function __construct(LockFactory $lockFactory = null)
public function __construct(?LockFactory $lockFactory = null)
{
if (null === $lockFactory && !\class_exists(LockFactory::class)) {
throw new MissingDependency(WithoutOverlappingExtension::getMissingDependencyMessage());
Expand Down
6 changes: 3 additions & 3 deletions src/Schedule/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ final public function pingOnFailure(string $url, string $method = 'GET', array $
* @param callable|null $callback Add your own headers etc
* Receives an instance of \Symfony\Component\Mime\Email
*/
final public function emailAfter($to = null, string $subject = null, callable $callback = null): self
final public function emailAfter($to = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->addExtension(EmailExtension::taskAfter($to, $subject, $callback));
}

/**
* Alias for emailAfter().
*/
final public function thenEmail($to = null, string $subject = null, callable $callback = null): self
final public function thenEmail($to = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->emailAfter($to, $subject, $callback);
}
Expand All @@ -284,7 +284,7 @@ final public function thenEmail($to = null, string $subject = null, callable $ca
* @param callable|null $callback Add your own headers etc
* Receives an instance of \Symfony\Component\Mime\Email
*/
final public function emailOnFailure($to = null, string $subject = null, callable $callback = null): self
final public function emailOnFailure($to = null, ?string $subject = null, ?callable $callback = null): self
{
return $this->addExtension(EmailExtension::taskFailure($to, $subject, $callback));
}
Expand Down
10 changes: 5 additions & 5 deletions src/Schedule/Task/CompoundTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function add(Task $task): self
*
* @param string|null $description optional description
*/
public function addCommand(string $name, array $arguments = [], string $description = null): self
public function addCommand(string $name, array $arguments = [], ?string $description = null): self
{
return $this->addWithDescription(new CommandTask($name, ...$arguments), $description);
}
Expand All @@ -43,7 +43,7 @@ public function addCommand(string $name, array $arguments = [], string $descript
*
* @param string|null $description optional description
*/
public function addCallback(callable $callback, string $description = null): self
public function addCallback(callable $callback, ?string $description = null): self
{
return $this->addWithDescription(new CallbackTask($callback), $description);
}
Expand All @@ -53,7 +53,7 @@ public function addCallback(callable $callback, string $description = null): sel
*
* @param string|null $description optional description
*/
public function addProcess($process, string $description = null): self
public function addProcess($process, ?string $description = null): self
{
return $this->addWithDescription(new ProcessTask($process), $description);
}
Expand All @@ -63,7 +63,7 @@ public function addProcess($process, string $description = null): self
*
* @param string|null $description optional description
*/
public function addPing(string $url, string $method = 'GET', array $options = [], string $description = null): self
public function addPing(string $url, string $method = 'GET', array $options = [], ?string $description = null): self
{
return $this->addWithDescription(new PingTask($url, $method, $options), $description);
}
Expand All @@ -88,7 +88,7 @@ public function getIterator(): iterable
}
}

private function addWithDescription(Task $task, string $description = null): self
private function addWithDescription(Task $task, ?string $description = null): self
{
if ($description) {
$task->description($description);
Expand Down
6 changes: 3 additions & 3 deletions src/Schedule/Task/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ public function __toString(): string
return $this->getDescription();
}

public static function successful(Task $task, string $output = null, string $description = 'Successful'): self
public static function successful(Task $task, ?string $output = null, string $description = 'Successful'): self
{
$result = new self($task, self::SUCCESSFUL, $description);
$result->output = $output;

return $result;
}

public static function failure(Task $task, string $description, string $output = null): self
public static function failure(Task $task, string $description, ?string $output = null): self
{
$result = new self($task, self::FAILED, $description);
$result->output = $output;

return $result;
}

public static function exception(Task $task, \Throwable $exception, string $output = null, string $description = null): self
public static function exception(Task $task, \Throwable $exception, ?string $output = null, ?string $description = null): self
{
$description = $description ?: \sprintf('%s: %s', (new \ReflectionClass($exception))->getShortName(), $exception->getMessage());

Expand Down
2 changes: 1 addition & 1 deletion src/Schedule/Task/Runner/PingTaskRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class PingTaskRunner implements TaskRunner
{
private $httpClient;

public function __construct(HttpClientInterface $httpClient = null)
public function __construct(?HttpClientInterface $httpClient = null)
{
if (null === $httpClient && !\class_exists(HttpClient::class)) {
throw new MissingDependency(PingTask::getMissingDependencyMessage());
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixture/MockScheduleBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function run(string ...$taskIds): ScheduleRunContext
return $this->getRunner()(...$taskIds);
}

public function getRunner(EventDispatcherInterface $dispatcher = null): ScheduleRunner
public function getRunner(?EventDispatcherInterface $dispatcher = null): ScheduleRunner
{
$dispatcher = $dispatcher ?: new EventDispatcher();
$dispatcher->addSubscriber(new ScheduleBuilderSubscriber(\array_merge($this->builders, [$this])));
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixture/MockTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function getResult(): Result
return $this->result;
}

public static function success(string $name = 'my task', string $output = null): self
public static function success(string $name = 'my task', ?string $output = null): self
{
$task = new self($name);
$task->result = Result::successful($task, $output);

return $task;
}

public static function failure(string $description = 'failure description', string $name = 'my task', string $output = null): self
public static function failure(string $description = 'failure description', string $name = 'my task', ?string $output = null): self
{
$task = new self($name);
$task->result = Result::failure($task, $description, $output);
Expand All @@ -46,7 +46,7 @@ public static function skipped(string $description = 'skip reason', string $name
return $task;
}

public static function exception(\Throwable $e, string $name = 'my task', string $output = null): self
public static function exception(\Throwable $e, string $name = 'my task', ?string $output = null): self
{
$task = new self($name);
$task->result = Result::exception($task, $e, $output);
Expand Down
2 changes: 1 addition & 1 deletion tests/Schedule/Extension/EmailExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private function createMailer(): MailerInterface
/** @var RawMessage */
public $lastMessage;

public function send(RawMessage $message, Envelope $envelope = null): void
public function send(RawMessage $message, ?Envelope $envelope = null): void
{
$this->lastMessage = $message;
}
Expand Down

0 comments on commit cd6bba4

Please sign in to comment.