diff --git a/lib/Tumblr/API/Client.php b/lib/Tumblr/API/Client.php index 7d51138..6700522 100644 --- a/lib/Tumblr/API/Client.php +++ b/lib/Tumblr/API/Client.php @@ -7,16 +7,19 @@ */ class Client { - + /** @var string */ private $apiKey; + /** @var RequestHandler */ + public $requestHandler; + /** * Create a new Client * * @param string $consumerKey the consumer key - * @param string $consumerSecret the consumer secret - * @param string $token oauth token - * @param string $secret oauth token secret + * @param string|null $consumerSecret the consumer secret + * @param string|null $token oauth token + * @param string|null $secret oauth token secret */ public function __construct($consumerKey, $consumerSecret = null, $token = null, $secret = null) { @@ -32,7 +35,8 @@ public function __construct($consumerKey, $consumerSecret = null, $token = null, * Set the consumer for this client * * @param string $consumerKey the consumer key - * @param string $consumerSecret the consumer secret + * @param string|null $consumerSecret the consumer secret + * @return void */ public function setConsumer($consumerKey, $consumerSecret) { @@ -265,7 +269,7 @@ public function getBlogInfo($blogName) * @param string $blogName the nae of the blog to look up * @param int $size the size to retrieve * - * @return string the avatar url + * @return string|null the avatar url */ public function getBlogAvatar($blogName, $size = null) { @@ -375,7 +379,7 @@ public function getSubmissionPosts($blogName, $options = null) * Make a GET request to the given endpoint and return the response * * @param string $path the path to call on - * @param array $options the options to call with + * @param array|null $options the options to call with * @param bool $addApiKey whether or not to add the api key * * @return array the response object (parsed) @@ -432,10 +436,10 @@ private function parseResponse($response) * Make a GET request to the given endpoint and return the response * * @param string $path the path to call on - * @param array $options the options to call with + * @param array|null $options the options to call with * @param bool $addApiKey whether or not to add the api key * - * @return string url redirected to (or null) + * @return string|null url redirected to (or null) */ private function getRedirect($path, $options, $addApiKey) { @@ -452,7 +456,7 @@ private function getRedirect($path, $options, $addApiKey) * * @param string $method the method to call: GET, POST * @param string $path the path to call on - * @param array $options the options to call with + * @param array|null $options the options to call with * @param bool $addApiKey whether or not to add the api key * * @return \stdClass the response object (not parsed) diff --git a/lib/Tumblr/API/RequestException.php b/lib/Tumblr/API/RequestException.php index 00af04b..465c2ca 100644 --- a/lib/Tumblr/API/RequestException.php +++ b/lib/Tumblr/API/RequestException.php @@ -4,6 +4,8 @@ class RequestException extends \Exception { + /** @var string|int */ + public $statusCode; /** * @param \stdClass $response @@ -27,6 +29,10 @@ public function __construct($response) parent::__construct($this->message, $this->statusCode); } + /** + * @return string + */ + #[\ReturnTypeWillChange] public function __toString() { return __CLASS__ . ": [$this->statusCode]: $this->message\n"; diff --git a/lib/Tumblr/API/RequestHandler.php b/lib/Tumblr/API/RequestHandler.php index c14eefc..f7ae44f 100644 --- a/lib/Tumblr/API/RequestHandler.php +++ b/lib/Tumblr/API/RequestHandler.php @@ -8,14 +8,22 @@ */ class RequestHandler { - + /** @var \Eher\OAuth\Consumer */ private $consumer; + /** @var \Eher\OAuth\Token */ private $token; + /** @var \Eher\OAuth\HmacSha1 */ private $signatureMethod; + /** @var string */ private $baseUrl; + + /** @var string */ private $version; + /** @var \GuzzleHttp\Client */ + public $client; + /** * Instantiate a new RequestHandler */ @@ -34,7 +42,8 @@ public function __construct() * Set the consumer for this request handler * * @param string $key the consumer key - * @param string $secret the consumer secret + * @param string|null $secret the consumer secret + * @return void */ public function setConsumer($key, $secret) { @@ -46,6 +55,7 @@ public function setConsumer($key, $secret) * * @param string $token the oauth token * @param string $secret the oauth secret + * @return void */ public function setToken($token, $secret) { @@ -56,6 +66,7 @@ public function setToken($token, $secret) * Set the base url for this request handler. * * @param string $url The base url (e.g. https://api.tumblr.com) + * @return void */ public function setBaseUrl($url) { @@ -72,7 +83,7 @@ public function setBaseUrl($url) * * @param string $method one of GET, POST * @param string $path the path to hit - * @param array $options the array of params + * @param array|null $options the array of params * * @return \stdClass response object */ @@ -96,7 +107,7 @@ public function request($method, $path, $options) ); $oauth->sign_request($this->signatureMethod, $this->consumer, $this->token); $authHeader = $oauth->to_header(); - $pieces = explode(' ', $authHeader, 2); + $pieces = explode(' ', $authHeader, 2) + [1 => '']; $authString = $pieces[1];