Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PhpCsFixer ruleset - enable nullable_type_declaration_for_default_null_value #7870

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/ruleSets/PhpCsFixer.rst
Expand Up @@ -79,5 +79,4 @@ Rules
Disabled rules
--------------

- `nullable_type_declaration_for_default_null_value <./../rules/function_notation/nullable_type_declaration_for_default_null_value.rst>`_
- `single_line_throw <./../rules/function_notation/single_line_throw.rst>`_
Expand Up @@ -113,8 +113,9 @@ With configuration: ``['use_nullable_type_declaration' => false]``.
Rule sets
---------

The rule is part of the following rule set:
The rule is part of the following rule sets:

- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

References
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Basic/BracesFixer.php
Expand Up @@ -152,7 +152,7 @@ public function getSuccessorsNames(): array
return array_keys($this->proxyFixers);
}

public function configure(array $configuration = null): void
public function configure(array $configuration): void
{
parent::configure($configuration);

Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocToCommentFixer.php
Expand Up @@ -111,7 +111,7 @@ function returnClassName() {
);
}

public function configure(array $configuration = null): void
public function configure(array $configuration): void
{
parent::configure($configuration);

Expand Down
1 change: 0 additions & 1 deletion src/RuleSet/Sets/PhpCsFixerSet.php
Expand Up @@ -105,7 +105,6 @@ public function getRules(): array
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => ['after_heredoc' => true],
'nullable_type_declaration_for_default_null_value' => false,
'ordered_class_elements' => true,
'ordered_types' => true,
'php_unit_internal_class' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php
Expand Up @@ -62,7 +62,7 @@ final class TypeAnalysis implements StartEndTokenAwareAnalysis
/**
* @param ($startIndex is null ? null : int) $endIndex
*/
public function __construct(string $name, int $startIndex = null, int $endIndex = null)
public function __construct(string $name, ?int $startIndex = null, ?int $endIndex = null)
{
$this->name = $name;

Expand Down
4 changes: 2 additions & 2 deletions tests/Console/ConfigurationResolverTest.php
Expand Up @@ -1378,9 +1378,9 @@ private static function getFixtureDir(): string
*/
private function createConfigurationResolver(
array $options,
Config $config = null,
?Config $config = null,
string $cwdPath = '',
ToolInfoInterface $toolInfo = null
?ToolInfoInterface $toolInfo = null
): ConfigurationResolver {
return new ConfigurationResolver(
$config ?? new Config(),
Expand Down
4 changes: 2 additions & 2 deletions tests/DocBlock/DocBlockTest.php
Expand Up @@ -156,7 +156,7 @@ public function testIsMultiLIne(): void
/**
* @dataProvider provideMakeMultiLIneCases
*/
public function testMakeMultiLIne(string $inputDocBlock, string $outputDocBlock = null, string $indent = '', string $newLine = "\n"): void
public function testMakeMultiLIne(string $inputDocBlock, ?string $outputDocBlock = null, string $indent = '', string $newLine = "\n"): void
{
$doc = new DocBlock($inputDocBlock);
$doc->makeMultiLine($indent, $newLine);
Expand Down Expand Up @@ -204,7 +204,7 @@ public static function provideMakeMultiLIneCases(): iterable
/**
* @dataProvider provideMakeSingleLineCases
*/
public function testMakeSingleLine(string $inputDocBlock, string $outputDocBlock = null): void
public function testMakeSingleLine(string $inputDocBlock, ?string $outputDocBlock = null): void
{
$doc = new DocBlock($inputDocBlock);
$doc->makeSingleLine();
Expand Down
4 changes: 2 additions & 2 deletions tests/DocBlock/TypeExpressionTest.php
Expand Up @@ -32,7 +32,7 @@ final class TypeExpressionTest extends TestCase
* @dataProvider provideGetConstTypesCases
* @dataProvider provideGetTypesCases
*/
public function testGetTypes(string $typesExpression, array $expectedTypes = null): void
public function testGetTypes(string $typesExpression, ?array $expectedTypes = null): void
{
if (null === $expectedTypes) {
$expectedTypes = [$typesExpression];
Expand Down Expand Up @@ -449,7 +449,7 @@ public static function provideIsUnionTypeCases(): iterable
*
* @dataProvider provideGetCommonTypeCases
*/
public function testGetCommonType(string $typesExpression, ?string $expectedCommonType, NamespaceAnalysis $namespace = null, array $namespaceUses = []): void
public function testGetCommonType(string $typesExpression, ?string $expectedCommonType, ?NamespaceAnalysis $namespace = null, array $namespaceUses = []): void
{
$expression = new TypeExpression($typesExpression, $namespace, $namespaceUses);
self::assertSame($expectedCommonType, $expression->getCommonType());
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixer/Alias/ArrayPushFixerTest.php
Expand Up @@ -270,7 +270,7 @@ public static function provideFixCases(): iterable
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand All @@ -293,7 +293,7 @@ public static function provideFixPre80Cases(): iterable
*
* @requires PHP 8.0
*/
public function testFix80(string $expected, string $input = null): void
public function testFix80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Alias/PowToExponentiationFixerTest.php
Expand Up @@ -297,7 +297,7 @@ public function &pow($a, $b);
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Alias/RandomApiMigrationFixerTest.php
Expand Up @@ -231,7 +231,7 @@ public function &rand();
*
* @requires PHP 8.1
*/
public function testFix81(string $expected, string $input = null): void
public function testFix81(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -30,7 +30,7 @@ final class NoWhitespaceBeforeCommaInArrayFixerTest extends AbstractFixerTestCas
*
* @dataProvider provideFixCases
*/
public function testFix(string $expected, string $input = null, array $config = []): void
public function testFix(string $expected, ?string $input = null, array $config = []): void
{
$this->fixer->configure($config);

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Basic/BracesFixerTest.php
Expand Up @@ -5694,7 +5694,7 @@ function example()
/**
* @dataProvider provideIndentCommentCases
*/
public function testIndentComment(string $expected, ?string $input, WhitespacesFixerConfig $config = null): void
public function testIndentComment(string $expected, ?string $input, ?WhitespacesFixerConfig $config = null): void
{
if (null !== $config) {
$this->fixer->setWhitespacesConfig($config);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Basic/EncodingFixerTest.php
Expand Up @@ -28,7 +28,7 @@ final class EncodingFixerTest extends AbstractFixerTestCase
/**
* @dataProvider provideFixCases
*/
public function testFix(string $expected, ?string $input = null, \SplFileInfo $file = null): void
public function testFix(string $expected, ?string $input = null, ?\SplFileInfo $file = null): void
{
$this->doTest($expected, $input, $file);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Basic/NoTrailingCommaInSinglelineFixerTest.php
Expand Up @@ -487,7 +487,7 @@ function foo1(string $param = null ): void
*
* @requires PHP 8.0
*/
public function testFix80(string $expected, string $input = null): void
public function testFix80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Casing/ClassReferenceNameCasingFixerTest.php
Expand Up @@ -26,7 +26,7 @@ final class ClassReferenceNameCasingFixerTest extends AbstractFixerTestCase
/**
* @dataProvider provideFixCases
*/
public function testFix(string $expected, string $input = null): void
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Casing/IntegerLiteralCaseFixerTest.php
Expand Up @@ -26,7 +26,7 @@ final class IntegerLiteralCaseFixerTest extends AbstractFixerTestCase
/**
* @dataProvider provideFixCases
*/
public function testFix(string $expected, string $input = null): void
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Casing/MagicMethodCasingFixerTest.php
Expand Up @@ -350,7 +350,7 @@ public function testFix80(): void
*
* @requires PHP 8.1
*/
public function testFix81(string $expected, string $input = null): void
public function testFix81(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -413,7 +413,7 @@ public static function provideFix82Cases(): iterable
*
* @requires PHP 8.3
*/
public function testFix83(string $expected, string $input = null): void
public function testFix83(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/CastNotation/LowercaseCastFixerTest.php
Expand Up @@ -48,7 +48,7 @@ public static function provideFixCases(): iterable
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -215,7 +215,7 @@ public function &doubleval($a);
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/CastNotation/ShortScalarCastFixerTest.php
Expand Up @@ -55,7 +55,7 @@ public static function provideFixCases(): iterable
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php
Expand Up @@ -79,7 +79,7 @@ public static function provideInvalidConfigurationCases(): iterable
*
* @dataProvider provideFixCases
*/
public function testFix(string $expected, string $input = null, array $configuration = []): void
public function testFix(string $expected, ?string $input = null, array $configuration = []): void
{
$this->fixer->configure($configuration);
$this->doTest($expected, $input);
Expand Down
Expand Up @@ -273,7 +273,7 @@ public static function provideFixCases(): iterable
*
* @dataProvider provideWithWhitespacesConfigCases
*/
public function testWithWhitespacesConfig(string $expected, ?string $input = null, array $configuration = null): void
public function testWithWhitespacesConfig(string $expected, ?string $input = null, ?array $configuration = null): void
{
if (null !== $configuration) {
$this->fixer->configure($configuration);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ControlStructure/NoUnneededBracesFixerTest.php
Expand Up @@ -210,7 +210,7 @@ class X {}
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -136,7 +136,7 @@ public function getBar(): array
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -245,7 +245,7 @@ public static function provideFixCases(): iterable
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ControlStructure/SwitchCaseSpaceFixerTest.php
Expand Up @@ -350,7 +350,7 @@ public static function provideFixCases(): iterable
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ControlStructure/YodaStyleFixerTest.php
Expand Up @@ -1221,7 +1221,7 @@ public static function provideFix80Cases(): iterable
*
* @requires PHP 8.1
*/
public function testFix81(string $expected, string $input = null): void
public function testFix81(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -223,7 +223,7 @@ function TisMy ($p1)
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -26,7 +26,7 @@ final class NoTrailingCommaInSinglelineFunctionCallFixerTest extends AbstractFix
/**
* @dataProvider provideFixCases
*/
public function testFix(string $expected, string $input = null): void
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ function foo1(string $param = null ): void
*
* @requires PHP 8.0
*/
public function testFix80(string $expected, string $input = null): void
public function testFix80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/FunctionNotation/NoUselessSprintfFixerTest.php
Expand Up @@ -111,7 +111,7 @@ function sprintf($foo) {
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -516,7 +516,7 @@ function bar($x) {}
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -523,7 +523,7 @@ public abstract function getFoo();
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -409,7 +409,7 @@ function bar() {}
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/FunctionNotation/StaticLambdaFixerTest.php
Expand Up @@ -26,7 +26,7 @@ final class StaticLambdaFixerTest extends AbstractFixerTestCase
/**
* @dataProvider provideFixCases
*/
public function testFix(string $expected, string $input = null): void
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Import/GroupImportFixerTest.php
Expand Up @@ -361,7 +361,7 @@ public static function provideFixCases(): iterable
*
* @requires PHP <8.0
*/
public function testFixPre80(string $expected, string $input = null): void
public function testFixPre80(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixer/Import/OrderedImportsFixerTest.php
Expand Up @@ -2040,7 +2040,7 @@ public static function provideFixTypesOrderAndLengthCases(): iterable
*
* @param string[] $importOrder
*/
public function testFixTypesOrderAndAlphabet(string $expected, ?string $input = null, array $importOrder = null): void
public function testFixTypesOrderAndAlphabet(string $expected, ?string $input = null, ?array $importOrder = null): void
{
$this->fixer->configure([
'sort_algorithm' => OrderedImportsFixer::SORT_ALPHA,
Expand Down Expand Up @@ -2106,7 +2106,7 @@ public static function provideFixTypesOrderAndAlphabetCases(): iterable
*
* @param null|string[] $importOrder
*/
public function testFixTypesOrderAndNone(string $expected, ?string $input = null, array $importOrder = null): void
public function testFixTypesOrderAndNone(string $expected, ?string $input = null, ?array $importOrder = null): void
{
$this->fixer->configure([
'sort_algorithm' => OrderedImportsFixer::SORT_NONE,
Expand Down