Skip to content

Commit

Permalink
Last set of PHP-CS-Fixer updates (#875)
Browse files Browse the repository at this point in the history
* Update .php_cs.dist

* Use standard configuration for multiline_whitespace_before_semicolons rule

* Enable private_to_protected rule

* Update .php_cs.dist
  • Loading branch information
ob-stripe authored Feb 13, 2020
1 parent 87b4701 commit f7c6462
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
41 changes: 26 additions & 15 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,33 @@ return PhpCsFixer\Config::create()
'@PHP56Migration:risky' => true,
'@PHPUnit57Migration:risky' => true,

// Diffs from @PhpCsFixer / @PhpCsFixer:risky
'concat_space' => [
'spacing' => 'one',
],
// Additional rules
'fopen_flags' => true,
'linebreak_after_opening_tag' => true,
'native_function_invocation' => true,

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

// 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,

// This can be enabled once we update every test class and method with
// the correct `@covers` annotations.
'php_unit_test_class_requires_covers' => false,
'phpdoc_align' => false,
'protected_to_private' => false,
'self_accessor' => false,

// Should be included in @PhpCsFixer / @PhpCsFixer:risky according to doc, but need to be
// enabled manually for some reason.
'fopen_flags' => true,
'multiline_whitespace_before_semicolons' => true,
'native_function_invocation' => true,
// Keep this disabled to avoid unnecessary diffs in PHPDoc comments of
// codegen'd classes.
'phpdoc_align' => false,

// Additional rules
'linebreak_after_opening_tag' => true,
]);
// 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,
])
;
6 changes: 4 additions & 2 deletions tests/Stripe/StripeTelemetryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public function testNoTelemetrySentIfNotEnabled()
$stub = $this
->getMockBuilder('HttpClient\\ClientInterface')
->setMethods(['request'])
->getMock();
->getMock()
;

$stub->expects(static::any())
->method('request')
Expand Down Expand Up @@ -75,7 +76,8 @@ public function testTelemetrySetIfEnabled()
$stub = $this
->getMockBuilder('HttpClient\\ClientInterface')
->setMethods(['request'])
->getMock();
->getMock()
;

$stub->expects(static::any())
->method('request')
Expand Down
9 changes: 6 additions & 3 deletions tests/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function ($method, $absUrl, $headers, $params, $hasFile) {

return $curlClient->request($method, $absUrl, $headers, $params, $hasFile);
}
);
)
;
}

/**
Expand Down Expand Up @@ -124,7 +125,8 @@ protected function stubRequest(
$base = null
) {
$this->prepareRequestMock($method, $path, $params, $headers, $hasFile, $base)
->willReturn([\json_encode($response), $rcode, []]);
->willReturn([\json_encode($response), $rcode, []])
;
}

/**
Expand Down Expand Up @@ -179,6 +181,7 @@ private function prepareRequestMock(
}),
null === $params ? static::anything() : static::identicalTo($params),
static::identicalTo($hasFile)
);
)
;
}
}

0 comments on commit f7c6462

Please sign in to comment.