From: Matthias Schmidt Date: Fri, 6 May 2016 13:37:56 +0000 (+0200) Subject: Throw InvalidArgumentException for invalid condition object lists X-Git-Tag: 3.0.0_Beta_1~1757 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f2a4a4294a2a6794aba2a6df6530a4a80bcadb03;p=GitHub%2FWoltLab%2FWCF.git Throw InvalidArgumentException for invalid condition object lists --- diff --git a/wcfsetup/install/files/lib/system/condition/AbstractCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractCondition.class.php index 1621127dae..c41429aae3 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractCondition.class.php @@ -6,7 +6,7 @@ use wcf\data\object\type\AbstractObjectTypeProcessor; * Abstract implementation of a condition. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -14,14 +14,14 @@ use wcf\data\object\type\AbstractObjectTypeProcessor; */ abstract class AbstractCondition extends AbstractObjectTypeProcessor implements ICondition { /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { // does nothing } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { // does nothing diff --git a/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php index a22aeae796..3d8c5ed97a 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractIntegerCondition.class.php @@ -8,7 +8,7 @@ use wcf\system\WCF; * Abstract implementation of a condition for an integer value. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -52,10 +52,10 @@ abstract class AbstractIntegerCondition extends AbstractSingleFieldCondition { protected $propertyName = ''; /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { - $data = array(); + $data = []; if ($this->lessThan !== null) { $data['lessThan'] = $this->lessThan; @@ -72,34 +72,34 @@ abstract class AbstractIntegerCondition extends AbstractSingleFieldCondition { } /** - * @see \wcf\system\condition\AbstractMultipleFieldsCondition::getData() + * @inheritDoc */ protected function getErrorMessageElement() { if ($this->errorMessage) { $errorMessage = ''; switch ($this->errorMessage) { case 'wcf.condition.greaterThan.error.maxValue': - $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array( + $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [ 'maxValue' => $this->maxValue - 1 - )); + ]); break; case 'wcf.condition.lessThan.error.maxValue': - $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array( + $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [ 'maxValue' => $this->maxValue - )); + ]); break; case 'wcf.condition.greaterThan.error.minValue': - $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array( + $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [ 'minValue' => $this->minValue - )); + ]); break; case 'wcf.condition.lessThan.error.minValue': - $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, array( + $errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, [ 'minValue' => $this->minValue + 1 - )); + ]); break; default: @@ -114,7 +114,7 @@ abstract class AbstractIntegerCondition extends AbstractSingleFieldCondition { } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement() + * @inheritDoc */ public function getFieldElement() { $greaterThanPlaceHolder = WCF::getLanguage()->get('wcf.condition.greaterThan'); @@ -190,7 +190,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['lessThan_'.$this->getIdentifier()]) && strlen($_POST['lessThan_'.$this->getIdentifier()])) $this->lessThan = intval($_POST['lessThan_'.$this->getIdentifier()]); @@ -198,7 +198,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->lessThan = null; @@ -206,7 +206,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { $this->lessThan = $condition->lessThan; @@ -214,7 +214,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { if ($this->lessThan !== null) { diff --git a/wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php index 9566019205..fb57986b21 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php @@ -17,7 +17,7 @@ use wcf\util\ArrayUtil; abstract class AbstractMultiSelectCondition extends AbstractSelectCondition { /** * selected values - * @var mixed[] + * @var array */ protected $fieldValue = []; diff --git a/wcfsetup/install/files/lib/system/condition/AbstractMultipleFieldsCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractMultipleFieldsCondition.class.php index d06885f921..f39be359cb 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractMultipleFieldsCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractMultipleFieldsCondition.class.php @@ -6,7 +6,7 @@ use wcf\system\WCF; * Abstract implementation of a condition for multiple fields. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -15,21 +15,21 @@ use wcf\system\WCF; abstract class AbstractMultipleFieldsCondition extends AbstractCondition { /** * language items of the input element descriptions - * @var string + * @var string[] */ - protected $descriptions = array(); + protected $descriptions = []; /** * error messages if the validation failed - * @var string + * @var string[] */ - protected $errorMessages = array(); + protected $errorMessages = []; /** * language items of the input element labels - * @var string + * @var string[] */ - protected $labels = array(); + protected $labels = []; /** * Returns the description element for the HTML output. diff --git a/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php index 33c73b1ec0..f0c165b01e 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php @@ -2,13 +2,14 @@ namespace wcf\system\condition; use wcf\data\DatabaseObject; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; /** * Abstract condition implementation for check a text-typed property of a database * object. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -36,11 +37,13 @@ abstract class AbstractObjectTextPropertyCondition extends AbstractTextCondition protected $propertyName = ''; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { $className = $this->getListClassName(); - if (!($objectList instanceof $className)) return; + if (!($objectList instanceof $className)) { + throw new InvalidArgumentException("Object list is no instance of '{$className}', instance of '".get_class($objectList)."' given."); + } if ($this->supportsMultipleValues) { $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' IN (?)', [$conditionData[$this->fieldName]]); @@ -51,7 +54,7 @@ abstract class AbstractObjectTextPropertyCondition extends AbstractTextCondition } /** - * @see \wcf\system\condition\IObjectCondition::checkObject() + * @inheritDoc */ public function checkObject(DatabaseObject $object, array $conditionData) { $className = $this->getClassName(); @@ -70,7 +73,7 @@ abstract class AbstractObjectTextPropertyCondition extends AbstractTextCondition } /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { $value = parent::getData(); diff --git a/wcfsetup/install/files/lib/system/condition/AbstractSingleFieldCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractSingleFieldCondition.class.php index ba8ded0b49..6653204a53 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractSingleFieldCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractSingleFieldCondition.class.php @@ -78,7 +78,7 @@ abstract class AbstractSingleFieldCondition extends AbstractCondition implements abstract protected function getFieldElement(); /** - * @see \wcf\system\condition\ICondition::getHTML() + * @inheritDoc */ public function getHTML() { return << * @package com.woltlab.wcf * @subpackage system.condition @@ -27,41 +27,39 @@ abstract class AbstractTextCondition extends AbstractSingleFieldCondition { protected $fieldValue = ''; /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { if (mb_strlen($this->fieldValue)) { - return [ - $this->fieldName => $this->fieldValue - ]; + return [$this->fieldName => $this->fieldValue]; } return null; } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement() + * @inheritDoc */ protected function getFieldElement() { return ''; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST[$this->fieldName])) $this->fieldValue = StringUtil::trim($_POST[$this->fieldName]); } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->fieldValue = ''; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { $this->fieldValue = $condition->conditionData[$this->fieldName]; diff --git a/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php index 34208c7ac4..4fe0c4895f 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php @@ -3,6 +3,7 @@ namespace wcf\system\condition; use wcf\data\condition\Condition; use wcf\data\DatabaseObject; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\exception\UserInputException; use wcf\system\WCF; @@ -44,11 +45,13 @@ abstract class AbstractTimestampCondition extends AbstractSingleFieldCondition i protected $startTime = ''; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { $className = $this->getListClassName(); - if (!($objectList instanceof $className)) return; + if (!($objectList instanceof $className)) { + throw new InvalidArgumentException("Object list is no instance of '{$className}', instance of '".get_class($objectList)."' given."); + } $objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias().'.'.$this->getPropertyName().' <> ?', [0]); if (isset($conditionData['endTime'])) { @@ -60,7 +63,7 @@ abstract class AbstractTimestampCondition extends AbstractSingleFieldCondition i } /** - * @see \wcf\system\condition\IObjectCondition::checkObject() + * @inheritDoc */ public function checkObject(DatabaseObject $object, array $conditionData) { $className = $this->getClassName(); @@ -86,10 +89,10 @@ abstract class AbstractTimestampCondition extends AbstractSingleFieldCondition i } /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { - $data = array(); + $data = []; if (strlen($this->startTime)) { $data['startTime'] = $this->startTime; @@ -106,7 +109,7 @@ abstract class AbstractTimestampCondition extends AbstractSingleFieldCondition i } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement() + * @inheritDoc */ protected function getFieldElement() { $start = WCF::getLanguage()->get('wcf.date.period.start'); @@ -119,7 +122,7 @@ HTML; } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getLabel() + * @inheritDoc */ protected function getLabel() { return WCF::getLanguage()->get($this->getLanguageItemPrefix().'.'.$this->getPropertyName()); @@ -151,7 +154,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST[$this->getPropertyName().'EndTime'])) $this->endTime = $_POST[$this->getPropertyName().'EndTime']; @@ -159,7 +162,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->endTime = ''; @@ -167,7 +170,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { if ($condition->endTime) { @@ -179,7 +182,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { $endTime = $startTime = null; diff --git a/wcfsetup/install/files/lib/system/condition/DaysOfWeekCondition.class.php b/wcfsetup/install/files/lib/system/condition/DaysOfWeekCondition.class.php index 699d967699..a3f4db9ca2 100644 --- a/wcfsetup/install/files/lib/system/condition/DaysOfWeekCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/DaysOfWeekCondition.class.php @@ -8,7 +8,7 @@ use wcf\util\DateUtil; * Condition implementation for the days of the week. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -16,25 +16,25 @@ use wcf\util\DateUtil; */ class DaysOfWeekCondition extends AbstractMultiSelectCondition implements IContentCondition { /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $description = 'wcf.global.multiSelect'; /** - * @see wcf\system\condition\AbstractSelectCondition::$fieldName + * @inheritDoc */ protected $fieldName = 'daysOfWeek'; /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.date.daysOfWeek'; /** - * @see \wcf\system\condition\AbstractSelectCondition::getOptions() + * @inheritDoc */ protected function getOptions() { - $options = array(); + $options = []; $daysOfWeek = DateUtil::getWeekDays(); foreach ($daysOfWeek as $index => $day) { @@ -45,7 +45,7 @@ class DaysOfWeekCondition extends AbstractMultiSelectCondition implements IConte } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { $date = DateUtil::getDateTimeByTimestamp(TIME_NOW); diff --git a/wcfsetup/install/files/lib/system/condition/IContentCondition.class.php b/wcfsetup/install/files/lib/system/condition/IContentCondition.class.php index 545741e5aa..6081ced998 100644 --- a/wcfsetup/install/files/lib/system/condition/IContentCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/IContentCondition.class.php @@ -6,7 +6,7 @@ use wcf\data\condition\Condition; * Every implementation for content conditions needs to implements this interface. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -19,7 +19,7 @@ interface IContentCondition extends ICondition { * All necessary data to check the condition needs to be globally available * like the active user object via WCF::getUser(). * - * @param \wcf\data\condition\Condition $condition + * @param Condition $condition * @return boolean */ public function showContent(Condition $condition); diff --git a/wcfsetup/install/files/lib/system/condition/IObjectCondition.class.php b/wcfsetup/install/files/lib/system/condition/IObjectCondition.class.php index 3077be426e..527110eb35 100644 --- a/wcfsetup/install/files/lib/system/condition/IObjectCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/IObjectCondition.class.php @@ -7,7 +7,7 @@ use wcf\data\DatabaseObject; * this interface. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -19,8 +19,8 @@ interface IObjectCondition extends ICondition { * Returns true if the given object fulfills the condition specified by * the given condition data returned by \wcf\system\condition\ICondition::getData(). * - * @param \wcf\data\DatabaseObject $object - * @param array $conditionData + * @param DatabaseObject $object + * @param array $conditionData * @return boolean */ public function checkObject(DatabaseObject $object, array $conditionData); diff --git a/wcfsetup/install/files/lib/system/condition/IObjectListCondition.class.php b/wcfsetup/install/files/lib/system/condition/IObjectListCondition.class.php index 79d44cd244..cd3029b9e9 100644 --- a/wcfsetup/install/files/lib/system/condition/IObjectListCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/IObjectListCondition.class.php @@ -19,8 +19,8 @@ interface IObjectListCondition extends ICondition { * Adds a condition to the given object list based on the given condition * data returned by \wcf\system\condition\ICondition::getData(). * - * @param \wcf\data\DatabaseObjectList $objectList - * @param array $conditionData + * @param DatabaseObjectList $objectList + * @param array $conditionData */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData); } diff --git a/wcfsetup/install/files/lib/system/condition/IUserCondition.class.php b/wcfsetup/install/files/lib/system/condition/IUserCondition.class.php index 5fc328c349..eb417cec69 100644 --- a/wcfsetup/install/files/lib/system/condition/IUserCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/IUserCondition.class.php @@ -8,7 +8,7 @@ use wcf\data\user\UserList; * Every implementation for user conditions needs to implements this interface. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -19,16 +19,16 @@ interface IUserCondition extends ICondition { * Adds the condition to the given user list to fetch the users which fulfill * the given condition. * - * @param \wcf\data\condition\Condition $condition - * @param \wcf\data\user\UserList $userList + * @param Condition $condition + * @param UserList $userList */ public function addUserCondition(Condition $condition, UserList $userList); /** * Returns true if the given user fulfills the given condition. * - * @param \wcf\data\condition\Condition $condition - * @param \wcf\data\user\User $user + * @param Condition $condition + * @param User $user * @return boolean */ public function checkUser(Condition $condition, User $user); diff --git a/wcfsetup/install/files/lib/system/condition/TObjectListUserCondition.class.php b/wcfsetup/install/files/lib/system/condition/TObjectListUserCondition.class.php index 7b7d3451c3..63e08889f0 100644 --- a/wcfsetup/install/files/lib/system/condition/TObjectListUserCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/TObjectListUserCondition.class.php @@ -8,7 +8,7 @@ use wcf\data\user\UserList; * IObjectListCondition::addObjectListCondition(). * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -17,7 +17,7 @@ use wcf\data\user\UserList; */ trait TObjectListUserCondition { /** - * @see \wcf\system\condition\IUserCondition::addUserCondition() + * @inheritDoc */ public function addUserCondition(Condition $condition, UserList $userList) { $this->addObjectListCondition($userList, $condition->conditionData); diff --git a/wcfsetup/install/files/lib/system/condition/TObjectUserCondition.class.php b/wcfsetup/install/files/lib/system/condition/TObjectUserCondition.class.php index f27419ea33..8f2afea58a 100644 --- a/wcfsetup/install/files/lib/system/condition/TObjectUserCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/TObjectUserCondition.class.php @@ -7,7 +7,7 @@ use wcf\data\user\User; * Redirects IUserCondition::checkUser() calls to the more general IObjectCondition::checkObject(). * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -16,7 +16,7 @@ use wcf\data\user\User; */ trait TObjectUserCondition { /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { $this->checkObject($user, $condition->conditionData); diff --git a/wcfsetup/install/files/lib/system/condition/TimeCondition.class.php b/wcfsetup/install/files/lib/system/condition/TimeCondition.class.php index ce988158d7..fc8c94a79c 100644 --- a/wcfsetup/install/files/lib/system/condition/TimeCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/TimeCondition.class.php @@ -10,7 +10,7 @@ use wcf\util\StringUtil; * Condition implementation for the current time. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -24,12 +24,12 @@ class TimeCondition extends AbstractMultipleFieldsCondition implements IContentC protected $endTime = '00:00'; /** - * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$label + * @inheritDoc */ - protected $labels = array( + protected $labels = [ 'time' => 'wcf.date.time', 'timezone' => 'wcf.date.timezone' - ); + ]; /** * start time @@ -44,10 +44,10 @@ class TimeCondition extends AbstractMultipleFieldsCondition implements IContentC protected $timezone = 0; /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { - $data = array(); + $data = []; if ($this->startTime) { $data['startTime'] = $this->startTime; @@ -68,7 +68,7 @@ class TimeCondition extends AbstractMultipleFieldsCondition implements IContentC } /** - * @see \wcf\system\condition\ICondition::getHTML() + * @inheritDoc */ public function getHTML() { $start = WCF::getLanguage()->get('wcf.date.period.start'); @@ -111,7 +111,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['endTime'])) $this->endTime = StringUtil::trim($_POST['endTime']); @@ -120,7 +120,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->endTime = '00:00'; @@ -129,7 +129,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { if ($condition->endTime) { @@ -144,7 +144,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { if ($this->startTime == '00:00' && $this->endTime == '00:00') { @@ -186,7 +186,7 @@ HTML; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { $timezone = WCF::getUser()->getTimeZone(); diff --git a/wcfsetup/install/files/lib/system/condition/UserAvatarCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserAvatarCondition.class.php index 57bcd4b090..023095dc18 100644 --- a/wcfsetup/install/files/lib/system/condition/UserAvatarCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserAvatarCondition.class.php @@ -4,13 +4,14 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\WCF; /** * Condition implementation for the avatar of a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -20,12 +21,12 @@ class UserAvatarCondition extends AbstractSelectCondition implements IContentCon use TObjectListUserCondition; /** - * @see wcf\system\condition\AbstractSelectCondition::$fieldName + * @inheritDoc */ protected $fieldName = 'userAvatar'; /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.user.condition.avatar'; @@ -48,15 +49,17 @@ class UserAvatarCondition extends AbstractSelectCondition implements IContentCon const GRAVATAR = 2; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } switch ($conditionData['userAvatar']) { case self::NO_AVATAR: $objectList->getConditionBuilder()->add('user_table.avatarID IS NULL'); - $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', array(0)); + $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', [0]); break; case self::AVATAR: @@ -64,13 +67,13 @@ class UserAvatarCondition extends AbstractSelectCondition implements IContentCon break; case self::GRAVATAR: - $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', array(1)); + $objectList->getConditionBuilder()->add('user_table.enableGravatar = ?', [1]); break; } } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { switch ($condition->userAvatar) { @@ -89,19 +92,19 @@ class UserAvatarCondition extends AbstractSelectCondition implements IContentCon } /** - * @see \wcf\system\condition\AbstractSelectCondition::getOptions() + * @inheritDoc */ protected function getOptions() { - return array( + return [ self::NO_SELECTION_VALUE => 'wcf.global.noSelection', self::NO_AVATAR => 'wcf.user.condition.avatar.noAvatar', self::AVATAR => 'wcf.user.condition.avatar.avatar', self::GRAVATAR => 'wcf.user.condition.avatar.gravatar' - ); + ]; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserBirthdayCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserBirthdayCondition.class.php index ae46b3630c..d60187b2c5 100644 --- a/wcfsetup/install/files/lib/system/condition/UserBirthdayCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserBirthdayCondition.class.php @@ -8,7 +8,7 @@ use wcf\system\WCF; * Condition implementation if it is the active user's birthday today. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -22,20 +22,18 @@ class UserBirthdayCondition extends AbstractCondition implements IContentConditi protected $birthdayToday = 0; /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { if ($this->birthdayToday) { - return array( - 'birthdayToday' => 1 - ); + return ['birthdayToday' => 1]; } return null; } /** - * @see \wcf\system\condition\ICondition::getHTML() + * @inheritDoc */ public function getHTML() { $label = WCF::getLanguage()->get('wcf.user.birthdayToday'); @@ -55,28 +53,28 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['birthdayToday'])) $this->birthdayToday = 1; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->birthdayToday = 0; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function setData(Condition $condition) { $this->birthdayToday = $condition->birthdayToday; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserEmailCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserEmailCondition.class.php index 0413e47699..5f2307b17f 100644 --- a/wcfsetup/install/files/lib/system/condition/UserEmailCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserEmailCondition.class.php @@ -4,13 +4,14 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\WCF; /** * Condition implementation for the email address of a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -20,33 +21,35 @@ class UserEmailCondition extends AbstractTextCondition implements IContentCondit use TObjectListUserCondition; /** - * @see \wcf\system\condition\AbstractTextCondition::$fieldName + * @inheritDoc */ protected $fieldName = 'email'; /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.user.email'; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } - $objectList->getConditionBuilder()->add('user_table.email LIKE ?', array('%'.addcslashes($conditionData['email'], '_%').'%')); + $objectList->getConditionBuilder()->add('user_table.email LIKE ?', ['%'.addcslashes($conditionData['email'], '_%').'%']); } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { return mb_strpos($user->email, $condition->email) !== false; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php index 08ce692aa1..9913a65f14 100644 --- a/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php @@ -5,6 +5,7 @@ use wcf\data\user\group\UserGroup; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\exception\UserInputException; use wcf\system\WCF; use wcf\util\ArrayUtil; @@ -14,7 +15,7 @@ use wcf\util\ArrayUtil; * of and the user groups a user may not be a member of. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -24,55 +25,57 @@ class UserGroupCondition extends AbstractMultipleFieldsCondition implements ICon use TObjectListUserCondition; /** - * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$descriptions + * @inheritDoc */ - protected $descriptions = array( + protected $descriptions = [ 'groupIDs' => 'wcf.user.condition.groupIDs.description', 'notGroupIDs' => 'wcf.user.condition.notGroupIDs.description' - ); + ]; /** * ids of the selected user groups the user has to be member of * @var integer[] */ - protected $groupIDs = array(); + protected $groupIDs = []; /** - * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$labels + * @inheritDoc */ - protected $labels = array( + protected $labels = [ 'groupIDs' => 'wcf.user.condition.groupIDs', 'notGroupIDs' => 'wcf.user.condition.notGroupIDs' - ); + ]; /** * ids of the selected user groups the user may not be member of * @var integer[] */ - protected $notGroupIDs = array(); + protected $notGroupIDs = []; /** * selectable user groups * @var UserGroup[] */ - protected $userGroups = null; + protected $userGroups; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } if (isset($conditionData['groupIDs'])) { - $objectList->getConditionBuilder()->add('user_table.userID IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?) GROUP BY userID HAVING COUNT(userID) = ?)', array($conditionData['groupIDs'], count($conditionData['groupIDs']))); + $objectList->getConditionBuilder()->add('user_table.userID IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?) GROUP BY userID HAVING COUNT(userID) = ?)', [$conditionData['groupIDs'], count($conditionData['groupIDs'])]); } if (isset($conditionData['notGroupIDs'])) { - $objectList->getConditionBuilder()->add('user_table.userID NOT IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?))', array($conditionData['notGroupIDs'])); + $objectList->getConditionBuilder()->add('user_table.userID NOT IN (SELECT userID FROM wcf'.WCF_N.'_user_to_group WHERE groupID IN (?))', [$conditionData['notGroupIDs']]); } } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { $groupIDs = $user->getGroupIDs(); @@ -88,10 +91,10 @@ class UserGroupCondition extends AbstractMultipleFieldsCondition implements ICon } /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { - $data = array(); + $data = []; if (!empty($this->groupIDs)) { $data['groupIDs'] = $this->groupIDs; @@ -108,7 +111,7 @@ class UserGroupCondition extends AbstractMultipleFieldsCondition implements ICon } /** - * @see \wcf\system\condition\ICondition::getHTML() + * @inheritDoc */ public function getHTML() { return <<userGroups == null) { - $invalidGroupTypes = array( + $invalidGroupTypes = [ UserGroup::EVERYONE, UserGroup::USERS - ); + ]; if (!$this->includeguests) { $invalidGroupTypes[] = UserGroup::GUESTS; } - $this->userGroups = UserGroup::getAccessibleGroups(array(), $invalidGroupTypes); + $this->userGroups = UserGroup::getAccessibleGroups([], $invalidGroupTypes); uasort($this->userGroups, function(UserGroup $groupA, UserGroup $groupB) { return strcmp($groupA->getName(), $groupB->getName()); @@ -174,7 +177,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['groupIDs'])) $this->groupIDs = ArrayUtil::toIntegerArray($_POST['groupIDs']); @@ -182,15 +185,15 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { - $this->groupIDs = array(); - $this->notGroupIDs = array(); + $this->groupIDs = []; + $this->notGroupIDs = []; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { if ($condition->groupIDs !== null) { @@ -211,7 +214,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { $userGroups = $this->getUserGroups(); @@ -238,7 +241,7 @@ HTML; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { return $this->checkUser($condition, WCF::getUser()); diff --git a/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php index 3f9e74aef0..005dfb43f7 100644 --- a/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserIntegerPropertyCondition.class.php @@ -4,13 +4,14 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\WCF; /** * Condition implementation for an integer property of a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -20,21 +21,23 @@ class UserIntegerPropertyCondition extends AbstractIntegerCondition implements I use TObjectListUserCondition; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } if (isset($conditionData['greaterThan'])) { - $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' > ?', array($conditionData['greaterThan'])); + $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' > ?', [$conditionData['greaterThan']]); } if (isset($conditionData['lessThan'])) { - $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' < ?', array($conditionData['lessThan'])); + $objectList->getConditionBuilder()->add('user_table.'.$this->getDecoratedObject()->propertyname.' < ?', [$conditionData['lessThan']]); } } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { if ($condition->greaterThan !== null && $user->{$this->getDecoratedObject()->propertyname} <= $condition->greaterThan) { @@ -48,21 +51,21 @@ class UserIntegerPropertyCondition extends AbstractIntegerCondition implements I } /** - * @see \wcf\system\condition\AbstractIntegerCondition::getIdentifier() + * @inheritDoc */ protected function getIdentifier() { return 'user_'.$this->getDecoratedObject()->propertyname; } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getLabel() + * @inheritDoc */ protected function getLabel() { return WCF::getLanguage()->get('wcf.user.condition.'.$this->getDecoratedObject()->propertyname); } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserLanguageCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserLanguageCondition.class.php index 07b402e61c..111685df26 100644 --- a/wcfsetup/install/files/lib/system/condition/UserLanguageCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserLanguageCondition.class.php @@ -4,6 +4,7 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\exception\UserInputException; use wcf\system\language\LanguageFactory; use wcf\system\WCF; @@ -23,7 +24,7 @@ class UserLanguageCondition extends AbstractSingleFieldCondition implements ICon use TObjectListUserCondition; /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.user.condition.languages'; @@ -31,19 +32,21 @@ class UserLanguageCondition extends AbstractSingleFieldCondition implements ICon * ids of the selected languages * @var integer[] */ - protected $languageIDs = array(); + protected $languageIDs = []; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } - $objectList->getConditionBuilder()->add('user_table.languageID IN (?)', array($conditionData['languageIDs'])); + $objectList->getConditionBuilder()->add('user_table.languageID IN (?)', [$conditionData['languageIDs']]); } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { if (!empty($condition->conditionData['languageIDs']) && !in_array($user->languageID, $condition->languageIDs)) { @@ -54,20 +57,20 @@ class UserLanguageCondition extends AbstractSingleFieldCondition implements ICon } /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { if (!empty($this->languageIDs)) { - return array( + return [ 'languageIDs' => $this->languageIDs - ); + ]; } return null; } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement() + * @inheritDoc */ protected function getFieldElement() { $returnValue = ""; @@ -79,21 +82,21 @@ class UserLanguageCondition extends AbstractSingleFieldCondition implements ICon } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['languageIDs']) && is_array($_POST['languageIDs'])) $this->languageIDs = ArrayUtil::toIntegerArray($_POST['languageIDs']); } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { - $this->languageIDs = array(); + $this->languageIDs = []; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { if (!empty($condition->conditionData['languageIDs'])) { @@ -102,7 +105,7 @@ class UserLanguageCondition extends AbstractSingleFieldCondition implements ICon } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { foreach ($this->languageIDs as $languageID) { @@ -115,7 +118,7 @@ class UserLanguageCondition extends AbstractSingleFieldCondition implements ICon } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (WCF::getUser()->userID) { diff --git a/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php index 08c25ee9f2..af3cc7be65 100644 --- a/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserMobileBrowserCondition.class.php @@ -9,7 +9,7 @@ use wcf\util\UserUtil; * Condition implementation if it is the active user uses a mobile browser. * * @author Joshua Ruesweg, Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -17,7 +17,7 @@ use wcf\util\UserUtil; */ class UserMobileBrowserCondition extends AbstractSingleFieldCondition implements IContentCondition { /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.user.condition.mobileBrowser'; @@ -34,22 +34,22 @@ class UserMobileBrowserCondition extends AbstractSingleFieldCondition implements protected $usesNoMobileBrowser = 0; /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { if ($this->usesMobileBrowser || $this->usesNoMobileBrowser) { - return array( + return [ // if notUseMobileBrowser is selected usesMobileBrowser is 0 // otherwise notUseMobileBrowser is 1 'usesMobileBrowser' => $this->usesMobileBrowser - ); + ]; } return null; } /** - * @see \wcf\system\condition\ICondition::getHTML() + * @inheritDoc */ public function getFieldElement() { $usesMobileBrowserLabel = WCF::getLanguage()->get('wcf.user.condition.mobileBrowser.usesMobileBrowser'); @@ -71,7 +71,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['usesMobileBrowser'])) $this->usesMobileBrowser = 1; @@ -79,7 +79,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->usesMobileBrowser = 0; @@ -87,7 +87,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { $this->usesMobileBrowser = $condition->usesMobileBrowser; @@ -95,7 +95,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { if ($this->usesMobileBrowser && $this->usesNoMobileBrowser) { @@ -106,7 +106,7 @@ HTML; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { return (($condition->usesMobileBrowser && UserUtil::usesMobileBrowser()) || (!$condition->usesMobileBrowser && !UserUtil::usesMobileBrowser())); diff --git a/wcfsetup/install/files/lib/system/condition/UserOptionsCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserOptionsCondition.class.php index 59ee212e91..2584444bc4 100644 --- a/wcfsetup/install/files/lib/system/condition/UserOptionsCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserOptionsCondition.class.php @@ -5,6 +5,7 @@ use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObject; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\option\user\UserOptionHandler; use wcf\system\WCF; @@ -12,7 +13,7 @@ use wcf\system\WCF; * Condition implementation for the options of a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -23,12 +24,12 @@ class UserOptionsCondition extends AbstractMultipleFieldsCondition implements IC /** * user option handler object - * @var \wcf\system\option\user\UserOptionHandler + * @var UserOptionHandler */ - protected $optionHandler = null; + protected $optionHandler; /** - * @see \wcf\data\DatabaseObjectDecorator::__construct() + * @inheritDoc */ public function __construct(DatabaseObject $object) { parent::__construct($object); @@ -39,10 +40,12 @@ class UserOptionsCondition extends AbstractMultipleFieldsCondition implements IC } /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } $optionValues = $conditionData['optionValues']; @@ -56,7 +59,7 @@ class UserOptionsCondition extends AbstractMultipleFieldsCondition implements IC } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { $optionValues = $condition->optionValues; @@ -77,12 +80,12 @@ class UserOptionsCondition extends AbstractMultipleFieldsCondition implements IC } /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { $optionValues = $this->optionHandler->getOptionValues(); - $data = array(); + $data = []; foreach ($this->optionHandler->getCategoryOptions('profile') as $option) { $option = $option['object']; @@ -95,46 +98,46 @@ class UserOptionsCondition extends AbstractMultipleFieldsCondition implements IC } if (!empty($data)) { - return array( + return [ 'optionValues' => $data - ); + ]; } return null; } /** - * @see \wcf\system\condition\ICondition::getHTML() + * @inheritDoc */ public function getHTML() { - return WCF::getTPL()->fetch('userOptionsCondition', 'wcf', array( + return WCF::getTPL()->fetch('userOptionsCondition', 'wcf', [ 'optionTree' => $this->optionHandler->getOptionTree('profile') - )); + ]); } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { $this->optionHandler->readUserInput($_POST); } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { - $this->optionHandler->setOptionValues(array()); + $this->optionHandler->setOptionValues([]); } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { $this->optionHandler->setOptionValues($condition->conditionData['optionValues']); } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php index 5cdd1d206b..13bbccb14b 100644 --- a/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php @@ -4,6 +4,7 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\exception\UserInputException; use wcf\system\WCF; @@ -11,7 +12,7 @@ use wcf\system\WCF; * Condition implementation for the registration date of a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -21,7 +22,7 @@ class UserRegistrationDateCondition extends AbstractSingleFieldCondition impleme use TObjectListUserCondition; /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.user.condition.registrationDate'; @@ -38,21 +39,23 @@ class UserRegistrationDateCondition extends AbstractSingleFieldCondition impleme protected $registrationDateStart = ''; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } if (isset($conditionData['registrationDateEnd'])) { - $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', array(strtotime($conditionData['registrationDateEnd']) + 86400)); + $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', [strtotime($conditionData['registrationDateEnd']) + 86400]); } if (isset($conditionData['registrationDateStart'])) { - $objectList->getConditionBuilder()->add('user_table.registrationDate >= ?', array(strtotime($conditionData['registrationDateStart']))); + $objectList->getConditionBuilder()->add('user_table.registrationDate >= ?', [strtotime($conditionData['registrationDateStart'])]); } } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { if ($condition->registrationDateStart !== null && $user->registrationDate < strtotime($condition->registrationDateStart)) { @@ -66,10 +69,10 @@ class UserRegistrationDateCondition extends AbstractSingleFieldCondition impleme } /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { - $data = array(); + $data = []; if (strlen($this->registrationDateStart)) { $data['registrationDateStart'] = $this->registrationDateStart; @@ -86,7 +89,7 @@ class UserRegistrationDateCondition extends AbstractSingleFieldCondition impleme } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement() + * @inheritDoc */ protected function getFieldElement() { $start = WCF::getLanguage()->get('wcf.date.period.start'); @@ -99,7 +102,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['registrationDateEnd'])) $this->registrationDateEnd = $_POST['registrationDateEnd']; @@ -107,7 +110,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->registrationDateEnd = ''; @@ -115,7 +118,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { if ($condition->registrationDateEnd) { @@ -127,7 +130,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { $registrationDateEnd = $registrationDateStart = null; @@ -156,7 +159,7 @@ HTML; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserRegistrationDateIntervalCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserRegistrationDateIntervalCondition.class.php index 964bc6650b..99d6a17bef 100644 --- a/wcfsetup/install/files/lib/system/condition/UserRegistrationDateIntervalCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserRegistrationDateIntervalCondition.class.php @@ -4,6 +4,7 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\WCF; /** @@ -11,7 +12,7 @@ use wcf\system\WCF; * a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -21,31 +22,33 @@ class UserRegistrationDateIntervalCondition extends AbstractIntegerCondition imp use TObjectListUserCondition; /** - * @see \wcf\system\condition\AbstractMultipleFieldsCondition::$languageItemPrefix + * @inheritDoc */ protected $label = 'wcf.user.condition.registrationDateInterval'; /** - * @see \wcf\system\condition\AbstractIntegerCondition::$minValue + * @inheritDoc */ protected $minValue = 0; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } if ($conditionData['greaterThan'] !== null) { - $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', array(TIME_NOW - $conditionData['greaterThan'] * 86400)); + $objectList->getConditionBuilder()->add('user_table.registrationDate < ?', [TIME_NOW - $conditionData['greaterThan'] * 86400]); } if ($conditionData['lessThan'] !== null) { - $objectList->getConditionBuilder()->add('user_table.registrationDate > ?', array(TIME_NOW - $conditionData['lessThan'] * 86400)); + $objectList->getConditionBuilder()->add('user_table.registrationDate > ?', [TIME_NOW - $conditionData['lessThan'] * 86400]); } } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { if ($condition->greaterThan !== null && $user->registrationDate >= TIME_NOW - $condition->greaterThan * 86400) { @@ -59,14 +62,14 @@ class UserRegistrationDateIntervalCondition extends AbstractIntegerCondition imp } /** - * @see \wcf\system\condition\AbstractIntegerCondition::getIdentifier() + * @inheritDoc */ protected function getIdentifier() { return 'user_registrationDateInterval'; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php index 32ab28abb7..fa59fd5222 100644 --- a/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserStateCondition.class.php @@ -4,6 +4,7 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\exception\UserInputException; use wcf\system\WCF; @@ -11,7 +12,7 @@ use wcf\system\WCF; * Condition implementation for the state (banned, enabled) of a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -21,7 +22,7 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten use TObjectListUserCondition; /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.user.condition.state'; @@ -50,27 +51,29 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten protected $userIsNotBanned = 0; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } if (isset($conditionData['userIsBanned'])) { - $objectList->getConditionBuilder()->add('user_table.banned = ?', array($conditionData['userIsBanned'])); + $objectList->getConditionBuilder()->add('user_table.banned = ?', [$conditionData['userIsBanned']]); } if ($conditionData['userIsEnabled']) { if ($conditionData['userIsEnabled']) { - $objectList->getConditionBuilder()->add('user_table.activationCode = ?', array(0)); + $objectList->getConditionBuilder()->add('user_table.activationCode = ?', [0]); } else { - $objectList->getConditionBuilder()->add('user_table.activationCode <> ?', array(0)); + $objectList->getConditionBuilder()->add('user_table.activationCode <> ?', [0]); } } } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { if ($condition->userIsBanned !== null && $user->banned != $condition->userIsBanned) { @@ -90,10 +93,10 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten } /** - * @see \wcf\system\condition\ICondition::getData() + * @inheritDoc */ public function getData() { - $data = array(); + $data = []; if ($this->userIsBanned) { $data['userIsBanned'] = 1; @@ -130,7 +133,7 @@ class UserStateCondition extends AbstractSingleFieldCondition implements IConten } /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement() + * @inheritDoc */ protected function getFieldElement() { $userIsNotBanned = WCF::getLanguage()->get('wcf.user.condition.state.isNotBanned'); @@ -147,7 +150,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::readFormParameters() + * @inheritDoc */ public function readFormParameters() { if (isset($_POST['userIsBanned'])) $this->userIsBanned = 1; @@ -157,7 +160,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::reset() + * @inheritDoc */ public function reset() { $this->userIsBanned = 0; @@ -167,7 +170,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::setData() + * @inheritDoc */ public function setData(Condition $condition) { if ($condition->userIsBanned !== null) { @@ -181,7 +184,7 @@ HTML; } /** - * @see \wcf\system\condition\ICondition::validate() + * @inheritDoc */ public function validate() { if ($this->userIsBanned && $this->userIsNotBanned) { @@ -198,7 +201,7 @@ HTML; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserTimestampPropertyCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserTimestampPropertyCondition.class.php index f2ed3cf228..16788d03e2 100644 --- a/wcfsetup/install/files/lib/system/condition/UserTimestampPropertyCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserTimestampPropertyCondition.class.php @@ -21,26 +21,26 @@ class UserTimestampPropertyCondition extends AbstractTimestampCondition implemen use TObjectUserCondition; /** - * @see \wcf\system\condition\AbstractTimestampCondition::$className + * @inheritDoc */ protected $className = User::class; /** - * @see \wcf\system\condition\AbstractTimestampCondition::getLanguageItemPrefix() + * @inheritDoc */ protected function getLanguageItemPrefix() { return 'wcf.user.condition'; } /** - * @see \wcf\system\condition\AbstractTimestampCondition::getPropertyName() + * @inheritDoc */ protected function getPropertyName() { return $this->getDecoratedObject()->propertyname; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false; diff --git a/wcfsetup/install/files/lib/system/condition/UserUsernameCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserUsernameCondition.class.php index 9205e4b9d0..d17db653c0 100644 --- a/wcfsetup/install/files/lib/system/condition/UserUsernameCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserUsernameCondition.class.php @@ -4,13 +4,14 @@ use wcf\data\condition\Condition; use wcf\data\user\User; use wcf\data\user\UserList; use wcf\data\DatabaseObjectList; +use wcf\system\exception\InvalidArgumentException; use wcf\system\WCF; /** * Condition implementation for the username of a user. * * @author Matthias Schmidt - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.condition @@ -20,33 +21,35 @@ class UserUsernameCondition extends AbstractTextCondition implements IContentCon use TObjectListUserCondition; /** - * @see \wcf\system\condition\AbstractTextCondition::$fieldName + * @inheritDoc */ protected $fieldName = 'username'; /** - * @see \wcf\system\condition\AbstractSingleFieldCondition::$label + * @inheritDoc */ protected $label = 'wcf.user.username'; /** - * @see \wcf\system\condition\IObjectListCondition::addObjectListCondition() + * @inheritDoc */ public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) { - if (!($objectList instanceof UserList)) return; + if (!($objectList instanceof UserList)) { + throw new InvalidArgumentException("Object list is no instance of '".UserList::class."', instance of '".get_class($objectList)."' given."); + } - $objectList->getConditionBuilder()->add('user_table.username LIKE ?', array('%'.addcslashes($conditionData['username'], '_%').'%')); + $objectList->getConditionBuilder()->add('user_table.username LIKE ?', ['%'.addcslashes($conditionData['username'], '_%').'%']); } /** - * @see \wcf\system\condition\IUserCondition::checkUser() + * @inheritDoc */ public function checkUser(Condition $condition, User $user) { return mb_strpos($user->username, $condition->username) !== false; } /** - * @see \wcf\system\condition\IContentCondition::showContent() + * @inheritDoc */ public function showContent(Condition $condition) { if (!WCF::getUser()->userID) return false;