Skip to content

Commit

Permalink
Use PHP 8.1 never return type (#1184)
Browse files Browse the repository at this point in the history
This replaces the `@return never` docstring used by some CI tools.

Related to #1183.
  • Loading branch information
hemberger authored Dec 9, 2021
1 parent e958ad5 commit f386316
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function handleException(Throwable $e) : void {
/**
* Can be used to convert any type of notice into an exception.
*/
function exception_error_handler($errno, $errstr, $errfile, $errline) {
function exception_error_handler($errno, $errstr, $errfile, $errline) : never {
throw new ErrorException($errstr, $errno, E_ERROR, $errfile, $errline);
}

Expand Down
5 changes: 1 addition & 4 deletions src/engine/Default/alliance_set_op_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
$account = $session->getAccount();
$player = $session->getPlayer();

/**
* @return never
*/
function error_on_page(string $error) : void {
function error_on_page(string $error) : never {
$message = '<span class="bold red">ERROR:</span> ' . $error;
Page::create('skeleton.php', 'alliance_set_op.php', array('message' => $message))->go();
}
Expand Down
5 changes: 1 addition & 4 deletions src/engine/Default/chat_sharing_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
$session = Smr\Session::getInstance();
$player = $session->getPlayer();

/**
* @return never
*/
function error_on_page(string $message) : void {
function error_on_page(string $message) : never {
$message = '<span class="bold red">ERROR:</span> ' . $message;
Page::create('skeleton.php', 'chat_sharing.php', array('message' => $message))->go();
}
Expand Down
4 changes: 1 addition & 3 deletions src/lib/Default/Page.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ public static function copy(Page $other) : self {

/**
* Forward to the page identified by this container.
*
* @return never
*/
public function go() : void {
public function go() : never {
if (defined('OVERRIDE_FORWARD') && OVERRIDE_FORWARD === true) {
overrideForward($this);
}
Expand Down
9 changes: 2 additions & 7 deletions src/lib/Default/smr.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,7 @@ function bbifyMessage(string $message, bool $noLinks = false) : string {
return $message;
}

/**
* @return never
*/
function create_error(string $message) : void {
function create_error(string $message) : never {
$container = Page::create('skeleton.php', 'error.php');
$container['message'] = $message;
if (USING_AJAX) {
Expand Down Expand Up @@ -297,10 +294,8 @@ function pluralise(string $word, float $count = 0) : string {
* This function is a hack around the old style http forward mechanism.
* It is also responsible for setting most of the global variables
* (see loader.php for the initialization of the globals).
*
* @return never
*/
function do_voodoo() : void {
function do_voodoo() : never {
global $lock;

$session = Smr\Session::getInstance();
Expand Down
10 changes: 2 additions & 8 deletions src/tools/npc/npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
// Use this exception to help override container forwarding for NPC's
class ForwardException extends Exception {}

/**
* @return never
*/
function overrideForward(Page $container) : void {
function overrideForward(Page $container) : never {
global $forwardedContainer;
$forwardedContainer = $container;
if ($container['body'] == 'error.php') {
Expand Down Expand Up @@ -335,10 +332,7 @@ function debug(string $message, mixed $debugObject = null) : void {
}
}

/**
* @return never
*/
function processContainer(Page $container) : void {
function processContainer(Page $container) : never {
global $forwardedContainer, $previousContainer;
$session = Smr\Session::getInstance();
$player = $session->getPlayer();
Expand Down

0 comments on commit f386316

Please sign in to comment.