This repository has been archived on 2024-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
quintolin/.php-cs-fixer.dist.php

280 lines
9.2 KiB
PHP

<?php
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
// rule sets
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
'@PHP83Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit100Migration:risky' => true,
// override config from rule sets
'binary_operator_spaces' => true,
'ordered_class_elements' => true,
'ordered_imports' => [
'imports_order' => ['class', 'function', 'const'],
'sort_algorithm' => 'alpha',
],
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => ['arguments', 'arrays', 'match', 'parameters'],
],
// additional rules from “Alias” category
'array_push' => true,
'backtick_to_shell_exec' => true,
'ereg_to_preg' => true,
'mb_str_functions' => true,
'no_alias_language_construct_call' => true,
'no_mixed_echo_print' => true,
'set_type_to_cast' => true,
// additional rules from “Array Notation” category
'no_multiline_whitespace_around_double_arrow' => true,
'return_to_yield_from' => true,
'trim_array_spaces' => true,
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yield_from_array_to_yields' => true,
// additional rules from “Attribute Notation” category
'attribute_empty_parentheses' => true,
// additional rules from “Basic” category
'no_trailing_comma_in_singleline' => true,
'numeric_literal_separator' => true,
// additional rules from “Casing” category
'class_reference_name_casing' => true,
'integer_literal_case' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'native_function_casing' => true,
'native_type_declaration_casing' => true,
// additional rules from “Cast Notation” category
'modernize_types_casting' => true,
'no_short_bool_cast' => true,
// additional rules from “Class Notation” category
'class_attributes_separation' => [
'elements' => [
'const' => 'only_if_meta',
'method' => 'one',
'property' => 'only_if_meta',
'trait_import' => 'none',
'case' => 'none',
],
],
'final_class' => true,
'final_public_method_for_abstract_class' => true,
'ordered_interfaces' => true,
'ordered_traits' => true,
'ordered_types' => true,
'phpdoc_readonly_class_comment_to_keyword' => true,
'protected_to_private' => true,
'self_accessor' => true,
'self_static_accessor' => true,
// additional rules from “Class Usage” category
'date_time_immutable' => true,
// additional rules from “Comment” category
'comment_to_phpdoc' => true,
'multiline_comment_opening_closing' => true,
'no_empty_comment' => true,
'single_line_comment_spacing' => true,
'single_line_comment_style' => true,
// additional rules from “Constant Notation” category
'native_constant_invocation' => true,
// additional rules from "Control Structure" category
'empty_loop_body' => ['style' => 'braces'],
'empty_loop_condition' => true,
'include' => true,
'no_alternative_syntax' => true,
'no_superfluous_elseif' => true,
'no_unneeded_braces' => ['namespaces' => true],
'no_unneeded_control_parentheses' => [
'statements' => [
'break',
'clone',
'continue',
'echo_print',
'negative_instanceof',
'others',
'return',
'switch_case',
'yield',
'yield_from',
],
],
'no_useless_else' => true,
'simplified_if_return' => true,
'switch_continue_to_break' => true,
'yoda_style' => ['always_move_variable' => true],
// additional rules from “Function Notation” category
'date_time_create_from_format_call' => true,
'fopen_flag_order' => true,
'fopen_flags' => true,
'lambda_not_used_import' => true,
'native_function_invocation' => ['include' => ['@all']],
'no_useless_sprintf' => true,
'nullable_type_declaration_for_default_null_value' => true,
'regular_callable_call' => true,
'static_lambda' => true,
// additional rules from “Import” category
'fully_qualified_strict_types' => ['import_symbols' => true],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'no_unneeded_import_alias' => true,
'no_unused_imports' => true,
// additional rules from “Language Construct” category
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'declare_parentheses' => true,
'dir_constant' => true,
'error_suppression' => ['mute_deprecation_error' => false, 'noise_remaining_usages' => true],
'explicit_indirect_variable' => true,
'function_to_constant' => true,
'is_null' => true,
'no_unset_on_property' => true,
'nullable_type_declaration' => ['syntax' => 'union'],
'single_space_around_construct' => true,
// additional rules from “Namespace Notation” category
'no_leading_namespace_whitespace' => true,
// additional rules from “Naming” category
'no_homoglyph_names' => true,
// additional rules from “Operator” category
'increment_style' => true,
'logical_operators' => true,
'no_useless_concat_operator' => ['juggle_simple_strings' => true],
'no_useless_nullsafe_operator' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'operator_linebreak' => true,
'standardize_not_equals' => true,
'ternary_to_elvis_operator' => true,
// additional rules from “PHP Tag” category
'echo_tag_syntax' => true,
'linebreak_after_opening_tag' => true,
// additional rules from “PHPUnit” category
'php_unit_construct' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_mock_short_will_return' => true,
'php_unit_strict' => true,
'php_unit_test_case_static_method_calls' => true,
'php_unit_test_class_requires_covers' => true,
// additional rules from “PHPDoc” category
'align_multiline_comment' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_superfluous_phpdoc_tags' => true,
'phpdoc_align' => ['align' => 'left'],
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_line_span' => true,
'phpdoc_list_type' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order_by_value' => true,
'phpdoc_order' => true,
'phpdoc_param_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_summary' => true,
'phpdoc_tag_casing' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
// additional rules from “Return Notation” category
'no_useless_return' => true,
'simplified_null_return' => true,
// additional rules from “Semicolon” category
'multiline_whitespace_before_semicolons' => [
'strategy' => 'new_line_for_chained_calls',
],
'no_empty_statement' => true,
'no_singleline_whitespace_before_semicolons' => true,
'space_after_semicolon' => true,
// additional rules from “Strict” category
'strict_comparison' => true,
'strict_param' => true,
// additional rules from “String Notation” category
'explicit_string_variable' => true,
'heredoc_closing_marker' => ['explicit_heredoc_style' => true],
'heredoc_to_nowdoc' => true,
'no_binary_string' => true,
'single_quote' => true,
'string_implicit_backslashes' => true,
'string_length_to_empty' => true,
// additional rules from “Whitespace” category
'array_indentation' => true,
'method_chaining_indentation' => true,
'no_extra_blank_lines' => [
'tokens' => [
'attribute',
'break',
'case',
'continue',
'curly_brace_block',
'default',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'switch',
'throw',
'use',
],
],
'no_spaces_around_offset' => true,
'type_declaration_spaces' => true,
'types_spaces' => ['space' => 'single'],
];
$finder = Finder::create();
$finder->files();
$finder->in(dirs: __DIR__);
$finder->exclude(dirs: ['core/vendor', 'tools', 'website/var', 'website/vendor']);
$finder->append(iterator: [__FILE__, __DIR__ . '/website/bin/console']);
$config = new Config(name: 'Quintolin coding standard');
$config->setFinder(finder: $finder);
$config->setRiskyAllowed(isRiskyAllowed: true);
$config->setRules(rules: $rules);
return $config;