Skip to content

Commit

Permalink
Add never return type to redirect methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab authored and nilmerg committed Sep 7, 2023
1 parent 36d4e6d commit ab96f66
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
18 changes: 18 additions & 0 deletions library/Icinga/Web/Controller/ActionController.php
Expand Up @@ -413,6 +413,13 @@ public function isXhr()
return $this->getRequest()->isXmlHttpRequest();
}

/**
* Issue a redirect that's performed with XHR by the client
*
* @param Url|string $url
*
* @return never
*/
protected function redirectXhr($url)
{
$response = $this->getResponse();
Expand All @@ -428,6 +435,15 @@ protected function redirectXhr($url)
$response->redirectAndExit($url);
}

/**
* Issue a redirect that's performed as a native HTTP request by the client
*
* This will effectively reload the window
*
* @param Url|string $url
*
* @return never
*/
protected function redirectHttp($url)
{
if ($this->isXhr()) {
Expand All @@ -441,6 +457,8 @@ protected function redirectHttp($url)
* Redirect to a specific url, updating the browsers URL field
*
* @param Url|string $url The target to redirect to
*
* @return never
**/
public function redirectNow($url)
{
Expand Down
2 changes: 2 additions & 0 deletions library/Icinga/Web/Response.php
Expand Up @@ -393,6 +393,8 @@ protected function prepare()
* Redirect to the given URL and exit immediately
*
* @param string|Url $url
*
* @return never
*/
public function redirectAndExit($url)
{
Expand Down
30 changes: 0 additions & 30 deletions phpstan-baseline.neon
Expand Up @@ -12060,36 +12060,11 @@ parameters:
count: 1
path: library/Icinga/Web/Controller/ActionController.php

-
message: "#^Method Icinga\\\\Web\\\\Controller\\\\ActionController\\:\\:redirectHttp\\(\\) has no return type specified\\.$#"
count: 1
path: library/Icinga/Web/Controller/ActionController.php

-
message: "#^Method Icinga\\\\Web\\\\Controller\\\\ActionController\\:\\:redirectHttp\\(\\) has parameter \\$url with no type specified\\.$#"
count: 1
path: library/Icinga/Web/Controller/ActionController.php

-
message: "#^Method Icinga\\\\Web\\\\Controller\\\\ActionController\\:\\:redirectNow\\(\\) has no return type specified\\.$#"
count: 1
path: library/Icinga/Web/Controller/ActionController.php

-
message: "#^Method Icinga\\\\Web\\\\Controller\\\\ActionController\\:\\:redirectToLogin\\(\\) has no return type specified\\.$#"
count: 1
path: library/Icinga/Web/Controller/ActionController.php

-
message: "#^Method Icinga\\\\Web\\\\Controller\\\\ActionController\\:\\:redirectXhr\\(\\) has no return type specified\\.$#"
count: 1
path: library/Icinga/Web/Controller/ActionController.php

-
message: "#^Method Icinga\\\\Web\\\\Controller\\\\ActionController\\:\\:redirectXhr\\(\\) has parameter \\$url with no type specified\\.$#"
count: 1
path: library/Icinga/Web/Controller/ActionController.php

-
message: "#^Method Icinga\\\\Web\\\\Controller\\\\ActionController\\:\\:reloadCss\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -13785,11 +13760,6 @@ parameters:
count: 1
path: library/Icinga/Web/Response.php

-
message: "#^Method Icinga\\\\Web\\\\Response\\:\\:redirectAndExit\\(\\) has no return type specified\\.$#"
count: 1
path: library/Icinga/Web/Response.php

-
message: "#^Method Icinga\\\\Web\\\\Response\\:\\:sendCookies\\(\\) has no return type specified\\.$#"
count: 1
Expand Down

0 comments on commit ab96f66

Please sign in to comment.