Skip to content

Commit

Permalink
Update CS fixer to v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed May 5, 2021
1 parent 01d0190 commit c86e679
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --diff-format=udiff --dry-run --show-progress=dots --using-cache=no --verbose .
args: --dry-run --show-progress=dots --using-cache=no --verbose .

phpstan:
name: PHPStan
Expand Down
48 changes: 48 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

$config = new PhpCsFixer\Config();
$config->setRiskyAllowed(true);
$config->setRules([
// Rulesets
'@PSR2' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP56Migration:risky' => true,
'@PHPUnit57Migration:risky' => true,

// Additional rules
'fopen_flags' => true,
'linebreak_after_opening_tag' => true,
'native_constant_invocation' => true,
'native_function_invocation' => ['include' => ['@internal'], 'strict' => false],

// --- Diffs from @PhpCsFixer / @PhpCsFixer:risky ---

// This is the same as the default for the @PhpCsFixer ruleset, minus
// the following values: ['include', 'include_once', 'require',
// 'require_once']. We could enable them and remove this line after
// updating codegen for the `init.php` file to be compliant.
'blank_line_before_statement' => ['statements' => ['break', 'case', 'continue', 'declare', 'default', 'exit', 'goto', 'return', 'switch', 'throw', 'try']],

// This is just prettier / easier to read.
'concat_space' => ['spacing' => 'one'],

// This causes strange ordering with codegen'd classes. We might be
// able to enable this if we update codegen to output class elements
// in the correct order.
'ordered_class_elements' => false,

// Keep this disabled to avoid unnecessary diffs in PHPDoc comments of
// codegen'd classes.
'phpdoc_align' => false,

// This is a "risky" rule that causes a bug in our codebase.
// Specifically, in `StripeObject.updateAttributes` we construct new
// `StripeObject`s for metadata. We can't use `self` there because it
// needs to be a raw `StripeObject`.
'self_accessor' => false,

'visibility_required' => false,
]);
return $config;

45 changes: 0 additions & 45 deletions .php_cs.dist

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"phpunit/phpunit": "^5.7",
"php-coveralls/php-coveralls": "^2.1",
"squizlabs/php_codesniffer": "^3.3",
"symfony/process": "~3.4",
"friendsofphp/php-cs-fixer": "2.17.1"
"symfony/process": "~5.0",
"friendsofphp/php-cs-fixer": "3.0.0"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit c86e679

Please sign in to comment.