Skip to content

Commit e960a69

Browse files
provokateurinbackportbot[bot]
authored andcommitted
fix(Http): Only allow valid HTTP status code values via template
Signed-off-by: provokateurin <[email protected]> [skip ci]
1 parent cc6cfda commit e960a69

20 files changed

+43
-41
lines changed

lib/private/AppFramework/OCS/BaseResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333

3434
/**
3535
* @psalm-import-type DataResponseType from DataResponse
36-
* @template S of int
36+
* @template S of Http::STATUS_*
3737
* @template-covariant T of DataResponseType
3838
* @template H of array<string, mixed>
39-
* @template-extends Response<int, array<string, mixed>>
39+
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
4040
*/
4141
abstract class BaseResponse extends Response {
4242
/** @var array */

lib/private/AppFramework/OCS/V1Response.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131

3232
/**
3333
* @psalm-import-type DataResponseType from DataResponse
34-
* @template S of int
34+
* @template S of Http::STATUS_*
3535
* @template-covariant T of DataResponseType
3636
* @template H of array<string, mixed>
37-
* @template-extends BaseResponse<int, DataResponseType, array<string, mixed>>
37+
* @template-extends BaseResponse<Http::STATUS_*, DataResponseType, array<string, mixed>>
3838
*/
3939
class V1Response extends BaseResponse {
4040
/**
4141
* The V1 endpoint has very limited http status codes basically everything
4242
* is status 200 except 401
4343
*
44-
* @return int
44+
* @return Http::STATUS_*
4545
*/
4646
public function getStatus() {
4747
$status = parent::getStatus();

lib/private/AppFramework/OCS/V2Response.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030

3131
/**
3232
* @psalm-import-type DataResponseType from DataResponse
33-
* @template S of int
33+
* @template S of Http::STATUS_*
3434
* @template-covariant T of DataResponseType
3535
* @template H of array<string, mixed>
36-
* @template-extends BaseResponse<int, DataResponseType, array<string, mixed>>
36+
* @template-extends BaseResponse<Http::STATUS_*, DataResponseType, array<string, mixed>>
3737
*/
3838
class V2Response extends BaseResponse {
3939
/**
4040
* The V2 endpoint just passes on status codes.
4141
* Of course we have to map the OCS specific codes to proper HTTP status codes
4242
*
43-
* @return int
43+
* @return Http::STATUS_*
4444
*/
4545
public function getStatus() {
4646
$status = parent::getStatus();

lib/public/AppFramework/Http/DataDisplayResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
* Class DataDisplayResponse
3232
*
3333
* @since 8.1.0
34-
* @template S of int
34+
* @template S of Http::STATUS_*
3535
* @template H of array<string, mixed>
36-
* @template-extends Response<int, array<string, mixed>>
36+
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
3737
*/
3838
class DataDisplayResponse extends Response {
3939
/**

lib/public/AppFramework/Http/DataDownloadResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
* Class DataDownloadResponse
3131
*
3232
* @since 8.0.0
33-
* @template S of int
33+
* @template S of Http::STATUS_*
3434
* @template C of string
3535
* @template H of array<string, mixed>
36-
* @template-extends DownloadResponse<int, string, array<string, mixed>>
36+
* @template-extends DownloadResponse<Http::STATUS_*, string, array<string, mixed>>
3737
*/
3838
class DataDownloadResponse extends DownloadResponse {
3939
/**

lib/public/AppFramework/Http/DataResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
* for responders to transform
3333
* @since 8.0.0
3434
* @psalm-type DataResponseType = array|int|float|string|bool|object|null|\stdClass|\JsonSerializable
35-
* @template S of int
35+
* @template S of Http::STATUS_*
3636
* @template-covariant T of DataResponseType
3737
* @template H of array<string, mixed>
38-
* @template-extends Response<int, array<string, mixed>>
38+
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
3939
*/
4040
class DataResponse extends Response {
4141
/**

lib/public/AppFramework/Http/DownloadResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
/**
3232
* Prompts the user to download the a file
3333
* @since 7.0.0
34-
* @template S of int
34+
* @template S of Http::STATUS_*
3535
* @template C of string
3636
* @template H of array<string, mixed>
37-
* @template-extends Response<int, array<string, mixed>>
37+
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
3838
*/
3939
class DownloadResponse extends Response {
4040
/**

lib/public/AppFramework/Http/FileDisplayResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
* Class FileDisplayResponse
3333
*
3434
* @since 11.0.0
35-
* @template S of int
35+
* @template S of Http::STATUS_*
3636
* @template H of array<string, mixed>
37-
* @template-extends Response<int, array<string, mixed>>
37+
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
3838
*/
3939
class FileDisplayResponse extends Response implements ICallbackResponse {
4040
/** @var File|ISimpleFile */

lib/public/AppFramework/Http/JSONResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
/**
3434
* A renderer for JSON calls
3535
* @since 6.0.0
36-
* @template S of int
36+
* @template S of Http::STATUS_*
3737
* @template-covariant T of null|string|int|float|bool|array|\stdClass|\JsonSerializable
3838
* @template H of array<string, mixed>
39-
* @template-extends Response<int, array<string, mixed>>
39+
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
4040
*/
4141
class JSONResponse extends Response {
4242
/**

lib/public/AppFramework/Http/NotFoundResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
/**
3131
* A generic 404 response showing an 404 error page as well to the end-user
3232
* @since 8.1.0
33-
* @template S of int
33+
* @template S of Http::STATUS_*
3434
* @template H of array<string, mixed>
35-
* @template-extends TemplateResponse<int, array<string, mixed>>
35+
* @template-extends TemplateResponse<Http::STATUS_*, array<string, mixed>>
3636
*/
3737
class NotFoundResponse extends TemplateResponse {
3838
/**

0 commit comments

Comments
 (0)