From e419060e8a61a08721fa26d021820c072cd385c9 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Thu, 22 Oct 2020 15:28:26 +0200 Subject: [PATCH] Add type hinting to methods parameters --- sources/Form/Field/BlobField.php | 6 +- sources/Form/Field/CaseLogField.php | 8 +-- sources/Form/Field/CheckboxField.php | 2 +- sources/Form/Field/DateTimeField.php | 16 ++--- sources/Form/Field/DurationField.php | 2 +- sources/Form/Field/EmailField.php | 5 ++ sources/Form/Field/Field.php | 67 +++++++++++++------ sources/Form/Field/FileUploadField.php | 12 ++-- sources/Form/Field/HiddenField.php | 1 + sources/Form/Field/ImageField.php | 3 + sources/Form/Field/LinkedSetField.php | 22 +++--- sources/Form/Field/MultipleChoicesField.php | 12 ++-- sources/Form/Field/MultipleSelectField.php | 1 + sources/Form/Field/PhoneField.php | 5 ++ sources/Form/Field/RadioField.php | 1 + sources/Form/Field/SelectField.php | 9 +-- sources/Form/Field/SelectObjectField.php | 16 ++--- sources/Form/Field/SubFormField.php | 15 ++--- sources/Form/Field/TextAreaField.php | 18 ++++- sources/Form/Field/UrlField.php | 16 +++-- .../FieldRenderer/BsSetFieldRenderer.php | 2 +- 21 files changed, 147 insertions(+), 92 deletions(-) diff --git a/sources/Form/Field/BlobField.php b/sources/Form/Field/BlobField.php index fe276922a..1eeaa5269 100644 --- a/sources/Form/Field/BlobField.php +++ b/sources/Form/Field/BlobField.php @@ -29,7 +29,9 @@ use Dict; */ class BlobField extends Field { + /** @var string */ protected $sDownloadUrl; + /** @var string */ protected $sDisplayUrl; public function GetDownloadUrl() @@ -42,13 +44,13 @@ class BlobField extends Field return $this->sDisplayUrl; } - public function SetDownloadUrl($sDownloadUrl) + public function SetDownloadUrl(string $sDownloadUrl) { $this->sDownloadUrl = $sDownloadUrl; return $this; } - public function SetDisplayUrl($sDisplayUrl) + public function SetDisplayUrl(string $sDisplayUrl) { $this->sDisplayUrl = $sDisplayUrl; return $this; diff --git a/sources/Form/Field/CaseLogField.php b/sources/Form/Field/CaseLogField.php index fc0cae63e..cb90db826 100644 --- a/sources/Form/Field/CaseLogField.php +++ b/sources/Form/Field/CaseLogField.php @@ -27,13 +27,13 @@ namespace Combodo\iTop\Form\Field; */ class CaseLogField extends TextAreaField { + /** @var array */ protected $aEntries; /** - * @param bool $bMustChange - * @return $this + * @inheritDoc */ - public function SetMustChange($bMustChange) + public function SetMustChange(bool $bMustChange) { $this->SetMandatory($bMustChange); return $this; @@ -53,7 +53,7 @@ class CaseLogField extends TextAreaField * @param array $aEntries * @return \Combodo\iTop\Form\Field\TextAreaField */ - public function SetEntries($aEntries) + public function SetEntries(array $aEntries) { $this->aEntries = $aEntries; return $this; diff --git a/sources/Form/Field/CheckboxField.php b/sources/Form/Field/CheckboxField.php index 70922be8d..fe86512f3 100644 --- a/sources/Form/Field/CheckboxField.php +++ b/sources/Form/Field/CheckboxField.php @@ -26,6 +26,6 @@ namespace Combodo\iTop\Form\Field; */ class CheckboxField extends MultipleChoicesField { + /** @inheritDoc */ const DEFAULT_MULTIPLE_VALUES_ENABLED = true; - } diff --git a/sources/Form/Field/DateTimeField.php b/sources/Form/Field/DateTimeField.php index c82a9e549..206859543 100644 --- a/sources/Form/Field/DateTimeField.php +++ b/sources/Form/Field/DateTimeField.php @@ -26,17 +26,17 @@ use Closure; */ class DateTimeField extends StringField { + /** @var string */ protected $sJSDateTimeFormat; + /** @var string */ protected $sPHPDateTimeFormat; + /** @var bool */ protected $bDateOnly; /** - * Overloaded constructor - * - * @param string $sId - * @param \Closure $onFinalizeCallback (Used in the $oForm->AddField($sId, ..., function() use ($oManager, $oForm, '...') { ... } ); ) + * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { parent::__construct($sId, $onFinalizeCallback); $this->bDateOnly = false; @@ -58,7 +58,7 @@ class DateTimeField extends StringField * * @return \Combodo\iTop\Form\Field\DateTimeField */ - public function SetPHPDateTimeFormat($sPHPDateTimeFormat) + public function SetPHPDateTimeFormat(string $sPHPDateTimeFormat) { $this->sPHPDateTimeFormat = $sPHPDateTimeFormat; @@ -79,7 +79,7 @@ class DateTimeField extends StringField * * @return \Combodo\iTop\Form\Field\DateTimeField */ - public function SetJSDateTimeFormat($sJSDateTimeFormat) + public function SetJSDateTimeFormat(string $sJSDateTimeFormat) { $this->sJSDateTimeFormat = $sJSDateTimeFormat; @@ -93,7 +93,7 @@ class DateTimeField extends StringField * * @return \Combodo\iTop\Form\Field\DateTimeField */ - public function SetDateOnly($bDateOnly) + public function SetDateOnly(bool $bDateOnly) { $this->bDateOnly = $bDateOnly; return $this; diff --git a/sources/Form/Field/DurationField.php b/sources/Form/Field/DurationField.php index 5e48e1ec6..53a03ad8a 100644 --- a/sources/Form/Field/DurationField.php +++ b/sources/Form/Field/DurationField.php @@ -31,7 +31,7 @@ class DurationField extends Field /** * Note: This is inspired by AttributeDuration::GetAsHTML() * - * @return string + * @inheritDoc */ public function GetDisplayValue() { diff --git a/sources/Form/Field/EmailField.php b/sources/Form/Field/EmailField.php index fd1f1dd01..9a2505466 100644 --- a/sources/Form/Field/EmailField.php +++ b/sources/Form/Field/EmailField.php @@ -29,6 +29,11 @@ use utils; */ class EmailField extends StringField { + /** + * @inheritDoc + * @throws \ConfigException + * @throws \CoreException + */ public function GetDisplayValue() { $sLabel = Str::pure2html($this->currentValue); diff --git a/sources/Form/Field/Field.php b/sources/Form/Field/Field.php index 8acbcfb5f..c248b27d6 100644 --- a/sources/Form/Field/Field.php +++ b/sources/Form/Field/Field.php @@ -32,22 +32,37 @@ use Combodo\iTop\Form\Validator\MandatoryValidator; */ abstract class Field { - const ENUM_DISPLAY_MODE_COSY = 'cosy'; // Label above value - const ENUM_DISPLAY_MODE_COMPACT = 'compact'; // Label and value side by side - const ENUM_DISPLAY_MODE_DENSE = 'dense'; // Label and value side by side, closely + /** @var string */ + const ENUM_DISPLAY_MODE_COSY = 'cosy'; // Label above value + /** @var string */ + const ENUM_DISPLAY_MODE_COMPACT = 'compact'; // Label and value side by side + /** @var string */ + const ENUM_DISPLAY_MODE_DENSE = 'dense'; // Label and value side by side, closely + /** @var string */ const DEFAULT_LABEL = ''; + /** @var string */ const DEFAULT_DESCRIPTION = ''; + /** @var array */ const DEFAULT_METADATA = array(); + /** @var bool */ const DEFAULT_HIDDEN = false; + /** @var bool */ const DEFAULT_READ_ONLY = false; + /** @var bool */ const DEFAULT_MANDATORY = false; - const DEFAULT_DISPLAY_MODE = self::ENUM_DISPLAY_MODE_COSY; + /** @var string */ + const DEFAULT_DISPLAY_MODE = self::ENUM_DISPLAY_MODE_COSY; + /** @var bool */ const DEFAULT_VALID = true; + /** @var string */ protected $sId; + /** @var string */ protected $sGlobalId; + /** @var string */ protected $sFormPath; + /** @var string */ protected $sLabel; /** * Description text of the field, typically to bring more information to the user on the field purpose @@ -56,13 +71,21 @@ abstract class Field * @since 3.0.0 */ protected $sDescription; + /** @var array */ protected $aMetadata; + /** @var bool */ protected $bHidden; + /** @var bool */ protected $bReadOnly; + /** @var bool */ protected $bMandatory; + /** @var string */ protected $sDisplayMode; + /** @var array */ protected $aValidators; + /** @var bool */ protected $bValid; + /** @var array */ protected $aErrorMessages; protected $currentValue; protected $onFinalizeCallback; @@ -70,10 +93,10 @@ abstract class Field /** * Default constructor * - * @param string $sId - * @param Closure $onFinalizeCallback (Used in the $oForm->AddField($sId, ..., function() use ($oManager, $oForm, '...') { ... } ); ) + * @param string $sId + * @param \Closure|null $onFinalizeCallback (Used in the $oForm->AddField($sId, ..., function() use ($oManager, $oForm, '...') { ... } ); ) */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { $this->sId = $sId; // No space in such an id, that could be used as a DOM node id @@ -249,7 +272,9 @@ abstract class Field return $this->currentValue; } - + /** + * @return mixed + */ public function GetDisplayValue() { return $this->currentValue; @@ -262,7 +287,7 @@ abstract class Field * @param string $sFormPath * @return $this */ - public function SetFormPath($sFormPath) + public function SetFormPath(string $sFormPath) { $this->sFormPath = $sFormPath; return $this; @@ -273,7 +298,7 @@ abstract class Field * @param string $sLabel * @return $this */ - public function SetLabel($sLabel) + public function SetLabel(string $sLabel) { $this->sLabel = $sLabel; return $this; @@ -300,7 +325,7 @@ abstract class Field * @return $this * @since 2.7.0 */ - public function SetMetadata($aMetadata) + public function SetMetadata(array $aMetadata) { $this->aMetadata = $aMetadata; return $this; @@ -311,7 +336,7 @@ abstract class Field * @param boolean $bHidden * @return $this */ - public function SetHidden($bHidden) + public function SetHidden(bool $bHidden) { $this->bHidden = $bHidden; return $this; @@ -322,7 +347,7 @@ abstract class Field * @param boolean $bReadOnly * @return $this */ - public function SetReadOnly($bReadOnly) + public function SetReadOnly(bool $bReadOnly) { $this->bReadOnly = $bReadOnly; return $this; @@ -335,7 +360,7 @@ abstract class Field * @param boolean $bMandatory * @return $this */ - public function SetMandatory($bMandatory) + public function SetMandatory(bool $bMandatory) { // Before changing the property, we check if it was already mandatory. If not, we had the mandatory validator if ($bMandatory && !$this->bMandatory) @@ -366,7 +391,7 @@ abstract class Field * @param boolean $bMustChange * @return $this */ - public function SetMustChange($bMustChange) + public function SetMustChange(bool $bMustChange) { // TODO. return $this; @@ -377,7 +402,7 @@ abstract class Field * @param string $sDisplayMode * @return $this */ - public function SetDisplayMode($sDisplayMode) + public function SetDisplayMode(string $sDisplayMode) { $this->sDisplayMode = $sDisplayMode; return $this; @@ -388,7 +413,7 @@ abstract class Field * @param array $aValidators * @return $this */ - public function SetValidators($aValidators) + public function SetValidators(array $aValidators) { $this->aValidators = $aValidators; return $this; @@ -400,7 +425,7 @@ abstract class Field * @param boolean $bValid * @return $this */ - protected function SetValid($bValid) + protected function SetValid(bool $bValid) { $this->bValid = $bValid; return $this; @@ -412,7 +437,7 @@ abstract class Field * @param array $aErrorMessages * @return $this */ - protected function SetErrorMessages($aErrorMessages) + protected function SetErrorMessages(array $aErrorMessages) { $this->aErrorMessages = $aErrorMessages; return $this; @@ -450,7 +475,7 @@ abstract class Field * @return $this; * @since 2.7.0 */ - public function AddMetadata($sName, $sValue) + public function AddMetadata(string $sName, string $sValue) { $this->aMetadata[$sName] = $sValue; return $this; @@ -490,7 +515,7 @@ abstract class Field * @param string $sErrorMessage * @return $this */ - protected function AddErrorMessage($sErrorMessage) + protected function AddErrorMessage(string $sErrorMessage) { $this->aErrorMessages[] = $sErrorMessage; return $this; diff --git a/sources/Form/Field/FileUploadField.php b/sources/Form/Field/FileUploadField.php index 6d1077007..27771be29 100644 --- a/sources/Form/Field/FileUploadField.php +++ b/sources/Form/Field/FileUploadField.php @@ -45,7 +45,7 @@ class FileUploadField extends Field /** * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { $this->sTransactionId = null; $this->oObject = null; @@ -71,7 +71,7 @@ class FileUploadField extends Field * @param string $sTransactionId * @return $this */ - public function SetTransactionId($sTransactionId) + public function SetTransactionId(string $sTransactionId) { $this->sTransactionId = $sTransactionId; return $this; @@ -109,7 +109,7 @@ class FileUploadField extends Field * * @return $this */ - public function SetUploadEndpoint($sUploadEndpoint) + public function SetUploadEndpoint(string $sUploadEndpoint) { $this->sUploadEndpoint = $sUploadEndpoint; return $this; @@ -128,7 +128,7 @@ class FileUploadField extends Field * * @return $this */ - public function SetDownloadEndpoint($sDownloadEndpoint) + public function SetDownloadEndpoint(string $sDownloadEndpoint) { $this->sDownloadEndpoint = $sDownloadEndpoint; return $this; @@ -143,11 +143,11 @@ class FileUploadField extends Field } /** - * @param $bAllowDelete + * @param bool $bAllowDelete * * @return $this */ - public function SetAllowDelete($bAllowDelete) + public function SetAllowDelete(bool $bAllowDelete) { $this->bAllowDelete = (boolean) $bAllowDelete; return $this; diff --git a/sources/Form/Field/HiddenField.php b/sources/Form/Field/HiddenField.php index 4533f9515..43d75edaa 100644 --- a/sources/Form/Field/HiddenField.php +++ b/sources/Form/Field/HiddenField.php @@ -26,5 +26,6 @@ namespace Combodo\iTop\Form\Field; */ class HiddenField extends TextField { + /** @inheritDoc */ const DEFAULT_HIDDEN = true; } diff --git a/sources/Form/Field/ImageField.php b/sources/Form/Field/ImageField.php index f8d9e09c6..2c63de7e6 100644 --- a/sources/Form/Field/ImageField.php +++ b/sources/Form/Field/ImageField.php @@ -29,6 +29,9 @@ use Dict; */ class ImageField extends BlobField { + /** + * @inheritDoc + */ public function GetDisplayValue() { if ($this->currentValue->IsEmpty()) diff --git a/sources/Form/Field/LinkedSetField.php b/sources/Form/Field/LinkedSetField.php index 59520e35e..511881b50 100644 --- a/sources/Form/Field/LinkedSetField.php +++ b/sources/Form/Field/LinkedSetField.php @@ -59,7 +59,7 @@ class LinkedSetField extends Field /** * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { $this->sTargetClass = null; $this->sExtKeyToRemote = null; @@ -89,7 +89,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetTargetClass($sTargetClass) + public function SetTargetClass(string $sTargetClass) { $this->sTargetClass = $sTargetClass; @@ -111,7 +111,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetExtKeyToRemote($sExtKeyToRemote) + public function SetExtKeyToRemote(string $sExtKeyToRemote) { $this->sExtKeyToRemote = $sExtKeyToRemote; @@ -133,7 +133,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetIndirect($bIndirect) + public function SetIndirect(bool $bIndirect) { $this->bIndirect = $bIndirect; @@ -157,7 +157,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetDisplayOpened($bDisplayOpened) + public function SetDisplayOpened(bool $bDisplayOpened) { $this->bDisplayOpened = $bDisplayOpened; @@ -181,7 +181,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetDisplayLimitedAccessItems($bDisplayLimitedAccessItems) + public function SetDisplayLimitedAccessItems(bool $bDisplayLimitedAccessItems) { $this->bDisplayLimitedAccessItems = $bDisplayLimitedAccessItems; @@ -205,7 +205,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetLimitedAccessItemIDs($aLimitedAccessItemIDs) + public function SetLimitedAccessItemIDs(array $aLimitedAccessItemIDs) { $this->aLimitedAccessItemIDs = $aLimitedAccessItemIDs; @@ -219,7 +219,7 @@ class LinkedSetField extends Field * * @return array */ - public function GetAttributesToDisplay($bAttCodesOnly = false) + public function GetAttributesToDisplay(bool $bAttCodesOnly = false) { return ($bAttCodesOnly) ? array_keys($this->aAttributesToDisplay) : $this->aAttributesToDisplay; } @@ -250,7 +250,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetSearchEndpoint($sSearchEndpoint) + public function SetSearchEndpoint(string $sSearchEndpoint) { $this->sSearchEndpoint = $sSearchEndpoint; @@ -270,7 +270,7 @@ class LinkedSetField extends Field * * @return $this */ - public function SetInformationEndpoint($sInformationEndpoint) + public function SetInformationEndpoint(string $sInformationEndpoint) { $this->sInformationEndpoint = $sInformationEndpoint; @@ -284,7 +284,7 @@ class LinkedSetField extends Field * * @return bool */ - public function IsLimitedAccessItem($iItemID) + public function IsLimitedAccessItem(int $iItemID) { return in_array($iItemID, $this->aLimitedAccessItemIDs, false); } diff --git a/sources/Form/Field/MultipleChoicesField.php b/sources/Form/Field/MultipleChoicesField.php index a8a113837..4fe783a8a 100644 --- a/sources/Form/Field/MultipleChoicesField.php +++ b/sources/Form/Field/MultipleChoicesField.php @@ -43,7 +43,7 @@ abstract class MultipleChoicesField extends Field /** * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { parent::__construct($sId, $onFinalizeCallback); $this->bMultipleValuesEnabled = static::DEFAULT_MULTIPLE_VALUES_ENABLED; @@ -109,7 +109,7 @@ abstract class MultipleChoicesField extends Field * * @return $this */ - public function SetMultipleValuesEnabled($bMultipleValuesEnabled) + public function SetMultipleValuesEnabled(bool $bMultipleValuesEnabled) { $this->bMultipleValuesEnabled = $bMultipleValuesEnabled; return $this; @@ -120,7 +120,7 @@ abstract class MultipleChoicesField extends Field * * @return $this */ - public function SetValues($aValues) + public function SetValues(array $aValues) { $this->currentValue = $aValues; return $this; @@ -174,7 +174,7 @@ abstract class MultipleChoicesField extends Field * * @return $this */ - public function SetChoices($aChoices) + public function SetChoices(array $aChoices) { $this->aChoices = $aChoices; return $this; @@ -186,7 +186,7 @@ abstract class MultipleChoicesField extends Field * * @return $this */ - public function AddChoice($sId, $choice = null) + public function AddChoice(string $sId, $choice = null) { if ($choice === null) { @@ -201,7 +201,7 @@ abstract class MultipleChoicesField extends Field * * @return $this */ - public function RemoveChoice($sId) + public function RemoveChoice(string $sId) { if (in_array($sId, $this->aChoices)) { diff --git a/sources/Form/Field/MultipleSelectField.php b/sources/Form/Field/MultipleSelectField.php index 12a5a9552..cc4b8a473 100644 --- a/sources/Form/Field/MultipleSelectField.php +++ b/sources/Form/Field/MultipleSelectField.php @@ -26,6 +26,7 @@ namespace Combodo\iTop\Form\Field; */ class MultipleSelectField extends SelectField { + /** @inheritDoc */ const DEFAULT_MULTIPLE_VALUES_ENABLED = true; } diff --git a/sources/Form/Field/PhoneField.php b/sources/Form/Field/PhoneField.php index 33943ea19..54eab09d5 100644 --- a/sources/Form/Field/PhoneField.php +++ b/sources/Form/Field/PhoneField.php @@ -29,6 +29,11 @@ use utils; */ class PhoneField extends StringField { + /** + * @inheritDoc + * @throws \ConfigException + * @throws \CoreException + */ public function GetDisplayValue() { $sLabel = Str::pure2html($this->currentValue); diff --git a/sources/Form/Field/RadioField.php b/sources/Form/Field/RadioField.php index 0d4fe498a..b1f2a217d 100644 --- a/sources/Form/Field/RadioField.php +++ b/sources/Form/Field/RadioField.php @@ -26,6 +26,7 @@ namespace Combodo\iTop\Form\Field; */ class RadioField extends MultipleChoicesField { + /** @inheritDoc */ const DEFAULT_MULTIPLE_VALUES_ENABLED = false; } diff --git a/sources/Form/Field/SelectField.php b/sources/Form/Field/SelectField.php index 0cae8a562..7ab5e814c 100644 --- a/sources/Form/Field/SelectField.php +++ b/sources/Form/Field/SelectField.php @@ -31,6 +31,7 @@ use Dict; class SelectField extends MultipleChoicesField { // Overloaded constants + /** @inheritDoc */ const DEFAULT_MULTIPLE_VALUES_ENABLED = false; /** @var string DEFAULT_NULL_CHOICE_LABEL */ @@ -44,7 +45,7 @@ class SelectField extends MultipleChoicesField /** * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { parent::__construct($sId, $onFinalizeCallback); $this->bStartsWithNullChoice = static::DEFAULT_STARTS_WITH_NULL_CHOICE; @@ -62,11 +63,11 @@ class SelectField extends MultipleChoicesField } /** - * @param $bStartsWithNullChoice + * @param bool $bStartsWithNullChoice * * @return $this */ - public function SetStartsWithNullChoice($bStartsWithNullChoice) + public function SetStartsWithNullChoice(bool $bStartsWithNullChoice) { $this->bStartsWithNullChoice = $bStartsWithNullChoice; @@ -95,7 +96,7 @@ class SelectField extends MultipleChoicesField * @param boolean $bMultipleValuesEnabled * @return $this */ - public function SetMultipleValuesEnabled($bMultipleValuesEnabled) + public function SetMultipleValuesEnabled(bool $bMultipleValuesEnabled) { // We don't allow changing this value return $this; diff --git a/sources/Form/Field/SelectObjectField.php b/sources/Form/Field/SelectObjectField.php index e14bc216a..0b2d6fefb 100644 --- a/sources/Form/Field/SelectObjectField.php +++ b/sources/Form/Field/SelectObjectField.php @@ -57,7 +57,7 @@ class SelectObjectField extends Field /** * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { parent::__construct($sId, $onFinalizeCallback); $this->oSearch = null; @@ -85,7 +85,7 @@ class SelectObjectField extends Field * * @return $this */ - public function SetMaximumComboLength($iMaximumComboLength) + public function SetMaximumComboLength(int $iMaximumComboLength) { $this->iMaximumComboLength = $iMaximumComboLength; @@ -97,7 +97,7 @@ class SelectObjectField extends Field * * @return $this */ - public function SetMinAutoCompleteChars($iMinAutoCompleteChars) + public function SetMinAutoCompleteChars(int $iMinAutoCompleteChars) { $this->iMinAutoCompleteChars = $iMinAutoCompleteChars; @@ -109,7 +109,7 @@ class SelectObjectField extends Field * * @return $this */ - public function SetHierarchical($bHierarchical) + public function SetHierarchical(bool $bHierarchical) { $this->bHierarchical = $bHierarchical; @@ -119,7 +119,7 @@ class SelectObjectField extends Field /** * @param int $iControlType */ - public function SetControlType($iControlType) + public function SetControlType(int $iControlType) { $this->iControlType = $iControlType; } @@ -129,7 +129,7 @@ class SelectObjectField extends Field * * @return $this */ - public function SetSearchEndpoint($sSearchEndpoint) + public function SetSearchEndpoint(string $sSearchEndpoint) { $this->sSearchEndpoint = $sSearchEndpoint; @@ -139,7 +139,7 @@ class SelectObjectField extends Field /** * @inheritDoc */ - public function SetMandatory($bMandatory) + public function SetMandatory(bool $bMandatory) { // Before changing the property, we check if it was already mandatory. If not, we had the mandatory validator if ($bMandatory && !$this->bMandatory) @@ -219,7 +219,7 @@ class SelectObjectField extends Field * * @throws \CoreException */ - public function VerifyCurrentValue($bAlways = false) + public function VerifyCurrentValue(bool $bAlways = false) { if (!$this->GetReadOnly() || $bAlways) { diff --git a/sources/Form/Field/SubFormField.php b/sources/Form/Field/SubFormField.php index e1ba0a098..3fca8c4f0 100644 --- a/sources/Form/Field/SubFormField.php +++ b/sources/Form/Field/SubFormField.php @@ -32,12 +32,9 @@ class SubFormField extends Field protected $oForm; /** - * Default constructor - * - * @param string $sId - * @param \Closure $onFinalizeCallback + * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { $this->oForm = new Form('subform_' . $sId); parent::__construct($sId, $onFinalizeCallback); @@ -126,7 +123,7 @@ class SubFormField extends Field * * @param boolean $bMandatory */ - public function SetMandatory($bMandatory) + public function SetMandatory(bool $bMandatory) { foreach ($this->oForm->GetFields() as $oField) { @@ -140,7 +137,7 @@ class SubFormField extends Field * * @param boolean $bReadOnly */ - public function SetReadOnly($bReadOnly) + public function SetReadOnly(bool $bReadOnly) { foreach ($this->oForm->GetFields() as $oField) { @@ -155,7 +152,7 @@ class SubFormField extends Field * * @param boolean $bHidden */ - public function SetHidden($bHidden) + public function SetHidden(bool $bHidden) { foreach ($this->oForm->GetFields() as $oField) { @@ -168,7 +165,7 @@ class SubFormField extends Field * @param $sFormPath * @return Form|null */ - public function FindSubForm($sFormPath) + public function FindSubForm(string $sFormPath) { return $this->oForm->FindSubForm($sFormPath); } diff --git a/sources/Form/Field/TextAreaField.php b/sources/Form/Field/TextAreaField.php index 58a5b1de6..215f30720 100644 --- a/sources/Form/Field/TextAreaField.php +++ b/sources/Form/Field/TextAreaField.php @@ -33,15 +33,27 @@ use AttributeText; */ class TextAreaField extends TextField { + /** @var string */ const ENUM_FORMAT_TEXT = 'text'; + /** @var string */ const ENUM_FORMAT_HTML = 'html'; + /** @var string */ const DEFAULT_FORMAT = 'html'; + /** @var string */ protected $sFormat; protected $oObject; + /** @var string|null */ protected $sTransactionId; - public function __construct($sId, Closure $onFinalizeCallback = null, DBObject $oObject = null) + /** + * TextAreaField constructor. + * + * @param string $sId + * @param \Closure|null $onFinalizeCallback + * @param \DBObject|null $oObject + */ + public function __construct(string $sId, Closure $onFinalizeCallback = null, DBObject $oObject = null) { parent::__construct($sId, $onFinalizeCallback); $this->sFormat = static::DEFAULT_FORMAT; @@ -63,7 +75,7 @@ class TextAreaField extends TextField * @param string $sFormat * @return \Combodo\iTop\Form\Field\TextAreaField */ - public function SetFormat($sFormat) + public function SetFormat(string $sFormat) { $this->sFormat = $sFormat; return $this; @@ -104,7 +116,7 @@ class TextAreaField extends TextField * @param string $sTransactionId * @return \Combodo\iTop\Form\Field\TextAreaField */ - public function SetTransactionId($sTransactionId) + public function SetTransactionId(string $sTransactionId) { $this->sTransactionId = $sTransactionId; return $this; diff --git a/sources/Form/Field/UrlField.php b/sources/Form/Field/UrlField.php index 0b72aa1d5..342c29f4a 100644 --- a/sources/Form/Field/UrlField.php +++ b/sources/Form/Field/UrlField.php @@ -29,17 +29,16 @@ use Closure; */ class UrlField extends StringField { - const DEFAULT_TARGET = '_blank'; + /** @var string */ + const DEFAULT_TARGET = '_blank'; - protected $sTarget; + /** @var string */ + protected $sTarget; /** - * Default constructor - * - * @param string $sId - * @param \Closure $onFinalizeCallback (Used in the $oForm->AddField($sId, ..., function() use ($oManager, $oForm, '...') { ... } ); ) + * @inheritDoc */ - public function __construct($sId, Closure $onFinalizeCallback = null) + public function __construct(string $sId, Closure $onFinalizeCallback = null) { parent::__construct($sId, $onFinalizeCallback); @@ -53,6 +52,9 @@ class UrlField extends StringField return $this; } + /** + * @inheritDoc + */ public function GetDisplayValue() { $sLabel = Str::pure2html($this->currentValue); diff --git a/sources/Renderer/Bootstrap/FieldRenderer/BsSetFieldRenderer.php b/sources/Renderer/Bootstrap/FieldRenderer/BsSetFieldRenderer.php index 4e5c68265..c7d3b9f9a 100644 --- a/sources/Renderer/Bootstrap/FieldRenderer/BsSetFieldRenderer.php +++ b/sources/Renderer/Bootstrap/FieldRenderer/BsSetFieldRenderer.php @@ -31,7 +31,7 @@ use utils; class BsSetFieldRenderer extends BsFieldRenderer { /** - * @inheritdoc + * @inheritDoc */ public function Render() {