From 535405241324aa387fcce24bee6e993f77f08156 Mon Sep 17 00:00:00 2001 From: Cole Thorsen <959538+colethorsen@users.noreply.github.com> Date: Tue, 14 Nov 2023 12:47:14 -0800 Subject: [PATCH 1/4] fix issue where running getClassName on a directory would cause a PHP error --- system/Autoloader/FileLocator.php | 4 ++++ tests/system/Autoloader/FileLocatorTest.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php index 744567a3bcc0..7cd2a5e60135 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/tests/system/Autoloader/FileLocatorTest.php b/tests/system/Autoloader/FileLocatorTest.php index 1cf32cfa5ad1..8df13094ef7a 100644 --- a/tests/system/Autoloader/FileLocatorTest.php +++ b/tests/system/Autoloader/FileLocatorTest.php @@ -312,4 +312,12 @@ public function testGetClassNameFromNonClassFile(): void $this->locator->getClassname(SYSTEMPATH . 'bootstrap.php') ); } + + public function testGetClassNameFromDirectory(): void + { + $this->assertSame( + '', + $this->locator->getClassname(SYSTEMPATH) + ); + } } From 3ba7ef65cd6d1b5dca7b97bc1b93d95a4139c9ab Mon Sep 17 00:00:00 2001 From: Cole Thorsen <959538+colethorsen@users.noreply.github.com> Date: Wed, 15 Nov 2023 07:51:19 -0800 Subject: [PATCH 2/4] fix style --- system/Autoloader/FileLocator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php index 7cd2a5e60135..92381a7ee25b 100644 --- a/system/Autoloader/FileLocator.php +++ b/system/Autoloader/FileLocator.php @@ -119,7 +119,7 @@ public function locateFile(string $file, ?string $folder = null, string $ext = ' */ public function getClassname(string $file): string { - if(is_dir($file)) { + if (is_dir($file)) { return ''; } From 7c0024a10002b3d0532ea4a03ac8a6cf5a49c06e Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 19 Nov 2023 09:42:07 +0900 Subject: [PATCH 3/4] docs: add space after comma --- app/Config/Publisher.php | 2 +- system/Config/Publisher.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 => '*', From ad6e3e141b6201788cce9b0d351411bf47e19669 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 19 Nov 2023 09:42:30 +0900 Subject: [PATCH 4/4] config: update system/Config/Routing This should be the same as Config\Routing. --- system/Config/Routing.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 = []; }