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 null|UriInterface */ |
||
24 | protected $baseApiUri; |
||
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function __construct( |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | public function requestRequestToken() |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | public function getAuthorizationUri(array $additionalParameters = []) |
||
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | public function requestAccessToken($token, $verifier, $tokenSecret = null) |
||
107 | |||
108 | /** |
||
109 | * Refreshes an OAuth1 access token. |
||
110 | * |
||
111 | * @return TokenInterface $token |
||
112 | */ |
||
113 | public function refreshAccessToken(TokenInterface $token) |
||
116 | |||
117 | /** |
||
118 | * Sends an authenticated API request to the path provided. |
||
119 | * If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used. |
||
120 | * |
||
121 | * @param string|UriInterface $path |
||
122 | * @param string $method HTTP method |
||
123 | * @param array $body Request body if applicable (key/value pairs) |
||
124 | * @param array $extraHeaders Extra headers if applicable. |
||
125 | * These will override service-specific any defaults. |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | public function request($path, $method = 'GET', $body = null, array $extraHeaders = []) |
||
143 | |||
144 | /** |
||
145 | * Return any additional headers always needed for this service implementation's OAuth calls. |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | protected function getExtraOAuthHeaders() |
||
153 | |||
154 | /** |
||
155 | * Return any additional headers always needed for this service implementation's API calls. |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | protected function getExtraApiHeaders() |
||
163 | |||
164 | /** |
||
165 | * Builds the authorization header for getting an access or request token. |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = []) |
||
189 | |||
190 | /** |
||
191 | * Builds the authorization header for an authenticated API request. |
||
192 | * |
||
193 | * @param string $method |
||
194 | * @param UriInterface $uri The uri the request is headed |
||
195 | * @param array $bodyParams Request body if applicable (key/value pairs) |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | protected function buildAuthorizationHeaderForAPIRequest( |
||
231 | |||
232 | /** |
||
233 | * Builds the authorization header array. |
||
234 | * |
||
235 | * @return array |
||
236 | */ |
||
237 | protected function getBasicAuthorizationHeaderInfo() |
||
251 | |||
252 | /** |
||
253 | * Pseudo random string generator used to build a unique string to sign each request. |
||
254 | * |
||
255 | * @param int $length |
||
256 | * |
||
257 | * @return string |
||
258 | */ |
||
259 | protected function generateNonce($length = 32) |
||
271 | |||
272 | /** |
||
273 | * @return string |
||
274 | */ |
||
275 | protected function getSignatureMethod() |
||
279 | |||
280 | /** |
||
281 | * This returns the version used in the authorization header of the requests. |
||
282 | * |
||
283 | * @return string |
||
284 | */ |
||
285 | protected function getVersion() |
||
289 | |||
290 | /** |
||
291 | * Parses the request token response and returns a TokenInterface. |
||
292 | * This is only needed to verify the `oauth_callback_confirmed` parameter. The actual |
||
293 | * parsing logic is contained in the access token parser. |
||
294 | * |
||
295 | * @abstract |
||
296 | * |
||
297 | * @param string $responseBody |
||
298 | * |
||
299 | * @return TokenInterface |
||
300 | */ |
||
301 | abstract protected function parseRequestTokenResponse($responseBody); |
||
302 | |||
303 | /** |
||
304 | * Parses the access token response and returns a TokenInterface. |
||
305 | * |
||
306 | * @abstract |
||
307 | * |
||
308 | * @param string $responseBody |
||
309 | * |
||
310 | * @return TokenInterface |
||
311 | */ |
||
312 | abstract protected function parseAccessTokenResponse($responseBody); |
||
313 | } |
||
314 |
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.