Skip to content

Commit c915a76

Browse files
committed
[TASK] Make implicit nullable param to explicit
Applied rule: Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector Resolves: #806
1 parent 8f3d079 commit c915a76

File tree

9 files changed

+30
-24
lines changed

9 files changed

+30
-24
lines changed

rector.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
*/
1111

1212
use Rector\Config\RectorConfig;
13+
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
1314
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
1415
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector;
1516
use Rector\PHPUnit\Set\PHPUnitSetList;
1617
use Rector\Set\ValueObject\LevelSetList;
18+
use Rector\ValueObject\PhpVersion;
1719

1820
return static function (RectorConfig $rectorConfig): void {
1921
$rectorConfig->importNames();
@@ -32,4 +34,8 @@
3234
PHPUnitSetList::PHPUNIT_90,
3335
LevelSetList::UP_TO_PHP_74,
3436
]);
37+
$rectorConfig->rules([
38+
ExplicitNullableParamTypeRector::class,
39+
]);
40+
$rectorConfig->phpVersion(PhpVersion::PHP_84);
3541
};

src/Cli/Symfony/ConsoleApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(FactoryInterface $factory, OutputInterface $output,
3232
$this->output = $output;
3333
}
3434

35-
public function run(InputInterface $input = null, OutputInterface $output = null): int
35+
public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
3636
{
3737
return parent::run($input, $this->output);
3838
}

src/Domain/Clock/ClockInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface ClockInterface
1515
{
1616
public function currentTime(): int;
1717

18-
public function stringToTime(string $string, int $time = null): int;
18+
public function stringToTime(string $string, ?int $time = null): int;
1919

2020
public function createTimestampFromFormat(string $format, string $time): int;
2121
}

src/Domain/Clock/SystemClock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function currentTime(): int
2020
return time();
2121
}
2222

23-
public function stringToTime(string $string, int $time = null): int
23+
public function stringToTime(string $string, ?int $time = null): int
2424
{
2525
$time ??= $this->currentTime();
2626
$timestamp = strtotime($string, $time);

src/Domain/Model/Deployment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Deployment implements LoggerAwareInterface
101101
private string $deploymentLockIdentifier;
102102
private ContainerInterface $container;
103103

104-
public function __construct(ContainerInterface $container, string $name, string $deploymentLockIdentifier = null)
104+
public function __construct(ContainerInterface $container, string $name, ?string $deploymentLockIdentifier = null)
105105
{
106106
$this->container = $container;
107107
$this->name = $name;

src/Domain/Model/Workflow.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ abstract public function getName(): string;
5151
/**
5252
* Remove the given task from all stages and applications
5353
*/
54-
public function removeTask(string $removeTask, Application $application = null): self
54+
public function removeTask(string $removeTask, ?Application $application = null): self
5555
{
5656
$removeApplicationName = $application instanceof Application ? $application->getName() : null;
5757

@@ -111,7 +111,7 @@ public function forStage(string $stage, $tasks): self
111111
* @param string $stage The name of the stage when this task shall be executed
112112
* @param string $step A stage has three steps "before", "tasks" and "after"
113113
*/
114-
protected function addTaskToStage($tasks, string $stage, Application $application = null, string $step = 'tasks'): void
114+
protected function addTaskToStage($tasks, string $stage, ?Application $application = null, string $step = 'tasks'): void
115115
{
116116
if (!is_array($tasks)) {
117117
$tasks = [$tasks];
@@ -137,7 +137,7 @@ protected function addTaskToStage($tasks, string $stage, Application $applicatio
137137
*
138138
* @return Workflow
139139
*/
140-
public function addTask($tasks, string $stage, Application $application = null)
140+
public function addTask($tasks, string $stage, ?Application $application = null)
141141
{
142142
$this->addTaskToStage($tasks, $stage, $application);
143143

@@ -151,7 +151,7 @@ public function addTask($tasks, string $stage, Application $application = null)
151151
*
152152
* @param array<int, class-string|string>|string $tasks
153153
*/
154-
public function afterTask(string $task, $tasks, Application $application = null): self
154+
public function afterTask(string $task, $tasks, ?Application $application = null): self
155155
{
156156
if (!is_array($tasks)) {
157157
$tasks = [$tasks];
@@ -174,7 +174,7 @@ public function afterTask(string $task, $tasks, Application $application = null)
174174
*
175175
* @param array<int, class-string|string>|string $tasks
176176
*/
177-
public function beforeTask(string $task, $tasks, Application $application = null): self
177+
public function beforeTask(string $task, $tasks, ?Application $application = null): self
178178
{
179179
if (!is_array($tasks)) {
180180
$tasks = [$tasks];
@@ -209,7 +209,7 @@ public function defineTask(string $taskName, string $baseTask, array $options):
209209
*
210210
* @param class-string[]|string $tasks
211211
*/
212-
public function beforeStage(string $stage, $tasks, Application $application = null): self
212+
public function beforeStage(string $stage, $tasks, ?Application $application = null): self
213213
{
214214
$this->addTaskToStage($tasks, $stage, $application, 'before');
215215

@@ -221,7 +221,7 @@ public function beforeStage(string $stage, $tasks, Application $application = nu
221221
*
222222
* @param class-string[]|string $tasks
223223
*/
224-
public function afterStage(string $stage, $tasks, Application $application = null): self
224+
public function afterStage(string $stage, $tasks, ?Application $application = null): self
225225
{
226226
$this->addTaskToStage($tasks, $stage, $application, 'after');
227227

src/Integration/Factory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(ContainerInterface $container, FilesystemInterface $
4040
$this->logger = $logger;
4141
}
4242

43-
public function getDeployment(string $deploymentName, string $configurationPath = null, bool $simulateDeployment = true, bool $initialize = true, bool $forceDeployment = false): Deployment
43+
public function getDeployment(string $deploymentName, ?string $configurationPath = null, bool $simulateDeployment = true, bool $initialize = true, bool $forceDeployment = false): Deployment
4444
{
4545
$deployment = $this->createDeployment($deploymentName, $configurationPath);
4646

@@ -65,7 +65,7 @@ public function getDeployment(string $deploymentName, string $configurationPath
6565
/**
6666
* @inheritDoc
6767
*/
68-
public function getDeploymentNames(string $path = null): array
68+
public function getDeploymentNames(?string $path = null): array
6969
{
7070
$path = $this->getDeploymentsBasePath($path);
7171
$files = $this->filesystem->glob(Files::concatenatePaths([$path, '*.php']));
@@ -76,7 +76,7 @@ public function getDeploymentNames(string $path = null): array
7676
/**
7777
* @inheritDoc
7878
*/
79-
public function getDeploymentsBasePath(string $path = null): string
79+
public function getDeploymentsBasePath(?string $path = null): string
8080
{
8181
$localDeploymentDescription = $this->filesystem->getRealPath('./.surf');
8282
if (! $path && $this->filesystem->isDirectory($localDeploymentDescription)) {
@@ -91,7 +91,7 @@ public function getDeploymentsBasePath(string $path = null): string
9191
/**
9292
* @inheritDoc
9393
*/
94-
public function getWorkspacesBasePath(string $path = null): string
94+
public function getWorkspacesBasePath(?string $path = null): string
9595
{
9696
$workspacesBasePath = getenv('SURF_WORKSPACE');
9797

@@ -124,7 +124,7 @@ public function getWorkspacesBasePath(string $path = null): string
124124
* The script has access to a deployment object as "$deployment". This could change
125125
* in the future.
126126
*/
127-
protected function createDeployment(string $deploymentName, string $path = null): Deployment
127+
protected function createDeployment(string $deploymentName, ?string $path = null): Deployment
128128
{
129129
$deploymentConfigurationPath = $this->getDeploymentsBasePath($path);
130130
$workspacesBasePath = $this->getWorkspacesBasePath();

src/Integration/FactoryInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
interface FactoryInterface
1717
{
18-
public function getDeployment(string $deploymentName, string $configurationPath = null, bool $simulateDeployment = true, bool $initialize = true, bool $forceDeployment = false): Deployment;
18+
public function getDeployment(string $deploymentName, ?string $configurationPath = null, bool $simulateDeployment = true, bool $initialize = true, bool $forceDeployment = false): Deployment;
1919

2020
/**
2121
* Get available deployment names
@@ -24,17 +24,17 @@ public function getDeployment(string $deploymentName, string $configurationPath
2424
*
2525
* @return string[]
2626
*/
27-
public function getDeploymentNames(string $path = null): array;
27+
public function getDeploymentNames(?string $path = null): array;
2828

2929
/**
3030
* Get the root path of the surf deployment declarations
3131
*
3232
* This defaults to ./.surf if a NULL path is given.
3333
*/
34-
public function getDeploymentsBasePath(string $path = null): string;
34+
public function getDeploymentsBasePath(?string $path = null): string;
3535

3636
/**
3737
* Get the base path to local workspaces
3838
*/
39-
public function getWorkspacesBasePath(string $path = null): string;
39+
public function getWorkspacesBasePath(?string $path = null): string;
4040
}

tests/Unit/Domain/Service/ShellCommandServiceTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class ShellCommandServiceTest extends TestCase
3434
*/
3535
public function executeRemoteCommandRespectsOptionsInSshCommand(
3636
string $expectedCommandArguments,
37-
string $username = null,
38-
string $password = null,
39-
int $port = null,
40-
string $privateKey = null
37+
?string $username = null,
38+
?string $password = null,
39+
?int $port = null,
40+
?string $privateKey = null
4141
): void {
4242
/** @var MockObject|ShellCommandService $service */
4343
$service = $this->createPartialMock(ShellCommandService::class, ['executeProcess']);

0 commit comments

Comments
 (0)