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 1759251 commit cbc28e3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ExecutableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function addSuffix(string $suffix)
*
* @return string|null
*/
public function find(string $name, string $default = null, array $extraDirs = [])
public function find(string $name, ?string $default = null, array $extraDirs = [])
{
if (\ini_get('open_basedir')) {
$searchPath = array_merge(explode(\PATH_SEPARATOR, \ini_get('open_basedir')), $extraDirs);
Expand Down
2 changes: 1 addition & 1 deletion InputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class InputStream implements \IteratorAggregate
/**
* Sets a callback that is called when the write buffer becomes empty.
*/
public function onEmpty(callable $onEmpty = null)
public function onEmpty(?callable $onEmpty = null)
{
$this->onEmpty = $onEmpty;
}
Expand Down
6 changes: 3 additions & 3 deletions PhpProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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();
Expand All @@ -53,15 +53,15 @@ public function __construct(string $script, string $cwd = null, array $env = nul
/**
* {@inheritdoc}
*/
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));
}

/**
* {@inheritdoc}
*/
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.');
Expand Down
18 changes: 9 additions & 9 deletions Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,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.');
Expand Down Expand Up @@ -189,7 +189,7 @@ public function __construct(array $command, string $cwd = null, array $env = nul
*
* @throws LogicException When proc_open is not installed
*/
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;
Expand Down Expand Up @@ -247,7 +247,7 @@ public function __clone()
*
* @final
*/
public function run(callable $callback = null, array $env = []): int
public function run(?callable $callback = null, array $env = []): int
{
$this->start($callback, $env);

Expand All @@ -266,7 +266,7 @@ public function run(callable $callback = null, array $env = []): int
*
* @final
*/
public function mustRun(callable $callback = null, array $env = []): self
public function mustRun(?callable $callback = null, array $env = []): self
{
if (0 !== $this->run($callback, $env)) {
throw new ProcessFailedException($this);
Expand Down Expand Up @@ -294,7 +294,7 @@ public function mustRun(callable $callback = null, array $env = []): self
* @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.');
Expand Down Expand Up @@ -385,7 +385,7 @@ public function start(callable $callback = null, array $env = [])
*
* @final
*/
public function restart(callable $callback = null, array $env = []): self
public function restart(?callable $callback = null, array $env = []): self
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running.');
Expand All @@ -412,7 +412,7 @@ public function restart(callable $callback = null, array $env = []): self
* @throws ProcessSignaledException When process stopped after receiving signal
* @throws LogicException When process is not yet started
*/
public function wait(callable $callback = null)
public function wait(?callable $callback = null)
{
$this->requireProcessIsStarted(__FUNCTION__);

Expand Down Expand Up @@ -914,7 +914,7 @@ public function getStatus()
*
* @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)
public function stop(float $timeout = 10, ?int $signal = null)
{
$timeoutMicro = microtime(true) + $timeout;
if ($this->isRunning()) {
Expand Down Expand Up @@ -1310,7 +1310,7 @@ private function getDescriptors(): array
*
* @return \Closure
*/
protected function buildCallback(callable $callback = null)
protected function buildCallback(?callable $callback = null)
{
if ($this->outputDisabled) {
return function ($type, $data) use ($callback): bool {
Expand Down
4 changes: 2 additions & 2 deletions Tests/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ public function testNotTerminableInputPipe()
* @param string|array $commandline
* @param mixed $input
*/
private function getProcess($commandline, string $cwd = null, array $env = null, $input = null, ?int $timeout = 60): Process
private function getProcess($commandline, ?string $cwd = null, ?array $env = null, $input = null, ?int $timeout = 60): Process
{
if (\is_string($commandline)) {
$process = Process::fromShellCommandline($commandline, $cwd, $env, $input, $timeout);
Expand All @@ -1573,7 +1573,7 @@ private function getProcess($commandline, string $cwd = null, array $env = null,
return self::$process = $process;
}

private function getProcessForCode(string $code, string $cwd = null, array $env = null, $input = null, ?int $timeout = 60): Process
private function getProcessForCode(string $code, ?string $cwd = null, ?array $env = null, $input = null, ?int $timeout = 60): Process
{
return $this->getProcess([self::$phpBin, '-r', $code], $cwd, $env, $input, $timeout);
}
Expand Down

0 comments on commit cbc28e3

Please sign in to comment.