Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: handle ambiguous IResponse.getBody return types
Signed-off-by: Daniel Kesselberg <[email protected]>
  • Loading branch information
kesselb committed Jun 30, 2025
commit de54bdb06bedd461fd359d3cc7d4dfcab46be3ad
12 changes: 0 additions & 12 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
10 changes: 9 additions & 1 deletion lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,13 @@ public function fopen(string $path, string $mode) {
}
}

return $response->getBody();
$content = $response->getBody();

if ($content === null || is_string($content)) {
return false;
}

return $content;
case 'w':
case 'wb':
case 'a':
Expand Down Expand Up @@ -390,6 +396,8 @@ public function fopen(string $path, string $mode) {
$this->writeBack($tmpFile, $path);
});
}

return false;
}

public function writeBack(string $tmpFile, string $path): void {
Expand Down
8 changes: 7 additions & 1 deletion lib/private/Remote/Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ private function getStatus() {
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;
}
Expand Down
17 changes: 10 additions & 7 deletions lib/private/Updater/VersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,20 @@ public function check() {
}

/**
* @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 {
Expand Down
Loading