Skip to content

Commit

Permalink
Merge pull request #1487 from stripe/richardm-better-method-types
Browse files Browse the repository at this point in the history
PHPDoc: use union of literals for $method parameter throughout
  • Loading branch information
richardm-stripe authored Jul 18, 2023
2 parents 73383b4 + 873dca2 commit 67d021b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/ApiOperations/NestedResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
trait NestedResource
{
/**
* @param string $method
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param null|array $params
* @param null|array|string $options
Expand Down
8 changes: 4 additions & 4 deletions lib/ApiOperations/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected static function _validateParams($params = null)
}

/**
* @param string $method HTTP method ('get', 'post', etc.)
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param array $params list of parameters for the request
* @param null|array|string $options
Expand All @@ -46,7 +46,7 @@ protected function _request($method, $url, $params = [], $options = null)
}

/**
* @param string $method HTTP method ('get', 'post', etc.)
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param callable $readBodyChunk function that will receive chunks of data from a successful request body
* @param array $params list of parameters for the request
Expand All @@ -61,7 +61,7 @@ protected function _requestStream($method, $url, $readBodyChunk, $params = [], $
}

/**
* @param string $method HTTP method ('get', 'post', etc.)
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param array $params list of parameters for the request
* @param null|array|string $options
Expand All @@ -82,7 +82,7 @@ protected static function _staticRequest($method, $url, $params, $options)
}

/**
* @param string $method HTTP method ('get', 'post', etc.)
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param callable $readBodyChunk function that will receive chunks of data from a successful request body
* @param array $params list of parameters for the request
Expand Down
8 changes: 4 additions & 4 deletions lib/ApiRequestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static function _encodeObjects($d)
}

/**
* @param string $method
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param null|array $params
* @param null|array $headers
Expand All @@ -128,7 +128,7 @@ public function request($method, $url, $params = null, $headers = null)
}

/**
* @param string $method
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param callable $readBodyChunkCallable
* @param null|array $params
Expand Down Expand Up @@ -432,7 +432,7 @@ function ($key) use ($params) {
}

/**
* @param string $method
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param array $params
* @param array $headers
Expand Down Expand Up @@ -469,7 +469,7 @@ private function _requestRaw($method, $url, $params, $headers)
}

/**
* @param string $method
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param array $params
* @param array $headers
Expand Down
8 changes: 4 additions & 4 deletions lib/BaseStripeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function getFilesBase()
/**
* Sends a request to Stripe's API.
*
* @param string $method the HTTP method
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
Expand All @@ -143,7 +143,7 @@ public function request($method, $path, $params, $opts)
* Sends a request to Stripe's API, passing chunks of the streamed response
* into a user-provided $readBodyChunkCallable callback.
*
* @param string $method the HTTP method
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param callable $readBodyChunkCallable a function that will be called
* @param array $params the parameters of the request
Expand All @@ -161,7 +161,7 @@ public function requestStream($method, $path, $readBodyChunkCallable, $params, $
/**
* Sends a request to Stripe's API.
*
* @param string $method the HTTP method
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
Expand All @@ -185,7 +185,7 @@ public function requestCollection($method, $path, $params, $opts)
/**
* Sends a request to Stripe's API.
*
* @param string $method the HTTP method
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
Expand Down
2 changes: 1 addition & 1 deletion lib/HttpClient/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
interface ClientInterface
{
/**
* @param string $method The HTTP method being used
* @param 'delete'|'get'|'post' $method The HTTP method being used
* @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
Expand Down
2 changes: 1 addition & 1 deletion lib/HttpClient/StreamingClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
interface StreamingClientInterface
{
/**
* @param string $method The HTTP method being used
* @param 'delete'|'get'|'post' $method The HTTP method being used
* @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
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/OAuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class OAuthService extends \Stripe\Service\AbstractService
/**
* Sends a request to Stripe's Connect API.
*
* @param string $method the HTTP method
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
Expand Down
2 changes: 1 addition & 1 deletion lib/StripeClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface StripeClientInterface extends BaseStripeClientInterface
/**
* Sends a request to Stripe's API.
*
* @param string $method the HTTP method
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
Expand Down
10 changes: 5 additions & 5 deletions tests/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function tearDownConfig()
* Sets up a request expectation with the provided parameters. The request
* will actually go through and be emitted.
*
* @param string $method HTTP method (e.g. 'post', 'get', etc.)
* @param 'delete'|'get'|'post' $method HTTP method (e.g. 'post', 'get', etc.)
* @param string $path relative path (e.g. '/v1/charges')
* @param null|array $params array of parameters. If null, parameters will
* not be checked.
Expand Down Expand Up @@ -106,7 +106,7 @@ function ($method, $absUrl, $headers, $params, $hasFile) {
* Sets up a request expectation with the provided parameters. The request
* will actually go through and be emitted.
*
* @param string $method HTTP method (e.g. 'post', 'get', etc.)
* @param 'delete'|'get'|'post' $method HTTP method (e.g. 'post', 'get', etc.)
* @param string $path relative path (e.g. '/v1/charges')
* @param null|array $params array of parameters. If null, parameters will
* not be checked.
Expand Down Expand Up @@ -142,7 +142,7 @@ function ($method, $absUrl, $readBodyChunkCallable, $headers, $params, $hasFile)
* will not actually be emitted, instead the provided response parameters
* will be returned.
*
* @param string $method HTTP method (e.g. 'post', 'get', etc.)
* @param 'delete'|'get'|'post' $method HTTP method (e.g. 'post', 'get', etc.)
* @param string $path relative path (e.g. '/v1/charges')
* @param null|array $params array of parameters. If null, parameters will
* not be checked.
Expand Down Expand Up @@ -175,7 +175,7 @@ protected function stubRequest(
* prepare the client mocker to expect an invocation of the `request` method
* with the provided arguments.
*
* @param string $method HTTP method (e.g. 'post', 'get', etc.)
* @param 'delete'|'get'|'post' $method HTTP method (e.g. 'post', 'get', etc.)
* @param string $path relative path (e.g. '/v1/charges')
* @param null|array $params array of parameters. If null, parameters will
* not be checked.
Expand Down Expand Up @@ -231,7 +231,7 @@ private function prepareRequestMock(
* prepare the client mocker to expect an invocation of the `request` method
* with the provided arguments.
*
* @param string $method HTTP method (e.g. 'post', 'get', etc.)
* @param 'delete'|'get'|'post' $method HTTP method (e.g. 'post', 'get', etc.)
* @param string $path relative path (e.g. '/v1/charges')
* @param null|array $params array of parameters. If null, parameters will
* not be checked.
Expand Down

0 comments on commit 67d021b

Please sign in to comment.