From 2cbde92617e7247ce9cda7e85172ec38e2b6c2b8 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Mon, 9 Sep 2024 12:45:28 +0200 Subject: [PATCH] Simplify getting target namespace by including appending \ --- src/Config/Mozart.php | 9 ++++++++- src/Config/Package.php | 4 +--- src/Console/Commands/Compose.php | 5 ----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Config/Mozart.php b/src/Config/Mozart.php index 55a26e2e..9d26c194 100644 --- a/src/Config/Mozart.php +++ b/src/Config/Mozart.php @@ -5,6 +5,7 @@ use stdClass; use CoenJacobs\Mozart\Config\OverrideAutoload; use CoenJacobs\Mozart\Config\Package; +use Exception; class Mozart { @@ -92,7 +93,13 @@ public function getDeleteVendorDirectories(): bool public function getDependencyNamespace(): string { - return $this->dep_namespace; + $namespace = preg_replace("/\\\{2,}$/", "\\", $this->dep_namespace."\\"); + + if (empty($namespace)) { + throw new Exception('Could not get target dependency namespace'); + } + + return $namespace; } public function getClassmapPrefix(): string diff --git a/src/Config/Package.php b/src/Config/Package.php index d78a8c93..abf464a5 100644 --- a/src/Config/Package.php +++ b/src/Config/Package.php @@ -40,9 +40,7 @@ public function __construct($path, $overrideAutoload = null) $this->path = $path; if (isset($overrideAutoload)) { - $autoload = new Autoload(); - $autoload->setupAutoloaders($overrideAutoload); - $this->set('autoload', $autoload); + $this->setAutoload($overrideAutoload); } } diff --git a/src/Console/Commands/Compose.php b/src/Console/Commands/Compose.php index 0ac68fb9..cb1cb0cd 100644 --- a/src/Console/Commands/Compose.php +++ b/src/Console/Commands/Compose.php @@ -67,11 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $this->config = $config; - $this->config->set('dep_namespace', preg_replace( - "/\\\{2,}$/", - "\\", - $this->config->getDependencyNamespace()."\\" - )); $require = $this->config->getPackages(); if (empty($require)) {