I usually code in PHP, but I have a very simple html code and it's in a broken structure. It can get worse when I try to fix it with php-cs-fixer. It keeps some elements like "i" on the same line but moves its class down the line. Or it keeps the Lorem part of the "Lorem" Impsum script up and throws the "Impsum" down...etc.
I use the following config codes that I found ready on the internet:
<?php
$config = new PhpCsFixer\Config();
return $config
->setRules([
'@PSR12' => true,
'new_with_braces' => false,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'multiline_whitespace_before_semicolons' => true,
'single_quote' => true,
'blank_line_before_statement' => true,
'braces' => [
'allow_single_line_closure' => true,
],
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'include' => true,
'lowercase_cast' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_spaces_around_offset' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'single_blank_line_before_namespace' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'single_trait_insert_per_statement' => false,
'method_separation' => false,
])
->setLineEnding("\n");
Does anyone have a better config suggestion for me? Thanks for all the kind replies.
PSR-12 format pure PHP code, PhpCsFixer not so good to format mixed code, use PHP CodeSniffer(or
badoo/phpcf
) instead