We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use
When fixing an enum, the use statement for a trait is removed when no_unused_imports = true.
no_unused_imports = true
php-cs-fixer fix TestEnum.php --config=.php-cs-fixer.php
$config = new PhpCsFixer\Config(); return $config ->setRules([ '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], 'combine_consecutive_unsets' => true, 'class_attributes_separation' => [ 'elements' => [ 'method' => 'one', ], ], 'multiline_whitespace_before_semicolons' => true, 'single_quote' => true, 'braces' => [ 'allow_single_line_closure' => true, ], 'concat_space' => ['spacing' => 'one'], 'declare_equal_normalize' => true, 'function_typehint_space' => true, 'single_line_comment_style' => true, 'include' => true, 'lowercase_cast' => true, 'no_extra_blank_lines' => [ 'tokens' => [ 'break', 'continue', 'curly_brace_block', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'throw', 'use', 'use_trait', 'switch', 'case', 'default', ], ], 'no_multiline_whitespace_around_double_arrow' => true, 'no_spaces_around_offset' => true, 'no_unused_imports' => true, 'ordered_imports' => ['sort_algorithm' => 'alpha'], 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, 'object_operator_without_whitespace' => true, 'return_type_declaration' => true, 'single_blank_line_before_namespace' => true, 'ternary_operator_spaces' => true, 'trailing_comma_in_multiline' => true, 'trim_array_spaces' => true, 'unary_operator_spaces' => true, 'whitespace_after_comma_in_array' => true, 'binary_operator_spaces' => true, 'not_operator_with_successor_space' => true, ]) ->setLineEnding("\n");
// TestEnum.php namespace App\Shared; enum TestEnum: string { use EnumHasValues; case Test1 = 'test1'; case Test2 = 'test2'; } // EnumHasValues.php namespace App\Shared; trait EnumHasValues { public static function toValues(): array { return array_map( static fn ($enum) => $enum->value, static::cases() ); } }
namespace App\Shared; enum TestEnum: string { case Test1 = 'test1'; case Test2 = 'test2'; }
The text was updated successfully, but these errors were encountered:
enum
Hi and thanks for reporting,
I've made a PR that aims to fix this bug #6181
Sorry, something went wrong.
Awesome! Thank you!
37f96ce
Please add a tag to make this solution available
Successfully merging a pull request may close this issue.
Bug report
When fixing an enum, the
use
statement for a trait is removed whenno_unused_imports = true
.Versions
Command
php-cs-fixer fix TestEnum.php --config=.php-cs-fixer.php
Configuration
Click to expand
Code snippet that reproduces the problem
Expected
Actual
The text was updated successfully, but these errors were encountered: