From 8e7b66bf81d61d44361e6c722c770b7c59543b67 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:01:47 -0800 Subject: [PATCH 01/18] Use phpdoc_scalar rule --- .php_cs.dist | 1 + lib/ApiResource.php | 2 +- lib/ApiResponse.php | 2 +- lib/Collection.php | 2 +- lib/ErrorObject.php | 2 +- lib/HttpClient/ClientInterface.php | 2 +- lib/HttpClient/CurlClient.php | 12 ++++++------ lib/OAuthErrorObject.php | 2 +- lib/Stripe.php | 4 ++-- lib/StripeObject.php | 4 ++-- lib/Util/Util.php | 4 ++-- tests/Stripe/HttpClient/CurlClientTest.php | 4 ++-- tests/TestCase.php | 2 +- 13 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 55a95f2b7c..e2d57126ea 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -13,5 +13,6 @@ return PhpCsFixer\Config::create() ], 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, + 'phpdoc_scalar' => true, ]) ; diff --git a/lib/ApiResource.php b/lib/ApiResource.php index 2eb1f02bfa..35449d1e6f 100644 --- a/lib/ApiResource.php +++ b/lib/ApiResource.php @@ -28,7 +28,7 @@ public static function getSavedNestedResources() } /** - * @var boolean A flag that can be set a behavior that will cause this + * @var bool A flag that can be set a behavior that will cause this * resource to be encoded and sent up along with an update of its parent * resource. This is usually not desirable because resources are updated * individually on their own endpoints, but there are certain cases, diff --git a/lib/ApiResponse.php b/lib/ApiResponse.php index dc3eef1376..a6407a6ad8 100644 --- a/lib/ApiResponse.php +++ b/lib/ApiResponse.php @@ -33,7 +33,7 @@ class ApiResponse /** * @param string $body - * @param integer $code + * @param int $code * @param array|CaseInsensitiveArray|null $headers * @param array|null $json */ diff --git a/lib/Collection.php b/lib/Collection.php index 3fe45409ca..c585deac3b 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -168,7 +168,7 @@ public static function emptyCollection($opts = null) /** * Returns true if the page object contains no element. * - * @return boolean + * @return bool */ public function isEmpty() { diff --git a/lib/ErrorObject.php b/lib/ErrorObject.php index 285a51154f..9df400ae6d 100644 --- a/lib/ErrorObject.php +++ b/lib/ErrorObject.php @@ -137,7 +137,7 @@ class ErrorObject extends StripeObject * * @param array $values * @param null|string|array|Util\RequestOptions $opts - * @param boolean $partial Defaults to false. + * @param bool $partial Defaults to false. */ public function refreshFrom($values, $opts, $partial = false) { diff --git a/lib/HttpClient/ClientInterface.php b/lib/HttpClient/ClientInterface.php index 4d31e4f1c9..857598a0cc 100644 --- a/lib/HttpClient/ClientInterface.php +++ b/lib/HttpClient/ClientInterface.php @@ -9,7 +9,7 @@ interface ClientInterface * @param string $absUrl The URL being requested, including domain and protocol * @param array $headers Headers to be used in the request (full strings, not KV pairs) * @param array $params KV pairs for parameters. Can be nested for arrays and hashes - * @param boolean $hasFile Whether or not $params references a file (via an @ prefix or + * @param bool $hasFile Whether or not $params references a file (via an @ prefix or * CURLFile) * * @throws \Stripe\Exception\ApiConnectionException diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index ad03938dfc..d27ac59ce7 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -98,7 +98,7 @@ public function getUserAgentInfo() } /** - * @return boolean + * @return bool */ public function getEnablePersistentConnections() { @@ -106,7 +106,7 @@ public function getEnablePersistentConnections() } /** - * @param boolean $enable + * @param bool $enable */ public function setEnablePersistentConnections($enable) { @@ -114,7 +114,7 @@ public function setEnablePersistentConnections($enable) } /** - * @return boolean + * @return bool */ public function getEnableHttp2() { @@ -122,7 +122,7 @@ public function getEnableHttp2() } /** - * @param boolean $enable + * @param bool $enable */ public function setEnableHttp2($enable) { @@ -504,7 +504,7 @@ private function resetCurlHandle() /** * Indicates whether it is safe to use HTTP/2 or not. * - * @return boolean + * @return bool */ private function canSafelyUseHttp2() { @@ -519,7 +519,7 @@ private function canSafelyUseHttp2() * * @param string[] $headers * @param string $name - * @return boolean + * @return bool */ private function hasHeader($headers, $name) { diff --git a/lib/OAuthErrorObject.php b/lib/OAuthErrorObject.php index ca2bbc553e..b4d6c5f407 100644 --- a/lib/OAuthErrorObject.php +++ b/lib/OAuthErrorObject.php @@ -17,7 +17,7 @@ class OAuthErrorObject extends StripeObject * * @param array $values * @param null|string|array|Util\RequestOptions $opts - * @param boolean $partial Defaults to false. + * @param bool $partial Defaults to false. */ public function refreshFrom($values, $opts, $partial = false) { diff --git a/lib/Stripe.php b/lib/Stripe.php index d42cf5ed77..bfe74fa75c 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -159,7 +159,7 @@ public static function setCABundlePath($caBundlePath) } /** - * @return boolean + * @return bool */ public static function getVerifySslCerts() { @@ -167,7 +167,7 @@ public static function getVerifySslCerts() } /** - * @param boolean $verify + * @param bool $verify */ public static function setVerifySslCerts($verify) { diff --git a/lib/StripeObject.php b/lib/StripeObject.php index c60a61c531..ddd79db8cd 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -234,7 +234,7 @@ public static function constructFrom($values, $opts = null) * * @param array $values * @param null|string|array|Util\RequestOptions $opts - * @param boolean $partial Defaults to false. + * @param bool $partial Defaults to false. */ public function refreshFrom($values, $opts, $partial = false) { @@ -271,7 +271,7 @@ public function refreshFrom($values, $opts, $partial = false) * * @param array $values * @param null|string|array|Util\RequestOptions $opts - * @param boolean $dirty Defaults to true. + * @param bool $dirty Defaults to true. */ public function updateAttributes($values, $opts = null, $dirty = true) { diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 94f9653b6c..2fcf3f4f5f 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -15,7 +15,7 @@ abstract class Util * integers starting at 0. Empty arrays are considered to be lists. * * @param array|mixed $array - * @return boolean true if the given object is a list. + * @return bool true if the given object is a list. */ public static function isList($array) { @@ -327,7 +327,7 @@ public static function normalizeId($id) /** * Returns UNIX timestamp in milliseconds * - * @return integer current time in millis + * @return int current time in millis */ public static function currentTimeMillis() { diff --git a/tests/Stripe/HttpClient/CurlClientTest.php b/tests/Stripe/HttpClient/CurlClientTest.php index b2bf760658..cbe5a0b286 100644 --- a/tests/Stripe/HttpClient/CurlClientTest.php +++ b/tests/Stripe/HttpClient/CurlClientTest.php @@ -10,13 +10,13 @@ class CurlClientTest extends \Stripe\TestCase /** @var \ReflectionProperty */ private $maxNetworkRetryDelayProperty; - /** @var double */ + /** @var float */ private $origInitialNetworkRetryDelay; /** @var int */ private $origMaxNetworkRetries; - /** @var double */ + /** @var float */ private $origMaxNetworkRetryDelay; /** @var \ReflectionMethod */ diff --git a/tests/TestCase.php b/tests/TestCase.php index 4428c635c6..9339919c01 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -105,7 +105,7 @@ function ($method, $absUrl, $headers, $params, $hasFile) { * @param bool $hasFile Whether the request parameters contains a file. * Defaults to false. * @param array $response - * @param integer $rcode + * @param int $rcode * @param string|null $base * * @return array From 28a5355c6bbfb430f90fff2de3bfab85eda1add2 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:05:54 -0800 Subject: [PATCH 02/18] Use phpdoc_add_missing_param_annotation rule --- .php_cs.dist | 1 + lib/ApiResource.php | 4 ++++ lib/HttpClient/CurlClient.php | 2 ++ lib/Stripe.php | 5 +++-- lib/StripeObject.php | 5 +++++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index e2d57126ea..cceba5cb3a 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -13,6 +13,7 @@ return PhpCsFixer\Config::create() ], 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, + 'phpdoc_add_missing_param_annotation' => true, 'phpdoc_scalar' => true, ]) ; diff --git a/lib/ApiResource.php b/lib/ApiResource.php index 35449d1e6f..a62f844dc9 100644 --- a/lib/ApiResource.php +++ b/lib/ApiResource.php @@ -88,6 +88,10 @@ public static function classUrl() } /** + * @param string|null $id the ID of the resource + * + * @throws Exception\UnexpectedValueException if $id is null + * * @return string The instance endpoint URL for the given class. */ public static function resourceUrl($id) diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index d27ac59ce7..ae6cecb859 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -63,6 +63,7 @@ public static function instance() * throw an exception if $defaultOptions returns a non-array value. * * @param array|callable|null $defaultOptions + * @param \Stripe\Util\RandomGenerator|null $randomGenerator */ public function __construct($defaultOptions = null, $randomGenerator = null) { @@ -273,6 +274,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile) /** * @param array $opts cURL options + * @param string $absUrl */ private function executeRequestWithRetries($opts, $absUrl) { diff --git a/lib/Stripe.php b/lib/Stripe.php index bfe74fa75c..2be01b43df 100644 --- a/lib/Stripe.php +++ b/lib/Stripe.php @@ -202,8 +202,9 @@ public static function getAppInfo() /** * @param string $appName The application's name - * @param string $appVersion The application's version - * @param string $appUrl The application's URL + * @param string|null $appVersion The application's version + * @param string|null $appUrl The application's URL + * @param string|null $appPartnerId The application's partner ID */ public static function setAppInfo($appName, $appVersion = null, $appUrl = null, $appPartnerId = null) { diff --git a/lib/StripeObject.php b/lib/StripeObject.php index ddd79db8cd..5c29ea0ecf 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -293,6 +293,7 @@ public function updateAttributes($values, $opts = null, $dirty = true) } /** + * @param bool $force Defaults to false. * @return array A recursive mapping of attributes to values for this object, * including the proper value for deleted attributes. */ @@ -477,6 +478,8 @@ protected function dirtyValue($value) /** * Produces a deep copy of the given object including support for arrays * and StripeObjects. + * + * @param mixed $obj */ protected static function deepCopy($obj) { @@ -499,6 +502,8 @@ protected static function deepCopy($obj) /** * Returns a hash of empty values for all the values that are in the given * StripeObject. + * + * @param mixed $obj */ public static function emptyValues($obj) { From 8be2049dbccc67666757b7c9babc72ca214fdfd7 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:08:32 -0800 Subject: [PATCH 03/18] Use phpdoc_indent rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index cceba5cb3a..39a92b5cd2 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -14,6 +14,7 @@ return PhpCsFixer\Config::create() 'linebreak_after_opening_tag' => true, 'native_function_invocation' => true, 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_indent' => true, 'phpdoc_scalar' => true, ]) ; From 3804cbdb55fd5f5f35b73dc41c6d08e159e2748d Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:08:56 -0800 Subject: [PATCH 04/18] Use phpdoc_inline_tag rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 39a92b5cd2..95646903d1 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,6 +15,7 @@ return PhpCsFixer\Config::create() 'native_function_invocation' => true, 'phpdoc_add_missing_param_annotation' => true, 'phpdoc_indent' => true, + 'phpdoc_inline_tag' => true, 'phpdoc_scalar' => true, ]) ; From f20e23213f42aa677802bf03a3c8d37f4ea89c77 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:09:24 -0800 Subject: [PATCH 05/18] Use phpdoc_no_access rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 95646903d1..9163bfda32 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -16,6 +16,7 @@ return PhpCsFixer\Config::create() 'phpdoc_add_missing_param_annotation' => true, 'phpdoc_indent' => true, 'phpdoc_inline_tag' => true, + 'phpdoc_no_access' => true, 'phpdoc_scalar' => true, ]) ; From 6bd7b4acbce23bf7ba5ad043bb334be5eb55d0c0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:12:05 -0800 Subject: [PATCH 06/18] Use phpdoc_no_empty_return rule --- .php_cs.dist | 1 + lib/StripeObject.php | 1 - lib/Util/LoggerInterface.php | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 9163bfda32..908a72b5f2 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -17,6 +17,7 @@ return PhpCsFixer\Config::create() 'phpdoc_indent' => true, 'phpdoc_inline_tag' => true, 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => true, 'phpdoc_scalar' => true, ]) ; diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 5c29ea0ecf..406e5e7721 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -532,7 +532,6 @@ public function getLastResponse() * Sets the last response from the Stripe API * * @param ApiResponse $resp - * @return void */ public function setLastResponse($resp) { diff --git a/lib/Util/LoggerInterface.php b/lib/Util/LoggerInterface.php index cf04e1d2ba..f61629dc91 100644 --- a/lib/Util/LoggerInterface.php +++ b/lib/Util/LoggerInterface.php @@ -30,7 +30,6 @@ interface LoggerInterface * * @param string $message * @param array $context - * @return void */ public function error($message, array $context = []); } From 537b8b6a2c59774f11878baeb33180bfe613f17e Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:12:39 -0800 Subject: [PATCH 07/18] Use phpdoc_no_useless_inheritdoc rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 908a72b5f2..302dbd0a77 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -18,6 +18,7 @@ return PhpCsFixer\Config::create() 'phpdoc_inline_tag' => true, 'phpdoc_no_access' => true, 'phpdoc_no_empty_return' => true, + 'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_scalar' => true, ]) ; From cd93dad0f5b80e23407da76f1eb31b9cc64ecbe2 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:13:07 -0800 Subject: [PATCH 08/18] Use phpdoc_return_self_reference rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 302dbd0a77..626634920e 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -19,6 +19,7 @@ return PhpCsFixer\Config::create() 'phpdoc_no_access' => true, 'phpdoc_no_empty_return' => true, 'phpdoc_no_useless_inheritdoc' => true, + 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, ]) ; From aca76e185125da4965ea48abb559b1e7f0389c9c Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:27:19 -0800 Subject: [PATCH 09/18] Use phpdoc_single_line_var_spacing rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 626634920e..bb0eff29fa 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -21,5 +21,6 @@ return PhpCsFixer\Config::create() 'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, + 'phpdoc_single_line_var_spacing' => true, ]) ; From eee0c644d7393bf46250a07bce0136ac520d99b4 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:27:52 -0800 Subject: [PATCH 10/18] Use phpdoc_trim rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index bb0eff29fa..94e5fe0887 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -22,5 +22,6 @@ return PhpCsFixer\Config::create() 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_trim' => true, ]) ; From 7c4e2e6678868ba230c3d05e1e9874a00a646055 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:28:11 -0800 Subject: [PATCH 11/18] Use phpdoc_trim_consecutive_blank_line_separation rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 94e5fe0887..6023ed990f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -23,5 +23,6 @@ return PhpCsFixer\Config::create() 'phpdoc_scalar' => true, 'phpdoc_single_line_var_spacing' => true, 'phpdoc_trim' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, ]) ; From c8d6f79df05456a7e64b514eb8dc93b368e8eb8f Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:28:33 -0800 Subject: [PATCH 12/18] Use phpdoc_types rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 6023ed990f..e017b3450e 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -24,5 +24,6 @@ return PhpCsFixer\Config::create() 'phpdoc_single_line_var_spacing' => true, 'phpdoc_trim' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'phpdoc_types' => true, ]) ; From 93d43195c98dc5600741561eb07fb33eed769790 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:30:12 -0800 Subject: [PATCH 13/18] Use phpdoc_types_order rule --- .php_cs.dist | 3 +++ lib/ApiOperations/Request.php | 2 +- lib/ApiRequestor.php | 10 +++++----- lib/ErrorObject.php | 2 +- lib/OAuthErrorObject.php | 2 +- lib/StripeObject.php | 6 +++--- lib/Util/Util.php | 6 +++--- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index e017b3450e..1d201fa3e6 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -25,5 +25,8 @@ return PhpCsFixer\Config::create() 'phpdoc_trim' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, 'phpdoc_types' => true, + 'phpdoc_types_order' => [ + 'null_adjustment' => 'always_last', + ], ]) ; diff --git a/lib/ApiOperations/Request.php b/lib/ApiOperations/Request.php index ba8e018f38..e9f4e7897f 100644 --- a/lib/ApiOperations/Request.php +++ b/lib/ApiOperations/Request.php @@ -10,7 +10,7 @@ trait Request { /** - * @param array|null|mixed $params The list of parameters to validate + * @param array|mixed|null $params The list of parameters to validate * * @throws \Stripe\Exception\InvalidArgumentException if $params exists and is not an array */ diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 8a6c8e0ca1..8551ccd917 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -71,9 +71,9 @@ private static function _telemetryJson($requestTelemetry) /** * @static * - * @param ApiResource|bool|array|mixed $d + * @param ApiResource|array|bool|mixed $d * - * @return ApiResource|array|string|mixed + * @return ApiResource|array|mixed|string */ private static function _encodeObjects($d) { @@ -194,7 +194,7 @@ private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $err /** * @static * - * @param string|bool $rbody + * @param bool|string $rbody * @param int $rcode * @param array $rheaders * @param array $resp @@ -227,9 +227,9 @@ private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $e /** * @static * - * @param null|array $appInfo + * @param array|null $appInfo * - * @return null|string + * @return string|null */ private static function _formatAppInfo($appInfo) { diff --git a/lib/ErrorObject.php b/lib/ErrorObject.php index 9df400ae6d..d2089df7b7 100644 --- a/lib/ErrorObject.php +++ b/lib/ErrorObject.php @@ -136,7 +136,7 @@ class ErrorObject extends StripeObject * Refreshes this object using the provided values. * * @param array $values - * @param null|string|array|Util\RequestOptions $opts + * @param array|string|Util\RequestOptions|null $opts * @param bool $partial Defaults to false. */ public function refreshFrom($values, $opts, $partial = false) diff --git a/lib/OAuthErrorObject.php b/lib/OAuthErrorObject.php index b4d6c5f407..6cd355fd6d 100644 --- a/lib/OAuthErrorObject.php +++ b/lib/OAuthErrorObject.php @@ -16,7 +16,7 @@ class OAuthErrorObject extends StripeObject * Refreshes this object using the provided values. * * @param array $values - * @param null|string|array|Util\RequestOptions $opts + * @param array|string|Util\RequestOptions|null $opts * @param bool $partial Defaults to false. */ public function refreshFrom($values, $opts, $partial = false) diff --git a/lib/StripeObject.php b/lib/StripeObject.php index 406e5e7721..a8440c9111 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -218,7 +218,7 @@ public function values() * This unfortunately needs to be public to be used in Util\Util * * @param array $values - * @param null|string|array|Util\RequestOptions $opts + * @param array|string|Util\RequestOptions|null $opts * * @return static The object constructed from the given values. */ @@ -233,7 +233,7 @@ public static function constructFrom($values, $opts = null) * Refreshes this object using the provided values. * * @param array $values - * @param null|string|array|Util\RequestOptions $opts + * @param array|string|Util\RequestOptions|null $opts * @param bool $partial Defaults to false. */ public function refreshFrom($values, $opts, $partial = false) @@ -270,7 +270,7 @@ public function refreshFrom($values, $opts, $partial = false) * Mass assigns attributes on the model. * * @param array $values - * @param null|string|array|Util\RequestOptions $opts + * @param array|string|Util\RequestOptions|null $opts * @param bool $dirty Defaults to true. */ public function updateAttributes($values, $opts = null, $dirty = true) diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 2fcf3f4f5f..51b883ff59 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -36,7 +36,7 @@ public static function isList($array) * * @param array $resp The response from the Stripe API. * @param array $opts - * @return StripeObject|array + * @return array|StripeObject */ public static function convertToStripeObject($resp, $opts) { @@ -144,9 +144,9 @@ public static function convertToStripeObject($resp, $opts) } /** - * @param string|mixed $value A string to UTF8-encode. + * @param mixed|string $value A string to UTF8-encode. * - * @return string|mixed The UTF8-encoded string, or the object passed in if + * @return mixed|string The UTF8-encoded string, or the object passed in if * it wasn't a string. */ public static function utf8($value) From 6be2949caa86ca9bce455ea869351bcff1aeba81 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:30:30 -0800 Subject: [PATCH 14/18] Use phpdoc_var_annotation_correct_order rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 1d201fa3e6..c394ad9c7e 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -28,5 +28,6 @@ return PhpCsFixer\Config::create() 'phpdoc_types_order' => [ 'null_adjustment' => 'always_last', ], + 'phpdoc_var_annotation_correct_order' => true, ]) ; From 6d603886a793d3f14d0c16837e327618603de081 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 11:30:50 -0800 Subject: [PATCH 15/18] Use phpdoc_var_without_name rule --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index c394ad9c7e..3b482384f3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -29,5 +29,6 @@ return PhpCsFixer\Config::create() 'null_adjustment' => 'always_last', ], 'phpdoc_var_annotation_correct_order' => true, + 'phpdoc_var_without_name' => true, ]) ; From 25526af6d1d9219260b3e3ca0f1f878b6704d3ec Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 13:02:07 -0800 Subject: [PATCH 16/18] Rebase --- lib/PaymentIntent.php | 1 - lib/SetupIntent.php | 1 - lib/Subscription.php | 1 - 3 files changed, 3 deletions(-) diff --git a/lib/PaymentIntent.php b/lib/PaymentIntent.php index 7abc3555f1..8071136351 100644 --- a/lib/PaymentIntent.php +++ b/lib/PaymentIntent.php @@ -56,7 +56,6 @@ class PaymentIntent extends ApiResource /** * These constants are possible representations of the status field. * - * * @see https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status */ const STATUS_CANCELED = 'canceled'; diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index 04ec0e528b..eafd7a35cf 100644 --- a/lib/SetupIntent.php +++ b/lib/SetupIntent.php @@ -40,7 +40,6 @@ class SetupIntent extends ApiResource /** * These constants are possible representations of the status field. * - * * @see https://stripe.com/docs/api/setup_intents/object#setup_intent_object-status */ const STATUS_CANCELED = 'canceled'; diff --git a/lib/Subscription.php b/lib/Subscription.php index 87c6203e83..d955680bc2 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -55,7 +55,6 @@ class Subscription extends ApiResource /** * These constants are possible representations of the status field. * - * * @see https://stripe.com/docs/api#subscription_object-status */ const STATUS_ACTIVE = 'active'; From 2907a0a51d5479fa3cd16fd0f11a899a492e8dd0 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 13:04:30 -0800 Subject: [PATCH 17/18] Use phpdoc_separation rule --- .php_cs.dist | 1 + lib/ApiRequestor.php | 2 ++ lib/Capability.php | 1 + lib/Collection.php | 3 +++ lib/CustomerBalanceTransaction.php | 1 + lib/ErrorObject.php | 1 + lib/HttpClient/ClientInterface.php | 1 + lib/HttpClient/CurlClient.php | 2 ++ lib/Invoice.php | 2 +- lib/Person.php | 2 ++ lib/RequestTelemetry.php | 1 + lib/StripeObject.php | 1 + lib/TaxId.php | 2 ++ lib/Util/RandomGenerator.php | 1 + lib/Util/RequestOptions.php | 2 ++ lib/Util/Util.php | 4 ++++ lib/Webhook.php | 2 ++ lib/WebhookSignature.php | 5 +++++ 18 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index 3b482384f3..b94c08d450 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -21,6 +21,7 @@ return PhpCsFixer\Config::create() 'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, + 'phpdoc_separation' => true, 'phpdoc_single_line_var_spacing' => true, 'phpdoc_trim' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, diff --git a/lib/ApiRequestor.php b/lib/ApiRequestor.php index 8551ccd917..9c7475e907 100644 --- a/lib/ApiRequestor.php +++ b/lib/ApiRequestor.php @@ -46,9 +46,11 @@ public function __construct($apiKey = null, $apiBase = null) /** * Creates a telemetry json blob for use in 'X-Stripe-Client-Telemetry' headers + * * @static * * @param RequestTelemetry $requestTelemetry + * * @return string */ private static function _telemetryJson($requestTelemetry) diff --git a/lib/Capability.php b/lib/Capability.php index 56d1596cd9..e38b5b6ce2 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -23,6 +23,7 @@ class Capability extends ApiResource /** * Possible string representations of a capability's status. + * * @link https://stripe.com/docs/api/capabilities/object#capability_object-status */ const STATUS_ACTIVE = 'active'; diff --git a/lib/Collection.php b/lib/Collection.php index c585deac3b..d1d9d733e6 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -158,6 +158,7 @@ public function autoPagingIterator() * behavior of the API when it attempts to return a page beyond the last. * * @param array|string|null $opts + * * @return Collection */ public static function emptyCollection($opts = null) @@ -183,6 +184,7 @@ public function isEmpty() * * @param array|null $params * @param array|string|null $opts + * * @return Collection */ public function nextPage($params = null, $opts = null) @@ -210,6 +212,7 @@ public function nextPage($params = null, $opts = null) * * @param array|null $params * @param array|string|null $opts + * * @return Collection */ public function previousPage($params = null, $opts = null) diff --git a/lib/CustomerBalanceTransaction.php b/lib/CustomerBalanceTransaction.php index 459c130804..0e96d2d105 100644 --- a/lib/CustomerBalanceTransaction.php +++ b/lib/CustomerBalanceTransaction.php @@ -27,6 +27,7 @@ class CustomerBalanceTransaction extends ApiResource /** * Possible string representations of a balance transaction's type. + * * @link https://stripe.com/docs/api/customers/customer_balance_transaction_object#customer_balance_transaction_object-type */ const TYPE_ADJUSTEMENT = 'adjustment'; diff --git a/lib/ErrorObject.php b/lib/ErrorObject.php index d2089df7b7..93c88fe0c4 100644 --- a/lib/ErrorObject.php +++ b/lib/ErrorObject.php @@ -38,6 +38,7 @@ class ErrorObject extends StripeObject { /** * Possible string representations of an error's code. + * * @link https://stripe.com/docs/error-codes */ const CODE_ACCOUNT_ALREADY_EXISTS = 'account_already_exists'; diff --git a/lib/HttpClient/ClientInterface.php b/lib/HttpClient/ClientInterface.php index 857598a0cc..ec4ef3a6b5 100644 --- a/lib/HttpClient/ClientInterface.php +++ b/lib/HttpClient/ClientInterface.php @@ -14,6 +14,7 @@ interface ClientInterface * * @throws \Stripe\Exception\ApiConnectionException * @throws \Stripe\Exception\UnexpectedValueException + * * @return array An array whose first element is raw request body, second * element is HTTP status code and third array of HTTP headers. */ diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php index ae6cecb859..a25ef2f9b2 100644 --- a/lib/HttpClient/CurlClient.php +++ b/lib/HttpClient/CurlClient.php @@ -343,6 +343,7 @@ private function executeRequestWithRetries($opts, $absUrl) * @param int $errno * @param string $message * @param int $numRetries + * * @throws Exception\ApiConnectionException */ private function handleCurlError($url, $errno, $message, $numRetries) @@ -521,6 +522,7 @@ private function canSafelyUseHttp2() * * @param string[] $headers * @param string $name + * * @return bool */ private function hasHeader($headers, $name) diff --git a/lib/Invoice.php b/lib/Invoice.php index fa849d0dab..3a7ed0c0bd 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -114,8 +114,8 @@ class Invoice extends ApiResource /** * Possible string representations of the `billing` property. - * @deprecated Use `collection_method` instead. * + * @deprecated Use `collection_method` instead. * @see https://stripe.com/docs/api/invoices/object#invoice_object-billing */ const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically'; diff --git a/lib/Person.php b/lib/Person.php index 1153097852..0dbd78683b 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -42,6 +42,7 @@ class Person extends ApiResource /** * Possible string representations of a person's gender. + * * @link https://stripe.com/docs/api/persons/object#person_object-gender */ const GENDER_MALE = 'male'; @@ -49,6 +50,7 @@ class Person extends ApiResource /** * Possible string representations of a person's verification status. + * * @link https://stripe.com/docs/api/persons/object#person_object-verification-status */ const VERIFICATION_STATUS_PENDING = 'pending'; diff --git a/lib/RequestTelemetry.php b/lib/RequestTelemetry.php index f677a7f76e..1d01ae75c2 100644 --- a/lib/RequestTelemetry.php +++ b/lib/RequestTelemetry.php @@ -6,6 +6,7 @@ * Class RequestTelemetry * * Tracks client request telemetry + * * @package Stripe */ class RequestTelemetry diff --git a/lib/StripeObject.php b/lib/StripeObject.php index a8440c9111..90fdbc3914 100644 --- a/lib/StripeObject.php +++ b/lib/StripeObject.php @@ -294,6 +294,7 @@ public function updateAttributes($values, $opts = null, $dirty = true) /** * @param bool $force Defaults to false. + * * @return array A recursive mapping of attributes to values for this object, * including the proper value for deleted attributes. */ diff --git a/lib/TaxId.php b/lib/TaxId.php index cd4190f12d..dc0a4cfd77 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -25,6 +25,7 @@ class TaxId extends ApiResource /** * Possible string representations of a tax id's type. + * * @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-type */ const TYPE_AU_ABN = 'au_abn'; @@ -46,6 +47,7 @@ class TaxId extends ApiResource /** * Possible string representations of the verification status. + * * @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-verification */ const VERIFICATION_STATUS_PENDING = 'pending'; diff --git a/lib/Util/RandomGenerator.php b/lib/Util/RandomGenerator.php index 0709f65c03..490377fb4c 100644 --- a/lib/Util/RandomGenerator.php +++ b/lib/Util/RandomGenerator.php @@ -12,6 +12,7 @@ class RandomGenerator * Returns a random value between 0 and $max. * * @param float $max (optional) + * * @return float */ public function randFloat($max = 1.0) diff --git a/lib/Util/RequestOptions.php b/lib/Util/RequestOptions.php index c5acaaae14..0f651d2441 100644 --- a/lib/Util/RequestOptions.php +++ b/lib/Util/RequestOptions.php @@ -37,6 +37,7 @@ public function __debugInfo() /** * Unpacks an options array and merges it into the existing RequestOptions * object. + * * @param array|string|null $options a key => value array * * @return RequestOptions @@ -68,6 +69,7 @@ public function discardNonPersistentHeaders() /** * Unpacks an options array into an RequestOptions object + * * @param array|string|null $options a key => value array * * @return RequestOptions diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 51b883ff59..f332288813 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -15,6 +15,7 @@ abstract class Util * integers starting at 0. Empty arrays are considered to be lists. * * @param array|mixed $array + * * @return bool true if the given object is a list. */ public static function isList($array) @@ -36,6 +37,7 @@ public static function isList($array) * * @param array $resp The response from the Stripe API. * @param array $opts + * * @return array|StripeObject */ public static function convertToStripeObject($resp, $opts) @@ -175,6 +177,7 @@ public static function utf8($value) * * @param string $a one of the strings to compare. * @param string $b the other string to compare. + * * @return bool true if the strings are equal, false otherwise. */ public static function secureCompare($a, $b) @@ -204,6 +207,7 @@ public static function secureCompare($a, $b) * Also clears out null values. * * @param mixed $h + * * @return mixed */ public static function objectsToIds($h) diff --git a/lib/Webhook.php b/lib/Webhook.php index a252a4a7ec..a34771fa81 100644 --- a/lib/Webhook.php +++ b/lib/Webhook.php @@ -18,7 +18,9 @@ abstract class Webhook * @param string $secret secret used to generate the signature. * @param int $tolerance maximum difference allowed between the header's * timestamp and the current time + * * @return Event the Event instance + * * @throws Exception\UnexpectedValueException if the payload is not valid JSON, * @throws Exception\SignatureVerificationException if the verification fails. */ diff --git a/lib/WebhookSignature.php b/lib/WebhookSignature.php index 1425260472..dc4f4d5f29 100644 --- a/lib/WebhookSignature.php +++ b/lib/WebhookSignature.php @@ -17,7 +17,9 @@ abstract class WebhookSignature * @param string $secret secret used to generate the signature. * @param int $tolerance maximum difference allowed between the header's * timestamp and the current time + * * @throws Exception\SignatureVerificationException if the verification fails. + * * @return bool */ public static function verifyHeader($payload, $header, $secret, $tolerance = null) @@ -75,6 +77,7 @@ public static function verifyHeader($payload, $header, $secret, $tolerance = nul * Extracts the timestamp in a signature header. * * @param string $header the signature header + * * @return int the timestamp contained in the header, or -1 if no valid * timestamp is found */ @@ -100,6 +103,7 @@ private static function getTimestamp($header) * * @param string $header the signature header * @param string $scheme the signature scheme to look for. + * * @return array the list of signatures matching the provided scheme. */ private static function getSignatures($header, $scheme) @@ -124,6 +128,7 @@ private static function getSignatures($header, $scheme) * * @param string $payload the payload to sign. * @param string $secret the secret used to generate the signature. + * * @return string the signature as a string. */ private static function computeSignature($payload, $secret) From 4ff2575689c149d6ee4f8a0cff0ccd8a8ebc0669 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 6 Feb 2020 13:05:05 -0800 Subject: [PATCH 18/18] Use phpdoc_no_alias_tag rule --- .php_cs.dist | 1 + lib/AlipayAccount.php | 6 +++--- lib/Capability.php | 2 +- lib/CustomerBalanceTransaction.php | 2 +- lib/ErrorObject.php | 2 +- lib/Person.php | 4 ++-- lib/TaxId.php | 4 ++-- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index b94c08d450..ebef7f8b14 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -17,6 +17,7 @@ return PhpCsFixer\Config::create() 'phpdoc_indent' => true, 'phpdoc_inline_tag' => true, 'phpdoc_no_access' => true, + 'phpdoc_no_alias_tag' => true, 'phpdoc_no_empty_return' => true, 'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_return_self_reference' => true, diff --git a/lib/AlipayAccount.php b/lib/AlipayAccount.php index d430ab5ba6..abbb95c90a 100644 --- a/lib/AlipayAccount.php +++ b/lib/AlipayAccount.php @@ -8,7 +8,7 @@ * @package Stripe * * @deprecated Alipay accounts are deprecated. Please use the sources API instead. - * @link https://stripe.com/docs/sources/alipay + * @see https://stripe.com/docs/sources/alipay */ class AlipayAccount extends ApiResource { @@ -43,7 +43,7 @@ public function instanceUrl() * @throws \Stripe\Exception\BadMethodCallException * * @deprecated Alipay accounts are deprecated. Please use the sources API instead. - * @link https://stripe.com/docs/sources/alipay + * @see https://stripe.com/docs/sources/alipay */ public static function retrieve($_id, $_opts = null) { @@ -61,7 +61,7 @@ public static function retrieve($_id, $_opts = null) * @throws \Stripe\Exception\BadMethodCallException * * @deprecated Alipay accounts are deprecated. Please use the sources API instead. - * @link https://stripe.com/docs/sources/alipay + * @see https://stripe.com/docs/sources/alipay */ public static function update($_id, $_params = null, $_options = null) { diff --git a/lib/Capability.php b/lib/Capability.php index e38b5b6ce2..6988b9ae7f 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -24,7 +24,7 @@ class Capability extends ApiResource /** * Possible string representations of a capability's status. * - * @link https://stripe.com/docs/api/capabilities/object#capability_object-status + * @see https://stripe.com/docs/api/capabilities/object#capability_object-status */ const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; diff --git a/lib/CustomerBalanceTransaction.php b/lib/CustomerBalanceTransaction.php index 0e96d2d105..e844ea49c4 100644 --- a/lib/CustomerBalanceTransaction.php +++ b/lib/CustomerBalanceTransaction.php @@ -28,7 +28,7 @@ class CustomerBalanceTransaction extends ApiResource /** * Possible string representations of a balance transaction's type. * - * @link https://stripe.com/docs/api/customers/customer_balance_transaction_object#customer_balance_transaction_object-type + * @see https://stripe.com/docs/api/customers/customer_balance_transaction_object#customer_balance_transaction_object-type */ const TYPE_ADJUSTEMENT = 'adjustment'; const TYPE_APPLIED_TO_INVOICE = 'applied_to_invoice'; diff --git a/lib/ErrorObject.php b/lib/ErrorObject.php index 93c88fe0c4..d54eb8349b 100644 --- a/lib/ErrorObject.php +++ b/lib/ErrorObject.php @@ -39,7 +39,7 @@ class ErrorObject extends StripeObject /** * Possible string representations of an error's code. * - * @link https://stripe.com/docs/error-codes + * @see https://stripe.com/docs/error-codes */ const CODE_ACCOUNT_ALREADY_EXISTS = 'account_already_exists'; const CODE_ACCOUNT_COUNTRY_INVALID_ADDRESS = 'account_country_invalid_address'; diff --git a/lib/Person.php b/lib/Person.php index 0dbd78683b..22c1ac66b1 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -43,7 +43,7 @@ class Person extends ApiResource /** * Possible string representations of a person's gender. * - * @link https://stripe.com/docs/api/persons/object#person_object-gender + * @see https://stripe.com/docs/api/persons/object#person_object-gender */ const GENDER_MALE = 'male'; const GENDER_FEMALE = 'female'; @@ -51,7 +51,7 @@ class Person extends ApiResource /** * Possible string representations of a person's verification status. * - * @link https://stripe.com/docs/api/persons/object#person_object-verification-status + * @see https://stripe.com/docs/api/persons/object#person_object-verification-status */ const VERIFICATION_STATUS_PENDING = 'pending'; const VERIFICATION_STATUS_UNVERIFIED = 'unverified'; diff --git a/lib/TaxId.php b/lib/TaxId.php index dc0a4cfd77..94cfaea331 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -26,7 +26,7 @@ class TaxId extends ApiResource /** * Possible string representations of a tax id's type. * - * @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-type + * @see https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-type */ const TYPE_AU_ABN = 'au_abn'; const TYPE_CA_BN = 'ca_bn'; @@ -48,7 +48,7 @@ class TaxId extends ApiResource /** * Possible string representations of the verification status. * - * @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-verification + * @see https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-verification */ const VERIFICATION_STATUS_PENDING = 'pending'; const VERIFICATION_STATUS_UNAVAILABLE = 'unavailable';