Skip to content

Commit 6726993

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

9 files changed

Lines changed: 30 additions & 24 deletions

File tree

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
@@ -96,7 +96,7 @@ class Deployment implements LoggerAwareInterface
9696
private string $deploymentLockIdentifier;
9797
private ContainerInterface $container;
9898

99-
public function __construct(ContainerInterface $container, string $name, string $deploymentLockIdentifier = null)
99+
public function __construct(ContainerInterface $container, string $name, ?string $deploymentLockIdentifier = null)
100100
{
101101
$this->container = $container;
102102
$this->name = $name;

src/Domain/Model/Workflow.php

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

@@ -108,7 +108,7 @@ public function forStage(string $stage, $tasks): self
108108
* @param string $stage The name of the stage when this task shall be executed
109109
* @param string $step A stage has three steps "before", "tasks" and "after"
110110
*/
111-
protected function addTaskToStage($tasks, string $stage, Application $application = null, string $step = 'tasks'): void
111+
protected function addTaskToStage($tasks, string $stage, ?Application $application = null, string $step = 'tasks'): void
112112
{
113113
if (!is_array($tasks)) {
114114
$tasks = [$tasks];
@@ -134,7 +134,7 @@ protected function addTaskToStage($tasks, string $stage, Application $applicatio
134134
*
135135
* @return Workflow
136136
*/
137-
public function addTask($tasks, string $stage, Application $application = null)
137+
public function addTask($tasks, string $stage, ?Application $application = null)
138138
{
139139
$this->addTaskToStage($tasks, $stage, $application);
140140

@@ -148,7 +148,7 @@ public function addTask($tasks, string $stage, Application $application = null)
148148
*
149149
* @param array|string $tasks
150150
*/
151-
public function afterTask(string $task, $tasks, Application $application = null): self
151+
public function afterTask(string $task, $tasks, ?Application $application = null): self
152152
{
153153
if (!is_array($tasks)) {
154154
$tasks = [$tasks];
@@ -171,7 +171,7 @@ public function afterTask(string $task, $tasks, Application $application = null)
171171
*
172172
* @param array|string $tasks
173173
*/
174-
public function beforeTask(string $task, $tasks, Application $application = null): self
174+
public function beforeTask(string $task, $tasks, ?Application $application = null): self
175175
{
176176
if (!is_array($tasks)) {
177177
$tasks = [$tasks];
@@ -204,7 +204,7 @@ public function defineTask(string $taskName, string $baseTask, array $options):
204204
*
205205
* @param array|string $tasks
206206
*/
207-
public function beforeStage(string $stage, $tasks, Application $application = null): self
207+
public function beforeStage(string $stage, $tasks, ?Application $application = null): self
208208
{
209209
$this->addTaskToStage($tasks, $stage, $application, 'before');
210210

@@ -216,7 +216,7 @@ public function beforeStage(string $stage, $tasks, Application $application = nu
216216
*
217217
* @param array|string $tasks
218218
*/
219-
public function afterStage(string $stage, $tasks, Application $application = null): self
219+
public function afterStage(string $stage, $tasks, ?Application $application = null): self
220220
{
221221
$this->addTaskToStage($tasks, $stage, $application, 'after');
222222

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,24 +15,24 @@
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
2222
*
2323
* Will look up all .php files in the directory ./.surf/ or the given path if specified.
2424
*/
25-
public function getDeploymentNames(string $path = null): array;
25+
public function getDeploymentNames(?string $path = null): array;
2626

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

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

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)