Browse Source

docs: options - handle enums in dicts (#8082)

Dariusz Rumiński 9 months ago
parent
commit
3649d8173e

+ 1 - 1
doc/rules/phpdoc/phpdoc_tag_type.rst

@@ -12,7 +12,7 @@ Configuration
 
 The list of tags to fix.
 
-Allowed types: ``array<string, string>``
+Allowed types: ``array<string, 'annotation'|'inline'>``
 
 Default value: ``['api' => 'annotation', 'author' => 'annotation', 'copyright' => 'annotation', 'deprecated' => 'annotation', 'example' => 'annotation', 'global' => 'annotation', 'inheritDoc' => 'annotation', 'internal' => 'annotation', 'license' => 'annotation', 'method' => 'annotation', 'package' => 'annotation', 'param' => 'annotation', 'property' => 'annotation', 'return' => 'annotation', 'see' => 'annotation', 'since' => 'annotation', 'throws' => 'annotation', 'todo' => 'annotation', 'uses' => 'annotation', 'var' => 'annotation', 'version' => 'annotation']``
 

+ 1 - 1
src/Fixer/Phpdoc/PhpdocTagTypeFixer.php

@@ -135,7 +135,7 @@ final class PhpdocTagTypeFixer extends AbstractFixer implements ConfigurableFixe
     {
         return new FixerConfigurationResolver([
             (new FixerOptionBuilder('tags', 'The list of tags to fix.'))
-                ->setAllowedTypes(['array<string, string>'])
+                ->setAllowedTypes(["array<string, 'annotation'|'inline'>"])
                 ->setAllowedValues([static function (array $value): bool {
                     foreach ($value as $type) {
                         if (!\in_array($type, ['annotation', 'inline'], true)) {

+ 5 - 1
src/FixerConfiguration/FixerConfigurationResolver.php

@@ -101,11 +101,15 @@ final class FixerConfigurationResolver implements FixerConfigurationResolverInte
                 $allowedTypesNormalised = array_map(
                     static function (string $type): string {
                         $matches = [];
-                        if (true === Preg::match('/array<\w+,\s*(\??\w+)>/', $type, $matches)) {
+                        if (true === Preg::match('/array<\w+,\s*(\??[\w\'|]+)>/', $type, $matches)) {
                             if ('?' === $matches[1][0]) {
                                 return 'array';
                             }
 
+                            if ("'" === $matches[1][0]) {
+                                return 'string[]';
+                            }
+
                             return $matches[1].'[]';
                         }