mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 14:08:46 +02:00
Introduce type hinting in methods prototype (PHP >= 7.1)
This commit is contained in:
@@ -78,7 +78,7 @@ class ActivityEntry extends UIBlock
|
||||
*
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function __construct(DateTime $oDateTime, $sAuthorLogin, $sContent = null, $sId = null)
|
||||
public function __construct(DateTime $oDateTime, string $sAuthorLogin, ?string $sContent = null, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
|
||||
@@ -97,7 +97,7 @@ class ActivityEntry extends UIBlock
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetType($sType)
|
||||
public function SetType(string $sType)
|
||||
{
|
||||
$this->sType = $sType;
|
||||
|
||||
@@ -121,7 +121,7 @@ class ActivityEntry extends UIBlock
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetDecorationClasses($sDecorationClasses)
|
||||
public function SetDecorationClasses(string $sDecorationClasses)
|
||||
{
|
||||
$this->sDecorationClasses = $sDecorationClasses;
|
||||
|
||||
@@ -145,9 +145,10 @@ class ActivityEntry extends UIBlock
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetContent($sContent)
|
||||
public function SetContent(string $sContent)
|
||||
{
|
||||
$this->sContent = $sContent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -202,7 +203,7 @@ class ActivityEntry extends UIBlock
|
||||
* @throws \OQLException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function SetAuthor($sAuthorLogin)
|
||||
public function SetAuthor(string $sAuthorLogin)
|
||||
{
|
||||
$this->sAuthorLogin = $sAuthorLogin;
|
||||
// TODO 2.8.0: Check that this does not return '' when author is the CRON or an extension.
|
||||
@@ -263,9 +264,10 @@ class ActivityEntry extends UIBlock
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function SetOrigin($sOrigin)
|
||||
protected function SetOrigin(string $sOrigin)
|
||||
{
|
||||
$this->sOrigin = $sOrigin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class ActivityEntryFactory
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public static function MakeFromCaseLogEntryArray($sAttCode, $aOrmEntry)
|
||||
public static function MakeFromCaseLogEntryArray(string $sAttCode, array $aOrmEntry)
|
||||
{
|
||||
$oUser = MetaModel::GetObject('User', $aOrmEntry['user_id'], false, true);
|
||||
$sUserLogin = ($oUser === null) ? '' : $oUser->Get('login');
|
||||
|
||||
@@ -58,7 +58,7 @@ class CaseLogEntry extends ActivityEntry
|
||||
*
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function __construct(DateTime $oDateTime, $sAuthorLogin, $sAttCode, $sContent, $sId = null)
|
||||
public function __construct(DateTime $oDateTime, string $sAuthorLogin, string $sAttCode, string $sContent, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($oDateTime, $sAuthorLogin, $sContent, $sId);
|
||||
|
||||
@@ -84,9 +84,10 @@ class CaseLogEntry extends ActivityEntry
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetCaseLogRank($iCaseLogRank)
|
||||
public function SetCaseLogRank(int $iCaseLogRank)
|
||||
{
|
||||
$this->iCaseLogRank = $iCaseLogRank;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class EditsEntry extends ActivityEntry
|
||||
*
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function __construct(DateTime $oDateTime, $sAuthorLogin, $sObjectClass, $sId = null)
|
||||
public function __construct(DateTime $oDateTime, string $sAuthorLogin, string $sObjectClass, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($oDateTime, $sAuthorLogin, null, $sId);
|
||||
|
||||
@@ -82,7 +82,7 @@ class EditsEntry extends ActivityEntry
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetAttributes($aAttributes)
|
||||
public function SetAttributes(array $aAttributes)
|
||||
{
|
||||
$this->aAttributes = $aAttributes;
|
||||
|
||||
@@ -104,11 +104,12 @@ class EditsEntry extends ActivityEntry
|
||||
* Note that if an attribute with the same $sAttCode already exists, it will be replaced.
|
||||
*
|
||||
* @param string $sAttCode
|
||||
* @param string $sEditDescriptionAsHtml The description of the edit already in HTML, it MUSt have been sanitized first (Already in HTML because most of the time it comes from CMDBChangeOp::GetDescription())
|
||||
* @param string $sEditDescriptionAsHtml The description of the edit already in HTML, it MUSt have been sanitized first (Already in
|
||||
* HTML because most of the time it comes from CMDBChangeOp::GetDescription())
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function AddAttribute($sAttCode, $sEditDescriptionAsHtml)
|
||||
public function AddAttribute(string $sAttCode, string $sEditDescriptionAsHtml)
|
||||
{
|
||||
$this->aAttributes[$sAttCode] = [
|
||||
'code' => $sAttCode,
|
||||
@@ -125,9 +126,9 @@ class EditsEntry extends ActivityEntry
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function RemoveAttribute($sAttCode)
|
||||
public function RemoveAttribute(string $sAttCode)
|
||||
{
|
||||
if(array_key_exists($sAttCode, $this->aAttributes))
|
||||
if (array_key_exists($sAttCode, $this->aAttributes))
|
||||
{
|
||||
unset($this->aAttributes[$sAttCode]);
|
||||
}
|
||||
|
||||
@@ -62,8 +62,10 @@ class TransitionEntry extends ActivityEntry
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function __construct(DateTime $oDateTime, $sAuthorLogin, $sObjectClass, $sOriginStateCode, $sTargetStateCode, $sId = null)
|
||||
{
|
||||
public function __construct(
|
||||
DateTime $oDateTime, string $sAuthorLogin, string $sObjectClass, string $sOriginStateCode, string $sTargetStateCode,
|
||||
?string $sId = null
|
||||
) {
|
||||
parent::__construct($oDateTime, $sAuthorLogin, null, $sId);
|
||||
|
||||
$this->SetOriginalState($sObjectClass, $sOriginStateCode);
|
||||
@@ -79,7 +81,7 @@ class TransitionEntry extends ActivityEntry
|
||||
* @return $this
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function SetOriginalState($sObjectClass, $sStateCode)
|
||||
public function SetOriginalState(string $sObjectClass, string $sStateCode)
|
||||
{
|
||||
$this->sOriginStateCode = $sStateCode;
|
||||
$this->sOriginStateLabel = MetaModel::GetStateLabel($sObjectClass, $sStateCode);
|
||||
@@ -116,7 +118,7 @@ class TransitionEntry extends ActivityEntry
|
||||
* @return $this
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function SetTargetState($sObjectClass, $sStateCode)
|
||||
public function SetTargetState(string $sObjectClass, string $sStateCode)
|
||||
{
|
||||
$this->sTargetStateCode = $sStateCode;
|
||||
$this->sTargetStateLabel = MetaModel::GetStateLabel($sObjectClass, $sStateCode);
|
||||
|
||||
Reference in New Issue
Block a user