From 677cf3b1db0251a519c254fcd163c8b9da2e10ac Mon Sep 17 00:00:00 2001 From: Brent Roose Date: Tue, 19 Nov 2024 12:33:31 +0100 Subject: [PATCH] chore(core): setup fixes (#749) --- src/Tempest/Core/src/Composer.php | 4 ---- src/Tempest/Core/src/Environment.php | 2 +- src/Tempest/Core/src/Kernel.php | 2 +- tests/Integration/Core/ComposerTest.php | 7 ------- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Tempest/Core/src/Composer.php b/src/Tempest/Core/src/Composer.php index e504e6a2a..b796757e6 100644 --- a/src/Tempest/Core/src/Composer.php +++ b/src/Tempest/Core/src/Composer.php @@ -39,10 +39,6 @@ public function __construct( if (! isset($this->mainNamespace) && count($this->namespaces)) { $this->mainNamespace = $this->namespaces[0]; } - - if (! isset($this->mainNamespace)) { - throw new KernelException("Tempest requires at least one PSR-4 namespace to be defined in composer.json."); - } } public function setMainNamespace(ComposerNamespace $namespace): self diff --git a/src/Tempest/Core/src/Environment.php b/src/Tempest/Core/src/Environment.php index f401d790c..b352d9141 100644 --- a/src/Tempest/Core/src/Environment.php +++ b/src/Tempest/Core/src/Environment.php @@ -47,7 +47,7 @@ public function isOther(): bool public static function fromEnv(): self { - $value = env('ENVIRONMENT', 'production'); + $value = env('ENVIRONMENT', 'local'); return self::tryFrom($value) ?? throw new InvalidEnvironment($value); } diff --git a/src/Tempest/Core/src/Kernel.php b/src/Tempest/Core/src/Kernel.php index 46ad04eb8..4f88200cb 100644 --- a/src/Tempest/Core/src/Kernel.php +++ b/src/Tempest/Core/src/Kernel.php @@ -186,7 +186,7 @@ private function registerKernelErrorHandler(): self $handler = new HttpProductionErrorHandler(); set_exception_handler($handler->handleException(...)); set_error_handler($handler->handleError(...)); // @phpstan-ignore-line - } else { + } elseif (PHP_SAPI !== 'cli') { $whoops = new Run(); $whoops->pushHandler(new PrettyPageHandler()); $whoops->register(); diff --git a/tests/Integration/Core/ComposerTest.php b/tests/Integration/Core/ComposerTest.php index 25a6a3a6d..884c3bac5 100644 --- a/tests/Integration/Core/ComposerTest.php +++ b/tests/Integration/Core/ComposerTest.php @@ -92,13 +92,6 @@ public function takes_src_namespace_in_priority(): void $this->assertSame('src/', $composer->mainNamespace->path); } - #[Test] - public function errors_without_namespace(): void - { - $this->expectException(KernelException::class); - $this->initializeComposer([]); - } - #[Test] public function errors_without_composer_file(): void {