mirror of
https://github.com/nextcloud/server.git
synced 2026-02-27 18:37:17 +01:00
fix: handle ambiguous IResponse.getBody return types
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
@@ -3943,12 +3943,6 @@
|
||||
<code><![CDATA[ArrayCache]]></code>
|
||||
<code><![CDATA[ArrayCache]]></code>
|
||||
</InvalidClass>
|
||||
<InvalidReturnStatement>
|
||||
<code><![CDATA[$response->getBody()]]></code>
|
||||
</InvalidReturnStatement>
|
||||
<InvalidReturnType>
|
||||
<code><![CDATA[fopen]]></code>
|
||||
</InvalidReturnType>
|
||||
</file>
|
||||
<file src="lib/private/Files/Storage/Local.php">
|
||||
<TypeDoesNotContainNull>
|
||||
@@ -4197,12 +4191,6 @@
|
||||
</ImplementedReturnTypeMismatch>
|
||||
</file>
|
||||
<file src="lib/private/Remote/Instance.php">
|
||||
<InvalidReturnStatement>
|
||||
<code><![CDATA[$request->getBody()]]></code>
|
||||
</InvalidReturnStatement>
|
||||
<InvalidReturnType>
|
||||
<code><![CDATA[bool|string]]></code>
|
||||
</InvalidReturnType>
|
||||
<InvalidScalarArgument>
|
||||
<code><![CDATA[$response]]></code>
|
||||
</InvalidScalarArgument>
|
||||
|
||||
@@ -350,7 +350,13 @@ class DAV extends Common {
|
||||
}
|
||||
}
|
||||
|
||||
return $response->getBody();
|
||||
$content = $response->getBody();
|
||||
|
||||
if ($content === null || is_string($content)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $content;
|
||||
case 'w':
|
||||
case 'wb':
|
||||
case 'a':
|
||||
@@ -390,6 +396,8 @@ class DAV extends Common {
|
||||
$this->writeBack($tmpFile, $path);
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function writeBack(string $tmpFile, string $path): void {
|
||||
|
||||
@@ -123,7 +123,13 @@ class Instance implements IInstance {
|
||||
private function downloadStatus($url) {
|
||||
try {
|
||||
$request = $this->clientService->newClient()->get($url);
|
||||
return $request->getBody();
|
||||
$content = $request->getBody();
|
||||
|
||||
// IResponse.getBody responds with null|resource if returning a stream response was requested.
|
||||
// As that's not the case here, we can just ignore the psalm warning by adding an assertion.
|
||||
assert(is_string($content));
|
||||
|
||||
return $content;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,17 +105,20 @@ class VersionCheck {
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @param string $url
|
||||
* @return resource|string
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getUrlContent($url) {
|
||||
$client = $this->clientService->newClient();
|
||||
$response = $client->get($url, [
|
||||
protected function getUrlContent(string $url): string {
|
||||
$response = $this->clientService->newClient()->get($url, [
|
||||
'timeout' => 5,
|
||||
]);
|
||||
return $response->getBody();
|
||||
|
||||
$content = $response->getBody();
|
||||
|
||||
// IResponse.getBody responds with null|resource if returning a stream response was requested.
|
||||
// As that's not the case here, we can just ignore the psalm warning by adding an assertion.
|
||||
assert(is_string($content));
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function computeCategory(): int {
|
||||
|
||||
Reference in New Issue
Block a user