mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Add type hinting to methods parameters
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,6 +26,6 @@ namespace Combodo\iTop\Form\Field;
|
||||
*/
|
||||
class CheckboxField extends MultipleChoicesField
|
||||
{
|
||||
/** @inheritDoc */
|
||||
const DEFAULT_MULTIPLE_VALUES_ENABLED = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -31,7 +31,7 @@ class DurationField extends Field
|
||||
/**
|
||||
* Note: This is inspired by AttributeDuration::GetAsHTML()
|
||||
*
|
||||
* @return string
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function GetDisplayValue()
|
||||
{
|
||||
|
||||
@@ -29,6 +29,11 @@ use utils;
|
||||
*/
|
||||
class EmailField extends StringField
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetDisplayValue()
|
||||
{
|
||||
$sLabel = Str::pure2html($this->currentValue);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,5 +26,6 @@ namespace Combodo\iTop\Form\Field;
|
||||
*/
|
||||
class HiddenField extends TextField
|
||||
{
|
||||
/** @inheritDoc */
|
||||
const DEFAULT_HIDDEN = true;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ use Dict;
|
||||
*/
|
||||
class ImageField extends BlobField
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function GetDisplayValue()
|
||||
{
|
||||
if ($this->currentValue->IsEmpty())
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Combodo\iTop\Form\Field;
|
||||
*/
|
||||
class MultipleSelectField extends SelectField
|
||||
{
|
||||
/** @inheritDoc */
|
||||
const DEFAULT_MULTIPLE_VALUES_ENABLED = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,11 @@ use utils;
|
||||
*/
|
||||
class PhoneField extends StringField
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetDisplayValue()
|
||||
{
|
||||
$sLabel = Str::pure2html($this->currentValue);
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Combodo\iTop\Form\Field;
|
||||
*/
|
||||
class RadioField extends MultipleChoicesField
|
||||
{
|
||||
/** @inheritDoc */
|
||||
const DEFAULT_MULTIPLE_VALUES_ENABLED = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user