Skip to content

Commit

Permalink
feat: @Symfony - add nullable_type_declaration (#7856)
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Feb 28, 2024
1 parent 64c4398 commit 413066c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/ruleSets/Symfony.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions doc/rules/language_construct/nullable_type_declaration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------

Expand Down
1 change: 1 addition & 0 deletions src/RuleSet/Sets/SymfonySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Integration/misc/PHP8_2.test
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 413066c

Please sign in to comment.