mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
docs(http): Update return type for getBody
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
44be41d9bd
commit
3d0fb7e603
3 changed files with 5 additions and 41 deletions
|
|
@ -4059,16 +4059,6 @@
|
|||
<code><![CDATA[isAdmin]]></code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="lib/private/Http/Client/Response.php">
|
||||
<InvalidNullableReturnType>
|
||||
<code><![CDATA[string|resource]]></code>
|
||||
</InvalidNullableReturnType>
|
||||
<NullableReturnStatement>
|
||||
<code><![CDATA[$this->stream ?
|
||||
$this->response->getBody()->detach():
|
||||
$this->response->getBody()->getContents()]]></code>
|
||||
</NullableReturnStatement>
|
||||
</file>
|
||||
<file src="lib/private/Installer.php">
|
||||
<InvalidArgument>
|
||||
<code><![CDATA[false]]></code>
|
||||
|
|
|
|||
|
|
@ -11,49 +11,25 @@ namespace OC\Http\Client;
|
|||
use OCP\Http\Client\IResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Class Response
|
||||
*
|
||||
* @package OC\Http
|
||||
*/
|
||||
class Response implements IResponse {
|
||||
/** @var ResponseInterface */
|
||||
private $response;
|
||||
private ResponseInterface $response;
|
||||
private bool $stream;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* @param ResponseInterface $response
|
||||
* @param bool $stream
|
||||
*/
|
||||
public function __construct(ResponseInterface $response, $stream = false) {
|
||||
public function __construct(ResponseInterface $response, bool $stream = false) {
|
||||
$this->response = $response;
|
||||
$this->stream = $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|resource
|
||||
*/
|
||||
public function getBody() {
|
||||
return $this->stream ?
|
||||
$this->response->getBody()->detach():
|
||||
$this->response->getBody()->getContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode(): int {
|
||||
return $this->response->getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
public function getHeader(string $key): string {
|
||||
$headers = $this->response->getHeader($key);
|
||||
|
||||
|
|
@ -64,9 +40,6 @@ class Response implements IResponse {
|
|||
return $headers[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders(): array {
|
||||
return $this->response->getHeaders();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@ namespace OCP\Http\Client;
|
|||
*/
|
||||
interface IResponse {
|
||||
/**
|
||||
* @return string|resource
|
||||
* @return null|resource|string
|
||||
* @since 8.1.0
|
||||
* @sicne 8.2.0 with stream enabled, the function returns null or a resource
|
||||
*/
|
||||
public function getBody();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue