Skip to content

Commit

Permalink
fix: psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTheHood committed Nov 11, 2023
1 parent a286cef commit f28ea77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/Classes/ModuleManager/ModuleInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function install(Module $module, bool $force = false): void
$moduleText = "module {$module->getArchiveName()} {$module->getVersion()}";

$installedModule = $module->getInstalledVersion();
if (!$force && $module->getInstalledVersion()) {
if (!$force && $installedModule) {
$installedModuleText = "module {$installedModule->getArchiveName()} {$installedModule->getVersion()}";
$this->error("Can not install $moduleText, because $installedModuleText is already installed.");
}
Expand Down Expand Up @@ -259,8 +259,9 @@ public function update(Module $module, bool $force = false): Module
}

$combinationSatisfyerResult = $this->dependencyManager->canBeInstalled($newModule);
$foundCombination = $combinationSatisfyerResult->foundCombination;

if (!$combinationSatisfyerResult->foundCombination) {
if (!$foundCombination) {
$this->error(
"Can not update $moduleText to $newModuleText."
. " No possible combination of versions found"
Expand All @@ -277,7 +278,7 @@ public function update(Module $module, bool $force = false): Module
// Modul installieren
$this->installWithoutDependencies($loadedNewModule);
// Modul Abhängigkeiten installieren
$this->installDependencies($loadedNewModule, $combinationSatisfyerResult->foundCombination);
$this->installDependencies($loadedNewModule, $foundCombination);

return $loadedNewModule;
}
Expand Down Expand Up @@ -368,7 +369,7 @@ public function uninstall(Module $module, bool $force = false): void
* @param Module $parentModule The parent Module for which dependencies need to be installed.
* @param Combination $combination The Combination specifying the dependencies to be installed.
*
* @throws DependencyException
* @throws \RobinTheHood\ModifiedModuleLoaderClient\DependencyManager\DependencyException
* If any of the dependencies cannot be installed due to conflicting versions or other issues,
* a DependencyException may be thrown with details.
*/
Expand Down Expand Up @@ -423,7 +424,7 @@ private function pullAndInstallWithoutDependencies(Module $module): void
*
* @return string The URL to download the module's archive.
*
* @throws Exception
* @throws \Exception
* If the API response is empty or lacks the necessary information to construct the archive URL, an Exception
* is thrown with a detailed error message.
*/
Expand Down Expand Up @@ -496,6 +497,7 @@ private function reload(Module $module): Module

/**
* // NOTE: Vielleicht neue class ModuleInstallerException hinzufügen
* @return never
*/
private function error(string $message): void
{
Expand Down
5 changes: 4 additions & 1 deletion src/Classes/ModuleManager/ModuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ public function install(string $archiveName, $versionConstraint): void
$systemSet = $this->systemSetFactory->getSystemSet();

$combinationSatisfyerResult = $this->dependencyBuilder->satisfies($archiveName, $versionConstraint, $systemSet);
if ($combinationSatisfyerResult->result === CombinationSatisfyerResult::RESULT_COMBINATION_NOT_FOUND) {
if (
$combinationSatisfyerResult->result === CombinationSatisfyerResult::RESULT_COMBINATION_NOT_FOUND
|| !$combinationSatisfyerResult->foundCombination
) {
$this->log->error(
self::ERROR_INSTALL_MODULE_MISSING_REQUIREMENTS,
"Can not install %s, because not all requirements are met. "
Expand Down

0 comments on commit f28ea77

Please sign in to comment.