Instantly share code, notes, and snippets.

@gruz /.php_cs
Last active Apr 27, 2018

Embed
What would you like to do?
Joomla phpcs and php-cd-fixer settings
<?php
$topFilesFinder = PhpCsFixer\Finder::create()
->in(array(__DIR__ . '/libraries'))
->files()
->depth(0);
$mainFinder = PhpCsFixer\Finder::create()
->in(
array(
__DIR__ . '/libraries/cms',
__DIR__ . '/libraries/joomla',
__DIR__ . '/libraries/legacy',
)
)
->append($topFilesFinder);
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setIndent("\t")
->setRules(
array(
// psr-1
'encoding' => true,
// psr-2
'elseif' => true,
'single_blank_line_at_eof' => true,
'no_spaces_after_function_name' => true,
'blank_line_after_namespace' => true,
'line_ending' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'method_argument_space' => true,
'single_import_per_statement' => true,
'no_spaces_inside_parenthesis' => true,
'single_line_after_imports' => true,
'no_trailing_whitespace' => true,
'visibility_required' => true,
// symfony
'no_whitespace_before_comma_in_array' => true,
'whitespace_after_comma_in_array' => true,
'no_empty_statement' => true,
'simplified_null_return' => true,
'no_extra_consecutive_blank_lines' => true,
'function_typehint_space' => true,
'include' => true,
'no_alias_functions' => true,
'no_trailing_comma_in_list_call' => true,
'trailing_comma_in_multiline_array' => true,
'no_blank_lines_after_class_opening' => true,
'phpdoc_trim' => true,
'blank_line_before_return' => true,
'no_trailing_comma_in_singleline_array' => true,
'single_blank_line_before_namespace' => true,
'cast_spaces' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
// contrib
'concat_space' => ['spacing' => 'one'],
'array_syntax' => ['syntax' => 'long'],
'braces' => ['position_after_control_structures' => 'next', 'position_after_control_structures' => 'next'],
'binary_operator_spaces' => ['default' => 'align_single_space'],
'blank_line_before_statement' => ['statements' => ['if', 'for', 'foreach', 'break', 'continue', 'declare', 'return', 'throw', 'try']],
)
)
->setFinder($mainFinder);
{
"require": {
"friendsofphp/php-cs-fixer": "^2.10",
"laravel/installer": "^1.5"
},
"require-dev": {
"joomla/coding-standards": "dev-3.x-dev"
},
"minimum-stability": "alpha"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment