Code cleanup

- Format code accordingly to coding conventions
- Add / update PHPDoc all over the place
- Suppress most of the warnings that did not have a big impact on code's logic
This commit is contained in:
Molkobain
2019-07-09 19:10:16 +02:00
parent 9e9187b169
commit 030d912820
7 changed files with 145 additions and 21 deletions

View File

@@ -954,6 +954,9 @@ class DBObjectSearch extends DBSearch
} }
} }
/**
* @inheritDoc
*/
public function Intersect(DBSearch $oFilter) public function Intersect(DBSearch $oFilter)
{ {
if ($oFilter instanceof DBUnionSearch) if ($oFilter instanceof DBUnionSearch)

View File

@@ -187,6 +187,11 @@ abstract class DBSearch
*/ */
abstract public function AddCondition_ReferencedBy(DBObjectSearch $oFilter, $sForeignExtKeyAttCode, $iOperatorCode = TREE_OPERATOR_EQUALS, &$aRealiasingMap = null); abstract public function AddCondition_ReferencedBy(DBObjectSearch $oFilter, $sForeignExtKeyAttCode, $iOperatorCode = TREE_OPERATOR_EQUALS, &$aRealiasingMap = null);
/**
* @param \DBSearch $oFilter
*
* @return \DBSearch
*/
abstract public function Intersect(DBSearch $oFilter); abstract public function Intersect(DBSearch $oFilter);
/** /**

View File

@@ -214,7 +214,7 @@ abstract class Field
* Usually Called by the form when adding the field * Usually Called by the form when adding the field
* *
* @param string $sFormPath * @param string $sFormPath
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetFormPath($sFormPath) public function SetFormPath($sFormPath)
{ {
@@ -225,7 +225,7 @@ abstract class Field
/** /**
* *
* @param string $sLabel * @param string $sLabel
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetLabel($sLabel) public function SetLabel($sLabel)
{ {
@@ -236,7 +236,7 @@ abstract class Field
/** /**
* *
* @param boolean $bHidden * @param boolean $bHidden
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetHidden($bHidden) public function SetHidden($bHidden)
{ {
@@ -247,7 +247,7 @@ abstract class Field
/** /**
* *
* @param boolean $bReadOnly * @param boolean $bReadOnly
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetReadOnly($bReadOnly) public function SetReadOnly($bReadOnly)
{ {
@@ -260,7 +260,7 @@ abstract class Field
* Setting the value will automatically add/remove a MandatoryValidator to the Field * Setting the value will automatically add/remove a MandatoryValidator to the Field
* *
* @param boolean $bMandatory * @param boolean $bMandatory
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetMandatory($bMandatory) public function SetMandatory($bMandatory)
{ {
@@ -291,7 +291,7 @@ abstract class Field
* *
* @todo Implement * @todo Implement
* @param boolean $bMustChange * @param boolean $bMustChange
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetMustChange($bMustChange) public function SetMustChange($bMustChange)
{ {
@@ -313,7 +313,7 @@ abstract class Field
/** /**
* *
* @param array $aValidators * @param array $aValidators
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetValidators($aValidators) public function SetValidators($aValidators)
{ {
@@ -325,7 +325,7 @@ abstract class Field
* Note : Function is protected as bValid should not be set from outside * Note : Function is protected as bValid should not be set from outside
* *
* @param boolean $bValid * @param boolean $bValid
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
protected function SetValid($bValid) protected function SetValid($bValid)
{ {
@@ -337,7 +337,7 @@ abstract class Field
* Note : Function is protected as aErrorMessages should not be set from outside * Note : Function is protected as aErrorMessages should not be set from outside
* *
* @param array $aErrorMessages * @param array $aErrorMessages
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
protected function SetErrorMessages($aErrorMessages) protected function SetErrorMessages($aErrorMessages)
{ {
@@ -348,7 +348,7 @@ abstract class Field
/** /**
* *
* @param mixed $currentValue * @param mixed $currentValue
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetCurrentValue($currentValue) public function SetCurrentValue($currentValue)
{ {
@@ -359,7 +359,7 @@ abstract class Field
/** /**
* *
* @param Closure $onFinalizeCallback * @param Closure $onFinalizeCallback
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function SetOnFinalizeCallback(Closure $onFinalizeCallback) public function SetOnFinalizeCallback(Closure $onFinalizeCallback)
{ {
@@ -370,7 +370,7 @@ abstract class Field
/** /**
* *
* @param \Combodo\iTop\Form\Validator\Validator $oValidator * @param \Combodo\iTop\Form\Validator\Validator $oValidator
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function AddValidator(Validator $oValidator) public function AddValidator(Validator $oValidator)
{ {
@@ -381,7 +381,7 @@ abstract class Field
/** /**
* *
* @param \Combodo\iTop\Form\Validator\Validator $oValidator * @param \Combodo\iTop\Form\Validator\Validator $oValidator
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
public function RemoveValidator(Validator $oValidator) public function RemoveValidator(Validator $oValidator)
{ {
@@ -399,7 +399,7 @@ abstract class Field
* Note : Function is protected as aErrorMessages should not be add from outside * Note : Function is protected as aErrorMessages should not be add from outside
* *
* @param string $sErrorMessage * @param string $sErrorMessage
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
protected function AddErrorMessage($sErrorMessage) protected function AddErrorMessage($sErrorMessage)
{ {
@@ -410,7 +410,7 @@ abstract class Field
/** /**
* Note : Function is protected as aErrorMessages should not be set from outside * Note : Function is protected as aErrorMessages should not be set from outside
* *
* @return \Combodo\iTop\Form\Field\Field * @return $this
*/ */
protected function EmptyErrorMessages() protected function EmptyErrorMessages()
{ {

View File

@@ -19,6 +19,8 @@
namespace Combodo\iTop\Form\Field; namespace Combodo\iTop\Form\Field;
use Closure;
/** /**
* Description of FileUploadField * Description of FileUploadField
* *
@@ -26,15 +28,24 @@ namespace Combodo\iTop\Form\Field;
*/ */
class FileUploadField extends Field class FileUploadField extends Field
{ {
/** @var bool DEFAULT_ALLOW_DELETE */
const DEFAULT_ALLOW_DELETE = true; const DEFAULT_ALLOW_DELETE = true;
/** @var string|null $sTransactionId */
protected $sTransactionId; protected $sTransactionId;
/** @var \DBObject|null $oObject */
protected $oObject; protected $oObject;
/** @var string|null $sUploadEndpoint */
protected $sUploadEndpoint; protected $sUploadEndpoint;
/** @var string|null $sDownloadEndpoint */
protected $sDownloadEndpoint; protected $sDownloadEndpoint;
/** @var bool $bAllowDelete */
protected $bAllowDelete; protected $bAllowDelete;
public function __construct($sId, \Closure $onFinalizeCallback = null) /**
* @inheritDoc
*/
public function __construct($sId, Closure $onFinalizeCallback = null)
{ {
$this->sTransactionId = null; $this->sTransactionId = null;
$this->oObject = null; $this->oObject = null;
@@ -58,7 +69,7 @@ class FileUploadField extends Field
/** /**
* *
* @param string $sTransactionId * @param string $sTransactionId
* @return \Combodo\iTop\Form\Field\FileUploadField * @return $this
*/ */
public function SetTransactionId($sTransactionId) public function SetTransactionId($sTransactionId)
{ {
@@ -66,44 +77,76 @@ class FileUploadField extends Field
return $this; return $this;
} }
/**
* @return \DBObject|null
*/
public function GetObject() public function GetObject()
{ {
return $this->oObject; return $this->oObject;
} }
/**
* @param $oObject
*
* @return $this
*/
public function SetObject($oObject) public function SetObject($oObject)
{ {
$this->oObject = $oObject; $this->oObject = $oObject;
return $this; return $this;
} }
/**
* @return string|null
*/
public function GetUploadEndpoint() public function GetUploadEndpoint()
{ {
return $this->sUploadEndpoint; return $this->sUploadEndpoint;
} }
/**
* @param $sUploadEndpoint
*
* @return $this
*/
public function SetUploadEndpoint($sUploadEndpoint) public function SetUploadEndpoint($sUploadEndpoint)
{ {
$this->sUploadEndpoint = $sUploadEndpoint; $this->sUploadEndpoint = $sUploadEndpoint;
return $this; return $this;
} }
/**
* @return string|null
*/
public function GetDownloadEndpoint() public function GetDownloadEndpoint()
{ {
return $this->sDownloadEndpoint; return $this->sDownloadEndpoint;
} }
/**
* @param $sDownloadEndpoint
*
* @return $this
*/
public function SetDownloadEndpoint($sDownloadEndpoint) public function SetDownloadEndpoint($sDownloadEndpoint)
{ {
$this->sDownloadEndpoint = $sDownloadEndpoint; $this->sDownloadEndpoint = $sDownloadEndpoint;
return $this; return $this;
} }
/**
* @return bool
*/
public function GetAllowDelete() public function GetAllowDelete()
{ {
return $this->bAllowDelete; return $this->bAllowDelete;
} }
/**
* @param $bAllowDelete
*
* @return $this
*/
public function SetAllowDelete($bAllowDelete) public function SetAllowDelete($bAllowDelete)
{ {
$this->bAllowDelete = (boolean) $bAllowDelete; $this->bAllowDelete = (boolean) $bAllowDelete;

View File

@@ -28,14 +28,21 @@ use Closure;
* Values = Items that have been picked * Values = Items that have been picked
* *
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com> * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/ */
abstract class MultipleChoicesField extends Field abstract class MultipleChoicesField extends Field
{ {
/** @var bool DEFAULT_MULTIPLE_VALUES_ENABLED */
const DEFAULT_MULTIPLE_VALUES_ENABLED = false; const DEFAULT_MULTIPLE_VALUES_ENABLED = false;
/** @var bool $bMultipleValuesEnabled */
protected $bMultipleValuesEnabled; protected $bMultipleValuesEnabled;
/** @var array $aChoices */
protected $aChoices; protected $aChoices;
/**
* @inheritDoc
*/
public function __construct($sId, Closure $onFinalizeCallback = null) public function __construct($sId, Closure $onFinalizeCallback = null)
{ {
parent::__construct($sId, $onFinalizeCallback); parent::__construct($sId, $onFinalizeCallback);
@@ -44,6 +51,9 @@ abstract class MultipleChoicesField extends Field
$this->currentValue = array(); $this->currentValue = array();
} }
/**
* @inheritDoc
*/
public function GetCurrentValue() public function GetCurrentValue()
{ {
$value = null; $value = null;
@@ -67,7 +77,7 @@ abstract class MultipleChoicesField extends Field
* Sets the current value for the MultipleChoicesField. * Sets the current value for the MultipleChoicesField.
* *
* @param mixed $currentValue Can be either an array of values (in case of multiple values) or just a simple value * @param mixed $currentValue Can be either an array of values (in case of multiple values) or just a simple value
* @return \Combodo\iTop\Form\Field\MultipleChoicesField * @return $this
*/ */
public function SetCurrentValue($currentValue) public function SetCurrentValue($currentValue)
{ {
@@ -86,29 +96,52 @@ abstract class MultipleChoicesField extends Field
return $this; return $this;
} }
/**
* @return bool
*/
public function GetMultipleValuesEnabled() public function GetMultipleValuesEnabled()
{ {
return $this->bMultipleValuesEnabled; return $this->bMultipleValuesEnabled;
} }
/**
* @param bool $bMultipleValuesEnabled
*
* @return $this
*/
public function SetMultipleValuesEnabled($bMultipleValuesEnabled) public function SetMultipleValuesEnabled($bMultipleValuesEnabled)
{ {
$this->bMultipleValuesEnabled = $bMultipleValuesEnabled; $this->bMultipleValuesEnabled = $bMultipleValuesEnabled;
return $this; return $this;
} }
/**
* @param array $aValues
*
* @return $this
*/
public function SetValues($aValues) public function SetValues($aValues)
{ {
$this->currentValue = $aValues; $this->currentValue = $aValues;
return $this; return $this;
} }
/**
* @param mixed $value
*
* @return $this
*/
public function AddValue($value) public function AddValue($value)
{ {
$this->currentValue = $value; $this->currentValue = $value;
return $this; return $this;
} }
/**
* @param mixed $value
*
* @return $this
*/
public function RemoveValue($value) public function RemoveValue($value)
{ {
if (array_key_exists($value, $this->currentValue)) if (array_key_exists($value, $this->currentValue))
@@ -118,22 +151,41 @@ abstract class MultipleChoicesField extends Field
return $this; return $this;
} }
/**
* @param mixed $value
*
* @return bool
*/
public function IsAmongValues($value) public function IsAmongValues($value)
{ {
return in_array($value, $this->currentValue); return in_array($value, $this->currentValue);
} }
/**
* @return array
*/
public function GetChoices() public function GetChoices()
{ {
return $this->aChoices; return $this->aChoices;
} }
/**
* @param array $aChoices
*
* @return $this
*/
public function SetChoices($aChoices) public function SetChoices($aChoices)
{ {
$this->aChoices = $aChoices; $this->aChoices = $aChoices;
return $this; return $this;
} }
/**
* @param string $sId
* @param null $choice
*
* @return $this
*/
public function AddChoice($sId, $choice = null) public function AddChoice($sId, $choice = null)
{ {
if ($choice === null) if ($choice === null)
@@ -144,6 +196,11 @@ abstract class MultipleChoicesField extends Field
return $this; return $this;
} }
/**
* @param string $sId
*
* @return $this
*/
public function RemoveChoice($sId) public function RemoveChoice($sId)
{ {
if (in_array($sId, $this->aChoices)) if (in_array($sId, $this->aChoices))
@@ -153,6 +210,9 @@ abstract class MultipleChoicesField extends Field
return $this; return $this;
} }
/**
* @inheritDoc
*/
public function Validate() public function Validate()
{ {
$this->SetValid(true); $this->SetValid(true);

View File

@@ -26,15 +26,24 @@ use Dict;
* Description of SelectField * Description of SelectField
* *
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com> * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/ */
class SelectField extends MultipleChoicesField class SelectField extends MultipleChoicesField
{ {
// Overloaded constants
const DEFAULT_MULTIPLE_VALUES_ENABLED = false; const DEFAULT_MULTIPLE_VALUES_ENABLED = false;
/** @var string DEFAULT_NULL_CHOICE_LABEL */
const DEFAULT_NULL_CHOICE_LABEL = 'UI:SelectOne'; const DEFAULT_NULL_CHOICE_LABEL = 'UI:SelectOne';
/** @var bool DEFAULT_STARTS_WITH_NULL_CHOICE */
const DEFAULT_STARTS_WITH_NULL_CHOICE = true; const DEFAULT_STARTS_WITH_NULL_CHOICE = true;
/** @var bool $bStartsWithNullChoice */
protected $bStartsWithNullChoice; protected $bStartsWithNullChoice;
/**
* @inheritDoc
*/
public function __construct($sId, Closure $onFinalizeCallback = null) public function __construct($sId, Closure $onFinalizeCallback = null)
{ {
parent::__construct($sId, $onFinalizeCallback); parent::__construct($sId, $onFinalizeCallback);
@@ -55,7 +64,7 @@ class SelectField extends MultipleChoicesField
/** /**
* @param $bStartsWithNullChoice * @param $bStartsWithNullChoice
* *
* @return \Combodo\iTop\Form\Field\SelectField * @return $this
*/ */
public function SetStartsWithNullChoice($bStartsWithNullChoice) public function SetStartsWithNullChoice($bStartsWithNullChoice)
{ {
@@ -84,7 +93,7 @@ class SelectField extends MultipleChoicesField
* Overloads the method to prevent changing this property. * Overloads the method to prevent changing this property.
* *
* @param boolean $bMultipleValuesEnabled * @param boolean $bMultipleValuesEnabled
* @return \Combodo\iTop\Form\Field\SelectField * @return $this
*/ */
public function SetMultipleValuesEnabled($bMultipleValuesEnabled) public function SetMultipleValuesEnabled($bMultipleValuesEnabled)
{ {

View File

@@ -19,11 +19,12 @@
namespace Combodo\iTop\Form; namespace Combodo\iTop\Form;
use \Combodo\iTop\Renderer\FormRenderer; use Combodo\iTop\Renderer\FormRenderer;
/** /**
* Description of formmanager * Description of formmanager
* *
* @package Combodo\iTop\Form
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com> * @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
*/ */
abstract class FormManager abstract class FormManager
@@ -68,6 +69,9 @@ abstract class FormManager
return $oFormManager; return $oFormManager;
} }
/**
* FormManager constructor.
*/
public function __construct() public function __construct()
{ {
// Overload in child class when needed // Overload in child class when needed