From 4f81b367660dd95973d6b38919a8290daa755cc1 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 5 Feb 2026 12:46:01 +0100 Subject: [PATCH] fix(AppFramework): Adjust types so PHPStan understands them Signed-off-by: provokateurin --- lib/private/AppFramework/OCS/BaseResponse.php | 7 +++---- lib/private/AppFramework/OCS/V1Response.php | 9 +++------ lib/private/AppFramework/OCS/V2Response.php | 9 +++------ lib/public/AppFramework/Http/DataDisplayResponse.php | 4 ++-- lib/public/AppFramework/Http/DataDownloadResponse.php | 4 ++-- lib/public/AppFramework/Http/DataResponse.php | 7 +++---- lib/public/AppFramework/Http/DownloadResponse.php | 4 ++-- lib/public/AppFramework/Http/FileDisplayResponse.php | 4 ++-- lib/public/AppFramework/Http/JSONResponse.php | 4 ++-- lib/public/AppFramework/Http/NotFoundResponse.php | 4 ++-- lib/public/AppFramework/Http/RedirectResponse.php | 4 ++-- .../AppFramework/Http/RedirectToDefaultAppResponse.php | 4 ++-- lib/public/AppFramework/Http/Response.php | 4 ++-- .../AppFramework/Http/StandaloneTemplateResponse.php | 4 ++-- lib/public/AppFramework/Http/StreamResponse.php | 4 ++-- .../AppFramework/Http/StreamTraversableResponse.php | 4 ++-- .../Http/Template/PublicTemplateResponse.php | 4 ++-- lib/public/AppFramework/Http/TemplateResponse.php | 4 ++-- lib/public/AppFramework/Http/TextPlainResponse.php | 4 ++-- lib/public/AppFramework/Http/TooManyRequestsResponse.php | 4 ++-- lib/public/AppFramework/Http/ZipResponse.php | 4 ++-- 21 files changed, 46 insertions(+), 54 deletions(-) diff --git a/lib/private/AppFramework/OCS/BaseResponse.php b/lib/private/AppFramework/OCS/BaseResponse.php index 05ce133db24f2..01e8737a14e6a 100644 --- a/lib/private/AppFramework/OCS/BaseResponse.php +++ b/lib/private/AppFramework/OCS/BaseResponse.php @@ -11,10 +11,9 @@ use OCP\AppFramework\Http\Response; /** - * @psalm-import-type DataResponseType from DataResponse - * @template S of Http::STATUS_* - * @template-covariant T of DataResponseType - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant T of array|int|float|string|bool|object|null|\stdClass|\JsonSerializable + * @template-covariant H of array * @template-extends Response> */ abstract class BaseResponse extends Response { diff --git a/lib/private/AppFramework/OCS/V1Response.php b/lib/private/AppFramework/OCS/V1Response.php index 1c2c25f5cb026..4b29bf237a4e6 100644 --- a/lib/private/AppFramework/OCS/V1Response.php +++ b/lib/private/AppFramework/OCS/V1Response.php @@ -7,15 +7,12 @@ namespace OC\AppFramework\OCS; use OCP\AppFramework\Http; -use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; /** - * @psalm-import-type DataResponseType from DataResponse - * @template S of Http::STATUS_* - * @template-covariant T of DataResponseType - * @template H of array - * @template-extends BaseResponse> + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array + * @template-extends BaseResponse> */ class V1Response extends BaseResponse { /** diff --git a/lib/private/AppFramework/OCS/V2Response.php b/lib/private/AppFramework/OCS/V2Response.php index efc9348eb3759..fc039e92bb1e7 100644 --- a/lib/private/AppFramework/OCS/V2Response.php +++ b/lib/private/AppFramework/OCS/V2Response.php @@ -7,15 +7,12 @@ namespace OC\AppFramework\OCS; use OCP\AppFramework\Http; -use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; /** - * @psalm-import-type DataResponseType from DataResponse - * @template S of Http::STATUS_* - * @template-covariant T of DataResponseType - * @template H of array - * @template-extends BaseResponse> + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array + * @template-extends BaseResponse> */ class V2Response extends BaseResponse { /** diff --git a/lib/public/AppFramework/Http/DataDisplayResponse.php b/lib/public/AppFramework/Http/DataDisplayResponse.php index e1ded9103288d..9a91b9f8417c0 100644 --- a/lib/public/AppFramework/Http/DataDisplayResponse.php +++ b/lib/public/AppFramework/Http/DataDisplayResponse.php @@ -13,8 +13,8 @@ * Class DataDisplayResponse * * @since 8.1.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class DataDisplayResponse extends Response { diff --git a/lib/public/AppFramework/Http/DataDownloadResponse.php b/lib/public/AppFramework/Http/DataDownloadResponse.php index ee6bcf0d0c50d..d22d1dd6433c1 100644 --- a/lib/public/AppFramework/Http/DataDownloadResponse.php +++ b/lib/public/AppFramework/Http/DataDownloadResponse.php @@ -13,9 +13,9 @@ * Class DataDownloadResponse * * @since 8.0.0 - * @template S of Http::STATUS_* + * @template-covariant S of Http::STATUS_* * @template C of string - * @template H of array + * @template-covariant H of array * @template-extends DownloadResponse> */ class DataDownloadResponse extends DownloadResponse { diff --git a/lib/public/AppFramework/Http/DataResponse.php b/lib/public/AppFramework/Http/DataResponse.php index 2b54ce848efa1..404dbe9cdff7b 100644 --- a/lib/public/AppFramework/Http/DataResponse.php +++ b/lib/public/AppFramework/Http/DataResponse.php @@ -13,10 +13,9 @@ * A generic DataResponse class that is used to return generic data responses * for responders to transform * @since 8.0.0 - * @psalm-type DataResponseType = array|int|float|string|bool|object|null|\stdClass|\JsonSerializable - * @template S of Http::STATUS_* - * @template-covariant T of DataResponseType - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant T of array|int|float|string|bool|object|null|\stdClass|\JsonSerializable + * @template-covariant H of array * @template-extends Response> */ class DataResponse extends Response { diff --git a/lib/public/AppFramework/Http/DownloadResponse.php b/lib/public/AppFramework/Http/DownloadResponse.php index 190de022d368e..a4748de74c5b3 100644 --- a/lib/public/AppFramework/Http/DownloadResponse.php +++ b/lib/public/AppFramework/Http/DownloadResponse.php @@ -12,9 +12,9 @@ /** * Prompts the user to download the a file * @since 7.0.0 - * @template S of Http::STATUS_* + * @template-covariant S of Http::STATUS_* * @template C of string - * @template H of array + * @template-covariant H of array * @template-extends Response> */ class DownloadResponse extends Response { diff --git a/lib/public/AppFramework/Http/FileDisplayResponse.php b/lib/public/AppFramework/Http/FileDisplayResponse.php index c18404b7d9161..077befc51d67f 100644 --- a/lib/public/AppFramework/Http/FileDisplayResponse.php +++ b/lib/public/AppFramework/Http/FileDisplayResponse.php @@ -14,8 +14,8 @@ * Class FileDisplayResponse * * @since 11.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class FileDisplayResponse extends Response implements ICallbackResponse { diff --git a/lib/public/AppFramework/Http/JSONResponse.php b/lib/public/AppFramework/Http/JSONResponse.php index a226e29a1b58c..03ae3ae61cb7c 100644 --- a/lib/public/AppFramework/Http/JSONResponse.php +++ b/lib/public/AppFramework/Http/JSONResponse.php @@ -12,9 +12,9 @@ /** * A renderer for JSON calls * @since 6.0.0 - * @template S of Http::STATUS_* + * @template-covariant S of Http::STATUS_* * @template-covariant T of null|string|int|float|bool|array|\stdClass|\JsonSerializable - * @template H of array + * @template-covariant H of array * @template-extends Response> */ class JSONResponse extends Response { diff --git a/lib/public/AppFramework/Http/NotFoundResponse.php b/lib/public/AppFramework/Http/NotFoundResponse.php index 137d1a266557b..6faeb4110d27e 100644 --- a/lib/public/AppFramework/Http/NotFoundResponse.php +++ b/lib/public/AppFramework/Http/NotFoundResponse.php @@ -12,8 +12,8 @@ /** * A generic 404 response showing an 404 error page as well to the end-user * @since 8.1.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends TemplateResponse> */ class NotFoundResponse extends TemplateResponse { diff --git a/lib/public/AppFramework/Http/RedirectResponse.php b/lib/public/AppFramework/Http/RedirectResponse.php index 7484720597682..ef1fb2761eaae 100644 --- a/lib/public/AppFramework/Http/RedirectResponse.php +++ b/lib/public/AppFramework/Http/RedirectResponse.php @@ -12,8 +12,8 @@ /** * Redirects to a different URL * @since 7.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class RedirectResponse extends Response { diff --git a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php index 0a0c04f671d5b..32fcb1c49519b 100644 --- a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php +++ b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php @@ -16,8 +16,8 @@ * * @since 16.0.0 * @deprecated 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends RedirectResponse> */ class RedirectToDefaultAppResponse extends RedirectResponse { diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index 6edd32a1f8b69..0f82ca9a73830 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -20,8 +20,8 @@ * * It handles headers, HTTP status code, last modified and ETag. * @since 6.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array */ class Response { /** diff --git a/lib/public/AppFramework/Http/StandaloneTemplateResponse.php b/lib/public/AppFramework/Http/StandaloneTemplateResponse.php index 244a6b80f9f2b..06be77b6c3f51 100644 --- a/lib/public/AppFramework/Http/StandaloneTemplateResponse.php +++ b/lib/public/AppFramework/Http/StandaloneTemplateResponse.php @@ -16,8 +16,8 @@ * full nextcloud UI. Like the 2FA page, or the grant page in the login flow. * * @since 16.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends TemplateResponse> */ class StandaloneTemplateResponse extends TemplateResponse { diff --git a/lib/public/AppFramework/Http/StreamResponse.php b/lib/public/AppFramework/Http/StreamResponse.php index d0e6e3e148abf..a7cf61298be46 100644 --- a/lib/public/AppFramework/Http/StreamResponse.php +++ b/lib/public/AppFramework/Http/StreamResponse.php @@ -13,8 +13,8 @@ * Class StreamResponse * * @since 8.1.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class StreamResponse extends Response implements ICallbackResponse { diff --git a/lib/public/AppFramework/Http/StreamTraversableResponse.php b/lib/public/AppFramework/Http/StreamTraversableResponse.php index aecf57c80596f..4338ed73d5d94 100644 --- a/lib/public/AppFramework/Http/StreamTraversableResponse.php +++ b/lib/public/AppFramework/Http/StreamTraversableResponse.php @@ -16,8 +16,8 @@ * Class StreamResponse * * @since 33.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class StreamTraversableResponse extends Response implements ICallbackResponse { diff --git a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php index 4c156cdecea6d..4fb0a09efea49 100644 --- a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php +++ b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php @@ -15,8 +15,8 @@ * Class PublicTemplateResponse * * @since 14.0.0 - * @template H of array - * @template S of Http::STATUS_* + * @template-covariant H of array + * @template-covariant S of Http::STATUS_* * @template-extends TemplateResponse> */ class PublicTemplateResponse extends TemplateResponse { diff --git a/lib/public/AppFramework/Http/TemplateResponse.php b/lib/public/AppFramework/Http/TemplateResponse.php index 7e76c7a6e96cd..a1a39d92e04a1 100644 --- a/lib/public/AppFramework/Http/TemplateResponse.php +++ b/lib/public/AppFramework/Http/TemplateResponse.php @@ -19,8 +19,8 @@ * Response for a normal template * @since 6.0.0 * - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class TemplateResponse extends Response { diff --git a/lib/public/AppFramework/Http/TextPlainResponse.php b/lib/public/AppFramework/Http/TextPlainResponse.php index 9dfa2c5544dc5..52c6b6b6f207b 100644 --- a/lib/public/AppFramework/Http/TextPlainResponse.php +++ b/lib/public/AppFramework/Http/TextPlainResponse.php @@ -12,8 +12,8 @@ /** * A renderer for text responses * @since 22.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class TextPlainResponse extends Response { diff --git a/lib/public/AppFramework/Http/TooManyRequestsResponse.php b/lib/public/AppFramework/Http/TooManyRequestsResponse.php index f7084ec768d9b..d18d6543ee04c 100644 --- a/lib/public/AppFramework/Http/TooManyRequestsResponse.php +++ b/lib/public/AppFramework/Http/TooManyRequestsResponse.php @@ -14,8 +14,8 @@ /** * A generic 429 response showing an 404 error page as well to the end-user * @since 19.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class TooManyRequestsResponse extends Response { diff --git a/lib/public/AppFramework/Http/ZipResponse.php b/lib/public/AppFramework/Http/ZipResponse.php index f0c6577f0d4d2..128fb1b7f761f 100644 --- a/lib/public/AppFramework/Http/ZipResponse.php +++ b/lib/public/AppFramework/Http/ZipResponse.php @@ -16,8 +16,8 @@ * Public library to send several files in one zip archive. * * @since 15.0.0 - * @template S of Http::STATUS_* - * @template H of array + * @template-covariant S of Http::STATUS_* + * @template-covariant H of array * @template-extends Response> */ class ZipResponse extends Response implements ICallbackResponse {