Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

If you want to use php-cs-fixer then make sure you either have file below in your project root or run full command below. For more info, check PHP-CS-Fixer and php-cs-fixer-configurator.


.php_cs


<?php

return PhpCsFixer\Config::create()
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => true,
'compact_nullable_typehint' => true,
'list_syntax' => ['syntax' => 'long'],
'method_argument_space' => ['ensure_fully_multiline' => true],
'method_chaining_indentation' => true,
'multiline_comment_opening_closing' => true,
'no_alternative_syntax' => true,
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
'no_null_property_initialization' => true,
'no_short_echo_tag' => true,
'no_superfluous_elseif' => true,
'no_unneeded_curly_braces' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_test_annotation' => ['style' => 'annotation', 'case' => 'snake'],
'phpdoc_order' => true,
'phpdoc_types_order' => ['sort_algorithm' => 'alpha', 'null_adjustment' => 'always_last'],
'strict_comparison' => true,
'yoda_style' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude(['app', 'bin', 'var', 'vendor', 'web'])
->in(__DIR__)
);

Full command


Tags --dry-run --verbose --diff are optional.


bin/php-cs-fixer fix src --fixers=-yoda_conditions,-phpdoc_align,short_array_syntax --dry-run --verbose --diff