code style fix

This commit is contained in:
odain
2025-11-14 10:41:47 +01:00
parent 2b1ecf15b4
commit 5b7a5e14a3
7 changed files with 29 additions and 37 deletions

View File

@@ -81,11 +81,11 @@ class MFException extends Exception
public function __construct($message = null, $code = 0, $oNode, $sXPath = null, $sExtraInfo = '', $oParentFallbackNode = null)
{
$iSourceLineNumber = ModelFactory::GetXMLLineNumber($oNode);
if ($iSourceLineNumber==0 && ! is_null($oParentFallbackNode)){
if ($iSourceLineNumber == 0 && ! is_null($oParentFallbackNode)) {
$iSourceLineNumber = ModelFactory::GetXMLLineNumber($oParentFallbackNode);
}
if (is_null($sXPath)){
if (is_null($sXPath)) {
$sXPath = DesignDocument::GetItopNodePath($oNode);
}
@@ -2139,7 +2139,7 @@ EOF;
* @throws MFException
* @throws \Exception
*/
public function RedefineChildNode(MFElement $oNode, $sSearchId = null, $oParentFallbackNode=null)
public function RedefineChildNode(MFElement $oNode, $sSearchId = null, $oParentFallbackNode = null)
{
// First: cleanup any flag behind the new node, and eventually add trace data
$oNode->ApplyChanges();

View File

@@ -215,10 +215,8 @@ class ModuleDiscovery
ksort($aDependencies);
$aOrderedModules = [];
$iLoopCount = 0;
while(($iLoopCount < count($aModules)) && (count($aDependencies) > 0) )
{
foreach($aDependencies as $sId => $aRemainingDeps)
{
while (($iLoopCount < count($aModules)) && (count($aDependencies) > 0)) {
foreach ($aDependencies as $sId => $aRemainingDeps) {
$bDependenciesSolved = true;
foreach ($aRemainingDeps as $sDepId) {
if (!self::DependencyIsResolved($sDepId, $aOrderedModules, $aSelectedModules)) {
@@ -278,8 +276,7 @@ class ModuleDiscovery
$bResult = false;
$aModuleVersions = [];
// Separate the module names from their version for an easier comparison later
foreach($aOrderedModules as $sModuleId)
{
foreach ($aOrderedModules as $sModuleId) {
list($sModuleName, $sVersion) = self::GetModuleName($sModuleId);
$aModuleVersions[$sModuleName] = $sVersion;
}
@@ -395,12 +392,10 @@ class ModuleDiscovery
if (preg_match('!^(.*)/(.*)$!', $sModuleId, $aMatches)) {
$sName = $aMatches[1];
$sVersion = $aMatches[2];
if ($sVersion === ""){
if ($sVersion === "") {
$sVersion = "1.0.0";
}
}
else
{
} else {
$sName = $sModuleId;
$sVersion = "1.0.0";
}

View File

@@ -1268,10 +1268,9 @@ JS;
*/
protected function AddCompatibilityFiles(string $sFileType, string $sMode): void
{
$sConstantName = 'COMPATIBILITY_'.strtoupper($sMode).'_LINKED_'. ($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'STYLESHEETS' : 'SCRIPTS') .'_REL_PATH';
$sConstantName = 'COMPATIBILITY_'.strtoupper($sMode).'_LINKED_'.($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'STYLESHEETS' : 'SCRIPTS').'_REL_PATH';
$sMethodName = 'Link'.($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'Resource' : 'Script').'FromAppRoot';
// Add ancestors files
foreach (array_reverse(class_parents(static::class)) as $sParentClass) {
foreach (constant($sParentClass.'::'.$sConstantName) as $sFile) {

View File

@@ -139,15 +139,15 @@ class SessionHandler extends \SessionHandler
// - Data corruption (not a json / not an array / no previous creation_time key)
$iCreationTime = time();
$aJson=[];
$aJson = [];
if (! is_null($sPreviousFileVersionContent)) {
$aJson = json_decode($sPreviousFileVersionContent, true);
if (is_array($aJson)){
if (is_array($aJson)) {
if (array_key_exists('creation_time', $aJson)) {
$iCreationTime = $aJson['creation_time'];
}
} else {
$aJson=[];
} else {
$aJson = [];
}
}
@@ -155,42 +155,42 @@ class SessionHandler extends \SessionHandler
'login_mode' => Session::Get('login_mode'),
'user_id' => $sUserId,
'creation_time' => $iCreationTime,
'context' => implode('|', ContextTag::GetStack())
'context' => implode('|', ContextTag::GetStack()),
];
$oiSessionHandlerExtension = $this->GetSessionHandlerExtension();
if (! is_null($oiSessionHandlerExtension)){
if (! is_null($oiSessionHandlerExtension)) {
$oiSessionHandlerExtension->CompleteSessionData($aJson, $aData);
}
return json_encode (
return json_encode(
$aData
);
} catch(Exception $e) {
} catch (Exception $e) {
IssueLog::Error(__METHOD__, null, [ 'error' => $e->getMessage() ]);
}
return null;
}
private function GetSessionHandlerExtension() : ?iSessionHandlerExtension
private function GetSessionHandlerExtension(): ?iSessionHandlerExtension
{
$sSessionHandlerExtensionClass = utils::GetConfig()->Get('sessions_tracking.session_handler_extension');
if (strlen($sSessionHandlerExtensionClass) !=0){
try{
if (! class_exists($sSessionHandlerExtensionClass)){
if (strlen($sSessionHandlerExtensionClass) != 0) {
try {
if (! class_exists($sSessionHandlerExtensionClass)) {
throw new \Exception("Cannot find class");
}
/** @var iSessionHandlerExtension $oSessionHandlerExtension */
$oSessionHandlerExtension = new $sSessionHandlerExtensionClass;
if ($oSessionHandlerExtension instanceof iSessionHandlerExtension){
$oSessionHandlerExtension = new $sSessionHandlerExtensionClass();
if ($oSessionHandlerExtension instanceof iSessionHandlerExtension) {
return $oSessionHandlerExtension;
}
throw new \Exception("Not an instance of iSessionHandlerExtension");
} catch(\Exception $e) {
IssueLog::Error(__METHOD__ . ': cannot instanciate iSessionHandlerExtension', null, ['sessions_tracking.session_handler_extension' => $sSessionHandlerExtensionClass]);
} catch (\Exception $e) {
IssueLog::Error(__METHOD__.': cannot instanciate iSessionHandlerExtension', null, ['sessions_tracking.session_handler_extension' => $sSessionHandlerExtensionClass]);
}
}

View File

@@ -2397,9 +2397,8 @@ class SynchroReplica extends DBObject implements iDisplay
}
}
// Really modified ?
if ($oDestObj->IsModified())
{
if(method_exists(get_class($oDestObj), "SetCurrentChange")){
if ($oDestObj->IsModified()) {
if (method_exists(get_class($oDestObj), "SetCurrentChange")) {
$oDestObj::SetCurrentChange($oChange);
}
$oDestObj->DBUpdate();
@@ -2452,7 +2451,7 @@ class SynchroReplica extends DBObject implements iDisplay
}
}
if(method_exists(get_class($oDestObj), "SetCurrentChange")){
if (method_exists(get_class($oDestObj), "SetCurrentChange")) {
$oDestObj::SetCurrentChange($oChange);
}
$iNew = $oDestObj->DBInsert();

View File

@@ -1,6 +1,5 @@
<?php
namespace Combodo\iTop\Test\UnitTest\Setup;
use Combodo\iTop\Test\UnitTest\ItopTestCase;

View File

@@ -325,4 +325,4 @@ class SessionHandlerTest extends ItopDataTestCase
$sContent = $this->GenerateSessionContent($oSessionHandler, json_encode(null));
$this->assertNotNull($sContent, "Call to CompleteSessionData should NOT fail due to Argument #1 (\$aJson) must be of type array, null given");
}
}
}