Updated Rector to commit b78db9f56f9b9ae95169d37726cb6d2a2f802623

b78db9f56f Remove unused variable (#5531)
This commit is contained in:
Tomas Votruba 2024-01-31 07:59:42 +00:00
parent aace6ea006
commit b63058a821
49 changed files with 148 additions and 121 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7294e98a19531d580c3ba901c147ea0a52282595';
public const PACKAGE_VERSION = 'b78db9f56f9b9ae95169d37726cb6d2a2f802623';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-01-30 23:55:11';
public const RELEASE_DATE = '2024-01-31 07:57:26';
/**
* @var int
*/

View File

@ -24,7 +24,6 @@ final class BootstrapFilesIncluder
{
$bootstrapFiles = SimpleParameterProvider::provideArrayParameter(Option::BOOTSTRAP_FILES);
Assert::allString($bootstrapFiles);
$isLoadPHPUnitPhar = \false;
/** @var string[] $bootstrapFiles */
foreach ($bootstrapFiles as $bootstrapFile) {
if (!\is_file($bootstrapFile)) {

View File

@ -1998,17 +1998,17 @@
},
{
"name": "symfony\/console",
"version": "v6.4.2",
"version_normalized": "6.4.2.0",
"version": "v6.4.3",
"version_normalized": "6.4.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/console.git",
"reference": "0254811a143e6bc6c8deea08b589a7e68a37f625"
"reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/0254811a143e6bc6c8deea08b589a7e68a37f625",
"reference": "0254811a143e6bc6c8deea08b589a7e68a37f625",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e",
"reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e",
"shasum": ""
},
"require": {
@ -2041,7 +2041,7 @@
"symfony\/stopwatch": "^5.4|^6.0|^7.0",
"symfony\/var-dumper": "^5.4|^6.0|^7.0"
},
"time": "2023-12-10T16:15:48+00:00",
"time": "2024-01-23T14:51:35+00:00",
"type": "library",
"extra": {
"patches_applied": [
@ -2080,7 +2080,7 @@
"terminal"
],
"support": {
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.2"
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.3"
},
"funding": [
{
@ -2170,17 +2170,17 @@
},
{
"name": "symfony\/filesystem",
"version": "v6.4.0",
"version_normalized": "6.4.0.0",
"version": "v6.4.3",
"version_normalized": "6.4.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/filesystem.git",
"reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59"
"reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/filesystem\/zipball\/952a8cb588c3bc6ce76f6023000fb932f16a6e59",
"reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59",
"url": "https:\/\/api.github.com\/repos\/symfony\/filesystem\/zipball\/7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb",
"reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb",
"shasum": ""
},
"require": {
@ -2188,7 +2188,7 @@
"symfony\/polyfill-ctype": "~1.8",
"symfony\/polyfill-mbstring": "~1.8"
},
"time": "2023-07-26T17:27:13+00:00",
"time": "2024-01-23T14:51:35+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2216,7 +2216,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https:\/\/symfony.com",
"support": {
"source": "https:\/\/github.com\/symfony\/filesystem\/tree\/v6.4.0"
"source": "https:\/\/github.com\/symfony\/filesystem\/tree\/v6.4.3"
},
"funding": [
{
@ -2389,23 +2389,23 @@
},
{
"name": "symfony\/process",
"version": "v6.4.2",
"version_normalized": "6.4.2.0",
"version": "v6.4.3",
"version_normalized": "6.4.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/process.git",
"reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241"
"reference": "31642b0818bfcff85930344ef93193f8c607e0a3"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/process\/zipball\/c4b1ef0bc80533d87a2e969806172f1c2a980241",
"reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241",
"url": "https:\/\/api.github.com\/repos\/symfony\/process\/zipball\/31642b0818bfcff85930344ef93193f8c607e0a3",
"reference": "31642b0818bfcff85930344ef93193f8c607e0a3",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"time": "2023-12-22T16:42:54+00:00",
"time": "2024-01-23T14:51:35+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2433,7 +2433,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https:\/\/symfony.com",
"support": {
"source": "https:\/\/github.com\/symfony\/process\/tree\/v6.4.2"
"source": "https:\/\/github.com\/symfony\/process\/tree\/v6.4.3"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -188,7 +188,7 @@ class Application implements ResetInterface
*
* @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());
@ -720,7 +720,7 @@ class Application implements ResetInterface
*
* @return Command[]
*/
public function all(string $namespace = null)
public function all(?string $namespace = null)
{
$this->init();
if (null === $namespace) {
@ -1032,7 +1032,7 @@ class Application implements ResetInterface
*
* 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);
return \implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));

View File

@ -43,7 +43,7 @@ class GithubActionReporter
*
* @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);
}
@ -52,7 +52,7 @@ class GithubActionReporter
*
* @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);
}
@ -61,11 +61,11 @@ class GithubActionReporter
*
* @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);

View File

@ -137,7 +137,7 @@ class Command
*
* @throws LogicException When the command name is empty
*/
public function __construct(string $name = null)
public function __construct(?string $name = null)
{
$this->definition = new InputDefinition();
if (null === $name && null !== ($name = static::getDefaultName())) {
@ -170,7 +170,7 @@ class Command
/**
* @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__);
@ -452,7 +452,7 @@ class Command
* @throws InvalidArgumentException When argument mode is not valid
* @param mixed $default
*/
public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null)
{
$suggestedValues = 5 <= \func_num_args() ? \func_get_arg(4) : [];
if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) {
@ -473,10 +473,10 @@ class Command
* @return $this
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
* @param string|mixed[] $shortcut
* @param string|mixed[]|null $shortcut
* @param mixed $default
*/
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)
{
$suggestedValues = 6 <= \func_num_args() ? \func_get_arg(5) : [];
if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) {

View File

@ -42,7 +42,7 @@ final class LazyCommand extends Command
{
$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__);
@ -108,7 +108,7 @@ final class LazyCommand extends Command
* @param mixed $default
* @return static
*/
public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null)
{
$suggestedValues = 5 <= \func_num_args() ? \func_get_arg(4) : [];
$this->getCommand()->addArgument($name, $mode, $description, $default, $suggestedValues);
@ -116,11 +116,11 @@ final class LazyCommand extends Command
}
/**
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
* @param string|mixed[] $shortcut
* @param string|mixed[]|null $shortcut
* @param mixed $default
* @return static
*/
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)
{
$suggestedValues = 6 <= \func_num_args() ? \func_get_arg(5) : [];
$this->getCommand()->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues);

View File

@ -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".');

View File

@ -146,7 +146,7 @@ final class TraceableCommand extends Command implements SignalableCommandInterfa
$this->command->ignoreValidationErrors();
parent::ignoreValidationErrors();
}
public function setApplication(Application $application = null) : void
public function setApplication(?Application $application = null) : void
{
$this->command->setApplication($application);
}
@ -215,18 +215,18 @@ final class TraceableCommand extends Command implements SignalableCommandInterfa
* @param mixed $default
* @return static
*/
public function addArgument(string $name, int $mode = null, string $description = '', $default = null, $suggestedValues = [])
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
{
$this->command->addArgument($name, $mode, $description, $default, $suggestedValues);
return $this;
}
/**
* @param string|mixed[] $shortcut
* @param string|mixed[]|null $shortcut
* @param mixed[]|\Closure $suggestedValues
* @param mixed $default
* @return static
*/
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null, $suggestedValues = [])
public function addOption(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
{
$this->command->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues);
return $this;

View File

@ -25,7 +25,7 @@ use RectorPrefix202401\Symfony\Component\VarDumper\Cloner\Data;
*/
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;

View File

@ -45,7 +45,7 @@ class ApplicationDescription
* @var array<string, Command>
*/
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;

View File

@ -64,7 +64,7 @@ class XmlDescriptor extends Descriptor
}
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'));

View File

@ -27,7 +27,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);
$this->alternatives = $alternatives;

View File

@ -19,14 +19,14 @@ final class NullOutputFormatterStyle implements OutputFormatterStyleInterface
{
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__);
}
// 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__);

View File

@ -48,14 +48,14 @@ 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);
}
/**
* @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__);
@ -65,7 +65,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
/**
* @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__);

View File

@ -25,7 +25,7 @@ class OutputFormatterStyleStack implements ResetInterface
* @var \Symfony\Component\Console\Formatter\OutputFormatterStyleInterface
*/
private $emptyStyle;
public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
public function __construct(?OutputFormatterStyleInterface $emptyStyle = null)
{
$this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle();
$this->reset();
@ -53,7 +53,7 @@ class OutputFormatterStyleStack implements ResetInterface
*
* @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;

View File

@ -35,7 +35,7 @@ final class Dumper
* @var \Closure
*/
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;

View File

@ -23,7 +23,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__);
@ -69,7 +69,7 @@ abstract class Helper implements HelperInterface
/**
* 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 = $string ?? '';
if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) {

View File

@ -34,7 +34,7 @@ class HelperSet implements \IteratorAggregate
/**
* @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) {

View File

@ -30,7 +30,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".');
@ -81,7 +81,7 @@ class ProcessHelper extends Helper
*
* @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);
if (!$process->isSuccessful()) {
@ -92,7 +92,7 @@ class ProcessHelper extends Helper
/**
* 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();

View File

@ -345,7 +345,7 @@ final class ProgressBar
*
* @return iterable<TKey, TValue>
*/
public function iterate(iterable $iterable, int $max = null) : iterable
public function iterate(iterable $iterable, ?int $max = null) : iterable
{
$this->start($max ?? (\is_array($iterable) || $iterable instanceof \Countable ? \count($iterable) : 0));
foreach ($iterable as $key => $value) {
@ -360,7 +360,7 @@ final class ProgressBar
* @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;

View File

@ -63,7 +63,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;
$format = $format ?? $this->determineBestFormat();

View File

@ -431,7 +431,7 @@ class Table
*
* +-----+-----------+-------+
*/
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;
@ -487,7 +487,7 @@ class Table
*
* | 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);

View File

@ -153,7 +153,7 @@ class TableStyle
*
* @return $this
*/
public function setHorizontalBorderChars(string $outside, string $inside = null)
public function setHorizontalBorderChars(string $outside, ?string $inside = null)
{
$this->horizontalOutsideBorderChar = $outside;
$this->horizontalInsideBorderChar = $inside ?? $outside;
@ -176,7 +176,7 @@ class TableStyle
*
* @return $this
*/
public function setVerticalBorderChars(string $outside, string $inside = null)
public function setVerticalBorderChars(string $outside, ?string $inside = null)
{
$this->verticalOutsideBorderChar = $outside;
$this->verticalInsideBorderChar = $inside ?? $outside;
@ -222,7 +222,7 @@ class TableStyle
*
* @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)
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)
{
$this->crossingChar = $cross;
$this->crossingTopLeftChar = $topLeft;

View File

@ -46,7 +46,7 @@ class ArgvInput extends Input
* @var mixed[]
*/
private $parsed;
public function __construct(array $argv = null, InputDefinition $definition = null)
public function __construct(?array $argv = null, ?InputDefinition $definition = null)
{
$argv = $argv ?? $_SERVER['argv'] ?? [];
// strip the application name

View File

@ -27,7 +27,7 @@ class ArrayInput extends Input
* @var mixed[]
*/
private $parameters;
public function __construct(array $parameters, InputDefinition $definition = null)
public function __construct(array $parameters, ?InputDefinition $definition = null)
{
$this->parameters = $parameters;
parent::__construct($definition);

View File

@ -31,7 +31,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
protected $options = [];
protected $arguments = [];
protected $interactive = \true;
public function __construct(InputDefinition $definition = null)
public function __construct(?InputDefinition $definition = null)
{
if (null === $definition) {
$this->definition = new InputDefinition();

View File

@ -55,7 +55,7 @@ class InputArgument
*
* @throws InvalidArgumentException When argument mode is not valid
*/
public function __construct(string $name, int $mode = null, string $description = '', $default = null, $suggestedValues = [])
public function __construct(string $name, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
{
if (null === $mode) {
$mode = self::OPTIONAL;
@ -99,7 +99,7 @@ class InputArgument
* @return void
*
* @throws LogicException When incorrect default value is given
* @param string|bool|int|float|mixed[] $default
* @param string|bool|int|float|mixed[]|null $default
*/
public function setDefault($default = null)
{

View File

@ -75,7 +75,7 @@ class InputOption
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*/
public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null, $suggestedValues = [])
public function __construct(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
{
if (\strncmp($name, '--', \strlen('--')) === 0) {
$name = \substr($name, 2);
@ -83,7 +83,7 @@ class InputOption
if (empty($name)) {
throw new InvalidArgumentException('An option name cannot be empty.');
}
if (empty($shortcut)) {
if ('' === $shortcut || [] === $shortcut) {
$shortcut = null;
}
if (null !== $shortcut) {
@ -91,9 +91,9 @@ class InputOption
$shortcut = \implode('|', $shortcut);
}
$shortcuts = \preg_split('{(\\|)-?}', \ltrim($shortcut, '-'));
$shortcuts = \array_filter($shortcuts);
$shortcuts = \array_filter($shortcuts, 'strlen');
$shortcut = \implode('|', $shortcuts);
if (empty($shortcut)) {
if ('' === $shortcut) {
throw new InvalidArgumentException('An option shortcut cannot be empty.');
}
}
@ -174,7 +174,7 @@ class InputOption
}
/**
* @return void
* @param string|bool|int|float|mixed[] $default
* @param string|bool|int|float|mixed[]|null $default
*/
public function setDefault($default = null)
{

View File

@ -40,7 +40,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);
if (null === $formatter) {

View File

@ -72,7 +72,7 @@ class ConsoleSectionOutput extends StreamOutput
*
* @return void
*/
public function clear(int $lines = null)
public function clear(?int $lines = null)
{
if (empty($this->content) || !$this->isDecorated()) {
return;

View File

@ -40,7 +40,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();

View File

@ -37,7 +37,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.');
@ -85,9 +85,37 @@ class StreamOutput extends Output
if (isset($_SERVER['NO_COLOR']) || \false !== \getenv('NO_COLOR')) {
return \false;
}
if (!$this->isTty()) {
return \false;
}
if (\DIRECTORY_SEPARATOR === '\\' && \function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($this->stream)) {
return \true;
}
return 'Hyper' === \getenv('TERM_PROGRAM') || \false !== \getenv('ANSICON') || 'ON' === \getenv('ConEmuANSI') || \strncmp((string) \getenv('TERM'), 'xterm', \strlen('xterm')) === 0 || \stream_isatty($this->stream);
return 'Hyper' === \getenv('TERM_PROGRAM') || \false !== \getenv('ANSICON') || 'ON' === \getenv('ConEmuANSI') || \strncmp((string) \getenv('TERM'), 'xterm', \strlen('xterm')) === 0;
}
/**
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
*
* Reference: Composer\Util\Platform::isTty
* https://github.com/composer/composer
*/
private function isTty() : bool
{
// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (\in_array(\strtoupper((string) \getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], \true)) {
return \true;
}
// Modern cross-platform function, includes the fstat fallback so if it is present we trust it
if (\function_exists('stream_isatty')) {
return \stream_isatty($this->stream);
}
// Only trusting this if it is positive, otherwise prefer fstat fallback.
if (\function_exists('posix_isatty') && \posix_isatty($this->stream)) {
return \true;
}
$stat = @\fstat($this->stream);
// Check if formatted mode is S_IFCHR
return $stat ? 020000 === ($stat['mode'] & 0170000) : \false;
}
}

View File

@ -27,7 +27,7 @@ class TrimmedBufferOutput extends Output
* @var string
*/
private $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));

View File

@ -185,7 +185,7 @@ class Question
*
* @return $this
*/
public function setAutocompleterCallback(callable $callback = null)
public function setAutocompleterCallback(?callable $callback = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
@ -201,7 +201,7 @@ class Question
*
* @return $this
*/
public function setValidator(callable $validator = null)
public function setValidator(?callable $validator = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);

View File

@ -48,7 +48,7 @@ class SingleCommandApplication extends Command
$this->autoExit = $autoExit;
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);

View File

@ -87,12 +87,12 @@ interface StyleInterface
* Asks a question.
* @return mixed
*/
public function ask(string $question, string $default = null, callable $validator = null);
public function ask(string $question, ?string $default = null, ?callable $validator = null);
/**
* Asks a question with the user input hidden.
* @return mixed
*/
public function askHidden(string $question, callable $validator = null);
public function askHidden(string $question, ?callable $validator = null);
/**
* Asks for confirmation.
*/

View File

@ -76,7 +76,7 @@ class SymfonyStyle extends OutputStyle
* @return void
* @param string|mixed[] $messages
*/
public function block($messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = \false, bool $escape = \true)
public function block($messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = \false, bool $escape = \true)
{
$messages = \is_array($messages) ? \array_values($messages) : [$messages];
$this->autoPrependBlock();
@ -240,7 +240,7 @@ class SymfonyStyle extends OutputStyle
/**
* @return mixed
*/
public function ask(string $question, string $default = null, callable $validator = null)
public function ask(string $question, ?string $default = null, ?callable $validator = null)
{
$question = new Question($question, $default);
$question->setValidator($validator);
@ -249,7 +249,7 @@ class SymfonyStyle extends OutputStyle
/**
* @return mixed
*/
public function askHidden(string $question, callable $validator = null)
public function askHidden(string $question, ?callable $validator = null)
{
$question = new Question($question);
$question->setHidden(\true);
@ -321,7 +321,7 @@ class SymfonyStyle extends OutputStyle
*
* @return iterable<TKey, TValue>
*/
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);
$this->newLine(2);
@ -428,7 +428,7 @@ class SymfonyStyle extends OutputStyle
// We need to know if the last chars are PHP_EOL
$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));

View File

@ -18,7 +18,7 @@ namespace RectorPrefix202401\Symfony\Component\Filesystem\Exception;
*/
class FileNotFoundException extends IOException
{
public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null)
public function __construct(?string $message = null, int $code = 0, ?\Throwable $previous = null, ?string $path = null)
{
if (null === $message) {
if (null === $path) {

View File

@ -23,7 +23,7 @@ class IOException extends \RuntimeException implements IOExceptionInterface
* @var string|null
*/
private $path;
public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null)
public function __construct(string $message, int $code = 0, ?\Throwable $previous = null, ?string $path = null)
{
$this->path = $path;
parent::__construct($message, $code, $previous);

View File

@ -119,7 +119,7 @@ class Filesystem
* @throws IOException When touch fails
* @param string|iterable $files
*/
public function touch($files, int $time = null, int $atime = null)
public function touch($files, ?int $time = null, ?int $atime = null)
{
foreach ($this->toIterable($files) as $file) {
if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) {
@ -471,7 +471,7 @@ class Filesystem
*
* @throws IOException When file type is unknown
*/
public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = [])
public function mirror(string $originDir, string $targetDir, ?\Traversable $iterator = null, array $options = [])
{
$targetDir = \rtrim($targetDir, '/\\');
$originDir = \rtrim($originDir, '/\\');

View File

@ -223,7 +223,7 @@ final class Path
* @param string|null $extension if specified, only that extension is cut
* off (may contain leading dot)
*/
public static function getFilenameWithoutExtension(string $path, string $extension = null) : string
public static function getFilenameWithoutExtension(string $path, ?string $extension = null) : string
{
if ('' === $path) {
return '';

View File

@ -47,7 +47,7 @@ class ExecutableFinder
* @param string|null $default The default to return if no executable is found
* @param array $extraDirs Additional dirs to check into
*/
public function find(string $name, string $default = null, array $extraDirs = []) : ?string
public function find(string $name, ?string $default = null, array $extraDirs = []) : ?string
{
$dirs = \array_merge(\explode(\PATH_SEPARATOR, \getenv('PATH') ?: \getenv('Path')), $extraDirs);
$suffixes = [''];

View File

@ -37,7 +37,7 @@ class InputStream implements \IteratorAggregate
*
* @return void
*/
public function onEmpty(callable $onEmpty = null)
public function onEmpty(?callable $onEmpty = null)
{
$this->onEmpty = null !== $onEmpty ? \Closure::fromCallable($onEmpty) : null;
}

View File

@ -34,7 +34,7 @@ class PhpExecutableFinder
{
if ($php = \getenv('PHP_BINARY')) {
if (!\is_executable($php)) {
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v --';
if (\function_exists('exec') && ($php = \strtok(\exec($command . ' ' . \escapeshellarg($php)), \PHP_EOL))) {
if (!\is_executable($php)) {
return \false;

View File

@ -30,7 +30,7 @@ class PhpProcess extends Process
* @param int $timeout The timeout in seconds
* @param array|null $php Path to the PHP binary to use with any additional arguments
*/
public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
public function __construct(string $script, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null)
{
if (null === $php) {
$executableFinder = new PhpExecutableFinder();
@ -50,14 +50,14 @@ class PhpProcess extends Process
* @param mixed $input
* @return static
*/
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
{
throw new LogicException(\sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
}
/**
* @return void
*/
public function start(callable $callback = null, array $env = [])
public function start(?callable $callback = null, array $env = [])
{
if (null === $this->getCommandLine()) {
throw new RuntimeException('Unable to find the PHP executable.');

View File

@ -49,7 +49,7 @@ class PhpSubprocess extends Process
* @param int $timeout The timeout in seconds
* @param array|null $php Path to the PHP binary to use with any additional arguments
*/
public function __construct(array $command, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
public function __construct(array $command, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null)
{
if (null === $php) {
$executableFinder = new PhpExecutableFinder();
@ -69,11 +69,11 @@ class PhpSubprocess extends Process
* @param mixed $input
* @return static
*/
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
{
throw new LogicException(\sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
}
public function start(callable $callback = null, array $env = []) : void
public function start(?callable $callback = null, array $env = []) : void
{
if (null === $this->getCommandLine()) {
throw new RuntimeException('Unable to find the PHP executable.');

View File

@ -193,7 +193,7 @@ class Process implements \IteratorAggregate
*
* @throws LogicException When proc_open is not installed
*/
public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
public function __construct(array $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
{
if (!\function_exists('proc_open')) {
throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
@ -236,7 +236,7 @@ class Process implements \IteratorAggregate
* @throws LogicException When proc_open is not installed
* @return static
*/
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
{
$process = new static([], $cwd, $env, $input, $timeout);
$process->commandline = $command;
@ -288,7 +288,7 @@ class Process implements \IteratorAggregate
*
* @final
*/
public function run(callable $callback = null, array $env = []) : int
public function run(?callable $callback = null, array $env = []) : int
{
$this->start($callback, $env);
return $this->wait();
@ -305,7 +305,7 @@ class Process implements \IteratorAggregate
*
* @final
*/
public function mustRun(callable $callback = null, array $env = [])
public function mustRun(?callable $callback = null, array $env = [])
{
if (0 !== $this->run($callback, $env)) {
throw new ProcessFailedException($this);
@ -333,7 +333,7 @@ class Process implements \IteratorAggregate
* @throws RuntimeException When process is already running
* @throws LogicException In case a callback is provided and output has been disabled
*/
public function start(callable $callback = null, array $env = [])
public function start(?callable $callback = null, array $env = [])
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running.');
@ -404,7 +404,7 @@ class Process implements \IteratorAggregate
* @final
* @return static
*/
public function restart(callable $callback = null, array $env = [])
public function restart(?callable $callback = null, array $env = [])
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running.');
@ -428,7 +428,7 @@ class Process implements \IteratorAggregate
* @throws ProcessSignaledException When process stopped after receiving signal
* @throws LogicException When process is not yet started
*/
public function wait(callable $callback = null) : int
public function wait(?callable $callback = null) : int
{
$this->requireProcessIsStarted(__FUNCTION__);
$this->updateStatus(\false);
@ -829,7 +829,7 @@ class Process implements \IteratorAggregate
*
* @return int|null The exit-code of the process or null if it's not running
*/
public function stop(float $timeout = 10, int $signal = null) : ?int
public function stop(float $timeout = 10, ?int $signal = null) : ?int
{
$timeoutMicro = \microtime(\true) + $timeout;
if ($this->isRunning()) {
@ -1152,7 +1152,7 @@ class Process implements \IteratorAggregate
*
* @param callable|null $callback The user defined PHP callback
*/
protected function buildCallback(callable $callback = null) : \Closure
protected function buildCallback(?callable $callback = null) : \Closure
{
if ($this->outputDisabled) {
return function ($type, $data) use($callback) : bool {