N°8796 - Add PHP code style validation in iTop and extensions - format whole code base

This commit is contained in:
odain
2025-11-07 15:39:53 +01:00
parent 12f23113f5
commit 890a2568c8
2110 changed files with 53099 additions and 63885 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\UIBlock;
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
@@ -335,7 +335,7 @@ class ActivityEntry extends UIBlock
$sDecorationClasses = null;
// Note: We put fa-fw on all cases instead of just in the template as one of the cases could (in the future) not use FA icons. This will ensure that any use of the FA icons are always the same width.
switch($this->GetOrigin()) {
switch ($this->GetOrigin()) {
case CMDBChangeOrigin::CSV_INTERACTIVE:
case CMDBChangeOrigin::CSV_IMPORT:
$sDecorationClasses = 'fas fa-fw fa-file-import';
@@ -364,4 +364,4 @@ class ActivityEntry extends UIBlock
return $sDecorationClasses;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use AttributeDateTime;
use CMDBChange;
use CMDBChangeOp;
@@ -83,7 +83,7 @@ class ActivityEntryFactory
$oUser = MetaModel::GetObject('User', $aOrmEntry['user_id'], false, true);
$sUserLogin = ($oUser === null) ? '' : $oUser->Get('login');
// We sanitize OrmEntry even if it's already sanitized: if the entry is somehow truncated or metadata are wrong we may break whole page DOM
// We sanitize OrmEntry even if it's already sanitized: if the entry is somehow truncated or metadata are wrong we may break whole page DOM
$oEntry = new CaseLogEntry(
DateTime::createFromFormat(AttributeDateTime::GetInternalFormat(), $aOrmEntry['date']),
$sUserLogin,
@@ -154,4 +154,4 @@ class ActivityEntryFactory
return $sFactoryFqcn;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpAttachmentAddedFactory
*
@@ -31,4 +31,4 @@ namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CM
class CMDBChangeOpAttachmentAddedFactory extends CMDBChangeOpFactory
{
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-paperclip';
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpAttachmentRemovedFactory
*
@@ -31,4 +31,4 @@ namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CM
class CMDBChangeOpAttachmentRemovedFactory extends CMDBChangeOpFactory
{
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-unlink';
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpCreateFactory
*
@@ -28,6 +28,7 @@ namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CM
* @since 3.0.0
* @internal
*/
class CMDBChangeOpCreateFactory extends CMDBChangeOpFactory {
class CMDBChangeOpCreateFactory extends CMDBChangeOpFactory
{
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-seedling';
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
/**
* Class CMDBChangeOpDeleteFactory
*
@@ -28,6 +28,7 @@ namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CM
* @since 3.0.0
* @internal
*/
class CMDBChangeOpDeleteFactory extends CMDBChangeOpFactory {
class CMDBChangeOpDeleteFactory extends CMDBChangeOpFactory
{
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-trash';
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntry;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EditsEntry;
@@ -82,15 +82,13 @@ class CMDBChangeOpFactory
// - Set login in the friendlyname as a fallback
$sAuthorLogin = $oChangeOp->Get('userinfo');
// - Try to find user login from its ID if present (since iTop 3.0.0)
if(empty($iAuthorId) === false)
{
if (empty($iAuthorId) === false) {
$oAuthor = MetaModel::GetObject('User', $iAuthorId, false, true);
if(empty($oAuthor) === false)
{
if (empty($oAuthor) === false) {
$sAuthorLogin = $oAuthor->Get('login');
}
}
return $sAuthorLogin;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EditsEntry;
use DateTime;
@@ -60,4 +60,4 @@ class CMDBChangeOpSetAttributeFactory extends CMDBChangeOpFactory
return $oEntry;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\CMDBChangeOp;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\TransitionEntry;
use DateTime;
@@ -56,12 +56,10 @@ class CMDBChangeOpSetAttributeScalarFactory extends CMDBChangeOpSetAttributeFact
$sTargetStateLabel = MetaModel::GetStateLabel($sHostObjectClass, $oChangeOp->Get('newvalue'));
$oEntry = new TransitionEntry($oDateTime, $sAuthorLogin, $sHostObjectClass, $sOriginStateLabel, $sTargetStateLabel);
}
else
{
} else {
$oEntry = parent::MakeFromCmdbChangeOp($oChangeOp);
}
return $oEntry;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
use utils;
@@ -70,10 +70,10 @@ class CaseLogEntry extends ActivityEntry
$this->sAttCode = $sAttCode;
$this->SetCaseLogRank(static::DEFAULT_CASELOG_RANK);
}
/*
* Set the author and its information based on the $sAuthorLogin using parent call
* If no parent call found no matching User, fallback on caselog author name and display it as foreign message
* If no parent call found no matching User, fallback on caselog author name and display it as foreign message
*
* @param string $sAuthorLogin
*
@@ -84,13 +84,13 @@ class CaseLogEntry extends ActivityEntry
public function SetAuthor(string $sAuthorLogin)
{
parent::SetAuthor($sAuthorLogin);
// If no User was found in parent call
if($this->sAuthorLogin === '') {
if ($this->sAuthorLogin === '') {
// Use caselog user_login info as friendlyname and compute its initials
$this->sAuthorFriendlyname = $this->sAuthorName;
$this->sAuthorInitials = utils::ToAcronym($this->sAuthorFriendlyname);
// Reset Picture as we probably have default image
$this->sAuthorPictureAbsUrl = null;
// Reset bIsFromCurrentUser as UserRights often consider '' login as current user login
@@ -132,4 +132,4 @@ class CaseLogEntry extends ActivityEntry
{
return $this->iCaseLogRank;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
use Dict;
use Exception;
@@ -137,8 +137,7 @@ class EditsEntry extends ActivityEntry
*/
public function RemoveAttribute(string $sAttCode)
{
if (array_key_exists($sAttCode, $this->aAttributes))
{
if (array_key_exists($sAttCode, $this->aAttributes)) {
unset($this->aAttributes[$sAttCode]);
}
@@ -180,8 +179,7 @@ class EditsEntry extends ActivityEntry
// We need the array to be indexed by numbers instead of being associative
$aAttributesData = array_values($this->GetAttributes());
$iAttributesCount = count($aAttributesData);
switch($iAttributesCount)
{
switch ($iAttributesCount) {
case 0:
$sDescriptionAsHtml = '';
break;
@@ -204,8 +202,7 @@ class EditsEntry extends ActivityEntry
$sFirstAttLabelAsHtml = '<span class="ibo-edits-entry--attribute-label" data-attribute-code="'.$aAttributesData[0]['code'].'">'.$aAttributesData[0]['label'].'</span>';
$sSecondAttLabelAsHtml = '<span class="ibo-edits-entry--attribute-label" data-attribute-code="'.$aAttributesData[1]['code'].'">'.$aAttributesData[1]['label'].'</span>';
switch($iAttributesCount)
{
switch ($iAttributesCount) {
case 2:
$sDescriptionAsHtml = Dict::Format('Change:TwoAttributesChanged', $sFirstAttLabelAsHtml, $sSecondAttLabelAsHtml);
break;
@@ -222,4 +219,4 @@ class EditsEntry extends ActivityEntry
return $sDescriptionAsHtml;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EventNotification;
/**
* Class EventNotificationEmailFactory
*
@@ -34,4 +34,4 @@ class EventNotificationEmailFactory extends EventNotificationFactory
{
/** @inheritDoc */
public const DEFAULT_DECORATION_CLASSES = 'fas fa-fw fa-envelope';
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\EventNotification;
use AttributeDateTime;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\NotificationEntry;
use DateTime;
@@ -65,4 +65,4 @@ class EventNotificationFactory
return $oEntry;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
/**
@@ -108,4 +108,4 @@ class NotificationEntry extends ActivityEntry
{
return $this->sMessage;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry;
use DateTime;
use MetaModel;
@@ -63,7 +63,11 @@ class TransitionEntry extends ActivityEntry
* @throws \OQLException
*/
public function __construct(
DateTime $oDateTime, string $sAuthorLogin, string $sObjectClass, string $sOriginStateCode, string $sTargetStateCode,
DateTime $oDateTime,
string $sAuthorLogin,
string $sObjectClass,
string $sOriginStateCode,
string $sTargetStateCode,
?string $sId = null
) {
parent::__construct($oDateTime, $sAuthorLogin, null, $sId);
@@ -145,4 +149,4 @@ class TransitionEntry extends ActivityEntry
{
return $this->sTargetStateLabel;
}
}
}