Browse Source

Update Symfony ruleset

Dariusz Ruminski 4 years ago
parent
commit
3161ebfdb7

+ 3 - 0
doc/ruleSets/PhpCsFixerRisky.rst

@@ -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']]``

+ 0 - 2
doc/ruleSets/SymfonyRisky.rst

@@ -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]``

+ 1 - 3
doc/rules/constant_notation/native_constant_invocation.rst

@@ -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 - 0
src/RuleSet/Sets/PhpCsFixerRiskySet.php

@@ -25,6 +25,18 @@ final class PhpCsFixerRiskySet extends AbstractRuleSetDescription
             '@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',

+ 1 - 11
src/RuleSet/Sets/SymfonyRiskySet.php

@@ -47,17 +47,7 @@ final class SymfonyRiskySet extends AbstractRuleSetDescription
             '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',

+ 1 - 1
tests/Fixtures/Integration/misc/PHP7_3.test

@@ -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