Skip to content

Commit

Permalink
Override setStatus and setHeaders methods in responses
Browse files Browse the repository at this point in the history
Signed-off-by: jld3103 <[email protected]>
  • Loading branch information
provokateurin committed Jun 14, 2023
1 parent 7d5ceb9 commit 8b1d849
Show file tree
Hide file tree
Showing 16 changed files with 399 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/DataDisplayResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,30 @@ public function setData($data) {
public function getData() {
return $this->data;
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/DataDownloadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,30 @@ public function setData($data) {
public function render() {
return $this->data;
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, C, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, C, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/DataResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,30 @@ public function setData($data) {
public function getData() {
return $this->data;
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, T, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, T, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/DownloadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,30 @@ public function __construct(string $filename, string $contentType) {
$this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
$this->addHeader('Content-Type', $contentType);
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, C, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, C, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/FileDisplayResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,30 @@ public function callback(IOutput $output) {
$output->setOutput($this->file->getContent());
}
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/JSONResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,30 @@ public function setData($data) {
public function getData() {
return $this->data;
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, T, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, T, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
22 changes: 22 additions & 0 deletions lib/public/AppFramework/Http/NotFoundResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,26 @@ public function __construct() {
$this->setContentSecurityPolicy(new ContentSecurityPolicy());
$this->setStatus(Http::STATUS_NOT_FOUND);
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @depreacted Do not use this method. It modifies the status code which you are not supposed to do on a NotFoundResponse
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
22 changes: 22 additions & 0 deletions lib/public/AppFramework/Http/RedirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,26 @@ public function __construct($redirectURL) {
public function getRedirectURL() {
return $this->redirectURL;
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @depreacted Do not use this method. It modifies the status code which you are not supposed to do on a RedirectResponse
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
22 changes: 22 additions & 0 deletions lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,26 @@ public function __construct() {
$urlGenerator = \OC::$server->get(IURLGenerator::class);
parent::__construct($urlGenerator->linkToDefaultPageUrl());
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @depreacted Do not use this method. It modifies the status code which you are not supposed to do on a RedirectToDefaultAppResponse
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
25 changes: 25 additions & 0 deletions lib/public/AppFramework/Http/StandaloneTemplateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,29 @@
* @template-extends TemplateResponse<S, H>
*/
class StandaloneTemplateResponse extends TemplateResponse {
/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/StreamResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,30 @@ public function callback(IOutput $output) {
}
}
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/Template/PublicTemplateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,30 @@ public function render(): string {
$this->setParams($params);
return parent::render();
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
26 changes: 26 additions & 0 deletions lib/public/AppFramework/Http/TemplateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,30 @@ public function render() {

return $template->fetchPage($this->params);
}

/**
* @inheritDoc
* @template NewH as array<string, mixed>
* @param NewH $headers value header pairs
* @psalm-this-out self<S, NewH>
* @return $this
* @since 8.0.0
*/
public function setHeaders(array $headers) {
parent::setHeaders($headers);
return $this;
}

/**
* @inheritDoc
* @template NewS as int
* @param NewS $status
* @psalm-this-out self<NewS, H>
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
public function setStatus($status) {
parent::setStatus($status);
return $this;
}
}
Loading

0 comments on commit 8b1d849

Please sign in to comment.