mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -48,7 +49,7 @@ class LinkSetDataTransformer
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function Decode(iDBObjectSetIterator $oDbObjectSet, string $sTargetClass, string $sTargetField = null): array
|
||||
public static function Decode(iDBObjectSetIterator $oDbObjectSet, string $sTargetClass, string $sTargetField = null): array
|
||||
{
|
||||
try {
|
||||
// Prepare result
|
||||
@@ -74,8 +75,7 @@ class LinkSetDataTransformer
|
||||
}
|
||||
|
||||
return $aResult;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
ExceptionLog::LogException($e);
|
||||
|
||||
@@ -96,7 +96,7 @@ class LinkSetDataTransformer
|
||||
*
|
||||
* @return array{to_be_created: array, to_be_deleted: array, to_be_added: array, to_be_removed: array}
|
||||
*/
|
||||
static public function Encode(array $aElements, string $sLinkClass, string $sExtKeyToRemote = null): array
|
||||
public static function Encode(array $aElements, string $sLinkClass, string $sExtKeyToRemote = null): array
|
||||
{
|
||||
// Result arrays
|
||||
$aToBeCreate = [];
|
||||
@@ -125,7 +125,7 @@ class LinkSetDataTransformer
|
||||
}
|
||||
break;
|
||||
|
||||
// OPERATION REMOVE
|
||||
// OPERATION REMOVE
|
||||
case 'remove':
|
||||
if ($sExtKeyToRemote === null) {
|
||||
// Direct link detach
|
||||
@@ -156,7 +156,7 @@ class LinkSetDataTransformer
|
||||
* @param \ormLinkSet $oOrmLinkSet
|
||||
*
|
||||
*/
|
||||
static public function StringToOrmLinkSet(string $sValue, ormLinkSet $oOrmLinkSet)
|
||||
public static function StringToOrmLinkSet(string $sValue, ormLinkSet $oOrmLinkSet)
|
||||
{
|
||||
try {
|
||||
$aItems = explode(" ", $sValue);
|
||||
@@ -169,9 +169,8 @@ class LinkSetDataTransformer
|
||||
$oOrmLinkSet->AddItem($oItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
ExceptionLog::LogException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -39,8 +40,7 @@ class LinkSetModel
|
||||
} else {
|
||||
return $oAttDef->GetLinkedClass();
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return 'unknown';
|
||||
}
|
||||
}
|
||||
@@ -90,4 +90,4 @@ class LinkSetModel
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -24,7 +25,6 @@ use utils;
|
||||
*/
|
||||
class LinkSetRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Get list of remote objects information based on a linkSet
|
||||
*
|
||||
@@ -36,7 +36,7 @@ class LinkSetRepository
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
static public function LinksDbSetToTargetObjectArray(iDBObjectSetIterator $oDbObjectSet, bool $bForce, array &$aInitialOptions, string $sTargetClass, string $sTargetField = null): ?array
|
||||
public static function LinksDbSetToTargetObjectArray(iDBObjectSetIterator $oDbObjectSet, bool $bForce, array &$aInitialOptions, string $sTargetClass, string $sTargetField = null): ?array
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -90,8 +90,7 @@ class LinkSetRepository
|
||||
}
|
||||
|
||||
return $aInitialOptions;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
ExceptionLog::LogException($e);
|
||||
|
||||
@@ -99,4 +98,4 @@ class LinkSetRepository
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -71,7 +72,7 @@ class LinksBulkDataPostProcessor implements iDataPostProcessor
|
||||
|
||||
// Group by links attached to object selection
|
||||
$oFieldExp = new FieldExpression($sTargetField, 'lnk');
|
||||
$sQuery = $oDbObjectSearch->MakeGroupByQuery([$sTargetField], array('grouped_by_1' => $oFieldExp), true);
|
||||
$sQuery = $oDbObjectSearch->MakeGroupByQuery([$sTargetField], ['grouped_by_1' => $oFieldExp], true);
|
||||
$aGroupResult = CMDBSource::QueryToArray($sQuery, MYSQLI_ASSOC);
|
||||
|
||||
// Iterate throw result...
|
||||
@@ -109,8 +110,7 @@ class LinksBulkDataPostProcessor implements iDataPostProcessor
|
||||
|
||||
// Order items
|
||||
usort($aResult, [self::class, "CompareItems"]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
ExceptionLog::LogException($e);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class LinksBulkDataPostProcessor implements iDataPostProcessor
|
||||
*
|
||||
* @return array|int
|
||||
*/
|
||||
static private function CompareItems($aItemA, $aItemB): int
|
||||
private static function CompareItems($aItemA, $aItemB): int
|
||||
{
|
||||
if ($aItemA['occurrence'] === $aItemB['occurrence']) {
|
||||
return 0;
|
||||
@@ -136,4 +136,4 @@ class LinksBulkDataPostProcessor implements iDataPostProcessor
|
||||
|
||||
return ($aItemA['occurrence'] > $aItemB['occurrence']) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user