RoundCube Webmail
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.8 KiB

  1. <?php
  2. use PhpCsFixer\Config;
  3. use PhpCsFixer\Finder;
  4. use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
  5. $finder = Finder::create()
  6. ->in([__DIR__])
  7. ->exclude([
  8. 'node_modules',
  9. 'vendor',
  10. ])
  11. ->ignoreDotFiles(false)
  12. ->name('*.php.dist')
  13. ->name('*.sh');
  14. return (new Config())
  15. ->setParallelConfig(ParallelConfigFactory::detect())
  16. ->setRiskyAllowed(true)
  17. ->setRules([
  18. '@PhpCsFixer' => true,
  19. '@PhpCsFixer:risky' => true,
  20. '@PHP81Migration' => true,
  21. // required by PSR-12
  22. 'concat_space' => [
  23. 'spacing' => 'one',
  24. ],
  25. // disable some too strict rules
  26. 'phpdoc_types_order' => [
  27. 'null_adjustment' => 'always_last',
  28. 'sort_algorithm' => 'none',
  29. ],
  30. 'single_line_throw' => false,
  31. 'yoda_style' => [
  32. 'equal' => false,
  33. 'identical' => false,
  34. ],
  35. 'native_constant_invocation' => [
  36. 'include' => [
  37. // https://github.com/php/php-src/commit/2475337bd8a0fad0dac03db3f5e7e9d331d53653
  38. 'LOG_LOCAL0',
  39. 'LOG_LOCAL1',
  40. 'LOG_LOCAL2',
  41. 'LOG_LOCAL3',
  42. 'LOG_LOCAL4',
  43. 'LOG_LOCAL5',
  44. 'LOG_LOCAL6',
  45. 'LOG_LOCAL7',
  46. // https://github.com/php/php-src/blob/php-8.3.0/ext/ldap/ldap.stub.php#L104
  47. 'LDAP_OPT_PROTOCOL_VERSION',
  48. // https://github.com/php/pecl-text-pspell/blob/1.0.1/pspell.stub.php#L24
  49. 'PSPELL_FAST',
  50. // https://github.com/websupport-sk/pecl-memcache/blob/8.2/src/memcache.c#L755
  51. 'MEMCACHE_COMPRESSED',
  52. ],
  53. ],
  54. 'native_function_invocation' => false,
  55. 'void_return' => false,
  56. 'blank_line_before_statement' => [
  57. 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'],
  58. ],
  59. 'final_internal_class' => false,
  60. 'combine_consecutive_issets' => false,
  61. 'combine_consecutive_unsets' => false,
  62. 'multiline_whitespace_before_semicolons' => false,
  63. 'no_superfluous_elseif' => false,
  64. 'ordered_class_elements' => false,
  65. 'php_unit_internal_class' => false,
  66. 'php_unit_test_class_requires_covers' => false,
  67. 'phpdoc_add_missing_param_annotation' => false,
  68. 'return_assignment' => false,
  69. 'comment_to_phpdoc' => false,
  70. 'general_phpdoc_annotation_remove' => [
  71. 'annotations' => ['author', 'copyright', 'throws'],
  72. ],
  73. // fn => without curly brackets is less readable,
  74. // also prevent bounding of unwanted variables for GC
  75. 'use_arrow_functions' => false,
  76. // disable too destructive formating for now
  77. 'blank_line_before_statement' => false,
  78. 'declare_strict_types' => false,
  79. 'increment_style' => [
  80. 'style' => 'post',
  81. ],
  82. 'php_unit_data_provider_name' => [
  83. 'prefix' => 'provide_',
  84. 'suffix' => '_cases',
  85. ],
  86. 'php_unit_method_casing' => false,
  87. 'php_unit_test_case_static_method_calls' => false,
  88. 'psr_autoloading' => false,
  89. 'strict_comparison' => false,
  90. 'octal_notation' => false,
  91. // TODO
  92. 'array_indentation' => false,
  93. 'general_phpdoc_annotation_remove' => false,
  94. 'method_argument_space' => ['on_multiline' => 'ignore'],
  95. 'modernize_types_casting' => false,
  96. 'no_blank_lines_after_phpdoc' => false,
  97. 'no_break_comment' => false,
  98. 'phpdoc_summary' => false,
  99. // TODO - risky
  100. 'strict_param' => false,
  101. ])
  102. ->setFinder($finder)
  103. ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');