4
0

.php-cs-fixer.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. $finder = PhpCsFixer\Finder::create()
  3. ->notPath('tests/TestCase.php');
  4. $config = new PhpCsFixer\Config();
  5. $config->setRiskyAllowed(true);
  6. $config->setRules([
  7. // Rulesets
  8. '@PSR2' => true,
  9. '@PhpCsFixer' => true,
  10. '@PhpCsFixer:risky' => true,
  11. '@PHP56Migration:risky' => true,
  12. '@PHPUnit57Migration:risky' => true,
  13. // Additional rules
  14. 'fopen_flags' => true,
  15. 'linebreak_after_opening_tag' => true,
  16. // This one is non-deterministic based on what environment you are running it in and what `get_defined_constants` returns.
  17. 'native_constant_invocation' => false,
  18. 'native_function_invocation' => [
  19. "strict" => false,
  20. ],
  21. // --- Diffs from @PhpCsFixer / @PhpCsFixer:risky ---
  22. // This is the same as the default for the @PhpCsFixer ruleset, minus
  23. // the following values: ['include', 'include_once', 'require',
  24. // 'require_once']. We could enable them and remove this line after
  25. // updating codegen for the `init.php` file to be compliant.
  26. 'blank_line_before_statement' => ['statements' => ['break', 'case', 'continue', 'declare', 'default', 'exit', 'goto', 'return', 'switch', 'throw', 'try']],
  27. // This is just prettier / easier to read.
  28. 'concat_space' => ['spacing' => 'one'],
  29. // This causes strange ordering with codegen'd classes. We might be
  30. // able to enable this if we update codegen to output class elements
  31. // in the correct order.
  32. 'ordered_class_elements' => false,
  33. // Keep this disabled to avoid unnecessary diffs in PHPDoc comments of
  34. // codegen'd classes.
  35. 'phpdoc_align' => false,
  36. // This is a "risky" rule that causes a bug in our codebase.
  37. // Specifically, in `StripeObject.updateAttributes` we construct new
  38. // `StripeObject`s for metadata. We can't use `self` there because it
  39. // needs to be a raw `StripeObject`.
  40. 'self_accessor' => false,
  41. // Visibility annotations are not supported by php5.6
  42. 'visibility_required' => false,
  43. // Apparently "uninitialized" is distinct from "null" in some versions of PHP
  44. // so I am defensively disabling this rule so as to not cause breaking changes
  45. // but we can feel free to remove it in a major version (or maybe in a minor if
  46. // we devote some effort into determining that it is safe)
  47. 'no_null_property_initialization' => false,
  48. ]);
  49. $config->setFinder($finder);
  50. return $config;