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)
{
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);
/**
* @param \DBSearch $oFilter
*
* @return \DBSearch
*/
abstract public function Intersect(DBSearch $oFilter);
/**

View File

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

View File

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

View File

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

View File

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

View File

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