Skip to content

Instantly share code, notes, and snippets.

@leek
Created July 11, 2022 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leek/6b7254937a46797c579d44621907dbce to your computer and use it in GitHub Desktop.
Save leek/6b7254937a46797c579d44621907dbce to your computer and use it in GitHub Desktop.
Personal ideal PHP CS Fixer configuration
<?php
/**
* PHP Coding Standards fixer configuration
*/
$finder = PhpCsFixer\Finder::create()
->ignoreDotFiles(true)
->ignoreVCSIgnored(true)
->exclude('node_modules')
->exclude('vendor')
;
$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(false)
->setFinder($finder)
->setRules([
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/ruleSets/PhpCsFixer.rst
*/
'@PhpCsFixer' => true,
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/class_notation/visibility_required.rst
*/
'visibility_required' => [
'elements' => [
'method',
'property'
]
],
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/operator/concat_space.rst
*/
'concat_space' => ['spacing' => 'one'],
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/operator/binary_operator_spaces.rst
*/
'binary_operator_spaces' => [
'operators' => [
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
]
],
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/control_structure/yoda_style.rst
*/
'yoda_style' => false,
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/control_structure/no_useless_else.rst
*/
'no_useless_else' => false,
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/php_tag/echo_tag_syntax.rst
*/
'echo_tag_syntax' => [
'format' => 'short',
],
/**
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/control_structure/no_alternative_syntax.rst
*/
'no_alternative_syntax' => [
'fix_non_monolithic_code' => false,
],
])
;
return $config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment