From e7ee059f5c04817df39462ae289528e7dfeddcb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 25 Mar 2016 21:31:25 +0100 Subject: [PATCH] Fix code style in session classes --- .../lib/data/acp/session/ACPSession.class.php | 17 ++++++----------- .../data/acp/session/ACPSessionAction.class.php | 4 ++-- .../data/acp/session/ACPSessionEditor.class.php | 8 ++++---- .../data/acp/session/ACPSessionList.class.php | 4 ++-- .../session/virtual/ACPSessionVirtual.class.php | 16 +++++++++++----- .../virtual/ACPSessionVirtualAction.class.php | 2 +- .../files/lib/data/session/Session.class.php | 1 - .../session/virtual/SessionVirtual.class.php | 6 ------ 8 files changed, 26 insertions(+), 32 deletions(-) diff --git a/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php b/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php index cb8061bad1..8d120e5455 100644 --- a/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php @@ -28,17 +28,17 @@ use wcf\system\WCF; */ class ACPSession extends DatabaseObject { /** - * @see \wcf\data\DatabaseObject::$databaseTableName + * @inheritDoc */ protected static $databaseTableName = 'acp_session'; /** - * @see \wcf\data\DatabaseObject::$databaseTableIndexIsIdentity + * @inheritDoc */ protected static $databaseTableIndexIsIdentity = false; /** - * @see \wcf\data\DatabaseObject::$databaseTableIndexName + * @inheritDoc */ protected static $databaseTableIndexName = 'sessionID'; @@ -66,20 +66,15 @@ class ACPSession extends DatabaseObject { * is no such session. * * @param integer $userID - * @return \wcf\data\session\Session + * @return ACPSession */ public static function getSessionByUserID($userID) { $sql = "SELECT * FROM ".static::getDatabaseTableName()." WHERE userID = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($userID)); - $row = $statement->fetchArray(); + $statement->execute([$userID]); - if ($row === false) { - return null; - } - - return new static(null, $row); + return $statement->fetchObject(static::class); } } diff --git a/wcfsetup/install/files/lib/data/acp/session/ACPSessionAction.class.php b/wcfsetup/install/files/lib/data/acp/session/ACPSessionAction.class.php index dc6e0469fb..9abb4679c2 100644 --- a/wcfsetup/install/files/lib/data/acp/session/ACPSessionAction.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/ACPSessionAction.class.php @@ -14,7 +14,7 @@ use wcf\data\AbstractDatabaseObjectAction; */ class ACPSessionAction extends AbstractDatabaseObjectAction { /** - * @see \wcf\data\AbstractDatabaseObjectAction::$className + * @inheritDoc */ - protected $className = 'wcf\data\acp\session\ACPSessionEditor'; + protected $className = ACPSessionEditor::class; } diff --git a/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php b/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php index 6f863e0277..498ba65e61 100644 --- a/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/ACPSessionEditor.class.php @@ -16,12 +16,12 @@ use wcf\system\WCF; */ class ACPSessionEditor extends DatabaseObjectEditor { /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - protected static $baseClass = 'wcf\data\acp\session\ACPSession'; + protected static $baseClass = ACPSession::class; /** - * @see \wcf\data\DatabaseObjectEditor::create() + * @inheritDoc */ public static function create(array $parameters = array()) { if (isset($parameters['userID']) && !$parameters['userID']) { @@ -68,6 +68,6 @@ class ACPSessionEditor extends DatabaseObjectEditor { $sql = "DELETE FROM ".call_user_func(array(static::$baseClass, 'getDatabaseTableName'))." WHERE lastActivityTime < ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($timestamp)); + $statement->execute([$timestamp]); } } diff --git a/wcfsetup/install/files/lib/data/acp/session/ACPSessionList.class.php b/wcfsetup/install/files/lib/data/acp/session/ACPSessionList.class.php index fbde91f36e..a187f43df6 100644 --- a/wcfsetup/install/files/lib/data/acp/session/ACPSessionList.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/ACPSessionList.class.php @@ -14,7 +14,7 @@ use wcf\data\DatabaseObjectList; */ class ACPSessionList extends DatabaseObjectList { /** - * @see \wcf\data\DatabaseObjectList::$className + * @inheritDoc */ - public $className = 'wcf\data\acp\session\ACPSession'; + public $className = ACPSession::class; } diff --git a/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php b/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php index dd4b98bfa8..c5d318c8a5 100644 --- a/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php @@ -19,15 +19,22 @@ use wcf\util\UserUtil; * @package com.woltlab.wcf * @subpackage data.acp.session.virtual * @category Community Framework + * + * @property-read integer $virtualSessionID + * @property-read string $sessionID + * @property-read string $ipAddress + * @property-read string $userAgent + * @property-read integer $lastActivityTime + * @property-read string $sessionVariables */ class ACPSessionVirtual extends DatabaseObject { /** - * @see \wcf\data\DatabaseObject::$databaseTableName + * @inheritDoc */ protected static $databaseTableName = 'acp_session_virtual'; /** - * @see \wcf\data\DatabaseObject::$databaseTableIndexName + * @inheritDoc */ protected static $databaseTableIndexName = 'virtualSessionID'; @@ -35,7 +42,7 @@ class ACPSessionVirtual extends DatabaseObject { * Returns the active virtual session object or null. * * @param string $sessionID - * @return \wcf\data\session\virtual\SessionVirtual + * @return ACPSessionVirtual */ public static function getExistingSession($sessionID) { $sql = "SELECT * @@ -65,8 +72,7 @@ class ACPSessionVirtual extends DatabaseObject { WHERE sessionID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($sessionID)); - $row = $statement->fetchArray(); - return $row['count']; + return $statement->fetchColumn(); } } diff --git a/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtualAction.class.php b/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtualAction.class.php index 6a81565cc8..9d106c9648 100644 --- a/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtualAction.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtualAction.class.php @@ -15,7 +15,7 @@ use wcf\util\UserUtil; */ class ACPSessionVirtualAction extends AbstractDatabaseObjectAction { /** - * @see \wcf\data\AbstractDatabaseObjectAction::$className + * @inheritDoc */ protected $className = ACPSessionVirtualEditor::class; diff --git a/wcfsetup/install/files/lib/data/session/Session.class.php b/wcfsetup/install/files/lib/data/session/Session.class.php index f9778e6014..db20962f39 100644 --- a/wcfsetup/install/files/lib/data/session/Session.class.php +++ b/wcfsetup/install/files/lib/data/session/Session.class.php @@ -12,7 +12,6 @@ use wcf\data\acp\session\ACPSession; * @subpackage data.session * @category Community Framework * - * @property-read string $sessionVariables * @property-read string $spiderID */ class Session extends ACPSession { diff --git a/wcfsetup/install/files/lib/data/session/virtual/SessionVirtual.class.php b/wcfsetup/install/files/lib/data/session/virtual/SessionVirtual.class.php index 71c1e0f322..23342cab6c 100644 --- a/wcfsetup/install/files/lib/data/session/virtual/SessionVirtual.class.php +++ b/wcfsetup/install/files/lib/data/session/virtual/SessionVirtual.class.php @@ -12,12 +12,6 @@ use wcf\data\acp\session\virtual\ACPSessionVirtual; * @package com.woltlab.wcf * @subpackage data.session.virtual * @category Community Framework - * - * @property-read integer $virtualSessionID - * @property-read string $sessionID - * @property-read string $ipAddress - * @property-read string $userAgent - * @property-read integer $lastActivityTime */ class SessionVirtual extends ACPSessionVirtual { /** -- 2.20.1