chadicus /
slim-oauth2-http
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace Chadicus\Slim\OAuth2\Http; |
||
| 3 | |||
| 4 | use Slim\Http\Headers; |
||
| 5 | use Slim\Http\Response; |
||
| 6 | use Slim\Http\Stream; |
||
| 7 | use OAuth2; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Static utility class for bridging OAuth2 responses to PSR-7 responses. |
||
| 11 | */ |
||
| 12 | class ResponseBridge |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Copies values from the given Oauth2\Response to a Slim Response. |
||
| 16 | * |
||
| 17 | * @param OAuth2\ResponseInterface $oauth2Response The OAuth2 server response. |
||
| 18 | * |
||
| 19 | * @return Response |
||
| 20 | */ |
||
| 21 | final public static function fromOauth2(OAuth2\ResponseInterface $oauth2Response) |
||
| 22 | { |
||
| 23 | $headers = new Headers(); |
||
| 24 | foreach ($oauth2Response->getHttpHeaders() as $key => $value) { |
||
| 25 | $headers->set($key, explode(', ', $value)); |
||
|
0 ignored issues
–
show
|
|||
| 26 | } |
||
| 27 | |||
| 28 | $body = new Stream(fopen('php://temp', 'r')); |
||
| 29 | if (!empty($oauth2Response->getParameters())) { |
||
|
0 ignored issues
–
show
The method
getParameters() does not exist on OAuth2\ResponseInterface. Did you maybe mean getParameter()?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. Loading history...
|
|||
| 30 | $stream = fopen('php://memory','r+'); |
||
| 31 | fwrite($stream, $oauth2Response->getResponseBody()); |
||
| 32 | rewind($stream); |
||
| 33 | $body = new Stream($stream); |
||
| 34 | } |
||
| 35 | |||
| 36 | return new Response($oauth2Response->getStatusCode(), $headers, $body); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: