• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 11319238494

13 Oct 2024 12:13PM UTC coverage: 82.008% (-0.09%) from 82.1%
11319238494

push

github

web-flow
fix: view argument casing (#585)

4 of 4 new or added lines in 1 file covered. (100.0%)

30 existing lines in 5 files now uncovered.

6764 of 8248 relevant lines covered (82.01%)

39.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
/src/Tempest/Core/src/Kernel.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Core;
6

7
use Dotenv\Dotenv;
8
use Tempest\Container\Container;
9
use Tempest\Container\GenericContainer;
10
use Tempest\Core\Kernel\LoadConfig;
11
use Tempest\Core\Kernel\LoadDiscoveryClasses;
12
use Tempest\Core\Kernel\LoadDiscoveryLocations;
13
use Tempest\EventBus\EventBus;
14

15
final class Kernel
16
{
17
    public readonly Container $container;
18

19
    public bool $discoveryCache;
20

21
    public array $discoveryClasses = [
22
        DiscoveryDiscovery::class,
23
    ];
24

25
    public function __construct(
278✔
26
        public readonly string $root,
27
        public array $discoveryLocations = [],
28
        ?Container $container = null,
29
    ) {
30
        $this->container = $container ?? $this->createContainer();
278✔
31

32
        $this
278✔
33
            ->loadEnv()
278✔
34
            ->registerShutdownFunction()
278✔
35
            ->registerKernel()
278✔
36
            ->loadComposer()
278✔
37
            ->loadDiscoveryLocations()
278✔
38
            ->loadConfig()
278✔
39
            ->loadExceptionHandler()
278✔
40
            ->loadDiscovery()
278✔
41
            ->event(KernelEvent::BOOTED);
278✔
42
    }
43

UNCOV
44
    public static function boot(string $root, ?Container $container = null): self
×
45
    {
UNCOV
46
        return new self(
×
47
            root: $root,
×
UNCOV
48
            container: $container,
×
49
        );
×
50
    }
51

52
    private function createContainer(): Container
278✔
53
    {
54
        $container = new GenericContainer();
278✔
55

56
        GenericContainer::setInstance($container);
278✔
57

58
        $container->singleton(Container::class, fn () => $container);
278✔
59

60
        return $container;
278✔
61
    }
62

63
    private function loadComposer(): self
278✔
64
    {
65
        $this->container->singleton(Composer::class, new Composer($this->root));
278✔
66

67
        return $this;
278✔
68
    }
69

70
    private function loadEnv(): self
278✔
71
    {
72
        $dotenv = Dotenv::createUnsafeImmutable($this->root);
278✔
73
        $dotenv->safeLoad();
278✔
74

75
        return $this;
278✔
76
    }
77

78
    private function registerKernel(): self
278✔
79
    {
80
        $this->container->singleton(self::class, $this);
278✔
81

82
        return $this;
278✔
83
    }
84

85
    private function registerShutdownFunction(): self
278✔
86
    {
87
        // Fix for classes that don't have a proper PSR-4 namespace,
88
        // they break discovery with an unrecoverable error,
89
        // but you don't know why because PHP simply says "duplicate classname" instead of something reasonable.
90
        register_shutdown_function(function (): void {
278✔
UNCOV
91
            $error = error_get_last();
×
92

UNCOV
93
            $message = $error['message'] ?? '';
×
94

UNCOV
95
            if (str_contains($message, 'Cannot declare class')) {
×
UNCOV
96
                echo "Does this class have the right namespace?" . PHP_EOL;
×
97
            }
98
        });
278✔
99

100
        return $this;
278✔
101
    }
102

103
    private function loadDiscoveryLocations(): self
278✔
104
    {
105
        ($this->container->get(LoadDiscoveryLocations::class))();
278✔
106

107
        return $this;
278✔
108
    }
109

110
    private function loadDiscovery(): self
278✔
111
    {
112
        ($this->container->get(LoadDiscoveryClasses::class))();
278✔
113

114
        return $this;
278✔
115
    }
116

117
    private function loadConfig(): self
278✔
118
    {
119
        $this->container->get(LoadConfig::class)();
278✔
120

121
        return $this;
278✔
122
    }
123

124
    private function loadExceptionHandler(): self
278✔
125
    {
126
        $appConfig = $this->container->get(AppConfig::class);
278✔
127

128
        $appConfig->exceptionHandlerSetup->setup($appConfig);
278✔
129

130
        return $this;
278✔
131
    }
132

133
    private function event(object $event): self
278✔
134
    {
135
        if (interface_exists(EventBus::class)) {
278✔
136
            $this->container->get(EventBus::class)->dispatch($event);
278✔
137
        }
138

139
        return $this;
278✔
140
    }
141
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc