1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00
Arsse/.php_cs.dist

86 lines
3.9 KiB
Text
Raw Permalink Normal View History

2017-08-29 14:50:31 +00:00
<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
2020-03-01 20:15:57 +00:00
declare(strict_types=1);
2017-08-29 14:50:31 +00:00
namespace JKingWeb\Arsse;
2017-10-20 22:41:21 +00:00
const BASE = __DIR__.DIRECTORY_SEPARATOR;
2017-08-29 14:50:31 +00:00
$paths = [
__FILE__,
BASE."arsse.php",
2017-12-20 03:21:54 +00:00
BASE."RoboFile.php",
2017-08-29 14:50:31 +00:00
BASE."lib",
BASE."tests",
];
$rules = [
2020-03-01 20:15:57 +00:00
// house rules where PSR series is silent
2020-03-02 02:07:36 +00:00
'align_multiline_comment' => ['comment_type' => "phpdocs_only"],
'array_syntax' => ['syntax' => "short"],
'binary_operator_spaces' => [
2020-03-01 20:15:57 +00:00
'default' => "single_space",
'operators' => ['=>' => "align_single_space"],
],
'cast_spaces' => ['space' => "single"],
'concat_space' => ['spacing' => "none"],
'list_syntax' => ['syntax' => "short"],
'magic_constant_casing' => true,
'magic_method_casing' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'native_function_type_declaration_casing' => true,
'no_binary_string' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_extra_blank_lines' => true, // this could probably use more configuration
'no_mixed_echo_print' => ['use' => "echo"],
'no_short_bool_cast' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'pow_to_exponentiation' => true,
'set_type_to_cast' => true,
'standardize_not_equals' => true,
'trailing_comma_in_multiline_array' => true,
'unary_operator_spaces' => true,
'yoda_style' => false,
// PSR standard to apply
2017-08-29 14:50:31 +00:00
'@PSR2' => true,
2020-03-01 23:32:01 +00:00
// PSR-12 rules; php-cs-fixer does not yet support PSR-12 natively
2020-03-02 02:07:36 +00:00
'compact_nullable_typehint' => true,
2020-03-01 23:32:01 +00:00
'declare_equal_normalize' => ['space' => "none"],
2020-03-02 02:07:36 +00:00
'function_typehint_space' => true,
2020-03-01 23:32:01 +00:00
'lowercase_cast' => true,
'lowercase_static_reference' => true,
2020-03-02 02:07:36 +00:00
'no_alternative_syntax' => true,
'no_empty_statement' => true,
2020-03-01 23:32:01 +00:00
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
2020-03-02 02:07:36 +00:00
'no_whitespace_in_blank_line' => true,
'return_type_declaration' => ['space_before' => "none"],
'single_trait_insert_per_statement' => true,
2020-03-01 23:32:01 +00:00
'short_scalar_cast' => true,
'visibility_required' => ['elements' => ["const", "property", "method"]],
2020-03-01 20:15:57 +00:00
// house exceptions to PSR rules
2020-03-02 02:07:36 +00:00
'braces' => ['position_after_functions_and_oop_constructs' => "same"],
'function_declaration' => ['closure_function_spacing' => "none"],
'new_with_braces' => false, // no option to specify absence of braces
];
2017-08-29 14:50:31 +00:00
$finder = \PhpCsFixer\Finder::create();
foreach ($paths as $path) {
if (is_file($path)) {
2017-08-29 15:16:37 +00:00
$finder = $finder->append([$path]);
2017-08-29 14:50:31 +00:00
} else {
$finder = $finder->in($path);
}
}
2020-03-01 20:15:57 +00:00
return \PhpCsFixer\Config::create()->setRiskyAllowed(true)->setRules($rules)->setFinder($finder);