Skip to content

Commit fe864f1

Browse files
committed
Add a couple of php-cs-fixer clarifications and apply them
1. Disable the 'modernize_strpos' rule. It only can be applied to PHP >=8 and we still support 7.4. Pity that the rule itself, that is part of the Symfony ruleset is not able to act conditionally based on the PHP version. 2. We want the nullability chars (?) to be explicitly declared in parameters, no matter they are superfluous if the default is null. Way better than removing the default some day and forgetting to add them. Here the Symfony ruleset sucks.
1 parent 6d62541 commit fe864f1

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

.php-cs-fixer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
->setRules([
1616
'@Symfony' => true,
1717
'@Symfony:risky' => true,
18+
# Couple of changes from Symfony defaults
19+
'modernize_strpos' => false, # TODO: Enable this once PHP8.0 is the min. req.
20+
'nullable_type_declaration_for_default_null_value' => true, # We prefer explicit typing, no matter the defaults.
21+
# We continue here.
1822
'array_syntax' => ['syntax' => 'short'],
1923
'combine_consecutive_unsets' => true,
2024
'combine_consecutive_issets' => true,

src/PluginValidate/Finder/AbstractParserFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class AbstractParserFinder implements FinderInterface
3232
*/
3333
protected $filter;
3434

35-
public function __construct(CodeParser $parser = null, StatementFilter $filter = null)
35+
public function __construct(?CodeParser $parser = null, ?StatementFilter $filter = null)
3636
{
3737
$this->parser = $parser ?: new CodeParser();
3838
$this->filter = $filter ?: new StatementFilter();

src/Process/MoodleProcess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MoodleProcess extends Process
2626
* @param array|null $env The environment variables or null to inherit
2727
* @param ?int $timeout The timeout in seconds or null (default) to disable
2828
*/
29-
public function __construct(array $command, string $cwd = null, array $env = null, ?int $timeout = null)
29+
public function __construct(array $command, ?string $cwd = null, ?array $env = null, ?int $timeout = null)
3030
{
3131
// Let's find our beloved php.
3232
$phpBinaryFinder = new PhpExecutableFinder();

tests/Fake/Process/DummyExecute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function getMockProcess($cmd)
3939
return $process;
4040
}
4141

42-
public function run($cmd, string $error = null): Process
42+
public function run($cmd, ?string $error = null): Process
4343
{
4444
if ($cmd instanceof Process) {
4545
// Get the command line from process.
@@ -49,7 +49,7 @@ public function run($cmd, string $error = null): Process
4949
return $this->helper->run($this->output, $this->getMockProcess($cmd), $error);
5050
}
5151

52-
public function mustRun($cmd, string $error = null): Process
52+
public function mustRun($cmd, ?string $error = null): Process
5353
{
5454
if ($cmd instanceof Process) {
5555
// Get the command line from process.

0 commit comments

Comments
 (0)