Skip to content

Commit

Permalink
Update Symfony ruleset
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Jan 18, 2021
1 parent ef7dca1 commit 3161ebf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
3 changes: 3 additions & 0 deletions doc/ruleSets/PhpCsFixerRisky.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Rules
- `@Symfony:risky <./SymfonyRisky.rst>`_
- `comment_to_phpdoc <./../rules/comment/comment_to_phpdoc.rst>`_
- `final_internal_class <./../rules/class_notation/final_internal_class.rst>`_
- `native_constant_invocation <./../rules/constant_notation/native_constant_invocation.rst>`_
config:
``['fix_built_in' => false, 'include' => ['DIRECTORY_SEPARATOR', 'PHP_INT_SIZE', 'PHP_SAPI', 'PHP_VERSION_ID'], 'scope' => 'namespaced', 'strict' => true]``
- `no_alias_functions <./../rules/alias/no_alias_functions.rst>`_
config:
``['sets' => ['@all']]``
Expand Down
2 changes: 0 additions & 2 deletions doc/ruleSets/SymfonyRisky.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Rules
- `logical_operators <./../rules/operator/logical_operators.rst>`_
- `modernize_types_casting <./../rules/cast_notation/modernize_types_casting.rst>`_
- `native_constant_invocation <./../rules/constant_notation/native_constant_invocation.rst>`_
config:
``['fix_built_in' => false, 'include' => ['DIRECTORY_SEPARATOR', 'PHP_INT_SIZE', 'PHP_SAPI', 'PHP_VERSION_ID'], 'scope' => 'namespaced', 'strict' => true]``
- `native_function_invocation <./../rules/function_notation/native_function_invocation.rst>`_
config:
``['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true]``
Expand Down
4 changes: 1 addition & 3 deletions doc/rules/constant_notation/native_constant_invocation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,4 @@ The rule is part of the following rule sets:
``['fix_built_in' => false, 'include' => ['DIRECTORY_SEPARATOR', 'PHP_INT_SIZE', 'PHP_SAPI', 'PHP_VERSION_ID'], 'scope' => 'namespaced', 'strict' => true]``

@Symfony:risky
Using the `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_ rule set will enable the ``native_constant_invocation`` rule with the config below:

``['fix_built_in' => false, 'include' => ['DIRECTORY_SEPARATOR', 'PHP_INT_SIZE', 'PHP_SAPI', 'PHP_VERSION_ID'], 'scope' => 'namespaced', 'strict' => true]``
Using the `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_ rule set will enable the ``native_constant_invocation`` rule with the default config.
12 changes: 12 additions & 0 deletions src/RuleSet/Sets/PhpCsFixerRiskySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public function getRules()
'@Symfony:risky' => true,
'comment_to_phpdoc' => true,
'final_internal_class' => true,
// @TODO: consider switching to `true`, like in @Symfony
'native_constant_invocation' => [
'fix_built_in' => false,
'include' => [
'DIRECTORY_SEPARATOR',
'PHP_INT_SIZE',
'PHP_SAPI',
'PHP_VERSION_ID',
],
'scope' => 'namespaced',
'strict' => true,
],
'no_alias_functions' => [
'sets' => [
'@all',
Expand Down
12 changes: 1 addition & 11 deletions src/RuleSet/Sets/SymfonyRiskySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,7 @@ public function getRules()
'is_null' => true,
'logical_operators' => true,
'modernize_types_casting' => true,
'native_constant_invocation' => [
'fix_built_in' => false,
'include' => [
'DIRECTORY_SEPARATOR',
'PHP_INT_SIZE',
'PHP_SAPI',
'PHP_VERSION_ID',
],
'scope' => 'namespaced',
'strict' => true,
],
'native_constant_invocation' => true,
'native_function_invocation' => [
'include' => [
'@compiler_optimized',
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Integration/misc/PHP7_3.test
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $a ** 1; // `pow_to_exponentiation` rule
random_int($a, $b, ); // `random_api_migration` rule
$foo = (int) $foo; // `set_type_to_cast` rule
in_array($b, $c, true, ); // `strict_param` rule
@trigger_error('Warning.', E_USER_DEPRECATED, ); // `error_suppression` rule
@trigger_error('Warning.', \E_USER_DEPRECATED, ); // `error_suppression` rule
foo(null === $a, ); // `yoda_style` rule
$a = null; // `no_unset_cast` rule
$foo->bar = null; // `no_unset_on_property` rule
Expand Down

0 comments on commit 3161ebf

Please sign in to comment.