From 99862a8d638632a96781898754ee6fcb343ef7e3 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:12:08 -0800 Subject: [PATCH 01/97] Use array_indentation rule --- .php_cs.dist | 2 ++ lib/ApiRequestor.php | 3 ++- tests/Stripe/OAuthTest.php | 2 +- update_certs.php | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 55a95f2b7..b395cfc6a 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -6,6 +6,8 @@ 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, 'class_attributes_separation' => [ diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 8a6c8e0ca..bf6452a98 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -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) { diff --git a/tests/Stripe/OAuthTest.php b/tests/Stripe/OAuthTest.php index 58414dc86..81ce9feac 100644 --- a/tests/Stripe/OAuthTest.php +++ b/tests/Stripe/OAuthTest.php @@ -89,7 +89,7 @@ public function testDeauthorize() ); $resp = OAuth::deauthorize([ - 'stripe_user_id' => 'acct_test_deauth', + 'stripe_user_id' => 'acct_test_deauth', ]); $this->assertSame('acct_test_deauth', $resp->stripe_user_id); } diff --git a/update_certs.php b/update_certs.php index 1b8a1d0ea..7bdb10899 100755 --- a/update_certs.php +++ b/update_certs.php @@ -7,9 +7,9 @@ $fp = \fopen(\dirname(__FILE__) . '/data/ca-certificates.crt', 'w+'); $options = [ - CURLOPT_FILE => $fp, - CURLOPT_TIMEOUT => 3600, - CURLOPT_URL => 'https://curl.haxx.se/ca/cacert.pem', + CURLOPT_FILE => $fp, + CURLOPT_TIMEOUT => 3600, + CURLOPT_URL => 'https://curl.haxx.se/ca/cacert.pem', ]; $ch = \curl_init(); From 3c2cd7794b6a5fdffd02c4688d5215cb44988890 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:13:26 -0800 Subject: [PATCH 02/97] Use cast_spaces rule --- .php_cs.dist | 1 + build.php | 2 +- tests/Stripe/Exception/ApiErrorExceptionTest.php | 2 +- tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php | 2 +- tests/Stripe/StripeObjectTest.php | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index b395cfc6a..44078e839 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -10,6 +10,7 @@ return PhpCsFixer\Config::create() 'array_indentation' => true, 'array_syntax' => ['syntax' => 'short'], 'blank_line_after_opening_tag' => true, + 'cast_spaces' => true, 'class_attributes_separation' => [ 'elements' => ['method'], ], diff --git a/build.php b/build.php index 3f0bbe69e..29005dc8f 100755 --- a/build.php +++ b/build.php @@ -2,7 +2,7 @@ createFixture(); - $this->assertContains("(Request req_test)", (string)$e); + $this->assertContains("(Request req_test)", (string) $e); } } diff --git a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php index ae8fe5200..89d81905b 100644 --- a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php +++ b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php @@ -38,6 +38,6 @@ public function testGetters() public function testToString() { $e = $this->createFixture(); - $this->assertContains("(Request req_test)", (string)$e); + $this->assertContains("(Request req_test)", (string) $e); } } diff --git a/tests/Stripe/StripeObjectTest.php b/tests/Stripe/StripeObjectTest.php index 126307095..0fd84e245 100644 --- a/tests/Stripe/StripeObjectTest.php +++ b/tests/Stripe/StripeObjectTest.php @@ -163,7 +163,7 @@ public function testToString() $s = new StripeObject(); $s->foo = 'a'; - $string = (string)$s; + $string = (string) $s; $expected = << Date: Fri, 7 Feb 2020 10:15:02 -0800 Subject: [PATCH 03/97] Use class_definition rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 44078e839..20e0c45fa 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -14,6 +14,7 @@ return PhpCsFixer\Config::create() 'class_attributes_separation' => [ 'elements' => ['method'], ], + 'class_definition' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From 9a5e8c6f55aaa2b15787142b0b72a33fe4c6b43e Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:15:34 -0800 Subject: [PATCH 04/97] Use combine_consecutive_unsets rule --- .php_cs.dist | 1 + build.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 20e0c45fa..4a1e76d54 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,6 +15,7 @@ return PhpCsFixer\Config::create() 'elements' => ['method'], ], 'class_definition' => true, + 'combine_consecutive_unsets' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/build.php b/build.php index 29005dc8f..11fed9613 100755 --- a/build.php +++ b/build.php @@ -8,8 +8,8 @@ if (!$autoload) { // Modify composer to not autoload Stripe $composer = \json_decode(\file_get_contents('composer.json'), true); - unset($composer['autoload']); - unset($composer['autoload-dev']); + unset($composer['autoload'], $composer['autoload-dev']); + \file_put_contents('composer.json', \json_encode($composer, JSON_PRETTY_PRINT)); } From 4990b410ad9248c641bf741711fd1b8acd97c3a6 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:16:13 -0800 Subject: [PATCH 05/97] Use comment_to_phpdoc rule --- .php_cs.dist | 1 + lib/Stripe.php | 36 +++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 4a1e76d54..49e369aef 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -16,6 +16,7 @@ return PhpCsFixer\Config::create() ], 'class_definition' => true, 'combine_consecutive_unsets' => true, + 'comment_to_phpdoc' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/lib/Stripe.php b/lib/Stripe.php index d42cf5ed7..cf7efa46c 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -9,53 +9,55 @@ */ class Stripe { - // @var string The Stripe API key to be used for requests. + /** @var string The Stripe API key to be used for requests. */ public static $apiKey; - // @var string The Stripe client_id to be used for Connect requests. + /** @var string The Stripe client_id to be used for Connect requests. */ public static $clientId; - // @var string The base URL for the Stripe API. + /** @var string The base URL for the Stripe API. */ public static $apiBase = 'https://api.stripe.com'; - // @var string The base URL for the OAuth API. + /** @var string The base URL for the OAuth API. */ public static $connectBase = 'https://connect.stripe.com'; - // @var string The base URL for the Stripe API uploads endpoint. + /** @var string The base URL for the Stripe API uploads endpoint. */ public static $apiUploadBase = 'https://files.stripe.com'; - // @var string|null The version of the Stripe API to use for requests. + /** @var string|null The version of the Stripe API to use for requests. */ public static $apiVersion = null; - // @var string|null The account ID for connected accounts requests. + /** @var string|null The account ID for connected accounts requests. */ public static $accountId = null; - // @var string Path to the CA bundle used to verify SSL certificates + /** @var string Path to the CA bundle used to verify SSL certificates */ public static $caBundlePath = null; - // @var boolean Defaults to true. + /** @var boolean Defaults to true. */ public static $verifySslCerts = true; - // @var array The application's information (name, version, URL) + /** @var array The application's information (name, version, URL) */ public static $appInfo = null; - // @var Util\LoggerInterface|null The logger to which the library will - // produce messages. + /** + * @var Util\LoggerInterface|null The logger to which the library will + * produce messages. + */ public static $logger = null; - // @var int Maximum number of request retries + /** @var int Maximum number of request retries */ public static $maxNetworkRetries = 0; - // @var boolean Whether client telemetry is enabled. Defaults to true. + /** @var boolean Whether client telemetry is enabled. Defaults to true. */ public static $enableTelemetry = true; - // @var float Maximum delay between retries, in seconds + /** @var float Maximum delay between retries, in seconds */ private static $maxNetworkRetryDelay = 2.0; - // @var float Maximum delay between retries, in seconds, that will be respected from the Stripe API + /** @var float Maximum delay between retries, in seconds, that will be respected from the Stripe API */ private static $maxRetryAfter = 60.0; - // @var float Initial delay between retries, in seconds + /** @var float Initial delay between retries, in seconds */ private static $initialNetworkRetryDelay = 0.5; const VERSION = '7.23.0'; From 6a8fd0951e9a10c3ee8054b74f3156d190cc85e8 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:16:41 -0800 Subject: [PATCH 06/97] Use compact_nullable_typehint rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 49e369aef..ab2069ce9 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -17,6 +17,7 @@ return PhpCsFixer\Config::create() 'class_definition' => true, 'combine_consecutive_unsets' => true, 'comment_to_phpdoc' => true, + 'compact_nullable_typehint' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From dd332f4f4611734e9cb07b7a205bd69aaa765195 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:18:08 -0800 Subject: [PATCH 07/97] Use concat_space rule --- .php_cs.dist | 3 +++ lib/ApiRequestor.php | 2 +- lib/StripeObject.php | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index ab2069ce9..e55d8588a 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -18,6 +18,9 @@ return PhpCsFixer\Config::create() 'combine_consecutive_unsets' => true, 'comment_to_phpdoc' => true, 'compact_nullable_typehint' => true, + 'concat_space' => [ + 'spacing' => 'one', + ], 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index bf6452a98..87adc2661 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -322,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) { diff --git a/lib/StripeObject.php b/lib/StripeObject.php index c60a61c53..391d7f2d9 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -124,9 +124,9 @@ public function __set($k, $v) if ($v === "") { throw new Exception\InvalidArgumentException( - 'You cannot set \''.$k.'\'to an empty string. ' - .'We interpret empty strings as NULL in requests. ' - .'You may set obj->'.$k.' = NULL to delete the property' + 'You cannot set \'' . $k . '\'to an empty string. ' + . 'We interpret empty strings as NULL in requests. ' + . 'You may set obj->' . $k . ' = NULL to delete the property' ); } From 6febfede15104b06c2c77f1c7a05492887eeebfd Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:18:32 -0800 Subject: [PATCH 08/97] Use declare_equal_normalize rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index e55d8588a..a1ac93e1a 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -21,6 +21,7 @@ return PhpCsFixer\Config::create() 'concat_space' => [ 'spacing' => 'one', ], + 'declare_equal_normalize' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From 6a34965469f28e349764fd9add57c93f5455b60a Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:20:49 -0800 Subject: [PATCH 09/97] Use ereg_to_preg rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index a1ac93e1a..b97e21e6a 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -22,6 +22,7 @@ return PhpCsFixer\Config::create() 'spacing' => 'one', ], 'declare_equal_normalize' => true, + 'ereg_to_preg' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From a1dd4aef1fd7094bc082d1bbec56027012ab49d2 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:21:08 -0800 Subject: [PATCH 10/97] Use error_suppression rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index b97e21e6a..bae32bb9d 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -23,6 +23,7 @@ return PhpCsFixer\Config::create() ], 'declare_equal_normalize' => true, 'ereg_to_preg' => true, + 'error_suppression' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From e3c9768ef31e22c5a8ecb16c27d8e954809515ff Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:21:50 -0800 Subject: [PATCH 11/97] Use escape_implicit_backslashes rule --- .php_cs.dist | 1 + tests/Stripe/StripeObjectTest.php | 4 ++-- tests/Stripe/StripeTelemetryTest.php | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index bae32bb9d..7e52b2b2d 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -24,6 +24,7 @@ return PhpCsFixer\Config::create() 'declare_equal_normalize' => true, 'ereg_to_preg' => true, 'error_suppression' => true, + 'escape_implicit_backslashes' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/tests/Stripe/StripeObjectTest.php b/tests/Stripe/StripeObjectTest.php index 0fd84e245..3adf2b76e 100644 --- a/tests/Stripe/StripeObjectTest.php +++ b/tests/Stripe/StripeObjectTest.php @@ -165,7 +165,7 @@ public function testToString() $string = (string) $s; $expected = <<fail("Did not raise error"); } catch (\InvalidArgumentException $e) { $this->assertSame( - "Cannot save property `customer` containing an API resource of type Stripe\Customer. " . + "Cannot save property `customer` containing an API resource of type Stripe\\Customer. " . "It doesn't appear to be persisted and is not marked as `saveWithParent`.", $e->getMessage() ); diff --git a/tests/Stripe/StripeTelemetryTest.php b/tests/Stripe/StripeTelemetryTest.php index 2fedd60d3..e1833d65f 100644 --- a/tests/Stripe/StripeTelemetryTest.php +++ b/tests/Stripe/StripeTelemetryTest.php @@ -28,7 +28,7 @@ public function testNoTelemetrySentIfNotEnabled() $requestheaders = null; $stub = $this - ->getMockBuilder("HttpClient\ClientInterface") + ->getMockBuilder("HttpClient\\ClientInterface") ->setMethods(['request']) ->getMock(); @@ -70,7 +70,7 @@ public function testTelemetrySetIfEnabled() $requestheaders = null; $stub = $this - ->getMockBuilder("HttpClient\ClientInterface") + ->getMockBuilder("HttpClient\\ClientInterface") ->setMethods(['request']) ->getMock(); From dab9e2971dff4c224a1795cc226d7e9c955b6fd6 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:22:54 -0800 Subject: [PATCH 12/97] Use explicit_string_variable rule --- .php_cs.dist | 1 + build.php | 2 +- examples/oauth.php | 6 +++--- lib/AlipayAccount.php | 2 +- lib/ApiOperations/NestedResource.php | 2 +- lib/ApiRequestor.php | 8 ++++---- lib/ApiResource.php | 4 ++-- lib/ApplicationFeeRefund.php | 4 ++-- lib/BankAccount.php | 2 +- lib/BitcoinReceiver.php | 4 ++-- lib/Capability.php | 4 ++-- lib/Card.php | 2 +- lib/Collection.php | 4 ++-- lib/CustomerBalanceTransaction.php | 4 ++-- lib/HttpClient/CurlClient.php | 14 +++++++------- lib/Person.php | 4 ++-- lib/Source.php | 6 +++--- lib/StripeObject.php | 12 ++++++------ lib/TaxId.php | 4 ++-- lib/TransferReversal.php | 4 ++-- lib/Webhook.php | 4 ++-- lib/WebhookSignature.php | 2 +- tests/Stripe/WebhookTest.php | 4 ++-- 23 files changed, 52 insertions(+), 51 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 7e52b2b2d..0ceed37da 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -25,6 +25,7 @@ return PhpCsFixer\Config::create() 'ereg_to_preg' => true, 'error_suppression' => true, 'escape_implicit_backslashes' => true, + 'explicit_string_variable' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/build.php b/build.php index 11fed9613..49b110d50 100755 --- a/build.php +++ b/build.php @@ -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); } diff --git a/examples/oauth.php b/examples/oauth.php index b3230a669..0998c831e 100644 --- a/examples/oauth.php +++ b/examples/oauth.php @@ -21,8 +21,8 @@ $accountId = $resp->stripe_user_id; - echo "

Success! Account $accountId is connected.

\n"; - echo "

Click here to disconnect the account.

\n"; + echo "

Success! Account ${accountId} is connected.

\n"; + echo "

Click here to disconnect the account.

\n"; } elseif (isset($_GET['error'])) { // The user was redirect back from the OAuth form with an error. $error = $_GET['error']; @@ -48,5 +48,5 @@ $url = \Stripe\OAuth::authorizeUrl([ 'scope' => 'read_only', ]); - echo "Connect with Stripe\n"; + echo "Connect with Stripe\n"; } diff --git a/lib/AlipayAccount.php b/lib/AlipayAccount.php index d430ab5ba..f60c9b3cb 100644 --- a/lib/AlipayAccount.php +++ b/lib/AlipayAccount.php @@ -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}"; } /** diff --git a/lib/ApiOperations/NestedResource.php b/lib/ApiOperations/NestedResource.php index a3cabfd15..9dcdc5c4d 100644 --- a/lib/ApiOperations/NestedResource.php +++ b/lib/ApiOperations/NestedResource.php @@ -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; } diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 87adc2661..7b91a6149 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -128,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); } @@ -421,8 +421,8 @@ 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)"; + $msg = "Invalid response body from API: ${rbody} " + . "(HTTP response code was ${rcode}, json_last_error() was ${jsonError})"; throw new Exception\UnexpectedValueException($msg, $rcode); } diff --git a/lib/ApiResource.php b/lib/ApiResource.php index 2eb1f02bf..c0f3349cb 100644 --- a/lib/ApiResource.php +++ b/lib/ApiResource.php @@ -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}"; } /** diff --git a/lib/ApplicationFeeRefund.php b/lib/ApplicationFeeRefund.php index c4137429d..4d67a1496 100644 --- a/lib/ApplicationFeeRefund.php +++ b/lib/ApplicationFeeRefund.php @@ -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 ); } @@ -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}"; } /** diff --git a/lib/BankAccount.php b/lib/BankAccount.php index 4930323b5..378e4109f 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -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}"; } /** diff --git a/lib/BitcoinReceiver.php b/lib/BitcoinReceiver.php index 8ed63a308..b300b6f62 100644 --- a/lib/BitcoinReceiver.php +++ b/lib/BitcoinReceiver.php @@ -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}"; } } } diff --git a/lib/Capability.php b/lib/Capability.php index 56d1596cd..64e986648 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -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 ); } @@ -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}"; } /** diff --git a/lib/Card.php b/lib/Card.php index 87647ed03..68a99b80b 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -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}"; } /** diff --git a/lib/Collection.php b/lib/Collection.php index 3fe45409c..8965db611 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -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 ); @@ -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'])) { diff --git a/lib/CustomerBalanceTransaction.php b/lib/CustomerBalanceTransaction.php index 459c13080..86c6a4f66 100644 --- a/lib/CustomerBalanceTransaction.php +++ b/lib/CustomerBalanceTransaction.php @@ -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 ); } @@ -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}"; } /** diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index ad03938df..acc228e03 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -213,7 +213,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $opts[CURLOPT_HTTPGET] = 1; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); - $absUrl = "$absUrl?$encoded"; + $absUrl = "${absUrl}?${encoded}"; } } elseif ($method == 'post') { $opts[CURLOPT_POST] = 1; @@ -222,10 +222,10 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); - $absUrl = "$absUrl?$encoded"; + $absUrl = "${absUrl}?${encoded}"; } } else { - throw new Exception\UnexpectedValueException("Unrecognized method $method"); + throw new Exception\UnexpectedValueException("Unrecognized method ${method}"); } // It is only safe to retry network failures on POST requests if we @@ -349,7 +349,7 @@ private function handleCurlError($url, $errno, $message, $numRetries) case CURLE_COULDNT_CONNECT: case CURLE_COULDNT_RESOLVE_HOST: case CURLE_OPERATION_TIMEOUTED: - $msg = "Could not connect to Stripe ($url). Please check your " + $msg = "Could not connect to Stripe (${url}). Please check your " . "internet connection and try again. If this problem persists, " . "you should check Stripe's service status at " . "https://twitter.com/stripestatus, or"; @@ -358,7 +358,7 @@ private function handleCurlError($url, $errno, $message, $numRetries) case CURLE_SSL_PEER_CERTIFICATE: $msg = "Could not verify Stripe's SSL certificate. Please make sure " . "that your network is not intercepting certificates. " - . "(Try going to $url in your browser.) " + . "(Try going to ${url} in your browser.) " . "If this problem persists,"; break; default: @@ -367,10 +367,10 @@ private function handleCurlError($url, $errno, $message, $numRetries) } $msg .= " let us know at support@stripe.com."; - $msg .= "\n\n(Network error [errno $errno]: $message)"; + $msg .= "\n\n(Network error [errno ${errno}]: ${message})"; if ($numRetries > 0) { - $msg .= "\n\nRequest was retried $numRetries times."; + $msg .= "\n\nRequest was retried ${numRetries} times."; } throw new Exception\ApiConnectionException($msg); diff --git a/lib/Person.php b/lib/Person.php index 115309785..80e88595f 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -65,7 +65,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 ); } @@ -75,7 +75,7 @@ public function instanceUrl() $base = Account::classUrl(); $accountExtn = \urlencode($account); $extn = \urlencode($id); - return "$base/$accountExtn/persons/$extn"; + return "${base}/${accountExtn}/persons/${extn}"; } /** diff --git a/lib/Source.php b/lib/Source.php index a2125e79a..0b1501c56 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -98,8 +98,8 @@ public function detach($params = null, $opts = null) $id = $this['id']; if (!$id) { $class = \get_class($this); - $msg = "Could not determine which URL to request: $class instance " - . "has invalid ID: $id"; + $msg = "Could not determine which URL to request: ${class} instance " + . "has invalid ID: ${id}"; throw new Exception\UnexpectedValueException($msg, null); } @@ -107,7 +107,7 @@ public function detach($params = null, $opts = null) $base = Customer::classUrl(); $parentExtn = \urlencode(Util\Util::utf8($this['customer'])); $extn = \urlencode(Util\Util::utf8($id)); - $url = "$base/$parentExtn/sources/$extn"; + $url = "${base}/${parentExtn}/sources/${extn}"; list($response, $opts) = $this->_request('delete', $url, $params, $opts); $this->refreshFrom($response, $opts); diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 391d7f2d9..744d23db5 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -117,7 +117,7 @@ public function __set($k, $v) { if (static::getPermanentAttributes()->includes($k)) { throw new Exception\InvalidArgumentException( - "Cannot set $k on this object. HINT: you can't set: " . + "Cannot set ${k} on this object. HINT: you can't set: " . \join(', ', static::getPermanentAttributes()->toArray()) ); } @@ -156,17 +156,17 @@ public function &__get($k) } elseif (!empty($this->_transientValues) && $this->_transientValues->includes($k)) { $class = \get_class($this); $attrs = \join(', ', \array_keys($this->_values)); - $message = "Stripe Notice: Undefined property of $class instance: $k. " - . "HINT: The $k attribute was set in the past, however. " + $message = "Stripe Notice: Undefined property of ${class} instance: ${k}. " + . "HINT: The ${k} attribute was set in the past, however. " . "It was then wiped when refreshing the object " . "with the result returned by Stripe's API, " . "probably as a result of a save(). The attributes currently " - . "available on this object are: $attrs"; + . "available on this object are: ${attrs}"; Stripe::getLogger()->error($message); return $nullval; } else { $class = \get_class($this); - Stripe::getLogger()->error("Stripe Notice: Undefined property of $class instance: $k"); + Stripe::getLogger()->error("Stripe Notice: Undefined property of ${class} instance: ${k}"); return $nullval; } } @@ -367,7 +367,7 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = return $value; } else { throw new Exception\InvalidArgumentException( - "Cannot save property `$key` containing an API resource of type " . + "Cannot save property `${key}` containing an API resource of type " . \get_class($value) . ". It doesn't appear to be persisted and is " . "not marked as `saveWithParent`." ); diff --git a/lib/TaxId.php b/lib/TaxId.php index cd4190f12..336850983 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -62,7 +62,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}" ); } $id = Util\Util::utf8($id); @@ -71,7 +71,7 @@ public function instanceUrl() $base = Customer::classUrl(); $customerExtn = \urlencode($customer); $extn = \urlencode($id); - return "$base/$customerExtn/tax_ids/$extn"; + return "${base}/${customerExtn}/tax_ids/${extn}"; } /** diff --git a/lib/TransferReversal.php b/lib/TransferReversal.php index e16cf8258..e896c02c9 100644 --- a/lib/TransferReversal.php +++ b/lib/TransferReversal.php @@ -36,7 +36,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 ); } @@ -46,7 +46,7 @@ public function instanceUrl() $base = Transfer::classUrl(); $transferExtn = \urlencode($transfer); $extn = \urlencode($id); - return "$base/$transferExtn/reversals/$extn"; + return "${base}/${transferExtn}/reversals/${extn}"; } /** diff --git a/lib/Webhook.php b/lib/Webhook.php index a252a4a7e..d4c23a1f0 100644 --- a/lib/Webhook.php +++ b/lib/Webhook.php @@ -29,8 +29,8 @@ public static function constructEvent($payload, $sigHeader, $secret, $tolerance $data = \json_decode($payload, true); $jsonError = \json_last_error(); if ($data === null && $jsonError !== JSON_ERROR_NONE) { - $msg = "Invalid payload: $payload " - . "(json_last_error() was $jsonError)"; + $msg = "Invalid payload: ${payload} " + . "(json_last_error() was ${jsonError})"; throw new Exception\UnexpectedValueException($msg); } $event = Event::constructFrom($data); diff --git a/lib/WebhookSignature.php b/lib/WebhookSignature.php index 142526047..be1b9940b 100644 --- a/lib/WebhookSignature.php +++ b/lib/WebhookSignature.php @@ -42,7 +42,7 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul // Check if expected signature is found in list of signatures from // header - $signedPayload = "$timestamp.$payload"; + $signedPayload = "${timestamp}.${payload}"; $expectedSignature = self::computeSignature($signedPayload, $secret); $signatureFound = false; foreach ($signatures as $signature) { diff --git a/tests/Stripe/WebhookTest.php b/tests/Stripe/WebhookTest.php index cd3c8c4ce..ccce351e2 100644 --- a/tests/Stripe/WebhookTest.php +++ b/tests/Stripe/WebhookTest.php @@ -18,10 +18,10 @@ private function generateHeader($opts = []) $scheme = \array_key_exists('scheme', $opts) ? $opts['scheme'] : WebhookSignature::EXPECTED_SCHEME; $signature = \array_key_exists('signature', $opts) ? $opts['signature'] : null; if ($signature === null) { - $signedPayload = "$timestamp.$payload"; + $signedPayload = "${timestamp}.${payload}"; $signature = \hash_hmac("sha256", $signedPayload, $secret); } - return "t=$timestamp,$scheme=$signature"; + return "t=${timestamp},${scheme}=${signature}"; } public function testValidJsonAndHeader() From 4dcfc313c5cddc5f9f9d7c40108e5fbfc5b7b3d8 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:23:18 -0800 Subject: [PATCH 13/97] Use final_internal_class rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 0ceed37da..ac01c096b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -26,6 +26,7 @@ return PhpCsFixer\Config::create() 'error_suppression' => true, 'escape_implicit_backslashes' => true, 'explicit_string_variable' => true, + 'final_internal_class' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From 228d3480ff1c6794ce266d8940e96d0c7b50cccd Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:23:38 -0800 Subject: [PATCH 14/97] Use fopen_flag_order rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index ac01c096b..6bf46481d 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -27,6 +27,7 @@ return PhpCsFixer\Config::create() 'escape_implicit_backslashes' => true, 'explicit_string_variable' => true, 'final_internal_class' => true, + 'fopen_flag_order' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From 9c95ad613e1550fa6aa4ebac7a1a95c32a932f71 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:25:10 -0800 Subject: [PATCH 15/97] Use fopen_flags rule --- .php_cs.dist | 1 + tests/Stripe/FileCreationTest.php | 2 +- update_certs.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 6bf46481d..3ca53cd81 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -28,6 +28,7 @@ return PhpCsFixer\Config::create() 'explicit_string_variable' => true, 'final_internal_class' => true, 'fopen_flag_order' => true, + 'fopen_flags' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/tests/Stripe/FileCreationTest.php b/tests/Stripe/FileCreationTest.php index 8a1695bfb..425a1e840 100644 --- a/tests/Stripe/FileCreationTest.php +++ b/tests/Stripe/FileCreationTest.php @@ -36,7 +36,7 @@ public function testIsCreatableWithFileHandle() true, Stripe::$apiUploadBase ); - $fp = \fopen(\dirname(__FILE__) . '/../data/test.png', 'r'); + $fp = \fopen(\dirname(__FILE__) . '/../data/test.png', 'rb'); $resource = File::create([ "purpose" => "dispute_evidence", "file" => $fp, diff --git a/update_certs.php b/update_certs.php index 7bdb10899..48b6fd893 100755 --- a/update_certs.php +++ b/update_certs.php @@ -4,7 +4,7 @@ \set_time_limit(0); // unlimited max execution time -$fp = \fopen(\dirname(__FILE__) . '/data/ca-certificates.crt', 'w+'); +$fp = \fopen(\dirname(__FILE__) . '/data/ca-certificates.crt', 'w+b'); $options = [ CURLOPT_FILE => $fp, From 9a06631bb94a78299d6fa44c587be2c6e0dee971 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:25:36 -0800 Subject: [PATCH 16/97] Use fully_qualified_strict_types rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 3ca53cd81..b07b2a9a2 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -29,6 +29,7 @@ return PhpCsFixer\Config::create() 'final_internal_class' => true, 'fopen_flag_order' => true, 'fopen_flags' => true, + 'fully_qualified_strict_types' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From 8339363b4096b377b03e0598b3fba8c431e718a0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:26:46 -0800 Subject: [PATCH 17/97] Use function_to_constant rule --- .php_cs.dist | 1 + lib/ApiRequestor.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index b07b2a9a2..7f60d4940 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -30,6 +30,7 @@ return PhpCsFixer\Config::create() 'fopen_flag_order' => true, 'fopen_flags' => true, 'fully_qualified_strict_types' => true, + 'function_to_constant' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 7b91a6149..b568d6e31 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -260,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(); From b6aac1d77cccc5496e5a84d3a8e712aec91b471c Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:27:21 -0800 Subject: [PATCH 18/97] Use function_typehint_space rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 7f60d4940..4427215ef 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -31,6 +31,7 @@ return PhpCsFixer\Config::create() 'fopen_flags' => true, 'fully_qualified_strict_types' => true, 'function_to_constant' => true, + 'function_typehint_space' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From 030772f97be39f69aebcb7d0067f37f95018c024 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:27:58 -0800 Subject: [PATCH 19/97] Use heredoc_to_nowdoc rule --- .php_cs.dist | 1 + tests/Stripe/StripeObjectTest.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 4427215ef..e33b4d849 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -32,6 +32,7 @@ return PhpCsFixer\Config::create() 'fully_qualified_strict_types' => true, 'function_to_constant' => true, 'function_typehint_space' => true, + 'heredoc_to_nowdoc' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/tests/Stripe/StripeObjectTest.php b/tests/Stripe/StripeObjectTest.php index 3adf2b76e..9a6be9f4f 100644 --- a/tests/Stripe/StripeObjectTest.php +++ b/tests/Stripe/StripeObjectTest.php @@ -164,8 +164,8 @@ public function testToString() $s->foo = 'a'; $string = (string) $s; - $expected = << Date: Fri, 7 Feb 2020 10:28:17 -0800 Subject: [PATCH 20/97] Use implode_call rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index e33b4d849..54d08d4a6 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -33,6 +33,7 @@ return PhpCsFixer\Config::create() 'function_to_constant' => true, 'function_typehint_space' => true, 'heredoc_to_nowdoc' => true, + 'implode_call' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) From 4528c664e73e9461e93c76af0aa177630e1776bd Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:29:32 -0800 Subject: [PATCH 21/97] Use increment_style rule --- .php_cs.dist | 1 + lib/Util/Util.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index 54d08d4a6..f9a58dd41 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -34,6 +34,7 @@ return PhpCsFixer\Config::create() 'function_typehint_space' => true, 'heredoc_to_nowdoc' => true, 'implode_call' => true, + 'increment_style' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 94f9653b6..91c4677b1 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -191,7 +191,7 @@ public static function secureCompare($a, $b) } $result = 0; - for ($i = 0; $i < \strlen($a); $i++) { + for ($i = 0; $i < \strlen($a); ++$i) { $result |= \ord($a[$i]) ^ \ord($b[$i]); } return ($result == 0); From e3410ffd98b6a63156bbfbc4958a38e64590bf1f Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:30:36 -0800 Subject: [PATCH 22/97] Use is_null rule --- .php_cs.dist | 1 + lib/Exception/ApiErrorException.php | 2 +- lib/Exception/OAuth/OAuthErrorException.php | 2 +- lib/File.php | 2 +- lib/HttpClient/CurlClient.php | 4 ++-- lib/StripeObject.php | 2 +- lib/Util/CaseInsensitiveArray.php | 2 +- lib/Util/RequestOptions.php | 2 +- lib/Util/Util.php | 2 +- tests/StripeMock.php | 4 ++-- 10 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index f9a58dd41..bb781d7ce 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -35,6 +35,7 @@ return PhpCsFixer\Config::create() 'heredoc_to_nowdoc' => true, 'implode_call' => true, 'increment_style' => true, + 'is_null' => true, 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, ]) diff --git a/lib/Exception/ApiErrorException.php b/lib/Exception/ApiErrorException.php index 09730deee..7026511b4 100644 --- a/lib/Exception/ApiErrorException.php +++ b/lib/Exception/ApiErrorException.php @@ -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; } diff --git a/lib/Exception/OAuth/OAuthErrorException.php b/lib/Exception/OAuth/OAuthErrorException.php index 1303d1d41..bded3c889 100644 --- a/lib/Exception/OAuth/OAuthErrorException.php +++ b/lib/Exception/OAuth/OAuthErrorException.php @@ -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; } diff --git a/lib/File.php b/lib/File.php index 5b14bfa83..0e6438b5e 100644 --- a/lib/File.php +++ b/lib/File.php @@ -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 diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index acc228e03..c067dccfd 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -482,7 +482,7 @@ private function initCurlHandle() */ private function closeCurlHandle() { - if (!\is_null($this->curlHandle)) { + if (null !== $this->curlHandle) { \curl_close($this->curlHandle); $this->curlHandle = null; } @@ -494,7 +494,7 @@ private function closeCurlHandle() */ private function resetCurlHandle() { - if (!\is_null($this->curlHandle) && $this->getEnablePersistentConnections()) { + if (null !== $this->curlHandle && $this->getEnablePersistentConnections()) { \curl_reset($this->curlHandle); } else { $this->initCurlHandle(); diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 744d23db5..45b8bf094 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -412,7 +412,7 @@ public function jsonSerialize() public function toArray() { $maybeToArray = function ($value) { - if (\is_null($value)) { + if (null === $value) { return null; } diff --git a/lib/Util/CaseInsensitiveArray.php b/lib/Util/CaseInsensitiveArray.php index 64da53dcc..c5eaa6824 100644 --- a/lib/Util/CaseInsensitiveArray.php +++ b/lib/Util/CaseInsensitiveArray.php @@ -34,7 +34,7 @@ public function getIterator() public function offsetSet($offset, $value) { $offset = static::maybeLowercase($offset); - if (\is_null($offset)) { + if (null === $offset) { $this->container[] = $value; } else { $this->container[$offset] = $value; diff --git a/lib/Util/RequestOptions.php b/lib/Util/RequestOptions.php index c5acaaae1..ef938e28e 100644 --- a/lib/Util/RequestOptions.php +++ b/lib/Util/RequestOptions.php @@ -78,7 +78,7 @@ public static function parse($options) return $options; } - if (\is_null($options)) { + if (null === $options) { return new RequestOptions(null, [], null); } diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 91c4677b1..ad01d2c3c 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -219,7 +219,7 @@ public static function objectsToIds($h) } elseif (\is_array($h)) { $results = []; foreach ($h as $k => $v) { - if (\is_null($v)) { + if (null === $v) { continue; } $results[$k] = static::objectsToIds($v); diff --git a/tests/StripeMock.php b/tests/StripeMock.php index 5b23a191e..ce230c8f8 100644 --- a/tests/StripeMock.php +++ b/tests/StripeMock.php @@ -23,7 +23,7 @@ public static function start() return false; } - if (!\is_null(static::$process) && static::$process->isRunning()) { + if (null !== static::$process && static::$process->isRunning()) { echo "stripe-mock already running on port " . static::$port . "\n"; return true; } @@ -58,7 +58,7 @@ public static function start() */ public static function stop() { - if (\is_null(static::$process) || !static::$process->isRunning()) { + if (null === static::$process || !static::$process->isRunning()) { return; } From b0394a2cf0b9d4e77756d16dff83ff1d7d72610c Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:31:10 -0800 Subject: [PATCH 23/97] Use logical_operators rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index bb781d7ce..c5c1ccec8 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -37,6 +37,7 @@ return PhpCsFixer\Config::create() 'increment_style' => true, 'is_null' => true, 'linebreak_after_opening_tag' => true, + 'logical_operators' => true, 'native_function_invocation' => true, ]) ; From 3cdeae4d9cf592c24e1f25fecc37ce3d2e00d5f0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:31:34 -0800 Subject: [PATCH 24/97] Use lowercase_cast rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index c5c1ccec8..566419dbd 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -38,6 +38,7 @@ return PhpCsFixer\Config::create() 'is_null' => true, 'linebreak_after_opening_tag' => true, 'logical_operators' => true, + 'lowercase_cast' => true, 'native_function_invocation' => true, ]) ; From ca659edf060c5a3ad30bd4b4f7403a1a2eb01f93 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:31:53 -0800 Subject: [PATCH 25/97] Use lowercase_static_reference rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 566419dbd..bf9c1c037 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -39,6 +39,7 @@ return PhpCsFixer\Config::create() 'linebreak_after_opening_tag' => true, 'logical_operators' => true, 'lowercase_cast' => true, + 'lowercase_static_reference' => true, 'native_function_invocation' => true, ]) ; From 25020bc0005bc9f118893ec234b84364aec68e32 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:32:12 -0800 Subject: [PATCH 26/97] Use magic_constant_casing rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index bf9c1c037..488de89bd 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -40,6 +40,7 @@ return PhpCsFixer\Config::create() 'logical_operators' => true, 'lowercase_cast' => true, 'lowercase_static_reference' => true, + 'magic_constant_casing' => true, 'native_function_invocation' => true, ]) ; From 102075d27bae5b9221909aa0a1898daa25f38995 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:32:27 -0800 Subject: [PATCH 27/97] Use magic_method_casing rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 488de89bd..afddace01 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -41,6 +41,7 @@ return PhpCsFixer\Config::create() 'lowercase_cast' => true, 'lowercase_static_reference' => true, 'magic_constant_casing' => true, + 'magic_method_casing' => true, 'native_function_invocation' => true, ]) ; From a274a36c44fbd3ae76f6cbb8a77bf234db0edf30 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:33:20 -0800 Subject: [PATCH 28/97] Use method_chaining_indentation rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index afddace01..bc7269961 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -42,6 +42,7 @@ return PhpCsFixer\Config::create() 'lowercase_static_reference' => true, 'magic_constant_casing' => true, 'magic_method_casing' => true, + 'method_chaining_indentation' => true, 'native_function_invocation' => true, ]) ; From 65f91c0608336e313f38b5d6d4d182e3a6b14721 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:34:00 -0800 Subject: [PATCH 29/97] Use modernize_types_casting rule --- .php_cs.dist | 1 + lib/HttpClient/CurlClient.php | 4 ++-- lib/WebhookSignature.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index bc7269961..057db78d8 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -43,6 +43,7 @@ return PhpCsFixer\Config::create() 'magic_constant_casing' => true, 'magic_method_casing' => true, 'method_chaining_indentation' => true, + 'modernize_types_casting' => true, 'native_function_invocation' => true, ]) ; diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index c067dccfd..ef04538a0 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -323,7 +323,7 @@ private function executeRequestWithRetries($opts, $absUrl) if ($shouldRetry) { $numRetries += 1; $sleepSeconds = $this->sleepTime($numRetries, $rheaders); - \usleep(\intval($sleepSeconds * 1000000)); + \usleep((int) ($sleepSeconds * 1000000)); } else { break; } @@ -460,7 +460,7 @@ private function sleepTime($numRetries, $rheaders) $sleepSeconds = \max(Stripe::getInitialNetworkRetryDelay(), $sleepSeconds); // And never sleep less than the time the API asks us to wait, assuming it's a reasonable ask. - $retryAfter = isset($rheaders['retry-after']) ? \floatval($rheaders['retry-after']) : 0.0; + $retryAfter = isset($rheaders['retry-after']) ? (float) ($rheaders['retry-after']) : 0.0; if (\floor($retryAfter) == $retryAfter && $retryAfter <= Stripe::getMaxRetryAfter()) { $sleepSeconds = \max($sleepSeconds, $retryAfter); } diff --git a/lib/WebhookSignature.php b/lib/WebhookSignature.php index be1b9940b..1813ccb18 100644 --- a/lib/WebhookSignature.php +++ b/lib/WebhookSignature.php @@ -88,7 +88,7 @@ private static function getTimestamp($header) if (!\is_numeric($itemParts[1])) { return -1; } - return \intval($itemParts[1]); + return (int) ($itemParts[1]); } } From fb437b36645c2d9aebf45803d2a30b6c460b9115 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:34:21 -0800 Subject: [PATCH 30/97] Use multiline_comment_opening_closing rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 057db78d8..945a6e43f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -44,6 +44,7 @@ return PhpCsFixer\Config::create() 'magic_method_casing' => true, 'method_chaining_indentation' => true, 'modernize_types_casting' => true, + 'multiline_comment_opening_closing' => true, 'native_function_invocation' => true, ]) ; From b0e02174c63772b9d66e7f500d0b9268b194cd78 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:34:37 -0800 Subject: [PATCH 31/97] Use multiline_whitespace_before_semicolons rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 945a6e43f..27ad6eba4 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -45,6 +45,7 @@ return PhpCsFixer\Config::create() 'method_chaining_indentation' => true, 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, + 'multiline_whitespace_before_semicolons' => true, 'native_function_invocation' => true, ]) ; From d813bf9f8dc70804790a70c4be7d4d89c2619ca1 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:35:44 -0800 Subject: [PATCH 32/97] Use native_constant_invocation rule --- .php_cs.dist | 1 + build.php | 2 +- examples/oauth.php | 4 +- lib/ApiRequestor.php | 2 +- lib/HttpClient/CurlClient.php | 46 +++++++++++----------- lib/StripeObject.php | 2 +- lib/Util/CaseInsensitiveArray.php | 2 +- lib/Util/Util.php | 2 +- lib/Webhook.php | 2 +- tests/Stripe/HttpClient/CurlClientTest.php | 10 ++--- tests/StripeMock.php | 4 +- tests/bootstrap.php | 6 +-- update_certs.php | 6 +-- 13 files changed, 45 insertions(+), 44 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 27ad6eba4..e28e1a2b9 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -46,6 +46,7 @@ return PhpCsFixer\Config::create() 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, 'multiline_whitespace_before_semicolons' => true, + 'native_constant_invocation' => true, 'native_function_invocation' => true, ]) ; diff --git a/build.php b/build.php index 49b110d50..59897302b 100755 --- a/build.php +++ b/build.php @@ -10,7 +10,7 @@ $composer = \json_decode(\file_get_contents('composer.json'), true); unset($composer['autoload'], $composer['autoload-dev']); - \file_put_contents('composer.json', \json_encode($composer, JSON_PRETTY_PRINT)); + \file_put_contents('composer.json', \json_encode($composer, \JSON_PRETTY_PRINT)); } \passthru('composer update', $returnStatus); diff --git a/examples/oauth.php b/examples/oauth.php index 0998c831e..eee9b4952 100644 --- a/examples/oauth.php +++ b/examples/oauth.php @@ -28,7 +28,7 @@ $error = $_GET['error']; $error_description = $_GET['error_description']; - echo "

Error: code=" . \htmlspecialchars($error, ENT_QUOTES) . ", description=" . \htmlspecialchars($error_description, ENT_QUOTES) . "

\n"; + echo "

Error: code=" . \htmlspecialchars($error, \ENT_QUOTES) . ", description=" . \htmlspecialchars($error_description, \ENT_QUOTES) . "

\n"; echo "

Click here to restart the OAuth flow.

\n"; } elseif (isset($_GET['deauth'])) { // Deauthorization request @@ -42,7 +42,7 @@ exit("Error: " . $e->getMessage()); } - echo "

Success! Account " . \htmlspecialchars($accountId, ENT_QUOTES) . " is disconnected.

\n"; + echo "

Success! Account " . \htmlspecialchars($accountId, \ENT_QUOTES) . " is disconnected.

\n"; echo "

Click here to restart the OAuth flow.

\n"; } else { $url = \Stripe\OAuth::authorizeUrl([ diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index b568d6e31..db54e6e3a 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -420,7 +420,7 @@ private function _interpretResponse($rbody, $rcode, $rheaders) { $resp = \json_decode($rbody, true); $jsonError = \json_last_error(); - if ($resp === null && $jsonError !== JSON_ERROR_NONE) { + 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); diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index ef04538a0..b2cbbc3e1 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -210,16 +210,16 @@ public function request($method, $absUrl, $headers, $params, $hasFile) "Issuing a GET request with a file parameter" ); } - $opts[CURLOPT_HTTPGET] = 1; + $opts[\CURLOPT_HTTPGET] = 1; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); $absUrl = "${absUrl}?${encoded}"; } } elseif ($method == 'post') { - $opts[CURLOPT_POST] = 1; - $opts[CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::encodeParameters($params); + $opts[\CURLOPT_POST] = 1; + $opts[\CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::encodeParameters($params); } elseif ($method == 'delete') { - $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; + $opts[\CURLOPT_CUSTOMREQUEST] = 'DELETE'; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); $absUrl = "${absUrl}?${encoded}"; @@ -251,19 +251,19 @@ public function request($method, $absUrl, $headers, $params, $hasFile) \array_push($headers, 'Expect: '); $absUrl = Util\Util::utf8($absUrl); - $opts[CURLOPT_URL] = $absUrl; - $opts[CURLOPT_RETURNTRANSFER] = true; - $opts[CURLOPT_CONNECTTIMEOUT] = $this->connectTimeout; - $opts[CURLOPT_TIMEOUT] = $this->timeout; - $opts[CURLOPT_HTTPHEADER] = $headers; - $opts[CURLOPT_CAINFO] = Stripe::getCABundlePath(); + $opts[\CURLOPT_URL] = $absUrl; + $opts[\CURLOPT_RETURNTRANSFER] = true; + $opts[\CURLOPT_CONNECTTIMEOUT] = $this->connectTimeout; + $opts[\CURLOPT_TIMEOUT] = $this->timeout; + $opts[\CURLOPT_HTTPHEADER] = $headers; + $opts[\CURLOPT_CAINFO] = Stripe::getCABundlePath(); if (!Stripe::getVerifySslCerts()) { - $opts[CURLOPT_SSL_VERIFYPEER] = false; + $opts[\CURLOPT_SSL_VERIFYPEER] = false; } - if (!isset($opts[CURLOPT_HTTP_VERSION]) && $this->getEnableHttp2()) { + if (!isset($opts[\CURLOPT_HTTP_VERSION]) && $this->getEnableHttp2()) { // For HTTPS requests, enable HTTP/2, if supported - $opts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2TLS; + $opts[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_2TLS; } list($rbody, $rcode, $rheaders) = $this->executeRequestWithRetries($opts, $absUrl); @@ -277,7 +277,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) private function executeRequestWithRetries($opts, $absUrl) { $numRetries = 0; - $isPost = \array_key_exists(CURLOPT_POST, $opts) && $opts[CURLOPT_POST] == 1; + $isPost = \array_key_exists(\CURLOPT_POST, $opts) && $opts[\CURLOPT_POST] == 1; while (true) { $rcode = 0; @@ -295,7 +295,7 @@ private function executeRequestWithRetries($opts, $absUrl) $rheaders[\trim($key)] = \trim($value); return \strlen($header_line); }; - $opts[CURLOPT_HEADERFUNCTION] = $headerCallback; + $opts[\CURLOPT_HEADERFUNCTION] = $headerCallback; $this->resetCurlHandle(); \curl_setopt_array($this->curlHandle, $opts); @@ -305,7 +305,7 @@ private function executeRequestWithRetries($opts, $absUrl) $errno = \curl_errno($this->curlHandle); $message = \curl_error($this->curlHandle); } else { - $rcode = \curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE); + $rcode = \curl_getinfo($this->curlHandle, \CURLINFO_HTTP_CODE); } if (!$this->getEnablePersistentConnections()) { $this->closeCurlHandle(); @@ -346,16 +346,16 @@ private function executeRequestWithRetries($opts, $absUrl) private function handleCurlError($url, $errno, $message, $numRetries) { switch ($errno) { - case CURLE_COULDNT_CONNECT: - case CURLE_COULDNT_RESOLVE_HOST: - case CURLE_OPERATION_TIMEOUTED: + case \CURLE_COULDNT_CONNECT: + case \CURLE_COULDNT_RESOLVE_HOST: + case \CURLE_OPERATION_TIMEOUTED: $msg = "Could not connect to Stripe (${url}). Please check your " . "internet connection and try again. If this problem persists, " . "you should check Stripe's service status at " . "https://twitter.com/stripestatus, or"; break; - case CURLE_SSL_CACERT: - case CURLE_SSL_PEER_CERTIFICATE: + case \CURLE_SSL_CACERT: + case \CURLE_SSL_PEER_CERTIFICATE: $msg = "Could not verify Stripe's SSL certificate. Please make sure " . "that your network is not intercepting certificates. " . "(Try going to ${url} in your browser.) " @@ -395,14 +395,14 @@ private function shouldRetry($errno, $rcode, $rheaders, $numRetries) } // Retry on timeout-related problems (either on open or read). - if ($errno === CURLE_OPERATION_TIMEOUTED) { + if ($errno === \CURLE_OPERATION_TIMEOUTED) { return true; } // Destination refused the connection, the connection was reset, or a // variety of other connection failures. This could occur from a single // saturated server, so retry in case it's intermittent. - if ($errno === CURLE_COULDNT_CONNECT) { + if ($errno === \CURLE_COULDNT_CONNECT) { return true; } diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 45b8bf094..3b52f321d 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -440,7 +440,7 @@ public function toArray() */ public function toJSON() { - return \json_encode($this->toArray(), JSON_PRETTY_PRINT); + return \json_encode($this->toArray(), \JSON_PRETTY_PRINT); } public function __toString() diff --git a/lib/Util/CaseInsensitiveArray.php b/lib/Util/CaseInsensitiveArray.php index c5eaa6824..978fed05e 100644 --- a/lib/Util/CaseInsensitiveArray.php +++ b/lib/Util/CaseInsensitiveArray.php @@ -18,7 +18,7 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \IteratorAggrega public function __construct($initial_array = []) { - $this->container = \array_change_key_case($initial_array, CASE_LOWER); + $this->container = \array_change_key_case($initial_array, \CASE_LOWER); } public function count() diff --git a/lib/Util/Util.php b/lib/Util/Util.php index ad01d2c3c..3971e3c8e 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -158,7 +158,7 @@ public static function utf8($value) \trigger_error("It looks like the mbstring extension is not enabled. " . "UTF-8 strings will not properly be encoded. Ask your system " . "administrator to enable the mbstring extension, or write to " . - "support@stripe.com if you have any questions.", E_USER_WARNING); + "support@stripe.com if you have any questions.", \E_USER_WARNING); } } diff --git a/lib/Webhook.php b/lib/Webhook.php index d4c23a1f0..a21ef8c4f 100644 --- a/lib/Webhook.php +++ b/lib/Webhook.php @@ -28,7 +28,7 @@ public static function constructEvent($payload, $sigHeader, $secret, $tolerance $data = \json_decode($payload, true); $jsonError = \json_last_error(); - if ($data === null && $jsonError !== JSON_ERROR_NONE) { + if ($data === null && $jsonError !== \JSON_ERROR_NONE) { $msg = "Invalid payload: ${payload} " . "(json_last_error() was ${jsonError})"; throw new Exception\UnexpectedValueException($msg); diff --git a/tests/Stripe/HttpClient/CurlClientTest.php b/tests/Stripe/HttpClient/CurlClientTest.php index b2bf76065..6aabee60c 100644 --- a/tests/Stripe/HttpClient/CurlClientTest.php +++ b/tests/Stripe/HttpClient/CurlClientTest.php @@ -113,7 +113,7 @@ public function testUserAgentInfo() public function testDefaultOptions() { // make sure options array loads/saves properly - $optionsArray = [CURLOPT_PROXY => 'localhost:80']; + $optionsArray = [\CURLOPT_PROXY => 'localhost:80']; $withOptionsArray = new CurlClient($optionsArray); $this->assertSame($withOptionsArray->getDefaultOptions(), $optionsArray); @@ -139,7 +139,7 @@ public function testDefaultOptions() public function testSslOption() { // make sure options array loads/saves properly - $optionsArray = [CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]; + $optionsArray = [\CURLOPT_SSLVERSION => \CURL_SSLVERSION_TLSv1]; $withOptionsArray = new CurlClient($optionsArray); $this->assertSame($withOptionsArray->getDefaultOptions(), $optionsArray); } @@ -150,7 +150,7 @@ public function testShouldRetryOnTimeout() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, CURLE_OPERATION_TIMEOUTED, 0, [], 0)); + $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, \CURLE_OPERATION_TIMEOUTED, 0, [], 0)); } public function testShouldRetryOnConnectionFailure() @@ -159,7 +159,7 @@ public function testShouldRetryOnConnectionFailure() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, CURLE_COULDNT_CONNECT, 0, [], 0)); + $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, \CURLE_COULDNT_CONNECT, 0, [], 0)); } public function testShouldRetryOnConflict() @@ -233,7 +233,7 @@ public function testShouldNotRetryOnCertValidationError() $curlClient = new CurlClient(); - $this->assertFalse($this->shouldRetryMethod->invoke($curlClient, CURLE_SSL_PEER_CERTIFICATE, -1, [], 0)); + $this->assertFalse($this->shouldRetryMethod->invoke($curlClient, \CURLE_SSL_PEER_CERTIFICATE, -1, [], 0)); } public function testSleepTimeShouldGrowExponentially() diff --git a/tests/StripeMock.php b/tests/StripeMock.php index ce230c8f8..f21a066cf 100644 --- a/tests/StripeMock.php +++ b/tests/StripeMock.php @@ -63,7 +63,7 @@ public static function stop() } echo "Stopping stripe-mock...\n"; - static::$process->stop(0, SIGTERM); + static::$process->stop(0, \SIGTERM); static::$process->wait(); static::$process = null; static::$port = -1; @@ -87,7 +87,7 @@ public static function getPort() */ private static function findAvailablePort() { - $sock = \socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $sock = \socket_create(\AF_INET, \SOCK_STREAM, \SOL_TCP); \socket_bind($sock, "localhost", 0); $addr = null; $port = -1; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2c3440245..352485166 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -18,9 +18,9 @@ // Send a request to stripe-mock $ch = \curl_init(MOCK_URL); -\curl_setopt($ch, CURLOPT_HEADER, 1); -\curl_setopt($ch, CURLOPT_NOBODY, 1); -\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); +\curl_setopt($ch, \CURLOPT_HEADER, 1); +\curl_setopt($ch, \CURLOPT_NOBODY, 1); +\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1); $resp = \curl_exec($ch); if (\curl_errno($ch)) { diff --git a/update_certs.php b/update_certs.php index 48b6fd893..32e526caf 100755 --- a/update_certs.php +++ b/update_certs.php @@ -7,9 +7,9 @@ $fp = \fopen(\dirname(__FILE__) . '/data/ca-certificates.crt', 'w+b'); $options = [ - CURLOPT_FILE => $fp, - CURLOPT_TIMEOUT => 3600, - CURLOPT_URL => 'https://curl.haxx.se/ca/cacert.pem', + \CURLOPT_FILE => $fp, + \CURLOPT_TIMEOUT => 3600, + \CURLOPT_URL => 'https://curl.haxx.se/ca/cacert.pem', ]; $ch = \curl_init(); From 4d1bc4dd97d37bdde90b0292ba9fc43b333fe706 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:36:03 -0800 Subject: [PATCH 33/97] Use native_function_casing rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index e28e1a2b9..f6290e133 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -47,6 +47,7 @@ return PhpCsFixer\Config::create() 'multiline_comment_opening_closing' => true, 'multiline_whitespace_before_semicolons' => true, 'native_constant_invocation' => true, + 'native_function_casing' => true, 'native_function_invocation' => true, ]) ; From 000f0196b106a4548a503347d3cf462b68d60cff Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:36:21 -0800 Subject: [PATCH 34/97] Use native_function_type_declaration_casing rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index f6290e133..b10264068 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -49,5 +49,6 @@ return PhpCsFixer\Config::create() 'native_constant_invocation' => true, 'native_function_casing' => true, 'native_function_invocation' => true, + 'native_function_type_declaration_casing' => true, ]) ; From ab7f07f6fa4d8509f038b48a8e8d04057cd81a88 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:36:41 -0800 Subject: [PATCH 35/97] Use new_with_braces rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index b10264068..aec185476 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -50,5 +50,6 @@ return PhpCsFixer\Config::create() 'native_function_casing' => true, 'native_function_invocation' => true, 'native_function_type_declaration_casing' => true, + 'new_with_braces' => true, ]) ; From cd33de28c63700c4307012d54a65c87a4a1f1b32 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:37:16 -0800 Subject: [PATCH 36/97] Use no_alias_functions rule --- .php_cs.dist | 1 + lib/StripeObject.php | 4 ++-- tests/StripeMock.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index aec185476..de22747f4 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -51,5 +51,6 @@ return PhpCsFixer\Config::create() 'native_function_invocation' => true, 'native_function_type_declaration_casing' => true, 'new_with_braces' => true, + 'no_alias_functions' => true, ]) ; diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 3b52f321d..7359733f8 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -118,7 +118,7 @@ public function __set($k, $v) if (static::getPermanentAttributes()->includes($k)) { throw new Exception\InvalidArgumentException( "Cannot set ${k} on this object. HINT: you can't set: " . - \join(', ', static::getPermanentAttributes()->toArray()) + \implode(', ', static::getPermanentAttributes()->toArray()) ); } @@ -155,7 +155,7 @@ public function &__get($k) return $this->_values[$k]; } elseif (!empty($this->_transientValues) && $this->_transientValues->includes($k)) { $class = \get_class($this); - $attrs = \join(', ', \array_keys($this->_values)); + $attrs = \implode(', ', \array_keys($this->_values)); $message = "Stripe Notice: Undefined property of ${class} instance: ${k}. " . "HINT: The ${k} attribute was set in the past, however. " . "It was then wiped when refreshing the object " diff --git a/tests/StripeMock.php b/tests/StripeMock.php index f21a066cf..567f94aa9 100644 --- a/tests/StripeMock.php +++ b/tests/StripeMock.php @@ -32,7 +32,7 @@ public static function start() echo "Starting stripe-mock on port " . static::$port . "...\n"; - static::$process = new Process(\join(' ', [ + static::$process = new Process(\implode(' ', [ 'stripe-mock', '-http-port', static::$port, From b5a03a750b62fec6efd99e5d181583d35fa9a007 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:37:35 -0800 Subject: [PATCH 37/97] Use no_alternative_syntax rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index de22747f4..e87ed2bef 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -52,5 +52,6 @@ return PhpCsFixer\Config::create() 'native_function_type_declaration_casing' => true, 'new_with_braces' => true, 'no_alias_functions' => true, + 'no_alternative_syntax' => true, ]) ; From 3cf8e079d82186f88470a721798672425afc43cf Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:37:52 -0800 Subject: [PATCH 38/97] Use no_binary_string rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index e87ed2bef..3b770c6a3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -53,5 +53,6 @@ return PhpCsFixer\Config::create() 'new_with_braces' => true, 'no_alias_functions' => true, 'no_alternative_syntax' => true, + 'no_binary_string' => true, ]) ; From bb54f18681fe1ea841b7b72f3230d2760ab4c8c7 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:38:09 -0800 Subject: [PATCH 39/97] Use no_blank_lines_after_class_opening rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 3b770c6a3..71061dd99 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -54,5 +54,6 @@ return PhpCsFixer\Config::create() 'no_alias_functions' => true, 'no_alternative_syntax' => true, 'no_binary_string' => true, + 'no_blank_lines_after_class_opening' => true, ]) ; From 75760018d8b8c87c7f5f86f5af6702d34d4562e8 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:38:37 -0800 Subject: [PATCH 40/97] Use no_empty_comment rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 71061dd99..7645d757c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -55,5 +55,6 @@ return PhpCsFixer\Config::create() 'no_alternative_syntax' => true, 'no_binary_string' => true, 'no_blank_lines_after_class_opening' => true, + 'no_empty_comment' => true, ]) ; From f566e41c75960e2852570a2aff96b13f6dfcd26d Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:38:56 -0800 Subject: [PATCH 41/97] Use no_empty_statement rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 7645d757c..6db505eea 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -56,5 +56,6 @@ return PhpCsFixer\Config::create() 'no_binary_string' => true, 'no_blank_lines_after_class_opening' => true, 'no_empty_comment' => true, + 'no_empty_statement' => true, ]) ; From a7f0d2e83f95bb80c08c2491cefc49d3768d8743 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:39:22 -0800 Subject: [PATCH 42/97] Use no_extra_blank_lines rule --- .php_cs.dist | 1 + examples/oauth.php | 1 - lib/Account.php | 1 - lib/ApplicationFee.php | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 6db505eea..b9f04c97a 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -57,5 +57,6 @@ return PhpCsFixer\Config::create() 'no_blank_lines_after_class_opening' => true, 'no_empty_comment' => true, 'no_empty_statement' => true, + 'no_extra_blank_lines' => true, ]) ; diff --git a/examples/oauth.php b/examples/oauth.php index eee9b4952..22fc5684f 100644 --- a/examples/oauth.php +++ b/examples/oauth.php @@ -5,7 +5,6 @@ \Stripe\Stripe::setApiKey(\getenv('STRIPE_SECRET_KEY')); \Stripe\Stripe::setClientId(\getenv('STRIPE_CLIENT_ID')); - if (isset($_GET['code'])) { // The user was redirected back from the OAuth form with an authorization code. $code = $_GET['code']; diff --git a/lib/Account.php b/lib/Account.php index 144421e48..d1d9bd1f4 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -201,7 +201,6 @@ public function reject($params = null, $opts = null) * capabilities property which is a hash and not the sub-list of capabilities. */ - const PATH_CAPABILITIES = '/capabilities'; /** diff --git a/lib/ApplicationFee.php b/lib/ApplicationFee.php index e4cd68743..ce24b1560 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -30,7 +30,6 @@ class ApplicationFee extends ApiResource use ApiOperations\NestedResource; use ApiOperations\Retrieve; - const PATH_REFUNDS = '/refunds'; /** From 67f4ad6e8b7bba08f4ea060a363de8382874b703 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:39:43 -0800 Subject: [PATCH 43/97] Use no_homoglyph_names rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index b9f04c97a..7d270ae5b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -58,5 +58,6 @@ return PhpCsFixer\Config::create() 'no_empty_comment' => true, 'no_empty_statement' => true, 'no_extra_blank_lines' => true, + 'no_homoglyph_names' => true, ]) ; From dbc104b4e64b3297ae89f8dd2f959d5b1b10dd72 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:40:10 -0800 Subject: [PATCH 44/97] Use no_leading_import_slash rule --- .php_cs.dist | 1 + tests/StripeMock.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index 7d270ae5b..57a657585 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -59,5 +59,6 @@ return PhpCsFixer\Config::create() 'no_empty_statement' => true, 'no_extra_blank_lines' => true, 'no_homoglyph_names' => true, + 'no_leading_import_slash' => true, ]) ; diff --git a/tests/StripeMock.php b/tests/StripeMock.php index 567f94aa9..23078007d 100644 --- a/tests/StripeMock.php +++ b/tests/StripeMock.php @@ -2,7 +2,7 @@ namespace Stripe; -use \Symfony\Component\Process\Process; +use Symfony\Component\Process\Process; class StripeMock { From ea46b51ef71db89422f16f41c8fcceadd460302a Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:40:29 -0800 Subject: [PATCH 45/97] Use no_leading_namespace_whitespace rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 57a657585..1eee61316 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -60,5 +60,6 @@ return PhpCsFixer\Config::create() 'no_extra_blank_lines' => true, 'no_homoglyph_names' => true, 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, ]) ; From 6ce2a95cdae62159ab74a70c58eaab64b44ad6f2 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:40:45 -0800 Subject: [PATCH 46/97] Use no_mixed_echo_print rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 1eee61316..94b5fa2dd 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -61,5 +61,6 @@ return PhpCsFixer\Config::create() 'no_homoglyph_names' => true, 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, + 'no_mixed_echo_print' => true, ]) ; From bfb5c27d5e73a35a1a4d4d86869e6812f1c9fd35 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:41:01 -0800 Subject: [PATCH 47/97] Use no_multiline_whitespace_around_double_arrow rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 94b5fa2dd..d1d8d8916 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -62,5 +62,6 @@ return PhpCsFixer\Config::create() 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_mixed_echo_print' => true, + 'no_multiline_whitespace_around_double_arrow' => true, ]) ; From 174814348802a7931b6dc66995c3cf68bdea544a Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:41:40 -0800 Subject: [PATCH 48/97] Use no_null_property_initialization rule --- .php_cs.dist | 1 + lib/HttpClient/CurlClient.php | 6 +++--- lib/Util/DefaultLogger.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index d1d8d8916..882bcb3f7 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -63,5 +63,6 @@ return PhpCsFixer\Config::create() 'no_leading_namespace_whitespace' => true, 'no_mixed_echo_print' => true, 'no_multiline_whitespace_around_double_arrow' => true, + 'no_null_property_initialization' => true, ]) ; diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index b2cbbc3e1..766cb0e21 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -45,11 +45,11 @@ public static function instance() protected $enablePersistentConnections = true; - protected $enableHttp2 = null; + protected $enableHttp2; - protected $curlHandle = null; + protected $curlHandle; - protected $requestStatusCallback = null; + protected $requestStatusCallback; /** * CurlClient constructor. diff --git a/lib/Util/DefaultLogger.php b/lib/Util/DefaultLogger.php index 2c526251f..e51a57c14 100644 --- a/lib/Util/DefaultLogger.php +++ b/lib/Util/DefaultLogger.php @@ -10,7 +10,7 @@ class DefaultLogger implements LoggerInterface { public $messageType = 0; - public $destination = null; + public $destination; public function error($message, array $context = []) { From d803db2bb5e8a405dd32d8d4c41a098a800beb72 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:41:56 -0800 Subject: [PATCH 49/97] Use no_short_bool_cast rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 882bcb3f7..77d37719c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -64,5 +64,6 @@ return PhpCsFixer\Config::create() 'no_mixed_echo_print' => true, 'no_multiline_whitespace_around_double_arrow' => true, 'no_null_property_initialization' => true, + 'no_short_bool_cast' => true, ]) ; From 589b9735fcedccc1716e86b44a478280e8577d0b Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:42:22 -0800 Subject: [PATCH 50/97] Use no_short_echo_tag rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 77d37719c..a362a12e5 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -65,5 +65,6 @@ return PhpCsFixer\Config::create() 'no_multiline_whitespace_around_double_arrow' => true, 'no_null_property_initialization' => true, 'no_short_bool_cast' => true, + 'no_short_echo_tag' => true, ]) ; From f49639040b7fb6285df058eb96f15b816aaba76e Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:42:39 -0800 Subject: [PATCH 51/97] Use no_singleline_whitespace_before_semicolons rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index a362a12e5..f131c7179 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -66,5 +66,6 @@ return PhpCsFixer\Config::create() 'no_null_property_initialization' => true, 'no_short_bool_cast' => true, 'no_short_echo_tag' => true, + 'no_singleline_whitespace_before_semicolons' => true, ]) ; From 194064850c552def59cb59915d6c2150020f9e86 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:43:03 -0800 Subject: [PATCH 52/97] Use no_spaces_around_offset rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index f131c7179..7ac5668c5 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -67,5 +67,6 @@ return PhpCsFixer\Config::create() 'no_short_bool_cast' => true, 'no_short_echo_tag' => true, 'no_singleline_whitespace_before_semicolons' => true, + 'no_spaces_around_offset' => true, ]) ; From 6b2940f7994f0fb24e5a92c9253460d65bc35c86 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:43:55 -0800 Subject: [PATCH 53/97] Use no_superfluous_elseif rule --- .php_cs.dist | 1 + lib/ApiRequestor.php | 9 ++++++--- lib/StripeObject.php | 12 ++++++++---- lib/Util/Util.php | 9 ++++++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 7ac5668c5..ca5123fce 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -68,5 +68,6 @@ return PhpCsFixer\Config::create() 'no_short_echo_tag' => true, 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_around_offset' => true, + 'no_superfluous_elseif' => true, ]) ; diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index db54e6e3a..df6f5ddf8 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -80,11 +80,14 @@ private static function _encodeObjects($d) { if ($d instanceof ApiResource) { return Util\Util::utf8($d->id); - } elseif ($d === true) { + } + if ($d === true) { return 'true'; - } elseif ($d === false) { + } + if ($d === false) { return 'false'; - } elseif (\is_array($d)) { + } + if (\is_array($d)) { $res = []; foreach ($d as $k => $v) { $res[$k] = self::_encodeObjects($v); diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 7359733f8..e725529e5 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -153,7 +153,8 @@ public function &__get($k) $nullval = null; if (!empty($this->_values) && \array_key_exists($k, $this->_values)) { return $this->_values[$k]; - } elseif (!empty($this->_transientValues) && $this->_transientValues->includes($k)) { + } + if (!empty($this->_transientValues) && $this->_transientValues->includes($k)) { $class = \get_class($this); $attrs = \implode(', ', \array_keys($this->_values)); $message = "Stripe Notice: Undefined property of ${class} instance: ${k}. " @@ -360,10 +361,12 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = // user intended it to. if ($value === null) { return ""; - } elseif (($value instanceof ApiResource) && (!$value->saveWithParent)) { + } + if (($value instanceof ApiResource) && (!$value->saveWithParent)) { if (!$unsaved) { return null; - } elseif (isset($value->id)) { + } + if (isset($value->id)) { return $value; } else { throw new Exception\InvalidArgumentException( @@ -486,7 +489,8 @@ protected static function deepCopy($obj) $copy[$k] = self::deepCopy($v); } return $copy; - } elseif ($obj instanceof StripeObject) { + } + if ($obj instanceof StripeObject) { return $obj::constructFrom( self::deepCopy($obj->_values), clone $obj->_opts diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 3971e3c8e..78748966f 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -131,7 +131,8 @@ public static function convertToStripeObject($resp, $opts) \array_push($mapped, self::convertToStripeObject($i, $opts)); } return $mapped; - } elseif (\is_array($resp)) { + } + if (\is_array($resp)) { if (isset($resp['object']) && \is_string($resp['object']) && isset($types[$resp['object']])) { $class = $types[$resp['object']]; } else { @@ -210,13 +211,15 @@ public static function objectsToIds($h) { if ($h instanceof \Stripe\ApiResource) { return $h->id; - } elseif (static::isList($h)) { + } + if (static::isList($h)) { $results = []; foreach ($h as $v) { \array_push($results, static::objectsToIds($v)); } return $results; - } elseif (\is_array($h)) { + } + if (\is_array($h)) { $results = []; foreach ($h as $k => $v) { if (null === $v) { From f44e427162a08d375d9b5a04e620f7759a4c0d79 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:44:16 -0800 Subject: [PATCH 54/97] Use no_trailing_comma_in_list_call rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index ca5123fce..44f884844 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -69,5 +69,6 @@ return PhpCsFixer\Config::create() 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_around_offset' => true, 'no_superfluous_elseif' => true, + 'no_trailing_comma_in_list_call' => true, ]) ; From 9aa05a4570accbebcf8430258b239c76161c66d3 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:44:33 -0800 Subject: [PATCH 55/97] Use no_trailing_comma_in_singleline_array rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 44f884844..e72745b90 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -70,5 +70,6 @@ return PhpCsFixer\Config::create() 'no_spaces_around_offset' => true, 'no_superfluous_elseif' => true, 'no_trailing_comma_in_list_call' => true, + 'no_trailing_comma_in_singleline_array' => true, ]) ; From ca220da4f59f212365d3b540707c86f64cc81227 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:44:56 -0800 Subject: [PATCH 56/97] Use no_unneeded_control_parentheses rule --- .php_cs.dist | 1 + lib/HttpClient/CurlClient.php | 2 +- lib/Util/Util.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index e72745b90..18753f5aa 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -71,5 +71,6 @@ return PhpCsFixer\Config::create() 'no_superfluous_elseif' => true, 'no_trailing_comma_in_list_call' => true, 'no_trailing_comma_in_singleline_array' => true, + 'no_unneeded_control_parentheses' => true, ]) ; diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index 766cb0e21..f4d12896f 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -511,7 +511,7 @@ private function canSafelyUseHttp2() // Versions of curl older than 7.60.0 don't respect GOAWAY frames // (cf. https://github.com/curl/curl/issues/2416), which Stripe use. $curlVersion = \curl_version()['version']; - return (\version_compare($curlVersion, '7.60.0') >= 0); + return \version_compare($curlVersion, '7.60.0') >= 0; } /** diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 78748966f..54b6745b1 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -195,7 +195,7 @@ public static function secureCompare($a, $b) for ($i = 0; $i < \strlen($a); ++$i) { $result |= \ord($a[$i]) ^ \ord($b[$i]); } - return ($result == 0); + return $result == 0; } } From 5357a991baa8882bca52244a7ec8ca8d4d962a21 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:45:16 -0800 Subject: [PATCH 57/97] Use no_unneeded_curly_braces rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 18753f5aa..33af59fcb 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -72,5 +72,6 @@ return PhpCsFixer\Config::create() 'no_trailing_comma_in_list_call' => true, 'no_trailing_comma_in_singleline_array' => true, 'no_unneeded_control_parentheses' => true, + 'no_unneeded_curly_braces' => true, ]) ; From eb512cb1e2f6aefd83483b614f40aa50dbf6d1e3 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:45:32 -0800 Subject: [PATCH 58/97] Use no_unneeded_final_method rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 33af59fcb..219ae612f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -73,5 +73,6 @@ return PhpCsFixer\Config::create() 'no_trailing_comma_in_singleline_array' => true, 'no_unneeded_control_parentheses' => true, 'no_unneeded_curly_braces' => true, + 'no_unneeded_final_method' => true, ]) ; From ed675bd7d526ff1899a3ed9f9eb6f22ed82269bb Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:46:01 -0800 Subject: [PATCH 59/97] Use no_unreachable_default_argument_value rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 219ae612f..07536fa4c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -74,5 +74,6 @@ return PhpCsFixer\Config::create() 'no_unneeded_control_parentheses' => true, 'no_unneeded_curly_braces' => true, 'no_unneeded_final_method' => true, + 'no_unreachable_default_argument_value' => true, ]) ; From d13c7010ddf61d8151d9535d0f47019e9c27b02a Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:46:17 -0800 Subject: [PATCH 60/97] Use no_unset_cast rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 07536fa4c..10e5352ed 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -75,5 +75,6 @@ return PhpCsFixer\Config::create() 'no_unneeded_curly_braces' => true, 'no_unneeded_final_method' => true, 'no_unreachable_default_argument_value' => true, + 'no_unset_cast' => true, ]) ; From 0d164b0fbf1b8f6850a09ca98032451bac68739c Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:47:14 -0800 Subject: [PATCH 61/97] Use no_unused_imports rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 10e5352ed..c9f7cdbaf 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -76,5 +76,6 @@ return PhpCsFixer\Config::create() 'no_unneeded_final_method' => true, 'no_unreachable_default_argument_value' => true, 'no_unset_cast' => true, + 'no_unused_imports' => true, ]) ; From 791eaad7d398192a9c5664cbfbcbdf8e97ace80d Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:48:16 -0800 Subject: [PATCH 62/97] Use no_useless_else rule --- .php_cs.dist | 1 + lib/Account.php | 3 +-- lib/ApiRequestor.php | 11 ++++------- lib/BitcoinReceiver.php | 7 +++---- lib/Collection.php | 7 +++---- lib/Source.php | 7 +++---- lib/StripeObject.php | 15 ++++++--------- lib/Util/CaseInsensitiveArray.php | 3 +-- lib/Util/Util.php | 26 +++++++++++--------------- 9 files changed, 33 insertions(+), 47 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index c9f7cdbaf..eb7a0fbe3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -77,5 +77,6 @@ return PhpCsFixer\Config::create() 'no_unreachable_default_argument_value' => true, 'no_unset_cast' => true, 'no_unused_imports' => true, + 'no_useless_else' => true, ]) ; diff --git a/lib/Account.php b/lib/Account.php index d1d9bd1f4..24e937f5d 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -90,9 +90,8 @@ public function instanceUrl() { if ($this['id'] === null) { return '/v1/account'; - } else { - return parent::instanceUrl(); } + return parent::instanceUrl(); } public function serializeParameters($force = false) diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index df6f5ddf8..08ad2b686 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -63,10 +63,9 @@ private static function _telemetryJson($requestTelemetry) $result = \json_encode($payload); if ($result != false) { return $result; - } else { - Stripe::getLogger()->error("Serializing telemetry payload failed!"); - return "{}"; } + Stripe::getLogger()->error("Serializing telemetry payload failed!"); + return "{}"; } /** @@ -93,9 +92,8 @@ private static function _encodeObjects($d) $res[$k] = self::_encodeObjects($v); } return $res; - } else { - return Util\Util::utf8($d); } + return Util\Util::utf8($d); } /** @@ -246,9 +244,8 @@ private static function _formatAppInfo($appInfo) $string .= ' (' . $appInfo['url'] . ')'; } return $string; - } else { - return null; } + return null; } /** diff --git a/lib/BitcoinReceiver.php b/lib/BitcoinReceiver.php index b300b6f62..57a3a3d00 100644 --- a/lib/BitcoinReceiver.php +++ b/lib/BitcoinReceiver.php @@ -62,10 +62,9 @@ public function instanceUrl() $parentExtn = \urlencode(Util\Util::utf8($parent)); $extn = \urlencode(Util\Util::utf8($this['id'])); return "${base}/${parentExtn}/${path}/${extn}"; - } else { - $base = BitcoinReceiver::classUrl(); - $extn = \urlencode(Util\Util::utf8($this['id'])); - return "${base}/${extn}"; } + $base = BitcoinReceiver::classUrl(); + $extn = \urlencode(Util\Util::utf8($this['id'])); + return "${base}/${extn}"; } } diff --git a/lib/Collection.php b/lib/Collection.php index 8965db611..af402eaee 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -53,13 +53,12 @@ public function offsetGet($k) { if (\is_string($k)) { return parent::offsetGet($k); - } else { - $msg = "You tried to access the {$k} index, but Collection " . + } + $msg = "You tried to access the {$k} index, but Collection " . "types only support string keys. (HINT: List calls " . "return an object with a `data` (which is the data " . "array). You likely want to call ->data[{$k}])"; - throw new Exception\InvalidArgumentException($msg); - } + throw new Exception\InvalidArgumentException($msg); } public function all($params = null, $opts = null) diff --git a/lib/Source.php b/lib/Source.php index 0b1501c56..79fac9895 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -112,11 +112,10 @@ public function detach($params = null, $opts = null) list($response, $opts) = $this->_request('delete', $url, $params, $opts); $this->refreshFrom($response, $opts); return $this; - } else { - $message = "This source object does not appear to be currently attached " - . "to a customer object."; - throw new Exception\UnexpectedValueException($message); } + $message = "This source object does not appear to be currently attached " + . "to a customer object."; + throw new Exception\UnexpectedValueException($message); } /** diff --git a/lib/StripeObject.php b/lib/StripeObject.php index e725529e5..ae69d1bc5 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -165,11 +165,10 @@ public function &__get($k) . "available on this object are: ${attrs}"; Stripe::getLogger()->error($message); return $nullval; - } else { - $class = \get_class($this); - Stripe::getLogger()->error("Stripe Notice: Undefined property of ${class} instance: ${k}"); - return $nullval; } + $class = \get_class($this); + Stripe::getLogger()->error("Stripe Notice: Undefined property of ${class} instance: ${k}"); + return $nullval; } // Magic method for var_dump output. Only works with PHP >= 5.6 @@ -368,13 +367,12 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = } if (isset($value->id)) { return $value; - } else { - throw new Exception\InvalidArgumentException( + } + throw new Exception\InvalidArgumentException( "Cannot save property `${key}` containing an API resource of type " . \get_class($value) . ". It doesn't appear to be persisted and is " . "not marked as `saveWithParent`." ); - } } elseif (\is_array($value)) { if (Util\Util::isList($value)) { // Sequential array, i.e. a list @@ -495,9 +493,8 @@ protected static function deepCopy($obj) self::deepCopy($obj->_values), clone $obj->_opts ); - } else { - return $obj; } + return $obj; } /** diff --git a/lib/Util/CaseInsensitiveArray.php b/lib/Util/CaseInsensitiveArray.php index 978fed05e..80781a43d 100644 --- a/lib/Util/CaseInsensitiveArray.php +++ b/lib/Util/CaseInsensitiveArray.php @@ -63,8 +63,7 @@ private static function maybeLowercase($v) { if (\is_string($v)) { return \strtolower($v); - } else { - return $v; } + return $v; } } diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 54b6745b1..8939e7a61 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -139,9 +139,8 @@ public static function convertToStripeObject($resp, $opts) $class = \Stripe\StripeObject::class; } return $class::constructFrom($resp, $opts); - } else { - return $resp; } + return $resp; } /** @@ -165,9 +164,8 @@ public static function utf8($value) if (\is_string($value) && self::$isMbstringAvailable && \mb_detect_encoding($value, "UTF-8", true) != "UTF-8") { return \utf8_encode($value); - } else { - return $value; } + return $value; } /** @@ -186,17 +184,16 @@ public static function secureCompare($a, $b) if (self::$isHashEqualsAvailable) { return \hash_equals($a, $b); - } else { - if (\strlen($a) != \strlen($b)) { - return false; - } + } + if (\strlen($a) != \strlen($b)) { + return false; + } - $result = 0; - for ($i = 0; $i < \strlen($a); ++$i) { - $result |= \ord($a[$i]) ^ \ord($b[$i]); - } - return $result == 0; + $result = 0; + for ($i = 0; $i < \strlen($a); ++$i) { + $result |= \ord($a[$i]) ^ \ord($b[$i]); } + return $result == 0; } /** @@ -228,9 +225,8 @@ public static function objectsToIds($h) $results[$k] = static::objectsToIds($v); } return $results; - } else { - return $h; } + return $h; } /** From 6e4243167db938d61de88bc014633abfe0a9d7fe Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:48:58 -0800 Subject: [PATCH 63/97] Use no_useless_return rule --- .php_cs.dist | 1 + lib/StripeObject.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index eb7a0fbe3..8771c8fcc 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -78,5 +78,6 @@ return PhpCsFixer\Config::create() 'no_unset_cast' => true, 'no_unused_imports' => true, 'no_useless_else' => true, + 'no_useless_return' => true, ]) ; diff --git a/lib/StripeObject.php b/lib/StripeObject.php index ae69d1bc5..f8128384f 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -369,11 +369,12 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = return $value; } throw new Exception\InvalidArgumentException( - "Cannot save property `${key}` containing an API resource of type " . + "Cannot save property `${key}` containing an API resource of type " . \get_class($value) . ". It doesn't appear to be persisted and is " . "not marked as `saveWithParent`." - ); - } elseif (\is_array($value)) { + ); + } + if (\is_array($value)) { if (Util\Util::isList($value)) { // Sequential array, i.e. a list $update = []; From aec7b9839d1eec6b79e3a5d1018e017fc4a541e7 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:49:22 -0800 Subject: [PATCH 64/97] Use no_whitespace_before_comma_in_array rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 8771c8fcc..9a74e9d0f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -79,5 +79,6 @@ return PhpCsFixer\Config::create() 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, + 'no_whitespace_before_comma_in_array' => true, ]) ; From a5eac7196af8f69a11cd4923479fff191673a193 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:49:42 -0800 Subject: [PATCH 65/97] Use no_whitespace_in_blank_line rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 9a74e9d0f..1ee2ecb5c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -80,5 +80,6 @@ return PhpCsFixer\Config::create() 'no_useless_else' => true, 'no_useless_return' => true, 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, ]) ; From c1847f85dd5ee7493bcfc7d60eb9b129d4dc0fc0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:50:38 -0800 Subject: [PATCH 66/97] Use non_printable_character rule --- .php_cs.dist | 1 + build.php | 2 +- lib/Account.php | 2 +- lib/ApiResponse.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 1ee2ecb5c..ed6ad7671 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -81,5 +81,6 @@ return PhpCsFixer\Config::create() 'no_useless_return' => true, 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, + 'non_printable_character' => true, ]) ; diff --git a/build.php b/build.php index 59897302b..aa3e1dbf0 100755 --- a/build.php +++ b/build.php @@ -9,7 +9,7 @@ // Modify composer to not autoload Stripe $composer = \json_decode(\file_get_contents('composer.json'), true); unset($composer['autoload'], $composer['autoload-dev']); - + \file_put_contents('composer.json', \json_encode($composer, \JSON_PRETTY_PRINT)); } diff --git a/lib/Account.php b/lib/Account.php index 24e937f5d..a125f5670 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -193,7 +193,7 @@ public function reject($params = null, $opts = null) $this->refreshFrom($response, $opts); return $this; } - + /* * Capabilities methods * We can not add the capabilities() method today as the Account object already has a diff --git a/lib/ApiResponse.php b/lib/ApiResponse.php index dc3eef137..0f14c41a1 100644 --- a/lib/ApiResponse.php +++ b/lib/ApiResponse.php @@ -15,7 +15,7 @@ class ApiResponse * @var array|CaseInsensitiveArray|null */ public $headers; - + /** * @var string */ From f6fcfd8cfc7784b6639e7423dd63da64de5a4189 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:50:56 -0800 Subject: [PATCH 67/97] Use normalize_index_brace rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index ed6ad7671..ca12e9ef9 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -82,5 +82,6 @@ return PhpCsFixer\Config::create() 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, 'non_printable_character' => true, + 'normalize_index_brace' => true, ]) ; From 8d5ac9929b027aae42c6980d15eff51cbe5c2e57 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:51:15 -0800 Subject: [PATCH 68/97] Use object_operator_without_whitespace rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index ca12e9ef9..eaa669831 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -83,5 +83,6 @@ return PhpCsFixer\Config::create() 'no_whitespace_in_blank_line' => true, 'non_printable_character' => true, 'normalize_index_brace' => true, + 'object_operator_without_whitespace' => true, ]) ; From 9a6c3841d48bd6ae8181881186862a3055a38d64 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:52:35 -0800 Subject: [PATCH 69/97] Use php_unit_construct rule --- .php_cs.dist | 1 + tests/Stripe/Util/RequestOptionsTest.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index eaa669831..7c245c03c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -84,5 +84,6 @@ return PhpCsFixer\Config::create() 'non_printable_character' => true, 'normalize_index_brace' => true, 'object_operator_without_whitespace' => true, + 'php_unit_construct' => true, ]) ; diff --git a/tests/Stripe/Util/RequestOptionsTest.php b/tests/Stripe/Util/RequestOptionsTest.php index 7b50408e6..57dfa36da 100644 --- a/tests/Stripe/Util/RequestOptionsTest.php +++ b/tests/Stripe/Util/RequestOptionsTest.php @@ -14,14 +14,14 @@ public function testStringAPIKey() public function testNull() { $opts = RequestOptions::parse(null); - $this->assertSame(null, $opts->apiKey); + $this->assertNull($opts->apiKey); $this->assertSame([], $opts->headers); } public function testEmptyArray() { $opts = RequestOptions::parse([]); - $this->assertSame(null, $opts->apiKey); + $this->assertNull($opts->apiKey); $this->assertSame([], $opts->headers); } @@ -43,7 +43,7 @@ public function testIdempotentKeyArray() 'idempotency_key' => 'foo', ] ); - $this->assertSame(null, $opts->apiKey); + $this->assertNull($opts->apiKey); $this->assertSame(['Idempotency-Key' => 'foo'], $opts->headers); } From c2589ad4bb797ca0f31f10b8d69f3abb4ecdd5fa Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:52:56 -0800 Subject: [PATCH 70/97] Use php_unit_fqcn_annotation rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 7c245c03c..e548ca1b9 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -85,5 +85,6 @@ return PhpCsFixer\Config::create() 'normalize_index_brace' => true, 'object_operator_without_whitespace' => true, 'php_unit_construct' => true, + 'php_unit_fqcn_annotation' => true, ]) ; From 26d46f050cae1624365625a03f0d442ce001fcc5 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:55:02 -0800 Subject: [PATCH 71/97] Use php_unit_method_casing rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index e548ca1b9..4c30720b2 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -86,5 +86,6 @@ return PhpCsFixer\Config::create() 'object_operator_without_whitespace' => true, 'php_unit_construct' => true, 'php_unit_fqcn_annotation' => true, + 'php_unit_method_casing' => true, ]) ; From a894e11627f08c37ee4a86600e21a34f641e784e Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:55:36 -0800 Subject: [PATCH 72/97] Use php_unit_mock_short_will_return rule --- .php_cs.dist | 1 + tests/TestCase.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 4c30720b2..2eeac2343 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -87,5 +87,6 @@ return PhpCsFixer\Config::create() 'php_unit_construct' => true, 'php_unit_fqcn_annotation' => true, 'php_unit_method_casing' => true, + 'php_unit_mock_short_will_return' => true, ]) ; diff --git a/tests/TestCase.php b/tests/TestCase.php index 4428c635c..ae16f342c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -82,13 +82,13 @@ protected function expectsRequest( $base = null ) { $this->prepareRequestMock($method, $path, $params, $headers, $hasFile, $base) - ->will($this->returnCallback( + ->willReturnCallback( function ($method, $absUrl, $headers, $params, $hasFile) { $curlClient = HttpClient\CurlClient::instance(); ApiRequestor::setHttpClient($curlClient); return $curlClient->request($method, $absUrl, $headers, $params, $hasFile); } - )); + ); } /** From 4b6b46faeae2cf52b8f48c64c6ef11d051e0ba7d Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:55:56 -0800 Subject: [PATCH 73/97] Use php_unit_ordered_covers rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 2eeac2343..4487ed2a8 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -88,5 +88,6 @@ return PhpCsFixer\Config::create() 'php_unit_fqcn_annotation' => true, 'php_unit_method_casing' => true, 'php_unit_mock_short_will_return' => true, + 'php_unit_ordered_covers' => true, ]) ; From aab88170416628da178f39e4781f21614846a7db Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:56:16 -0800 Subject: [PATCH 74/97] Use php_unit_set_up_tear_down_visibility rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 4487ed2a8..fd3a647e6 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -89,5 +89,6 @@ return PhpCsFixer\Config::create() 'php_unit_method_casing' => true, 'php_unit_mock_short_will_return' => true, 'php_unit_ordered_covers' => true, + 'php_unit_set_up_tear_down_visibility' => true, ]) ; From 5f37f3c6c2218366b7bfec7f171412bce934a6e8 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:57:11 -0800 Subject: [PATCH 75/97] Use php_unit_test_annotation rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index fd3a647e6..5bf02b91c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -90,5 +90,6 @@ return PhpCsFixer\Config::create() 'php_unit_mock_short_will_return' => true, 'php_unit_ordered_covers' => true, 'php_unit_set_up_tear_down_visibility' => true, + 'php_unit_test_annotation' => true, ]) ; From 3d5aac3dfa7dc4df7babdaa14c2a910b95612527 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:57:41 -0800 Subject: [PATCH 76/97] Use php_unit_test_case_static_method_calls rule --- .php_cs.dist | 1 + tests/Stripe/AccountLinkTest.php | 2 +- tests/Stripe/AccountTest.php | 78 ++++---- tests/Stripe/AlipayAccountTest.php | 6 +- tests/Stripe/ApiRequestorTest.php | 174 +++++++++--------- tests/Stripe/ApplePayDomainTest.php | 10 +- tests/Stripe/ApplicationFeeRefundTest.php | 2 +- tests/Stripe/ApplicationFeeTest.php | 16 +- tests/Stripe/BalanceTest.php | 2 +- tests/Stripe/BalanceTransactionTest.php | 6 +- tests/Stripe/BankAccountTest.php | 10 +- tests/Stripe/BitcoinReceiverTest.php | 10 +- tests/Stripe/CapabilityTest.php | 4 +- tests/Stripe/CardTest.php | 10 +- tests/Stripe/ChargeTest.php | 16 +- tests/Stripe/Checkout/SessionTest.php | 4 +- tests/Stripe/CollectionTest.php | 24 +-- tests/Stripe/CountrySpecTest.php | 6 +- tests/Stripe/CouponTest.php | 14 +- tests/Stripe/CreditNoteTest.php | 20 +- .../Stripe/CustomerBalanceTransactionTest.php | 2 +- tests/Stripe/CustomerTest.php | 28 +-- tests/Stripe/DisputeTest.php | 14 +- tests/Stripe/EphemeralKeyTest.php | 4 +- tests/Stripe/ErrorObjectTest.php | 22 +-- tests/Stripe/EventTest.php | 6 +- .../Exception/ApiErrorExceptionTest.php | 18 +- .../OAuth/OAuthErrorExceptionTest.php | 20 +- .../SignatureVerificationExceptionTest.php | 6 +- tests/Stripe/ExchangeRateTest.php | 6 +- tests/Stripe/FileCreationTest.php | 4 +- tests/Stripe/FileLinkTest.php | 12 +- tests/Stripe/FileTest.php | 10 +- tests/Stripe/HttpClient/CurlClientTest.php | 84 ++++----- tests/Stripe/InvoiceItemTest.php | 14 +- tests/Stripe/InvoiceTest.php | 38 ++-- tests/Stripe/Issuing/AuthorizationTest.php | 14 +- tests/Stripe/Issuing/CardTest.php | 12 +- tests/Stripe/Issuing/CardholderTest.php | 12 +- tests/Stripe/Issuing/DisputeTest.php | 12 +- tests/Stripe/Issuing/TransactionTest.php | 10 +- tests/Stripe/MandateTest.php | 2 +- tests/Stripe/OAuthErrorObjectTest.php | 4 +- tests/Stripe/OAuthTest.php | 20 +- tests/Stripe/OrderReturnTest.php | 6 +- tests/Stripe/OrderTest.php | 16 +- tests/Stripe/PaymentIntentTest.php | 18 +- tests/Stripe/PaymentMethodTest.php | 20 +- tests/Stripe/PayoutTest.php | 14 +- tests/Stripe/PersonTest.php | 6 +- tests/Stripe/PlanTest.php | 14 +- tests/Stripe/ProductTest.php | 14 +- tests/Stripe/Radar/EarlyFraudWarningTest.php | 6 +- tests/Stripe/Radar/ValueListItemTest.php | 10 +- tests/Stripe/Radar/ValueListTest.php | 14 +- tests/Stripe/RecipientTest.php | 14 +- tests/Stripe/RefundTest.php | 12 +- tests/Stripe/Reporting/ReportRunTest.php | 8 +- tests/Stripe/Reporting/ReportTypeTest.php | 6 +- tests/Stripe/ReviewTest.php | 8 +- tests/Stripe/SKUTest.php | 14 +- tests/Stripe/SetupIntentTest.php | 16 +- tests/Stripe/Sigma/ScheduledQueryRunTest.php | 6 +- tests/Stripe/SourceTest.php | 24 +-- tests/Stripe/StripeObjectTest.php | 138 +++++++------- tests/Stripe/StripeTelemetryTest.php | 36 ++-- tests/Stripe/StripeTest.php | 2 +- tests/Stripe/SubscriptionItemTest.php | 22 +-- tests/Stripe/SubscriptionScheduleTest.php | 16 +- tests/Stripe/SubscriptionTest.php | 18 +- tests/Stripe/TaxIdTest.php | 4 +- tests/Stripe/TaxRateTest.php | 12 +- tests/Stripe/Terminal/ConnectionTokenTest.php | 2 +- tests/Stripe/Terminal/LocationTest.php | 14 +- tests/Stripe/Terminal/ReaderTest.php | 14 +- tests/Stripe/ThreeDSecureTest.php | 4 +- tests/Stripe/TokenTest.php | 4 +- tests/Stripe/TopupTest.php | 14 +- tests/Stripe/TransferReversalTest.php | 2 +- tests/Stripe/TransferTest.php | 26 +-- .../Stripe/Util/CaseInsensitiveArrayTest.php | 24 +-- tests/Stripe/Util/DefaultLoggerTest.php | 2 +- tests/Stripe/Util/RequestOptionsTest.php | 32 ++-- tests/Stripe/Util/UtilTest.php | 28 +-- tests/Stripe/WebhookEndpointTest.php | 14 +- tests/Stripe/WebhookTest.php | 8 +- tests/TestCase.php | 12 +- 87 files changed, 742 insertions(+), 741 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 5bf02b91c..42b0a3e4b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -91,5 +91,6 @@ return PhpCsFixer\Config::create() 'php_unit_ordered_covers' => true, 'php_unit_set_up_tear_down_visibility' => true, 'php_unit_test_annotation' => true, + 'php_unit_test_case_static_method_calls' => true, ]) ; diff --git a/tests/Stripe/AccountLinkTest.php b/tests/Stripe/AccountLinkTest.php index 0ecb2e239..a981a9053 100644 --- a/tests/Stripe/AccountLinkTest.php +++ b/tests/Stripe/AccountLinkTest.php @@ -16,6 +16,6 @@ public function testIsCreatable() "success_url" => "https://stripe.com/success", "type" => "custom_account_verification", ]); - $this->assertInstanceOf(\Stripe\AccountLink::class, $resource); + static::assertInstanceOf(\Stripe\AccountLink::class, $resource); } } diff --git a/tests/Stripe/AccountTest.php b/tests/Stripe/AccountTest.php index 7e36a43b1..233494e74 100644 --- a/tests/Stripe/AccountTest.php +++ b/tests/Stripe/AccountTest.php @@ -16,8 +16,8 @@ public function testIsListable() '/v1/accounts' ); $resources = Account::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Account::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Account::class, $resources->data[0]); } public function testIsRetrievable() @@ -27,7 +27,7 @@ public function testIsRetrievable() '/v1/accounts/' . self::TEST_RESOURCE_ID ); $resource = Account::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Account::class, $resource); + static::assertInstanceOf(\Stripe\Account::class, $resource); } public function testIsRetrievableWithoutId() @@ -37,7 +37,7 @@ public function testIsRetrievableWithoutId() '/v1/account' ); $resource = Account::retrieve(); - $this->assertInstanceOf(\Stripe\Account::class, $resource); + static::assertInstanceOf(\Stripe\Account::class, $resource); } public function testIsCreatable() @@ -47,7 +47,7 @@ public function testIsCreatable() '/v1/accounts' ); $resource = Account::create(["type" => "custom"]); - $this->assertInstanceOf(\Stripe\Account::class, $resource); + static::assertInstanceOf(\Stripe\Account::class, $resource); } public function testIsSaveable() @@ -59,7 +59,7 @@ public function testIsSaveable() '/v1/accounts/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Account::class, $resource); + static::assertInstanceOf(\Stripe\Account::class, $resource); } public function testIsUpdatable() @@ -71,7 +71,7 @@ public function testIsUpdatable() $resource = Account::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Account::class, $resource); + static::assertInstanceOf(\Stripe\Account::class, $resource); } public function testIsDeletable() @@ -82,7 +82,7 @@ public function testIsDeletable() '/v1/accounts/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Account::class, $resource); + static::assertInstanceOf(\Stripe\Account::class, $resource); } public function testIsRejectable() @@ -93,8 +93,8 @@ public function testIsRejectable() '/v1/accounts/' . $account->id . '/reject' ); $resource = $account->reject(["reason" => "fraud"]); - $this->assertInstanceOf(\Stripe\Account::class, $resource); - $this->assertSame($resource, $account); + static::assertInstanceOf(\Stripe\Account::class, $resource); + static::assertSame($resource, $account); } public function testIsDeauthorizable() @@ -126,8 +126,8 @@ public function testPersons() '/v1/accounts/' . $account->id . '/persons' ); $persons = $account->persons(); - $this->assertInternalType('array', $persons->data); - $this->assertInstanceOf(\Stripe\Person::class, $persons->data[0]); + static::assertInternalType('array', $persons->data); + static::assertInstanceOf(\Stripe\Person::class, $persons->data[0]); } public function testCanRetrieveCapability() @@ -137,7 +137,7 @@ public function testCanRetrieveCapability() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/capabilities/' . self::TEST_CAPABILITY_ID ); $resource = Account::retrieveCapability(self::TEST_RESOURCE_ID, self::TEST_CAPABILITY_ID); - $this->assertInstanceOf(\Stripe\Capability::class, $resource); + static::assertInstanceOf(\Stripe\Capability::class, $resource); } public function testCanUpdateCapability() @@ -149,7 +149,7 @@ public function testCanUpdateCapability() $resource = Account::updateCapability(self::TEST_RESOURCE_ID, self::TEST_CAPABILITY_ID, [ "requested" => true, ]); - $this->assertInstanceOf(\Stripe\Capability::class, $resource); + static::assertInstanceOf(\Stripe\Capability::class, $resource); } public function testCanListCapabilities() @@ -159,7 +159,7 @@ public function testCanListCapabilities() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/capabilities' ); $resources = Account::allCapabilities(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } public function testCanCreateExternalAccount() @@ -171,7 +171,7 @@ public function testCanCreateExternalAccount() $resource = Account::createExternalAccount(self::TEST_RESOURCE_ID, [ "external_account" => "btok_123", ]); - $this->assertInstanceOf(\Stripe\BankAccount::class, $resource); + static::assertInstanceOf(\Stripe\BankAccount::class, $resource); } public function testCanRetrieveExternalAccount() @@ -181,7 +181,7 @@ public function testCanRetrieveExternalAccount() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/external_accounts/' . self::TEST_EXTERNALACCOUNT_ID ); $resource = Account::retrieveExternalAccount(self::TEST_RESOURCE_ID, self::TEST_EXTERNALACCOUNT_ID); - $this->assertInstanceOf(\Stripe\BankAccount::class, $resource); + static::assertInstanceOf(\Stripe\BankAccount::class, $resource); } public function testCanUpdateExternalAccount() @@ -193,7 +193,7 @@ public function testCanUpdateExternalAccount() $resource = Account::updateExternalAccount(self::TEST_RESOURCE_ID, self::TEST_EXTERNALACCOUNT_ID, [ "name" => "name", ]); - $this->assertInstanceOf(\Stripe\BankAccount::class, $resource); + static::assertInstanceOf(\Stripe\BankAccount::class, $resource); } public function testCanDeleteExternalAccount() @@ -203,7 +203,7 @@ public function testCanDeleteExternalAccount() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/external_accounts/' . self::TEST_EXTERNALACCOUNT_ID ); $resource = Account::deleteExternalAccount(self::TEST_RESOURCE_ID, self::TEST_EXTERNALACCOUNT_ID); - $this->assertTrue($resource->deleted); + static::assertTrue($resource->deleted); } public function testCanListExternalAccounts() @@ -213,7 +213,7 @@ public function testCanListExternalAccounts() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/external_accounts' ); $resources = Account::allExternalAccounts(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } public function testCanCreateLoginLink() @@ -223,7 +223,7 @@ public function testCanCreateLoginLink() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/login_links' ); $resource = Account::createLoginLink(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\LoginLink::class, $resource); + static::assertInstanceOf(\Stripe\LoginLink::class, $resource); } public function testCanCreatePerson() @@ -239,7 +239,7 @@ public function testCanCreatePerson() "year" => 1980 ] ]); - $this->assertInstanceOf(\Stripe\Person::class, $resource); + static::assertInstanceOf(\Stripe\Person::class, $resource); } public function testCanRetrievePerson() @@ -249,7 +249,7 @@ public function testCanRetrievePerson() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/persons/' . self::TEST_PERSON_ID ); $resource = Account::retrievePerson(self::TEST_RESOURCE_ID, self::TEST_PERSON_ID); - $this->assertInstanceOf(\Stripe\Person::class, $resource); + static::assertInstanceOf(\Stripe\Person::class, $resource); } public function testCanUpdatePerson() @@ -261,7 +261,7 @@ public function testCanUpdatePerson() $resource = Account::updatePerson(self::TEST_RESOURCE_ID, self::TEST_PERSON_ID, [ "first_name" => "First name", ]); - $this->assertInstanceOf(\Stripe\Person::class, $resource); + static::assertInstanceOf(\Stripe\Person::class, $resource); } public function testCanDeletePerson() @@ -271,7 +271,7 @@ public function testCanDeletePerson() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/persons/' . self::TEST_PERSON_ID ); $resource = Account::deletePerson(self::TEST_RESOURCE_ID, self::TEST_PERSON_ID); - $this->assertTrue($resource->deleted); + static::assertTrue($resource->deleted); } public function testCanListPersons() @@ -281,7 +281,7 @@ public function testCanListPersons() '/v1/accounts/' . self::TEST_RESOURCE_ID . '/persons' ); $resources = Account::allPersons(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } public function testSerializeNewAdditionalOwners() @@ -303,7 +303,7 @@ public function testSerializeNewAdditionalOwners() ], ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeAddAdditionalOwners() @@ -326,7 +326,7 @@ public function testSerializeAddAdditionalOwners() ], ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializePartiallyChangedAdditionalOwners() @@ -349,7 +349,7 @@ public function testSerializePartiallyChangedAdditionalOwners() ], ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeUnchangedAdditionalOwners() @@ -369,7 +369,7 @@ public function testSerializeUnchangedAdditionalOwners() 'additional_owners' => [], ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeUnsetAdditionalOwners() @@ -392,7 +392,7 @@ public function testSerializeUnsetAdditionalOwners() 'additional_owners' => '', ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeAdditionalOwnersDeletedItem() @@ -423,7 +423,7 @@ public function testSerializeExternalAccountString() $expected = [ 'external_account' => 'btok_123', ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeExternalAccountHash() @@ -448,7 +448,7 @@ public function testSerializeExternalAccountHash() 'currency' => 'usd', ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeBankAccountString() @@ -461,7 +461,7 @@ public function testSerializeBankAccountString() $expected = [ 'bank_account' => 'btok_123', ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeBankAccountHash() @@ -486,7 +486,7 @@ public function testSerializeBankAccountHash() 'currency' => 'usd', ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeNewIndividual() @@ -497,7 +497,7 @@ public function testSerializeNewIndividual() $obj->individual = ['first_name' => 'Jane']; $expected = ['individual' => ['first_name' => 'Jane']]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializePartiallyChangedIndividual() @@ -512,7 +512,7 @@ public function testSerializePartiallyChangedIndividual() $obj->individual = ['first_name' => 'Jane']; $expected = ['individual' => ['first_name' => 'Jane']]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeUnchangedIndividual() @@ -526,7 +526,7 @@ public function testSerializeUnchangedIndividual() ], null); $expected = ['individual' => []]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeUnsetIndividual() @@ -541,6 +541,6 @@ public function testSerializeUnsetIndividual() $obj->individual = null; $expected = ['individual' => '']; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } } diff --git a/tests/Stripe/AlipayAccountTest.php b/tests/Stripe/AlipayAccountTest.php index ab1c0c4cc..a615d2689 100644 --- a/tests/Stripe/AlipayAccountTest.php +++ b/tests/Stripe/AlipayAccountTest.php @@ -27,7 +27,7 @@ public function createFixture($params = []) public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); - $this->assertSame( + static::assertSame( "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertSame(\Stripe\AlipayAccount::class, \get_class($resource)); + static::assertSame(\Stripe\AlipayAccount::class, \get_class($resource)); } public function testIsNotDirectlyUpdatable() @@ -69,6 +69,6 @@ public function testIsDeletable() '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertSame(\Stripe\AlipayAccount::class, \get_class($resource)); + static::assertSame(\Stripe\AlipayAccount::class, \get_class($resource)); } } diff --git a/tests/Stripe/ApiRequestorTest.php b/tests/Stripe/ApiRequestorTest.php index f09498945..ff01038ba 100644 --- a/tests/Stripe/ApiRequestorTest.php +++ b/tests/Stripe/ApiRequestorTest.php @@ -14,26 +14,26 @@ public function testEncodeObjects() $a = ['customer' => new Customer('abcd')]; $enc = $method->invoke(null, $a); - $this->assertSame($enc, ['customer' => 'abcd']); + static::assertSame($enc, ['customer' => 'abcd']); // Preserves UTF-8 $v = ['customer' => "☃"]; $enc = $method->invoke(null, $v); - $this->assertSame($enc, $v); + static::assertSame($enc, $v); // Encodes latin-1 -> UTF-8 $v = ['customer' => "\xe9"]; $enc = $method->invoke(null, $v); - $this->assertSame($enc, ['customer' => "\xc3\xa9"]); + static::assertSame($enc, ['customer' => "\xc3\xa9"]); // Encodes booleans $v = true; $enc = $method->invoke(null, $v); - $this->assertSame('true', $enc); + static::assertSame('true', $enc); $v = false; $enc = $method->invoke(null, $v); - $this->assertSame('false', $enc); + static::assertSame('false', $enc); } public function testHttpClientInjection() @@ -47,7 +47,7 @@ public function testHttpClientInjection() ApiRequestor::setHttpClient($curl); $injectedCurl = $method->invoke(new ApiRequestor()); - $this->assertSame($injectedCurl, $curl); + static::assertSame($injectedCurl, $curl); } public function testDefaultHeaders() @@ -64,19 +64,19 @@ public function testDefaultHeaders() $headers = $method->invoke(null, $apiKey, $clientInfo); $ua = \json_decode($headers['X-Stripe-Client-User-Agent']); - $this->assertSame($ua->application->name, 'MyTestApp'); - $this->assertSame($ua->application->version, '1.2.34'); - $this->assertSame($ua->application->url, 'https://mytestapp.example'); - $this->assertSame($ua->application->partner_id, 'partner_1234'); + static::assertSame($ua->application->name, 'MyTestApp'); + static::assertSame($ua->application->version, '1.2.34'); + static::assertSame($ua->application->url, 'https://mytestapp.example'); + static::assertSame($ua->application->partner_id, 'partner_1234'); - $this->assertSame($ua->httplib, 'testlib 0.1.2'); + static::assertSame($ua->httplib, 'testlib 0.1.2'); - $this->assertSame( + static::assertSame( $headers['User-Agent'], 'Stripe/v1 PhpBindings/' . Stripe::VERSION . ' MyTestApp/1.2.34 (https://mytestapp.example)' ); - $this->assertSame($headers['Authorization'], 'Bearer ' . $apiKey); + static::assertSame($headers['Authorization'], 'Bearer ' . $apiKey); } public function testRaisesAuthenticationErrorWhenNoApiKey() @@ -108,14 +108,14 @@ public function testRaisesInvalidRequestErrorOn400() try { Charge::create(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\InvalidRequestException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame('Missing id', $e->getMessage()); - $this->assertSame('id', $e->getStripeParam()); + static::assertSame(400, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame('Missing id', $e->getMessage()); + static::assertSame('id', $e->getStripeParam()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -138,13 +138,13 @@ public function testRaisesIdempotencyErrorOn400AndTypeIdempotencyError() try { Charge::create(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\IdempotencyException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame("Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'abc' if you meant to execute a different request.", $e->getMessage()); + static::assertSame(400, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame("Keys for idempotent requests can only be used with the same parameters they were first used with. Try using a key other than 'abc' if you meant to execute a different request.", $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -167,13 +167,13 @@ public function testRaisesAuthenticationErrorOn401() try { Charge::create(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\AuthenticationException $e) { - $this->assertSame(401, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame('You did not provide an API key.', $e->getMessage()); + static::assertSame(401, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame('You did not provide an API key.', $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -200,16 +200,16 @@ public function testRaisesCardErrorOn402() try { Charge::create(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\CardException $e) { - $this->assertSame(402, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame('Your card was declined.', $e->getMessage()); - $this->assertSame('card_declined', $e->getStripeCode()); - $this->assertSame('generic_decline', $e->getDeclineCode()); - $this->assertSame('exp_month', $e->getStripeParam()); + static::assertSame(402, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame('Your card was declined.', $e->getMessage()); + static::assertSame('card_declined', $e->getStripeCode()); + static::assertSame('generic_decline', $e->getDeclineCode()); + static::assertSame('exp_month', $e->getStripeParam()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -232,13 +232,13 @@ public function testRaisesPermissionErrorOn403() try { Account::retrieve('foo'); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\PermissionException $e) { - $this->assertSame(403, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame("The provided key 'sk_test_********************1234' does not have access to account 'foo' (or that account does not exist). Application access may have been revoked.", $e->getMessage()); + static::assertSame(403, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame("The provided key 'sk_test_********************1234' does not have access to account 'foo' (or that account does not exist). Application access may have been revoked.", $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -262,14 +262,14 @@ public function testRaisesInvalidRequestErrorOn404() try { Charge::retrieve('foo'); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\InvalidRequestException $e) { - $this->assertSame(404, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame('No such charge: foo', $e->getMessage()); - $this->assertSame('id', $e->getStripeParam()); + static::assertSame(404, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame('No such charge: foo', $e->getMessage()); + static::assertSame('id', $e->getStripeParam()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -291,14 +291,14 @@ public function testRaisesRateLimitErrorOn429() try { Charge::create(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\RateLimitException $e) { - $this->assertSame(429, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame('Too many requests', $e->getMessage()); + static::assertSame(429, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame('Too many requests', $e->getMessage()); } catch (\Exception $e) { \var_dump($e); - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -321,13 +321,13 @@ public function testRaisesRateLimitErrorOn400AndCodeRateLimit() try { Charge::create(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\RateLimitException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertInternalType('array', $e->getJsonBody()); - $this->assertSame('Too many requests', $e->getMessage()); + static::assertSame(400, $e->getHttpStatus()); + static::assertInternalType('array', $e->getJsonBody()); + static::assertSame('Too many requests', $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -349,13 +349,13 @@ public function testRaisesOAuthInvalidRequestError() try { OAuth::token(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\OAuth\InvalidRequestException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertSame('invalid_request', $e->getStripeCode()); - $this->assertSame('No grant type specified', $e->getMessage()); + static::assertSame(400, $e->getHttpStatus()); + static::assertSame('invalid_request', $e->getStripeCode()); + static::assertSame('No grant type specified', $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -377,13 +377,13 @@ public function testRaisesOAuthInvalidClientError() try { OAuth::token(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\OAuth\InvalidClientException $e) { - $this->assertSame(401, $e->getHttpStatus()); - $this->assertSame('invalid_client', $e->getStripeCode()); - $this->assertSame('No authentication was provided. Send your secret API key using the Authorization header, or as a client_secret POST parameter.', $e->getMessage()); + static::assertSame(401, $e->getHttpStatus()); + static::assertSame('invalid_client', $e->getStripeCode()); + static::assertSame('No authentication was provided. Send your secret API key using the Authorization header, or as a client_secret POST parameter.', $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -405,13 +405,13 @@ public function testRaisesOAuthInvalidGrantError() try { OAuth::token(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\OAuth\InvalidGrantException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertSame('invalid_grant', $e->getStripeCode()); - $this->assertSame('This authorization code has already been used. All tokens issued with this code have been revoked.', $e->getMessage()); + static::assertSame(400, $e->getHttpStatus()); + static::assertSame('invalid_grant', $e->getStripeCode()); + static::assertSame('This authorization code has already been used. All tokens issued with this code have been revoked.', $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -433,13 +433,13 @@ public function testRaisesOAuthInvalidScopeError() try { OAuth::token(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\OAuth\InvalidScopeException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertSame('invalid_scope', $e->getStripeCode()); - $this->assertSame('Invalid scope provided: invalid_scope.', $e->getMessage()); + static::assertSame(400, $e->getHttpStatus()); + static::assertSame('invalid_scope', $e->getStripeCode()); + static::assertSame('Invalid scope provided: invalid_scope.', $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -460,12 +460,12 @@ public function testRaisesOAuthUnsupportedGrantTypeError() try { OAuth::token(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\OAuth\UnsupportedGrantTypeException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertSame('unsupported_grant_type', $e->getStripeCode()); + static::assertSame(400, $e->getHttpStatus()); + static::assertSame('unsupported_grant_type', $e->getStripeCode()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -487,13 +487,13 @@ public function testRaisesOAuthUnsupportedResponseTypeError() try { OAuth::token(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (Exception\OAuth\UnsupportedResponseTypeException $e) { - $this->assertSame(400, $e->getHttpStatus()); - $this->assertSame('unsupported_response_type', $e->getStripeCode()); - $this->assertSame("Only 'code' response_type is supported, but 'unsupported_response_type' was provided", $e->getMessage()); + static::assertSame(400, $e->getHttpStatus()); + static::assertSame('unsupported_response_type', $e->getStripeCode()); + static::assertSame("Only 'code' response_type is supported, but 'unsupported_response_type' was provided", $e->getMessage()); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } diff --git a/tests/Stripe/ApplePayDomainTest.php b/tests/Stripe/ApplePayDomainTest.php index 2918a91b8..9e5a23fb4 100644 --- a/tests/Stripe/ApplePayDomainTest.php +++ b/tests/Stripe/ApplePayDomainTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/apple_pay/domains' ); $resources = ApplePayDomain::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\ApplePayDomain::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\ApplePayDomain::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/apple_pay/domains/' . self::TEST_RESOURCE_ID ); $resource = ApplePayDomain::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\ApplePayDomain::class, $resource); + static::assertInstanceOf(\Stripe\ApplePayDomain::class, $resource); } public function testIsCreatable() @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = ApplePayDomain::create([ "domain_name" => "domain", ]); - $this->assertInstanceOf(\Stripe\ApplePayDomain::class, $resource); + static::assertInstanceOf(\Stripe\ApplePayDomain::class, $resource); } public function testIsDeletable() @@ -47,6 +47,6 @@ public function testIsDeletable() '/v1/apple_pay/domains/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\ApplePayDomain::class, $resource); + static::assertInstanceOf(\Stripe\ApplePayDomain::class, $resource); } } diff --git a/tests/Stripe/ApplicationFeeRefundTest.php b/tests/Stripe/ApplicationFeeRefundTest.php index fda6feea1..1f51f6e7a 100644 --- a/tests/Stripe/ApplicationFeeRefundTest.php +++ b/tests/Stripe/ApplicationFeeRefundTest.php @@ -16,6 +16,6 @@ public function testIsSaveable() '/v1/application_fees/' . $resource->fee . '/refunds/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); + static::assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); } } diff --git a/tests/Stripe/ApplicationFeeTest.php b/tests/Stripe/ApplicationFeeTest.php index eee486ace..00dd68f2c 100644 --- a/tests/Stripe/ApplicationFeeTest.php +++ b/tests/Stripe/ApplicationFeeTest.php @@ -14,8 +14,8 @@ public function testIsListable() '/v1/application_fees' ); $resources = ApplicationFee::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\ApplicationFee::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\ApplicationFee::class, $resources->data[0]); } public function testIsRetrievable() @@ -25,7 +25,7 @@ public function testIsRetrievable() '/v1/application_fees/' . self::TEST_RESOURCE_ID ); $resource = ApplicationFee::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\ApplicationFee::class, $resource); + static::assertInstanceOf(\Stripe\ApplicationFee::class, $resource); } public function testCanCreateRefund() @@ -35,7 +35,7 @@ public function testCanCreateRefund() '/v1/application_fees/' . self::TEST_RESOURCE_ID . '/refunds' ); $resource = ApplicationFee::createRefund(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); + static::assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); } public function testCanRetrieveRefund() @@ -45,7 +45,7 @@ public function testCanRetrieveRefund() '/v1/application_fees/' . self::TEST_RESOURCE_ID . '/refunds/' . self::TEST_FEEREFUND_ID ); $resource = ApplicationFee::retrieveRefund(self::TEST_RESOURCE_ID, self::TEST_FEEREFUND_ID); - $this->assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); + static::assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); } public function testCanUpdateRefund() @@ -55,7 +55,7 @@ public function testCanUpdateRefund() '/v1/application_fees/' . self::TEST_RESOURCE_ID . '/refunds/' . self::TEST_FEEREFUND_ID ); $resource = ApplicationFee::updateRefund(self::TEST_RESOURCE_ID, self::TEST_FEEREFUND_ID); - $this->assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); + static::assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resource); } public function testCanListRefunds() @@ -65,7 +65,7 @@ public function testCanListRefunds() '/v1/application_fees/' . self::TEST_RESOURCE_ID . '/refunds' ); $resources = ApplicationFee::allRefunds(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\ApplicationFeeRefund::class, $resources->data[0]); } } diff --git a/tests/Stripe/BalanceTest.php b/tests/Stripe/BalanceTest.php index dbdcd8e68..ada239bb4 100644 --- a/tests/Stripe/BalanceTest.php +++ b/tests/Stripe/BalanceTest.php @@ -11,6 +11,6 @@ public function testIsRetrievable() '/v1/balance' ); $resource = Balance::retrieve(); - $this->assertInstanceOf(\Stripe\Balance::class, $resource); + static::assertInstanceOf(\Stripe\Balance::class, $resource); } } diff --git a/tests/Stripe/BalanceTransactionTest.php b/tests/Stripe/BalanceTransactionTest.php index 22eecec84..79c9b3ace 100644 --- a/tests/Stripe/BalanceTransactionTest.php +++ b/tests/Stripe/BalanceTransactionTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/balance_transactions' ); $resources = BalanceTransaction::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\BalanceTransaction::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\BalanceTransaction::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,6 +24,6 @@ public function testIsRetrievable() '/v1/balance_transactions/' . self::TEST_RESOURCE_ID ); $resource = BalanceTransaction::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\BalanceTransaction::class, $resource); + static::assertInstanceOf(\Stripe\BalanceTransaction::class, $resource); } } diff --git a/tests/Stripe/BankAccountTest.php b/tests/Stripe/BankAccountTest.php index 0a3fa1335..2649d4a46 100644 --- a/tests/Stripe/BankAccountTest.php +++ b/tests/Stripe/BankAccountTest.php @@ -27,7 +27,7 @@ public function createFixture($params = []) public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); - $this->assertSame( + static::assertSame( "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -36,7 +36,7 @@ public function testHasCorrectUrlForCustomer() public function testHasCorrectUrlForAccount() { $resource = $this->createFixture(['account' => 'acct_123']); - $this->assertSame( + static::assertSame( "/v1/accounts/acct_123/external_accounts/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -58,7 +58,7 @@ public function testIsSaveable() '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertSame(\Stripe\BankAccount::class, \get_class($resource)); + static::assertSame(\Stripe\BankAccount::class, \get_class($resource)); } public function testIsNotDirectlyUpdatable() @@ -78,7 +78,7 @@ public function testIsDeletable() '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertSame(\Stripe\BankAccount::class, \get_class($resource)); + static::assertSame(\Stripe\BankAccount::class, \get_class($resource)); } public function testIsVerifiable() @@ -92,6 +92,6 @@ public function testIsVerifiable() ] ); $resource->verify(["amounts" => [1, 2]]); - $this->assertInstanceOf(\Stripe\BankAccount::class, $resource); + static::assertInstanceOf(\Stripe\BankAccount::class, $resource); } } diff --git a/tests/Stripe/BitcoinReceiverTest.php b/tests/Stripe/BitcoinReceiverTest.php index 1d106005a..9da178fc9 100644 --- a/tests/Stripe/BitcoinReceiverTest.php +++ b/tests/Stripe/BitcoinReceiverTest.php @@ -24,7 +24,7 @@ public function createFixture($params = []) public function testHasCorrectStandaloneUrl() { $resource = $this->createFixture(); - $this->assertSame( + static::assertSame( "/v1/bitcoin/receivers/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -33,7 +33,7 @@ public function testHasCorrectStandaloneUrl() public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); - $this->assertSame( + static::assertSame( "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -46,8 +46,8 @@ public function testIsListable() '/v1/bitcoin/receivers' ); $resources = BitcoinReceiver::all(); - $this->assertInternalType('array', $resources->data); - $this->assertSame(\Stripe\BitcoinReceiver::class, \get_class($resources->data[0])); + static::assertInternalType('array', $resources->data); + static::assertSame(\Stripe\BitcoinReceiver::class, \get_class($resources->data[0])); } public function testIsRetrievable() @@ -57,6 +57,6 @@ public function testIsRetrievable() '/v1/bitcoin/receivers/' . self::TEST_RESOURCE_ID ); $resource = BitcoinReceiver::retrieve(self::TEST_RESOURCE_ID); - $this->assertSame(\Stripe\BitcoinReceiver::class, \get_class($resource)); + static::assertSame(\Stripe\BitcoinReceiver::class, \get_class($resource)); } } diff --git a/tests/Stripe/CapabilityTest.php b/tests/Stripe/CapabilityTest.php index 56e117281..5c4de3e47 100644 --- a/tests/Stripe/CapabilityTest.php +++ b/tests/Stripe/CapabilityTest.php @@ -10,7 +10,7 @@ class CapabilityTest extends TestCase public function testHasCorrectUrl() { $resource = \Stripe\Account::retrieveCapability(self::TEST_ACCOUNT_ID, self::TEST_RESOURCE_ID); - $this->assertSame( + static::assertSame( "/v1/accounts/" . self::TEST_ACCOUNT_ID . "/capabilities/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -32,7 +32,7 @@ public function testIsSaveable() '/v1/accounts/' . self::TEST_ACCOUNT_ID . '/capabilities/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Capability::class, $resource); + static::assertInstanceOf(\Stripe\Capability::class, $resource); } public function testIsNotDirectlyUpdatable() diff --git a/tests/Stripe/CardTest.php b/tests/Stripe/CardTest.php index 43d5a7813..dffe8ec65 100644 --- a/tests/Stripe/CardTest.php +++ b/tests/Stripe/CardTest.php @@ -27,7 +27,7 @@ public function createFixture($params = []) public function testHasCorrectUrlForCustomer() { $resource = $this->createFixture(['customer' => 'cus_123']); - $this->assertSame( + static::assertSame( "/v1/customers/cus_123/sources/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -36,7 +36,7 @@ public function testHasCorrectUrlForCustomer() public function testHasCorrectUrlForAccount() { $resource = $this->createFixture(['account' => 'acct_123']); - $this->assertSame( + static::assertSame( "/v1/accounts/acct_123/external_accounts/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -45,7 +45,7 @@ public function testHasCorrectUrlForAccount() public function testHasCorrectUrlForRecipient() { $resource = $this->createFixture(['recipient' => 'rp_123']); - $this->assertSame( + static::assertSame( "/v1/recipients/rp_123/cards/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -67,7 +67,7 @@ public function testIsSaveable() '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertSame(\Stripe\Card::class, \get_class($resource)); + static::assertSame(\Stripe\Card::class, \get_class($resource)); } public function testIsNotDirectlyUpdatable() @@ -87,6 +87,6 @@ public function testIsDeletable() '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertSame(\Stripe\Card::class, \get_class($resource)); + static::assertSame(\Stripe\Card::class, \get_class($resource)); } } diff --git a/tests/Stripe/ChargeTest.php b/tests/Stripe/ChargeTest.php index 93a120a0f..ff5dcd9d5 100644 --- a/tests/Stripe/ChargeTest.php +++ b/tests/Stripe/ChargeTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/charges' ); $resources = Charge::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Charge::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Charge::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/charges/' . self::TEST_RESOURCE_ID ); $resource = Charge::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); + static::assertInstanceOf(\Stripe\Charge::class, $resource); } public function testIsCreatable() @@ -38,7 +38,7 @@ public function testIsCreatable() "currency" => "usd", "source" => "tok_123" ]); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); + static::assertInstanceOf(\Stripe\Charge::class, $resource); } public function testIsSaveable() @@ -50,7 +50,7 @@ public function testIsSaveable() '/v1/charges/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); + static::assertInstanceOf(\Stripe\Charge::class, $resource); } public function testIsUpdatable() @@ -62,7 +62,7 @@ public function testIsUpdatable() $resource = Charge::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); + static::assertInstanceOf(\Stripe\Charge::class, $resource); } public function testCanCapture() @@ -73,7 +73,7 @@ public function testCanCapture() '/v1/charges/' . $charge->id . '/capture' ); $resource = $charge->capture(); - $this->assertInstanceOf(\Stripe\Charge::class, $resource); - $this->assertSame($resource, $charge); + static::assertInstanceOf(\Stripe\Charge::class, $resource); + static::assertSame($resource, $charge); } } diff --git a/tests/Stripe/Checkout/SessionTest.php b/tests/Stripe/Checkout/SessionTest.php index 81ca4f3b0..404eee9c4 100644 --- a/tests/Stripe/Checkout/SessionTest.php +++ b/tests/Stripe/Checkout/SessionTest.php @@ -33,7 +33,7 @@ public function testIsCreatable() 'payment_method_types' => ['card'], 'success_url' => 'https://stripe.com/success' ]); - $this->assertInstanceOf(\Stripe\Checkout\Session::class, $resource); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $resource); } public function testIsRetrievable() @@ -43,6 +43,6 @@ public function testIsRetrievable() '/v1/checkout/sessions/' . self::TEST_RESOURCE_ID ); $resource = Session::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Checkout\Session::class, $resource); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $resource); } } diff --git a/tests/Stripe/CollectionTest.php b/tests/Stripe/CollectionTest.php index ca315201e..c0b7fb6a0 100644 --- a/tests/Stripe/CollectionTest.php +++ b/tests/Stripe/CollectionTest.php @@ -44,7 +44,7 @@ public function testCanList() ); $resources = $this->fixture->all(); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } public function testCanRetrieve() @@ -96,7 +96,7 @@ public function testCanIterate() \array_push($seen, $item['id']); } - $this->assertSame([1, 2, 3], $seen); + static::assertSame([1, 2, 3], $seen); } public function testCanIterateBackwards() @@ -112,7 +112,7 @@ public function testCanIterateBackwards() \array_push($seen, $item['id']); } - $this->assertSame([3, 2, 1], $seen); + static::assertSame([3, 2, 1], $seen); } public function testSupportsIteratorToArray() @@ -122,7 +122,7 @@ public function testSupportsIteratorToArray() \array_push($seen, $item['id']); } - $this->assertSame([1], $seen); + static::assertSame([1], $seen); } public function testProvidesAutoPagingIterator() @@ -147,7 +147,7 @@ public function testProvidesAutoPagingIterator() \array_push($seen, $item['id']); } - $this->assertSame([1, 2, 3], $seen); + static::assertSame([1, 2, 3], $seen); } public function testAutoPagingIteratorSupportsIteratorToArray() @@ -172,7 +172,7 @@ public function testAutoPagingIteratorSupportsIteratorToArray() \array_push($seen, $item['id']); } - $this->assertSame([1, 2, 3], $seen); + static::assertSame([1, 2, 3], $seen); } public function testProvidesAutoPagingIteratorThatSupportsBackwardsPagination() @@ -204,7 +204,7 @@ public function testProvidesAutoPagingIteratorThatSupportsBackwardsPagination() \array_push($seen, $item['id']); } - $this->assertSame([3, 2, 1], $seen); + static::assertSame([3, 2, 1], $seen); } public function testHeaders() @@ -236,16 +236,16 @@ public function testHeaders() public function testEmptyCollection() { $emptyCollection = Collection::emptyCollection(); - $this->assertEquals([], $emptyCollection->data); + static::assertEquals([], $emptyCollection->data); } public function testIsEmpty() { $empty = Collection::constructFrom(['data' => []]); - $this->assertTrue($empty->isEmpty()); + static::assertTrue($empty->isEmpty()); $notEmpty = Collection::constructFrom(['data' => [['id' => 1]]]); - $this->assertFalse($notEmpty->isEmpty()); + static::assertFalse($notEmpty->isEmpty()); } public function testNextPage() @@ -270,7 +270,7 @@ public function testNextPage() foreach ($nextPage->data as $element) { \array_push($ids, $element['id']); } - $this->assertEquals([2, 3], $ids); + static::assertEquals([2, 3], $ids); } public function testPreviousPage() @@ -291,6 +291,6 @@ public function testPreviousPage() ); $previousPage = $this->fixture->previousPage(); - $this->assertEquals([], $previousPage->data); + static::assertEquals([], $previousPage->data); } } diff --git a/tests/Stripe/CountrySpecTest.php b/tests/Stripe/CountrySpecTest.php index f368eebd0..86ad1b920 100644 --- a/tests/Stripe/CountrySpecTest.php +++ b/tests/Stripe/CountrySpecTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/country_specs' ); $resources = CountrySpec::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\CountrySpec::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\CountrySpec::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,6 +24,6 @@ public function testIsRetrievable() '/v1/country_specs/' . self::TEST_RESOURCE_ID ); $resource = CountrySpec::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\CountrySpec::class, $resource); + static::assertInstanceOf(\Stripe\CountrySpec::class, $resource); } } diff --git a/tests/Stripe/CouponTest.php b/tests/Stripe/CouponTest.php index 739ca532e..c75f0b79f 100644 --- a/tests/Stripe/CouponTest.php +++ b/tests/Stripe/CouponTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/coupons' ); $resources = Coupon::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Coupon::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Coupon::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/coupons/' . self::TEST_RESOURCE_ID ); $resource = Coupon::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Coupon::class, $resource); + static::assertInstanceOf(\Stripe\Coupon::class, $resource); } public function testIsCreatable() @@ -39,7 +39,7 @@ public function testIsCreatable() "duration_in_months" => 3, "id" => self::TEST_RESOURCE_ID, ]); - $this->assertInstanceOf(\Stripe\Coupon::class, $resource); + static::assertInstanceOf(\Stripe\Coupon::class, $resource); } public function testIsSaveable() @@ -51,7 +51,7 @@ public function testIsSaveable() '/v1/coupons/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Coupon::class, $resource); + static::assertInstanceOf(\Stripe\Coupon::class, $resource); } public function testIsUpdatable() @@ -63,7 +63,7 @@ public function testIsUpdatable() $resource = Coupon::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Coupon::class, $resource); + static::assertInstanceOf(\Stripe\Coupon::class, $resource); } public function testIsDeletable() @@ -74,6 +74,6 @@ public function testIsDeletable() '/v1/coupons/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Coupon::class, $resource); + static::assertInstanceOf(\Stripe\Coupon::class, $resource); } } diff --git a/tests/Stripe/CreditNoteTest.php b/tests/Stripe/CreditNoteTest.php index 86eebba4d..a15d5749a 100644 --- a/tests/Stripe/CreditNoteTest.php +++ b/tests/Stripe/CreditNoteTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/credit_notes' ); $resources = CreditNote::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\CreditNote::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\CreditNote::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/credit_notes/' . self::TEST_RESOURCE_ID ); $resource = CreditNote::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\CreditNote::class, $resource); + static::assertInstanceOf(\Stripe\CreditNote::class, $resource); } public function testIsCreatable() @@ -38,7 +38,7 @@ public function testIsCreatable() "invoice" => "in_132", "reason" => "duplicate", ]); - $this->assertInstanceOf(\Stripe\CreditNote::class, $resource); + static::assertInstanceOf(\Stripe\CreditNote::class, $resource); } public function testIsSaveable() @@ -50,7 +50,7 @@ public function testIsSaveable() '/v1/credit_notes/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\CreditNote::class, $resource); + static::assertInstanceOf(\Stripe\CreditNote::class, $resource); } public function testIsUpdatable() @@ -62,7 +62,7 @@ public function testIsUpdatable() $resource = CreditNote::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\CreditNote::class, $resource); + static::assertInstanceOf(\Stripe\CreditNote::class, $resource); } public function testCanPreview() @@ -75,7 +75,7 @@ public function testCanPreview() 'amount' => 100, 'invoice' => 'in_123', ]); - $this->assertInstanceOf(\Stripe\CreditNote::class, $resource); + static::assertInstanceOf(\Stripe\CreditNote::class, $resource); } public function testCanVoidCreditNote() @@ -86,8 +86,8 @@ public function testCanVoidCreditNote() '/v1/credit_notes/' . $creditNote->id . '/void' ); $resource = $creditNote->voidCreditNote(); - $this->assertInstanceOf(\Stripe\CreditNote::class, $resource); - $this->assertSame($resource, $creditNote); + static::assertInstanceOf(\Stripe\CreditNote::class, $resource); + static::assertSame($resource, $creditNote); } public function testCanListLines() @@ -97,6 +97,6 @@ public function testCanListLines() '/v1/credit_notes/' . self::TEST_RESOURCE_ID . '/lines' ); $resources = CreditNote::allLines(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } } diff --git a/tests/Stripe/CustomerBalanceTransactionTest.php b/tests/Stripe/CustomerBalanceTransactionTest.php index 817a46899..f71adcd84 100644 --- a/tests/Stripe/CustomerBalanceTransactionTest.php +++ b/tests/Stripe/CustomerBalanceTransactionTest.php @@ -10,7 +10,7 @@ class CustomerBalanceTransactionTest extends TestCase public function testHasCorrectUrl() { $resource = \Stripe\Customer::retrieveBalanceTransaction(self::TEST_CUSTOMER_ID, self::TEST_RESOURCE_ID); - $this->assertSame( + static::assertSame( "/v1/customers/" . self::TEST_CUSTOMER_ID . "/balance_transactions/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); diff --git a/tests/Stripe/CustomerTest.php b/tests/Stripe/CustomerTest.php index a0730856a..d5b018895 100644 --- a/tests/Stripe/CustomerTest.php +++ b/tests/Stripe/CustomerTest.php @@ -16,8 +16,8 @@ public function testIsListable() '/v1/customers' ); $resources = Customer::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Customer::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Customer::class, $resources->data[0]); } public function testIsRetrievable() @@ -27,7 +27,7 @@ public function testIsRetrievable() '/v1/customers/' . self::TEST_RESOURCE_ID ); $resource = Customer::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Customer::class, $resource); + static::assertInstanceOf(\Stripe\Customer::class, $resource); } public function testIsCreatable() @@ -37,7 +37,7 @@ public function testIsCreatable() '/v1/customers' ); $resource = Customer::create(); - $this->assertInstanceOf(\Stripe\Customer::class, $resource); + static::assertInstanceOf(\Stripe\Customer::class, $resource); } public function testIsSaveable() @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/customers/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Customer::class, $resource); + static::assertInstanceOf(\Stripe\Customer::class, $resource); } public function testIsUpdatable() @@ -61,7 +61,7 @@ public function testIsUpdatable() $resource = Customer::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Customer::class, $resource); + static::assertInstanceOf(\Stripe\Customer::class, $resource); } public function testIsDeletable() @@ -72,7 +72,7 @@ public function testIsDeletable() '/v1/customers/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Customer::class, $resource); + static::assertInstanceOf(\Stripe\Customer::class, $resource); } public function testCanDeleteDiscount() @@ -83,7 +83,7 @@ public function testCanDeleteDiscount() '/v1/customers/' . $customer->id . '/discount' ); $customer->deleteDiscount(); - $this->assertSame($customer->discount, null); + static::assertSame($customer->discount, null); } public function testCanCreateSource() @@ -112,7 +112,7 @@ public function testCanUpdateSource() ); $resource = Customer::updateSource(self::TEST_RESOURCE_ID, self::TEST_SOURCE_ID, ["name" => "name"]); // stripe-mock returns a Card on this method and not a bank account - $this->assertInstanceOf(\Stripe\Card::class, $resource); + static::assertInstanceOf(\Stripe\Card::class, $resource); } public function testCanDeleteSource() @@ -131,7 +131,7 @@ public function testCanListSources() '/v1/customers/' . self::TEST_RESOURCE_ID . '/sources' ); $resources = Customer::allSources(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } public function testSerializeSourceString() @@ -144,7 +144,7 @@ public function testSerializeSourceString() $expected = [ 'source' => 'tok_visa', ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testSerializeSourceMap() @@ -167,7 +167,7 @@ public function testSerializeSourceMap() 'exp_year' => 2032, ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } public function testCanCreateTaxId() @@ -207,7 +207,7 @@ public function testCanListTaxIds() '/v1/customers/' . self::TEST_RESOURCE_ID . '/tax_ids' ); $resources = Customer::allTaxIds(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } public function testCanCreateBalanceTransaction() @@ -247,6 +247,6 @@ public function testCanListCustomerBalanceTransactions() '/v1/customers/' . self::TEST_RESOURCE_ID . '/balance_transactions' ); $resources = Customer::allBalanceTransactions(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } } diff --git a/tests/Stripe/DisputeTest.php b/tests/Stripe/DisputeTest.php index cabc130d7..81a5e1964 100644 --- a/tests/Stripe/DisputeTest.php +++ b/tests/Stripe/DisputeTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/disputes' ); $resources = Dispute::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Dispute::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Dispute::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/disputes/' . self::TEST_RESOURCE_ID ); $resource = Dispute::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Dispute::class, $resource); + static::assertInstanceOf(\Stripe\Dispute::class, $resource); } public function testIsSaveable() @@ -36,7 +36,7 @@ public function testIsSaveable() '/v1/disputes/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Dispute::class, $resource); + static::assertInstanceOf(\Stripe\Dispute::class, $resource); } public function testIsUpdatable() @@ -48,7 +48,7 @@ public function testIsUpdatable() $resource = Dispute::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Dispute::class, $resource); + static::assertInstanceOf(\Stripe\Dispute::class, $resource); } public function testIsClosable() @@ -59,7 +59,7 @@ public function testIsClosable() '/v1/disputes/' . $dispute->id . '/close' ); $resource = $dispute->close(); - $this->assertInstanceOf(\Stripe\Dispute::class, $resource); - $this->assertSame($resource, $dispute); + static::assertInstanceOf(\Stripe\Dispute::class, $resource); + static::assertSame($resource, $dispute); } } diff --git a/tests/Stripe/EphemeralKeyTest.php b/tests/Stripe/EphemeralKeyTest.php index 88877fb71..684ca1ae0 100644 --- a/tests/Stripe/EphemeralKeyTest.php +++ b/tests/Stripe/EphemeralKeyTest.php @@ -15,7 +15,7 @@ public function testIsCreatable() $resource = EphemeralKey::create([ "customer" => "cus_123", ], ["stripe_version" => "2017-05-25"]); - $this->assertInstanceOf(\Stripe\EphemeralKey::class, $resource); + static::assertInstanceOf(\Stripe\EphemeralKey::class, $resource); } public function testIsNotCreatableWithoutAnExplicitApiVersion() @@ -37,6 +37,6 @@ public function testIsDeletable() '/v1/ephemeral_keys/' . $key->id ); $resource = $key->delete(); - $this->assertInstanceOf(\Stripe\EphemeralKey::class, $resource); + static::assertInstanceOf(\Stripe\EphemeralKey::class, $resource); } } diff --git a/tests/Stripe/ErrorObjectTest.php b/tests/Stripe/ErrorObjectTest.php index ffde88680..1699f9055 100644 --- a/tests/Stripe/ErrorObjectTest.php +++ b/tests/Stripe/ErrorObjectTest.php @@ -8,16 +8,16 @@ public function testDefaultValues() { $error = ErrorObject::constructFrom([]); - $this->assertNull($error->charge); - $this->assertNull($error->code); - $this->assertNull($error->decline_code); - $this->assertNull($error->doc_url); - $this->assertNull($error->message); - $this->assertNull($error->param); - $this->assertNull($error->payment_intent); - $this->assertNull($error->payment_method); - $this->assertNull($error->setup_intent); - $this->assertNull($error->source); - $this->assertNull($error->type); + static::assertNull($error->charge); + static::assertNull($error->code); + static::assertNull($error->decline_code); + static::assertNull($error->doc_url); + static::assertNull($error->message); + static::assertNull($error->param); + static::assertNull($error->payment_intent); + static::assertNull($error->payment_method); + static::assertNull($error->setup_intent); + static::assertNull($error->source); + static::assertNull($error->type); } } diff --git a/tests/Stripe/EventTest.php b/tests/Stripe/EventTest.php index 13f6ce4aa..428908a41 100644 --- a/tests/Stripe/EventTest.php +++ b/tests/Stripe/EventTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/events' ); $resources = Event::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Event::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Event::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,6 +24,6 @@ public function testIsRetrievable() '/v1/events/' . self::TEST_RESOURCE_ID ); $resource = Event::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Event::class, $resource); + static::assertInstanceOf(\Stripe\Event::class, $resource); } } diff --git a/tests/Stripe/Exception/ApiErrorExceptionTest.php b/tests/Stripe/Exception/ApiErrorExceptionTest.php index 7ae1e03c5..d76eb186b 100644 --- a/tests/Stripe/Exception/ApiErrorExceptionTest.php +++ b/tests/Stripe/Exception/ApiErrorExceptionTest.php @@ -24,19 +24,19 @@ public function createFixture() public function testGetters() { $e = $this->createFixture(); - $this->assertSame(200, $e->getHttpStatus()); - $this->assertSame('{"error": {"code": "some_code"}}', $e->getHttpBody()); - $this->assertSame(['error' => ['code' => 'some_code']], $e->getJsonBody()); - $this->assertSame('Some Value', $e->getHttpHeaders()['Some-Header']); - $this->assertSame('req_test', $e->getRequestId()); - $this->assertSame('some_code', $e->getStripeCode()); - $this->assertNotNull($e->getError()); - $this->assertSame('some_code', $e->getError()->code); + static::assertSame(200, $e->getHttpStatus()); + static::assertSame('{"error": {"code": "some_code"}}', $e->getHttpBody()); + static::assertSame(['error' => ['code' => 'some_code']], $e->getJsonBody()); + static::assertSame('Some Value', $e->getHttpHeaders()['Some-Header']); + static::assertSame('req_test', $e->getRequestId()); + static::assertSame('some_code', $e->getStripeCode()); + static::assertNotNull($e->getError()); + static::assertSame('some_code', $e->getError()->code); } public function testToString() { $e = $this->createFixture(); - $this->assertContains("(Request req_test)", (string) $e); + static::assertContains("(Request req_test)", (string) $e); } } diff --git a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php index 89d81905b..e5bbcb61c 100644 --- a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php +++ b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php @@ -24,20 +24,20 @@ public function createFixture() public function testGetters() { $e = $this->createFixture(); - $this->assertSame(200, $e->getHttpStatus()); - $this->assertSame('{"error": "code", "error_description": "description"}', $e->getHttpBody()); - $this->assertSame(['error' => 'code', 'error_description' => 'description'], $e->getJsonBody()); - $this->assertSame('Some Value', $e->getHttpHeaders()['Some-Header']); - $this->assertSame('req_test', $e->getRequestId()); - $this->assertSame('code', $e->getStripeCode()); - $this->assertNotNull($e->getError()); - $this->assertSame('code', $e->getError()->error); - $this->assertSame('description', $e->getError()->error_description); + static::assertSame(200, $e->getHttpStatus()); + static::assertSame('{"error": "code", "error_description": "description"}', $e->getHttpBody()); + static::assertSame(['error' => 'code', 'error_description' => 'description'], $e->getJsonBody()); + static::assertSame('Some Value', $e->getHttpHeaders()['Some-Header']); + static::assertSame('req_test', $e->getRequestId()); + static::assertSame('code', $e->getStripeCode()); + static::assertNotNull($e->getError()); + static::assertSame('code', $e->getError()->error); + static::assertSame('description', $e->getError()->error_description); } public function testToString() { $e = $this->createFixture(); - $this->assertContains("(Request req_test)", (string) $e); + static::assertContains("(Request req_test)", (string) $e); } } diff --git a/tests/Stripe/Exception/SignatureVerificationExceptionTest.php b/tests/Stripe/Exception/SignatureVerificationExceptionTest.php index a3ea273a2..165497f3b 100644 --- a/tests/Stripe/Exception/SignatureVerificationExceptionTest.php +++ b/tests/Stripe/Exception/SignatureVerificationExceptionTest.php @@ -7,8 +7,8 @@ class SignatureVerificationExceptionTest extends \Stripe\TestCase public function testGetters() { $e = SignatureVerificationException::factory('message', 'payload', 'sig_header'); - $this->assertSame('message', $e->getMessage()); - $this->assertSame('payload', $e->getHttpBody()); - $this->assertSame('sig_header', $e->getSigHeader()); + static::assertSame('message', $e->getMessage()); + static::assertSame('payload', $e->getHttpBody()); + static::assertSame('sig_header', $e->getSigHeader()); } } diff --git a/tests/Stripe/ExchangeRateTest.php b/tests/Stripe/ExchangeRateTest.php index 0a50d3457..2baaed70d 100644 --- a/tests/Stripe/ExchangeRateTest.php +++ b/tests/Stripe/ExchangeRateTest.php @@ -30,8 +30,8 @@ public function testIsListable() ); $listRates = ExchangeRate::all(); - $this->assertInternalType('array', $listRates->data); - $this->assertEquals('exchange_rate', $listRates->data[0]->object); + static::assertInternalType('array', $listRates->data); + static::assertEquals('exchange_rate', $listRates->data[0]->object); } public function testIsRetrievable() @@ -49,6 +49,6 @@ public function testIsRetrievable() ] ); $rates = ExchangeRate::retrieve("usd"); - $this->assertEquals('exchange_rate', $rates->object); + static::assertEquals('exchange_rate', $rates->object); } } diff --git a/tests/Stripe/FileCreationTest.php b/tests/Stripe/FileCreationTest.php index 425a1e840..734f68636 100644 --- a/tests/Stripe/FileCreationTest.php +++ b/tests/Stripe/FileCreationTest.php @@ -42,7 +42,7 @@ public function testIsCreatableWithFileHandle() "file" => $fp, "file_link_data" => ["create" => true] ]); - $this->assertInstanceOf(\Stripe\File::class, $resource); + static::assertInstanceOf(\Stripe\File::class, $resource); } public function testIsCreatableWithCURLFile() @@ -61,6 +61,6 @@ public function testIsCreatableWithCURLFile() "file" => $curlFile, "file_link_data" => ["create" => true] ]); - $this->assertInstanceOf(\Stripe\File::class, $resource); + static::assertInstanceOf(\Stripe\File::class, $resource); } } diff --git a/tests/Stripe/FileLinkTest.php b/tests/Stripe/FileLinkTest.php index 6db6bdb17..74edeb632 100644 --- a/tests/Stripe/FileLinkTest.php +++ b/tests/Stripe/FileLinkTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/file_links' ); $resources = FileLink::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\FileLink::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\FileLink::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/file_links/' . self::TEST_RESOURCE_ID ); $resource = FileLink::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\FileLink::class, $resource); + static::assertInstanceOf(\Stripe\FileLink::class, $resource); } public function testIsCreatable() @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = FileLink::create([ "file" => "file_123" ]); - $this->assertInstanceOf(\Stripe\FileLink::class, $resource); + static::assertInstanceOf(\Stripe\FileLink::class, $resource); } public function testIsSaveable() @@ -48,7 +48,7 @@ public function testIsSaveable() '/v1/file_links/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\FileLink::class, $resource); + static::assertInstanceOf(\Stripe\FileLink::class, $resource); } public function testIsUpdatable() @@ -60,6 +60,6 @@ public function testIsUpdatable() $resource = FileLink::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\FileLink::class, $resource); + static::assertInstanceOf(\Stripe\FileLink::class, $resource); } } diff --git a/tests/Stripe/FileTest.php b/tests/Stripe/FileTest.php index af2c66739..28f88224a 100644 --- a/tests/Stripe/FileTest.php +++ b/tests/Stripe/FileTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/files' ); $resources = File::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\File::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\File::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/files/' . self::TEST_RESOURCE_ID ); $resource = File::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\File::class, $resource); + static::assertInstanceOf(\Stripe\File::class, $resource); } public function testDeserializesFromFile() @@ -32,7 +32,7 @@ public function testDeserializesFromFile() $obj = Util\Util::convertToStripeObject([ 'object' => 'file', ], null); - $this->assertInstanceOf(\Stripe\File::class, $obj); + static::assertInstanceOf(\Stripe\File::class, $obj); } public function testDeserializesFromFileUpload() @@ -40,6 +40,6 @@ public function testDeserializesFromFileUpload() $obj = Util\Util::convertToStripeObject([ 'object' => 'file_upload', ], null); - $this->assertInstanceOf(\Stripe\File::class, $obj); + static::assertInstanceOf(\Stripe\File::class, $obj); } } diff --git a/tests/Stripe/HttpClient/CurlClientTest.php b/tests/Stripe/HttpClient/CurlClientTest.php index 6aabee60c..bb14e2e6d 100644 --- a/tests/Stripe/HttpClient/CurlClientTest.php +++ b/tests/Stripe/HttpClient/CurlClientTest.php @@ -87,27 +87,27 @@ private function createFakeRandomGenerator($returnValue = 1.0) public function testTimeout() { $curl = new CurlClient(); - $this->assertSame(CurlClient::DEFAULT_TIMEOUT, $curl->getTimeout()); - $this->assertSame(CurlClient::DEFAULT_CONNECT_TIMEOUT, $curl->getConnectTimeout()); + static::assertSame(CurlClient::DEFAULT_TIMEOUT, $curl->getTimeout()); + static::assertSame(CurlClient::DEFAULT_CONNECT_TIMEOUT, $curl->getConnectTimeout()); // implicitly tests whether we're returning the CurlClient instance $curl = $curl->setConnectTimeout(1)->setTimeout(10); - $this->assertSame(1, $curl->getConnectTimeout()); - $this->assertSame(10, $curl->getTimeout()); + static::assertSame(1, $curl->getConnectTimeout()); + static::assertSame(10, $curl->getTimeout()); $curl->setTimeout(-1); $curl->setConnectTimeout(-999); - $this->assertSame(0, $curl->getTimeout()); - $this->assertSame(0, $curl->getConnectTimeout()); + static::assertSame(0, $curl->getTimeout()); + static::assertSame(0, $curl->getConnectTimeout()); } public function testUserAgentInfo() { $curl = new CurlClient(); $uaInfo = $curl->getUserAgentInfo(); - $this->assertNotNull($uaInfo); - $this->assertNotNull($uaInfo['httplib']); - $this->assertNotNull($uaInfo['ssllib']); + static::assertNotNull($uaInfo); + static::assertNotNull($uaInfo['httplib']); + static::assertNotNull($uaInfo['ssllib']); } public function testDefaultOptions() @@ -115,7 +115,7 @@ public function testDefaultOptions() // make sure options array loads/saves properly $optionsArray = [\CURLOPT_PROXY => 'localhost:80']; $withOptionsArray = new CurlClient($optionsArray); - $this->assertSame($withOptionsArray->getDefaultOptions(), $optionsArray); + static::assertSame($withOptionsArray->getDefaultOptions(), $optionsArray); // make sure closure-based options work properly, including argument passing $ref = null; @@ -125,7 +125,7 @@ public function testDefaultOptions() }); $withClosure->request('get', 'https://httpbin.org/status/200', [], [], false); - $this->assertSame($ref, ['get', 'https://httpbin.org/status/200', [], [], false]); + static::assertSame($ref, ['get', 'https://httpbin.org/status/200', [], [], false]); // this is the last test case that will run, since it'll throw an exception at the end $withBadClosure = new CurlClient(function () { @@ -141,7 +141,7 @@ public function testSslOption() // make sure options array loads/saves properly $optionsArray = [\CURLOPT_SSLVERSION => \CURL_SSLVERSION_TLSv1]; $withOptionsArray = new CurlClient($optionsArray); - $this->assertSame($withOptionsArray->getDefaultOptions(), $optionsArray); + static::assertSame($withOptionsArray->getDefaultOptions(), $optionsArray); } public function testShouldRetryOnTimeout() @@ -150,7 +150,7 @@ public function testShouldRetryOnTimeout() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, \CURLE_OPERATION_TIMEOUTED, 0, [], 0)); + static::assertTrue($this->shouldRetryMethod->invoke($curlClient, \CURLE_OPERATION_TIMEOUTED, 0, [], 0)); } public function testShouldRetryOnConnectionFailure() @@ -159,7 +159,7 @@ public function testShouldRetryOnConnectionFailure() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, \CURLE_COULDNT_CONNECT, 0, [], 0)); + static::assertTrue($this->shouldRetryMethod->invoke($curlClient, \CURLE_COULDNT_CONNECT, 0, [], 0)); } public function testShouldRetryOnConflict() @@ -168,7 +168,7 @@ public function testShouldRetryOnConflict() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 409, [], 0)); + static::assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 409, [], 0)); } public function testShouldNotRetryOn429() @@ -177,7 +177,7 @@ public function testShouldNotRetryOn429() $curlClient = new CurlClient(); - $this->assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 429, [], 0)); + static::assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 429, [], 0)); } public function testShouldRetryOn500() @@ -186,7 +186,7 @@ public function testShouldRetryOn500() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 500, [], 0)); + static::assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 500, [], 0)); } public function testShouldRetryOn503() @@ -195,7 +195,7 @@ public function testShouldRetryOn503() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 503, [], 0)); + static::assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 503, [], 0)); } public function testShouldRetryOnStripeShouldRetryTrue() @@ -204,8 +204,8 @@ public function testShouldRetryOnStripeShouldRetryTrue() $curlClient = new CurlClient(); - $this->assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 400, [], 0)); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 400, ['stripe-should-retry' => 'true'], 0)); + static::assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 400, [], 0)); + static::assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 400, ['stripe-should-retry' => 'true'], 0)); } public function testShouldNotRetryOnStripeShouldRetryFalse() @@ -214,8 +214,8 @@ public function testShouldNotRetryOnStripeShouldRetryFalse() $curlClient = new CurlClient(); - $this->assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 500, [], 0)); - $this->assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 500, ['stripe-should-retry' => 'false'], 0)); + static::assertTrue($this->shouldRetryMethod->invoke($curlClient, 0, 500, [], 0)); + static::assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 500, ['stripe-should-retry' => 'false'], 0)); } public function testShouldNotRetryAtMaximumCount() @@ -224,7 +224,7 @@ public function testShouldNotRetryAtMaximumCount() $curlClient = new CurlClient(); - $this->assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 0, [], \Stripe\Stripe::getMaxNetworkRetries())); + static::assertFalse($this->shouldRetryMethod->invoke($curlClient, 0, 0, [], \Stripe\Stripe::getMaxNetworkRetries())); } public function testShouldNotRetryOnCertValidationError() @@ -233,7 +233,7 @@ public function testShouldNotRetryOnCertValidationError() $curlClient = new CurlClient(); - $this->assertFalse($this->shouldRetryMethod->invoke($curlClient, \CURLE_SSL_PEER_CERTIFICATE, -1, [], 0)); + static::assertFalse($this->shouldRetryMethod->invoke($curlClient, \CURLE_SSL_PEER_CERTIFICATE, -1, [], 0)); } public function testSleepTimeShouldGrowExponentially() @@ -242,19 +242,19 @@ public function testSleepTimeShouldGrowExponentially() $curlClient = new CurlClient(null, $this->createFakeRandomGenerator()); - $this->assertEquals( + static::assertEquals( \Stripe\Stripe::getInitialNetworkRetryDelay() * 1, $this->sleepTimeMethod->invoke($curlClient, 1, []) ); - $this->assertEquals( + static::assertEquals( \Stripe\Stripe::getInitialNetworkRetryDelay() * 2, $this->sleepTimeMethod->invoke($curlClient, 2, []) ); - $this->assertEquals( + static::assertEquals( \Stripe\Stripe::getInitialNetworkRetryDelay() * 4, $this->sleepTimeMethod->invoke($curlClient, 3, []) ); - $this->assertEquals( + static::assertEquals( \Stripe\Stripe::getInitialNetworkRetryDelay() * 8, $this->sleepTimeMethod->invoke($curlClient, 4, []) ); @@ -267,10 +267,10 @@ public function testSleepTimeShouldEnforceMaxNetworkRetryDelay() $curlClient = new CurlClient(null, $this->createFakeRandomGenerator()); - $this->assertEquals(1, $this->sleepTimeMethod->invoke($curlClient, 1, [])); - $this->assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, [])); - $this->assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 3, [])); - $this->assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 4, [])); + static::assertEquals(1, $this->sleepTimeMethod->invoke($curlClient, 1, [])); + static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, [])); + static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 3, [])); + static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 4, [])); } public function testSleepTimeShouldRespectRetryAfter() @@ -281,11 +281,11 @@ public function testSleepTimeShouldRespectRetryAfter() $curlClient = new CurlClient(null, $this->createFakeRandomGenerator()); // Uses max of default and header. - $this->assertEquals(10, $this->sleepTimeMethod->invoke($curlClient, 1, ['retry-after' => '10'])); - $this->assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '1'])); + static::assertEquals(10, $this->sleepTimeMethod->invoke($curlClient, 1, ['retry-after' => '10'])); + static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '1'])); // Ignores excessively large values. - $this->assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '100'])); + static::assertEquals(2, $this->sleepTimeMethod->invoke($curlClient, 2, ['retry-after' => '100'])); } public function testSleepTimeShouldAddSomeRandomness() @@ -300,12 +300,12 @@ public function testSleepTimeShouldAddSomeRandomness() // the initial value cannot be smaller than the base, // so the randomness is ignored - $this->assertEquals(\Stripe\Stripe::getInitialNetworkRetryDelay(), $this->sleepTimeMethod->invoke($curlClient, 1, [])); + static::assertEquals(\Stripe\Stripe::getInitialNetworkRetryDelay(), $this->sleepTimeMethod->invoke($curlClient, 1, [])); // after the first one, the randomness is applied - $this->assertEquals($baseValue * 2, $this->sleepTimeMethod->invoke($curlClient, 2, [])); - $this->assertEquals($baseValue * 4, $this->sleepTimeMethod->invoke($curlClient, 3, [])); - $this->assertEquals($baseValue * 8, $this->sleepTimeMethod->invoke($curlClient, 4, [])); + static::assertEquals($baseValue * 2, $this->sleepTimeMethod->invoke($curlClient, 2, [])); + static::assertEquals($baseValue * 4, $this->sleepTimeMethod->invoke($curlClient, 3, [])); + static::assertEquals($baseValue * 8, $this->sleepTimeMethod->invoke($curlClient, 4, [])); } public function testResponseHeadersCaseInsensitive() @@ -313,8 +313,8 @@ public function testResponseHeadersCaseInsensitive() $charge = \Stripe\Charge::all(); $headers = $charge->getLastResponse()->headers; - $this->assertNotNull($headers['request-id']); - $this->assertEquals($headers['request-id'], $headers['Request-Id']); + static::assertNotNull($headers['request-id']); + static::assertEquals($headers['request-id'], $headers['Request-Id']); } public function testSetRequestStatusCallback() @@ -339,7 +339,7 @@ public function testSetRequestStatusCallback() \Stripe\Charge::all(); - $this->assertTrue($called); + static::assertTrue($called); } finally { \Stripe\ApiRequestor::setHttpClient(null); } diff --git a/tests/Stripe/InvoiceItemTest.php b/tests/Stripe/InvoiceItemTest.php index ac79c5ca6..1d1012662 100644 --- a/tests/Stripe/InvoiceItemTest.php +++ b/tests/Stripe/InvoiceItemTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/invoiceitems' ); $resources = InvoiceItem::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\InvoiceItem::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/invoiceitems/' . self::TEST_RESOURCE_ID ); $resource = InvoiceItem::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resource); + static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } public function testIsCreatable() @@ -38,7 +38,7 @@ public function testIsCreatable() "currency" => "usd", "customer" => "cus_123" ]); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resource); + static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } public function testIsSaveable() @@ -50,7 +50,7 @@ public function testIsSaveable() '/v1/invoiceitems/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resource); + static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } public function testIsUpdatable() @@ -62,7 +62,7 @@ public function testIsUpdatable() $resource = InvoiceItem::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resource); + static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } public function testIsDeletable() @@ -73,6 +73,6 @@ public function testIsDeletable() '/v1/invoiceitems/' . $invoiceItem->id ); $resource = $invoiceItem->delete(); - $this->assertInstanceOf(\Stripe\InvoiceItem::class, $resource); + static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } } diff --git a/tests/Stripe/InvoiceTest.php b/tests/Stripe/InvoiceTest.php index 526093e38..21a562f22 100644 --- a/tests/Stripe/InvoiceTest.php +++ b/tests/Stripe/InvoiceTest.php @@ -14,8 +14,8 @@ public function testIsListable() '/v1/invoices' ); $resources = Invoice::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Invoice::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Invoice::class, $resources->data[0]); } public function testIsRetrievable() @@ -25,7 +25,7 @@ public function testIsRetrievable() '/v1/invoices/' . self::TEST_RESOURCE_ID ); $resource = Invoice::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); } public function testIsCreatable() @@ -37,7 +37,7 @@ public function testIsCreatable() $resource = Invoice::create([ "customer" => "cus_123" ]); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); } public function testIsSaveable() @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/invoices/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); } public function testIsUpdatable() @@ -61,7 +61,7 @@ public function testIsUpdatable() $resource = Invoice::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); } public function testIsDeletable() @@ -72,7 +72,7 @@ public function testIsDeletable() '/v1/invoices/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); } public function testCanFinalizeInvoice() @@ -83,8 +83,8 @@ public function testCanFinalizeInvoice() '/v1/invoices/' . $invoice->id . '/finalize' ); $resource = $invoice->finalizeInvoice(); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); - $this->assertSame($resource, $invoice); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertSame($resource, $invoice); } public function testCanMarkUncollectible() @@ -95,8 +95,8 @@ public function testCanMarkUncollectible() '/v1/invoices/' . $invoice->id . '/mark_uncollectible' ); $resource = $invoice->markUncollectible(); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); - $this->assertSame($resource, $invoice); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertSame($resource, $invoice); } public function testCanPay() @@ -107,8 +107,8 @@ public function testCanPay() '/v1/invoices/' . $invoice->id . '/pay' ); $resource = $invoice->pay(); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); - $this->assertSame($resource, $invoice); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertSame($resource, $invoice); } public function testCanRetrieveUpcoming() @@ -118,7 +118,7 @@ public function testCanRetrieveUpcoming() '/v1/invoices/upcoming' ); $resource = Invoice::upcoming(["customer" => "cus_123"]); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); } public function testCanSendInvoice() @@ -129,8 +129,8 @@ public function testCanSendInvoice() '/v1/invoices/' . $invoice->id . '/send' ); $resource = $invoice->sendInvoice(); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); - $this->assertSame($resource, $invoice); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertSame($resource, $invoice); } public function testCanVoidInvoice() @@ -141,8 +141,8 @@ public function testCanVoidInvoice() '/v1/invoices/' . $invoice->id . '/void' ); $resource = $invoice->voidInvoice(); - $this->assertInstanceOf(\Stripe\Invoice::class, $resource); - $this->assertSame($resource, $invoice); + static::assertInstanceOf(\Stripe\Invoice::class, $resource); + static::assertSame($resource, $invoice); } public function testCanListLines() @@ -152,6 +152,6 @@ public function testCanListLines() '/v1/invoices/' . self::TEST_RESOURCE_ID . '/lines' ); $resources = Invoice::allLines(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); + static::assertInternalType('array', $resources->data); } } diff --git a/tests/Stripe/Issuing/AuthorizationTest.php b/tests/Stripe/Issuing/AuthorizationTest.php index cb8f4335a..c970dfb7f 100644 --- a/tests/Stripe/Issuing/AuthorizationTest.php +++ b/tests/Stripe/Issuing/AuthorizationTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/issuing/authorizations' ); $resources = Authorization::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Issuing\Authorization::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Issuing\Authorization::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID ); $resource = Authorization::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); } public function testIsSaveable() @@ -37,7 +37,7 @@ public function testIsSaveable() '/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); } public function testIsUpdatable() @@ -50,7 +50,7 @@ public function testIsUpdatable() $resource = Authorization::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); } public function testIsApprovable() @@ -62,7 +62,7 @@ public function testIsApprovable() '/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID . '/approve' ); $resource = $resource->approve(); - $this->assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); } public function testIsDeclinable() @@ -74,6 +74,6 @@ public function testIsDeclinable() '/v1/issuing/authorizations/' . self::TEST_RESOURCE_ID . '/decline' ); $resource = $resource->decline(); - $this->assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Authorization::class, $resource); } } diff --git a/tests/Stripe/Issuing/CardTest.php b/tests/Stripe/Issuing/CardTest.php index 7863c07ce..2ab86b62d 100644 --- a/tests/Stripe/Issuing/CardTest.php +++ b/tests/Stripe/Issuing/CardTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/issuing/cards' ); $resources = Card::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Issuing\Card::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Issuing\Card::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/issuing/cards/' . self::TEST_RESOURCE_ID ); $resource = Card::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Issuing\Card::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Card::class, $resource); } public function testIsSaveable() @@ -37,7 +37,7 @@ public function testIsSaveable() '/v1/issuing/cards/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Issuing\Card::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Card::class, $resource); } public function testIsUpdatable() @@ -50,7 +50,7 @@ public function testIsUpdatable() $resource = Card::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Issuing\Card::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Card::class, $resource); } public function testCanRetrieveDetails() @@ -61,6 +61,6 @@ public function testCanRetrieveDetails() '/v1/issuing/cards/' . self::TEST_RESOURCE_ID . '/details' ); $details = $resource->details(); - $this->assertInstanceOf(\Stripe\Issuing\CardDetails::class, $details); + static::assertInstanceOf(\Stripe\Issuing\CardDetails::class, $details); } } diff --git a/tests/Stripe/Issuing/CardholderTest.php b/tests/Stripe/Issuing/CardholderTest.php index 355783323..44e1ec8d1 100644 --- a/tests/Stripe/Issuing/CardholderTest.php +++ b/tests/Stripe/Issuing/CardholderTest.php @@ -27,7 +27,7 @@ public function testIsCreatable() $params ); $resource = Cardholder::create($params); - $this->assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); } public function testIsListable() @@ -37,8 +37,8 @@ public function testIsListable() '/v1/issuing/cardholders' ); $resources = Cardholder::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resources->data[0]); } public function testIsRetrievable() @@ -48,7 +48,7 @@ public function testIsRetrievable() '/v1/issuing/cardholders/' . self::TEST_RESOURCE_ID ); $resource = Cardholder::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); } public function testIsSaveable() @@ -61,7 +61,7 @@ public function testIsSaveable() '/v1/issuing/cardholders/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); } public function testIsUpdatable() @@ -74,6 +74,6 @@ public function testIsUpdatable() $resource = Cardholder::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Cardholder::class, $resource); } } diff --git a/tests/Stripe/Issuing/DisputeTest.php b/tests/Stripe/Issuing/DisputeTest.php index c2961acc6..fc2e5f3d9 100644 --- a/tests/Stripe/Issuing/DisputeTest.php +++ b/tests/Stripe/Issuing/DisputeTest.php @@ -19,7 +19,7 @@ public function testIsCreatable() $params ); $resource = Dispute::create($params); - $this->assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); } public function testIsListable() @@ -29,8 +29,8 @@ public function testIsListable() '/v1/issuing/disputes' ); $resources = Dispute::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Issuing\Dispute::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resources->data[0]); } public function testIsRetrievable() @@ -40,7 +40,7 @@ public function testIsRetrievable() '/v1/issuing/disputes/' . self::TEST_RESOURCE_ID ); $resource = Dispute::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); } public function testIsSaveable() @@ -53,7 +53,7 @@ public function testIsSaveable() '/v1/issuing/disputes/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); } public function testIsUpdatable() @@ -66,6 +66,6 @@ public function testIsUpdatable() $resource = Dispute::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); } } diff --git a/tests/Stripe/Issuing/TransactionTest.php b/tests/Stripe/Issuing/TransactionTest.php index f43d68510..418064b3f 100644 --- a/tests/Stripe/Issuing/TransactionTest.php +++ b/tests/Stripe/Issuing/TransactionTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/issuing/transactions' ); $resources = Transaction::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Issuing\Transaction::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Issuing\Transaction::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/issuing/transactions/' . self::TEST_RESOURCE_ID ); $resource = Transaction::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Issuing\Transaction::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Transaction::class, $resource); } public function testIsSaveable() @@ -37,7 +37,7 @@ public function testIsSaveable() '/v1/issuing/transactions/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Issuing\Transaction::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Transaction::class, $resource); } public function testIsUpdatable() @@ -50,6 +50,6 @@ public function testIsUpdatable() $resource = Transaction::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Issuing\Transaction::class, $resource); + static::assertInstanceOf(\Stripe\Issuing\Transaction::class, $resource); } } diff --git a/tests/Stripe/MandateTest.php b/tests/Stripe/MandateTest.php index f4bc4eccf..7e5244a64 100644 --- a/tests/Stripe/MandateTest.php +++ b/tests/Stripe/MandateTest.php @@ -13,6 +13,6 @@ public function testIsRetrievable() '/v1/mandates/' . self::TEST_RESOURCE_ID ); $resource = Mandate::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Mandate::class, $resource); + static::assertInstanceOf(\Stripe\Mandate::class, $resource); } } diff --git a/tests/Stripe/OAuthErrorObjectTest.php b/tests/Stripe/OAuthErrorObjectTest.php index 0e9fb51bf..73b27e147 100644 --- a/tests/Stripe/OAuthErrorObjectTest.php +++ b/tests/Stripe/OAuthErrorObjectTest.php @@ -8,7 +8,7 @@ public function testDefaultValues() { $error = OAuthErrorObject::constructFrom([]); - $this->assertNull($error->error); - $this->assertNull($error->error_description); + static::assertNull($error->error); + static::assertNull($error->error_description); } } diff --git a/tests/Stripe/OAuthTest.php b/tests/Stripe/OAuthTest.php index 81ce9feac..a7beea953 100644 --- a/tests/Stripe/OAuthTest.php +++ b/tests/Stripe/OAuthTest.php @@ -19,15 +19,15 @@ public function testAuthorizeUrl() $uri = \parse_url($uriStr); \parse_str($uri['query'], $params); - $this->assertSame('https', $uri['scheme']); - $this->assertSame('connect.stripe.com', $uri['host']); - $this->assertSame('/oauth/authorize', $uri['path']); + static::assertSame('https', $uri['scheme']); + static::assertSame('connect.stripe.com', $uri['host']); + static::assertSame('/oauth/authorize', $uri['path']); - $this->assertSame('ca_123', $params['client_id']); - $this->assertSame('read_write', $params['scope']); - $this->assertSame('test@example.com', $params['stripe_user']['email']); - $this->assertSame('https://example.com/profile/test', $params['stripe_user']['url']); - $this->assertSame('US', $params['stripe_user']['country']); + static::assertSame('ca_123', $params['client_id']); + static::assertSame('read_write', $params['scope']); + static::assertSame('test@example.com', $params['stripe_user']['email']); + static::assertSame('https://example.com/profile/test', $params['stripe_user']['url']); + static::assertSame('US', $params['stripe_user']['country']); } public function testRaisesAuthenticationErrorWhenNoClientId() @@ -67,7 +67,7 @@ public function testToken() 'grant_type' => 'authorization_code', 'code' => 'this_is_an_authorization_code', ]); - $this->assertSame('sk_access_token', $resp->access_token); + static::assertSame('sk_access_token', $resp->access_token); } public function testDeauthorize() @@ -91,6 +91,6 @@ public function testDeauthorize() $resp = OAuth::deauthorize([ 'stripe_user_id' => 'acct_test_deauth', ]); - $this->assertSame('acct_test_deauth', $resp->stripe_user_id); + static::assertSame('acct_test_deauth', $resp->stripe_user_id); } } diff --git a/tests/Stripe/OrderReturnTest.php b/tests/Stripe/OrderReturnTest.php index dcfe68ca4..1351030a9 100644 --- a/tests/Stripe/OrderReturnTest.php +++ b/tests/Stripe/OrderReturnTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/order_returns' ); $resources = OrderReturn::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\OrderReturn::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\OrderReturn::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,6 +24,6 @@ public function testIsRetrievable() '/v1/order_returns/' . self::TEST_RESOURCE_ID ); $resource = OrderReturn::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\OrderReturn::class, $resource); + static::assertInstanceOf(\Stripe\OrderReturn::class, $resource); } } diff --git a/tests/Stripe/OrderTest.php b/tests/Stripe/OrderTest.php index 9cc9e5c73..e2138853d 100644 --- a/tests/Stripe/OrderTest.php +++ b/tests/Stripe/OrderTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/orders' ); $resources = Order::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Order::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Order::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/orders/' . self::TEST_RESOURCE_ID ); $resource = Order::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Order::class, $resource); + static::assertInstanceOf(\Stripe\Order::class, $resource); } public function testIsCreatable() @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = Order::create([ 'currency' => 'usd' ]); - $this->assertInstanceOf(\Stripe\Order::class, $resource); + static::assertInstanceOf(\Stripe\Order::class, $resource); } public function testIsSaveable() @@ -48,7 +48,7 @@ public function testIsSaveable() '/v1/orders/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Order::class, $resource); + static::assertInstanceOf(\Stripe\Order::class, $resource); } public function testIsUpdatable() @@ -60,7 +60,7 @@ public function testIsUpdatable() $resource = Order::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Order::class, $resource); + static::assertInstanceOf(\Stripe\Order::class, $resource); } public function testIsPayable() @@ -71,7 +71,7 @@ public function testIsPayable() '/v1/orders/' . $resource->id . '/pay' ); $resource->pay(); - $this->assertInstanceOf(\Stripe\Order::class, $resource); + static::assertInstanceOf(\Stripe\Order::class, $resource); } public function testIsReturnable() @@ -82,6 +82,6 @@ public function testIsReturnable() '/v1/orders/' . $order->id . '/returns' ); $resource = $order->returnOrder(); - $this->assertInstanceOf(\Stripe\OrderReturn::class, $resource); + static::assertInstanceOf(\Stripe\OrderReturn::class, $resource); } } diff --git a/tests/Stripe/PaymentIntentTest.php b/tests/Stripe/PaymentIntentTest.php index 1222a41f5..4fb2b8e93 100644 --- a/tests/Stripe/PaymentIntentTest.php +++ b/tests/Stripe/PaymentIntentTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/payment_intents' ); $resources = PaymentIntent::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/payment_intents/' . self::TEST_RESOURCE_ID ); $resource = PaymentIntent::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resource); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); } public function testIsCreatable() @@ -38,7 +38,7 @@ public function testIsCreatable() "currency" => "usd", 'payment_method_types' => ['card'], ]); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resource); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); } public function testIsSaveable() @@ -50,7 +50,7 @@ public function testIsSaveable() '/v1/payment_intents/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resource); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); } public function testIsUpdatable() @@ -65,7 +65,7 @@ public function testIsUpdatable() "metadata" => ["key" => "value"], ] ); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resource); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); } public function testIsCancelable() @@ -76,7 +76,7 @@ public function testIsCancelable() '/v1/payment_intents/' . self::TEST_RESOURCE_ID . '/cancel' ); $resource->cancel(); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resource); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); } public function testIsCapturable() @@ -87,7 +87,7 @@ public function testIsCapturable() '/v1/payment_intents/' . self::TEST_RESOURCE_ID . '/capture' ); $resource->capture(); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resource); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); } public function testIsConfirmable() @@ -98,6 +98,6 @@ public function testIsConfirmable() '/v1/payment_intents/' . self::TEST_RESOURCE_ID . '/confirm' ); $resource->confirm(); - $this->assertInstanceOf(\Stripe\PaymentIntent::class, $resource); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $resource); } } diff --git a/tests/Stripe/PaymentMethodTest.php b/tests/Stripe/PaymentMethodTest.php index 6851caa1c..81461fb81 100644 --- a/tests/Stripe/PaymentMethodTest.php +++ b/tests/Stripe/PaymentMethodTest.php @@ -16,8 +16,8 @@ public function testIsListable() 'customer' => 'cus_123', 'type' => 'card', ]); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\PaymentMethod::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $resources->data[0]); } public function testIsRetrievable() @@ -27,7 +27,7 @@ public function testIsRetrievable() '/v1/payment_methods/' . self::TEST_RESOURCE_ID ); $resource = PaymentMethod::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\PaymentMethod::class, $resource); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $resource); } public function testIsCreatable() @@ -39,7 +39,7 @@ public function testIsCreatable() $resource = PaymentMethod::create([ 'type' => 'card', ]); - $this->assertInstanceOf(\Stripe\PaymentMethod::class, $resource); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $resource); } public function testIsSaveable() @@ -51,7 +51,7 @@ public function testIsSaveable() '/v1/payment_methods/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\PaymentMethod::class, $resource); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $resource); } public function testIsUpdatable() @@ -63,7 +63,7 @@ public function testIsUpdatable() $resource = PaymentMethod::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\PaymentMethod::class, $resource); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $resource); } public function testCanAttach() @@ -76,8 +76,8 @@ public function testCanAttach() $resource = $resource->attach([ 'customer' => 'cus_123', ]); - $this->assertInstanceOf(\Stripe\PaymentMethod::class, $resource); - $this->assertSame($resource, $resource); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $resource); + static::assertSame($resource, $resource); } public function testCanDetach() @@ -88,7 +88,7 @@ public function testCanDetach() '/v1/payment_methods/' . $resource->id . '/detach' ); $resource = $resource->detach(); - $this->assertInstanceOf(\Stripe\PaymentMethod::class, $resource); - $this->assertSame($resource, $resource); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $resource); + static::assertSame($resource, $resource); } } diff --git a/tests/Stripe/PayoutTest.php b/tests/Stripe/PayoutTest.php index 147135b1c..4c0cbb2e2 100644 --- a/tests/Stripe/PayoutTest.php +++ b/tests/Stripe/PayoutTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/payouts' ); $resources = Payout::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Payout::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Payout::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/payouts/' . self::TEST_RESOURCE_ID ); $resource = Payout::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Payout::class, $resource); + static::assertInstanceOf(\Stripe\Payout::class, $resource); } public function testIsCreatable() @@ -37,7 +37,7 @@ public function testIsCreatable() "amount" => 100, "currency" => "usd" ]); - $this->assertInstanceOf(\Stripe\Payout::class, $resource); + static::assertInstanceOf(\Stripe\Payout::class, $resource); } public function testIsSaveable() @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/payouts/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Payout::class, $resource); + static::assertInstanceOf(\Stripe\Payout::class, $resource); } public function testIsUpdatable() @@ -61,7 +61,7 @@ public function testIsUpdatable() $resource = Payout::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Payout::class, $resource); + static::assertInstanceOf(\Stripe\Payout::class, $resource); } public function testIsCancelable() @@ -72,6 +72,6 @@ public function testIsCancelable() '/v1/payouts/' . $resource->id . '/cancel' ); $resource->cancel(); - $this->assertInstanceOf(\Stripe\Payout::class, $resource); + static::assertInstanceOf(\Stripe\Payout::class, $resource); } } diff --git a/tests/Stripe/PersonTest.php b/tests/Stripe/PersonTest.php index 691daa71d..927a659b2 100644 --- a/tests/Stripe/PersonTest.php +++ b/tests/Stripe/PersonTest.php @@ -10,7 +10,7 @@ class PersonTest extends TestCase public function testHasCorrectUrl() { $resource = \Stripe\Account::retrievePerson(self::TEST_ACCOUNT_ID, self::TEST_RESOURCE_ID); - $this->assertSame( + static::assertSame( "/v1/accounts/" . self::TEST_ACCOUNT_ID . "/persons/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -32,7 +32,7 @@ public function testIsSaveable() '/v1/accounts/' . self::TEST_ACCOUNT_ID . '/persons/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertSame(\Stripe\Person::class, \get_class($resource)); + static::assertSame(\Stripe\Person::class, \get_class($resource)); } public function testIsNotDirectlyUpdatable() @@ -52,6 +52,6 @@ public function testIsDeletable() '/v1/accounts/' . self::TEST_ACCOUNT_ID . '/persons/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertSame(\Stripe\Person::class, \get_class($resource)); + static::assertSame(\Stripe\Person::class, \get_class($resource)); } } diff --git a/tests/Stripe/PlanTest.php b/tests/Stripe/PlanTest.php index dc9914a5c..92e0c6803 100644 --- a/tests/Stripe/PlanTest.php +++ b/tests/Stripe/PlanTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/plans' ); $resources = Plan::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Plan::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Plan::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/plans/' . self::TEST_RESOURCE_ID ); $resource = Plan::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Plan::class, $resource); + static::assertInstanceOf(\Stripe\Plan::class, $resource); } public function testIsCreatable() @@ -40,7 +40,7 @@ public function testIsCreatable() 'nickname' => self::TEST_RESOURCE_ID, 'id' => self::TEST_RESOURCE_ID ]); - $this->assertInstanceOf(\Stripe\Plan::class, $resource); + static::assertInstanceOf(\Stripe\Plan::class, $resource); } public function testIsSaveable() @@ -52,7 +52,7 @@ public function testIsSaveable() '/v1/plans/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Plan::class, $resource); + static::assertInstanceOf(\Stripe\Plan::class, $resource); } public function testIsUpdatable() @@ -64,7 +64,7 @@ public function testIsUpdatable() $resource = Plan::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Plan::class, $resource); + static::assertInstanceOf(\Stripe\Plan::class, $resource); } public function testIsDeletable() @@ -75,6 +75,6 @@ public function testIsDeletable() '/v1/plans/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Plan::class, $resource); + static::assertInstanceOf(\Stripe\Plan::class, $resource); } } diff --git a/tests/Stripe/ProductTest.php b/tests/Stripe/ProductTest.php index ecff1e9db..cafdf7950 100644 --- a/tests/Stripe/ProductTest.php +++ b/tests/Stripe/ProductTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/products' ); $resources = Product::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Product::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Product::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/products/' . self::TEST_RESOURCE_ID ); $resource = Product::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Product::class, $resource); + static::assertInstanceOf(\Stripe\Product::class, $resource); } public function testIsCreatable() @@ -37,7 +37,7 @@ public function testIsCreatable() 'name' => 'name', 'type' => 'good' ]); - $this->assertInstanceOf(\Stripe\Product::class, $resource); + static::assertInstanceOf(\Stripe\Product::class, $resource); } public function testIsSaveable() @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/products/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Product::class, $resource); + static::assertInstanceOf(\Stripe\Product::class, $resource); } public function testIsUpdatable() @@ -61,7 +61,7 @@ public function testIsUpdatable() $resource = Product::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Product::class, $resource); + static::assertInstanceOf(\Stripe\Product::class, $resource); } public function testIsDeletable() @@ -72,6 +72,6 @@ public function testIsDeletable() '/v1/products/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Product::class, $resource); + static::assertInstanceOf(\Stripe\Product::class, $resource); } } diff --git a/tests/Stripe/Radar/EarlyFraudWarningTest.php b/tests/Stripe/Radar/EarlyFraudWarningTest.php index 9badc6da0..19b28c66a 100644 --- a/tests/Stripe/Radar/EarlyFraudWarningTest.php +++ b/tests/Stripe/Radar/EarlyFraudWarningTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/radar/early_fraud_warnings' ); $resources = EarlyFraudWarning::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Radar\EarlyFraudWarning::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Radar\EarlyFraudWarning::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,6 +24,6 @@ public function testIsRetrievable() '/v1/radar/early_fraud_warnings/' . self::TEST_RESOURCE_ID ); $resource = EarlyFraudWarning::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Radar\EarlyFraudWarning::class, $resource); + static::assertInstanceOf(\Stripe\Radar\EarlyFraudWarning::class, $resource); } } diff --git a/tests/Stripe/Radar/ValueListItemTest.php b/tests/Stripe/Radar/ValueListItemTest.php index 8a6d3ce6a..8dd2594d8 100644 --- a/tests/Stripe/Radar/ValueListItemTest.php +++ b/tests/Stripe/Radar/ValueListItemTest.php @@ -15,8 +15,8 @@ public function testIsListable() $resources = ValueListItem::all([ "value_list" => "rsl_123", ]); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resources->data[0]); } public function testIsRetrievable() @@ -26,7 +26,7 @@ public function testIsRetrievable() '/v1/radar/value_list_items/' . self::TEST_RESOURCE_ID ); $resource = ValueListItem::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resource); } public function testIsCreatable() @@ -39,7 +39,7 @@ public function testIsCreatable() "value_list" => "rsl_123", "value" => "value", ]); - $this->assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resource); } public function testIsDeletable() @@ -50,6 +50,6 @@ public function testIsDeletable() '/v1/radar/value_list_items/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueListItem::class, $resource); } } diff --git a/tests/Stripe/Radar/ValueListTest.php b/tests/Stripe/Radar/ValueListTest.php index 88846ac4d..c954281ab 100644 --- a/tests/Stripe/Radar/ValueListTest.php +++ b/tests/Stripe/Radar/ValueListTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/radar/value_lists' ); $resources = ValueList::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Radar\ValueList::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/radar/value_lists/' . self::TEST_RESOURCE_ID ); $resource = ValueList::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); } public function testIsCreatable() @@ -37,7 +37,7 @@ public function testIsCreatable() "alias" => "alias", "name" => "name", ]); - $this->assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); } public function testIsSaveable() @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/radar/value_lists/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); } public function testIsUpdatable() @@ -61,7 +61,7 @@ public function testIsUpdatable() $resource = ValueList::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); } public function testIsDeletable() @@ -72,6 +72,6 @@ public function testIsDeletable() '/v1/radar/value_lists/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); + static::assertInstanceOf(\Stripe\Radar\ValueList::class, $resource); } } diff --git a/tests/Stripe/RecipientTest.php b/tests/Stripe/RecipientTest.php index 206530e7f..b378825b4 100644 --- a/tests/Stripe/RecipientTest.php +++ b/tests/Stripe/RecipientTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/recipients' ); $resources = Recipient::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Recipient::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Recipient::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/recipients/' . self::TEST_RESOURCE_ID ); $resource = Recipient::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Recipient::class, $resource); + static::assertInstanceOf(\Stripe\Recipient::class, $resource); } public function testIsCreatable() @@ -37,7 +37,7 @@ public function testIsCreatable() "name" => "name", "type" => "individual" ]); - $this->assertInstanceOf(\Stripe\Recipient::class, $resource); + static::assertInstanceOf(\Stripe\Recipient::class, $resource); } public function testIsSaveable() @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/recipients/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Recipient::class, $resource); + static::assertInstanceOf(\Stripe\Recipient::class, $resource); } public function testIsUpdatable() @@ -61,7 +61,7 @@ public function testIsUpdatable() $resource = Recipient::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Recipient::class, $resource); + static::assertInstanceOf(\Stripe\Recipient::class, $resource); } public function testIsDeletable() @@ -72,6 +72,6 @@ public function testIsDeletable() '/v1/recipients/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Recipient::class, $resource); + static::assertInstanceOf(\Stripe\Recipient::class, $resource); } } diff --git a/tests/Stripe/RefundTest.php b/tests/Stripe/RefundTest.php index 11eb7be78..2896224e7 100644 --- a/tests/Stripe/RefundTest.php +++ b/tests/Stripe/RefundTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/refunds' ); $resources = Refund::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Refund::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Refund::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/refunds/' . self::TEST_RESOURCE_ID ); $resource = Refund::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Refund::class, $resource); + static::assertInstanceOf(\Stripe\Refund::class, $resource); } public function testIsCreatable() @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = Refund::create([ "charge" => "ch_123" ]); - $this->assertInstanceOf(\Stripe\Refund::class, $resource); + static::assertInstanceOf(\Stripe\Refund::class, $resource); } public function testIsSaveable() @@ -48,7 +48,7 @@ public function testIsSaveable() '/v1/refunds/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Refund::class, $resource); + static::assertInstanceOf(\Stripe\Refund::class, $resource); } public function testIsUpdatable() @@ -60,6 +60,6 @@ public function testIsUpdatable() $resource = Refund::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Refund::class, $resource); + static::assertInstanceOf(\Stripe\Refund::class, $resource); } } diff --git a/tests/Stripe/Reporting/ReportRunTest.php b/tests/Stripe/Reporting/ReportRunTest.php index 8bed9bd9d..842aeb2bb 100644 --- a/tests/Stripe/Reporting/ReportRunTest.php +++ b/tests/Stripe/Reporting/ReportRunTest.php @@ -21,7 +21,7 @@ public function testIsCreatable() $params ); $resource = ReportRun::create($params); - $this->assertInstanceOf(\Stripe\Reporting\ReportRun::class, $resource); + static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $resource); } public function testIsListable() @@ -31,8 +31,8 @@ public function testIsListable() '/v1/reporting/report_runs' ); $resources = ReportRun::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Reporting\ReportRun::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $resources->data[0]); } public function testIsRetrievable() @@ -42,6 +42,6 @@ public function testIsRetrievable() '/v1/reporting/report_runs/' . self::TEST_RESOURCE_ID ); $resource = ReportRun::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Reporting\ReportRun::class, $resource); + static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $resource); } } diff --git a/tests/Stripe/Reporting/ReportTypeTest.php b/tests/Stripe/Reporting/ReportTypeTest.php index 9b6c20c1d..3486d7d75 100644 --- a/tests/Stripe/Reporting/ReportTypeTest.php +++ b/tests/Stripe/Reporting/ReportTypeTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/reporting/report_types' ); $resources = ReportType::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Reporting\ReportType::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Reporting\ReportType::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,6 +24,6 @@ public function testIsRetrievable() '/v1/reporting/report_types/' . self::TEST_RESOURCE_ID ); $resource = ReportType::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Reporting\ReportType::class, $resource); + static::assertInstanceOf(\Stripe\Reporting\ReportType::class, $resource); } } diff --git a/tests/Stripe/ReviewTest.php b/tests/Stripe/ReviewTest.php index c5172b95d..aa9fb8ace 100644 --- a/tests/Stripe/ReviewTest.php +++ b/tests/Stripe/ReviewTest.php @@ -14,7 +14,7 @@ public function testIsApprovable() '/v1/reviews/' . self::TEST_RESOURCE_ID . '/approve' ); $resource->approve(); - $this->assertInstanceOf(\Stripe\Review::class, $resource); + static::assertInstanceOf(\Stripe\Review::class, $resource); } public function testIsListable() @@ -24,8 +24,8 @@ public function testIsListable() '/v1/reviews' ); $resources = Review::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Review::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Review::class, $resources->data[0]); } public function testIsRetrievable() @@ -35,6 +35,6 @@ public function testIsRetrievable() '/v1/reviews/' . self::TEST_RESOURCE_ID ); $resource = Review::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Review::class, $resource); + static::assertInstanceOf(\Stripe\Review::class, $resource); } } diff --git a/tests/Stripe/SKUTest.php b/tests/Stripe/SKUTest.php index a190aabb4..c7151fbc3 100644 --- a/tests/Stripe/SKUTest.php +++ b/tests/Stripe/SKUTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/skus' ); $resources = SKU::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\SKU::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\SKU::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/skus/' . self::TEST_RESOURCE_ID ); $resource = SKU::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\SKU::class, $resource); + static::assertInstanceOf(\Stripe\SKU::class, $resource); } public function testIsCreatable() @@ -42,7 +42,7 @@ public function testIsCreatable() 'price' => 100, 'product' => "prod_123" ]); - $this->assertInstanceOf(\Stripe\SKU::class, $resource); + static::assertInstanceOf(\Stripe\SKU::class, $resource); } public function testIsSaveable() @@ -54,7 +54,7 @@ public function testIsSaveable() '/v1/skus/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\SKU::class, $resource); + static::assertInstanceOf(\Stripe\SKU::class, $resource); } public function testIsUpdatable() @@ -66,7 +66,7 @@ public function testIsUpdatable() $resource = SKU::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\SKU::class, $resource); + static::assertInstanceOf(\Stripe\SKU::class, $resource); } public function testIsDeletable() @@ -77,6 +77,6 @@ public function testIsDeletable() '/v1/skus/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\SKU::class, $resource); + static::assertInstanceOf(\Stripe\SKU::class, $resource); } } diff --git a/tests/Stripe/SetupIntentTest.php b/tests/Stripe/SetupIntentTest.php index 9e68dd6cb..d0b8bb65b 100644 --- a/tests/Stripe/SetupIntentTest.php +++ b/tests/Stripe/SetupIntentTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/setup_intents' ); $resources = SetupIntent::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\SetupIntent::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\SetupIntent::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/setup_intents/' . self::TEST_RESOURCE_ID ); $resource = SetupIntent::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\SetupIntent::class, $resource); + static::assertInstanceOf(\Stripe\SetupIntent::class, $resource); } public function testIsCreatable() @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = SetupIntent::create([ 'payment_method_types' => ['card'], ]); - $this->assertInstanceOf(\Stripe\SetupIntent::class, $resource); + static::assertInstanceOf(\Stripe\SetupIntent::class, $resource); } public function testIsSaveable() @@ -48,7 +48,7 @@ public function testIsSaveable() '/v1/setup_intents/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\SetupIntent::class, $resource); + static::assertInstanceOf(\Stripe\SetupIntent::class, $resource); } public function testIsUpdatable() @@ -63,7 +63,7 @@ public function testIsUpdatable() "metadata" => ["key" => "value"], ] ); - $this->assertInstanceOf(\Stripe\SetupIntent::class, $resource); + static::assertInstanceOf(\Stripe\SetupIntent::class, $resource); } public function testIsCancelable() @@ -74,7 +74,7 @@ public function testIsCancelable() '/v1/setup_intents/' . self::TEST_RESOURCE_ID . '/cancel' ); $resource->cancel(); - $this->assertInstanceOf(\Stripe\SetupIntent::class, $resource); + static::assertInstanceOf(\Stripe\SetupIntent::class, $resource); } public function testIsConfirmable() @@ -85,6 +85,6 @@ public function testIsConfirmable() '/v1/setup_intents/' . self::TEST_RESOURCE_ID . '/confirm' ); $resource->confirm(); - $this->assertInstanceOf(\Stripe\SetupIntent::class, $resource); + static::assertInstanceOf(\Stripe\SetupIntent::class, $resource); } } diff --git a/tests/Stripe/Sigma/ScheduledQueryRunTest.php b/tests/Stripe/Sigma/ScheduledQueryRunTest.php index a7fa7fa34..1d345fbf4 100644 --- a/tests/Stripe/Sigma/ScheduledQueryRunTest.php +++ b/tests/Stripe/Sigma/ScheduledQueryRunTest.php @@ -9,13 +9,13 @@ class ScheduledQueryRunTest extends \Stripe\TestCase public function testIsListable() { $resources = ScheduledQueryRun::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $resources->data[0]); } public function testIsRetrievable() { $resource = ScheduledQueryRun::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $resource); + static::assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $resource); } } diff --git a/tests/Stripe/SourceTest.php b/tests/Stripe/SourceTest.php index bf577f1da..d0089f6ca 100644 --- a/tests/Stripe/SourceTest.php +++ b/tests/Stripe/SourceTest.php @@ -13,7 +13,7 @@ public function testIsRetrievable() '/v1/sources/' . self::TEST_RESOURCE_ID ); $resource = Source::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Source::class, $resource); + static::assertInstanceOf(\Stripe\Source::class, $resource); } public function testIsCreatable() @@ -25,7 +25,7 @@ public function testIsCreatable() $resource = Source::create([ "type" => "card" ]); - $this->assertInstanceOf(\Stripe\Source::class, $resource); + static::assertInstanceOf(\Stripe\Source::class, $resource); } public function testIsSaveable() @@ -37,7 +37,7 @@ public function testIsSaveable() '/v1/sources/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Source::class, $resource); + static::assertInstanceOf(\Stripe\Source::class, $resource); } public function testIsUpdatable() @@ -49,7 +49,7 @@ public function testIsUpdatable() $resource = Source::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Source::class, $resource); + static::assertInstanceOf(\Stripe\Source::class, $resource); } public function testCanSaveCardExpiryDate() @@ -84,8 +84,8 @@ public function testCanSaveCardExpiryDate() $source->card->exp_year = 2022; $source->save(); - $this->assertSame(12, $source->card->exp_month); - $this->assertSame(2022, $source->card->exp_year); + static::assertSame(12, $source->card->exp_month); + static::assertSame(2022, $source->card->exp_year); } public function testIsDetachableWhenAttached() @@ -97,7 +97,7 @@ public function testIsDetachableWhenAttached() '/v1/customers/cus_123/sources/' . $resource->id ); $resource->detach(); - $this->assertInstanceOf(\Stripe\Source::class, $resource); + static::assertInstanceOf(\Stripe\Source::class, $resource); } public function testIsNotDetachableWhenUnattached() @@ -116,8 +116,8 @@ public function testCanListSourceTransactionsDeprecated() '/v1/sources/' . $source->id . "/source_transactions" ); $resources = $source->sourceTransactions(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\SourceTransaction::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\SourceTransaction::class, $resources->data[0]); } public function testCanListSourceTransactions() @@ -127,8 +127,8 @@ public function testCanListSourceTransactions() '/v1/sources/' . self::TEST_RESOURCE_ID . "/source_transactions" ); $resources = Source::allSourceTransactions(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\SourceTransaction::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\SourceTransaction::class, $resources->data[0]); } public function testCanVerify() @@ -139,6 +139,6 @@ public function testCanVerify() '/v1/sources/' . $resource->id . "/verify" ); $resource->verify(["values" => [32, 45]]); - $this->assertInstanceOf(\Stripe\Source::class, $resource); + static::assertInstanceOf(\Stripe\Source::class, $resource); } } diff --git a/tests/Stripe/StripeObjectTest.php b/tests/Stripe/StripeObjectTest.php index 9a6be9f4f..a21d57b3a 100644 --- a/tests/Stripe/StripeObjectTest.php +++ b/tests/Stripe/StripeObjectTest.php @@ -31,59 +31,59 @@ public function testArrayAccessorsSemantics() { $s = new StripeObject(); $s['foo'] = 'a'; - $this->assertSame($s['foo'], 'a'); - $this->assertTrue(isset($s['foo'])); + static::assertSame($s['foo'], 'a'); + static::assertTrue(isset($s['foo'])); unset($s['foo']); - $this->assertFalse(isset($s['foo'])); + static::assertFalse(isset($s['foo'])); } public function testNormalAccessorsSemantics() { $s = new StripeObject(); $s->foo = 'a'; - $this->assertSame($s->foo, 'a'); - $this->assertTrue(isset($s->foo)); + static::assertSame($s->foo, 'a'); + static::assertTrue(isset($s->foo)); unset($s->foo); - $this->assertFalse(isset($s->foo)); + static::assertFalse(isset($s->foo)); } public function testArrayAccessorsMatchNormalAccessors() { $s = new StripeObject(); $s->foo = 'a'; - $this->assertSame($s['foo'], 'a'); + static::assertSame($s['foo'], 'a'); $s['bar'] = 'b'; - $this->assertSame($s->bar, 'b'); + static::assertSame($s->bar, 'b'); } public function testCount() { $s = new StripeObject(); - $this->assertCount(0, $s); + static::assertCount(0, $s); $s['key1'] = 'value1'; - $this->assertCount(1, $s); + static::assertCount(1, $s); $s['key2'] = 'value2'; - $this->assertCount(2, $s); + static::assertCount(2, $s); unset($s['key1']); - $this->assertCount(1, $s); + static::assertCount(1, $s); } public function testKeys() { $s = new StripeObject(); $s->foo = 'bar'; - $this->assertSame($s->keys(), ['foo']); + static::assertSame($s->keys(), ['foo']); } public function testValues() { $s = new StripeObject(); $s->foo = 'bar'; - $this->assertSame($s->values(), ['bar']); + static::assertSame($s->values(), ['bar']); } public function testToArray() @@ -97,8 +97,8 @@ public function testToArray() $converted = $s->toArray(); - $this->assertInternalType('array', $converted); - $this->assertEquals($array, $converted); + static::assertInternalType('array', $converted); + static::assertEquals($array, $converted); } public function testToArrayRecursive() @@ -122,7 +122,7 @@ public function testToArrayRecursive() 'list' => [$nestedArray], ]; - $this->assertEquals($expected, $obj->toArray()); + static::assertEquals($expected, $obj->toArray()); } public function testNonexistentProperty() @@ -132,9 +132,9 @@ public function testNonexistentProperty() try { $s = new StripeObject(); - $this->assertNull($s->nonexistent); + static::assertNull($s->nonexistent); - $this->assertRegExp( + static::assertRegExp( "/Stripe Notice: Undefined property of Stripe\\\\StripeObject instance: nonexistent/", \stream_get_contents($capture) ); @@ -147,7 +147,7 @@ public function testNonexistentProperty() public function testPropertyDoesNotExists() { $s = new StripeObject(); - $this->assertNull($s['nonexistent']); + static::assertNull($s['nonexistent']); } public function testJsonEncode() @@ -155,7 +155,7 @@ public function testJsonEncode() $s = new StripeObject(); $s->foo = 'a'; - $this->assertEquals('{"foo":"a"}', \json_encode($s)); + static::assertEquals('{"foo":"a"}', \json_encode($s)); } public function testToString() @@ -169,7 +169,7 @@ public function testToString() "foo": "a" } EOS; - $this->assertEquals($expected, $string); + static::assertEquals($expected, $string); } public function testReplaceNewNestedUpdatable() @@ -177,9 +177,9 @@ public function testReplaceNewNestedUpdatable() $s = new StripeObject(); $s->metadata = ['bar']; - $this->assertSame($s->metadata, ['bar']); + static::assertSame($s->metadata, ['bar']); $s->metadata = ['baz', 'qux']; - $this->assertSame($s->metadata, ['baz', 'qux']); + static::assertSame($s->metadata, ['baz', 'qux']); } public function testSetPermanentAttribute() @@ -201,21 +201,21 @@ public function testSetEmptyStringValue() public function testSerializeParametersOnEmptyObject() { $obj = StripeObject::constructFrom([]); - $this->assertSame([], $obj->serializeParameters()); + static::assertSame([], $obj->serializeParameters()); } public function testSerializeParametersOnNewObjectWithSubObject() { $obj = new StripeObject(); $obj->metadata = ['foo' => 'bar']; - $this->assertSame(['metadata' => ['foo' => 'bar']], $obj->serializeParameters()); + static::assertSame(['metadata' => ['foo' => 'bar']], $obj->serializeParameters()); } public function testSerializeParametersOnBasicObject() { $obj = StripeObject::constructFrom(['foo' => null]); $obj->updateAttributes(['foo' => 'bar']); - $this->assertSame(['foo' => 'bar'], $obj->serializeParameters()); + static::assertSame(['foo' => 'bar'], $obj->serializeParameters()); } public function testSerializeParametersOnMoreComplexObject() @@ -227,7 +227,7 @@ public function testSerializeParametersOnMoreComplexObject() ]), ]); $obj->foo->bar = 'newbar'; - $this->assertSame(['foo' => ['bar' => 'newbar']], $obj->serializeParameters()); + static::assertSame(['foo' => ['bar' => 'newbar']], $obj->serializeParameters()); } public function testSerializeParametersOnArray() @@ -236,7 +236,7 @@ public function testSerializeParametersOnArray() 'foo' => null, ]); $obj->foo = ['new-value']; - $this->assertSame(['foo' => ['new-value']], $obj->serializeParameters()); + static::assertSame(['foo' => ['new-value']], $obj->serializeParameters()); } public function testSerializeParametersOnArrayThatShortens() @@ -245,7 +245,7 @@ public function testSerializeParametersOnArrayThatShortens() 'foo' => ['0-index', '1-index', '2-index'], ]); $obj->foo = ['new-value']; - $this->assertSame(['foo' => ['new-value']], $obj->serializeParameters()); + static::assertSame(['foo' => ['new-value']], $obj->serializeParameters()); } public function testSerializeParametersOnArrayThatLengthens() @@ -254,7 +254,7 @@ public function testSerializeParametersOnArrayThatLengthens() 'foo' => ['0-index', '1-index', '2-index'], ]); $obj->foo = \array_fill(0, 4, 'new-value'); - $this->assertSame(['foo' => \array_fill(0, 4, 'new-value')], $obj->serializeParameters()); + static::assertSame(['foo' => \array_fill(0, 4, 'new-value')], $obj->serializeParameters()); } public function testSerializeParametersOnArrayOfHashes() @@ -265,7 +265,7 @@ public function testSerializeParametersOnArrayOfHashes() ]; $obj->foo[0]->bar = 'baz'; - $this->assertSame(['foo' => [['bar' => 'baz']]], $obj->serializeParameters()); + static::assertSame(['foo' => [['bar' => 'baz']]], $obj->serializeParameters()); } public function testSerializeParametersDoesNotIncludeUnchangedValues() @@ -273,7 +273,7 @@ public function testSerializeParametersDoesNotIncludeUnchangedValues() $obj = StripeObject::constructFrom([ 'foo' => null, ]); - $this->assertSame([], $obj->serializeParameters()); + static::assertSame([], $obj->serializeParameters()); } public function testSerializeParametersOnUnchangedArray() @@ -282,7 +282,7 @@ public function testSerializeParametersOnUnchangedArray() 'foo' => ['0-index', '1-index', '2-index'], ]); $obj->foo = ['0-index', '1-index', '2-index']; - $this->assertSame([], $obj->serializeParameters()); + static::assertSame([], $obj->serializeParameters()); } public function testSerializeParametersWithStripeObject() @@ -291,7 +291,7 @@ public function testSerializeParametersWithStripeObject() $obj->metadata = StripeObject::constructFrom(['foo' => 'bar']); $serialized = $obj->serializeParameters(); - $this->assertSame(['foo' => 'bar'], $serialized['metadata']); + static::assertSame(['foo' => 'bar'], $serialized['metadata']); } public function testSerializeParametersOnReplacedStripeObject() @@ -302,7 +302,7 @@ public function testSerializeParametersOnReplacedStripeObject() $obj->source = StripeObject::constructFrom(['baz' => 'foo']); $serialized = $obj->serializeParameters(); - $this->assertSame(['baz' => 'foo'], $serialized['source']); + static::assertSame(['baz' => 'foo'], $serialized['source']); } public function testSerializeParametersOnReplacedStripeObjectWhichIsMetadata() @@ -313,7 +313,7 @@ public function testSerializeParametersOnReplacedStripeObjectWhichIsMetadata() $obj->metadata = StripeObject::constructFrom(['baz' => 'foo']); $serialized = $obj->serializeParameters(); - $this->assertSame(['bar' => '', 'baz' => 'foo'], $serialized['metadata']); + static::assertSame(['bar' => '', 'baz' => 'foo'], $serialized['metadata']); } public function testSerializeParametersOnArrayOfStripeObjects() @@ -324,7 +324,7 @@ public function testSerializeParametersOnArrayOfStripeObjects() ]; $serialized = $obj->serializeParameters(); - $this->assertSame([['foo' => 'bar']], $serialized['metadata']); + static::assertSame([['foo' => 'bar']], $serialized['metadata']); } public function testSerializeParametersOnSetApiResource() @@ -337,7 +337,7 @@ public function testSerializeParametersOnSetApiResource() $obj->customer = $customer; $serialized = $obj->serializeParameters(); - $this->assertSame(['customer' => $customer], $serialized); + static::assertSame(['customer' => $customer], $serialized); } public function testSerializeParametersOnNotSetApiResource() @@ -346,7 +346,7 @@ public function testSerializeParametersOnNotSetApiResource() $obj = StripeObject::constructFrom(['customer' => $customer]); $serialized = $obj->serializeParameters(); - $this->assertSame([], $serialized); + static::assertSame([], $serialized); } public function testSerializeParametersOnApiResourceFlaggedWithSaveWithParent() @@ -357,7 +357,7 @@ public function testSerializeParametersOnApiResourceFlaggedWithSaveWithParent() $obj = StripeObject::constructFrom(['customer' => $customer]); $serialized = $obj->serializeParameters(); - $this->assertSame(['customer' => []], $serialized); + static::assertSame(['customer' => []], $serialized); } public function testSerializeParametersRaisesExceotionOnOtherEmbeddedApiResources() @@ -372,15 +372,15 @@ public function testSerializeParametersRaisesExceotionOnOtherEmbeddedApiResource try { $serialized = $obj->serializeParameters(); - $this->fail("Did not raise error"); + static::fail("Did not raise error"); } catch (\InvalidArgumentException $e) { - $this->assertSame( + static::assertSame( "Cannot save property `customer` containing an API resource of type Stripe\\Customer. " . "It doesn't appear to be persisted and is not marked as `saveWithParent`.", $e->getMessage() ); } catch (\Exception $e) { - $this->fail("Unexpected exception: " . \get_class($e)); + static::fail("Unexpected exception: " . \get_class($e)); } } @@ -394,7 +394,7 @@ public function testSerializeParametersForce() ]); $serialized = $obj->serializeParameters(true); - $this->assertSame(['id' => 'id', 'metadata' => ['bar' => 'foo']], $serialized); + static::assertSame(['id' => 'id', 'metadata' => ['bar' => 'foo']], $serialized); } public function testDirty() @@ -411,7 +411,7 @@ public function testDirty() $obj->dirty(); $serialized = $obj->serializeParameters(); - $this->assertSame(['id' => 'id', 'metadata' => ['bar' => 'foo']], $serialized); + static::assertSame(['id' => 'id', 'metadata' => ['bar' => 'foo']], $serialized); } public function testDeepCopy() @@ -439,66 +439,66 @@ public function testDeepCopy() // we can't compare the hashes directly because they have embedded // objects which are different from each other - $this->assertEquals($values["id"], $copyValues["id"]); - $this->assertEquals($values["name"], $copyValues["name"]); - $this->assertEquals(\count($values["arr"]), \count($copyValues["arr"])); + static::assertEquals($values["id"], $copyValues["id"]); + static::assertEquals($values["name"], $copyValues["name"]); + static::assertEquals(\count($values["arr"]), \count($copyValues["arr"])); // internal values of the copied StripeObject should be the same, // but the object itself should be new (hence the assertNotSame) - $this->assertEquals($values["arr"][0]["id"], $copyValues["arr"][0]["id"]); - $this->assertNotSame($values["arr"][0], $copyValues["arr"][0]); + static::assertEquals($values["arr"][0]["id"], $copyValues["arr"][0]["id"]); + static::assertNotSame($values["arr"][0], $copyValues["arr"][0]); // likewise, the Util\RequestOptions instance in _opts should have // copied values but be a new instance - $this->assertEquals( + static::assertEquals( $this->optsReflector->getValue($values["arr"][0]), $this->optsReflector->getValue($copyValues["arr"][0]) ); - $this->assertNotSame( + static::assertNotSame( $this->optsReflector->getValue($values["arr"][0]), $this->optsReflector->getValue($copyValues["arr"][0]) ); // scalars however, can be compared - $this->assertEquals($values["arr"][1], $copyValues["arr"][1]); - $this->assertEquals($values["arr"][2], $copyValues["arr"][2]); + static::assertEquals($values["arr"][1], $copyValues["arr"][1]); + static::assertEquals($values["arr"][2], $copyValues["arr"][2]); // and a similar story with the hash - $this->assertEquals($values["map"]["0"]["id"], $copyValues["map"]["0"]["id"]); - $this->assertNotSame($values["map"]["0"], $copyValues["map"]["0"]); - $this->assertNotSame( + static::assertEquals($values["map"]["0"]["id"], $copyValues["map"]["0"]["id"]); + static::assertNotSame($values["map"]["0"], $copyValues["map"]["0"]); + static::assertNotSame( $this->optsReflector->getValue($values["arr"][0]), $this->optsReflector->getValue($copyValues["arr"][0]) ); - $this->assertEquals( + static::assertEquals( $this->optsReflector->getValue($values["map"]["0"]), $this->optsReflector->getValue($copyValues["map"]["0"]) ); - $this->assertNotSame( + static::assertNotSame( $this->optsReflector->getValue($values["map"]["0"]), $this->optsReflector->getValue($copyValues["map"]["0"]) ); - $this->assertEquals($values["map"]["1"], $copyValues["map"]["1"]); - $this->assertEquals($values["map"]["2"], $copyValues["map"]["2"]); + static::assertEquals($values["map"]["1"], $copyValues["map"]["1"]); + static::assertEquals($values["map"]["2"], $copyValues["map"]["2"]); } public function testDeepCopyMaintainClass() { $charge = Charge::constructFrom(["id" => 1], null); $copyCharge = $this->deepCopyReflector->invoke(null, $charge); - $this->assertEquals(\get_class($charge), \get_class($copyCharge)); + static::assertEquals(\get_class($charge), \get_class($copyCharge)); } public function testIsDeleted() { $obj = StripeObject::constructFrom([]); - $this->assertFalse($obj->isDeleted()); + static::assertFalse($obj->isDeleted()); $obj = StripeObject::constructFrom(['deleted' => false]); - $this->assertFalse($obj->isDeleted()); + static::assertFalse($obj->isDeleted()); $obj = StripeObject::constructFrom(['deleted' => true]); - $this->assertTrue($obj->isDeleted()); + static::assertTrue($obj->isDeleted()); } public function testDeserializeEmptyMetadata() @@ -507,7 +507,7 @@ public function testDeserializeEmptyMetadata() 'metadata' => [], ]); - $this->assertInstanceOf(\Stripe\StripeObject::class, $obj->metadata); + static::assertInstanceOf(\Stripe\StripeObject::class, $obj->metadata); } public function testDeserializeMetadataWithKeyNamedMetadata() @@ -516,7 +516,7 @@ public function testDeserializeMetadataWithKeyNamedMetadata() 'metadata' => ['metadata' => 'value'], ]); - $this->assertInstanceOf(\Stripe\StripeObject::class, $obj->metadata); - $this->assertEquals("value", $obj->metadata->metadata); + static::assertInstanceOf(\Stripe\StripeObject::class, $obj->metadata); + static::assertEquals("value", $obj->metadata->metadata); } } diff --git a/tests/Stripe/StripeTelemetryTest.php b/tests/Stripe/StripeTelemetryTest.php index e1833d65f..665ed4e94 100644 --- a/tests/Stripe/StripeTelemetryTest.php +++ b/tests/Stripe/StripeTelemetryTest.php @@ -32,12 +32,12 @@ public function testNoTelemetrySentIfNotEnabled() ->setMethods(['request']) ->getMock(); - $stub->expects($this->any()) + $stub->expects(static::any()) ->method("request") ->with( - $this->anything(), - $this->anything(), - $this->callback(function ($headers) use (&$requestheaders) { + static::anything(), + static::anything(), + static::callback(function ($headers) use (&$requestheaders) { foreach ($headers as $index => $header) { // capture the requested headers and format back to into an assoc array $components = \explode(": ", $header, 2); @@ -46,19 +46,19 @@ public function testNoTelemetrySentIfNotEnabled() return true; }), - $this->anything(), - $this->anything() + static::anything(), + static::anything() )->willReturn([self::FAKE_VALID_RESPONSE, 200, ["request-id" => "123"]]); ApiRequestor::setHttpClient($stub); // make one request to capture its result Charge::all(); - $this->assertArrayNotHasKey('X-Stripe-Client-Telemetry', $requestheaders); + static::assertArrayNotHasKey('X-Stripe-Client-Telemetry', $requestheaders); // make another request and verify telemetry isn't sent Charge::all(); - $this->assertArrayNotHasKey('X-Stripe-Client-Telemetry', $requestheaders); + static::assertArrayNotHasKey('X-Stripe-Client-Telemetry', $requestheaders); ApiRequestor::setHttpClient(null); } @@ -74,12 +74,12 @@ public function testTelemetrySetIfEnabled() ->setMethods(['request']) ->getMock(); - $stub->expects($this->any()) + $stub->expects(static::any()) ->method("request") ->with( - $this->anything(), - $this->anything(), - $this->callback(function ($headers) use (&$requestheaders) { + static::anything(), + static::anything(), + static::callback(function ($headers) use (&$requestheaders) { // capture the requested headers and format back to into an assoc array foreach ($headers as $index => $header) { $components = \explode(": ", $header, 2); @@ -88,23 +88,23 @@ public function testTelemetrySetIfEnabled() return true; }), - $this->anything(), - $this->anything() + static::anything(), + static::anything() )->willReturn([self::FAKE_VALID_RESPONSE, 200, ["request-id" => ["req_123"]]]); ApiRequestor::setHttpClient($stub); // make one request to capture its result Charge::all(); - $this->assertArrayNotHasKey('X-Stripe-Client-Telemetry', $requestheaders); + static::assertArrayNotHasKey('X-Stripe-Client-Telemetry', $requestheaders); // make another request to send the previous Charge::all(); - $this->assertArrayHasKey('X-Stripe-Client-Telemetry', $requestheaders); + static::assertArrayHasKey('X-Stripe-Client-Telemetry', $requestheaders); $data = \json_decode($requestheaders['X-Stripe-Client-Telemetry'], true); - $this->assertEquals('req_123', $data['last_request_metrics']['request_id']); - $this->assertNotNull($data['last_request_metrics']['request_duration_ms']); + static::assertEquals('req_123', $data['last_request_metrics']['request_id']); + static::assertNotNull($data['last_request_metrics']['request_duration_ms']); ApiRequestor::setHttpClient(null); } diff --git a/tests/Stripe/StripeTest.php b/tests/Stripe/StripeTest.php index d34bd4828..cafa2a32a 100644 --- a/tests/Stripe/StripeTest.php +++ b/tests/Stripe/StripeTest.php @@ -28,6 +28,6 @@ public function restoreOriginalValues() public function testCABundlePathAccessors() { Stripe::setCABundlePath('path/to/ca/bundle'); - $this->assertEquals('path/to/ca/bundle', Stripe::getCABundlePath()); + static::assertEquals('path/to/ca/bundle', Stripe::getCABundlePath()); } } diff --git a/tests/Stripe/SubscriptionItemTest.php b/tests/Stripe/SubscriptionItemTest.php index 47d4ce001..e901059ce 100644 --- a/tests/Stripe/SubscriptionItemTest.php +++ b/tests/Stripe/SubscriptionItemTest.php @@ -18,8 +18,8 @@ public function testIsListable() $resources = SubscriptionItem::all([ "subscription" => "sub_123" ]); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\SubscriptionItem::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resources->data[0]); } public function testIsRetrievable() @@ -29,7 +29,7 @@ public function testIsRetrievable() '/v1/subscription_items/' . self::TEST_RESOURCE_ID ); $resource = SubscriptionItem::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } public function testIsCreatable() @@ -42,7 +42,7 @@ public function testIsCreatable() "plan" => "plan", "subscription" => "sub_123" ]); - $this->assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } public function testIsSaveable() @@ -54,7 +54,7 @@ public function testIsSaveable() '/v1/subscription_items/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } public function testIsUpdatable() @@ -66,7 +66,7 @@ public function testIsUpdatable() $resource = SubscriptionItem::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } public function testIsDeletable() @@ -77,7 +77,7 @@ public function testIsDeletable() '/v1/subscription_items/' . $resource->id ); $resource->delete(); - $this->assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } public function testCanCreateUsageRecord() @@ -101,8 +101,8 @@ public function testCanListUsageRecordSummariesDeprecated() '/v1/subscription_items/' . $resource->id . "/usage_record_summaries" ); $resources = $resource->usageRecordSummaries(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\UsageRecordSummary::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\UsageRecordSummary::class, $resources->data[0]); } public function testCanListUsageRecordSummaries() @@ -112,7 +112,7 @@ public function testCanListUsageRecordSummaries() '/v1/subscription_items/' . self::TEST_RESOURCE_ID . "/usage_record_summaries" ); $resources =SubscriptionItem::allUsageRecordSummaries(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\UsageRecordSummary::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\UsageRecordSummary::class, $resources->data[0]); } } diff --git a/tests/Stripe/SubscriptionScheduleTest.php b/tests/Stripe/SubscriptionScheduleTest.php index 8f6583166..e8c2acee7 100644 --- a/tests/Stripe/SubscriptionScheduleTest.php +++ b/tests/Stripe/SubscriptionScheduleTest.php @@ -14,8 +14,8 @@ public function testIsListable() '/v1/subscription_schedules' ); $resources = SubscriptionSchedule::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resources->data[0]); } public function testIsRetrievable() @@ -25,7 +25,7 @@ public function testIsRetrievable() '/v1/subscription_schedules/' . self::TEST_RESOURCE_ID ); $resource = SubscriptionSchedule::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); } public function testIsCreatable() @@ -43,7 +43,7 @@ public function testIsCreatable() ], ], ]); - $this->assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); } public function testIsSaveable() @@ -55,7 +55,7 @@ public function testIsSaveable() '/v1/subscription_schedules/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); } public function testIsUpdatable() @@ -67,7 +67,7 @@ public function testIsUpdatable() $resource = SubscriptionSchedule::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); } public function testIsCancelable() @@ -79,7 +79,7 @@ public function testIsCancelable() [] ); $resource->cancel([]); - $this->assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); } public function testIsReleaseable() @@ -91,6 +91,6 @@ public function testIsReleaseable() [] ); $resource->release([]); - $this->assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); + static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $resource); } } diff --git a/tests/Stripe/SubscriptionTest.php b/tests/Stripe/SubscriptionTest.php index 06ad9b665..6537cda5b 100644 --- a/tests/Stripe/SubscriptionTest.php +++ b/tests/Stripe/SubscriptionTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/subscriptions' ); $resources = Subscription::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Subscription::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Subscription::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/subscriptions/' . self::TEST_RESOURCE_ID ); $resource = Subscription::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); + static::assertInstanceOf(\Stripe\Subscription::class, $resource); } public function testIsCreatable() @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = Subscription::create([ "customer" => "cus_123" ]); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); + static::assertInstanceOf(\Stripe\Subscription::class, $resource); } public function testIsSaveable() @@ -48,7 +48,7 @@ public function testIsSaveable() '/v1/subscriptions/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); + static::assertInstanceOf(\Stripe\Subscription::class, $resource); } public function testIsUpdatable() @@ -60,7 +60,7 @@ public function testIsUpdatable() $resource = Subscription::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); + static::assertInstanceOf(\Stripe\Subscription::class, $resource); } public function testIsCancelable() @@ -72,7 +72,7 @@ public function testIsCancelable() [] ); $resource->cancel([]); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); + static::assertInstanceOf(\Stripe\Subscription::class, $resource); } public function testCanDeleteDiscount() @@ -83,7 +83,7 @@ public function testCanDeleteDiscount() '/v1/subscriptions/' . $resource->id . '/discount' ); $resource->deleteDiscount(); - $this->assertInstanceOf(\Stripe\Subscription::class, $resource); + static::assertInstanceOf(\Stripe\Subscription::class, $resource); } public function testSerializeParametersItems() @@ -105,6 +105,6 @@ public function testSerializeParametersItems() 1 => ['plan' => 'plan_bar'], ], ]; - $this->assertSame($expected, $obj->serializeParameters()); + static::assertSame($expected, $obj->serializeParameters()); } } diff --git a/tests/Stripe/TaxIdTest.php b/tests/Stripe/TaxIdTest.php index 3040d3b0e..39adf7ece 100644 --- a/tests/Stripe/TaxIdTest.php +++ b/tests/Stripe/TaxIdTest.php @@ -10,7 +10,7 @@ class TaxIdTest extends TestCase public function testHasCorrectUrl() { $resource = \Stripe\Customer::retrieveTaxId(self::TEST_CUSTOMER_ID, self::TEST_RESOURCE_ID); - $this->assertSame( + static::assertSame( "/v1/customers/" . self::TEST_CUSTOMER_ID . "/tax_ids/" . self::TEST_RESOURCE_ID, $resource->instanceUrl() ); @@ -24,6 +24,6 @@ public function testIsDeletable() '/v1/customers/' . self::TEST_CUSTOMER_ID . '/tax_ids/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\TaxId::class, $resource); + static::assertInstanceOf(\Stripe\TaxId::class, $resource); } } diff --git a/tests/Stripe/TaxRateTest.php b/tests/Stripe/TaxRateTest.php index 4a7dea800..85e5c4f3b 100644 --- a/tests/Stripe/TaxRateTest.php +++ b/tests/Stripe/TaxRateTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/tax_rates' ); $resources = TaxRate::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\TaxRate::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\TaxRate::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/tax_rates/' . self::TEST_RESOURCE_ID ); $resource = TaxRate::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\TaxRate::class, $resource); + static::assertInstanceOf(\Stripe\TaxRate::class, $resource); } public function testIsCreatable() @@ -38,7 +38,7 @@ public function testIsCreatable() "inclusive" => false, "percentage" => 10.15, ]); - $this->assertInstanceOf(\Stripe\TaxRate::class, $resource); + static::assertInstanceOf(\Stripe\TaxRate::class, $resource); } public function testIsSaveable() @@ -50,7 +50,7 @@ public function testIsSaveable() '/v1/tax_rates/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\TaxRate::class, $resource); + static::assertInstanceOf(\Stripe\TaxRate::class, $resource); } public function testIsUpdatable() @@ -62,6 +62,6 @@ public function testIsUpdatable() $resource = TaxRate::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\TaxRate::class, $resource); + static::assertInstanceOf(\Stripe\TaxRate::class, $resource); } } diff --git a/tests/Stripe/Terminal/ConnectionTokenTest.php b/tests/Stripe/Terminal/ConnectionTokenTest.php index 9283b6d98..db6dfda4e 100644 --- a/tests/Stripe/Terminal/ConnectionTokenTest.php +++ b/tests/Stripe/Terminal/ConnectionTokenTest.php @@ -11,6 +11,6 @@ public function testIsCreatable() '/v1/terminal/connection_tokens' ); $resource = ConnectionToken::create(); - $this->assertInstanceOf(\Stripe\Terminal\ConnectionToken::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\ConnectionToken::class, $resource); } } diff --git a/tests/Stripe/Terminal/LocationTest.php b/tests/Stripe/Terminal/LocationTest.php index fed2deecc..8170c18ef 100644 --- a/tests/Stripe/Terminal/LocationTest.php +++ b/tests/Stripe/Terminal/LocationTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/terminal/locations' ); $resources = Location::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Terminal\Location::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Terminal\Location::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/terminal/locations/' . self::TEST_RESOURCE_ID ); $resource = Location::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Terminal\Location::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); } public function testIsSaveable() @@ -37,7 +37,7 @@ public function testIsSaveable() '/v1/terminal/locations/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Terminal\Location::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); } public function testIsUpdatable() @@ -50,7 +50,7 @@ public function testIsUpdatable() $resource = Location::update(self::TEST_RESOURCE_ID, [ "display_name" => "new-name", ]); - $this->assertInstanceOf(\Stripe\Terminal\Location::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); } public function testIsCreatable() @@ -79,7 +79,7 @@ public function testIsCreatable() "city" => "San Francisco" ] ]); - $this->assertInstanceOf(\Stripe\Terminal\Location::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); } public function testIsDeletable() @@ -90,6 +90,6 @@ public function testIsDeletable() '/v1/terminal/locations/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Terminal\Location::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); } } diff --git a/tests/Stripe/Terminal/ReaderTest.php b/tests/Stripe/Terminal/ReaderTest.php index 7a0a4548d..00b4e97ec 100644 --- a/tests/Stripe/Terminal/ReaderTest.php +++ b/tests/Stripe/Terminal/ReaderTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/terminal/readers' ); $resources = Reader::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Terminal\Reader::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/terminal/readers/' . self::TEST_RESOURCE_ID ); $resource = Reader::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); } public function testIsSaveable() @@ -37,7 +37,7 @@ public function testIsSaveable() '/v1/terminal/readers/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); } public function testIsUpdatable() @@ -50,7 +50,7 @@ public function testIsUpdatable() $resource = Reader::update(self::TEST_RESOURCE_ID, [ "label" => "new-name", ]); - $this->assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); } public function testIsCreatable() @@ -61,7 +61,7 @@ public function testIsCreatable() ["registration_code" => "a-b-c"] ); $resource = Reader::create(['registration_code' => 'a-b-c']); - $this->assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); } public function testIsDeletable() @@ -72,6 +72,6 @@ public function testIsDeletable() '/v1/terminal/readers/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource); } } diff --git a/tests/Stripe/ThreeDSecureTest.php b/tests/Stripe/ThreeDSecureTest.php index 4e304fb7b..4cd22b26a 100644 --- a/tests/Stripe/ThreeDSecureTest.php +++ b/tests/Stripe/ThreeDSecureTest.php @@ -13,7 +13,7 @@ public function testIsRetrievable() '/v1/3d_secure/' . self::TEST_RESOURCE_ID ); $resource = ThreeDSecure::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\ThreeDSecure::class, $resource); + static::assertInstanceOf(\Stripe\ThreeDSecure::class, $resource); } public function testIsCreatable() @@ -27,6 +27,6 @@ public function testIsCreatable() "currency" => "usd", "return_url" => "url" ]); - $this->assertInstanceOf(\Stripe\ThreeDSecure::class, $resource); + static::assertInstanceOf(\Stripe\ThreeDSecure::class, $resource); } } diff --git a/tests/Stripe/TokenTest.php b/tests/Stripe/TokenTest.php index 7b1b781f6..90f92d3f6 100644 --- a/tests/Stripe/TokenTest.php +++ b/tests/Stripe/TokenTest.php @@ -13,7 +13,7 @@ public function testIsRetrievable() '/v1/tokens/' . self::TEST_RESOURCE_ID ); $resource = Token::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Token::class, $resource); + static::assertInstanceOf(\Stripe\Token::class, $resource); } public function testIsCreatable() @@ -23,6 +23,6 @@ public function testIsCreatable() '/v1/tokens' ); $resource = Token::create(["card" => "tok_visa"]); - $this->assertInstanceOf(\Stripe\Token::class, $resource); + static::assertInstanceOf(\Stripe\Token::class, $resource); } } diff --git a/tests/Stripe/TopupTest.php b/tests/Stripe/TopupTest.php index f7ffd20cf..9417542ac 100644 --- a/tests/Stripe/TopupTest.php +++ b/tests/Stripe/TopupTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/topups' ); $resources = Topup::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Topup::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Topup::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/topups/' . self::TEST_RESOURCE_ID ); $resource = Topup::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Topup::class, $resource); + static::assertInstanceOf(\Stripe\Topup::class, $resource); } public function testIsCreatable() @@ -40,7 +40,7 @@ public function testIsCreatable() "description" => "description", "statement_descriptor" => "statement descriptor" ]); - $this->assertInstanceOf(\Stripe\Topup::class, $resource); + static::assertInstanceOf(\Stripe\Topup::class, $resource); } public function testIsSaveable() @@ -52,7 +52,7 @@ public function testIsSaveable() '/v1/topups/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Topup::class, $resource); + static::assertInstanceOf(\Stripe\Topup::class, $resource); } public function testIsUpdatable() @@ -64,7 +64,7 @@ public function testIsUpdatable() $resource = Topup::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Topup::class, $resource); + static::assertInstanceOf(\Stripe\Topup::class, $resource); } public function testIsCancelable() @@ -75,6 +75,6 @@ public function testIsCancelable() '/v1/topups/' . self::TEST_RESOURCE_ID . '/cancel' ); $resource = $resource->cancel(); - $this->assertInstanceOf(\Stripe\Topup::class, $resource); + static::assertInstanceOf(\Stripe\Topup::class, $resource); } } diff --git a/tests/Stripe/TransferReversalTest.php b/tests/Stripe/TransferReversalTest.php index 21e9986ef..1788fdf14 100644 --- a/tests/Stripe/TransferReversalTest.php +++ b/tests/Stripe/TransferReversalTest.php @@ -16,6 +16,6 @@ public function testIsSaveable() '/v1/transfers/' . $resource->transfer . '/reversals/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\TransferReversal::class, $resource); + static::assertInstanceOf(\Stripe\TransferReversal::class, $resource); } } diff --git a/tests/Stripe/TransferTest.php b/tests/Stripe/TransferTest.php index e4ea4828e..13a5e0b0f 100644 --- a/tests/Stripe/TransferTest.php +++ b/tests/Stripe/TransferTest.php @@ -14,8 +14,8 @@ public function testIsListable() '/v1/transfers' ); $resources = Transfer::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\Transfer::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\Transfer::class, $resources->data[0]); } public function testIsRetrievable() @@ -25,7 +25,7 @@ public function testIsRetrievable() '/v1/transfers/' . self::TEST_RESOURCE_ID ); $resource = Transfer::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\Transfer::class, $resource); + static::assertInstanceOf(\Stripe\Transfer::class, $resource); } public function testIsCreatable() @@ -39,7 +39,7 @@ public function testIsCreatable() "currency" => "usd", "destination" => "acct_123" ]); - $this->assertInstanceOf(\Stripe\Transfer::class, $resource); + static::assertInstanceOf(\Stripe\Transfer::class, $resource); } public function testIsSaveable() @@ -51,7 +51,7 @@ public function testIsSaveable() '/v1/transfers/' . $resource->id ); $resource->save(); - $this->assertInstanceOf(\Stripe\Transfer::class, $resource); + static::assertInstanceOf(\Stripe\Transfer::class, $resource); } public function testIsUpdatable() @@ -63,7 +63,7 @@ public function testIsUpdatable() $resource = Transfer::update(self::TEST_RESOURCE_ID, [ "metadata" => ["key" => "value"], ]); - $this->assertInstanceOf(\Stripe\Transfer::class, $resource); + static::assertInstanceOf(\Stripe\Transfer::class, $resource); } public function testIsCancelable() @@ -76,8 +76,8 @@ public function testIsCancelable() '/v1/transfers/' . $transfer->id . '/cancel' ); $resource = $transfer->cancel(); - $this->assertInstanceOf(\Stripe\Transfer::class, $resource); - $this->assertSame($resource, $transfer); + static::assertInstanceOf(\Stripe\Transfer::class, $resource); + static::assertSame($resource, $transfer); } public function testCanCreateReversal() @@ -87,7 +87,7 @@ public function testCanCreateReversal() '/v1/transfers/' . self::TEST_RESOURCE_ID . '/reversals' ); $resource = Transfer::createReversal(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\TransferReversal::class, $resource); + static::assertInstanceOf(\Stripe\TransferReversal::class, $resource); } public function testCanRetrieveReversal() @@ -97,7 +97,7 @@ public function testCanRetrieveReversal() '/v1/transfers/' . self::TEST_RESOURCE_ID . '/reversals/' . self::TEST_REVERSAL_ID ); $resource = Transfer::retrieveReversal(self::TEST_RESOURCE_ID, self::TEST_REVERSAL_ID); - $this->assertInstanceOf(\Stripe\TransferReversal::class, $resource); + static::assertInstanceOf(\Stripe\TransferReversal::class, $resource); } public function testCanUpdateReversal() @@ -113,7 +113,7 @@ public function testCanUpdateReversal() "metadata" => ["key" => "value"], ] ); - $this->assertInstanceOf(\Stripe\TransferReversal::class, $resource); + static::assertInstanceOf(\Stripe\TransferReversal::class, $resource); } public function testCanListReversal() @@ -123,7 +123,7 @@ public function testCanListReversal() '/v1/transfers/' . self::TEST_RESOURCE_ID . '/reversals' ); $resources = Transfer::allReversals(self::TEST_RESOURCE_ID); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\TransferReversal::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\TransferReversal::class, $resources->data[0]); } } diff --git a/tests/Stripe/Util/CaseInsensitiveArrayTest.php b/tests/Stripe/Util/CaseInsensitiveArrayTest.php index 9a142e911..eef88ded5 100644 --- a/tests/Stripe/Util/CaseInsensitiveArrayTest.php +++ b/tests/Stripe/Util/CaseInsensitiveArrayTest.php @@ -10,24 +10,24 @@ public function testArrayAccess() $arr["thrEE"] = "3"; - $this->assertSame("1", $arr["one"]); - $this->assertSame("1", $arr["One"]); - $this->assertSame("1", $arr["ONE"]); + static::assertSame("1", $arr["one"]); + static::assertSame("1", $arr["One"]); + static::assertSame("1", $arr["ONE"]); - $this->assertSame("2", $arr["two"]); - $this->assertSame("2", $arr["twO"]); - $this->assertSame("2", $arr["TWO"]); + static::assertSame("2", $arr["two"]); + static::assertSame("2", $arr["twO"]); + static::assertSame("2", $arr["TWO"]); - $this->assertSame("3", $arr["three"]); - $this->assertSame("3", $arr["ThReE"]); - $this->assertSame("3", $arr["THREE"]); + static::assertSame("3", $arr["three"]); + static::assertSame("3", $arr["ThReE"]); + static::assertSame("3", $arr["THREE"]); } public function testCount() { $arr = new CaseInsensitiveArray(["One" => "1", "TWO" => "2"]); - $this->assertCount(2, $arr); + static::assertCount(2, $arr); } public function testIterable() @@ -40,7 +40,7 @@ public function testIterable() $seen[$k] = $v; } - $this->assertSame("1", $seen["one"]); - $this->assertSame("2", $seen["two"]); + static::assertSame("1", $seen["one"]); + static::assertSame("2", $seen["two"]); } } diff --git a/tests/Stripe/Util/DefaultLoggerTest.php b/tests/Stripe/Util/DefaultLoggerTest.php index 9fc47c149..a66755fc6 100644 --- a/tests/Stripe/Util/DefaultLoggerTest.php +++ b/tests/Stripe/Util/DefaultLoggerTest.php @@ -16,7 +16,7 @@ public function testDefaultLogger() $logger = new DefaultLogger(); $logger->error("This is a test message"); - $this->assertRegExp("/This is a test message/", \stream_get_contents($capture)); + static::assertRegExp("/This is a test message/", \stream_get_contents($capture)); } finally { \ini_set('error_log', $origErrorLog); \fclose($capture); diff --git a/tests/Stripe/Util/RequestOptionsTest.php b/tests/Stripe/Util/RequestOptionsTest.php index 57dfa36da..07a350cb2 100644 --- a/tests/Stripe/Util/RequestOptionsTest.php +++ b/tests/Stripe/Util/RequestOptionsTest.php @@ -7,22 +7,22 @@ class RequestOptionsTest extends \Stripe\TestCase public function testStringAPIKey() { $opts = RequestOptions::parse("foo"); - $this->assertSame("foo", $opts->apiKey); - $this->assertSame([], $opts->headers); + static::assertSame("foo", $opts->apiKey); + static::assertSame([], $opts->headers); } public function testNull() { $opts = RequestOptions::parse(null); - $this->assertNull($opts->apiKey); - $this->assertSame([], $opts->headers); + static::assertNull($opts->apiKey); + static::assertSame([], $opts->headers); } public function testEmptyArray() { $opts = RequestOptions::parse([]); - $this->assertNull($opts->apiKey); - $this->assertSame([], $opts->headers); + static::assertNull($opts->apiKey); + static::assertSame([], $opts->headers); } public function testAPIKeyArray() @@ -32,8 +32,8 @@ public function testAPIKeyArray() 'api_key' => 'foo', ] ); - $this->assertSame('foo', $opts->apiKey); - $this->assertSame([], $opts->headers); + static::assertSame('foo', $opts->apiKey); + static::assertSame([], $opts->headers); } public function testIdempotentKeyArray() @@ -43,8 +43,8 @@ public function testIdempotentKeyArray() 'idempotency_key' => 'foo', ] ); - $this->assertNull($opts->apiKey); - $this->assertSame(['Idempotency-Key' => 'foo'], $opts->headers); + static::assertNull($opts->apiKey); + static::assertSame(['Idempotency-Key' => 'foo'], $opts->headers); } public function testKeyArray() @@ -55,8 +55,8 @@ public function testKeyArray() 'api_key' => 'foo' ] ); - $this->assertSame('foo', $opts->apiKey); - $this->assertSame(['Idempotency-Key' => 'foo'], $opts->headers); + static::assertSame('foo', $opts->apiKey); + static::assertSame(['Idempotency-Key' => 'foo'], $opts->headers); } public function testWrongType() @@ -75,21 +75,21 @@ public function testDiscardNonPersistentHeaders() ] ); $opts->discardNonPersistentHeaders(); - $this->assertSame(['Stripe-Account' => 'foo'], $opts->headers); + static::assertSame(['Stripe-Account' => 'foo'], $opts->headers); } public function testDebugInfo() { $opts = RequestOptions::parse(['api_key' => 'sk_test_1234567890abcdefghijklmn']); $debugInfo = \print_r($opts, true); - $this->assertContains("[apiKey] => sk_test_********************klmn", $debugInfo); + static::assertContains("[apiKey] => sk_test_********************klmn", $debugInfo); $opts = RequestOptions::parse(['api_key' => 'sk_1234567890abcdefghijklmn']); $debugInfo = \print_r($opts, true); - $this->assertContains("[apiKey] => sk_********************klmn", $debugInfo); + static::assertContains("[apiKey] => sk_********************klmn", $debugInfo); $opts = RequestOptions::parse(['api_key' => '1234567890abcdefghijklmn']); $debugInfo = \print_r($opts, true); - $this->assertContains("[apiKey] => ********************klmn", $debugInfo); + static::assertContains("[apiKey] => ********************klmn", $debugInfo); } } diff --git a/tests/Stripe/Util/UtilTest.php b/tests/Stripe/Util/UtilTest.php index 220f95a51..74f209b2d 100644 --- a/tests/Stripe/Util/UtilTest.php +++ b/tests/Stripe/Util/UtilTest.php @@ -7,10 +7,10 @@ class UtilTest extends \Stripe\TestCase public function testIsList() { $list = [5, 'nstaoush', []]; - $this->assertTrue(Util::isList($list)); + static::assertTrue(Util::isList($list)); $notlist = [5, 'nstaoush', [], 'bar' => 'baz']; - $this->assertFalse(Util::isList($notlist)); + static::assertFalse(Util::isList($notlist)); } public function testThatPHPHasValueSemanticsForArrays() @@ -19,7 +19,7 @@ public function testThatPHPHasValueSemanticsForArrays() $derived = $original; $derived['php-arrays'] = 'reference-semantics'; - $this->assertSame('value-semantics', $original['php-arrays']); + static::assertSame('value-semantics', $original['php-arrays']); } public function testConvertStripeObjectToArrayIncludesId() @@ -31,22 +31,22 @@ public function testConvertStripeObjectToArrayIncludesId() ], null ); - $this->assertArrayHasKey("id", $customer->toArray()); + static::assertArrayHasKey("id", $customer->toArray()); } public function testUtf8() { // UTF-8 string $x = "\xc3\xa9"; - $this->assertSame(Util::utf8($x), $x); + static::assertSame(Util::utf8($x), $x); // Latin-1 string $x = "\xe9"; - $this->assertSame(Util::utf8($x), "\xc3\xa9"); + static::assertSame(Util::utf8($x), "\xc3\xa9"); // Not a string $x = true; - $this->assertSame(Util::utf8($x), $x); + static::assertSame(Util::utf8($x), $x); } public function testObjectsToIds() @@ -63,7 +63,7 @@ public function testObjectsToIds() 'null_value' => null, ]; - $this->assertSame( + static::assertSame( [ 'foo' => 'bar', 'customer' => 'cus_123', @@ -86,7 +86,7 @@ public function testEncodeParameters() 'g' => [], ]; - $this->assertSame( + static::assertSame( "a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[0]=0&e[1]=1&f=", Util::encodeParameters($params) ); @@ -94,10 +94,10 @@ public function testEncodeParameters() public function testUrlEncode() { - $this->assertSame("foo", Util::urlEncode("foo")); - $this->assertSame("foo%2B", Util::urlEncode("foo+")); - $this->assertSame("foo%26", Util::urlEncode("foo&")); - $this->assertSame("foo[bar]", Util::urlEncode("foo[bar]")); + static::assertSame("foo", Util::urlEncode("foo")); + static::assertSame("foo%2B", Util::urlEncode("foo+")); + static::assertSame("foo%26", Util::urlEncode("foo&")); + static::assertSame("foo[bar]", Util::urlEncode("foo[bar]")); } public function testFlattenParams() @@ -114,7 +114,7 @@ public function testFlattenParams() ], ]; - $this->assertSame( + static::assertSame( [ ['a', 3], ['b', '+foo?'], diff --git a/tests/Stripe/WebhookEndpointTest.php b/tests/Stripe/WebhookEndpointTest.php index aa37122aa..07471d45e 100644 --- a/tests/Stripe/WebhookEndpointTest.php +++ b/tests/Stripe/WebhookEndpointTest.php @@ -13,8 +13,8 @@ public function testIsListable() '/v1/webhook_endpoints' ); $resources = WebhookEndpoint::all(); - $this->assertInternalType('array', $resources->data); - $this->assertInstanceOf(\Stripe\WebhookEndpoint::class, $resources->data[0]); + static::assertInternalType('array', $resources->data); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $resources->data[0]); } public function testIsRetrievable() @@ -24,7 +24,7 @@ public function testIsRetrievable() '/v1/webhook_endpoints/' . self::TEST_RESOURCE_ID ); $resource = WebhookEndpoint::retrieve(self::TEST_RESOURCE_ID); - $this->assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); } public function testIsCreatable() @@ -37,7 +37,7 @@ public function testIsCreatable() 'enabled_events' => ['charge.succeeded'], 'url' => 'https://stripe.com', ]); - $this->assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); } public function testIsSaveable() @@ -49,7 +49,7 @@ public function testIsSaveable() '/v1/webhook_endpoints/' . self::TEST_RESOURCE_ID ); $resource->save(); - $this->assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); } public function testIsUpdatable() @@ -61,7 +61,7 @@ public function testIsUpdatable() $resource = WebhookEndpoint::update(self::TEST_RESOURCE_ID, [ 'enabled_events' => ['charge.succeeded'], ]); - $this->assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); } public function testIsDeletable() @@ -72,6 +72,6 @@ public function testIsDeletable() '/v1/webhook_endpoints/' . self::TEST_RESOURCE_ID ); $resource->delete(); - $this->assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $resource); } } diff --git a/tests/Stripe/WebhookTest.php b/tests/Stripe/WebhookTest.php index ccce351e2..b2069ac99 100644 --- a/tests/Stripe/WebhookTest.php +++ b/tests/Stripe/WebhookTest.php @@ -28,7 +28,7 @@ public function testValidJsonAndHeader() { $sigHeader = $this->generateHeader(); $event = Webhook::constructEvent(self::EVENT_PAYLOAD, $sigHeader, self::SECRET); - $this->assertEquals("evt_test_webhook", $event->id); + static::assertEquals("evt_test_webhook", $event->id); } public function testInvalidJson() @@ -96,18 +96,18 @@ public function testTimestampTooRecent() public function testValidHeaderAndSignature() { $sigHeader = $this->generateHeader(); - $this->assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET, 10)); + static::assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET, 10)); } public function testHeaderContainsValidSignature() { $sigHeader = $this->generateHeader() . ",v1=bad_signature"; - $this->assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET, 10)); + static::assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET, 10)); } public function testTimestampOffButNoTolerance() { $sigHeader = $this->generateHeader(["timestamp" => 12345]); - $this->assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET)); + static::assertTrue(WebhookSignature::verifyHeader(self::EVENT_PAYLOAD, $sigHeader, self::SECRET)); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index ae16f342c..e5b734661 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -158,14 +158,14 @@ private function prepareRequestMock( $absUrl = $base . $path; return $this->clientMock - ->expects($this->once()) + ->expects(static::once()) ->method('request') ->with( - $this->identicalTo(\strtolower($method)), - $this->identicalTo($absUrl), + static::identicalTo(\strtolower($method)), + static::identicalTo($absUrl), // for headers, we only check that all of the headers provided in $headers are // present in the list of headers of the actual request - $headers === null ? $this->anything() : $this->callback(function ($array) use ($headers) { + $headers === null ? static::anything() : static::callback(function ($array) use ($headers) { foreach ($headers as $header) { if (!\in_array($header, $array)) { return false; @@ -173,8 +173,8 @@ private function prepareRequestMock( } return true; }), - $params === null ? $this->anything() : $this->identicalTo($params), - $this->identicalTo($hasFile) + $params === null ? static::anything() : static::identicalTo($params), + static::identicalTo($hasFile) ); } } From 2aaa0468cc930d1cbcbb6657110aa08b13995716 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:58:25 -0800 Subject: [PATCH 77/97] Use psr4 rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 42b0a3e4b..c2ed408e3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -92,5 +92,6 @@ return PhpCsFixer\Config::create() 'php_unit_set_up_tear_down_visibility' => true, 'php_unit_test_annotation' => true, 'php_unit_test_case_static_method_calls' => true, + 'psr4' => true, ]) ; From a199b9cba3989ac2a1660e36a509c07eb69cd324 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 10:59:03 -0800 Subject: [PATCH 78/97] Use return_assignment rule --- .php_cs.dist | 1 + lib/ApiRequestor.php | 3 +-- lib/StripeObject.php | 3 +-- lib/Util/Util.php | 4 +--- lib/Webhook.php | 4 +--- tests/Stripe/Exception/ApiErrorExceptionTest.php | 3 +-- tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php | 3 +-- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index c2ed408e3..6f9ba6cad 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -93,5 +93,6 @@ return PhpCsFixer\Config::create() 'php_unit_test_annotation' => true, 'php_unit_test_case_static_method_calls' => true, 'psr4' => true, + 'return_assignment' => true, ]) ; diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 08ad2b686..c4aa16a29 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -280,12 +280,11 @@ private static function _defaultHeaders($apiKey, $clientInfo = null) $ua['application'] = $appInfo; } - $defaultHeaders = [ + return [ 'X-Stripe-Client-User-Agent' => \json_encode($ua), 'User-Agent' => $uaString, 'Authorization' => 'Bearer ' . $apiKey, ]; - return $defaultHeaders; } /** diff --git a/lib/StripeObject.php b/lib/StripeObject.php index f8128384f..d6b8952ef 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -513,8 +513,7 @@ public static function emptyValues($obj) "empty_values got unexpected object type: " . \get_class($obj) ); } - $update = \array_fill_keys(\array_keys($values), ""); - return $update; + return \array_fill_keys(\array_keys($values), ""); } /** diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 8939e7a61..5a4c7be83 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -306,9 +306,7 @@ public static function urlEncode($key) // characters back to their literals. This is fine by the server, and // makes these parameter strings easier to read. $s = \str_replace('%5B', '[', $s); - $s = \str_replace('%5D', ']', $s); - - return $s; + return \str_replace('%5D', ']', $s); } public static function normalizeId($id) diff --git a/lib/Webhook.php b/lib/Webhook.php index a21ef8c4f..f81394022 100644 --- a/lib/Webhook.php +++ b/lib/Webhook.php @@ -33,8 +33,6 @@ public static function constructEvent($payload, $sigHeader, $secret, $tolerance . "(json_last_error() was ${jsonError})"; throw new Exception\UnexpectedValueException($msg); } - $event = Event::constructFrom($data); - - return $event; + return Event::constructFrom($data); } } diff --git a/tests/Stripe/Exception/ApiErrorExceptionTest.php b/tests/Stripe/Exception/ApiErrorExceptionTest.php index d76eb186b..222f8695e 100644 --- a/tests/Stripe/Exception/ApiErrorExceptionTest.php +++ b/tests/Stripe/Exception/ApiErrorExceptionTest.php @@ -7,7 +7,7 @@ class ApiErrorExceptionTest extends \Stripe\TestCase public function createFixture() { $mock = $this->getMockForAbstractClass(ApiErrorException::class); - $instance = $mock::factory( + return $mock::factory( 'message', 200, '{"error": {"code": "some_code"}}', @@ -18,7 +18,6 @@ public function createFixture() ], 'some_code' ); - return $instance; } public function testGetters() diff --git a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php index e5bbcb61c..76000d1a2 100644 --- a/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php +++ b/tests/Stripe/Exception/OAuth/OAuthErrorExceptionTest.php @@ -7,7 +7,7 @@ class OAuthErrorExceptionTest extends \Stripe\TestCase public function createFixture() { $mock = $this->getMockForAbstractClass(OAuthErrorException::class); - $instance = $mock::factory( + return $mock::factory( 'description', 200, '{"error": "code", "error_description": "description"}', @@ -18,7 +18,6 @@ public function createFixture() ], 'code' ); - return $instance; } public function testGetters() From a3bfe4642c54de6fbfec34388a17eb690236480b Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:00:30 -0800 Subject: [PATCH 79/97] Use return_type_declaration rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 6f9ba6cad..869dca62b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -94,5 +94,6 @@ return PhpCsFixer\Config::create() 'php_unit_test_case_static_method_calls' => true, 'psr4' => true, 'return_assignment' => true, + 'return_type_declaration' => true, ]) ; From d8dd2b0297430e84a6b2249fdb42839b13aad056 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:00:58 -0800 Subject: [PATCH 80/97] Use semicolon_after_instruction rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 869dca62b..03419bca1 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -95,5 +95,6 @@ return PhpCsFixer\Config::create() 'psr4' => true, 'return_assignment' => true, 'return_type_declaration' => true, + 'semicolon_after_instruction' => true, ]) ; From 2573b0855384737cd41c4479dd1d65d7246358c9 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:01:19 -0800 Subject: [PATCH 81/97] Use set_type_to_cast rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 03419bca1..4f392f3db 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -96,5 +96,6 @@ return PhpCsFixer\Config::create() 'return_assignment' => true, 'return_type_declaration' => true, 'semicolon_after_instruction' => true, + 'set_type_to_cast' => true, ]) ; From dc263c8ed65c770d22eadafcdf8ce22ba31e5e92 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:01:39 -0800 Subject: [PATCH 82/97] Use short_scalar_cast rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 4f392f3db..3e7ca53ff 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -97,5 +97,6 @@ return PhpCsFixer\Config::create() 'return_type_declaration' => true, 'semicolon_after_instruction' => true, 'set_type_to_cast' => true, + 'short_scalar_cast' => true, ]) ; From b3add47cc42ee01e9f614f705fdf5888bbad68a0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:02:50 -0800 Subject: [PATCH 83/97] Use simple_to_complex_string_variable rule --- .php_cs.dist | 1 + build.php | 2 +- examples/oauth.php | 6 +++--- lib/AlipayAccount.php | 2 +- lib/ApiOperations/NestedResource.php | 2 +- lib/ApiRequestor.php | 8 ++++---- lib/ApiResource.php | 6 +++--- lib/ApplicationFeeRefund.php | 4 ++-- lib/BankAccount.php | 2 +- lib/BitcoinReceiver.php | 4 ++-- lib/Capability.php | 4 ++-- lib/Card.php | 2 +- lib/Collection.php | 4 ++-- lib/CustomerBalanceTransaction.php | 4 ++-- lib/HttpClient/CurlClient.php | 14 +++++++------- lib/Person.php | 4 ++-- lib/SingletonApiResource.php | 2 +- lib/Source.php | 6 +++--- lib/StripeObject.php | 12 ++++++------ lib/TaxId.php | 4 ++-- lib/TransferReversal.php | 4 ++-- lib/Webhook.php | 4 ++-- lib/WebhookSignature.php | 2 +- tests/Stripe/WebhookTest.php | 4 ++-- 24 files changed, 54 insertions(+), 53 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 3e7ca53ff..26f33c729 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -98,5 +98,6 @@ return PhpCsFixer\Config::create() 'semicolon_after_instruction' => true, 'set_type_to_cast' => true, 'short_scalar_cast' => true, + 'simple_to_complex_string_variable' => true, ]) ; diff --git a/build.php b/build.php index aa3e1dbf0..e37b01952 100755 --- a/build.php +++ b/build.php @@ -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); } diff --git a/examples/oauth.php b/examples/oauth.php index 22fc5684f..58b42f528 100644 --- a/examples/oauth.php +++ b/examples/oauth.php @@ -20,8 +20,8 @@ $accountId = $resp->stripe_user_id; - echo "

Success! Account ${accountId} is connected.

\n"; - echo "

Click here to disconnect the account.

\n"; + echo "

Success! Account {$accountId} is connected.

\n"; + echo "

Click here to disconnect the account.

\n"; } elseif (isset($_GET['error'])) { // The user was redirect back from the OAuth form with an error. $error = $_GET['error']; @@ -47,5 +47,5 @@ $url = \Stripe\OAuth::authorizeUrl([ 'scope' => 'read_only', ]); - echo "Connect with Stripe\n"; + echo "Connect with Stripe\n"; } diff --git a/lib/AlipayAccount.php b/lib/AlipayAccount.php index f60c9b3cb..aa91c1a02 100644 --- a/lib/AlipayAccount.php +++ b/lib/AlipayAccount.php @@ -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}"; } /** diff --git a/lib/ApiOperations/NestedResource.php b/lib/ApiOperations/NestedResource.php index 9dcdc5c4d..8af96264f 100644 --- a/lib/ApiOperations/NestedResource.php +++ b/lib/ApiOperations/NestedResource.php @@ -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; } diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index c4aa16a29..f60e19597 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -129,8 +129,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); } @@ -420,8 +420,8 @@ 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})"; + $msg = "Invalid response body from API: {$rbody} " + . "(HTTP response code was {$rcode}, json_last_error() was {$jsonError})"; throw new Exception\UnexpectedValueException($msg, $rcode); } diff --git a/lib/ApiResource.php b/lib/ApiResource.php index c0f3349cb..95609fe8b 100644 --- a/lib/ApiResource.php +++ b/lib/ApiResource.php @@ -84,7 +84,7 @@ public static function classUrl() // Replace dots with slashes for namespaced resources, e.g. if the object's name is // "foo.bar", then its URL will be "/v1/foo/bars". $base = \str_replace('.', '/', static::OBJECT_NAME); - return "/v1/${base}s"; + return "/v1/{$base}s"; } /** @@ -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}"; } /** diff --git a/lib/ApplicationFeeRefund.php b/lib/ApplicationFeeRefund.php index 4d67a1496..025656684 100644 --- a/lib/ApplicationFeeRefund.php +++ b/lib/ApplicationFeeRefund.php @@ -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 ); } @@ -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}"; } /** diff --git a/lib/BankAccount.php b/lib/BankAccount.php index 378e4109f..e6c6c7908 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -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}"; } /** diff --git a/lib/BitcoinReceiver.php b/lib/BitcoinReceiver.php index 57a3a3d00..36db8824e 100644 --- a/lib/BitcoinReceiver.php +++ b/lib/BitcoinReceiver.php @@ -61,10 +61,10 @@ 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}"; } $base = BitcoinReceiver::classUrl(); $extn = \urlencode(Util\Util::utf8($this['id'])); - return "${base}/${extn}"; + return "{$base}/{$extn}"; } } diff --git a/lib/Capability.php b/lib/Capability.php index 64e986648..4a420fc36 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -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 ); } @@ -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}"; } /** diff --git a/lib/Card.php b/lib/Card.php index 68a99b80b..f8fa82de7 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -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}"; } /** diff --git a/lib/Collection.php b/lib/Collection.php index af402eaee..8f601b280 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -95,7 +95,7 @@ public function retrieve($id, $params = null, $opts = null) $extn = \urlencode($id); list($response, $opts) = $this->_request( 'get', - "${url}/${extn}", + "{$url}/{$extn}", $params, $opts ); @@ -232,7 +232,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'])) { diff --git a/lib/CustomerBalanceTransaction.php b/lib/CustomerBalanceTransaction.php index 86c6a4f66..ae17bde6d 100644 --- a/lib/CustomerBalanceTransaction.php +++ b/lib/CustomerBalanceTransaction.php @@ -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 ); } @@ -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}"; } /** diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index f4d12896f..b29d04299 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -213,7 +213,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $opts[\CURLOPT_HTTPGET] = 1; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); - $absUrl = "${absUrl}?${encoded}"; + $absUrl = "{$absUrl}?{$encoded}"; } } elseif ($method == 'post') { $opts[\CURLOPT_POST] = 1; @@ -222,10 +222,10 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $opts[\CURLOPT_CUSTOMREQUEST] = 'DELETE'; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); - $absUrl = "${absUrl}?${encoded}"; + $absUrl = "{$absUrl}?{$encoded}"; } } else { - throw new Exception\UnexpectedValueException("Unrecognized method ${method}"); + throw new Exception\UnexpectedValueException("Unrecognized method {$method}"); } // It is only safe to retry network failures on POST requests if we @@ -349,7 +349,7 @@ private function handleCurlError($url, $errno, $message, $numRetries) case \CURLE_COULDNT_CONNECT: case \CURLE_COULDNT_RESOLVE_HOST: case \CURLE_OPERATION_TIMEOUTED: - $msg = "Could not connect to Stripe (${url}). Please check your " + $msg = "Could not connect to Stripe ({$url}). Please check your " . "internet connection and try again. If this problem persists, " . "you should check Stripe's service status at " . "https://twitter.com/stripestatus, or"; @@ -358,7 +358,7 @@ private function handleCurlError($url, $errno, $message, $numRetries) case \CURLE_SSL_PEER_CERTIFICATE: $msg = "Could not verify Stripe's SSL certificate. Please make sure " . "that your network is not intercepting certificates. " - . "(Try going to ${url} in your browser.) " + . "(Try going to {$url} in your browser.) " . "If this problem persists,"; break; default: @@ -367,10 +367,10 @@ private function handleCurlError($url, $errno, $message, $numRetries) } $msg .= " let us know at support@stripe.com."; - $msg .= "\n\n(Network error [errno ${errno}]: ${message})"; + $msg .= "\n\n(Network error [errno {$errno}]: {$message})"; if ($numRetries > 0) { - $msg .= "\n\nRequest was retried ${numRetries} times."; + $msg .= "\n\nRequest was retried {$numRetries} times."; } throw new Exception\ApiConnectionException($msg); diff --git a/lib/Person.php b/lib/Person.php index 80e88595f..c6c16cbaa 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -65,7 +65,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 ); } @@ -75,7 +75,7 @@ public function instanceUrl() $base = Account::classUrl(); $accountExtn = \urlencode($account); $extn = \urlencode($id); - return "${base}/${accountExtn}/persons/${extn}"; + return "{$base}/{$accountExtn}/persons/{$extn}"; } /** diff --git a/lib/SingletonApiResource.php b/lib/SingletonApiResource.php index 1a9dc0030..922c9ce39 100644 --- a/lib/SingletonApiResource.php +++ b/lib/SingletonApiResource.php @@ -25,7 +25,7 @@ public static function classUrl() // Replace dots with slashes for namespaced resources, e.g. if the object's name is // "foo.bar", then its URL will be "/v1/foo/bar". $base = \str_replace('.', '/', static::OBJECT_NAME); - return "/v1/${base}"; + return "/v1/{$base}"; } /** diff --git a/lib/Source.php b/lib/Source.php index 79fac9895..fca13d148 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -98,8 +98,8 @@ public function detach($params = null, $opts = null) $id = $this['id']; if (!$id) { $class = \get_class($this); - $msg = "Could not determine which URL to request: ${class} instance " - . "has invalid ID: ${id}"; + $msg = "Could not determine which URL to request: {$class} instance " + . "has invalid ID: {$id}"; throw new Exception\UnexpectedValueException($msg, null); } @@ -107,7 +107,7 @@ public function detach($params = null, $opts = null) $base = Customer::classUrl(); $parentExtn = \urlencode(Util\Util::utf8($this['customer'])); $extn = \urlencode(Util\Util::utf8($id)); - $url = "${base}/${parentExtn}/sources/${extn}"; + $url = "{$base}/{$parentExtn}/sources/{$extn}"; list($response, $opts) = $this->_request('delete', $url, $params, $opts); $this->refreshFrom($response, $opts); diff --git a/lib/StripeObject.php b/lib/StripeObject.php index d6b8952ef..27fdc2941 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -117,7 +117,7 @@ public function __set($k, $v) { if (static::getPermanentAttributes()->includes($k)) { throw new Exception\InvalidArgumentException( - "Cannot set ${k} on this object. HINT: you can't set: " . + "Cannot set {$k} on this object. HINT: you can't set: " . \implode(', ', static::getPermanentAttributes()->toArray()) ); } @@ -157,17 +157,17 @@ public function &__get($k) if (!empty($this->_transientValues) && $this->_transientValues->includes($k)) { $class = \get_class($this); $attrs = \implode(', ', \array_keys($this->_values)); - $message = "Stripe Notice: Undefined property of ${class} instance: ${k}. " - . "HINT: The ${k} attribute was set in the past, however. " + $message = "Stripe Notice: Undefined property of {$class} instance: {$k}. " + . "HINT: The {$k} attribute was set in the past, however. " . "It was then wiped when refreshing the object " . "with the result returned by Stripe's API, " . "probably as a result of a save(). The attributes currently " - . "available on this object are: ${attrs}"; + . "available on this object are: {$attrs}"; Stripe::getLogger()->error($message); return $nullval; } $class = \get_class($this); - Stripe::getLogger()->error("Stripe Notice: Undefined property of ${class} instance: ${k}"); + Stripe::getLogger()->error("Stripe Notice: Undefined property of {$class} instance: {$k}"); return $nullval; } @@ -369,7 +369,7 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = return $value; } throw new Exception\InvalidArgumentException( - "Cannot save property `${key}` containing an API resource of type " . + "Cannot save property `{$key}` containing an API resource of type " . \get_class($value) . ". It doesn't appear to be persisted and is " . "not marked as `saveWithParent`." ); diff --git a/lib/TaxId.php b/lib/TaxId.php index 336850983..1a5a0405f 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -62,7 +62,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}" ); } $id = Util\Util::utf8($id); @@ -71,7 +71,7 @@ public function instanceUrl() $base = Customer::classUrl(); $customerExtn = \urlencode($customer); $extn = \urlencode($id); - return "${base}/${customerExtn}/tax_ids/${extn}"; + return "{$base}/{$customerExtn}/tax_ids/{$extn}"; } /** diff --git a/lib/TransferReversal.php b/lib/TransferReversal.php index e896c02c9..003a1d74f 100644 --- a/lib/TransferReversal.php +++ b/lib/TransferReversal.php @@ -36,7 +36,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 ); } @@ -46,7 +46,7 @@ public function instanceUrl() $base = Transfer::classUrl(); $transferExtn = \urlencode($transfer); $extn = \urlencode($id); - return "${base}/${transferExtn}/reversals/${extn}"; + return "{$base}/{$transferExtn}/reversals/{$extn}"; } /** diff --git a/lib/Webhook.php b/lib/Webhook.php index f81394022..3f546832d 100644 --- a/lib/Webhook.php +++ b/lib/Webhook.php @@ -29,8 +29,8 @@ public static function constructEvent($payload, $sigHeader, $secret, $tolerance $data = \json_decode($payload, true); $jsonError = \json_last_error(); if ($data === null && $jsonError !== \JSON_ERROR_NONE) { - $msg = "Invalid payload: ${payload} " - . "(json_last_error() was ${jsonError})"; + $msg = "Invalid payload: {$payload} " + . "(json_last_error() was {$jsonError})"; throw new Exception\UnexpectedValueException($msg); } return Event::constructFrom($data); diff --git a/lib/WebhookSignature.php b/lib/WebhookSignature.php index 1813ccb18..3fd35e2fa 100644 --- a/lib/WebhookSignature.php +++ b/lib/WebhookSignature.php @@ -42,7 +42,7 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul // Check if expected signature is found in list of signatures from // header - $signedPayload = "${timestamp}.${payload}"; + $signedPayload = "{$timestamp}.{$payload}"; $expectedSignature = self::computeSignature($signedPayload, $secret); $signatureFound = false; foreach ($signatures as $signature) { diff --git a/tests/Stripe/WebhookTest.php b/tests/Stripe/WebhookTest.php index b2069ac99..61a67e708 100644 --- a/tests/Stripe/WebhookTest.php +++ b/tests/Stripe/WebhookTest.php @@ -18,10 +18,10 @@ private function generateHeader($opts = []) $scheme = \array_key_exists('scheme', $opts) ? $opts['scheme'] : WebhookSignature::EXPECTED_SCHEME; $signature = \array_key_exists('signature', $opts) ? $opts['signature'] : null; if ($signature === null) { - $signedPayload = "${timestamp}.${payload}"; + $signedPayload = "{$timestamp}.{$payload}"; $signature = \hash_hmac("sha256", $signedPayload, $secret); } - return "t=${timestamp},${scheme}=${signature}"; + return "t={$timestamp},{$scheme}={$signature}"; } public function testValidJsonAndHeader() From 5968fb1239e38fcfcf4c33d7413f872136185360 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:31:10 -0800 Subject: [PATCH 84/97] Use single_line_comment_style rule --- .php_cs.dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.php_cs.dist b/.php_cs.dist index 26f33c729..74d07968c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -99,5 +99,7 @@ return PhpCsFixer\Config::create() 'set_type_to_cast' => true, 'short_scalar_cast' => true, 'simple_to_complex_string_variable' => true, + 'single_blank_line_before_namespace' => true, + 'single_line_comment_style' => true, ]) ; From 7c81d77fa80b0bd55f37bee57424aa5c2017637b Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:31:58 -0800 Subject: [PATCH 85/97] Use single_trait_insert_per_statement rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 74d07968c..8c8c38d33 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -101,5 +101,6 @@ return PhpCsFixer\Config::create() 'simple_to_complex_string_variable' => true, 'single_blank_line_before_namespace' => true, 'single_line_comment_style' => true, + 'single_trait_insert_per_statement' => true, ]) ; From ddee3e332a1286913b38e45587b1069233afb50f Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:32:19 -0800 Subject: [PATCH 86/97] Use space_after_semicolon rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 8c8c38d33..0d3b25b9b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -102,5 +102,6 @@ return PhpCsFixer\Config::create() 'single_blank_line_before_namespace' => true, 'single_line_comment_style' => true, 'single_trait_insert_per_statement' => true, + 'space_after_semicolon' => true, ]) ; From c35ffc57126248333e734186dc804b310c75bccf Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:32:50 -0800 Subject: [PATCH 87/97] Use standardize_increment rule --- .php_cs.dist | 4 ++-- lib/HttpClient/CurlClient.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 0d3b25b9b..fbcbf5b89 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -103,5 +103,5 @@ return PhpCsFixer\Config::create() 'single_line_comment_style' => true, 'single_trait_insert_per_statement' => true, 'space_after_semicolon' => true, - ]) -; + 'standardize_increment' => true, + ]); diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index b29d04299..f6ec73a7e 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -321,7 +321,7 @@ private function executeRequestWithRetries($opts, $absUrl) } if ($shouldRetry) { - $numRetries += 1; + ++$numRetries; $sleepSeconds = $this->sleepTime($numRetries, $rheaders); \usleep((int) ($sleepSeconds * 1000000)); } else { From 517f1f33ad6da3d38fa279e47877ef923043def0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:33:09 -0800 Subject: [PATCH 88/97] Use standardize_not_equals rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index fbcbf5b89..aa7ee336c 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -104,4 +104,5 @@ return PhpCsFixer\Config::create() 'single_trait_insert_per_statement' => true, 'space_after_semicolon' => true, 'standardize_increment' => true, + 'standardize_not_equals' => true, ]); From fa73b496d1bb3b85ce2de7dde8afd9fc1903d9e0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:33:48 -0800 Subject: [PATCH 89/97] Use strict_comparison rule --- .php_cs.dist | 1 + lib/Account.php | 2 +- lib/ApiRequestor.php | 8 ++++---- lib/Exception/ApiErrorException.php | 4 ++-- lib/HttpClient/CurlClient.php | 12 ++++++------ lib/Stripe.php | 2 +- lib/StripeObject.php | 2 +- lib/Util/Util.php | 6 +++--- lib/WebhookSignature.php | 6 +++--- tests/bootstrap.php | 4 ++-- 10 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index aa7ee336c..a00d23125 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -105,4 +105,5 @@ return PhpCsFixer\Config::create() 'space_after_semicolon' => true, 'standardize_increment' => true, 'standardize_not_equals' => true, + 'strict_comparison' => true, ]); diff --git a/lib/Account.php b/lib/Account.php index a125f5670..3cacbbb07 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -135,7 +135,7 @@ private function serializeAdditionalOwners($legalEntity, $additionalOwners) if ($update !== []) { if (!$originalValue || !\array_key_exists($i, $originalValue) || - ($update != $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) { + ($update !== $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) { $updateArr[$i] = $update; } } diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index f60e19597..6bfc86ee3 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -61,7 +61,7 @@ private static function _telemetryJson($requestTelemetry) ]; $result = \json_encode($payload); - if ($result != false) { + if ($result !== false) { return $result; } Stripe::getLogger()->error("Serializing telemetry payload failed!"); @@ -170,10 +170,10 @@ private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $err case 400: // 'rate_limit' code is deprecated, but left here for backwards compatibility // for API versions earlier than 2015-09-08 - if ($code == 'rate_limit') { + if ($code === 'rate_limit') { return Exception\RateLimitException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param); } - if ($type == 'idempotency_error') { + if ($type === 'idempotency_error') { return Exception\IdempotencyException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code); } @@ -332,7 +332,7 @@ private function _requestRaw($method, $url, $params, $headers) $defaultHeaders['Stripe-Account'] = Stripe::$accountId; } - if (Stripe::$enableTelemetry && self::$requestTelemetry != null) { + if (Stripe::$enableTelemetry && self::$requestTelemetry !== null) { $defaultHeaders["X-Stripe-Client-Telemetry"] = self::_telemetryJson(self::$requestTelemetry); } diff --git a/lib/Exception/ApiErrorException.php b/lib/Exception/ApiErrorException.php index 7026511b4..45a64b773 100644 --- a/lib/Exception/ApiErrorException.php +++ b/lib/Exception/ApiErrorException.php @@ -202,8 +202,8 @@ public function setStripeCode($stripeCode) */ public function __toString() { - $statusStr = ($this->getHttpStatus() == null) ? "" : "(Status {$this->getHttpStatus()}) "; - $idStr = ($this->getRequestId() == null) ? "" : "(Request {$this->getRequestId()}) "; + $statusStr = ($this->getHttpStatus() === null) ? "" : "(Status {$this->getHttpStatus()}) "; + $idStr = ($this->getRequestId() === null) ? "" : "(Request {$this->getRequestId()}) "; return "{$statusStr}{$idStr}{$this->getMessage()}"; } diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index f6ec73a7e..3b92de6ed 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -204,7 +204,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $params = Util\Util::objectsToIds($params); - if ($method == 'get') { + if ($method === 'get') { if ($hasFile) { throw new Exception\UnexpectedValueException( "Issuing a GET request with a file parameter" @@ -215,10 +215,10 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $encoded = Util\Util::encodeParameters($params); $absUrl = "{$absUrl}?{$encoded}"; } - } elseif ($method == 'post') { + } elseif ($method === 'post') { $opts[\CURLOPT_POST] = 1; $opts[\CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::encodeParameters($params); - } elseif ($method == 'delete') { + } elseif ($method === 'delete') { $opts[\CURLOPT_CUSTOMREQUEST] = 'DELETE'; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); @@ -230,7 +230,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) // It is only safe to retry network failures on POST requests if we // add an Idempotency-Key header - if (($method == 'post') && (Stripe::$maxNetworkRetries > 0)) { + if (($method === 'post') && (Stripe::$maxNetworkRetries > 0)) { if (!$this->hasHeader($headers, "Idempotency-Key")) { \array_push($headers, 'Idempotency-Key: ' . $this->randomGenerator->uuid()); } @@ -277,7 +277,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) private function executeRequestWithRetries($opts, $absUrl) { $numRetries = 0; - $isPost = \array_key_exists(\CURLOPT_POST, $opts) && $opts[\CURLOPT_POST] == 1; + $isPost = \array_key_exists(\CURLOPT_POST, $opts) && $opts[\CURLOPT_POST] === 1; while (true) { $rcode = 0; @@ -461,7 +461,7 @@ private function sleepTime($numRetries, $rheaders) // And never sleep less than the time the API asks us to wait, assuming it's a reasonable ask. $retryAfter = isset($rheaders['retry-after']) ? (float) ($rheaders['retry-after']) : 0.0; - if (\floor($retryAfter) == $retryAfter && $retryAfter <= Stripe::getMaxRetryAfter()) { + if (\floor($retryAfter) === $retryAfter && $retryAfter <= Stripe::getMaxRetryAfter()) { $sleepSeconds = \max($sleepSeconds, $retryAfter); } diff --git a/lib/Stripe.php b/lib/Stripe.php index cf7efa46c..d230c9003 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -84,7 +84,7 @@ public static function getClientId() */ public static function getLogger() { - if (self::$logger == null) { + if (self::$logger === null) { return new Util\DefaultLogger(); } return self::$logger; diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 27fdc2941..a2d133fd0 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -422,7 +422,7 @@ public function toArray() }; return \array_reduce(\array_keys($this->_values), function ($acc, $k) use ($maybeToArray) { - if ($k[0] == '_') { + if ($k[0] === '_') { return $acc; } $v = $this->_values[$k]; diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 5a4c7be83..077cf1c83 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -162,7 +162,7 @@ public static function utf8($value) } } - if (\is_string($value) && self::$isMbstringAvailable && \mb_detect_encoding($value, "UTF-8", true) != "UTF-8") { + if (\is_string($value) && self::$isMbstringAvailable && \mb_detect_encoding($value, "UTF-8", true) !== "UTF-8") { return \utf8_encode($value); } return $value; @@ -185,7 +185,7 @@ public static function secureCompare($a, $b) if (self::$isHashEqualsAvailable) { return \hash_equals($a, $b); } - if (\strlen($a) != \strlen($b)) { + if (\strlen($a) !== \strlen($b)) { return false; } @@ -193,7 +193,7 @@ public static function secureCompare($a, $b) for ($i = 0; $i < \strlen($a); ++$i) { $result |= \ord($a[$i]) ^ \ord($b[$i]); } - return $result == 0; + return $result === 0; } /** diff --git a/lib/WebhookSignature.php b/lib/WebhookSignature.php index 3fd35e2fa..edcaca0ce 100644 --- a/lib/WebhookSignature.php +++ b/lib/WebhookSignature.php @@ -25,7 +25,7 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul // Extract timestamp and signatures from header $timestamp = self::getTimestamp($header); $signatures = self::getSignatures($header, self::EXPECTED_SCHEME); - if ($timestamp == -1) { + if ($timestamp === -1) { throw Exception\SignatureVerificationException::factory( "Unable to extract timestamp and signatures from header", $payload, @@ -84,7 +84,7 @@ private static function getTimestamp($header) foreach ($items as $item) { $itemParts = \explode("=", $item, 2); - if ($itemParts[0] == "t") { + if ($itemParts[0] === "t") { if (!\is_numeric($itemParts[1])) { return -1; } @@ -109,7 +109,7 @@ private static function getSignatures($header, $scheme) foreach ($items as $item) { $itemParts = \explode("=", $item, 2); - if ($itemParts[0] == $scheme) { + if ($itemParts[0] === $scheme) { \array_push($signatures, $itemParts[1]); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 352485166..ef1980d3f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -34,7 +34,7 @@ $headers = \explode("\n", $resp); foreach ($headers as $header) { $pair = \explode(":", $header, 2); - if ($pair[0] == "Stripe-Mock-Version") { + if ($pair[0] === "Stripe-Mock-Version") { $version = \trim($pair[1]); } } @@ -46,7 +46,7 @@ exit(1); } -if ($version != "master" && \version_compare($version, MOCK_MINIMUM_VERSION) == -1) { +if ($version !== "master" && \version_compare($version, MOCK_MINIMUM_VERSION) === -1) { echo "Your version of stripe-mock (" . $version . ") is too old. The minimum " . "version to run this test suite is " . MOCK_MINIMUM_VERSION . ". " . "Please see its repository for upgrade instructions.\n"; From 401b186b30c26c6d62267654629d7a7c2a215283 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:34:19 -0800 Subject: [PATCH 90/97] Use strict_param rule --- .php_cs.dist | 1 + lib/ApiRequestor.php | 2 +- lib/Util/RequestOptions.php | 2 +- tests/TestCase.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index a00d23125..1d320de41 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -106,4 +106,5 @@ return PhpCsFixer\Config::create() 'standardize_increment' => true, 'standardize_not_equals' => true, 'strict_comparison' => true, + 'strict_param' => true, ]); diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 6bfc86ee3..0ed21ab38 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -261,7 +261,7 @@ private static function _defaultHeaders($apiKey, $clientInfo = null) $uaString = 'Stripe/v1 PhpBindings/' . Stripe::VERSION; $langVersion = \PHP_VERSION; - $uname_disabled = \in_array('php_uname', \explode(',', \ini_get('disable_functions'))); + $uname_disabled = \in_array('php_uname', \explode(',', \ini_get('disable_functions')), true); $uname = $uname_disabled ? '(disabled)' : \php_uname(); $appInfo = Stripe::getAppInfo(); diff --git a/lib/Util/RequestOptions.php b/lib/Util/RequestOptions.php index ef938e28e..b34b6dbbd 100644 --- a/lib/Util/RequestOptions.php +++ b/lib/Util/RequestOptions.php @@ -60,7 +60,7 @@ public function merge($options) public function discardNonPersistentHeaders() { foreach ($this->headers as $k => $v) { - if (!\in_array($k, self::$HEADERS_TO_PERSIST)) { + if (!\in_array($k, self::$HEADERS_TO_PERSIST, true)) { unset($this->headers[$k]); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index e5b734661..ce6c84eee 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -167,7 +167,7 @@ private function prepareRequestMock( // present in the list of headers of the actual request $headers === null ? static::anything() : static::callback(function ($array) use ($headers) { foreach ($headers as $header) { - if (!\in_array($header, $array)) { + if (!\in_array($header, $array, true)) { return false; } } From 24e82cb1059af35dae51911385a0f37d47283767 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:34:38 -0800 Subject: [PATCH 91/97] Use string_line_ending rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 1d320de41..53304d428 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -107,4 +107,5 @@ return PhpCsFixer\Config::create() 'standardize_not_equals' => true, 'strict_comparison' => true, 'strict_param' => true, + 'string_line_ending' => true, ]); From 9df2dd05d6773a541366f7312ceae4f178c10dbc Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:35:00 -0800 Subject: [PATCH 92/97] Use ternary_operator_spaces rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 53304d428..a2b2bf9a6 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -108,4 +108,5 @@ return PhpCsFixer\Config::create() 'strict_comparison' => true, 'strict_param' => true, 'string_line_ending' => true, + 'ternary_operator_spaces' => true, ]); From d15967400cb4f08930278dfdcac192a1a63b2a9f Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:35:33 -0800 Subject: [PATCH 93/97] Use trailing_comma_in_multiline_array rule --- .php_cs.dist | 1 + tests/Stripe/AccountTest.php | 4 ++-- tests/Stripe/BankAccountTest.php | 2 +- tests/Stripe/ChargeTest.php | 2 +- tests/Stripe/Checkout/SessionTest.php | 2 +- tests/Stripe/FileCreationTest.php | 4 ++-- tests/Stripe/FileLinkTest.php | 2 +- tests/Stripe/InvoiceItemTest.php | 2 +- tests/Stripe/InvoiceTest.php | 2 +- tests/Stripe/OrderTest.php | 2 +- tests/Stripe/PayoutTest.php | 2 +- tests/Stripe/PlanTest.php | 2 +- tests/Stripe/ProductTest.php | 2 +- tests/Stripe/RecipientTest.php | 2 +- tests/Stripe/RefundTest.php | 2 +- tests/Stripe/Reporting/ReportRunTest.php | 2 +- tests/Stripe/SKUTest.php | 4 ++-- tests/Stripe/SourceTest.php | 4 ++-- tests/Stripe/StripeObjectTest.php | 2 +- tests/Stripe/SubscriptionItemTest.php | 6 +++--- tests/Stripe/SubscriptionTest.php | 2 +- tests/Stripe/Terminal/LocationTest.php | 8 ++++---- tests/Stripe/ThreeDSecureTest.php | 2 +- tests/Stripe/TopupTest.php | 2 +- tests/Stripe/TransferTest.php | 2 +- tests/Stripe/Util/RequestOptionsTest.php | 2 +- 26 files changed, 35 insertions(+), 34 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index a2b2bf9a6..37da848b0 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -109,4 +109,5 @@ return PhpCsFixer\Config::create() 'strict_param' => true, 'string_line_ending' => true, 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, ]); diff --git a/tests/Stripe/AccountTest.php b/tests/Stripe/AccountTest.php index 233494e74..1ab1da07f 100644 --- a/tests/Stripe/AccountTest.php +++ b/tests/Stripe/AccountTest.php @@ -236,8 +236,8 @@ public function testCanCreatePerson() "dob" => [ "day" => 1, "month" => 1, - "year" => 1980 - ] + "year" => 1980, + ], ]); static::assertInstanceOf(\Stripe\Person::class, $resource); } diff --git a/tests/Stripe/BankAccountTest.php b/tests/Stripe/BankAccountTest.php index 2649d4a46..dceb41111 100644 --- a/tests/Stripe/BankAccountTest.php +++ b/tests/Stripe/BankAccountTest.php @@ -88,7 +88,7 @@ public function testIsVerifiable() 'post', '/v1/customers/cus_123/sources/' . self::TEST_RESOURCE_ID . "/verify", [ - "amounts" => [1, 2] + "amounts" => [1, 2], ] ); $resource->verify(["amounts" => [1, 2]]); diff --git a/tests/Stripe/ChargeTest.php b/tests/Stripe/ChargeTest.php index ff5dcd9d5..6cc7169c8 100644 --- a/tests/Stripe/ChargeTest.php +++ b/tests/Stripe/ChargeTest.php @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = Charge::create([ "amount" => 100, "currency" => "usd", - "source" => "tok_123" + "source" => "tok_123", ]); static::assertInstanceOf(\Stripe\Charge::class, $resource); } diff --git a/tests/Stripe/Checkout/SessionTest.php b/tests/Stripe/Checkout/SessionTest.php index 404eee9c4..9eab988e9 100644 --- a/tests/Stripe/Checkout/SessionTest.php +++ b/tests/Stripe/Checkout/SessionTest.php @@ -31,7 +31,7 @@ public function testIsCreatable() 'receipt_email' => 'test@stripe.com', ], 'payment_method_types' => ['card'], - 'success_url' => 'https://stripe.com/success' + 'success_url' => 'https://stripe.com/success', ]); static::assertInstanceOf(\Stripe\Checkout\Session::class, $resource); } diff --git a/tests/Stripe/FileCreationTest.php b/tests/Stripe/FileCreationTest.php index 734f68636..1176c6fff 100644 --- a/tests/Stripe/FileCreationTest.php +++ b/tests/Stripe/FileCreationTest.php @@ -40,7 +40,7 @@ public function testIsCreatableWithFileHandle() $resource = File::create([ "purpose" => "dispute_evidence", "file" => $fp, - "file_link_data" => ["create" => true] + "file_link_data" => ["create" => true], ]); static::assertInstanceOf(\Stripe\File::class, $resource); } @@ -59,7 +59,7 @@ public function testIsCreatableWithCURLFile() $resource = File::create([ "purpose" => "dispute_evidence", "file" => $curlFile, - "file_link_data" => ["create" => true] + "file_link_data" => ["create" => true], ]); static::assertInstanceOf(\Stripe\File::class, $resource); } diff --git a/tests/Stripe/FileLinkTest.php b/tests/Stripe/FileLinkTest.php index 74edeb632..e16ecb5d7 100644 --- a/tests/Stripe/FileLinkTest.php +++ b/tests/Stripe/FileLinkTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/file_links' ); $resource = FileLink::create([ - "file" => "file_123" + "file" => "file_123", ]); static::assertInstanceOf(\Stripe\FileLink::class, $resource); } diff --git a/tests/Stripe/InvoiceItemTest.php b/tests/Stripe/InvoiceItemTest.php index 1d1012662..c93adcb44 100644 --- a/tests/Stripe/InvoiceItemTest.php +++ b/tests/Stripe/InvoiceItemTest.php @@ -36,7 +36,7 @@ public function testIsCreatable() $resource = InvoiceItem::create([ "amount" => 100, "currency" => "usd", - "customer" => "cus_123" + "customer" => "cus_123", ]); static::assertInstanceOf(\Stripe\InvoiceItem::class, $resource); } diff --git a/tests/Stripe/InvoiceTest.php b/tests/Stripe/InvoiceTest.php index 21a562f22..13ad286d0 100644 --- a/tests/Stripe/InvoiceTest.php +++ b/tests/Stripe/InvoiceTest.php @@ -35,7 +35,7 @@ public function testIsCreatable() '/v1/invoices' ); $resource = Invoice::create([ - "customer" => "cus_123" + "customer" => "cus_123", ]); static::assertInstanceOf(\Stripe\Invoice::class, $resource); } diff --git a/tests/Stripe/OrderTest.php b/tests/Stripe/OrderTest.php index e2138853d..cd8c5582d 100644 --- a/tests/Stripe/OrderTest.php +++ b/tests/Stripe/OrderTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/orders' ); $resource = Order::create([ - 'currency' => 'usd' + 'currency' => 'usd', ]); static::assertInstanceOf(\Stripe\Order::class, $resource); } diff --git a/tests/Stripe/PayoutTest.php b/tests/Stripe/PayoutTest.php index 4c0cbb2e2..bdd3e50de 100644 --- a/tests/Stripe/PayoutTest.php +++ b/tests/Stripe/PayoutTest.php @@ -35,7 +35,7 @@ public function testIsCreatable() ); $resource = Payout::create([ "amount" => 100, - "currency" => "usd" + "currency" => "usd", ]); static::assertInstanceOf(\Stripe\Payout::class, $resource); } diff --git a/tests/Stripe/PlanTest.php b/tests/Stripe/PlanTest.php index 92e0c6803..027602852 100644 --- a/tests/Stripe/PlanTest.php +++ b/tests/Stripe/PlanTest.php @@ -38,7 +38,7 @@ public function testIsCreatable() 'interval' => 'month', 'currency' => 'usd', 'nickname' => self::TEST_RESOURCE_ID, - 'id' => self::TEST_RESOURCE_ID + 'id' => self::TEST_RESOURCE_ID, ]); static::assertInstanceOf(\Stripe\Plan::class, $resource); } diff --git a/tests/Stripe/ProductTest.php b/tests/Stripe/ProductTest.php index cafdf7950..9e5587466 100644 --- a/tests/Stripe/ProductTest.php +++ b/tests/Stripe/ProductTest.php @@ -35,7 +35,7 @@ public function testIsCreatable() ); $resource = Product::create([ 'name' => 'name', - 'type' => 'good' + 'type' => 'good', ]); static::assertInstanceOf(\Stripe\Product::class, $resource); } diff --git a/tests/Stripe/RecipientTest.php b/tests/Stripe/RecipientTest.php index b378825b4..506b783de 100644 --- a/tests/Stripe/RecipientTest.php +++ b/tests/Stripe/RecipientTest.php @@ -35,7 +35,7 @@ public function testIsCreatable() ); $resource = Recipient::create([ "name" => "name", - "type" => "individual" + "type" => "individual", ]); static::assertInstanceOf(\Stripe\Recipient::class, $resource); } diff --git a/tests/Stripe/RefundTest.php b/tests/Stripe/RefundTest.php index 2896224e7..3bb90a350 100644 --- a/tests/Stripe/RefundTest.php +++ b/tests/Stripe/RefundTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/refunds' ); $resource = Refund::create([ - "charge" => "ch_123" + "charge" => "ch_123", ]); static::assertInstanceOf(\Stripe\Refund::class, $resource); } diff --git a/tests/Stripe/Reporting/ReportRunTest.php b/tests/Stripe/Reporting/ReportRunTest.php index 842aeb2bb..e9e8703cb 100644 --- a/tests/Stripe/Reporting/ReportRunTest.php +++ b/tests/Stripe/Reporting/ReportRunTest.php @@ -10,7 +10,7 @@ public function testIsCreatable() { $params = [ "parameters" => [ - "connected_account" => "acct_123" + "connected_account" => "acct_123", ], "report_type" => "activity.summary.1", ]; diff --git a/tests/Stripe/SKUTest.php b/tests/Stripe/SKUTest.php index c7151fbc3..7d6b56664 100644 --- a/tests/Stripe/SKUTest.php +++ b/tests/Stripe/SKUTest.php @@ -37,10 +37,10 @@ public function testIsCreatable() 'currency' => 'usd', 'inventory' => [ 'type' => 'finite', - 'quantity' => 1 + 'quantity' => 1, ], 'price' => 100, - 'product' => "prod_123" + 'product' => "prod_123", ]); static::assertInstanceOf(\Stripe\SKU::class, $resource); } diff --git a/tests/Stripe/SourceTest.php b/tests/Stripe/SourceTest.php index d0089f6ca..e069a1b3b 100644 --- a/tests/Stripe/SourceTest.php +++ b/tests/Stripe/SourceTest.php @@ -23,7 +23,7 @@ public function testIsCreatable() '/v1/sources' ); $resource = Source::create([ - "type" => "card" + "type" => "card", ]); static::assertInstanceOf(\Stripe\Source::class, $resource); } @@ -73,7 +73,7 @@ public function testCanSaveCardExpiryDate() 'card' => [ 'exp_month' => 12, 'exp_year' => 2022, - ] + ], ], null, false, diff --git a/tests/Stripe/StripeObjectTest.php b/tests/Stripe/StripeObjectTest.php index a21d57b3a..a2cf8bc2a 100644 --- a/tests/Stripe/StripeObjectTest.php +++ b/tests/Stripe/StripeObjectTest.php @@ -431,7 +431,7 @@ public function testDeepCopy() "map" => [ "0" => StripeObject::constructFrom(["id" => "index0"], $opts), "1" => "index1", - "2" => 2 + "2" => 2, ], ]; diff --git a/tests/Stripe/SubscriptionItemTest.php b/tests/Stripe/SubscriptionItemTest.php index e901059ce..b10d54226 100644 --- a/tests/Stripe/SubscriptionItemTest.php +++ b/tests/Stripe/SubscriptionItemTest.php @@ -12,11 +12,11 @@ public function testIsListable() 'get', '/v1/subscription_items', [ - "subscription" => "sub_123" + "subscription" => "sub_123", ] ); $resources = SubscriptionItem::all([ - "subscription" => "sub_123" + "subscription" => "sub_123", ]); static::assertInternalType('array', $resources->data); static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resources->data[0]); @@ -40,7 +40,7 @@ public function testIsCreatable() ); $resource = SubscriptionItem::create([ "plan" => "plan", - "subscription" => "sub_123" + "subscription" => "sub_123", ]); static::assertInstanceOf(\Stripe\SubscriptionItem::class, $resource); } diff --git a/tests/Stripe/SubscriptionTest.php b/tests/Stripe/SubscriptionTest.php index 6537cda5b..1a00316a8 100644 --- a/tests/Stripe/SubscriptionTest.php +++ b/tests/Stripe/SubscriptionTest.php @@ -34,7 +34,7 @@ public function testIsCreatable() '/v1/subscriptions' ); $resource = Subscription::create([ - "customer" => "cus_123" + "customer" => "cus_123", ]); static::assertInstanceOf(\Stripe\Subscription::class, $resource); } diff --git a/tests/Stripe/Terminal/LocationTest.php b/tests/Stripe/Terminal/LocationTest.php index 8170c18ef..383839fcc 100644 --- a/tests/Stripe/Terminal/LocationTest.php +++ b/tests/Stripe/Terminal/LocationTest.php @@ -65,8 +65,8 @@ public function testIsCreatable() "country" => "US", "state" => "CA", "postal_code" => "12345", - "city" => "San Francisco" - ] + "city" => "San Francisco", + ], ] ); $resource = Location::create([ @@ -76,8 +76,8 @@ public function testIsCreatable() "country" => "US", "state" => "CA", "postal_code" => "12345", - "city" => "San Francisco" - ] + "city" => "San Francisco", + ], ]); static::assertInstanceOf(\Stripe\Terminal\Location::class, $resource); } diff --git a/tests/Stripe/ThreeDSecureTest.php b/tests/Stripe/ThreeDSecureTest.php index 4cd22b26a..8cc7fc69f 100644 --- a/tests/Stripe/ThreeDSecureTest.php +++ b/tests/Stripe/ThreeDSecureTest.php @@ -25,7 +25,7 @@ public function testIsCreatable() $resource = ThreeDSecure::create([ "amount" => 100, "currency" => "usd", - "return_url" => "url" + "return_url" => "url", ]); static::assertInstanceOf(\Stripe\ThreeDSecure::class, $resource); } diff --git a/tests/Stripe/TopupTest.php b/tests/Stripe/TopupTest.php index 9417542ac..b92752e78 100644 --- a/tests/Stripe/TopupTest.php +++ b/tests/Stripe/TopupTest.php @@ -38,7 +38,7 @@ public function testIsCreatable() "currency" => "usd", "source" => "tok_123", "description" => "description", - "statement_descriptor" => "statement descriptor" + "statement_descriptor" => "statement descriptor", ]); static::assertInstanceOf(\Stripe\Topup::class, $resource); } diff --git a/tests/Stripe/TransferTest.php b/tests/Stripe/TransferTest.php index 13a5e0b0f..2bed136a0 100644 --- a/tests/Stripe/TransferTest.php +++ b/tests/Stripe/TransferTest.php @@ -37,7 +37,7 @@ public function testIsCreatable() $resource = Transfer::create([ "amount" => 100, "currency" => "usd", - "destination" => "acct_123" + "destination" => "acct_123", ]); static::assertInstanceOf(\Stripe\Transfer::class, $resource); } diff --git a/tests/Stripe/Util/RequestOptionsTest.php b/tests/Stripe/Util/RequestOptionsTest.php index 07a350cb2..5eb020f4d 100644 --- a/tests/Stripe/Util/RequestOptionsTest.php +++ b/tests/Stripe/Util/RequestOptionsTest.php @@ -52,7 +52,7 @@ public function testKeyArray() $opts = RequestOptions::parse( [ 'idempotency_key' => 'foo', - 'api_key' => 'foo' + 'api_key' => 'foo', ] ); static::assertSame('foo', $opts->apiKey); From bfb3fe3ecfee43f247d7080eb602f0d9990cb18e Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:35:57 -0800 Subject: [PATCH 94/97] Use trim_array_spaces rule --- .php_cs.dist | 1 + tests/Stripe/SubscriptionScheduleTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index 37da848b0..ed183a9f7 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -110,4 +110,5 @@ return PhpCsFixer\Config::create() 'string_line_ending' => true, 'ternary_operator_spaces' => true, 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, ]); diff --git a/tests/Stripe/SubscriptionScheduleTest.php b/tests/Stripe/SubscriptionScheduleTest.php index e8c2acee7..37c2ba932 100644 --- a/tests/Stripe/SubscriptionScheduleTest.php +++ b/tests/Stripe/SubscriptionScheduleTest.php @@ -38,7 +38,7 @@ public function testIsCreatable() "phases" => [ [ "plans" => [ - [ "plan" => "plan_123", "quantity" => 2], + ["plan" => "plan_123", "quantity" => 2], ], ], ], From 16ead4e3f1656d27ad9530f63626e0c030b4dbb9 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:36:16 -0800 Subject: [PATCH 95/97] Use unary_operator_spaces rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index ed183a9f7..1aa3625c3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -111,4 +111,5 @@ return PhpCsFixer\Config::create() 'ternary_operator_spaces' => true, 'trailing_comma_in_multiline_array' => true, 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, ]); From 70d8bbb9cf503e23fa0094372eb24d3378da2a40 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:36:41 -0800 Subject: [PATCH 96/97] Use whitespace_after_comma_in_array rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 1aa3625c3..8c4e85977 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -112,4 +112,5 @@ return PhpCsFixer\Config::create() 'trailing_comma_in_multiline_array' => true, 'trim_array_spaces' => true, 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, ]); From bd15068eb8732c3f0543bd9deb63ec01ca704632 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Fri, 7 Feb 2020 11:37:18 -0800 Subject: [PATCH 97/97] Use yoda_style rule --- .php_cs.dist | 1 + build.php | 4 ++-- lib/Account.php | 6 +++--- lib/ApiOperations/NestedResource.php | 2 +- lib/ApiRequestor.php | 26 +++++++++++++------------- lib/ApiResource.php | 4 ++-- lib/Customer.php | 2 +- lib/Exception/ApiErrorException.php | 4 ++-- lib/HttpClient/CurlClient.php | 28 ++++++++++++++-------------- lib/OAuth.php | 4 ++-- lib/Stripe.php | 2 +- lib/StripeObject.php | 16 ++++++++-------- lib/Subscription.php | 2 +- lib/Util/RequestOptions.php | 4 ++-- lib/Util/Util.php | 8 ++++---- lib/Webhook.php | 2 +- lib/WebhookSignature.php | 4 ++-- tests/Stripe/WebhookTest.php | 2 +- tests/TestCase.php | 6 +++--- tests/bootstrap.php | 6 +++--- 20 files changed, 67 insertions(+), 66 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 8c4e85977..ca4321f8b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -113,4 +113,5 @@ return PhpCsFixer\Config::create() 'trim_array_spaces' => true, 'unary_operator_spaces' => true, 'whitespace_after_comma_in_array' => true, + 'yoda_style' => true, ]); diff --git a/build.php b/build.php index e37b01952..355c38a92 100755 --- a/build.php +++ b/build.php @@ -14,12 +14,12 @@ } \passthru('composer update', $returnStatus); -if ($returnStatus !== 0) { +if (0 !== $returnStatus) { exit(1); } $config = $autoload ? 'phpunit.xml' : 'phpunit.no_autoload.xml'; \passthru("./vendor/bin/phpunit -c {$config}", $returnStatus); -if ($returnStatus !== 0) { +if (0 !== $returnStatus) { exit(1); } diff --git a/lib/Account.php b/lib/Account.php index 3cacbbb07..8b4408517 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -77,7 +77,7 @@ class Account extends ApiResource public static function getSavedNestedResources() { static $savedNestedResources = null; - if ($savedNestedResources === null) { + if (null === $savedNestedResources) { $savedNestedResources = new Util\Set([ 'external_account', 'bank_account', @@ -88,7 +88,7 @@ public static function getSavedNestedResources() public function instanceUrl() { - if ($this['id'] === null) { + if (null === $this['id']) { return '/v1/account'; } return parent::instanceUrl(); @@ -154,7 +154,7 @@ private function serializeAdditionalOwners($legalEntity, $additionalOwners) */ public static function retrieve($id = null, $opts = null) { - if (!$opts && \is_string($id) && \substr($id, 0, 3) === 'sk_') { + if (!$opts && \is_string($id) && 'sk_' === \substr($id, 0, 3)) { $opts = $id; $id = null; } diff --git a/lib/ApiOperations/NestedResource.php b/lib/ApiOperations/NestedResource.php index 8af96264f..d921a2ea7 100644 --- a/lib/ApiOperations/NestedResource.php +++ b/lib/ApiOperations/NestedResource.php @@ -37,7 +37,7 @@ protected static function _nestedResourceOperation($method, $url, $params = null protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null) { $url = static::resourceUrl($id) . $nestedPath; - if ($nestedId !== null) { + if (null !== $nestedId) { $url .= "/{$nestedId}"; } return $url; diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 0ed21ab38..11fde302f 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -61,7 +61,7 @@ private static function _telemetryJson($requestTelemetry) ]; $result = \json_encode($payload); - if ($result !== false) { + if (false !== $result) { return $result; } Stripe::getLogger()->error("Serializing telemetry payload failed!"); @@ -80,10 +80,10 @@ private static function _encodeObjects($d) if ($d instanceof ApiResource) { return Util\Util::utf8($d->id); } - if ($d === true) { + if (true === $d) { return 'true'; } - if ($d === false) { + if (false === $d) { return 'false'; } if (\is_array($d)) { @@ -170,10 +170,10 @@ private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $err case 400: // 'rate_limit' code is deprecated, but left here for backwards compatibility // for API versions earlier than 2015-09-08 - if ($code === 'rate_limit') { + if ('rate_limit' === $code) { return Exception\RateLimitException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param); } - if ($type === 'idempotency_error') { + if ('idempotency_error' === $type) { return Exception\IdempotencyException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code); } @@ -235,12 +235,12 @@ private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $e */ private static function _formatAppInfo($appInfo) { - if ($appInfo !== null) { + if (null !== $appInfo) { $string = $appInfo['name']; - if ($appInfo['version'] !== null) { + if (null !== $appInfo['version']) { $string .= '/' . $appInfo['version']; } - if ($appInfo['url'] !== null) { + if (null !== $appInfo['url']) { $string .= ' (' . $appInfo['url'] . ')'; } return $string; @@ -275,7 +275,7 @@ private static function _defaultHeaders($apiKey, $clientInfo = null) if ($clientInfo) { $ua = \array_merge($clientInfo, $ua); } - if ($appInfo !== null) { + if (null !== $appInfo) { $uaString .= ' ' . self::_formatAppInfo($appInfo); $ua['application'] = $appInfo; } @@ -332,7 +332,7 @@ private function _requestRaw($method, $url, $params, $headers) $defaultHeaders['Stripe-Account'] = Stripe::$accountId; } - if (Stripe::$enableTelemetry && self::$requestTelemetry !== null) { + if (Stripe::$enableTelemetry && null !== self::$requestTelemetry) { $defaultHeaders["X-Stripe-Client-Telemetry"] = self::_telemetryJson(self::$requestTelemetry); } @@ -388,14 +388,14 @@ private function _requestRaw($method, $url, $params, $headers) */ private function _processResourceParam($resource) { - if (\get_resource_type($resource) !== 'stream') { + if ('stream' !== \get_resource_type($resource)) { throw new Exception\InvalidArgumentException( 'Attempted to upload a resource that is not a stream' ); } $metaData = \stream_get_meta_data($resource); - if ($metaData['wrapper_type'] !== 'plainfile') { + if ('plainfile' !== $metaData['wrapper_type']) { throw new Exception\InvalidArgumentException( 'Only plainfile resource streams are supported' ); @@ -419,7 +419,7 @@ private function _interpretResponse($rbody, $rcode, $rheaders) { $resp = \json_decode($rbody, true); $jsonError = \json_last_error(); - if ($resp === null && $jsonError !== \JSON_ERROR_NONE) { + if (null === $resp && \JSON_ERROR_NONE !== $jsonError) { $msg = "Invalid response body from API: {$rbody} " . "(HTTP response code was {$rcode}, json_last_error() was {$jsonError})"; throw new Exception\UnexpectedValueException($msg, $rcode); diff --git a/lib/ApiResource.php b/lib/ApiResource.php index 95609fe8b..0b76fe648 100644 --- a/lib/ApiResource.php +++ b/lib/ApiResource.php @@ -21,7 +21,7 @@ abstract class ApiResource extends StripeObject public static function getSavedNestedResources() { static $savedNestedResources = null; - if ($savedNestedResources === null) { + if (null === $savedNestedResources) { $savedNestedResources = new Util\Set(); } return $savedNestedResources; @@ -92,7 +92,7 @@ public static function classUrl() */ public static function resourceUrl($id) { - if ($id === null) { + if (null === $id) { $class = \get_called_class(); $message = "Could not determine which URL to request: " . "{$class} instance has invalid ID: {$id}"; diff --git a/lib/Customer.php b/lib/Customer.php index bb3041016..2114571fc 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -53,7 +53,7 @@ class Customer extends ApiResource public static function getSavedNestedResources() { static $savedNestedResources = null; - if ($savedNestedResources === null) { + if (null === $savedNestedResources) { $savedNestedResources = new Util\Set([ 'source', ]); diff --git a/lib/Exception/ApiErrorException.php b/lib/Exception/ApiErrorException.php index 45a64b773..30225a54a 100644 --- a/lib/Exception/ApiErrorException.php +++ b/lib/Exception/ApiErrorException.php @@ -202,8 +202,8 @@ public function setStripeCode($stripeCode) */ public function __toString() { - $statusStr = ($this->getHttpStatus() === null) ? "" : "(Status {$this->getHttpStatus()}) "; - $idStr = ($this->getRequestId() === null) ? "" : "(Request {$this->getRequestId()}) "; + $statusStr = (null === $this->getHttpStatus()) ? "" : "(Status {$this->getHttpStatus()}) "; + $idStr = (null === $this->getRequestId()) ? "" : "(Request {$this->getRequestId()}) "; return "{$statusStr}{$idStr}{$this->getMessage()}"; } diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index 3b92de6ed..c12ab9731 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -204,7 +204,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $params = Util\Util::objectsToIds($params); - if ($method === 'get') { + if ('get' === $method) { if ($hasFile) { throw new Exception\UnexpectedValueException( "Issuing a GET request with a file parameter" @@ -215,10 +215,10 @@ public function request($method, $absUrl, $headers, $params, $hasFile) $encoded = Util\Util::encodeParameters($params); $absUrl = "{$absUrl}?{$encoded}"; } - } elseif ($method === 'post') { + } elseif ('post' === $method) { $opts[\CURLOPT_POST] = 1; $opts[\CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::encodeParameters($params); - } elseif ($method === 'delete') { + } elseif ('delete' === $method) { $opts[\CURLOPT_CUSTOMREQUEST] = 'DELETE'; if (\count($params) > 0) { $encoded = Util\Util::encodeParameters($params); @@ -230,7 +230,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) // It is only safe to retry network failures on POST requests if we // add an Idempotency-Key header - if (($method === 'post') && (Stripe::$maxNetworkRetries > 0)) { + if (('post' === $method) && (Stripe::$maxNetworkRetries > 0)) { if (!$this->hasHeader($headers, "Idempotency-Key")) { \array_push($headers, 'Idempotency-Key: ' . $this->randomGenerator->uuid()); } @@ -277,7 +277,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) private function executeRequestWithRetries($opts, $absUrl) { $numRetries = 0; - $isPost = \array_key_exists(\CURLOPT_POST, $opts) && $opts[\CURLOPT_POST] === 1; + $isPost = \array_key_exists(\CURLOPT_POST, $opts) && 1 === $opts[\CURLOPT_POST]; while (true) { $rcode = 0; @@ -288,7 +288,7 @@ private function executeRequestWithRetries($opts, $absUrl) $rheaders = new Util\CaseInsensitiveArray(); $headerCallback = function ($curl, $header_line) use (&$rheaders) { // Ignore the HTTP request line (HTTP/1.1 200 OK) - if (\strpos($header_line, ":") === false) { + if (false === \strpos($header_line, ":")) { return \strlen($header_line); } list($key, $value) = \explode(":", \trim($header_line), 2); @@ -301,7 +301,7 @@ private function executeRequestWithRetries($opts, $absUrl) \curl_setopt_array($this->curlHandle, $opts); $rbody = \curl_exec($this->curlHandle); - if ($rbody === false) { + if (false === $rbody) { $errno = \curl_errno($this->curlHandle); $message = \curl_error($this->curlHandle); } else { @@ -329,7 +329,7 @@ private function executeRequestWithRetries($opts, $absUrl) } } - if ($rbody === false) { + if (false === $rbody) { $this->handleCurlError($absUrl, $errno, $message, $numRetries); } @@ -395,30 +395,30 @@ private function shouldRetry($errno, $rcode, $rheaders, $numRetries) } // Retry on timeout-related problems (either on open or read). - if ($errno === \CURLE_OPERATION_TIMEOUTED) { + if (\CURLE_OPERATION_TIMEOUTED === $errno) { return true; } // Destination refused the connection, the connection was reset, or a // variety of other connection failures. This could occur from a single // saturated server, so retry in case it's intermittent. - if ($errno === \CURLE_COULDNT_CONNECT) { + if (\CURLE_COULDNT_CONNECT === $errno) { return true; } // The API may ask us not to retry (eg; if doing so would be a no-op) // or advise us to retry (eg; in cases of lock timeouts); we defer to that. if (isset($rheaders['stripe-should-retry'])) { - if ($rheaders['stripe-should-retry'] === 'false') { + if ('false' === $rheaders['stripe-should-retry']) { return false; } - if ($rheaders['stripe-should-retry'] === 'true') { + if ('true' === $rheaders['stripe-should-retry']) { return true; } } // 409 Conflict - if ($rcode === 409) { + if (409 === $rcode) { return true; } @@ -524,7 +524,7 @@ private function canSafelyUseHttp2() private function hasHeader($headers, $name) { foreach ($headers as $header) { - if (\strncasecmp($header, "{$name}: ", \strlen($name) + 2) === 0) { + if (0 === \strncasecmp($header, "{$name}: ", \strlen($name) + 2)) { return true; } } diff --git a/lib/OAuth.php b/lib/OAuth.php index a85f67781..7ab1fd4e6 100644 --- a/lib/OAuth.php +++ b/lib/OAuth.php @@ -79,10 +79,10 @@ public static function deauthorize($params = null, $opts = null) private static function _getClientId($params = null) { $clientId = ($params && \array_key_exists('client_id', $params)) ? $params['client_id'] : null; - if ($clientId === null) { + if (null === $clientId) { $clientId = Stripe::getClientId(); } - if ($clientId === null) { + if (null === $clientId) { $msg = 'No client_id provided. (HINT: set your client_id using ' . '"Stripe::setClientId()". You can find your client_ids ' . 'in your Stripe dashboard at ' diff --git a/lib/Stripe.php b/lib/Stripe.php index d230c9003..e142d9eb1 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -84,7 +84,7 @@ public static function getClientId() */ public static function getLogger() { - if (self::$logger === null) { + if (null === self::$logger) { return new Util\DefaultLogger(); } return self::$logger; diff --git a/lib/StripeObject.php b/lib/StripeObject.php index a2d133fd0..5b69dfc39 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -24,7 +24,7 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable public static function getPermanentAttributes() { static $permanentAttributes = null; - if ($permanentAttributes === null) { + if (null === $permanentAttributes) { $permanentAttributes = new Util\Set([ 'id', ]); @@ -85,7 +85,7 @@ public static function getPermanentAttributes() public static function getAdditiveParams() { static $additiveParams = null; - if ($additiveParams === null) { + if (null === $additiveParams) { // Set `metadata` as additive so that when it's set directly we remember // to clear keys that may have been previously set by sending empty // values for them. @@ -107,7 +107,7 @@ public function __construct($id = null, $opts = null) $this->_values = []; $this->_unsavedValues = new Util\Set(); $this->_transientValues = new Util\Set(); - if ($id !== null) { + if (null !== $id) { $this->_values['id'] = $id; } } @@ -122,7 +122,7 @@ public function __set($k, $v) ); } - if ($v === "") { + if ("" === $v) { throw new Exception\InvalidArgumentException( 'You cannot set \'' . $k . '\'to an empty string. ' . 'We interpret empty strings as NULL in requests. ' @@ -280,7 +280,7 @@ public function updateAttributes($values, $opts = null, $dirty = true) // This is necessary in case metadata is empty, as PHP arrays do // not differentiate between lists and hashes, and we consider // empty arrays to be lists. - if (($k === "metadata") && (\is_array($v))) { + if (("metadata" === $k) && (\is_array($v))) { $this->_values[$k] = StripeObject::constructFrom($v, $opts); } else { $this->_values[$k] = Util\Util::convertToStripeObject($v, $opts); @@ -327,7 +327,7 @@ public function serializeParameters($force = false) $updateParams = \array_filter( $updateParams, function ($v) { - return $v !== null; + return null !== $v; } ); @@ -358,7 +358,7 @@ public function serializeParamsValue($value, $original, $unsaved, $force, $key = // We throw an error if a property was set explicitly but we can't do // anything with it because the integration is probably not working as the // user intended it to. - if ($value === null) { + if (null === $value) { return ""; } if (($value instanceof ApiResource) && (!$value->saveWithParent)) { @@ -422,7 +422,7 @@ public function toArray() }; return \array_reduce(\array_keys($this->_values), function ($acc, $k) use ($maybeToArray) { - if ($k[0] === '_') { + if ('_' === $k[0]) { return $acc; } $v = $this->_values[$k]; diff --git a/lib/Subscription.php b/lib/Subscription.php index 7e0188b42..5e9e28b05 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -72,7 +72,7 @@ class Subscription extends ApiResource public static function getSavedNestedResources() { static $savedNestedResources = null; - if ($savedNestedResources === null) { + if (null === $savedNestedResources) { $savedNestedResources = new Util\Set([ 'source', ]); diff --git a/lib/Util/RequestOptions.php b/lib/Util/RequestOptions.php index b34b6dbbd..0442e35b5 100644 --- a/lib/Util/RequestOptions.php +++ b/lib/Util/RequestOptions.php @@ -44,10 +44,10 @@ public function __debugInfo() public function merge($options) { $other_options = self::parse($options); - if ($other_options->apiKey === null) { + if (null === $other_options->apiKey) { $other_options->apiKey = $this->apiKey; } - if ($other_options->apiBase === null) { + if (null === $other_options->apiBase) { $other_options->apiBase = $this->apiBase; } $other_options->headers = \array_merge($this->headers, $other_options->headers); diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 077cf1c83..14a3d70d6 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -151,7 +151,7 @@ public static function convertToStripeObject($resp, $opts) */ public static function utf8($value) { - if (self::$isMbstringAvailable === null) { + if (null === self::$isMbstringAvailable) { self::$isMbstringAvailable = \function_exists('mb_detect_encoding'); if (!self::$isMbstringAvailable) { @@ -162,7 +162,7 @@ public static function utf8($value) } } - if (\is_string($value) && self::$isMbstringAvailable && \mb_detect_encoding($value, "UTF-8", true) !== "UTF-8") { + if (\is_string($value) && self::$isMbstringAvailable && "UTF-8" !== \mb_detect_encoding($value, "UTF-8", true)) { return \utf8_encode($value); } return $value; @@ -178,7 +178,7 @@ public static function utf8($value) */ public static function secureCompare($a, $b) { - if (self::$isHashEqualsAvailable === null) { + if (null === self::$isHashEqualsAvailable) { self::$isHashEqualsAvailable = \function_exists('hash_equals'); } @@ -193,7 +193,7 @@ public static function secureCompare($a, $b) for ($i = 0; $i < \strlen($a); ++$i) { $result |= \ord($a[$i]) ^ \ord($b[$i]); } - return $result === 0; + return 0 === $result; } /** diff --git a/lib/Webhook.php b/lib/Webhook.php index 3f546832d..84bde71a1 100644 --- a/lib/Webhook.php +++ b/lib/Webhook.php @@ -28,7 +28,7 @@ public static function constructEvent($payload, $sigHeader, $secret, $tolerance $data = \json_decode($payload, true); $jsonError = \json_last_error(); - if ($data === null && $jsonError !== \JSON_ERROR_NONE) { + if (null === $data && \JSON_ERROR_NONE !== $jsonError) { $msg = "Invalid payload: {$payload} " . "(json_last_error() was {$jsonError})"; throw new Exception\UnexpectedValueException($msg); diff --git a/lib/WebhookSignature.php b/lib/WebhookSignature.php index edcaca0ce..95afa0776 100644 --- a/lib/WebhookSignature.php +++ b/lib/WebhookSignature.php @@ -25,7 +25,7 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul // Extract timestamp and signatures from header $timestamp = self::getTimestamp($header); $signatures = self::getSignatures($header, self::EXPECTED_SCHEME); - if ($timestamp === -1) { + if (-1 === $timestamp) { throw Exception\SignatureVerificationException::factory( "Unable to extract timestamp and signatures from header", $payload, @@ -84,7 +84,7 @@ private static function getTimestamp($header) foreach ($items as $item) { $itemParts = \explode("=", $item, 2); - if ($itemParts[0] === "t") { + if ("t" === $itemParts[0]) { if (!\is_numeric($itemParts[1])) { return -1; } diff --git a/tests/Stripe/WebhookTest.php b/tests/Stripe/WebhookTest.php index 61a67e708..f330c0ebc 100644 --- a/tests/Stripe/WebhookTest.php +++ b/tests/Stripe/WebhookTest.php @@ -17,7 +17,7 @@ private function generateHeader($opts = []) $secret = \array_key_exists('secret', $opts) ? $opts['secret'] : self::SECRET; $scheme = \array_key_exists('scheme', $opts) ? $opts['scheme'] : WebhookSignature::EXPECTED_SCHEME; $signature = \array_key_exists('signature', $opts) ? $opts['signature'] : null; - if ($signature === null) { + if (null === $signature) { $signedPayload = "{$timestamp}.{$payload}"; $signature = \hash_hmac("sha256", $signedPayload, $secret); } diff --git a/tests/TestCase.php b/tests/TestCase.php index ce6c84eee..b0ea1d133 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -152,7 +152,7 @@ private function prepareRequestMock( ) { ApiRequestor::setHttpClient($this->clientMock); - if ($base === null) { + if (null === $base) { $base = Stripe::$apiBase; } $absUrl = $base . $path; @@ -165,7 +165,7 @@ private function prepareRequestMock( static::identicalTo($absUrl), // for headers, we only check that all of the headers provided in $headers are // present in the list of headers of the actual request - $headers === null ? static::anything() : static::callback(function ($array) use ($headers) { + null === $headers ? static::anything() : static::callback(function ($array) use ($headers) { foreach ($headers as $header) { if (!\in_array($header, $array, true)) { return false; @@ -173,7 +173,7 @@ private function prepareRequestMock( } return true; }), - $params === null ? static::anything() : static::identicalTo($params), + null === $params ? static::anything() : static::identicalTo($params), static::identicalTo($hasFile) ); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ef1980d3f..a5fb00ee2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -34,19 +34,19 @@ $headers = \explode("\n", $resp); foreach ($headers as $header) { $pair = \explode(":", $header, 2); - if ($pair[0] === "Stripe-Mock-Version") { + if ("Stripe-Mock-Version" === $pair[0]) { $version = \trim($pair[1]); } } -if ($version === null) { +if (null === $version) { echo "Could not retrieve Stripe-Mock-Version header. Are you sure " . "that the server at `" . MOCK_HOST . ":" . MOCK_PORT . "` is a stripe-mock " . "instance?"; exit(1); } -if ($version !== "master" && \version_compare($version, MOCK_MINIMUM_VERSION) === -1) { +if ("master" !== $version && -1 === \version_compare($version, MOCK_MINIMUM_VERSION)) { echo "Your version of stripe-mock (" . $version . ") is too old. The minimum " . "version to run this test suite is " . MOCK_MINIMUM_VERSION . ". " . "Please see its repository for upgrade instructions.\n";