1 | <?php |
||
15 | abstract class AbstractService extends BaseAbstractService implements ServiceInterface |
||
16 | { |
||
17 | /** @const OAUTH_VERSION */ |
||
18 | const OAUTH_VERSION = 1; |
||
19 | |||
20 | /** @var SignatureInterface */ |
||
21 | protected $signature; |
||
22 | |||
23 | /** @var UriInterface|null */ |
||
24 | protected $baseApiUri; |
||
25 | |||
26 | /** |
||
27 | * {@inheritDoc} |
||
28 | */ |
||
29 | public function __construct( |
||
46 | |||
47 | /** |
||
48 | * Constructor extended initialization |
||
49 | */ |
||
50 | protected function init() { |
||
53 | |||
54 | /** |
||
55 | * {@inheritDoc} |
||
56 | */ |
||
57 | public function requestRequestToken() |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function getAuthorizationUri(array $additionalParameters = array()) |
||
83 | |||
84 | /** |
||
85 | * {@inheritDoc} |
||
86 | */ |
||
87 | public function requestAccessToken($token, $verifier, $tokenSecret = null) |
||
117 | |||
118 | /** |
||
119 | * Refreshes an OAuth1 access token |
||
120 | * @param TokenInterface $token |
||
121 | * @return TokenInterface $token |
||
122 | */ |
||
123 | public function refreshAccessToken(TokenInterface $token) |
||
126 | |||
127 | /** |
||
128 | * Sends an authenticated API request to the path provided. |
||
129 | * If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used. |
||
130 | * |
||
131 | * @param string|UriInterface $path |
||
132 | * @param string $method HTTP method |
||
133 | * @param array $body Request body if applicable (key/value pairs) |
||
134 | * @param array $extraHeaders Extra headers if applicable. |
||
135 | * These will override service-specific any defaults. |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) |
||
153 | |||
154 | /** |
||
155 | * Return any additional headers always needed for this service implementation's OAuth calls. |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | protected function getExtraOAuthHeaders() |
||
163 | |||
164 | /** |
||
165 | * Return any additional headers always needed for this service implementation's API calls. |
||
166 | * |
||
167 | * @return array |
||
168 | */ |
||
169 | protected function getExtraApiHeaders() |
||
173 | |||
174 | /** |
||
175 | * Builds the authorization header for getting an access or request token. |
||
176 | * |
||
177 | * @param array $extraParameters |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = array()) |
||
201 | |||
202 | /** |
||
203 | * Builds the authorization header for an authenticated API request |
||
204 | * |
||
205 | * @param string $method |
||
206 | * @param UriInterface $uri The uri the request is headed |
||
207 | * @param TokenInterface $token |
||
208 | * @param array $bodyParams Request body if applicable (key/value pairs) |
||
209 | * |
||
210 | * @return string |
||
211 | */ |
||
212 | protected function buildAuthorizationHeaderForAPIRequest( |
||
244 | |||
245 | /** |
||
246 | * Builds the authorization header array. |
||
247 | * |
||
248 | * @return array |
||
249 | */ |
||
250 | protected function getBasicAuthorizationHeaderInfo() |
||
264 | |||
265 | /** |
||
266 | * Pseudo random string generator used to build a unique string to sign each request |
||
267 | * |
||
268 | * @param int $length |
||
269 | * |
||
270 | * @return string |
||
271 | */ |
||
272 | protected function generateNonce($length = 32) |
||
284 | |||
285 | /** |
||
286 | * @return string |
||
287 | */ |
||
288 | protected function getSignatureMethod() |
||
292 | |||
293 | /** |
||
294 | * This returns the version used in the authorization header of the requests |
||
295 | * |
||
296 | * @return string |
||
297 | */ |
||
298 | protected function getVersion() |
||
302 | |||
303 | /** |
||
304 | * Parses the request token response and returns a TokenInterface. |
||
305 | * This is only needed to verify the `oauth_callback_confirmed` parameter. The actual |
||
306 | * parsing logic is contained in the access token parser. |
||
307 | * |
||
308 | * @abstract |
||
309 | * |
||
310 | * @param string $responseBody |
||
311 | * |
||
312 | * @return TokenInterface |
||
313 | * |
||
314 | * @throws TokenResponseException |
||
315 | */ |
||
316 | abstract protected function parseRequestTokenResponse($responseBody); |
||
317 | |||
318 | /** |
||
319 | * Parses the access token response and returns a TokenInterface. |
||
320 | * |
||
321 | * @abstract |
||
322 | * |
||
323 | * @param string $responseBody |
||
324 | * |
||
325 | * @return TokenInterface |
||
326 | * |
||
327 | * @throws TokenResponseException |
||
328 | */ |
||
329 | abstract protected function parseAccessTokenResponse($responseBody); |
||
330 | } |
||
331 |
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.