docs(http): Update return type for getBody

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2025-06-25 14:57:08 +02:00
parent 44be41d9bd
commit 3d0fb7e603
No known key found for this signature in database
GPG key ID: 4A81C29F63464E8F
3 changed files with 5 additions and 41 deletions

View file

@ -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>

View file

@ -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();
}

View file

@ -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();