Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ContainerRegistry
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 set
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 reset
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * Process-wide registry for the Kernel's shared DI container
5 *
6 * The Kernel registers its container here on boot so that controllers can reuse it
7 * during construction instead of parsing services.php into a private fallback
8 * container — which used to happen once per controller instantiation.
9 *
10 * This Source Code Form is subject to the terms of the Mozilla Public License,
11 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
12 * obtain one at https://mozilla.org/MPL/2.0/.
13 *
14 * @package   phpMyFAQ
15 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
16 * @copyright 2026 phpMyFAQ Team
17 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
18 * @link      https://www.phpmyfaq.de
19 * @since     2026-07-14
20 */
21
22declare(strict_types=1);
23
24namespace phpMyFAQ\Container;
25
26use Symfony\Component\DependencyInjection\ContainerInterface;
27
28final class ContainerRegistry
29{
30    private static ?ContainerInterface $container = null;
31
32    public static function set(ContainerInterface $container): void
33    {
34        self::$container = $container;
35    }
36
37    public static function get(): ?ContainerInterface
38    {
39        return self::$container;
40    }
41
42    public static function reset(): void
43    {
44        self::$container = null;
45    }
46}