From: Matthias Schmidt Date: Thu, 8 Feb 2018 18:18:00 +0000 (+0100) Subject: Add missing parameter type declarations in form builder API X-Git-Tag: 5.2.0_Alpha_1~827 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9ed17434ff3c26e5dd513203ce5ffe7a2392a53f;p=GitHub%2FWoltLab%2FWCF.git Add missing parameter type declarations in form builder API See #2509 --- diff --git a/wcfsetup/install/files/lib/system/form/builder/IFormElement.class.php b/wcfsetup/install/files/lib/system/form/builder/IFormElement.class.php index 88004284bb..a490a02a9c 100644 --- a/wcfsetup/install/files/lib/system/form/builder/IFormElement.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/IFormElement.class.php @@ -22,7 +22,7 @@ interface IFormElement extends IFormNode { * * @throws \InvalidArgumentException if the given description is invalid */ - public function description($languageItem = null, array $variables = []): IFormElement; + public function description(string $languageItem = null, array $variables = []): IFormElement; /** * Returns the description of this element or `null` if no description has been set. @@ -49,5 +49,5 @@ interface IFormElement extends IFormNode { * * @throws \InvalidArgumentException if the given label is invalid */ - public function label($languageItem = null, array $variables = []): IFormElement; + public function label(string $languageItem = null, array $variables = []): IFormElement; } diff --git a/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php index 2eb9fac5ae..ad13dd539d 100644 --- a/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php @@ -46,7 +46,7 @@ interface IFormNode { * * @throws \InvalidArgumentException if an invalid name or value is given (some attribute names are invalid as there are specific methods for setting that attribute) */ - public function attribute(string $name, $value = null): IFormNode; + public function attribute(string $name, string $value = null): IFormNode; /** * Sets if this node is available and returns this node. diff --git a/wcfsetup/install/files/lib/system/form/builder/TFormElement.class.php b/wcfsetup/install/files/lib/system/form/builder/TFormElement.class.php index 9fff72929b..ec0995fc17 100644 --- a/wcfsetup/install/files/lib/system/form/builder/TFormElement.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/TFormElement.class.php @@ -37,7 +37,7 @@ trait TFormElement { * * @throws \InvalidArgumentException if the given description is no string or otherwise is invalid */ - public function description($languageItem = null, array $variables = []): IFormElement { + public function description(string $languageItem = null, array $variables = []): IFormElement { if ($languageItem === null) { if (!empty($variables)) { throw new \InvalidArgumentException("Cannot use variables when unsetting description of element '{$this->getId()}'"); @@ -85,7 +85,7 @@ trait TFormElement { * * @throws \InvalidArgumentException if the given label is no string or otherwise is invalid */ - public function label($languageItem = null, array $variables = []): IFormElement { + public function label(string $languageItem = null, array $variables = []): IFormElement { if ($languageItem === null) { if (!empty($variables)) { throw new \InvalidArgumentException("Cannot use variables when unsetting label of element '{$this->getId()}'"); diff --git a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php index f742328dfc..3ed2b07c7b 100644 --- a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php @@ -102,7 +102,7 @@ trait TFormNode { * * @throws \InvalidArgumentException if an invalid name or value is given (some attribute names are invalid as there are specific methods for setting that attribute) */ - public function attribute(string $name, $value = null): IFormNode { + public function attribute(string $name, string $value = null): IFormNode { static::validateAttribute($name); if ($value !== null && !is_bool($value) && !is_numeric($value) && !is_string($value)) { diff --git a/wcfsetup/install/files/lib/system/form/builder/field/IMaximumFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/IMaximumFormField.class.php index d7fd61795b..1dfb9668a5 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/IMaximumFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/IMaximumFormField.class.php @@ -28,5 +28,5 @@ interface IMaximumFormField { * * @throws \InvalidArgumentException if the given maximum is no integer or otherwise invalid */ - public function maximum($maximum = null): IMaximumFormField; + public function maximum(int $maximum = null): IMaximumFormField; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/IMaximumLengthFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/IMaximumLengthFormField.class.php index 808c637b07..7d2d797597 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/IMaximumLengthFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/IMaximumLengthFormField.class.php @@ -28,5 +28,5 @@ interface IMaximumLengthFormField { * * @throws \InvalidArgumentException if the given maximum length is no integer or otherwise invalid */ - public function maximumLength($maximumLength = null): IMaximumLengthFormField; + public function maximumLength(int $maximumLength = null): IMaximumLengthFormField; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/IMinimumFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/IMinimumFormField.class.php index a06f4995af..993d1593a7 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/IMinimumFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/IMinimumFormField.class.php @@ -28,5 +28,5 @@ interface IMinimumFormField { * * @throws \InvalidArgumentException if the given minimum is no integer or otherwise invalid */ - public function minimum($minimum = null): IMinimumFormField; + public function minimum(int $minimum = null): IMinimumFormField; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/IMinimumLengthFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/IMinimumLengthFormField.class.php index 9caec1e543..de0e25a06c 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/IMinimumLengthFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/IMinimumLengthFormField.class.php @@ -28,5 +28,5 @@ interface IMinimumLengthFormField { * * @throws \InvalidArgumentException if the given minimum length is no integer or otherwise invalid */ - public function minimumLength($minimumLength = null): IMinimumLengthFormField; + public function minimumLength(int $minimumLength = null): IMinimumLengthFormField; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/IPlaceholderFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/IPlaceholderFormField.class.php index efaa657eec..4d315fd3b1 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/IPlaceholderFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/IPlaceholderFormField.class.php @@ -30,5 +30,5 @@ interface IPlaceholderFormField { * * @throws \InvalidArgumentException if the given value is invalid */ - public function placeholder($languageItem = null, array $variables = []): IPlaceholderFormField; + public function placeholder(string $languageItem = null, array $variables = []): IPlaceholderFormField; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/ISuffixedFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/ISuffixedFormField.class.php index 0fad21c142..5d34e9798b 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/ISuffixedFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/ISuffixedFormField.class.php @@ -28,5 +28,5 @@ interface ISuffixedFormField { * * @throws \InvalidArgumentException if the given language item is invalid */ - public function suffix($languageItem = null, array $variables = []): ISuffixedFormField; + public function suffix(string $languageItem = null, array $variables = []): ISuffixedFormField; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TMaximumFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TMaximumFormField.class.php index 3a80080921..6ff2cb0e75 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TMaximumFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TMaximumFormField.class.php @@ -36,7 +36,7 @@ trait TMaximumFormField { * * @throws \InvalidArgumentException if the given maximum is no integer or otherwise invalid */ - public function maximum($maximum = null): IMaximumFormField { + public function maximum(int $maximum = null): IMaximumFormField { if ($maximum !== null) { if (!is_int($maximum)) { throw new \InvalidArgumentException("Given maximum is no int, '" . gettype($maximum) . "' given."); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TMaximumLengthFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TMaximumLengthFormField.class.php index 94b955701e..227f00adfb 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TMaximumLengthFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TMaximumLengthFormField.class.php @@ -36,7 +36,7 @@ trait TMaximumLengthFormField { * * @throws \InvalidArgumentException if the given maximum length is no integer or otherwise invalid */ - public function maximumLength($maximumLength = null): IMaximumLengthFormField { + public function maximumLength(int $maximumLength = null): IMaximumLengthFormField { if ($maximumLength !== null) { if (!is_int($maximumLength)) { throw new \InvalidArgumentException("Given maximum length is no int, '" . gettype($maximumLength) . "' given."); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TMinimumFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TMinimumFormField.class.php index 244e034690..0fff47dbdb 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TMinimumFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TMinimumFormField.class.php @@ -36,7 +36,7 @@ trait TMinimumFormField { * * @throws \InvalidArgumentException if the given minimum is no integer or otherwise invalid */ - public function minimum($minimum = null): IMinimumFormField { + public function minimum(int $minimum = null): IMinimumFormField { if ($minimum !== null) { if (!is_int($minimum)) { throw new \InvalidArgumentException("Given minimum is no int, '" . gettype($minimum) . "' given."); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TMinimumLengthFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TMinimumLengthFormField.class.php index 84118a7984..48565c5890 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TMinimumLengthFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TMinimumLengthFormField.class.php @@ -36,7 +36,7 @@ trait TMinimumLengthFormField { * * @throws \InvalidArgumentException if the given minimum length is no integer or otherwise invalid */ - public function minimumLength($minimumLength = null): IMinimumLengthFormField { + public function minimumLength(int $minimumLength = null): IMinimumLengthFormField { if ($minimumLength !== null) { if (!is_int($minimumLength)) { throw new \InvalidArgumentException("Given minimum length is no int, '" . gettype($minimumLength) . "' given."); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TPlaceholderFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TPlaceholderFormField.class.php index c42f626656..805e1b9a11 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TPlaceholderFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TPlaceholderFormField.class.php @@ -39,7 +39,7 @@ trait TPlaceholderFormField { * * @throws \InvalidArgumentException if the given value is no string or otherwise invalid */ - public function placeholder($languageItem = null, array $variables = []): IPlaceholderFormField { + public function placeholder(string $languageItem = null, array $variables = []): IPlaceholderFormField { if ($languageItem === null) { if (!empty($variables)) { throw new \InvalidArgumentException("Cannot use variables when unsetting placeholder of field '{$this->getId()}'"); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TSuffixedFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TSuffixedFormField.class.php index dfb6fb32aa..09b518a25a 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TSuffixedFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TSuffixedFormField.class.php @@ -37,7 +37,7 @@ trait TSuffixedFormField { * * @throws \InvalidArgumentException if the given language item is no string or otherwise invalid */ - public function suffix($languageItem = null, array $variables = []): ISuffixedFormField { + public function suffix(string $languageItem = null, array $variables = []): ISuffixedFormField { if ($languageItem === null) { if (!empty($variables)) { throw new \InvalidArgumentException("Cannot use variables when unsetting suffix of field '{$this->getId()}'"); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php index 3f58212925..0e0d2a3394 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TextFormField.class.php @@ -59,7 +59,7 @@ class TextFormField extends AbstractFormField implements II18nFormField, IMaximu * @param string $text validated text * @param null|int $languageID language id of validated text or `null` for monolingual text */ - protected function validateText(string $text, $languageID = null) { + protected function validateText(string $text, int $languageID = null) { if ($this->getMinimumLength() !== null && mb_strlen($text) < $this->getMinimumLength()) { $this->addValidationError(new FormFieldValidationError('minimumLength', 'wcf.global.form.text.error.minimumLength', [ 'languageID' => $languageID, diff --git a/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidationError.class.php b/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidationError.class.php index 91f5623619..0fbf96b7ef 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidationError.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/validation/FormFieldValidationError.class.php @@ -33,7 +33,7 @@ class FormFieldValidationError implements IFormFieldValidationError { /** * @inheritDoc */ - public function __construct(string $type, $languageItem = null, array $information = []) { + public function __construct(string $type, string $languageItem = null, array $information = []) { if ($languageItem === null) { $languageItem = 'wcf.global.form.error.' . $type; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/validation/IFormFieldValidationError.class.php b/wcfsetup/install/files/lib/system/form/builder/field/validation/IFormFieldValidationError.class.php index bf055ca0ca..43cdebc11d 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/validation/IFormFieldValidationError.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/validation/IFormFieldValidationError.class.php @@ -22,7 +22,7 @@ interface IFormFieldValidationError { * * @throws \InvalidArgumentException if the given error type is invalid */ - public function __construct(string $type, $languageItem = null, array $information = []); + public function __construct(string $type, string $languageItem = null, array $information = []); /** * Returns the HTML element representing the error.