diff --git a/Application.php b/Application.php index 01b6a373d..b97d0872f 100644 --- a/Application.php +++ b/Application.php @@ -143,7 +143,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): int + public function run(?InputInterface $input = null, ?OutputInterface $output = null): int { if (\function_exists('putenv')) { @putenv('LINES='.$this->terminal->getHeight()); @@ -795,7 +795,7 @@ public function find(string $name) * * @return Command[] */ - public function all(string $namespace = null) + public function all(?string $namespace = null) { $this->init(); @@ -1177,7 +1177,7 @@ private function getAbbreviationSuggestions(array $abbrevs): string * * This method is not part of public API and should not be used directly. */ - public function extractNamespace(string $name, int $limit = null): string + public function extractNamespace(string $name, ?int $limit = null): string { $parts = explode(':', $name, -1); diff --git a/CI/GithubActionReporter.php b/CI/GithubActionReporter.php index 7e5565469..2cae6fd8b 100644 --- a/CI/GithubActionReporter.php +++ b/CI/GithubActionReporter.php @@ -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); } @@ -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); } @@ -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); diff --git a/Command/Command.php b/Command/Command.php index 704b112d1..9f9cb2f53 100644 --- a/Command/Command.php +++ b/Command/Command.php @@ -111,7 +111,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(); @@ -152,7 +152,7 @@ public function ignoreValidationErrors() /** * @return void */ - public function setApplication(Application $application = null) + public function setApplication(?Application $application = null) { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); @@ -460,7 +460,7 @@ public function getNativeDefinition(): InputDefinition * * @throws InvalidArgumentException When argument mode is not valid */ - public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = null */): static + public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = null */): static { $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : []; if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { @@ -484,7 +484,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, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static + public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : []; if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { diff --git a/Command/LazyCommand.php b/Command/LazyCommand.php index d56058221..b94da6665 100644 --- a/Command/LazyCommand.php +++ b/Command/LazyCommand.php @@ -45,7 +45,7 @@ public function ignoreValidationErrors(): void $this->getCommand()->ignoreValidationErrors(); } - public function setApplication(Application $application = null): void + public function setApplication(?Application $application = null): void { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); @@ -116,7 +116,7 @@ public function getNativeDefinition(): InputDefinition /** * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion */ - public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static + public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : []; $this->getCommand()->addArgument($name, $mode, $description, $default, $suggestedValues); @@ -127,7 +127,7 @@ public function addArgument(string $name, int $mode = null, string $description /** * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion */ - public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static + public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static { $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : []; $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues); diff --git a/Command/LockableTrait.php b/Command/LockableTrait.php index c1006a65c..cd7548f02 100644 --- a/Command/LockableTrait.php +++ b/Command/LockableTrait.php @@ -29,7 +29,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. Try running "composer require symfony/lock".'); diff --git a/Command/TraceableCommand.php b/Command/TraceableCommand.php index d8c46b7fa..9ffb68da3 100644 --- a/Command/TraceableCommand.php +++ b/Command/TraceableCommand.php @@ -134,7 +134,7 @@ public function ignoreValidationErrors(): void parent::ignoreValidationErrors(); } - public function setApplication(Application $application = null): void + public function setApplication(?Application $application = null): void { $this->command->setApplication($application); } @@ -209,14 +209,14 @@ public function getNativeDefinition(): InputDefinition return $this->command->getNativeDefinition(); } - public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []): static + public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []): static { $this->command->addArgument($name, $mode, $description, $default, $suggestedValues); return $this; } - public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []): static + public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []): static { $this->command->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues); diff --git a/DataCollector/CommandDataCollector.php b/DataCollector/CommandDataCollector.php index 16a0eadf4..45138c7dc 100644 --- a/DataCollector/CommandDataCollector.php +++ b/DataCollector/CommandDataCollector.php @@ -27,7 +27,7 @@ */ final class CommandDataCollector extends DataCollector { - public function collect(Request $request, Response $response, \Throwable $exception = null): void + public function collect(Request $request, Response $response, ?\Throwable $exception = null): void { if (!$request instanceof CliRequest) { return; diff --git a/Descriptor/ApplicationDescription.php b/Descriptor/ApplicationDescription.php index f8ed18045..ef9e8a63b 100644 --- a/Descriptor/ApplicationDescription.php +++ b/Descriptor/ApplicationDescription.php @@ -39,7 +39,7 @@ class ApplicationDescription */ private array $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; diff --git a/Descriptor/XmlDescriptor.php b/Descriptor/XmlDescriptor.php index 72580fd98..866c71856 100644 --- a/Descriptor/XmlDescriptor.php +++ b/Descriptor/XmlDescriptor.php @@ -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')); diff --git a/Event/ConsoleErrorEvent.php b/Event/ConsoleErrorEvent.php index d4a691216..7be2ff83e 100644 --- a/Event/ConsoleErrorEvent.php +++ b/Event/ConsoleErrorEvent.php @@ -25,7 +25,7 @@ final class ConsoleErrorEvent extends ConsoleEvent private \Throwable $error; private int $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); diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index 9925a5f74..c9ec24434 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -26,7 +26,7 @@ class ErrorListener implements EventSubscriberInterface { private ?LoggerInterface $logger; - public function __construct(LoggerInterface $logger = null) + public function __construct(?LoggerInterface $logger = null) { $this->logger = $logger; } diff --git a/Exception/CommandNotFoundException.php b/Exception/CommandNotFoundException.php index 1e9f1c793..541b32b23 100644 --- a/Exception/CommandNotFoundException.php +++ b/Exception/CommandNotFoundException.php @@ -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); diff --git a/Formatter/NullOutputFormatterStyle.php b/Formatter/NullOutputFormatterStyle.php index c2ce7d14c..ae23decb1 100644 --- a/Formatter/NullOutputFormatterStyle.php +++ b/Formatter/NullOutputFormatterStyle.php @@ -21,7 +21,7 @@ public function apply(string $text): string return $text; } - public function setBackground(string $color = null): void + public function setBackground(?string $color = null): void { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); @@ -29,7 +29,7 @@ public function setBackground(string $color = null): void // do nothing } - public function setForeground(string $color = null): void + public function setForeground(?string $color = null): void { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); diff --git a/Formatter/OutputFormatterStyle.php b/Formatter/OutputFormatterStyle.php index 346a474c6..21e7f5ab0 100644 --- a/Formatter/OutputFormatterStyle.php +++ b/Formatter/OutputFormatterStyle.php @@ -33,7 +33,7 @@ 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); } @@ -41,7 +41,7 @@ public function __construct(string $foreground = null, string $background = null /** * @return void */ - public function setForeground(string $color = null) + public function setForeground(?string $color = null) { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); @@ -52,7 +52,7 @@ public function setForeground(string $color = null) /** * @return void */ - public function setBackground(string $color = null) + public function setBackground(?string $color = null) { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); diff --git a/Formatter/OutputFormatterStyleStack.php b/Formatter/OutputFormatterStyleStack.php index f98c2eff7..62d2ca0e7 100644 --- a/Formatter/OutputFormatterStyleStack.php +++ b/Formatter/OutputFormatterStyleStack.php @@ -26,7 +26,7 @@ class OutputFormatterStyleStack implements ResetInterface private OutputFormatterStyleInterface $emptyStyle; - public function __construct(OutputFormatterStyleInterface $emptyStyle = null) + public function __construct(?OutputFormatterStyleInterface $emptyStyle = null) { $this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle(); $this->reset(); @@ -57,7 +57,7 @@ public function push(OutputFormatterStyleInterface $style) * * @throws InvalidArgumentException When style tags incorrectly nested */ - public function pop(OutputFormatterStyleInterface $style = null): OutputFormatterStyleInterface + public function pop(?OutputFormatterStyleInterface $style = null): OutputFormatterStyleInterface { if (!$this->styles) { return $this->emptyStyle; diff --git a/Helper/Dumper.php b/Helper/Dumper.php index 8c6a94d51..a3b8e3952 100644 --- a/Helper/Dumper.php +++ b/Helper/Dumper.php @@ -26,7 +26,7 @@ final class Dumper private ?ClonerInterface $cloner; private \Closure $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; diff --git a/Helper/Helper.php b/Helper/Helper.php index c4b3df72e..05be64787 100644 --- a/Helper/Helper.php +++ b/Helper/Helper.php @@ -26,7 +26,7 @@ abstract class Helper implements HelperInterface /** * @return void */ - public function setHelperSet(HelperSet $helperSet = null) + public function setHelperSet(?HelperSet $helperSet = null) { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); @@ -80,7 +80,7 @@ public static function length(?string $string): int /** * Returns the subset of a string, using mb_substr if it is available. */ - public static function substr(?string $string, int $from, int $length = null): string + public static function substr(?string $string, int $from, ?int $length = null): string { $string ??= ''; diff --git a/Helper/HelperSet.php b/Helper/HelperSet.php index dc5d499ca..f8c74ca2c 100644 --- a/Helper/HelperSet.php +++ b/Helper/HelperSet.php @@ -38,7 +38,7 @@ public function __construct(array $helpers = []) /** * @return void */ - public function set(HelperInterface $helper, string $alias = null) + public function set(HelperInterface $helper, ?string $alias = null) { $this->helpers[$helper->getName()] = $helper; if (null !== $alias) { diff --git a/Helper/ProcessHelper.php b/Helper/ProcessHelper.php index 26d35a1a8..3ef6f71f7 100644 --- a/Helper/ProcessHelper.php +++ b/Helper/ProcessHelper.php @@ -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, array|Process $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process + public function run(OutputInterface $output, array|Process $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".'); @@ -94,7 +94,7 @@ public function run(OutputInterface $output, array|Process $cmd, string $error = * * @see run() */ - public function mustRun(OutputInterface $output, array|Process $cmd, string $error = null, callable $callback = null): Process + public function mustRun(OutputInterface $output, array|Process $cmd, ?string $error = null, ?callable $callback = null): Process { $process = $this->run($output, $cmd, $error, $callback); @@ -108,7 +108,7 @@ public function mustRun(OutputInterface $output, array|Process $cmd, string $err /** * 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(); diff --git a/Helper/ProgressBar.php b/Helper/ProgressBar.php index 64389c4a2..f4eec051c 100644 --- a/Helper/ProgressBar.php +++ b/Helper/ProgressBar.php @@ -313,7 +313,7 @@ public function maxSecondsBetweenRedraws(float $seconds): void * * @return 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)); @@ -332,7 +332,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 * @param int $startAt The starting point of the bar (useful e.g. when resuming a previously started bar) */ - public function start(int $max = null, int $startAt = 0): void + public function start(?int $max = null, int $startAt = 0): void { $this->startTime = time(); $this->step = $startAt; diff --git a/Helper/ProgressIndicator.php b/Helper/ProgressIndicator.php index 79d47643e..92106caf6 100644 --- a/Helper/ProgressIndicator.php +++ b/Helper/ProgressIndicator.php @@ -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; diff --git a/Helper/Table.php b/Helper/Table.php index 3c189580e..a7e3fa250 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -466,7 +466,7 @@ public function render() * * +-----+-----------+-------+ */ - private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $title = null, string $titleFormat = null): void + private function renderRowSeparator(int $type = self::SEPARATOR_MID, ?string $title = null, ?string $titleFormat = null): void { if (!$count = $this->numberOfColumns) { return; @@ -531,7 +531,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): void + private function renderRow(array $row, string $cellFormat, ?string $firstCellFormat = null): void { $rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE); $columns = $this->getRowColumns($row); diff --git a/Helper/TableStyle.php b/Helper/TableStyle.php index bbad98e73..be956c109 100644 --- a/Helper/TableStyle.php +++ b/Helper/TableStyle.php @@ -88,7 +88,7 @@ public function getPaddingChar(): string * * @return $this */ - public function setHorizontalBorderChars(string $outside, string $inside = null): static + public function setHorizontalBorderChars(string $outside, ?string $inside = null): static { $this->horizontalOutsideBorderChar = $outside; $this->horizontalInsideBorderChar = $inside ?? $outside; @@ -113,7 +113,7 @@ public function setHorizontalBorderChars(string $outside, string $inside = null) * * @return $this */ - public function setVerticalBorderChars(string $outside, string $inside = null): static + public function setVerticalBorderChars(string $outside, ?string $inside = null): static { $this->verticalOutsideBorderChar = $outside; $this->verticalInsideBorderChar = $inside ?? $outside; @@ -167,7 +167,7 @@ public function getBorderChars(): array * * @return $this */ - public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): static + public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, ?string $topLeftBottom = null, ?string $topMidBottom = null, ?string $topRightBottom = null): static { $this->crossingChar = $cross; $this->crossingTopLeftChar = $topLeft; diff --git a/Input/ArgvInput.php b/Input/ArgvInput.php index 59f9217ec..ab9f28c54 100644 --- a/Input/ArgvInput.php +++ b/Input/ArgvInput.php @@ -43,7 +43,7 @@ class ArgvInput extends Input private array $tokens; private array $parsed; - public function __construct(array $argv = null, InputDefinition $definition = null) + public function __construct(?array $argv = null, ?InputDefinition $definition = null) { $argv ??= $_SERVER['argv'] ?? []; diff --git a/Input/ArrayInput.php b/Input/ArrayInput.php index 355de61dd..c1bc914ca 100644 --- a/Input/ArrayInput.php +++ b/Input/ArrayInput.php @@ -27,7 +27,7 @@ class ArrayInput extends Input { private array $parameters; - public function __construct(array $parameters, InputDefinition $definition = null) + public function __construct(array $parameters, ?InputDefinition $definition = null) { $this->parameters = $parameters; diff --git a/Input/Input.php b/Input/Input.php index c7959a6ce..1c21573bc 100644 --- a/Input/Input.php +++ b/Input/Input.php @@ -34,7 +34,7 @@ abstract class Input implements InputInterface, StreamableInputInterface protected $arguments = []; protected $interactive = true; - public function __construct(InputDefinition $definition = null) + public function __construct(?InputDefinition $definition = null) { if (null === $definition) { $this->definition = new InputDefinition(); diff --git a/Input/InputArgument.php b/Input/InputArgument.php index 5cb151488..4ef79feb7 100644 --- a/Input/InputArgument.php +++ b/Input/InputArgument.php @@ -44,7 +44,7 @@ class InputArgument * * @throws InvalidArgumentException When argument mode is not valid */ - public function __construct(string $name, int $mode = null, string $description = '', string|bool|int|float|array $default = null, \Closure|array $suggestedValues = []) + public function __construct(string $name, ?int $mode = null, string $description = '', string|bool|int|float|array|null $default = null, \Closure|array $suggestedValues = []) { if (null === $mode) { $mode = self::OPTIONAL; @@ -95,7 +95,7 @@ public function isArray(): bool * * @throws LogicException When incorrect default value is given */ - public function setDefault(string|bool|int|float|array $default = null) + public function setDefault(string|bool|int|float|array|null $default = null) { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); diff --git a/Input/InputOption.php b/Input/InputOption.php index f12ae2faf..35a144ffa 100644 --- a/Input/InputOption.php +++ b/Input/InputOption.php @@ -65,7 +65,7 @@ class InputOption * * @throws InvalidArgumentException If option mode is invalid or incompatible */ - public function __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', string|bool|int|float|array $default = null, array|\Closure $suggestedValues = []) + public function __construct(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', string|bool|int|float|array|null $default = null, array|\Closure $suggestedValues = []) { if (str_starts_with($name, '--')) { $name = substr($name, 2); @@ -181,7 +181,7 @@ public function isNegatable(): bool /** * @return void */ - public function setDefault(string|bool|int|float|array $default = null) + public function setDefault(string|bool|int|float|array|null $default = null) { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); diff --git a/Output/ConsoleOutput.php b/Output/ConsoleOutput.php index c1eb7cd14..5837e74a3 100644 --- a/Output/ConsoleOutput.php +++ b/Output/ConsoleOutput.php @@ -37,7 +37,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ - public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) + public function __construct(int $verbosity = self::VERBOSITY_NORMAL, ?bool $decorated = null, ?OutputFormatterInterface $formatter = null) { parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); diff --git a/Output/ConsoleSectionOutput.php b/Output/ConsoleSectionOutput.php index 21c4a44a8..f2d7933bb 100644 --- a/Output/ConsoleSectionOutput.php +++ b/Output/ConsoleSectionOutput.php @@ -63,7 +63,7 @@ public function setMaxHeight(int $maxHeight): void * * @return void */ - public function clear(int $lines = null) + public function clear(?int $lines = null) { if (empty($this->content) || !$this->isDecorated()) { return; diff --git a/Output/Output.php b/Output/Output.php index 3a06311a8..00f481e03 100644 --- a/Output/Output.php +++ b/Output/Output.php @@ -37,7 +37,7 @@ abstract class Output implements OutputInterface * @param bool $decorated Whether to decorate messages * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ - public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) + public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, ?OutputFormatterInterface $formatter = null) { $this->verbosity = $verbosity ?? self::VERBOSITY_NORMAL; $this->formatter = $formatter ?? new OutputFormatter(); diff --git a/Output/StreamOutput.php b/Output/StreamOutput.php index 69afe6033..84bbadc05 100644 --- a/Output/StreamOutput.php +++ b/Output/StreamOutput.php @@ -40,7 +40,7 @@ class StreamOutput extends Output * * @throws InvalidArgumentException When first argument is not a real stream */ - public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) + public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, ?bool $decorated = null, ?OutputFormatterInterface $formatter = null) { if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) { throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); diff --git a/Output/TrimmedBufferOutput.php b/Output/TrimmedBufferOutput.php index b00445ece..23a2be8c3 100644 --- a/Output/TrimmedBufferOutput.php +++ b/Output/TrimmedBufferOutput.php @@ -24,7 +24,7 @@ class TrimmedBufferOutput extends Output private int $maxLength; private string $buffer = ''; - public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) + public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, ?OutputFormatterInterface $formatter = null) { if ($maxLength <= 0) { throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength)); diff --git a/Question/Question.php b/Question/Question.php index 26896bb53..94c688fa8 100644 --- a/Question/Question.php +++ b/Question/Question.php @@ -36,7 +36,7 @@ class Question * @param string $question The question to ask to the user * @param string|bool|int|float|null $default The default answer to return if the user enters nothing */ - public function __construct(string $question, string|bool|int|float $default = null) + public function __construct(string $question, string|bool|int|float|null $default = null) { $this->question = $question; $this->default = $default; @@ -175,7 +175,7 @@ public function getAutocompleterCallback(): ?callable * * @return $this */ - public function setAutocompleterCallback(callable $callback = null): static + public function setAutocompleterCallback(?callable $callback = null): static { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); @@ -194,7 +194,7 @@ public function setAutocompleterCallback(callable $callback = null): static * * @return $this */ - public function setValidator(callable $validator = null): static + public function setValidator(?callable $validator = null): static { if (1 > \func_num_args()) { trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); diff --git a/SingleCommandApplication.php b/SingleCommandApplication.php index 4f0b5ba3c..ff1c17247 100644 --- a/SingleCommandApplication.php +++ b/SingleCommandApplication.php @@ -46,7 +46,7 @@ public function setAutoExit(bool $autoExit): static return $this; } - public function run(InputInterface $input = null, OutputInterface $output = null): int + public function run(?InputInterface $input = null, ?OutputInterface $output = null): int { if ($this->running) { return parent::run($input, $output); diff --git a/Style/StyleInterface.php b/Style/StyleInterface.php index e25a65bd2..6bced158a 100644 --- a/Style/StyleInterface.php +++ b/Style/StyleInterface.php @@ -91,12 +91,12 @@ public function table(array $headers, array $rows); /** * Asks a question. */ - public function ask(string $question, string $default = null, callable $validator = null): mixed; + public function ask(string $question, ?string $default = null, ?callable $validator = null): mixed; /** * Asks a question with the user input hidden. */ - public function askHidden(string $question, callable $validator = null): mixed; + public function askHidden(string $question, ?callable $validator = null): mixed; /** * Asks for confirmation. diff --git a/Style/SymfonyStyle.php b/Style/SymfonyStyle.php index 43d2edf5a..03bda8784 100644 --- a/Style/SymfonyStyle.php +++ b/Style/SymfonyStyle.php @@ -63,7 +63,7 @@ public function __construct(InputInterface $input, OutputInterface $output) * * @return void */ - public function block(string|array $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true) + public function block(string|array $messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true) { $messages = \is_array($messages) ? array_values($messages) : [$messages]; @@ -249,7 +249,7 @@ public function definitionList(string|array|TableSeparator ...$list) $this->horizontalTable($headers, [$row]); } - public function ask(string $question, string $default = null, callable $validator = null): mixed + public function ask(string $question, ?string $default = null, ?callable $validator = null): mixed { $question = new Question($question, $default); $question->setValidator($validator); @@ -257,7 +257,7 @@ public function ask(string $question, string $default = null, callable $validato return $this->askQuestion($question); } - public function askHidden(string $question, callable $validator = null): mixed + public function askHidden(string $question, ?callable $validator = null): mixed { $question = new Question($question); @@ -336,7 +336,7 @@ public function createProgressBar(int $max = 0): ProgressBar * * @return iterable */ - public function progressIterate(iterable $iterable, int $max = null): iterable + public function progressIterate(iterable $iterable, ?int $max = null): iterable { yield from $this->createProgressBar()->iterate($iterable, $max); @@ -456,7 +456,7 @@ private function writeBuffer(string $message, bool $newLine, int $type): void $this->bufferedOutput->write($message, $newLine, $type); } - private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array + private function createBlock(iterable $messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array { $indentLength = 0; $prefixLength = Helper::width(Helper::removeDecoration($this->getFormatter(), $prefix)); diff --git a/Tests/Formatter/OutputFormatterTest.php b/Tests/Formatter/OutputFormatterTest.php index 610522a7e..f62fa0889 100644 --- a/Tests/Formatter/OutputFormatterTest.php +++ b/Tests/Formatter/OutputFormatterTest.php @@ -162,7 +162,7 @@ public function testInlineStyle() /** * @dataProvider provideInlineStyleOptionsCases */ - public function testInlineStyleOptions(string $tag, string $expected = null, string $input = null, bool $truecolor = false) + public function testInlineStyleOptions(string $tag, ?string $expected = null, ?string $input = null, bool $truecolor = false) { if ($truecolor && 'truecolor' !== getenv('COLORTERM')) { $this->markTestSkipped('The terminal does not support true colors.'); diff --git a/Tests/Helper/HelperSetTest.php b/Tests/Helper/HelperSetTest.php index 9fbb9afca..389ee0ed3 100644 --- a/Tests/Helper/HelperSetTest.php +++ b/Tests/Helper/HelperSetTest.php @@ -87,7 +87,7 @@ public function testIteration() } } - private function getGenericMockHelper($name, HelperSet $helperset = null) + private function getGenericMockHelper($name, ?HelperSet $helperset = null) { $mock_helper = $this->createMock(HelperInterface::class); $mock_helper->expects($this->any())