Created
March 6, 2023 14:53
-
-
Save irealworlds/94eac8ca7f4878fbfa9091f668baade3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* This document has been generated with | |
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.12.0|configurator | |
* you can change this configuration by importing this file. | |
*/ | |
$config = new PhpCsFixer\Config(); | |
return $config | |
->setRiskyAllowed(true) | |
->setRules([ | |
// Each line of multi-line DocComments must have an asterisk [PSR-5] and must be aligned with the first one. | |
'align_multiline_comment' => true, | |
// Each element of an array must be indented exactly once. | |
'array_indentation' => true, | |
// Converts simple usages of `array_push($x, $y);` to `$x[] = $y;`. | |
'array_push' => true, | |
// PHP arrays should be declared using the configured syntax. | |
'array_syntax' => true, | |
// Use the null coalescing assignment operator `??=` where possible. | |
'assign_null_coalescing_to_coalesce_equal' => true, | |
// Converts backtick operators to `shell_exec` calls. | |
'backtick_to_shell_exec' => true, | |
// Binary operators should be surrounded by space as configured. | |
'binary_operator_spaces' => true, | |
// There MUST be one blank line after the namespace declaration. | |
'blank_line_after_namespace' => true, | |
// Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line. | |
'blank_line_after_opening_tag' => true, | |
// A single space or none should be between cast and variable. | |
'cast_spaces' => true, | |
// Class, trait and interface elements must be separated with one or none blank line. | |
'class_attributes_separation' => true, | |
// Whitespace around the keywords of a class, trait, enum or interfaces definition should be one space. | |
'class_definition' => true, | |
// When referencing an internal class it must be written using the correct casing. | |
'class_reference_name_casing' => true, | |
// The PHP constants `true`, `false`, and `null` MUST be written using the correct casing. | |
'constant_case' => true, | |
// Replaces `dirname(__FILE__)` expression with equivalent `__DIR__` constant. | |
'dir_constant' => true, | |
// PHP code must use the long `<?php` tags or short-echo `<?=` tags and not other tag variations. | |
'full_opening_tag' => true, | |
// Transforms imported FQCN parameters and return types in function arguments to short version. | |
'fully_qualified_strict_types' => true, | |
// Replace `get_class` calls on object variables with class keyword syntax. | |
'get_class_to_class_keyword' => true, | |
// There MUST be group use for the same namespaces. | |
'group_import' => true, | |
// Code MUST use configured indentation type. | |
'indentation_type' => true, | |
// Replaces `is_null($var)` expression with `null === $var`. | |
'is_null' => true, | |
// Lambda must not import variables it doesn't use. | |
'lambda_not_used_import' => true, | |
// All PHP files must use same line ending. | |
'line_ending' => true, | |
// Use `&&` and `||` logical operators instead of `and` and `or`. | |
'logical_operators' => true, | |
// Replace non multibyte-safe functions with corresponding mb function. | |
'mb_str_functions' => true, | |
// Method chaining MUST be properly indented. Method chaining with different levels of indentation is not supported. | |
'method_chaining_indentation' => true, | |
// Replace `strpos()` calls with `str_starts_with()` or `str_contains()` if possible. | |
'modernize_strpos' => true, | |
// Replaces `intval`, `floatval`, `doubleval`, `strval` and `boolval` function calls with according type casting operator. | |
'modernize_types_casting' => true, | |
// Function defined by PHP should be called using the correct casing. | |
'native_function_casing' => true, | |
// All instances created with `new` keyword must (not) be followed by braces. | |
'new_with_braces' => true, | |
// There must be a comment when fall-through is intentional in a non-empty case body. | |
'no_break_comment' => true, | |
// The closing `? >` tag MUST be omitted from files containing only PHP. | |
'no_closing_tag' => true, | |
// There should not be any empty comments. | |
'no_empty_comment' => true, | |
// There should not be empty PHPDoc blocks. | |
'no_empty_phpdoc' => true, | |
// Remove useless (semicolon) statements. | |
'no_empty_statement' => true, | |
// Removes extra blank lines and/or blank lines following configuration. | |
'no_extra_blank_lines' => true, | |
// Replace accidental usage of homoglyphs (non ascii characters) in names. | |
'no_homoglyph_names' => true, | |
// Remove leading slashes in `use` clauses. | |
'no_leading_import_slash' => true, | |
// Either language construct `print` or `echo` should be used. | |
'no_mixed_echo_print' => true, | |
// Imports should not be aliased as the same name. | |
'no_unneeded_import_alias' => true, | |
// Properties should be set to `null` instead of using `unset`. | |
'no_unset_on_property' => true, | |
// Unused `use` statements must be removed. | |
'no_unused_imports' => true, | |
// Ordering `use` statements. | |
'ordered_imports' => true, | |
// Trait `use` statements must be sorted alphabetically. | |
'ordered_traits' => true, | |
// PHPUnit annotations should be a FQCNs including a root namespace. | |
'php_unit_fqcn_annotation' => true, | |
// All PHPUnit test classes should be marked as internal. | |
'php_unit_internal_class' => true, | |
// Usages of `->getMock` and `->getMockWithoutInvokingTheOriginalConstructor` methods MUST be replaced by `->createMock` or `->createPartialMock` methods. | |
'php_unit_mock' => true, | |
// Usage of PHPUnit's mock e.g. `->will($this->returnValue(..))` must be replaced by its shorter equivalent such as `->willReturn(...)`. | |
'php_unit_mock_short_will_return' => true, | |
// PHPUnit classes MUST be used in namespaced version, e.g. `\PHPUnit\Framework\TestCase` instead of `\PHPUnit_Framework_TestCase`. | |
'php_unit_namespaced' => true, | |
// Usages of `@expectedException*` annotations MUST be replaced by `->setExpectedException*` methods. | |
'php_unit_no_expectation_annotation' => true, | |
// Adds or removes @test annotations from tests, following configuration. | |
'php_unit_test_annotation' => ['style'=>'annotation'], | |
// Adds a default `@coversNothing` annotation to PHPUnit test classes that have no `@covers*` annotation. | |
'php_unit_test_class_requires_covers' => true, | |
// PHPDoc should contain `@param` for all params. | |
'phpdoc_add_missing_param_annotation' => true, | |
// Scalar types should always be written in the same form. `int` not `integer`, `bool` not `boolean`, `float` not `real` or `double`. | |
'phpdoc_scalar' => true, | |
// Fixes casing of PHPDoc tags. | |
'phpdoc_tag_casing' => true, | |
// Converts `pow` to the `**` operator. | |
'pow_to_exponentiation' => true, | |
// Classes must be in a path that matches their namespace, be at least one namespace deep and the class name should match the file name. | |
'psr_autoloading' => true, | |
// Replaces `rand`, `srand`, `getrandmax` functions calls with their `mt_*` analogs or `random_int`. | |
'random_api_migration' => true, | |
// Cast `(boolean)` and `(integer)` should be written as `(bool)` and `(int)`, `(double)` and `(real)` as `(float)`, `(binary)` as `(string)`. | |
'short_scalar_cast' => true, | |
// Simplify `if` control structures that return the boolean result of their condition. | |
'simplified_if_return' => true, | |
// A return statement wishing to return `void` should not return `null`. | |
'simplified_null_return' => true, | |
// Each trait `use` must be done as single statement. | |
'single_trait_insert_per_statement' => true, | |
// Increment and decrement operators should be used if possible. | |
'standardize_increment' => true, | |
// Replace all `<>` with `!=`. | |
'standardize_not_equals' => true, | |
// Comparisons should be strict. | |
'strict_comparison' => true, | |
// A case should be followed by a colon and not a semicolon. | |
'switch_case_semicolon_to_colon' => true, | |
// Switch case must not be ended with `continue` but with `break`. | |
'switch_continue_to_break' => true, | |
// Use `null` coalescing operator `??` where possible. Requires PHP >= 7.0. | |
'ternary_to_null_coalescing' => true, | |
// Anonymous functions with one-liner return statement must use arrow functions. | |
'use_arrow_functions' => true, | |
// Visibility MUST be declared on all properties and methods; `abstract` and `final` MUST be declared before the visibility; `static` MUST be declared after the visibility. | |
'visibility_required' => true, | |
// Add `void` return type to functions with missing or empty return statements, but priority is given to `@return` annotations. Requires PHP >= 7.1. | |
'void_return' => true, | |
]) | |
->setFinder(PhpCsFixer\Finder::create() | |
// ->exclude('folder-to-exclude') // if you want to exclude some folders, you can do it like this! | |
->in(__DIR__) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment