Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 3 additions & 4 deletions lib/private/AppFramework/OCS/BaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant T of array|int|float|string|bool|object|null|\stdClass|\JsonSerializable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that not the same as mixed 🙃 ?

Also, \stdClass|\JsonSerializable is redundant with object, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is the correct type. It only allows what can be serialized to JSON.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But how can a var be \stdClass without being object? And same for JsonSerializable. For me either object or \stdClass|\JsonSerializable should be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.php.net/manual/en/language.types.mixed.php The only thing refused in this union is resource.

* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
abstract class BaseResponse extends Response {
Expand Down
9 changes: 3 additions & 6 deletions lib/private/AppFramework/OCS/V1Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no generic equivalent to this psalm instruction?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that phpstan doesn't understand this, it seems to have problems with the template-covariant referencing the alias.

* @template S of Http::STATUS_*
* @template-covariant T of DataResponseType
* @template H of array<string, mixed>
* @template-extends BaseResponse<Http::STATUS_*, DataResponseType, array<string, mixed>>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends BaseResponse<Http::STATUS_*, array|int|float|string|bool|object|null|\stdClass|\JsonSerializable, array<string, mixed>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @template-extends BaseResponse<Http::STATUS_*, array|int|float|string|bool|object|null|\stdClass|\JsonSerializable, array<string, mixed>>
* @template-extends BaseResponse<Http::STATUS_*, T, array<string, mixed>>

Is that not the same type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back when this was added it didn't work with psalm, but yes that is how it is supposed to be.

*/
class V1Response extends BaseResponse {
/**
Expand Down
9 changes: 3 additions & 6 deletions lib/private/AppFramework/OCS/V2Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-extends BaseResponse<Http::STATUS_*, DataResponseType, array<string, mixed>>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends BaseResponse<Http::STATUS_*, array|int|float|string|bool|object|null|\stdClass|\JsonSerializable, array<string, mixed>>
*/
class V2Response extends BaseResponse {
/**
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/DataDisplayResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* Class DataDisplayResponse
*
* @since 8.1.0
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class DataDisplayResponse extends Response {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/DataDownloadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant H of array<string, mixed>
* @template-extends DownloadResponse<Http::STATUS_*, string, array<string, mixed>>
*/
class DataDownloadResponse extends DownloadResponse {
Expand Down
7 changes: 3 additions & 4 deletions lib/public/AppFramework/Http/DataResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant T of array|int|float|string|bool|object|null|\stdClass|\JsonSerializable
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class DataResponse extends Response {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/DownloadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class DownloadResponse extends Response {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/FileDisplayResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* Class FileDisplayResponse
*
* @since 11.0.0
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class FileDisplayResponse extends Response implements ICallbackResponse {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/JSONResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class JSONResponse extends Response {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/NotFoundResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends TemplateResponse<Http::STATUS_*, array<string, mixed>>
*/
class NotFoundResponse extends TemplateResponse {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/RedirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
/**
* Redirects to a different URL
* @since 7.0.0
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class RedirectResponse extends Response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends RedirectResponse<Http::STATUS_*, array<string, mixed>>
*/
class RedirectToDefaultAppResponse extends RedirectResponse {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
*/
class Response {
/**
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/StandaloneTemplateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends TemplateResponse<Http::STATUS_*, array<string, mixed>>
*/
class StandaloneTemplateResponse extends TemplateResponse {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/StreamResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* Class StreamResponse
*
* @since 8.1.0
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class StreamResponse extends Response implements ICallbackResponse {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/StreamTraversableResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* Class StreamResponse
*
* @since 33.0.0
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class StreamTraversableResponse extends Response implements ICallbackResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* Class PublicTemplateResponse
*
* @since 14.0.0
* @template H of array<string, mixed>
* @template S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-extends TemplateResponse<Http::STATUS_*, array<string, mixed>>
*/
class PublicTemplateResponse extends TemplateResponse {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/TemplateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* Response for a normal template
* @since 6.0.0
*
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class TemplateResponse extends Response {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/TextPlainResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
/**
* A renderer for text responses
* @since 22.0.0
* @template S of Http::STATUS_*
* @template H of array<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class TextPlainResponse extends Response {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/TooManyRequestsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class TooManyRequestsResponse extends Response {
Expand Down
4 changes: 2 additions & 2 deletions lib/public/AppFramework/Http/ZipResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
* @template-covariant S of Http::STATUS_*
* @template-covariant H of array<string, mixed>
* @template-extends Response<Http::STATUS_*, array<string, mixed>>
*/
class ZipResponse extends Response implements ICallbackResponse {
Expand Down
Loading