.php-cs-fixer.dist.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* PHP 7.0 */
  3. $finder = (new PhpCsFixer\Finder())
  4. ->in(__DIR__)
  5. ->exclude([
  6. 'core/includes',
  7. 'custom',
  8. 'documents',
  9. 'doctemplates',
  10. 'vendor',
  11. 'install/doctemplates',
  12. 'htdocs/custom',
  13. 'htdocs/includes',
  14. 'htdocs/install/doctemplates',
  15. ])
  16. ->notPath('vendor');
  17. /* PHP 7.4+ */
  18. /*
  19. $finder = (new PhpCsFixer\Finder())
  20. ->in(__DIR__)
  21. ->exclude([
  22. 'custom',
  23. 'documents',
  24. 'htdocs/custom',
  25. 'htdocs/includes',
  26. ])
  27. ->notPath([
  28. 'vendor',
  29. ]);
  30. */
  31. return (new PhpCsFixer\Config())
  32. ->setRules([
  33. // Apply PSR-12 as per https://wiki.dolibarr.org/index.php?title=Langages_et_normes#PHP:~:text=utiliser%20est%20le-,PSR%2D12,-(https%3A//www
  34. '@PSR12' => true, // Disabled for now to limit number of changes
  35. // Minimum version Dolibarr v18.0.0
  36. // Compatibility with min 7.1 is announced with Dolibarr18.0 but
  37. // app is still working with 7.0 so no reason to abandon compatiblity with this target for the moment.
  38. // So we use target PHP70 for the moment.
  39. '@PHP70Migration' => true,
  40. //'@PHP71Migration' => true,
  41. // Avoid adding public to const (incompatible with PHP 7.0):
  42. 'visibility_required' => ['elements'=>['property', 'method']],
  43. //'strict_param' => true,
  44. //'array_syntax' => ['syntax' => 'short'],
  45. //'list_syntax' => false,
  46. //'visibility_required' => false,
  47. 'array_syntax' => false,
  48. 'ternary_to_null_coalescing' => false
  49. ])
  50. ->setFinder($finder)
  51. // TAB Indent violates PSR-12 "must" rule, but used in code
  52. // (See https://www.php-fig.org/psr/psr-12/#24-indenting )
  53. ->setIndent("\t")
  54. // All files MUST use the Unix LF line ending only
  55. // https://www.php-fig.org/psr/psr-12/#22-files
  56. ->setLineEnding("\n")
  57. ;