Skip to content

Commit a52667e

Browse files
Merge pull request #18488 from kamil-tekiela/Add-never-type
Add never return type
2 parents bea5211 + 079892b commit a52667e

13 files changed

Lines changed: 104 additions & 68 deletions

libraries/classes/Controllers/Setup/ShowConfigController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public function __invoke(ServerRequest $request): void
3636
$GLOBALS['ConfigFile']->resetConfigData();
3737
// drop post data
3838
$response->generateHeader303('../setup/index.php' . Url::getCommonRaw(['route' => '/setup']));
39-
40-
return;
4139
}
4240

4341
/** @var mixed $submitDownload */

libraries/classes/Plugins/Auth/AuthenticationConfig.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,18 @@ class AuthenticationConfig extends AuthenticationPlugin
2828
{
2929
/**
3030
* Displays authentication form
31-
*
32-
* @return bool always true
3331
*/
34-
public function showLoginForm(): bool
32+
public function showLoginForm(): void
3533
{
3634
$response = ResponseRenderer::getInstance();
37-
if ($response->isAjax()) {
38-
$response->setRequestStatus(false);
39-
// reload_flag removes the token parameter from the URL and reloads
40-
$response->addJSON('reload_flag', '1');
41-
$response->callExit();
35+
if (! $response->isAjax()) {
36+
return;
4237
}
4338

44-
return true;
39+
$response->setRequestStatus(false);
40+
// reload_flag removes the token parameter from the URL and reloads
41+
$response->addJSON('reload_flag', '1');
42+
$response->callExit();
4543
}
4644

4745
/**
@@ -66,7 +64,7 @@ public function readCredentials(): bool
6664
*
6765
* @param string $failure String describing why authentication has failed
6866
*/
69-
public function showFailure(string $failure): void
67+
public function showFailure(string $failure): never
7068
{
7169
parent::showFailure($failure);
7270

libraries/classes/Plugins/Auth/AuthenticationCookie.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class AuthenticationCookie extends AuthenticationPlugin
6363
*
6464
* @global string $conn_error the last connection error
6565
*/
66-
public function showLoginForm(): bool
66+
public function showLoginForm(): never
6767
{
6868
$GLOBALS['conn_error'] ??= null;
6969

@@ -379,7 +379,6 @@ public function readCredentials(): bool
379379
SessionCache::remove('proc_priv');
380380

381381
$this->showFailure('no-activity');
382-
ResponseRenderer::getInstance()->callExit();
383382
}
384383

385384
// check password cookie
@@ -552,12 +551,9 @@ public function storePasswordCookie(string $password): void
552551
* prepares error message and switches to showLoginForm() which display the error
553552
* and the login form
554553
*
555-
* this function MUST exit/quit the application,
556-
* currently done by call to showLoginForm()
557-
*
558554
* @param string $failure String describing why authentication has failed
559555
*/
560-
public function showFailure(string $failure): void
556+
public function showFailure(string $failure): never
561557
{
562558
$GLOBALS['conn_error'] ??= null;
563559

libraries/classes/Plugins/Auth/AuthenticationHttp.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ class AuthenticationHttp extends AuthenticationPlugin
3030
{
3131
/**
3232
* Displays authentication form and redirect as necessary
33-
*
34-
* @return bool always true (no return indeed)
3533
*/
36-
public function showLoginForm(): bool
34+
public function showLoginForm(): never
3735
{
3836
$response = ResponseRenderer::getInstance();
3937
if ($response->isAjax()) {
@@ -43,13 +41,13 @@ public function showLoginForm(): bool
4341
$response->callExit();
4442
}
4543

46-
return $this->authForm();
44+
$this->authForm();
4745
}
4846

4947
/**
5048
* Displays authentication form
5149
*/
52-
public function authForm(): bool
50+
public function authForm(): never
5351
{
5452
if (empty($GLOBALS['cfg']['Server']['auth_http_realm'])) {
5553
if (empty($GLOBALS['cfg']['Server']['verbose'])) {
@@ -179,7 +177,7 @@ public function readCredentials(): bool
179177
*
180178
* @param string $failure String describing why authentication has failed
181179
*/
182-
public function showFailure(string $failure): void
180+
public function showFailure(string $failure): never
183181
{
184182
parent::showFailure($failure);
185183

libraries/classes/Plugins/Auth/AuthenticationSignon.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AuthenticationSignon extends AuthenticationPlugin
3232
/**
3333
* Displays authentication form
3434
*/
35-
public function showLoginForm(): bool
35+
public function showLoginForm(): never
3636
{
3737
$response = ResponseRenderer::getInstance();
3838
$response->disable();
@@ -244,7 +244,7 @@ public function readCredentials(): bool
244244
*
245245
* @param string $failure String describing why authentication has failed
246246
*/
247-
public function showFailure(string $failure): void
247+
public function showFailure(string $failure): never
248248
{
249249
parent::showFailure($failure);
250250

libraries/classes/Plugins/AuthenticationPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct()
6161
/**
6262
* Displays authentication form
6363
*/
64-
abstract public function showLoginForm(): bool;
64+
abstract public function showLoginForm(): void;
6565

6666
/**
6767
* Gets authentication credentials

libraries/classes/ResponseRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public function setHttpResponseCode(int $responseCode): void
439439
*
440440
* @param string $location will set location to redirect.
441441
*/
442-
public function generateHeader303(string $location): void
442+
public function generateHeader303(string $location): never
443443
{
444444
$this->setHttpResponseCode(303);
445445
$this->header('Location: ' . $location);

libraries/classes/Setup/FormProcessing.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public static function process(FormDisplay $formDisplay): void
4848
$response = ResponseRenderer::getInstance();
4949
$response->disable();
5050
$response->generateHeader303('../setup/index.php' . Url::getCommonRaw(['route' => '/setup']));
51-
52-
return;
5351
}
5452

5553
// form has errors, show warning

psalm-baseline.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8177,9 +8177,6 @@
81778177
<InvalidArrayOffset>
81788178
<code><![CDATA[$GLOBALS['allowDeny_forbidden']]]></code>
81798179
</InvalidArrayOffset>
8180-
<PossiblyUnusedReturnValue>
8181-
<code>bool</code>
8182-
</PossiblyUnusedReturnValue>
81838180
</file>
81848181
<file src="libraries/classes/Plugins/Auth/AuthenticationCookie.php">
81858182
<DocblockTypeContradiction>
@@ -8243,7 +8240,6 @@
82438240
</PossiblyNullReference>
82448241
<PossiblyUnusedReturnValue>
82458242
<code>bool</code>
8246-
<code>bool</code>
82478243
</PossiblyUnusedReturnValue>
82488244
<RedundantCast>
82498245
<code><![CDATA[(int) $GLOBALS['cfg']['LoginCookieStore']]]></code>
@@ -8271,9 +8267,6 @@
82718267
<PossiblyInvalidCast>
82728268
<code>$oldUser</code>
82738269
</PossiblyInvalidCast>
8274-
<PossiblyUnusedReturnValue>
8275-
<code>bool</code>
8276-
</PossiblyUnusedReturnValue>
82778270
</file>
82788271
<file src="libraries/classes/Plugins/Auth/AuthenticationSignon.php">
82798272
<MixedArgument>
@@ -8297,9 +8290,6 @@
82978290
<code><![CDATA[$this->password]]></code>
82988291
<code><![CDATA[$this->user]]></code>
82998292
</MixedAssignment>
8300-
<PossiblyUnusedReturnValue>
8301-
<code>bool</code>
8302-
</PossiblyUnusedReturnValue>
83038293
<RedundantCast>
83048294
<code><![CDATA[(array) $GLOBALS['cfg']['Server']['SignonCookieParams']]]></code>
83058295
</RedundantCast>
@@ -8326,9 +8316,6 @@
83268316
<PossiblyNullReference>
83278317
<code>issetCookie</code>
83288318
</PossiblyNullReference>
8329-
<PossiblyUnusedReturnValue>
8330-
<code>bool</code>
8331-
</PossiblyUnusedReturnValue>
83328319
</file>
83338320
<file src="libraries/classes/Plugins/AuthenticationPluginFactory.php">
83348321
<RedundantFunctionCall>

test/classes/Plugins/Auth/AuthenticationConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testAuthFails(): void
9494

9595
$html = ob_get_clean();
9696

97-
$this->assertInstanceOf(ExitException::class, $throwable ?? null);
97+
$this->assertInstanceOf(ExitException::class, $throwable);
9898

9999
$this->assertIsString($html);
100100

0 commit comments

Comments
 (0)