1 | <?php |
||
13 | class Kernel |
||
14 | { |
||
15 | public const VERSION = '1.1.0'; |
||
16 | |||
17 | /** @var Kernel */ |
||
18 | private static $instance; |
||
19 | |||
20 | private $container; |
||
21 | |||
22 | private $driver; |
||
23 | private $channel; |
||
24 | private $session; |
||
25 | |||
26 | private function __construct(Container $container) |
||
30 | |||
31 | public static function getInstance(): Kernel |
||
35 | |||
36 | public static function createInstance(Container $container): Kernel |
||
40 | |||
41 | /** |
||
42 | * Get current channel. |
||
43 | * |
||
44 | * @return Channel|null |
||
45 | */ |
||
46 | public function getChannel(): ?Channel |
||
50 | |||
51 | /** |
||
52 | * Set channel. |
||
53 | * |
||
54 | * @param Channel $channel |
||
55 | */ |
||
56 | public function setChannel(Channel $channel): void |
||
60 | |||
61 | /** |
||
62 | * Get current driver. |
||
63 | * |
||
64 | * @return Driver|null |
||
65 | */ |
||
66 | public function getDriver(): ?Driver |
||
70 | |||
71 | /** |
||
72 | * Set driver. |
||
73 | * |
||
74 | * @param Driver $driver |
||
75 | */ |
||
76 | public function setDriver(Driver $driver): void |
||
80 | |||
81 | /** |
||
82 | * Get session. |
||
83 | * |
||
84 | * @return Session|null |
||
85 | */ |
||
86 | public function getSession(): ?Session |
||
90 | |||
91 | /** |
||
92 | * Set session. |
||
93 | * |
||
94 | * @param Session $session |
||
95 | */ |
||
96 | public function setSession(Session $session): void |
||
100 | |||
101 | /** |
||
102 | * Load session. |
||
103 | * |
||
104 | * @param Channel $channel |
||
105 | * @param Driver $driver |
||
106 | */ |
||
107 | public function loadSession(Channel $channel, Driver $driver): void |
||
111 | |||
112 | /** |
||
113 | * Save session. |
||
114 | */ |
||
115 | public function saveSession(): void |
||
121 | |||
122 | /** |
||
123 | * Close session. |
||
124 | * |
||
125 | * @throws \Psr\Container\ContainerExceptionInterface |
||
126 | */ |
||
127 | public function closeSession(): void |
||
134 | |||
135 | /** |
||
136 | * Resolve an alias from container. |
||
137 | * |
||
138 | * @param string $alias |
||
139 | * @param array $args |
||
140 | * |
||
141 | * @return mixed |
||
142 | * |
||
143 | * @throws \Psr\Container\ContainerExceptionInterface |
||
144 | */ |
||
145 | public function resolve(string $alias, array $args = []) |
||
149 | |||
150 | /** |
||
151 | * Get session manager. |
||
152 | * |
||
153 | * @return SessionManager |
||
154 | * |
||
155 | * @throws \Psr\Container\ContainerExceptionInterface |
||
156 | */ |
||
157 | private function sessionManager(): SessionManager |
||
161 | } |
||
162 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: