Skip to content

Commit

Permalink
refactor: Rename newly introduced option (#8293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirone authored Nov 19, 2024
1 parent 0adec43 commit effd9a3
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.php-highest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'@PHP83Migration' => true,
'@PHP82Migration:risky' => true,
'phpdoc_to_property_type' => [ // experimental
'map_types' => [
'types_map' => [
'TFixerInputConfig' => 'array',
'TFixerComputedConfig' => 'array',
'TFixer' => '\PhpCsFixer\AbstractFixer',
Expand Down
18 changes: 9 additions & 9 deletions doc/rules/function_notation/phpdoc_to_param_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
~~~~~~~~~~~~~~~~

Expand All @@ -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``
~~~~~~~~~~~~~~~

Expand Down
18 changes: 9 additions & 9 deletions doc/rules/function_notation/phpdoc_to_property_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
~~~~~~~~~~~~~~~~

Expand All @@ -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``
~~~~~~~~~~~~~~~

Expand Down
18 changes: 9 additions & 9 deletions doc/rules/function_notation/phpdoc_to_return_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
~~~~~~~~~~~~~~~~

Expand All @@ -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``
~~~~~~~~~~~~~~~

Expand Down
10 changes: 5 additions & 5 deletions src/AbstractPhpdocToTypeDeclarationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
*
* @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
* }
*
Expand Down Expand Up @@ -97,7 +97,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
->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(),
Expand Down Expand Up @@ -219,8 +219,8 @@ protected function getCommonTypeInfo(TypeExpression $typesExpression, bool $isRe
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])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/FunctionNotation/PhpdocToParamTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
* @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
* }
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/FunctionNotation/PhpdocToPropertyTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
* @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
* }
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
* @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
* }
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit effd9a3

Please sign in to comment.