From 1955132e54964ec63fb70fb07e01715506a56ba4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 3 Jun 2022 12:32:03 +0200 Subject: [PATCH] Improve typing in \wcf\system\request\Request --- .../lib/system/request/Request.class.php | 45 +++++-------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/wcfsetup/install/files/lib/system/request/Request.class.php b/wcfsetup/install/files/lib/system/request/Request.class.php index 3f362cbce0..8b694aeda9 100644 --- a/wcfsetup/install/files/lib/system/request/Request.class.php +++ b/wcfsetup/install/files/lib/system/request/Request.class.php @@ -11,49 +11,32 @@ use wcf\http\LegacyPlaceholderResponse; /** * Represents a page request. * - * @author Marcel Werk + * @author Tim Duesterhus, Marcel Werk * @copyright 2001-2022 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Request */ final class Request implements RequestHandlerInterface { - /** - * page class name - * @var string - */ - protected $className = ''; + private readonly string $className; - /** - * @var bool - */ - protected $isLandingPage = false; + private readonly bool $isLandingPage; - /** - * request meta data - * @var string[] - */ - protected $metaData; + private readonly array $metaData; /** * current page id * @var int */ - protected $pageID; + private $pageID; /** * request object * @var object */ - protected $requestObject; + private $requestObject; - /** - * Creates a new request object. - * - * @param string $className fully qualified name - * @param string[] $metaData additional meta data - */ - public function __construct($className, array $metaData, bool $isLandingPage) + public function __construct(string $className, array $metaData, bool $isLandingPage) { $this->className = $className; $this->metaData = $metaData; @@ -84,20 +67,16 @@ final class Request implements RequestHandlerInterface /** * Returns true if this request represents the landing page. - * - * @return bool */ - public function isLandingPage() + public function isLandingPage(): bool { return $this->isLandingPage; } /** * Returns the page class name of this request. - * - * @return string */ - public function getClassName() + public function getClassName(): string { return $this->className; } @@ -125,10 +104,8 @@ final class Request implements RequestHandlerInterface /** * Returns true if the requested page is available during the offline mode. - * - * @return bool */ - public function isAvailableDuringOfflineMode() + public function isAvailableDuringOfflineMode(): bool { if ( \defined($this->className . '::AVAILABLE_DURING_OFFLINE_MODE') @@ -153,7 +130,7 @@ final class Request implements RequestHandlerInterface */ public function getPageID() { - if ($this->pageID === null) { + if (!isset($this->pageID)) { if (isset($this->metaData['cms'])) { $this->pageID = $this->metaData['cms']['pageID']; } else { -- 2.20.1