From 734662c9b1fee3ce7c6fedb26814eddb03a9afb0 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 25 Mar 2016 21:54:07 +0100 Subject: [PATCH] Add some missing property declarations MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … and resolve related code issues --- .../files/lib/acp/form/UserAddForm.class.php | 42 ++++---- .../lib/acp/form/UserGroupEditForm.class.php | 50 +++------- .../lib/acp/page/TemplateDiffPage.class.php | 38 ++++--- .../files/lib/acp/page/UserListPage.class.php | 99 ++++++++++--------- .../data/category/CategoryNodeTree.class.php | 41 ++++---- .../lib/form/AbstractModerationForm.class.php | 36 ++++--- .../system/captcha/CaptchaHandler.class.php | 17 +++- .../captcha/CaptchaQuestionHandler.class.php | 25 +++-- .../cli/command/PackageCLICommand.class.php | 58 +++++------ .../PackageInstallationFormManager.class.php | 2 +- 10 files changed, 218 insertions(+), 190 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php index f36413e97f..2259a87f85 100644 --- a/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserAddForm.class.php @@ -15,7 +15,7 @@ use wcf\util\UserUtil; * Shows the user add form. * * @author Marcel Werk - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage acp.form @@ -30,7 +30,7 @@ class UserAddForm extends UserOptionListForm { /** * @see \wcf\page\AbstractPage::$neededPermissions */ - public $neededPermissions = array('admin.user.canAddUser'); + public $neededPermissions = ['admin.user.canAddUser']; /** * username @@ -66,7 +66,7 @@ class UserAddForm extends UserOptionListForm { * user group ids * @var array */ - public $groupIDs = array(); + public $groupIDs = []; /** * language id @@ -78,7 +78,7 @@ class UserAddForm extends UserOptionListForm { * visible languages * @var array */ - public $visibleLanguages = array(); + public $visibleLanguages = []; /** * title of the user @@ -128,6 +128,12 @@ class UserAddForm extends UserOptionListForm { */ public $disableSignatureExpires = ''; + /** + * tree of available user options + * @var array + */ + public $optionTree = []; + /** * @see \wcf\form\IForm::readFormParameters() */ @@ -192,17 +198,17 @@ class UserAddForm extends UserOptionListForm { // validate user groups if (!empty($this->groupIDs)) { $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("groupID IN (?)", array($this->groupIDs)); - $conditions->add("groupType NOT IN (?)", array(array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS))); + $conditions->add("groupID IN (?)", [$this->groupIDs]); + $conditions->add("groupType NOT IN (?)", [[UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]]); $sql = "SELECT groupID FROM wcf".WCF_N."_user_group ".$conditions; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); - $this->groupIDs = array(); + $this->groupIDs = []; while ($row = $statement->fetchArray()) { - if (UserGroup::isAccessibleGroup(array($row['groupID']))) { + if (UserGroup::isAccessibleGroup([$row['groupID']])) { $this->groupIDs[] = $row['groupID']; } } @@ -252,8 +258,8 @@ class UserAddForm extends UserOptionListForm { // create $saveOptions = $this->optionHandler->save(); $this->additionalFields['languageID'] = $this->languageID; - $data = array( - 'data' => array_merge($this->additionalFields, array( + $data = [ + 'data' => array_merge($this->additionalFields, [ 'username' => $this->username, 'email' => $this->email, 'password' => $this->password, @@ -262,11 +268,11 @@ class UserAddForm extends UserOptionListForm { 'signatureEnableBBCodes' => $this->signatureEnableBBCodes, 'signatureEnableSmilies' => $this->signatureEnableSmilies, 'signatureEnableHtml' => $this->signatureEnableHtml - )), + ]), 'groups' => $this->groupIDs, 'languageIDs' => $this->visibleLanguages, 'options' => $saveOptions - ); + ]; if (WCF::getSession()->getPermission('admin.user.canDisableSignature')) { $disableSignatureExpires = 0; @@ -279,21 +285,21 @@ class UserAddForm extends UserOptionListForm { $data['data']['disableSignatureExpires'] = $disableSignatureExpires; } - $this->objectAction = new UserAction(array(), 'create', $data); + $this->objectAction = new UserAction([], 'create', $data); $this->objectAction->executeAction(); $this->saved(); // show empty add form - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'success' => true - )); + ]); // reset values $this->signatureEnableHtml = $this->disableSignature = 0; $this->signatureEnableSmilies = $this->signatureEnableBBCodes = 1; $this->username = $this->email = $this->confirmEmail = $this->password = $this->confirmPassword = $this->userTitle = ''; $this->signature = $this->disableSignatureReason = $this->disableSignatureExpires = ''; - $this->groupIDs = array(); + $this->groupIDs = []; $this->languageID = $this->getDefaultFormLanguageID(); $this->optionHandler->resetOptionValues(); } @@ -385,7 +391,7 @@ class UserAddForm extends UserOptionListForm { public function assignVariables() { parent::assignVariables(); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'username' => $this->username, 'email' => $this->email, 'confirmEmail' => $this->confirmEmail, @@ -407,7 +413,7 @@ class UserAddForm extends UserOptionListForm { 'disableSignature' => $this->disableSignature, 'disableSignatureReason' => $this->disableSignatureReason, 'disableSignatureExpires' => $this->disableSignatureExpires - )); + ]); } /** diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php index c5a98dff31..63a9564c74 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php @@ -21,14 +21,14 @@ use wcf\system\WCF; */ class UserGroupEditForm extends UserGroupAddForm { /** - * @see \wcf\page\AbstractPage::$activeMenuItem + * @inheritDoc */ public $activeMenuItem = 'wcf.acp.menu.link.group'; /** - * @see \wcf\page\AbstractPage::$neededPermissions + * @inheritDoc */ - public $neededPermissions = array('admin.user.canEditGroup'); + public $neededPermissions = ['admin.user.canEditGroup']; /** * id of the edited user group @@ -38,12 +38,12 @@ class UserGroupEditForm extends UserGroupAddForm { /** * user group editor object - * @var \wcf\data\user\group\UserGroupEditor + * @var UserGroupEditor */ public $group = null; /** - * @see \wcf\page\IPage::readParameters() + * @inheritDoc */ public function readParameters() { parent::readParameters(); @@ -65,7 +65,7 @@ class UserGroupEditForm extends UserGroupAddForm { } /** - * @see \wcf\acp\form\AbstractOptionListForm::initOptionHandler() + * @inheritDoc */ protected function initOptionHandler() { // does nothing, we call OptionHandler::init() after we set the @@ -73,7 +73,7 @@ class UserGroupEditForm extends UserGroupAddForm { } /** - * @see \wcf\page\IPage::readData() + * @inheritDoc */ public function readData() { if (empty($_POST)) { @@ -84,44 +84,25 @@ class UserGroupEditForm extends UserGroupAddForm { $this->priority = $this->group->priority; $this->userOnlineMarking = $this->group->userOnlineMarking; $this->showOnTeamPage = $this->group->showOnTeamPage; - $options = $this->optionHandler->getCategoryOptions(); - - // get default values - if ($this->group->groupType != UserGroup::EVERYONE) { - $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE); - foreach ($options as $option) { - $value = $defaultGroup->getGroupOption($option['object']->optionName); - if ($value !== null) { - $this->optionValues[$option['object']->optionName] = $value; - } - } - } - - foreach ($options as $option) { - $value = $this->group->getGroupOption($option['object']->optionName); - if ($value !== null) { - $this->optionValues[$option['object']->optionName] = $value; - } - } } parent::readData(); } /** - * @see \wcf\page\IPage::assignVariables() + * @inheritDoc */ public function assignVariables() { parent::assignVariables(); I18nHandler::getInstance()->assignVariables(!empty($_POST)); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'groupID' => $this->group->groupID, 'group' => $this->group, 'action' => 'edit', 'availableUserGroups' => UserGroup::getAccessibleGroups() - )); + ]); // add warning when the initiator is in the group if ($this->group->isMember()) { @@ -130,7 +111,7 @@ class UserGroupEditForm extends UserGroupAddForm { } /** - * @see \wcf\form\IForm::save() + * @inheritDoc */ public function save() { AbstractForm::save(); @@ -159,17 +140,16 @@ class UserGroupEditForm extends UserGroupAddForm { I18nHandler::getInstance()->save('groupDescription', $this->groupDescription, 'wcf.acp.group', 1); } - $data = array( - 'data' => array_merge($this->additionalFields, array( + $this->objectAction = new UserGroupAction([$this->groupID], 'update', [ + 'data' => array_merge($this->additionalFields, [ 'groupName' => $this->groupName, 'groupDescription' => $this->groupDescription, 'priority' => $this->priority, 'userOnlineMarking' => $this->userOnlineMarking, 'showOnTeamPage' => $this->showOnTeamPage - )), + ]), 'options' => $optionValues - ); - $this->objectAction = new UserGroupAction(array($this->groupID), 'update', $data); + ]); $this->objectAction->executeAction(); $this->saved(); diff --git a/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php b/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php index a5a9159d80..071f1f617c 100644 --- a/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/TemplateDiffPage.class.php @@ -13,7 +13,7 @@ use wcf\util\StringUtil; * Compares two templates. * * @author Tim Duesterhus - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage acp.form @@ -21,7 +21,7 @@ use wcf\util\StringUtil; */ class TemplateDiffPage extends AbstractPage { /** - * @see \wcf\page\AbstractPage::$activeMenuItem + * @inheritDoc */ public $activeMenuItem = 'wcf.acp.menu.link.template'; @@ -33,7 +33,7 @@ class TemplateDiffPage extends AbstractPage { /** * template object - * @var \wcf\data\template\Template + * @var Template */ public $template = null; @@ -45,18 +45,24 @@ class TemplateDiffPage extends AbstractPage { /** * template to compare with - * @var \wcf\data\template\Template + * @var Template */ public $parent = null; /** * differences between both templates - * @var \wcf\util\Diff + * @var Diff */ public $diff = null; /** - * @see \wcf\page\IPage::readParameters() + * template group hierarchy + * @var array + */ + public $templateGroupHierarchy = []; + + /** + * @inheritDoc */ public function readParameters() { parent::readParameters(); @@ -76,7 +82,7 @@ class TemplateDiffPage extends AbstractPage { } /** - * @see \wcf\page\IPage::readData() + * @inheritDoc */ public function readData() { parent::readData(); @@ -86,19 +92,19 @@ class TemplateDiffPage extends AbstractPage { $templateGroupList->readObjects(); // build template group hierarchy (template groups that are parents of the template group of the selected template) - $this->templateGroupHierarchy = array(); + $this->templateGroupHierarchy = []; $templateGroup = $templateGroupList->search($this->template->templateGroupID); while ($templateGroup !== null) { - $this->templateGroupHierarchy[$templateGroup->templateGroupID] = array('group' => $templateGroup, 'hasTemplate' => false); + $this->templateGroupHierarchy[$templateGroup->templateGroupID] = ['group' => $templateGroup, 'hasTemplate' => false]; $templateGroup = $templateGroupList->search($templateGroup->parentTemplateGroupID); } - $this->templateGroupHierarchy[0] = array('group' => array(), 'hasTemplate' => false); + $this->templateGroupHierarchy[0] = ['group' => [], 'hasTemplate' => false]; // find matching templates in the hierarchy $templateList = new TemplateList(); - $templateList->getConditionBuilder()->add('templateName = ?', array($this->template->templateName)); - $templateList->getConditionBuilder()->add('application = ?', array($this->template->application)); - $templateList->getConditionBuilder()->add('(template.templateGroupID IN(?) OR template.templateGroupID IS NULL)', array(array_keys($this->templateGroupHierarchy))); + $templateList->getConditionBuilder()->add('templateName = ?', [$this->template->templateName]); + $templateList->getConditionBuilder()->add('application = ?', [$this->template->application]); + $templateList->getConditionBuilder()->add('(template.templateGroupID IN(?) OR template.templateGroupID IS NULL)', [array_keys($this->templateGroupHierarchy)]); $templateList->readObjects(); foreach ($templateList as $template) { $this->templateGroupHierarchy[($template->templateGroupID ?: 0)]['hasTemplate'] = $template->templateID; @@ -113,18 +119,18 @@ class TemplateDiffPage extends AbstractPage { } /** - * @see \wcf\page\IPage::assignVariables() + * @inheritDoc */ public function assignVariables() { parent::assignVariables(); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'templateID' => $this->templateID, 'template' => $this->template, 'parentID' => $this->parentID, 'parent' => $this->parent, 'diff' => $this->diff, 'templateGroupHierarchy' => array_reverse($this->templateGroupHierarchy, true) - )); + ]); } } diff --git a/wcfsetup/install/files/lib/acp/page/UserListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserListPage.class.php index 24e2559322..d0dc3c12b9 100755 --- a/wcfsetup/install/files/lib/acp/page/UserListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserListPage.class.php @@ -10,6 +10,7 @@ use wcf\system\clipboard\ClipboardHandler; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\event\EventHandler; use wcf\system\exception\IllegalLinkException; +use wcf\system\option\IOptionHandler; use wcf\system\request\LinkHandler; use wcf\system\WCF; use wcf\util\DateUtil; @@ -28,58 +29,58 @@ use wcf\util\StringUtil; class UserListPage extends SortablePage { /** * list of displayed column names - * @var array + * @var string[] */ - public $columnHeads = array(); + public $columnHeads = []; /** * list of selected columns - * @var array + * @var string[] */ - public $columns = array('registrationDate', 'lastActivityTime'); + public $columns = ['registrationDate', 'lastActivityTime']; /** * applies special CSS classes for selected columns * @var array */ - public $columnStyling = array( + public $columnStyling = [ 'registrationDate' => 'columnDate', 'lastActivityTime' => 'columnDate', 'profileHits' => 'columnDigits', 'activityPoints' => 'columnDigits', 'likesReceived' => 'columnDigits' - ); + ]; /** * list of column values - * @var array + * @var string[] */ - public $columnValues = array(); + public $columnValues = []; /** - * @see \wcf\page\SortablePage::$defaultSortField + * @inheritDoc */ public $defaultSortField = 'username'; /** - * @see \wcf\page\MultipleLinkPage::$itemsPerPage + * @inheritDoc */ public $itemsPerPage = 50; /** * list of marked user ids - * @var array + * @var integer[] */ - public $markedUsers = array(); + public $markedUsers = []; /** - * @see \wcf\page\AbstractPage::$neededPermissions + * @inheritDoc */ - public $neededPermissions = array('admin.user.canSearchUser'); + public $neededPermissions = ['admin.user.canSearchUser']; /** * IOptionHandler object - * @var \wcf\system\option\IOptionHandler + * @var IOptionHandler */ protected $optionHandler = null; @@ -87,7 +88,7 @@ class UserListPage extends SortablePage { * list of available user option names * @var array */ - public $options = array(); + public $options = []; /** * id of a user search @@ -97,15 +98,15 @@ class UserListPage extends SortablePage { /** * list of user ids - * @var array + * @var integer[] */ - public $userIDs = array(); + public $userIDs = []; /** * list of users - * @var array<\wcf\data\user\User> + * @var User[] */ - public $users = array(); + public $users = []; /** * page url @@ -114,12 +115,18 @@ class UserListPage extends SortablePage { public $url = ''; /** - * @see \wcf\page\SortablePage::$validSortFields + * condition builder for user filtering + * @var PreparedStatementConditionBuilder */ - public $validSortFields = array('userID', 'registrationDate', 'username', 'lastActivityTime', 'profileHits', 'activityPoints', 'likesReceived'); + public $conditions = null; /** - * @see \wcf\page\IPage::readParameters() + * @inheritDoc + */ + public $validSortFields = ['userID', 'registrationDate', 'username', 'lastActivityTime', 'profileHits', 'activityPoints', 'likesReceived']; + + /** + * @inheritDoc */ public function readParameters() { parent::readParameters(); @@ -132,7 +139,7 @@ class UserListPage extends SortablePage { if (empty($this->userIDs)) { throw new IllegalLinkException(); } - $this->conditions->add("user_table.userID IN (?)", array($this->userIDs)); + $this->conditions->add("user_table.userID IN (?)", [$this->userIDs]); } // get user options @@ -140,7 +147,7 @@ class UserListPage extends SortablePage { } /** - * @see \wcf\page\SortablePage::validateSortField() + * @inheritDoc */ public function validateSortField() { // add options to valid sort fields @@ -155,7 +162,7 @@ class UserListPage extends SortablePage { } /** - * @see \wcf\page\IPage::readData() + * @inheritDoc */ public function readData() { parent::readData(); @@ -167,7 +174,7 @@ class UserListPage extends SortablePage { // get marked users $this->markedUsers = WCF::getSession()->getVar('markedUsers'); - if ($this->markedUsers == null || !is_array($this->markedUsers)) $this->markedUsers = array(); + if ($this->markedUsers == null || !is_array($this->markedUsers)) $this->markedUsers = []; // get columns heads $this->readColumnsHeads(); @@ -176,16 +183,16 @@ class UserListPage extends SortablePage { $this->readUsers(); // build page url - $this->url = LinkHandler::getInstance()->getLink('UserList', array(), 'searchID='.$this->searchID.'&action='.rawurlencode($this->action).'&pageNo='.$this->pageNo.'&sortField='.$this->sortField.'&sortOrder='.$this->sortOrder); + $this->url = LinkHandler::getInstance()->getLink('UserList', [], 'searchID='.$this->searchID.'&action='.rawurlencode($this->action).'&pageNo='.$this->pageNo.'&sortField='.$this->sortField.'&sortOrder='.$this->sortOrder); } /** - * @see \wcf\page\IPage::assignVariables() + * @inheritDoc */ public function assignVariables() { parent::assignVariables(); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'users' => $this->users, 'searchID' => $this->searchID, 'hasMarkedItems' => ClipboardHandler::getInstance()->hasMarkedItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user')), @@ -193,11 +200,11 @@ class UserListPage extends SortablePage { 'columnHeads' => $this->columnHeads, 'columnValues' => $this->columnValues, 'columnStyling' => $this->columnStyling - )); + ]); } /** - * @see \wcf\page\IPage::show() + * @inheritDoc */ public function show() { $this->activeMenuItem = 'wcf.acp.menu.link.user.'.($this->searchID ? 'search' : 'list'); @@ -206,7 +213,7 @@ class UserListPage extends SortablePage { } /** - * @see \wcf\page\MultipleLinkPage::countItems() + * @inheritDoc */ public function countItems() { // call countItems event @@ -226,7 +233,7 @@ class UserListPage extends SortablePage { */ protected function readUsers() { // get user ids - $userIDs = array(); + $userIDs = []; $sql = "SELECT user_table.userID FROM wcf".WCF_N."_user user_table ".(isset($this->options[$this->sortField]) ? "LEFT JOIN wcf".WCF_N."_user_option_value user_option_value ON (user_option_value.userID = user_table.userID)" : '')." @@ -240,11 +247,11 @@ class UserListPage extends SortablePage { // get user data if (!empty($userIDs)) { - $userToGroups = array(); + $userToGroups = []; // get group ids $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("user_table.userID IN (?)", array($userIDs)); + $conditions->add("user_table.userID IN (?)", [$userIDs]); $sql = "SELECT userID, groupID FROM wcf".WCF_N."_user_to_group user_table @@ -266,7 +273,7 @@ class UserListPage extends SortablePage { $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); while ($row = $statement->fetchArray()) { - $groupIDs = (isset($userToGroups[$row['userID']]) ? $userToGroups[$row['userID']] : array()); + $groupIDs = (isset($userToGroups[$row['userID']]) ? $userToGroups[$row['userID']] : []); $row['groupIDs'] = implode(',', $groupIDs); $accessible = (!empty($groupIDs) ? UserGroup::isAccessibleGroup($groupIDs) : true); @@ -333,11 +340,11 @@ class UserListPage extends SortablePage { AND userID = ? AND searchType = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( + $statement->execute([ $this->searchID, WCF::getUser()->userID, 'users' - )); + ]); $search = $statement->fetchArray(); if (!isset($search['searchData'])) { throw new IllegalLinkException(); @@ -354,7 +361,7 @@ class UserListPage extends SortablePage { * Gets the user options from cache. */ protected function readUserOptions() { - $this->options = UserOptionCacheBuilder::getInstance()->getData(array(), 'options'); + $this->options = UserOptionCacheBuilder::getInstance()->getData([], 'options'); foreach ($this->options as &$option) { $option = new ViewableUserOption($option); @@ -386,12 +393,16 @@ class UserListPage extends SortablePage { } /** - * @see \wcf\page\MultipleLinkPage::initObjectList() + * @inheritDoc */ - protected function initObjectList() { } + protected function initObjectList() { + // does nothing + } /** - * @see \wcf\page\MultipleLinkPage::readObjects() + * @inheritDoc */ - protected function readObjects() { } + protected function readObjects() { + // does nothing + } } diff --git a/wcfsetup/install/files/lib/data/category/CategoryNodeTree.class.php b/wcfsetup/install/files/lib/data/category/CategoryNodeTree.class.php index 1951a13947..efc7d22edd 100644 --- a/wcfsetup/install/files/lib/data/category/CategoryNodeTree.class.php +++ b/wcfsetup/install/files/lib/data/category/CategoryNodeTree.class.php @@ -7,7 +7,7 @@ use wcf\system\exception\SystemException; * Represents a tree of category nodes. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.category @@ -15,8 +15,7 @@ use wcf\system\exception\SystemException; */ class CategoryNodeTree implements \IteratorAggregate { /** - * maximum depth considered when building the node tree. - * + * maximum depth considered when building the node tree * @var integer */ protected $maxDepth = -1; @@ -25,7 +24,7 @@ class CategoryNodeTree implements \IteratorAggregate { * name of the category node class * @var string */ - protected $nodeClassName = 'wcf\data\category\CategoryNode'; + protected $nodeClassName = CategoryNode::class; /** * id of the parent category @@ -35,19 +34,25 @@ class CategoryNodeTree implements \IteratorAggregate { /** * parent category node - * @var \wcf\data\category\CategoryNode + * @var CategoryNode */ protected $parentNode = null; + /** + * name of the category object type + * @var string + */ + protected $objectType = ''; + /** * Creates a new instance of CategoryNodeTree. * * @param string $objectType * @param integer $parentCategoryID * @param boolean $includeDisabledCategories - * @param array $excludedCategoryIDs + * @param integer[] $excludedCategoryIDs */ - public function __construct($objectType, $parentCategoryID = 0, $includeDisabledCategories = false, array $excludedCategoryIDs = array()) { + public function __construct($objectType, $parentCategoryID = 0, $includeDisabledCategories = false, array $excludedCategoryIDs = []) { $this->objectType = $objectType; $this->parentCategoryID = $parentCategoryID; $this->includeDisabledCategories = $includeDisabledCategories; @@ -80,8 +85,8 @@ class CategoryNodeTree implements \IteratorAggregate { /** * Builds a certain level of the tree. * - * @param \wcf\data\category\CategoryNode $parentNode - * @param integer $depth + * @param CategoryNode $parentNode + * @param integer $depth */ protected function buildTreeLevel(CategoryNode $parentNode, $depth = 0) { if ($this->maxDepth != -1 && $depth < 0) { @@ -104,7 +109,7 @@ class CategoryNodeTree implements \IteratorAggregate { * Returns the category with the given id. * * @param integer $categoryID - * @return \wcf\data\category\Category + * @return Category */ protected function getCategory($categoryID) { return CategoryHandler::getInstance()->getCategory($categoryID); @@ -113,15 +118,15 @@ class CategoryNodeTree implements \IteratorAggregate { /** * Returns the child categories of the given category node. * - * @param \wcf\data\category\CategoryNode $parentNode - * @return array<\wcf\data\category\Category> + * @param CategoryNode $parentNode + * @return Category[] */ protected function getChildCategories(CategoryNode $parentNode) { return CategoryHandler::getInstance()->getChildCategories($parentNode->categoryID, $parentNode->objectTypeID); } /** - * @see \IteratorAggregate::getIterator() + * @inheritDoc */ public function getIterator() { if ($this->parentNode === null) { @@ -135,21 +140,21 @@ class CategoryNodeTree implements \IteratorAggregate { * Returns the category node for the category with the given id. * * @param integer $categoryID - * @return \wcf\data\category\CategoryNode + * @return CategoryNode */ protected function getNode($categoryID) { if (!$categoryID) { - $category = new Category(null, array( + $category = new Category(null, [ 'categoryID' => 0, 'objectTypeID' => CategoryHandler::getInstance()->getObjectTypeByName($this->objectType)->objectTypeID - )); + ]); } else { $category = $this->getCategory($categoryID); } // decorate category if necessary - $decoratorClassName = call_user_func(array($this->nodeClassName, 'getBaseClass')); + $decoratorClassName = call_user_func([$this->nodeClassName, 'getBaseClass']); if ($decoratorClassName != 'wcf\data\category\Category') { $category = new $decoratorClassName($category); } @@ -161,7 +166,7 @@ class CategoryNodeTree implements \IteratorAggregate { * Returns true if the given category node fulfils all relevant conditions * to be included in this tree. * - * @param \wcf\data\category\CategoryNode $categoryNode + * @param CategoryNode $categoryNode * @return boolean */ protected function isIncluded(CategoryNode $categoryNode) { diff --git a/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php b/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php index ed8137e772..0d9a97d141 100644 --- a/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php +++ b/wcfsetup/install/files/lib/form/AbstractModerationForm.class.php @@ -15,32 +15,38 @@ use wcf\system\WCF; * Provides an abstract form for moderation queue processing. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage form * @category Community Framework */ abstract class AbstractModerationForm extends AbstractForm { + /** + * id of the assigned user + * @var integer + */ + public $assignedUserID = 0; + /** * data used for moderation queue update * @var array */ - public $data = array(); + public $data = []; /** - * @see \wcf\page\AbstractPage::$loginRequired + * @inheritDoc */ public $loginRequired = true; /** - * @see \wcf\page\AbstractPage::$neededPermissions + * @inheritDoc */ - public $neededPermissions = array('mod.general.canUseModeration'); + public $neededPermissions = ['mod.general.canUseModeration']; /** * moderation queue object - * @var \wcf\data\moderation\queue\ViewableModerationQueue + * @var ViewableModerationQueue */ public $queue = null; @@ -58,18 +64,18 @@ abstract class AbstractModerationForm extends AbstractForm { /** * comment manager object - * @var \wcf\system\comment\manager\ICommentManager + * @var ICommentManager */ public $commentManager = null; /** * list of comments - * @var \wcf\data\comment\StructuredCommentList + * @var StructuredCommentList */ public $commentList = null; /** - * @see \wcf\page\IPage::readParameters() + * @inheritDoc */ public function readParameters() { parent::readParameters(); @@ -86,7 +92,7 @@ abstract class AbstractModerationForm extends AbstractForm { } /** - * @see \wcf\page\IPage::readData() + * @inheritDoc */ public function readData() { parent::readData(); @@ -106,20 +112,20 @@ abstract class AbstractModerationForm extends AbstractForm { // update queue visit if ($this->queue->isNew()) { - $action = new ModerationQueueAction(array($this->queue->getDecoratedObject()), 'markAsRead', array( + $action = new ModerationQueueAction([$this->queue->getDecoratedObject()], 'markAsRead', [ 'visitTime' => TIME_NOW - )); + ]); $action->executeAction(); } } /** - * @see \wcf\page\IPage::assignVariables() + * @inheritDoc */ public function assignVariables() { parent::assignVariables(); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'assignedUserID' => $this->assignedUserID, 'queue' => $this->queue, 'queueID' => $this->queueID, @@ -129,7 +135,7 @@ abstract class AbstractModerationForm extends AbstractForm { 'lastCommentTime' => ($this->commentList ? $this->commentList->getMinCommentTime() : 0), 'sidebarCollapsed' => UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'com.woltlab.wcf.ModerationForm'), 'sidebarName' => 'com.woltlab.wcf.ModerationForm' - )); + ]); } /** diff --git a/wcfsetup/install/files/lib/system/captcha/CaptchaHandler.class.php b/wcfsetup/install/files/lib/system/captcha/CaptchaHandler.class.php index bf11f55464..89b9ea1063 100644 --- a/wcfsetup/install/files/lib/system/captcha/CaptchaHandler.class.php +++ b/wcfsetup/install/files/lib/system/captcha/CaptchaHandler.class.php @@ -1,5 +1,6 @@ * @package com.woltlab.wcf * @subpackage system.captcha * @category Community Framework */ class CaptchaHandler extends SingletonFactory { + /** + * available captcha object types + * @var ObjectType[] + */ + protected $objectTypes = []; + /** * Returns the available captcha types for selection. * - * @return array + * @return string[] */ public function getCaptchaSelection() { $selection = array(); @@ -36,7 +43,7 @@ class CaptchaHandler extends SingletonFactory { * object type exists. * * @param integer $objectTypeID - * @return \wcf\data\object\type\ObjectType + * @return ObjectType|null */ public function getObjectType($objectTypeID) { if (isset($this->objectTypes[$objectTypeID])) { @@ -51,14 +58,14 @@ class CaptchaHandler extends SingletonFactory { * object type exists. * * @param string $objectType - * @return \wcf\data\object\type\ObjectType + * @return ObjectType|null */ public function getObjectTypeByName($objectType) { return ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.captcha', $objectType); } /** - * @see \wcf\system\SingletonFactory::init() + * @inheritDoc */ protected function init() { $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.captcha'); diff --git a/wcfsetup/install/files/lib/system/captcha/CaptchaQuestionHandler.class.php b/wcfsetup/install/files/lib/system/captcha/CaptchaQuestionHandler.class.php index d086aab535..c8fe790ed8 100644 --- a/wcfsetup/install/files/lib/system/captcha/CaptchaQuestionHandler.class.php +++ b/wcfsetup/install/files/lib/system/captcha/CaptchaQuestionHandler.class.php @@ -1,5 +1,6 @@ * @package com.woltlab.wcf * @subpackage system.captcha @@ -30,10 +31,16 @@ class CaptchaQuestionHandler implements ICaptchaHandler { /** * captcha question to answer - * @var \wcf\data\captcha\question\CaptchaQuestion + * @var CaptchaQuestion */ protected $question = null; + /** + * list of available captcha questions + * @var CaptchaQuestion[] + */ + protected $questions = []; + /** * Creates a new instance of CaptchaQuestionHandler. */ @@ -42,29 +49,29 @@ class CaptchaQuestionHandler implements ICaptchaHandler { } /** - * @see \wcf\system\captcha\ICaptchaHandler::isAvailable() + * @inheritDoc */ public function isAvailable() { return count($this->questions) > 0; } /** - * @see \wcf\system\captcha\ICaptchaHandler::getFormElement() + * @inheritDoc */ public function getFormElement() { if ($this->question === null) { $this->readCaptchaQuestion(); } - return WCF::getTPL()->fetch('captchaQuestion', 'wcf', array( + return WCF::getTPL()->fetch('captchaQuestion', 'wcf', [ 'captchaQuestion' => $this->captchaQuestion, 'captchaQuestionAnswered' => WCF::getSession()->getVar('captchaQuestionSolved_'.$this->captchaQuestion) !== null, 'captchaQuestionObject' => $this->question - )); + ]); } /** - * @see \wcf\system\captcha\ICaptchaHandler::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['captchaQuestion'])) $this->captchaQuestion = StringUtil::trim($_POST['captchaQuestion']); @@ -72,7 +79,7 @@ class CaptchaQuestionHandler implements ICaptchaHandler { } /** - * @see \wcf\system\captcha\ICaptchaHandler::reset() + * @inheritDoc */ public function reset() { WCF::getSession()->unregister('captchaQuestion_'.$this->captchaQuestion); @@ -95,7 +102,7 @@ class CaptchaQuestionHandler implements ICaptchaHandler { } /** - * @see \wcf\system\captcha\ICaptchaHandler::validate() + * @inheritDoc */ public function validate() { $questionID = WCF::getSession()->getVar('captchaQuestion_'.$this->captchaQuestion); diff --git a/wcfsetup/install/files/lib/system/cli/command/PackageCLICommand.class.php b/wcfsetup/install/files/lib/system/cli/command/PackageCLICommand.class.php index e67def8a89..a3e8db3ac8 100644 --- a/wcfsetup/install/files/lib/system/cli/command/PackageCLICommand.class.php +++ b/wcfsetup/install/files/lib/system/cli/command/PackageCLICommand.class.php @@ -40,7 +40,7 @@ class PackageCLICommand implements IArgumentedCLICommand { * Initializes the argument parser. */ public function __construct() { - $this->argv = new ArgvParser(array()); + $this->argv = new ArgvParser([]); } /** @@ -88,13 +88,13 @@ class PackageCLICommand implements IArgumentedCLICommand { $file = $archive->downloadArchive(); } catch (SystemException $e) { - $this->error('notFound', array('file' => $file)); + $this->error('notFound', ['file' => $file]); } } else { // probably local path if (!file_exists($file)) { - $this->error('notFound', array('file' => $file)); + $this->error('notFound', ['file' => $file]); } $archive = new PackageArchive($file, null); @@ -113,7 +113,7 @@ class PackageCLICommand implements IArgumentedCLICommand { $errors = PackageInstallationDispatcher::validatePHPRequirements($archive->getPhpRequirements()); if (!empty($errors)) { // TODO: Nice output - $this->error('phpRequirements', array('errors' => $errors)); + $this->error('phpRequirements', ['errors' => $errors]); } // try to find existing package @@ -121,7 +121,7 @@ class PackageCLICommand implements IArgumentedCLICommand { FROM wcf".WCF_N."_package WHERE package = ?"; $statement = CLIWCF::getDB()->prepareStatement($sql); - $statement->execute(array($archive->getPackageInfo('name'))); + $statement->execute([$archive->getPackageInfo('name')]); $row = $statement->fetchArray(); $package = null; if ($row !== false) { @@ -130,7 +130,7 @@ class PackageCLICommand implements IArgumentedCLICommand { // check update or install support if ($package !== null) { - CLIWCF::getSession()->checkPermissions(array('admin.configuration.package.canUpdatePackage')); + CLIWCF::getSession()->checkPermissions(['admin.configuration.package.canUpdatePackage']); $archive->setPackage($package); if (!$archive->isValidUpdate()) { @@ -138,7 +138,7 @@ class PackageCLICommand implements IArgumentedCLICommand { } } else { - CLIWCF::getSession()->checkPermissions(array('admin.configuration.package.canInstallPackage')); + CLIWCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']); if (!$archive->isValidInstall()) { $this->error('noValidInstall'); @@ -150,7 +150,7 @@ class PackageCLICommand implements IArgumentedCLICommand { else if ($archive->isAlreadyInstalled()) { $this->error('uniqueAlreadyInstalled'); } - else if ($archive->getPackageInfo('isApplication') && $this->archive->hasUniqueAbbreviation()) { + else if ($archive->getPackageInfo('isApplication') && $archive->hasUniqueAbbreviation()) { $this->error('noUniqueAbbrevation'); } } @@ -159,7 +159,7 @@ class PackageCLICommand implements IArgumentedCLICommand { $processNo = PackageInstallationQueue::getNewProcessNo(); // insert queue - $queue = PackageInstallationQueueEditor::create(array( + $queue = PackageInstallationQueueEditor::create([ 'processNo' => $processNo, 'userID' => CLIWCF::getUser()->userID, 'package' => $archive->getPackageInfo('name'), @@ -167,15 +167,15 @@ class PackageCLICommand implements IArgumentedCLICommand { 'packageID' => ($package !== null) ? $package->packageID : null, 'archive' => $file, 'action' => ($package !== null ? 'update' : 'install') - )); + ]); // PackageInstallationDispatcher::openQueue() $parentQueueID = 0; $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("userID = ?", array(CLIWCF::getUser()->userID)); - $conditions->add("parentQueueID = ?", array($parentQueueID)); - if ($processNo != 0) $conditions->add("processNo = ?", array($processNo)); - $conditions->add("done = ?", array(0)); + $conditions->add("userID = ?", [CLIWCF::getUser()->userID]); + $conditions->add("parentQueueID = ?", [$parentQueueID]); + if ($processNo != 0) $conditions->add("processNo = ?", [$processNo]); + $conditions->add("done = ?", [0]); $sql = "SELECT * FROM wcf".WCF_N."_package_installation_queue @@ -250,11 +250,11 @@ class PackageCLICommand implements IArgumentedCLICommand { $excludingPackages = $packageInstallationDispatcher->getArchive()->getConflictedExcludingPackages(); $excludedPackages = $packageInstallationDispatcher->getArchive()->getConflictedExcludedPackages(); if (!($missingPackages == 0 && count($excludingPackages) == 0 && count($excludedPackages) == 0)) { - $this->error('missingPackagesOrExclude', array( + $this->error('missingPackagesOrExclude', [ 'requirements' => $requirements, 'excludingPackages' => $excludingPackages, 'excludedPackages' => $excludedPackages - )); + ]); return; } @@ -264,15 +264,15 @@ class PackageCLICommand implements IArgumentedCLICommand { $node = ''; // initialize progressbar - $progressbar = new ProgressBar(new ConsoleProgressBar(array( + $progressbar = new ProgressBar(new ConsoleProgressBar([ 'width' => CLIWCF::getTerminal()->getWidth(), - 'elements' => array( + 'elements' => [ ConsoleProgressBar::ELEMENT_PERCENT, ConsoleProgressBar::ELEMENT_BAR, ConsoleProgressBar::ELEMENT_TEXT - ), + ], 'textWidth' => min(floor(CLIWCF::getTerminal()->getWidth() / 2), 50) - ))); + ])); // InstallPackageAction::readParameters() $finished = false; @@ -370,13 +370,13 @@ class PackageCLICommand implements IArgumentedCLICommand { $processNo = PackageInstallationQueue::getNewProcessNo(); // create queue - $queue = PackageInstallationQueueEditor::create(array( + $queue = PackageInstallationQueueEditor::create([ 'processNo' => $processNo, 'userID' => CLIWCF::getUser()->userID, 'packageName' => $package->getName(), 'packageID' => $package->packageID, 'action' => 'uninstall' - )); + ]); // initialize uninstallation $installation = new PackageUninstallationDispatcher($queue); @@ -384,9 +384,9 @@ class PackageCLICommand implements IArgumentedCLICommand { $installation->nodeBuilder->purgeNodes(); $installation->nodeBuilder->buildNodes(); - CLIWCF::getTPL()->assign(array( + CLIWCF::getTPL()->assign([ 'queue' => $queue - )); + ]); $queueID = $installation->nodeBuilder->getQueueByNode($queue->processNo, $installation->nodeBuilder->getNextNode()); $step = 'uninstall'; @@ -395,15 +395,15 @@ class PackageCLICommand implements IArgumentedCLICommand { $progress = 0; // initialize progressbar - $progressbar = new ProgressBar(new ConsoleProgressBar(array( + $progressbar = new ProgressBar(new ConsoleProgressBar([ 'width' => CLIWCF::getTerminal()->getWidth(), - 'elements' => array( + 'elements' => [ ConsoleProgressBar::ELEMENT_PERCENT, ConsoleProgressBar::ELEMENT_BAR, ConsoleProgressBar::ELEMENT_TEXT - ), + ], 'textWidth' => min(floor(CLIWCF::getTerminal()->getWidth() / 2), 50) - ))); + ])); // InstallPackageAction::readParameters() $finished = false; @@ -449,7 +449,7 @@ class PackageCLICommand implements IArgumentedCLICommand { * @param string $name * @param array $parameters */ - public function error($name, array $parameters = array()) { + public function error($name, array $parameters = []) { Log::error('package.'.$name.':'.JSON::encode($parameters)); if ($parameters) { diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationFormManager.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationFormManager.class.php index 29eab62915..5bbd07ec68 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationFormManager.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationFormManager.class.php @@ -104,7 +104,7 @@ abstract class PackageInstallationFormManager { $statement->execute(array( base64_encode(serialize($document)), $queue->queueID, - $document->formName + $document->formName // TODO: FormDocument::$formName does not exist, FormDocument::getName()? )); } -- 2.20.1