diff --git a/doc/ruleSets/Symfony.rst b/doc/ruleSets/Symfony.rst index 03bce9d45f7..072008a555e 100644 --- a/doc/ruleSets/Symfony.rst +++ b/doc/ruleSets/Symfony.rst @@ -99,6 +99,7 @@ Rules - `no_useless_nullsafe_operator <./../rules/operator/no_useless_nullsafe_operator.rst>`_ - `no_whitespace_before_comma_in_array <./../rules/array_notation/no_whitespace_before_comma_in_array.rst>`_ - `normalize_index_brace <./../rules/array_notation/normalize_index_brace.rst>`_ +- `nullable_type_declaration <./../rules/language_construct/nullable_type_declaration.rst>`_ - `nullable_type_declaration_for_default_null_value <./../rules/function_notation/nullable_type_declaration_for_default_null_value.rst>`_ - `object_operator_without_whitespace <./../rules/operator/object_operator_without_whitespace.rst>`_ - `operator_linebreak <./../rules/operator/operator_linebreak.rst>`_ with config: diff --git a/doc/rules/language_construct/nullable_type_declaration.rst b/doc/rules/language_construct/nullable_type_declaration.rst index dc9c518b32b..6c3171ce41c 100644 --- a/doc/rules/language_construct/nullable_type_declaration.rst +++ b/doc/rules/language_construct/nullable_type_declaration.rst @@ -66,6 +66,15 @@ With configuration: ``['syntax' => 'question_mark']``. + public ?bool $internal; + public ?\Closure $callback; } + +Rule sets +--------- + +The rule is part of the following rule sets: + +- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ +- `@Symfony <./../../ruleSets/Symfony.rst>`_ + References ---------- diff --git a/src/RuleSet/Sets/SymfonySet.php b/src/RuleSet/Sets/SymfonySet.php index 6a07fc3d6a0..1b4f38cdd9f 100644 --- a/src/RuleSet/Sets/SymfonySet.php +++ b/src/RuleSet/Sets/SymfonySet.php @@ -135,6 +135,7 @@ public function getRules(): array 'no_useless_nullsafe_operator' => true, 'no_whitespace_before_comma_in_array' => true, 'normalize_index_brace' => true, + 'nullable_type_declaration' => true, 'nullable_type_declaration_for_default_null_value' => true, 'object_operator_without_whitespace' => true, 'operator_linebreak' => [ diff --git a/tests/Fixtures/Integration/misc/PHP8_2.test b/tests/Fixtures/Integration/misc/PHP8_2.test index f4a75d90a3c..dea778cff9d 100644 --- a/tests/Fixtures/Integration/misc/PHP8_2.test +++ b/tests/Fixtures/Integration/misc/PHP8_2.test @@ -55,7 +55,7 @@ class FalseNull } } -function falsyNull(null $n, false $f): null|false {} +function falsyNull(null $n, false $f): ?false {} array_filter([], fn (null $n) => null === $n); array_filter([], fn (false $n) => false === $n);