Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Sep 4, 2024
1 parent 92c1520 commit 109aa69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/Tempest/Core/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ public function __construct(

public function init(): Container
{
register_shutdown_function(function (): void {
$error = error_get_last();

$message = $error['message'] ?? '';

if (str_contains($message, 'Cannot declare class')) {
echo "Does this class have the right namespace?" . PHP_EOL;
}
});

$container = $this->createContainer();

$bootstraps = [
Expand Down
13 changes: 13 additions & 0 deletions src/Tempest/Core/Tempest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
{
public static function boot(?string $root = null, ?AppConfig $appConfig = null): Container
{
// Fix for classes that don't have a proper PSR-4 namespace,
// they break discovery with an unrecoverable error,
// but you don't know why because PHP simply says "duplicate classname" instead of something reasonable.
register_shutdown_function(function (): void {
$error = error_get_last();

$message = $error['message'] ?? '';

if (str_contains($message, 'Cannot declare class')) {
echo "Does this class have the right namespace?" . PHP_EOL;
}
});

$root ??= getcwd();

// Env
Expand Down

0 comments on commit 109aa69

Please sign in to comment.