exclude('bootstrap/cache') ->exclude('storage') ->exclude('vendor') ->in(__DIR__) ->name('*.php') ->ignoreDotFiles(true) ->ignoreVCS(true) ; return PhpCsFixer\Config::create() ->setRules([ 'align_multiline_comment' => [ 'comment_type' => 'phpdocs_only' ], 'array_indentation' => true, 'array_syntax' => [ 'syntax' => 'short' ], 'binary_operator_spaces' => [ 'default' => 'single_space' ], 'blank_line_after_namespace' => true, 'blank_line_after_opening_tag' => true, //'blank_line_before_statement' => [ // 'statements' => ['break', 'case', 'continue', 'declare', 'default', 'die', 'do', 'exit', 'for', 'foreach', 'goto', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield'] // ] 'braces' => [ 'allow_single_line_closure' => true, 'position_after_anonymous_constructs' => 'same', 'position_after_control_structures' => 'next', 'position_after_functions_and_oop_constructs' => 'next' ], 'cast_spaces' => [ 'space' => 'none' ], 'class_attributes_separation' => [ 'elements' => ['const', 'method', 'property'] ], 'class_definition' => [ 'multi_line_extends_each_single_line' => false, 'single_item_single_line' => false, 'single_line' => false ], 'class_keyword_remove' => false, 'combine_consecutive_issets' => false, 'combine_consecutive_unsets' => true, 'combine_nested_dirname' => true, 'comment_to_phpdoc' => true, 'compact_nullable_typehint' => true, 'concat_space' => [ 'spacing' => 'none' ], //'date_time_immutable' => false, 'declare_equal_normalize' => [ 'space'=>'none' ], 'declare_strict_types' => true, 'dir_constant' => true, 'elseif' => true, 'encoding' => true, 'ereg_to_preg' => true, 'error_suppression' => [ 'mute_deprecation_error' => false, 'noise_remaining_usages' => true, 'noise_remaining_usages_exclude' => [] // functions to exclude ], 'escape_implicit_backslashes' => [ 'double_quoted' => true, 'heredoc_syntax' => true, 'single_quoted' => true ], 'explicit_indirect_variable' => true, 'explicit_string_variable' => false, //'final_class' => true, // mark all non-abstract classes as final //'final_internal_class' => [ see doc for opts ] // mark all internal classes as final 'fopen_flag_order' => true, 'fopen_flags' => [ 'b_mode' => true ], 'full_opening_tag' => true, //'fully_qualified_strict_types' => ???, 'function_declaration' => [ 'closure_function_spacing' => 'none' ], //'function_to_constant' => [ // replaces get_called_class, get_class, php_sapi_name, phpversion, pi with // constants... not sure how that could be valid? //], 'function_typehint_space' => true, 'general_phpdoc_annotation_remove' => [ 'annotations' => [] // list of @annotations to remove form phpdoc comments ], //'heredoc_indentation' => true, // requires php 7.3 'heredoc_to_nowdoc' => true, 'implode_call' => true, 'include' => true, //'increment_style' => [ // 'style' => // post/pre //], 'indentation_type' => true, 'is_null' => true, 'line_ending' => true, 'linebreak_after_opening_tag' => true, 'list_syntax' => [ 'syntax' => 'short' ], 'logical_operators' => true, 'lowercase_cast' => true, 'lowercase_constants' => true, 'lowercase_keywords' => true, 'lowercase_static_reference' => true, 'magic_constant_casing' => true, 'magic_method_casing' => true, //'mb_str_function' => true, // replace non-mb safe with mb_ methods 'method_argument_space' => [ 'keep_multiple_spaces_after_comma' => false, 'on_multiline' => 'ignore' // ensure_fully_multiline, ensure_single_line, ignore ], 'method_chaining_indentation' => true, 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, 'multiline_whitespace_before_semicolons' => [ 'strategy' => 'new_line_for_chained_calls' ], 'native_constant_invocation' => [], 'native_function_casing' => true, 'native_function_invocation' => [], 'native_function_type_declaration_casing' => true, //'new_with_brances' => true, // no idea what this does? included in @Symfony bundle 'no_alias_functions' => [], 'no_alternative_syntax' => true, // get rid of while {} endwhile; stuff 'no_binary_string' => true, 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, //'no_blank_lines_before_namespace' => true, 'no_break_comment' => [ 'comment_text' => 'no break' ], 'no_closing_tag' => true, 'no_empty_comment' => true, 'no_empty_phpdoc' => true, 'no_empty_statement' => true, 'no_extra_blank_lines' => [ 'tokens' => ['extra'] ], 'no_homoglyph_names' => true, 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_mixed_echo_print' => [ 'use' => 'echo' ], 'no_multiline_whitespace_around_double_arrow' => true, 'no_null_property_initialization' => false, //'no_php4_constructor' => true, 'no_short_bool_cast' => true, 'no_short_echo_tag' => false, 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_after_function_name' => true, 'no_spaces_around_offset' => [ 'positions' => ['inside', 'outside'] ], 'no_spaces_inside_parenthesis' => true, //'no_superfluous_elseif' => false, // don't know what this would do? //'no_superfluous_phpdoc_tags' => [ // removes @param/@return that "don't provide any useful information" //], 'no_trailing_comma_in_list_call' => true, 'no_trailing_comma_in_singleline_array' => true, 'no_trailing_whitespace' => true, 'no_trailing_whitespace_in_comment' => true, 'no_unneeded_control_parentheses' => true, 'no_unneeded_curly_braces' => true, 'no_unneeded_final_method' => true, 'no_unreachable_default_argument_value' => true, 'no_unset_cast' => true, 'no_unset_on_property' => false, 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, 'no_whitespace_before_comma_in_array' => [ 'after_heredoc' => false ], 'no_whitespace_in_blank_line' => true, 'non_printable_character' => [ 'use_escape_sequences_in_strings' => true // don't just remove them, make them visible to the programmer and let them sort it out ], 'normalize_index_brace' => true, 'not_operator_with_space' => false, 'not_operator_with_successor_space' => false, 'object_operator_without_whitespace' => true, //'ordered_class_elements' => [ // lets us sort methods/props/etc in classes // 'order' => [], // 'sortAlgorithm'=>'' //], //'ordered_imports' => [ // sort use statements, off so we can retain some sort of context // 'sort_algorithm' => 'alpha' //], //'ordered_interfaces' => [ // sort implements or interface extends //], 'php_unit_construct' => [ // replace phpunit's ->assertSame(true, $foo) with ->assertTrue($foo) ], 'php_unit_dedicate_assert' => [ // try and replace things like assertTrue(file_exists()) with assertFileExists 'target'=>'newest' ], 'php_unit_dedicate_assert_internal_type' => [ 'target'=>'newest' ], 'php_unit_expectation' => [ // should use expectException instead of setExpectedException 'target' => 'newest' ], 'php_unit_fqcn_annotation' => true, 'php_unit_internal_class' => [ // phpunit tests should be marked internal 'types' => ['normal', 'final'] ], 'php_unit_mock' => [ // use createMock instead of getMock 'target' => 'newest' ], 'php_unit_mock_short_will_return' => true, 'php_unit_namespaced' => true, 'php_unit_no_expectation_annotation' => [ 'target'=>'newest' ], 'php_unit_ordered_covers' => true, 'php_unit_set_up_tear_down_visibility' => true, //'php_unit_size_class' => true, // tests should have @small/@medium/@large annotation 'php_unit_strict' => [ ], 'php_unit_test_annotation' => [ // add @test annotation to tests ], 'php_unit_test_case_static_method_calls' => [ ], 'php_unit_test_class_requires_covers' => true, 'phpdoc_add_missing_param_annotation' => [ 'only_untyped' => false ], 'phpdoc_align' => [ 'align' => 'vertical' ], 'phpdoc_annotation_without_dot' => true, 'phpdoc_indent' => true, 'phpdoc_inline_tag' => true, 'phpdoc_no_access' => true, //'phpdoc_no_alias_tag' => [], 'phpdoc_no_empty_return' => false, 'phpdoc_no_package' => true, 'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_order' => true, 'phpdoc_return_self_reference' => [], 'phpdoc_scalar' => true, 'phpdoc_separation' => false, 'phpdoc_single_line_var_spacing' => true, 'phpdoc_summary' => true, //'phpdoc_to_comment' => false, // we sometimes use these for phan suppression and stuff //'phpdoc_to_return_type' => [ 'scalar_types' => true ], 'phpdoc_trim' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, 'phpdoc_types' => [ // fix casing of types in phpdoc 'groups' => ['simple', 'alias', 'meta'] ], 'phpdoc_types_order' => [ 'null_adjustment' => 'always_last', 'sort_algorithm' => 'none' ], 'phpdoc_var_annotation_correct_order' => true, 'phpdoc_var_without_name' => true, 'pow_to_exponentiation' => true, //'protected_to_private' => true, // convert protected methods to private ones 'psr4' => true, // class name should match filename 'random_api_migration' => [ // replace rand/srand/etc with the mt_ funcs ], 'return_assignment' => true, 'return_type_declaration' => [ 'space_before' => 'none' ], //'self_accessor' => false, // force use of self instead of class name 'semicolon_after_instruction' => true, 'set_type_to_cast' => true, // use casting not settype 'short_scalar_cast' => true, // use bool not boolean, int not integer, etc 'simple_to_complex_string_variable' => false, // convert ${var} to {$var} in strings 'simplified_null_return' => true, // don't `return null`, just `return` 'single_blank_line_at_eof' => true, 'single_blank_line_before_namespace' => true, 'single_class_element_per_statement' => [ 'elements' => ['const', 'property'] ], 'single_import_per_statement' => true, 'single_line_after_imports' => true, 'single_line_comment_style' => [ 'comment_types' => ['asterisk', 'hash'] ], 'single_quote' => [ 'strings_containing_single_quote_chars' => false ], 'single_trait_insert_per_statement' => true, 'space_after_semicolon' => [ 'remove_in_empty_for_expressions' => false ], 'standardize_increment' => true, 'standardize_not_equals' => true, 'static_lambda' => true, //'strict_comparsion' => true, // would be good to *check* but not change //'strict_param' => true, //'string_line_ending' => true, // could screw up literals that are used for comparison to outside sourced data 'switch_case_semicolon_to_colon' => true, 'switch_case_space' => true, 'ternary_operator_spaces' => true, 'ternary_to_null_coalescing' => true, //'trailing_comma_in_multiline_array' => [ // no option to *remove* //], 'trim_array_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => [ 'elements' => ['property', 'method', 'const'] ], //'void_return' => true, // adds a void return type to functions without a @return/:return 'whitespace_after_comma_in_array' => true, //'yoda_style' => [ // would be a good habit but I find it hard to read // 'always_move_variable' => false, // 'equal' => false, // 'identical' => false, // 'less_and_greater' => false //] ]) ->setIndent("\t") ->setLineEnding("\n") ->setFinder($finder) ;