Skip to content

Instantly share code, notes, and snippets.

@ambengers
Last active November 14, 2022 02:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ambengers/c112d75bb7e14b41daf99dc2abad7690 to your computer and use it in GitHub Desktop.
Rules for PHP codestyle.
<?php
$rules = [
'@PSR2' => true,
// Syntax...
'array_syntax' => ['syntax' => 'short'],
'braces' => [
'allow_single_line_anonymous_class_with_empty_body' => true,
'allow_single_line_closure' => true,
],
'binary_operator_spaces' => ['operators' => ['=>' => 'single_space']],
'declare_equal_normalize' => ['space' => 'none'],
'method_argument_space' => [ 'on_multiline' => 'ignore'],
// Casting...
'no_short_bool_cast' => true,
'short_scalar_cast' => true,
'cast_spaces' => ['space' => 'single'],
// Imports...
'no_unused_imports' => true,
// Namespace...
'blank_line_after_namespace' => true,
'single_blank_line_before_namespace' => true,
// No's...
'no_useless_return' => true,
'no_useless_else' => true,
// Operator...
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
// PHP Tag...
'blank_line_after_opening_tag' => true,
// Semicolon...
'no_empty_statement' => true,
];
return (new PhpCsFixer\Config)
->setRules($rules);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment