.php_cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * This file represents the configuration for Code Sniffing PSR-2-related
  4. * checks of coding guidelines and is based on a template from the news extension
  5. * by Georg Ringer for the TYPO3 CMS.
  6. *
  7. * Install @fabpot's great php-cs-fixer tool via
  8. *
  9. * $ composer global require friendsofphp/php-cs-fixer
  10. *
  11. * And then simply run
  12. *
  13. * $ php-cs-fixer fix --config .php_cs
  14. *
  15. * For more information read:
  16. * http://www.php-fig.org/psr/psr-2/
  17. * http://cs.sensiolabs.org
  18. */
  19. if (PHP_SAPI !== 'cli') {
  20. die('This script supports command line usage only. Please check your command.');
  21. }
  22. // Define in which folders to search and which folders to exclude
  23. // Exclude some directories that are excluded by Git anyways to speed up the sniffing
  24. $finder = PhpCsFixer\Finder::create()
  25. ->exclude('vendor/')
  26. ->in(__DIR__);
  27. // Return a Code Sniffing configuration using
  28. // all sniffers needed for PSR-2
  29. // and additionally:
  30. // - Remove leading slashes in use clauses.
  31. // - PHP single-line arrays should not have trailing comma.
  32. // - Single-line whitespace before closing semicolon are prohibited.
  33. // - Remove unused use statements in the PHP source code
  34. // - Ensure Concatenation to have at least one whitespace around
  35. // - Remove trailing whitespace at the end of blank lines.
  36. return PhpCsFixer\Config::create()
  37. ->setRiskyAllowed(true)
  38. ->setRules([
  39. '@PSR2' => true,
  40. 'align_multiline_comment' => [
  41. 'comment_type' => 'all_multiline',
  42. ],
  43. 'array_syntax' => [
  44. 'syntax' => 'short'
  45. ],
  46. 'binary_operator_spaces' => [
  47. 'default' => 'single_space'
  48. ],
  49. 'concat_space' => [
  50. 'spacing' => 'one'
  51. ],
  52. 'function_typehint_space' => true,
  53. 'hash_to_slash_comment' => true,
  54. 'lowercase_cast' => true,
  55. 'native_function_casing' => true,
  56. 'no_alias_functions' => true,
  57. 'no_blank_lines_after_phpdoc' => true,
  58. 'no_empty_statement' => true,
  59. 'no_extra_consecutive_blank_lines' => true,
  60. 'no_leading_import_slash' => true,
  61. 'no_leading_namespace_whitespace' => true,
  62. 'no_trailing_comma_in_singleline_array' => true,
  63. 'no_short_bool_cast' => true,
  64. 'no_singleline_whitespace_before_semicolons' => true,
  65. 'no_unused_imports' => true,
  66. 'no_unneeded_control_parentheses' => true,
  67. 'no_whitespace_in_blank_line' => true,
  68. 'ordered_imports' => true,
  69. 'phpdoc_no_empty_return' => true,
  70. 'phpdoc_no_package' => false,
  71. 'phpdoc_scalar' => true,
  72. 'phpdoc_trim' => true,
  73. 'return_type_declaration' => [
  74. 'space_before' => 'none'
  75. ],
  76. 'self_accessor' => true,
  77. 'single_quote' => true,
  78. 'standardize_not_equals' => true,
  79. 'whitespace_after_comma_in_array' => true,
  80. ])
  81. ->setFinder($finder);