Просмотр исходного кода

refactor: Rename newly introduced option (#8293)

Greg Korba 3 месяцев назад
Родитель
Сommit
effd9a3b48

+ 1 - 1
.php-cs-fixer.php-highest.php

@@ -25,7 +25,7 @@ $config->setRules(array_merge($config->getRules(), [
     '@PHP83Migration' => true,
     '@PHP82Migration:risky' => true,
     'phpdoc_to_property_type' => [ // experimental
-        'map_types' => [
+        'types_map' => [
             'TFixerInputConfig' => 'array',
             'TFixerComputedConfig' => 'array',
             'TFixer' => '\PhpCsFixer\AbstractFixer',

+ 9 - 9
doc/rules/function_notation/phpdoc_to_param_type.rst

@@ -27,15 +27,6 @@ actions are required if inherited signatures are not properly documented.
 Configuration
 -------------
 
-``map_types``
-~~~~~~~~~~~~~
-
-Map of custom types, eg template types from PHPStan.
-
-Allowed types: ``array<string, string>``
-
-Default value: ``[]``
-
 ``scalar_types``
 ~~~~~~~~~~~~~~~~
 
@@ -46,6 +37,15 @@ Allowed types: ``bool``
 
 Default value: ``true``
 
+``types_map``
+~~~~~~~~~~~~~
+
+Map of custom types, e.g. template types from PHPStan.
+
+Allowed types: ``array<string, string>``
+
+Default value: ``[]``
+
 ``union_types``
 ~~~~~~~~~~~~~~~
 

+ 9 - 9
doc/rules/function_notation/phpdoc_to_property_type.rst

@@ -27,15 +27,6 @@ be required for newly typed properties that are read before initialization.
 Configuration
 -------------
 
-``map_types``
-~~~~~~~~~~~~~
-
-Map of custom types, eg template types from PHPStan.
-
-Allowed types: ``array<string, string>``
-
-Default value: ``[]``
-
 ``scalar_types``
 ~~~~~~~~~~~~~~~~
 
@@ -46,6 +37,15 @@ Allowed types: ``bool``
 
 Default value: ``true``
 
+``types_map``
+~~~~~~~~~~~~~
+
+Map of custom types, e.g. template types from PHPStan.
+
+Allowed types: ``array<string, string>``
+
+Default value: ``[]``
+
 ``union_types``
 ~~~~~~~~~~~~~~~
 

+ 9 - 9
doc/rules/function_notation/phpdoc_to_return_type.rst

@@ -27,15 +27,6 @@ Manual actions are required if inherited signatures are not properly documented.
 Configuration
 -------------
 
-``map_types``
-~~~~~~~~~~~~~
-
-Map of custom types, eg template types from PHPStan.
-
-Allowed types: ``array<string, string>``
-
-Default value: ``[]``
-
 ``scalar_types``
 ~~~~~~~~~~~~~~~~
 
@@ -46,6 +37,15 @@ Allowed types: ``bool``
 
 Default value: ``true``
 
+``types_map``
+~~~~~~~~~~~~~
+
+Map of custom types, e.g. template types from PHPStan.
+
+Allowed types: ``array<string, string>``
+
+Default value: ``[]``
+
 ``union_types``
 ~~~~~~~~~~~~~~~
 

+ 5 - 5
src/AbstractPhpdocToTypeDeclarationFixer.php

@@ -33,13 +33,13 @@ use PhpCsFixer\Tokenizer\Tokens;
  *
  * @phpstan-type _CommonTypeInfo array{commonType: string, isNullable: bool}
  * @phpstan-type _AutogeneratedInputConfiguration array{
- *  map_types?: array<string, string>,
  *  scalar_types?: bool,
+ *  types_map?: array<string, string>,
  *  union_types?: bool
  * }
  * @phpstan-type _AutogeneratedComputedConfiguration array{
- *  map_types: array<string, string>,
  *  scalar_types: bool,
+ *  types_map: array<string, string>,
  *  union_types: bool
  * }
  *
@@ -97,7 +97,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
                 ->setAllowedTypes(['bool'])
                 ->setDefault(\PHP_VERSION_ID >= 8_00_00)
                 ->getOption(),
-            (new FixerOptionBuilder('map_types', 'Map of custom types, eg template types from PHPStan.'))
+            (new FixerOptionBuilder('types_map', 'Map of custom types, e.g. template types from PHPStan.'))
                 ->setAllowedTypes(['array<string, string>'])
                 ->setDefault([])
                 ->getOption(),
@@ -219,8 +219,8 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
             return null;
         }
 
-        if (\array_key_exists($commonType, $this->configuration['map_types'])) {
-            $commonType = $this->configuration['map_types'][$commonType];
+        if (\array_key_exists($commonType, $this->configuration['types_map'])) {
+            $commonType = $this->configuration['types_map'][$commonType];
         }
 
         if (isset($this->scalarTypes[$commonType])) {

+ 2 - 2
src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php

@@ -30,13 +30,13 @@ use PhpCsFixer\Tokenizer\Tokens;
  * @implements ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>
  *
  * @phpstan-type _AutogeneratedInputConfiguration array{
- *  map_types?: array<string, string>,
  *  scalar_types?: bool,
+ *  types_map?: array<string, string>,
  *  union_types?: bool
  * }
  * @phpstan-type _AutogeneratedComputedConfiguration array{
- *  map_types: array<string, string>,
  *  scalar_types: bool,
+ *  types_map: array<string, string>,
  *  union_types: bool
  * }
  */

+ 2 - 2
src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php

@@ -30,13 +30,13 @@ use PhpCsFixer\Tokenizer\Tokens;
  * @implements ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>
  *
  * @phpstan-type _AutogeneratedInputConfiguration array{
- *  map_types?: array<string, string>,
  *  scalar_types?: bool,
+ *  types_map?: array<string, string>,
  *  union_types?: bool
  * }
  * @phpstan-type _AutogeneratedComputedConfiguration array{
- *  map_types: array<string, string>,
  *  scalar_types: bool,
+ *  types_map: array<string, string>,
  *  union_types: bool
  * }
  */

+ 2 - 2
src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php

@@ -32,13 +32,13 @@ use PhpCsFixer\Tokenizer\Tokens;
  * @implements ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>
  *
  * @phpstan-type _AutogeneratedInputConfiguration array{
- *  map_types?: array<string, string>,
  *  scalar_types?: bool,
+ *  types_map?: array<string, string>,
  *  union_types?: bool
  * }
  * @phpstan-type _AutogeneratedComputedConfiguration array{
- *  map_types: array<string, string>,
  *  scalar_types: bool,
+ *  types_map: array<string, string>,
  *  union_types: bool
  * }
  */

+ 1 - 1
tests/Fixtures/Integration/priority/phpdoc_to_property_type,fully_qualified_strict_types.test

@@ -1,7 +1,7 @@
 --TEST--
 Integration of fixers: phpdoc_to_property_type,fully_qualified_strict_types.
 --RULESET--
-{"phpdoc_to_property_type":{"map_types":{"TFixer":"\\PhpCsFixer\\AbstractFixer"}},"fully_qualified_strict_types":{"import_symbols":true}}
+{"phpdoc_to_property_type":{"types_map":{"TFixer":"\\PhpCsFixer\\AbstractFixer"}},"fully_qualified_strict_types":{"import_symbols":true}}
 --EXPECT--
 <?php