mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
phpstan cleanup
This commit is contained in:
@@ -140,35 +140,34 @@ class ModuleDependencySort
|
|||||||
}
|
}
|
||||||
//include all modules
|
//include all modules
|
||||||
$iInDegreeCounterIncludingOutsideModules = count($oModule->GetUnresolvedDependencyModuleNames());
|
$iInDegreeCounterIncludingOutsideModules = count($oModule->GetUnresolvedDependencyModuleNames());
|
||||||
$aCountDepsByModuleId[$sModuleId] = [$iInDegreeCounter, $iInDegreeCounterIncludingOutsideModules, $sModuleId];
|
$aCountDepsByModuleId[$sModuleId] = new ModuleCountDepency($sModuleId, $iInDegreeCounter, $iInDegreeCounterIncludingOutsideModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
$aRes = [];
|
$aRes = [];
|
||||||
while (count($aUnresolvedDependencyModules) > 0) {
|
while (count($aUnresolvedDependencyModules) > 0) {
|
||||||
asort($aCountDepsByModuleId);
|
asort($aCountDepsByModuleId);
|
||||||
|
|
||||||
uasort($aCountDepsByModuleId, function (array $aDeps1, array $aDeps2) {
|
uasort($aCountDepsByModuleId, function (ModuleCountDepency $oModuleCountDepency1, ModuleCountDepency $oModuleCountDepency2) {
|
||||||
//compare $iInDegreeCounter
|
$res = $oModuleCountDepency1->iInDegreeCounter - $oModuleCountDepency2->iInDegreeCounter;
|
||||||
$res = $aDeps1[0] - $aDeps2[0];
|
|
||||||
if ($res != 0) {
|
if ($res != 0) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
//compare $iInDegreeCounterIncludingOutsideModules
|
$res = $oModuleCountDepency1->iInDegreeCounterIncludingOutsideModules - $oModuleCountDepency2->iInDegreeCounterIncludingOutsideModules;
|
||||||
$res = $aDeps1[1] - $aDeps2[1];
|
|
||||||
if ($res != 0) {
|
if ($res != 0) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
//alphabetical order at least
|
//alphabetical order at least
|
||||||
return strcmp($aDeps1[2], $aDeps2[2]);
|
return strcmp($oModuleCountDepency1->sModuleId, $oModuleCountDepency2->sModuleId);
|
||||||
});
|
});
|
||||||
|
|
||||||
$bOneLoopAtLeast = false;
|
$bOneLoopAtLeast = false;
|
||||||
foreach ($aCountDepsByModuleId as $sModuleId => $iInDegreeCounter) {
|
foreach ($aCountDepsByModuleId as $sModuleId => $oModuleCountDepency) {
|
||||||
|
/** @var ModuleCountDepency $oModuleCountDepency */
|
||||||
$oModule = $aUnresolvedDependencyModules[$sModuleId];
|
$oModule = $aUnresolvedDependencyModules[$sModuleId];
|
||||||
|
|
||||||
if ($bOneLoopAtLeast && ($iInDegreeCounter > 0)) {
|
if ($bOneLoopAtLeast && ($oModuleCountDepency->iInDegreeCounter > 0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +182,10 @@ class ModuleDependencySort
|
|||||||
if (!array_key_exists($sModuleId2, $aCountDepsByModuleId)) {
|
if (!array_key_exists($sModuleId2, $aCountDepsByModuleId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$aDepCount = $aCountDepsByModuleId[$sModuleId2];
|
/** @var ModuleCountDepency $oModuleCountDepency2 */
|
||||||
$iInDegreeCounter = $aDepCount[0] - 1;
|
$oModuleCountDepency2 = $aCountDepsByModuleId[$sModuleId2];
|
||||||
$iInDegreeCounterIncludingOutsideModules = $aDepCount[1];
|
$iInDegreeCounter = $oModuleCountDepency2->iInDegreeCounter - 1;
|
||||||
$aCountDepsByModuleId[$sModuleId2] = [$iInDegreeCounter, $iInDegreeCounterIncludingOutsideModules, $sModuleId2];
|
$aCountDepsByModuleId[$sModuleId2] = new ModuleCountDepency($sModuleId2, $iInDegreeCounter, $oModuleCountDepency2->iInDegreeCounterIncludingOutsideModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($aDependsOnModuleName[$oModule->GetModuleName()]);
|
unset($aDependsOnModuleName[$oModule->GetModuleName()]);
|
||||||
@@ -199,3 +198,19 @@ class ModuleDependencySort
|
|||||||
$aUnresolvedDependencyModules = $aRes;
|
$aUnresolvedDependencyModules = $aRes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ModuleCountDepency
|
||||||
|
{
|
||||||
|
public string $sModuleId;
|
||||||
|
public int $iInDegreeCounter;
|
||||||
|
public int $iInDegreeCounterIncludingOutsideModules;
|
||||||
|
|
||||||
|
public function __construct(string $sModuleId, int $iInDegreeCounter, int $iInDegreeCounterIncludingOutsideModules)
|
||||||
|
{
|
||||||
|
$this->iInDegreeCounter = $iInDegreeCounter;
|
||||||
|
$this->iInDegreeCounterIncludingOutsideModules = $iInDegreeCounterIncludingOutsideModules;
|
||||||
|
$this->sModuleId = $sModuleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user