diff --git a/app/Config/Publisher.php b/app/Config/Publisher.php index 47475112c080..bf03be1db7e0 100644 --- a/app/Config/Publisher.php +++ b/app/Config/Publisher.php @@ -19,7 +19,7 @@ class Publisher extends BasePublisher * result in a PublisherException. Files that do no fit the * pattern will cause copy/merge to fail. * - * @var array + * @var array */ public $restrictions = [ ROOTPATH => '*', diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php index 05fcc9b2e715..e3821c1df27e 100644 --- a/system/Autoloader/FileLocator.php +++ b/system/Autoloader/FileLocator.php @@ -119,6 +119,10 @@ public function locateFile(string $file, ?string $folder = null, string $ext = ' */ public function getClassname(string $file): string { + if (is_dir($file)) { + return ''; + } + $php = file_get_contents($file); $tokens = token_get_all($php); $dlm = false; diff --git a/system/Config/Publisher.php b/system/Config/Publisher.php index fa04e24cd28f..d5f938e09be3 100644 --- a/system/Config/Publisher.php +++ b/system/Config/Publisher.php @@ -26,7 +26,7 @@ class Publisher extends BaseConfig * result in a PublisherException. Files that do no fit the * pattern will cause copy/merge to fail. * - * @var array + * @var array */ public $restrictions = [ ROOTPATH => '*', diff --git a/system/Config/Routing.php b/system/Config/Routing.php index 409bcf099f65..e6d25138f8f0 100644 --- a/system/Config/Routing.php +++ b/system/Config/Routing.php @@ -24,7 +24,7 @@ class Routing extends BaseConfig * Default: APPPATH . 'Config/Routes.php' */ public array $routeFiles = [ - APPPATH . 'Routes.php', + APPPATH . 'Config/Routes.php', ]; /** @@ -95,4 +95,17 @@ class Routing extends BaseConfig * Default: false */ public bool $prioritize = false; + + /** + * Map of URI segments and namespaces. For Auto Routing (Improved). + * + * The key is the first URI segment. The value is the controller namespace. + * E.g., + * [ + * 'blog' => 'Acme\Blog\Controllers', + * ] + * + * @var array [ uri_segment => namespace ] + */ + public array $moduleRoutes = []; } diff --git a/tests/system/Autoloader/FileLocatorTest.php b/tests/system/Autoloader/FileLocatorTest.php index 14c512493d26..53d8e8f2e6eb 100644 --- a/tests/system/Autoloader/FileLocatorTest.php +++ b/tests/system/Autoloader/FileLocatorTest.php @@ -313,4 +313,12 @@ public function testGetClassNameFromNonClassFile(): void $this->locator->getClassname(SYSTEMPATH . 'bootstrap.php') ); } + + public function testGetClassNameFromDirectory(): void + { + $this->assertSame( + '', + $this->locator->getClassname(SYSTEMPATH) + ); + } }