1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of Biurad opensource projects. |
||
7 | * |
||
8 | * PHP version 7.2 and above required |
||
9 | * |
||
10 | * @author Divine Niiquaye Ibok <[email protected]> |
||
11 | * @copyright 2019 Biurad Group (https://biurad.com/) |
||
12 | * @license https://opensource.org/licenses/BSD-3-Clause License |
||
13 | * |
||
14 | * For the full copyright and license information, please view the LICENSE |
||
15 | * file that was distributed with this source code. |
||
16 | */ |
||
17 | |||
18 | namespace Biurad\DependencyInjection; |
||
19 | |||
20 | use Nette; |
||
21 | use Nette\Bridges\DITracy\ContainerPanel as DITracyContainerPanel; |
||
22 | use ReflectionClass; |
||
23 | use Tracy; |
||
0 ignored issues
–
show
|
|||
24 | |||
25 | /** |
||
26 | * Dependency injection container panel for Debugger Bar. |
||
27 | */ |
||
28 | class ContainerPanel implements Tracy\IBarPanel |
||
0 ignored issues
–
show
The type
Tracy\IBarPanel was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
29 | { |
||
30 | use Nette\SmartObject; |
||
31 | |||
32 | /** @var null|float */ |
||
33 | public static $compilationTime; |
||
34 | |||
35 | /** @var Nette\DI\Container */ |
||
36 | private $container; |
||
37 | |||
38 | /** @var null|float */ |
||
39 | private $elapsedTime; |
||
40 | |||
41 | /** @var string */ |
||
42 | private $diPath; |
||
43 | |||
44 | public function __construct(Container $container) |
||
45 | { |
||
46 | $this->container = $container; |
||
47 | $this->elapsedTime = self::$compilationTime ? \microtime(true) - self::$compilationTime : null; |
||
48 | $this->diPath = \dirname((new ReflectionClass(DITracyContainerPanel::class))->getFileName()); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Renders tab. |
||
53 | */ |
||
54 | public function getTab(): string |
||
55 | { |
||
56 | return Nette\Utils\Helpers::capture(function (): void { |
||
57 | $elapsedTime = $this->elapsedTime; |
||
58 | |||
59 | require $this->diPath . '/templates/ContainerPanel.tab.phtml'; |
||
60 | }); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Renders panel. |
||
65 | */ |
||
66 | public function getPanel(): string |
||
67 | { |
||
68 | $rc = new ReflectionClass($this->container); |
||
69 | $tags = []; |
||
70 | $types = []; |
||
71 | |||
72 | foreach ($rc->getMethods() as $method) { |
||
73 | if (\preg_match('#^createService(.+)#', $method->name, $m) && $method->getReturnType()) { |
||
74 | $types[\lcfirst(\str_replace('__', '.', $m[1]))] = $method->getReturnType()->getName(); |
||
75 | } |
||
76 | } |
||
77 | $types = $this->getContainerProperty('types') + $types; |
||
78 | \ksort($types); |
||
79 | |||
80 | foreach ($this->getContainerProperty('tags') as $tag => $tmp) { |
||
81 | foreach ($tmp as $service => $val) { |
||
82 | $tags[$service][$tag] = $val; |
||
83 | } |
||
84 | } |
||
85 | |||
86 | return Nette\Utils\Helpers::capture(function () use ($tags, $types, $rc): void { |
||
87 | $container = $this->container; |
||
88 | $file = $rc->getFileName(); |
||
89 | $instances = $this->getContainerProperty('instances'); |
||
90 | $wiring = $this->getContainerProperty('wiring'); |
||
91 | |||
92 | require $this->diPath . '/templates/ContainerPanel.panel.phtml'; |
||
93 | }); |
||
94 | } |
||
95 | |||
96 | private function getContainerProperty(string $name) |
||
97 | { |
||
98 | $prop = (new ReflectionClass(Container::class))->getProperty($name); |
||
99 | $prop->setAccessible(true); |
||
100 | |||
101 | return $prop->getValue($this->container); |
||
102 | } |
||
103 | } |
||
104 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths