2017-08-29 14:50:31 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @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);
|
2021-04-14 15:16:36 +00:00
|
|
|
|
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",
|
2021-04-14 15:16:36 +00:00
|
|
|
BASE."tests/cases",
|
|
|
|
BASE."tests/lib",
|
|
|
|
BASE."tests/bootstrap.php",
|
|
|
|
BASE."tests/server.php",
|
2017-08-29 14:50:31 +00:00
|
|
|
];
|
|
|
|
$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,
|
2021-04-14 15:16:36 +00:00
|
|
|
'no_empty_statement' => true,
|
2020-03-01 20:15:57 +00:00
|
|
|
'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,
|
2023-03-23 03:14:19 +00:00
|
|
|
'trailing_comma_in_multiline' => ['elements' => ["arrays"]],
|
2020-03-01 20:15:57 +00:00
|
|
|
'unary_operator_spaces' => true,
|
|
|
|
'yoda_style' => false,
|
|
|
|
// PSR standard to apply
|
2021-04-14 15:16:36 +00:00
|
|
|
'@PSR12' => true,
|
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);
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 15:16:36 +00:00
|
|
|
return (new \PhpCsFixer\Config)->setRiskyAllowed(true)->setRules($rules)->setFinder($finder);
|