From 5b7a5e14a3c272794b407b192e55290a491d2e69 Mon Sep 17 00:00:00 2001 From: odain Date: Fri, 14 Nov 2025 10:41:47 +0100 Subject: [PATCH] code style fix --- setup/modelfactory.class.inc.php | 6 ++-- setup/modulediscovery.class.inc.php | 15 +++------ sources/Application/WebPage/WebPage.php | 3 +- sources/SessionTracker/SessionHandler.php | 32 +++++++++---------- synchro/synchrodatasource.class.inc.php | 7 ++-- .../modulediscovery/ModuleDiscoveryTest.php | 1 - .../SessionTracker/SessionHandlerTest.php | 2 +- 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index d43f0c6a3..a0aa189ee 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -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(); diff --git a/setup/modulediscovery.class.inc.php b/setup/modulediscovery.class.inc.php index e90ee2ca7..68249402d 100644 --- a/setup/modulediscovery.class.inc.php +++ b/setup/modulediscovery.class.inc.php @@ -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"; } diff --git a/sources/Application/WebPage/WebPage.php b/sources/Application/WebPage/WebPage.php index ed699ffcd..905a7ac9f 100644 --- a/sources/Application/WebPage/WebPage.php +++ b/sources/Application/WebPage/WebPage.php @@ -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) { diff --git a/sources/SessionTracker/SessionHandler.php b/sources/SessionTracker/SessionHandler.php index 72244b4a7..5f3c31226 100644 --- a/sources/SessionTracker/SessionHandler.php +++ b/sources/SessionTracker/SessionHandler.php @@ -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]); } } diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index f67114c4b..973a8fdaa 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -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(); diff --git a/tests/php-unit-tests/unitary-tests/modulediscovery/ModuleDiscoveryTest.php b/tests/php-unit-tests/unitary-tests/modulediscovery/ModuleDiscoveryTest.php index ec573f84c..d863c6d64 100644 --- a/tests/php-unit-tests/unitary-tests/modulediscovery/ModuleDiscoveryTest.php +++ b/tests/php-unit-tests/unitary-tests/modulediscovery/ModuleDiscoveryTest.php @@ -1,6 +1,5 @@ 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"); } -} \ No newline at end of file +}