Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get closer to @PhpCsFixer standard ruleset #865

Merged
merged 97 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
99862a8
Use array_indentation rule
ob-stripe Feb 7, 2020
3c2cd77
Use cast_spaces rule
ob-stripe Feb 7, 2020
38b4ab2
Use class_definition rule
ob-stripe Feb 7, 2020
9a5e8c6
Use combine_consecutive_unsets rule
ob-stripe Feb 7, 2020
4990b41
Use comment_to_phpdoc rule
ob-stripe Feb 7, 2020
6a8fd09
Use compact_nullable_typehint rule
ob-stripe Feb 7, 2020
dd332f4
Use concat_space rule
ob-stripe Feb 7, 2020
6febfed
Use declare_equal_normalize rule
ob-stripe Feb 7, 2020
6a34965
Use ereg_to_preg rule
ob-stripe Feb 7, 2020
a1dd4ae
Use error_suppression rule
ob-stripe Feb 7, 2020
e3c9768
Use escape_implicit_backslashes rule
ob-stripe Feb 7, 2020
dab9e29
Use explicit_string_variable rule
ob-stripe Feb 7, 2020
4dcfc31
Use final_internal_class rule
ob-stripe Feb 7, 2020
228d348
Use fopen_flag_order rule
ob-stripe Feb 7, 2020
9c95ad6
Use fopen_flags rule
ob-stripe Feb 7, 2020
9a06631
Use fully_qualified_strict_types rule
ob-stripe Feb 7, 2020
8339363
Use function_to_constant rule
ob-stripe Feb 7, 2020
b6aac1d
Use function_typehint_space rule
ob-stripe Feb 7, 2020
030772f
Use heredoc_to_nowdoc rule
ob-stripe Feb 7, 2020
99c9a20
Use implode_call rule
ob-stripe Feb 7, 2020
4528c66
Use increment_style rule
ob-stripe Feb 7, 2020
e3410ff
Use is_null rule
ob-stripe Feb 7, 2020
b0394a2
Use logical_operators rule
ob-stripe Feb 7, 2020
3cdeae4
Use lowercase_cast rule
ob-stripe Feb 7, 2020
ca659ed
Use lowercase_static_reference rule
ob-stripe Feb 7, 2020
25020bc
Use magic_constant_casing rule
ob-stripe Feb 7, 2020
102075d
Use magic_method_casing rule
ob-stripe Feb 7, 2020
a274a36
Use method_chaining_indentation rule
ob-stripe Feb 7, 2020
65f91c0
Use modernize_types_casting rule
ob-stripe Feb 7, 2020
fb437b3
Use multiline_comment_opening_closing rule
ob-stripe Feb 7, 2020
b0e0217
Use multiline_whitespace_before_semicolons rule
ob-stripe Feb 7, 2020
d813bf9
Use native_constant_invocation rule
ob-stripe Feb 7, 2020
4d1bc4d
Use native_function_casing rule
ob-stripe Feb 7, 2020
000f019
Use native_function_type_declaration_casing rule
ob-stripe Feb 7, 2020
ab7f07f
Use new_with_braces rule
ob-stripe Feb 7, 2020
cd33de2
Use no_alias_functions rule
ob-stripe Feb 7, 2020
b5a03a7
Use no_alternative_syntax rule
ob-stripe Feb 7, 2020
3cf8e07
Use no_binary_string rule
ob-stripe Feb 7, 2020
bb54f18
Use no_blank_lines_after_class_opening rule
ob-stripe Feb 7, 2020
7576001
Use no_empty_comment rule
ob-stripe Feb 7, 2020
f566e41
Use no_empty_statement rule
ob-stripe Feb 7, 2020
a7f0d2e
Use no_extra_blank_lines rule
ob-stripe Feb 7, 2020
67f4ad6
Use no_homoglyph_names rule
ob-stripe Feb 7, 2020
dbc104b
Use no_leading_import_slash rule
ob-stripe Feb 7, 2020
ea46b51
Use no_leading_namespace_whitespace rule
ob-stripe Feb 7, 2020
6ce2a95
Use no_mixed_echo_print rule
ob-stripe Feb 7, 2020
bfb5c27
Use no_multiline_whitespace_around_double_arrow rule
ob-stripe Feb 7, 2020
1748143
Use no_null_property_initialization rule
ob-stripe Feb 7, 2020
d803db2
Use no_short_bool_cast rule
ob-stripe Feb 7, 2020
589b973
Use no_short_echo_tag rule
ob-stripe Feb 7, 2020
f496390
Use no_singleline_whitespace_before_semicolons rule
ob-stripe Feb 7, 2020
1940648
Use no_spaces_around_offset rule
ob-stripe Feb 7, 2020
6b2940f
Use no_superfluous_elseif rule
ob-stripe Feb 7, 2020
f44e427
Use no_trailing_comma_in_list_call rule
ob-stripe Feb 7, 2020
9aa05a4
Use no_trailing_comma_in_singleline_array rule
ob-stripe Feb 7, 2020
ca220da
Use no_unneeded_control_parentheses rule
ob-stripe Feb 7, 2020
5357a99
Use no_unneeded_curly_braces rule
ob-stripe Feb 7, 2020
eb512cb
Use no_unneeded_final_method rule
ob-stripe Feb 7, 2020
ed675bd
Use no_unreachable_default_argument_value rule
ob-stripe Feb 7, 2020
d13c701
Use no_unset_cast rule
ob-stripe Feb 7, 2020
0d164b0
Use no_unused_imports rule
ob-stripe Feb 7, 2020
791eaad
Use no_useless_else rule
ob-stripe Feb 7, 2020
6e42431
Use no_useless_return rule
ob-stripe Feb 7, 2020
aec7b98
Use no_whitespace_before_comma_in_array rule
ob-stripe Feb 7, 2020
a5eac71
Use no_whitespace_in_blank_line rule
ob-stripe Feb 7, 2020
c1847f8
Use non_printable_character rule
ob-stripe Feb 7, 2020
f6fcfd8
Use normalize_index_brace rule
ob-stripe Feb 7, 2020
8d5ac99
Use object_operator_without_whitespace rule
ob-stripe Feb 7, 2020
9a6c384
Use php_unit_construct rule
ob-stripe Feb 7, 2020
c2589ad
Use php_unit_fqcn_annotation rule
ob-stripe Feb 7, 2020
26d46f0
Use php_unit_method_casing rule
ob-stripe Feb 7, 2020
a894e11
Use php_unit_mock_short_will_return rule
ob-stripe Feb 7, 2020
4b6b46f
Use php_unit_ordered_covers rule
ob-stripe Feb 7, 2020
aab8817
Use php_unit_set_up_tear_down_visibility rule
ob-stripe Feb 7, 2020
5f37f3c
Use php_unit_test_annotation rule
ob-stripe Feb 7, 2020
3d5aac3
Use php_unit_test_case_static_method_calls rule
ob-stripe Feb 7, 2020
2aaa046
Use psr4 rule
ob-stripe Feb 7, 2020
a199b9c
Use return_assignment rule
ob-stripe Feb 7, 2020
a3bfe46
Use return_type_declaration rule
ob-stripe Feb 7, 2020
d8dd2b0
Use semicolon_after_instruction rule
ob-stripe Feb 7, 2020
2573b08
Use set_type_to_cast rule
ob-stripe Feb 7, 2020
dc263c8
Use short_scalar_cast rule
ob-stripe Feb 7, 2020
b3add47
Use simple_to_complex_string_variable rule
ob-stripe Feb 7, 2020
5968fb1
Use single_line_comment_style rule
ob-stripe Feb 7, 2020
7c81d77
Use single_trait_insert_per_statement rule
ob-stripe Feb 7, 2020
ddee3e3
Use space_after_semicolon rule
ob-stripe Feb 7, 2020
c35ffc5
Use standardize_increment rule
ob-stripe Feb 7, 2020
517f1f3
Use standardize_not_equals rule
ob-stripe Feb 7, 2020
fa73b49
Use strict_comparison rule
ob-stripe Feb 7, 2020
401b186
Use strict_param rule
ob-stripe Feb 7, 2020
24e82cb
Use string_line_ending rule
ob-stripe Feb 7, 2020
9df2dd0
Use ternary_operator_spaces rule
ob-stripe Feb 7, 2020
d159674
Use trailing_comma_in_multiline_array rule
ob-stripe Feb 7, 2020
bfb3fe3
Use trim_array_spaces rule
ob-stripe Feb 7, 2020
16ead4e
Use unary_operator_spaces rule
ob-stripe Feb 7, 2020
70d8bbb
Use whitespace_after_comma_in_array rule
ob-stripe Feb 7, 2020
bd15068
Use yoda_style rule
ob-stripe Feb 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,47 @@ return PhpCsFixer\Config::create()
'@PHP56Migration:risky' => true,
'@PHPUnit57Migration:risky' => true,
'@PSR2' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => ['method'],
],
'class_definition' => true,
'combine_consecutive_unsets' => true,
'comment_to_phpdoc' => true,
'compact_nullable_typehint' => true,
'concat_space' => [
'spacing' => 'one',
],
'declare_equal_normalize' => true,
'ereg_to_preg' => true,
'error_suppression' => true,
'escape_implicit_backslashes' => true,
'explicit_string_variable' => true,
'final_internal_class' => true,
'fopen_flag_order' => true,
'fopen_flags' => true,
'fully_qualified_strict_types' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'heredoc_to_nowdoc' => true,
'implode_call' => true,
'increment_style' => true,
'is_null' => true,
'linebreak_after_opening_tag' => true,
'logical_operators' => true,
'lowercase_cast' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'method_chaining_indentation' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => true,
'native_function_invocation' => true,
])
;
10 changes: 5 additions & 5 deletions build.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<?php
\chdir(\dirname(__FILE__));

$autoload = (int)$argv[1];
$autoload = (int) $argv[1];
$returnStatus = null;

if (!$autoload) {
// Modify composer to not autoload Stripe
$composer = \json_decode(\file_get_contents('composer.json'), true);
unset($composer['autoload']);
unset($composer['autoload-dev']);
\file_put_contents('composer.json', \json_encode($composer, JSON_PRETTY_PRINT));
unset($composer['autoload'], $composer['autoload-dev']);

\file_put_contents('composer.json', \json_encode($composer, \JSON_PRETTY_PRINT));
}

\passthru('composer update', $returnStatus);
Expand All @@ -19,7 +19,7 @@
}

$config = $autoload ? 'phpunit.xml' : 'phpunit.no_autoload.xml';
\passthru("./vendor/bin/phpunit -c $config", $returnStatus);
\passthru("./vendor/bin/phpunit -c ${config}", $returnStatus);
if ($returnStatus !== 0) {
exit(1);
}
10 changes: 5 additions & 5 deletions examples/oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

$accountId = $resp->stripe_user_id;

echo "<p>Success! Account <code>$accountId</code> is connected.</p>\n";
echo "<p>Click <a href=\"?deauth=$accountId\">here</a> to disconnect the account.</p>\n";
echo "<p>Success! Account <code>${accountId}</code> is connected.</p>\n";
echo "<p>Click <a href=\"?deauth=${accountId}\">here</a> to disconnect the account.</p>\n";
} elseif (isset($_GET['error'])) {
// The user was redirect back from the OAuth form with an error.
$error = $_GET['error'];
$error_description = $_GET['error_description'];

echo "<p>Error: code=" . \htmlspecialchars($error, ENT_QUOTES) . ", description=" . \htmlspecialchars($error_description, ENT_QUOTES) . "</p>\n";
echo "<p>Error: code=" . \htmlspecialchars($error, \ENT_QUOTES) . ", description=" . \htmlspecialchars($error_description, \ENT_QUOTES) . "</p>\n";
echo "<p>Click <a href=\"?\">here</a> to restart the OAuth flow.</p>\n";
} elseif (isset($_GET['deauth'])) {
// Deauthorization request
Expand All @@ -42,11 +42,11 @@
exit("Error: " . $e->getMessage());
}

echo "<p>Success! Account <code>" . \htmlspecialchars($accountId, ENT_QUOTES) . "</code> is disconnected.</p>\n";
echo "<p>Success! Account <code>" . \htmlspecialchars($accountId, \ENT_QUOTES) . "</code> is disconnected.</p>\n";
echo "<p>Click <a href=\"?\">here</a> to restart the OAuth flow.</p>\n";
} else {
$url = \Stripe\OAuth::authorizeUrl([
'scope' => 'read_only',
]);
echo "<a href=\"$url\">Connect with Stripe</a>\n";
echo "<a href=\"${url}\">Connect with Stripe</a>\n";
}
2 changes: 1 addition & 1 deletion lib/AlipayAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function instanceUrl()
}
$parentExtn = \urlencode(Util\Util::utf8($parent));
$extn = \urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
return "${base}/${parentExtn}/${path}/${extn}";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/ApiOperations/NestedResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null)
{
$url = static::resourceUrl($id) . $nestedPath;
if ($nestedId !== null) {
$url .= "/$nestedId";
$url .= "/${nestedId}";
}
return $url;
}
Expand Down
17 changes: 9 additions & 8 deletions lib/ApiRequestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ private static function _telemetryJson($requestTelemetry)
'last_request_metrics' => [
'request_id' => $requestTelemetry->requestId,
'request_duration_ms' => $requestTelemetry->requestDuration,
]];
],
];

$result = \json_encode($payload);
if ($result != false) {
Expand Down Expand Up @@ -127,8 +128,8 @@ public function request($method, $url, $params = null, $headers = null)
public function handleErrorResponse($rbody, $rcode, $rheaders, $resp)
{
if (!\is_array($resp) || !isset($resp['error'])) {
$msg = "Invalid response object from API: $rbody "
. "(HTTP response code was $rcode)";
$msg = "Invalid response object from API: ${rbody} "
. "(HTTP response code was ${rcode})";
throw new Exception\UnexpectedValueException($msg);
}

Expand Down Expand Up @@ -259,7 +260,7 @@ private static function _defaultHeaders($apiKey, $clientInfo = null)
{
$uaString = 'Stripe/v1 PhpBindings/' . Stripe::VERSION;

$langVersion = \phpversion();
$langVersion = \PHP_VERSION;
$uname_disabled = \in_array('php_uname', \explode(',', \ini_get('disable_functions')));
$uname = $uname_disabled ? '(disabled)' : \php_uname();

Expand Down Expand Up @@ -321,7 +322,7 @@ private function _requestRaw($method, $url, $params, $headers)
$clientUAInfo = $this->httpClient()->getUserAgentInfo();
}

$absUrl = $this->_apiBase.$url;
$absUrl = $this->_apiBase . $url;
$params = self::_encodeObjects($params);
$defaultHeaders = $this->_defaultHeaders($myApiKey, $clientUAInfo);
if (Stripe::$apiVersion) {
Expand Down Expand Up @@ -419,9 +420,9 @@ private function _interpretResponse($rbody, $rcode, $rheaders)
{
$resp = \json_decode($rbody, true);
$jsonError = \json_last_error();
if ($resp === null && $jsonError !== JSON_ERROR_NONE) {
$msg = "Invalid response body from API: $rbody "
. "(HTTP response code was $rcode, json_last_error() was $jsonError)";
if ($resp === null && $jsonError !== \JSON_ERROR_NONE) {
$msg = "Invalid response body from API: ${rbody} "
. "(HTTP response code was ${rcode}, json_last_error() was ${jsonError})";
throw new Exception\UnexpectedValueException($msg, $rcode);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/ApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public static function resourceUrl($id)
if ($id === null) {
$class = \get_called_class();
$message = "Could not determine which URL to request: "
. "$class instance has invalid ID: $id";
. "${class} instance has invalid ID: ${id}";
throw new Exception\UnexpectedValueException($message);
}
$id = Util\Util::utf8($id);
$base = static::classUrl();
$extn = \urlencode($id);
return "$base/$extn";
return "${base}/${extn}";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/ApplicationFeeRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function instanceUrl()
if (!$id) {
throw new Exception\UnexpectedValueException(
"Could not determine which URL to request: " .
"class instance has invalid ID: $id",
"class instance has invalid ID: ${id}",
null
);
}
Expand All @@ -44,7 +44,7 @@ public function instanceUrl()
$base = ApplicationFee::classUrl();
$feeExtn = \urlencode($fee);
$extn = \urlencode($id);
return "$base/$feeExtn/refunds/$extn";
return "${base}/${feeExtn}/refunds/${extn}";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/BankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function instanceUrl()
}
$parentExtn = \urlencode(Util\Util::utf8($parent));
$extn = \urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
return "${base}/${parentExtn}/${path}/${extn}";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/BitcoinReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function instanceUrl()
$path = 'sources';
$parentExtn = \urlencode(Util\Util::utf8($parent));
$extn = \urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
return "${base}/${parentExtn}/${path}/${extn}";
} else {
$base = BitcoinReceiver::classUrl();
$extn = \urlencode(Util\Util::utf8($this['id']));
return "$base/$extn";
return "${base}/${extn}";
}
}
}
4 changes: 2 additions & 2 deletions lib/Capability.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function instanceUrl()
if (!$id) {
throw new Exception\UnexpectedValueException(
"Could not determine which URL to request: " .
"class instance has invalid ID: $id",
"class instance has invalid ID: ${id}",
null
);
}
Expand All @@ -50,7 +50,7 @@ public function instanceUrl()
$base = Account::classUrl();
$accountExtn = \urlencode($account);
$extn = \urlencode($id);
return "$base/$accountExtn/capabilities/$extn";
return "${base}/${accountExtn}/capabilities/${extn}";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function instanceUrl()
}
$parentExtn = \urlencode(Util\Util::utf8($parent));
$extn = \urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
return "${base}/${parentExtn}/${path}/${extn}";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function retrieve($id, $params = null, $opts = null)
$extn = \urlencode($id);
list($response, $opts) = $this->_request(
'get',
"$url/$extn",
"${url}/${extn}",
$params,
$opts
);
Expand Down Expand Up @@ -233,7 +233,7 @@ private function extractPathAndUpdateParams($params)
{
$url = \parse_url($this->url);
if (!isset($url['path'])) {
throw new Exception\UnexpectedValueException("Could not parse list url into parts: $url");
throw new Exception\UnexpectedValueException("Could not parse list url into parts: ${url}");
}

if (isset($url['query'])) {
Expand Down
4 changes: 2 additions & 2 deletions lib/CustomerBalanceTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function instanceUrl()
$customer = $this['customer'];
if (!$id) {
throw new Exception\UnexpectedValueException(
"Could not determine which URL to request: class instance has invalid ID: $id",
"Could not determine which URL to request: class instance has invalid ID: ${id}",
null
);
}
Expand All @@ -56,7 +56,7 @@ public function instanceUrl()
$base = Customer::classUrl();
$customerExtn = \urlencode($customer);
$extn = \urlencode($id);
return "$base/$customerExtn/balance_transactions/$extn";
return "${base}/${customerExtn}/balance_transactions/${extn}";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/ApiErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function __toString()

protected function constructErrorObject()
{
if (\is_null($this->jsonBody) || !\array_key_exists('error', $this->jsonBody)) {
if (null === $this->jsonBody || !\array_key_exists('error', $this->jsonBody)) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/OAuth/OAuthErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class OAuthErrorException extends \Stripe\Exception\ApiErrorException
{
protected function constructErrorObject()
{
if (\is_null($this->jsonBody)) {
if (null === $this->jsonBody) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function classUrl()
public static function create($params = null, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
if (\is_null($opts->apiBase)) {
if (null === $opts->apiBase) {
$opts->apiBase = Stripe::$apiUploadBase;
}
// Manually flatten params, otherwise curl's multipart encoder will
Expand Down
Loading