1 | <?php |
||
16 | abstract class AbstractService extends BaseAbstractService implements ServiceInterface |
||
17 | { |
||
18 | /** @const OAUTH_VERSION */ |
||
19 | const OAUTH_VERSION = 1; |
||
20 | |||
21 | /** @var SignatureInterface */ |
||
22 | protected $signature; |
||
23 | |||
24 | /** @var UriInterface|null */ |
||
25 | protected $baseApiUri; |
||
26 | |||
27 | /** |
||
28 | * {@inheritDoc} |
||
29 | */ |
||
30 | public function __construct( |
||
44 | |||
45 | /** |
||
46 | * {@inheritDoc} |
||
47 | */ |
||
48 | public function requestRequestToken() |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public function getAuthorizationUri(array $additionalParameters = array()) |
||
74 | |||
75 | /** |
||
76 | * {@inheritDoc} |
||
77 | */ |
||
78 | public function requestAccessToken($token, $verifier, $tokenSecret = null) |
||
108 | |||
109 | /** |
||
110 | * Refreshes an OAuth1 access token |
||
111 | * @param TokenInterface $token |
||
112 | * @return TokenInterface $token |
||
113 | */ |
||
114 | public function refreshAccessToken(TokenInterface $token) |
||
117 | |||
118 | /** |
||
119 | * Sends an authenticated API request to the path provided. |
||
120 | * If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used. |
||
121 | * |
||
122 | * @param string|UriInterface $path |
||
123 | * @param string $method HTTP method |
||
124 | * @param array $body Request body if applicable (key/value pairs) |
||
125 | * @param array $extraHeaders Extra headers if applicable. |
||
126 | * These will override service-specific any defaults. |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) |
||
144 | |||
145 | /** |
||
146 | * Return any additional headers always needed for this service implementation's OAuth calls. |
||
147 | * |
||
148 | * @return array |
||
149 | */ |
||
150 | protected function getExtraOAuthHeaders() |
||
154 | |||
155 | /** |
||
156 | * Return any additional headers always needed for this service implementation's API calls. |
||
157 | * |
||
158 | * @return array |
||
159 | */ |
||
160 | protected function getExtraApiHeaders() |
||
164 | |||
165 | /** |
||
166 | * Builds the authorization header for getting an access or request token. |
||
167 | * |
||
168 | * @param array $extraParameters |
||
169 | * |
||
170 | * @return string |
||
171 | */ |
||
172 | protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = array()) |
||
192 | |||
193 | /** |
||
194 | * Builds the authorization header to get an access token. |
||
195 | * |
||
196 | * @param string $method |
||
197 | * @param UriInterface $uri The uri the request is headed |
||
198 | * @param TokenInterface $token |
||
199 | * @param array $bodyParams Request body if applicable (key/value pairs) |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | protected function buildAuthorizationHeaderForAccessRequest( |
||
214 | |||
215 | /** |
||
216 | * Builds the authorization header for an authenticated API request |
||
217 | * |
||
218 | * @param string $method |
||
219 | * @param UriInterface $uri The uri the request is headed |
||
220 | * @param TokenInterface $token |
||
221 | * @param array $bodyParams Request body if applicable (key/value pairs) |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | protected function buildAuthorizationHeaderForAPIRequest( |
||
265 | |||
266 | /** |
||
267 | * Builds the authorization header array. |
||
268 | * |
||
269 | * @return array |
||
270 | */ |
||
271 | protected function getBasicAuthorizationHeaderInfo() |
||
285 | |||
286 | /** |
||
287 | * Pseudo random string generator used to build a unique string to sign each request |
||
288 | * |
||
289 | * @param int $length |
||
290 | * |
||
291 | * @return string |
||
292 | */ |
||
293 | protected function generateNonce($length = 32) |
||
305 | |||
306 | /** |
||
307 | * @return string |
||
308 | */ |
||
309 | protected function getSignatureMethod() |
||
313 | |||
314 | /** |
||
315 | * This returns the version used in the authorization header of the requests |
||
316 | * |
||
317 | * @return string |
||
318 | */ |
||
319 | protected function getVersion() |
||
323 | |||
324 | /** |
||
325 | * Parses the request token response and returns a TokenInterface. |
||
326 | * |
||
327 | * @param string $responseBody |
||
328 | * |
||
329 | * @return TokenInterface |
||
330 | * |
||
331 | * @throws TokenResponseException |
||
332 | */ |
||
333 | protected function parseRequestTokenResponse($responseBody) |
||
354 | |||
355 | /** |
||
356 | * Parses the access token response and returns a TokenInterface. |
||
357 | * |
||
358 | * @param string $responseBody |
||
359 | * |
||
360 | * @return TokenInterface |
||
361 | * |
||
362 | * @throws TokenResponseException |
||
363 | */ |
||
364 | protected function parseAccessTokenResponse($responseBody) |
||
379 | |||
380 | /** |
||
381 | * General validation of the response body. |
||
382 | * |
||
383 | * @param string $responseBody |
||
384 | * @return array |
||
385 | * @throws TokenResponseException |
||
386 | */ |
||
387 | protected function validateTokenResponse($responseBody) |
||
401 | } |
||
402 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.