Skip to content

Commit

Permalink
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_…
Browse files Browse the repository at this point in the history
…null_value
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
1 parent 0aff198 commit de9a8d9
Show file tree
Hide file tree
Showing 40 changed files with 69 additions and 69 deletions.
6 changes: 3 additions & 3 deletions Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent)
*
* @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}.
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
public function run(?InputInterface $input = null, ?OutputInterface $output = null)
{
if (\function_exists('putenv')) {
@putenv('LINES='.$this->terminal->getHeight());
Expand Down Expand Up @@ -778,7 +778,7 @@ public function find(string $name)
*
* @return Command[]
*/
public function all(string $namespace = null)
public function all(?string $namespace = null)
{
$this->init();

Expand Down Expand Up @@ -1147,7 +1147,7 @@ private function getAbbreviationSuggestions(array $abbrevs): string
*
* @return string
*/
public function extractNamespace(string $name, int $limit = null)
public function extractNamespace(string $name, ?int $limit = null)
{
$parts = explode(':', $name, -1);

Expand Down
8 changes: 4 additions & 4 deletions CI/GithubActionReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function isGithubActionEnvironment(): bool
*
* @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
*/
public function error(string $message, string $file = null, int $line = null, int $col = null): void
public function error(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
{
$this->log('error', $message, $file, $line, $col);
}
Expand All @@ -67,7 +67,7 @@ public function error(string $message, string $file = null, int $line = null, in
*
* @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message
*/
public function warning(string $message, string $file = null, int $line = null, int $col = null): void
public function warning(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
{
$this->log('warning', $message, $file, $line, $col);
}
Expand All @@ -77,12 +77,12 @@ public function warning(string $message, string $file = null, int $line = null,
*
* @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-a-debug-message
*/
public function debug(string $message, string $file = null, int $line = null, int $col = null): void
public function debug(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
{
$this->log('debug', $message, $file, $line, $col);
}

private function log(string $type, string $message, string $file = null, int $line = null, int $col = null): void
private function log(string $type, string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
{
// Some values must be encoded.
$message = strtr($message, self::ESCAPED_DATA);
Expand Down
8 changes: 4 additions & 4 deletions Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static function getDefaultDescription(): ?string
*
* @throws LogicException When the command name is empty
*/
public function __construct(string $name = null)
public function __construct(?string $name = null)
{
$this->definition = new InputDefinition();

Expand Down Expand Up @@ -132,7 +132,7 @@ public function ignoreValidationErrors()
$this->ignoreValidationErrors = true;
}

public function setApplication(Application $application = null)
public function setApplication(?Application $application = null)
{
$this->application = $application;
if ($application) {
Expand Down Expand Up @@ -433,7 +433,7 @@ public function getNativeDefinition()
*
* @throws InvalidArgumentException When argument mode is not valid
*/
public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null)
{
$this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
if (null !== $this->fullDefinition) {
Expand All @@ -454,7 +454,7 @@ public function addArgument(string $name, int $mode = null, string $description
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*/
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
public function addOption(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null)
{
$this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
if (null !== $this->fullDefinition) {
Expand Down
6 changes: 3 additions & 3 deletions Command/LazyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function ignoreValidationErrors(): void
$this->getCommand()->ignoreValidationErrors();
}

public function setApplication(Application $application = null): void
public function setApplication(?Application $application = null): void
{
if ($this->command instanceof parent) {
$this->command->setApplication($application);
Expand Down Expand Up @@ -117,7 +117,7 @@ public function getNativeDefinition(): InputDefinition
/**
* @return $this
*/
public function addArgument(string $name, int $mode = null, string $description = '', $default = null): self
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null): self
{
$this->getCommand()->addArgument($name, $mode, $description, $default);

Expand All @@ -127,7 +127,7 @@ public function addArgument(string $name, int $mode = null, string $description
/**
* @return $this
*/
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null): self
public function addOption(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null): self
{
$this->getCommand()->addOption($name, $shortcut, $mode, $description, $default);

Expand Down
2 changes: 1 addition & 1 deletion Command/LockableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ trait LockableTrait
/**
* Locks a command.
*/
private function lock(string $name = null, bool $blocking = false): bool
private function lock(?string $name = null, bool $blocking = false): bool
{
if (!class_exists(SemaphoreStore::class)) {
throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
Expand Down
2 changes: 1 addition & 1 deletion Descriptor/ApplicationDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ApplicationDescription
*/
private $aliases;

public function __construct(Application $application, string $namespace = null, bool $showHidden = false)
public function __construct(Application $application, ?string $namespace = null, bool $showHidden = false)
{
$this->application = $application;
$this->namespace = $namespace;
Expand Down
2 changes: 1 addition & 1 deletion Descriptor/XmlDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getCommandDocument(Command $command, bool $short = false): \DOMD
return $dom;
}

public function getApplicationDocument(Application $application, string $namespace = null, bool $short = false): \DOMDocument
public function getApplicationDocument(Application $application, ?string $namespace = null, bool $short = false): \DOMDocument
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($rootXml = $dom->createElement('symfony'));
Expand Down
2 changes: 1 addition & 1 deletion Event/ConsoleErrorEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class ConsoleErrorEvent extends ConsoleEvent
private $error;
private $exitCode;

public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, Command $command = null)
public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, ?Command $command = null)
{
parent::__construct($command, $input, $output);

Expand Down
2 changes: 1 addition & 1 deletion EventListener/ErrorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ErrorListener implements EventSubscriberInterface
{
private $logger;

public function __construct(LoggerInterface $logger = null)
public function __construct(?LoggerInterface $logger = null)
{
$this->logger = $logger;
}
Expand Down
2 changes: 1 addition & 1 deletion Exception/CommandNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce
* @param int $code Exception code
* @param \Throwable|null $previous Previous exception used for the exception chaining
*/
public function __construct(string $message, array $alternatives = [], int $code = 0, \Throwable $previous = null)
public function __construct(string $message, array $alternatives = [], int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);

Expand Down
4 changes: 2 additions & 2 deletions Formatter/NullOutputFormatterStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function apply(string $text): string
/**
* {@inheritdoc}
*/
public function setBackground(string $color = null): void
public function setBackground(?string $color = null): void
{
// do nothing
}

/**
* {@inheritdoc}
*/
public function setForeground(string $color = null): void
public function setForeground(?string $color = null): void
{
// do nothing
}
Expand Down
6 changes: 3 additions & 3 deletions Formatter/OutputFormatterStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
* @param string|null $foreground The style foreground color name
* @param string|null $background The style background color name
*/
public function __construct(string $foreground = null, string $background = null, array $options = [])
public function __construct(?string $foreground = null, ?string $background = null, array $options = [])
{
$this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options);
}

/**
* {@inheritdoc}
*/
public function setForeground(string $color = null)
public function setForeground(?string $color = null)
{
$this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options);
}

/**
* {@inheritdoc}
*/
public function setBackground(string $color = null)
public function setBackground(?string $color = null)
{
$this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options);
}
Expand Down
4 changes: 2 additions & 2 deletions Formatter/OutputFormatterStyleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ interface OutputFormatterStyleInterface
/**
* Sets style foreground color.
*/
public function setForeground(string $color = null);
public function setForeground(?string $color = null);

/**
* Sets style background color.
*/
public function setBackground(string $color = null);
public function setBackground(?string $color = null);

/**
* Sets some specific style option.
Expand Down
4 changes: 2 additions & 2 deletions Formatter/OutputFormatterStyleStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OutputFormatterStyleStack implements ResetInterface

private $emptyStyle;

public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
public function __construct(?OutputFormatterStyleInterface $emptyStyle = null)
{
$this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle();
$this->reset();
Expand Down Expand Up @@ -55,7 +55,7 @@ public function push(OutputFormatterStyleInterface $style)
*
* @throws InvalidArgumentException When style tags incorrectly nested
*/
public function pop(OutputFormatterStyleInterface $style = null)
public function pop(?OutputFormatterStyleInterface $style = null)
{
if (empty($this->styles)) {
return $this->emptyStyle;
Expand Down
2 changes: 1 addition & 1 deletion Helper/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Dumper
private $cloner;
private $handler;

public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null)
public function __construct(OutputInterface $output, ?CliDumper $dumper = null, ?ClonerInterface $cloner = null)
{
$this->output = $output;
$this->dumper = $dumper;
Expand Down
4 changes: 2 additions & 2 deletions Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class Helper implements HelperInterface
/**
* {@inheritdoc}
*/
public function setHelperSet(HelperSet $helperSet = null)
public function setHelperSet(?HelperSet $helperSet = null)
{
$this->helperSet = $helperSet;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public static function length(?string $string): int
*
* @return string
*/
public static function substr(?string $string, int $from, int $length = null)
public static function substr(?string $string, int $from, ?int $length = null)
{
$string ?? $string = '';

Expand Down
2 changes: 1 addition & 1 deletion Helper/HelperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface HelperInterface
/**
* Sets the helper set associated with this helper.
*/
public function setHelperSet(HelperSet $helperSet = null);
public function setHelperSet(?HelperSet $helperSet = null);

/**
* Gets the helper set associated with this helper.
Expand Down
4 changes: 2 additions & 2 deletions Helper/HelperSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(array $helpers = [])
}
}

public function set(HelperInterface $helper, string $alias = null)
public function set(HelperInterface $helper, ?string $alias = null)
{
$this->helpers[$helper->getName()] = $helper;
if (null !== $alias) {
Expand Down Expand Up @@ -76,7 +76,7 @@ public function get(string $name)
/**
* @deprecated since Symfony 5.4
*/
public function setCommand(Command $command = null)
public function setCommand(?Command $command = null)
{
trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);

Expand Down
6 changes: 3 additions & 3 deletions Helper/ProcessHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ProcessHelper extends Helper
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
*/
public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
public function run(OutputInterface $output, $cmd, ?string $error = null, ?callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
{
if (!class_exists(Process::class)) {
throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".');
Expand Down Expand Up @@ -98,7 +98,7 @@ public function run(OutputInterface $output, $cmd, string $error = null, callabl
*
* @see run()
*/
public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process
public function mustRun(OutputInterface $output, $cmd, ?string $error = null, ?callable $callback = null): Process
{
$process = $this->run($output, $cmd, $error, $callback);

Expand All @@ -112,7 +112,7 @@ public function mustRun(OutputInterface $output, $cmd, string $error = null, cal
/**
* Wraps a Process callback to add debugging output.
*/
public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable
public function wrapCallback(OutputInterface $output, Process $process, ?callable $callback = null): callable
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
Expand Down
4 changes: 2 additions & 2 deletions Helper/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function maxSecondsBetweenRedraws(float $seconds): void
*
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
*/
public function iterate(iterable $iterable, int $max = null): iterable
public function iterate(iterable $iterable, ?int $max = null): iterable
{
$this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));

Expand All @@ -311,7 +311,7 @@ public function iterate(iterable $iterable, int $max = null): iterable
*
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
*/
public function start(int $max = null)
public function start(?int $max = null)
{
$this->startTime = time();
$this->step = 0;
Expand Down
2 changes: 1 addition & 1 deletion Helper/ProgressIndicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ProgressIndicator
* @param int $indicatorChangeInterval Change interval in milliseconds
* @param array|null $indicatorValues Animated indicator characters
*/
public function __construct(OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null)
public function __construct(OutputInterface $output, ?string $format = null, int $indicatorChangeInterval = 100, ?array $indicatorValues = null)
{
$this->output = $output;

Expand Down
4 changes: 2 additions & 2 deletions Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public function render()
*
* +-----+-----------+-------+
*/
private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $title = null, string $titleFormat = null)
private function renderRowSeparator(int $type = self::SEPARATOR_MID, ?string $title = null, ?string $titleFormat = null)
{
if (0 === $count = $this->numberOfColumns) {
return;
Expand Down Expand Up @@ -516,7 +516,7 @@ private function renderColumnSeparator(int $type = self::BORDER_OUTSIDE): string
*
* | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
*/
private function renderRow(array $row, string $cellFormat, string $firstCellFormat = null)
private function renderRow(array $row, string $cellFormat, ?string $firstCellFormat = null)
{
$rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE);
$columns = $this->getRowColumns($row);
Expand Down

0 comments on commit de9a8d9

Please sign in to comment.