3
3
4
4
namespace PTS \SymfonyDiLoader ;
5
5
6
+ use RuntimeException ;
6
7
use Symfony \Component \Config \FileLocator ;
7
8
use Symfony \Component \DependencyInjection \ContainerBuilder ;
8
9
use Symfony \Component \DependencyInjection \ContainerInterface ;
9
10
use Symfony \Component \DependencyInjection \Dumper \PhpDumper ;
10
- use Symfony \Component \DependencyInjection \Exception \EnvParameterException ;
11
11
use Symfony \Component \DependencyInjection \Extension \ExtensionInterface ;
12
12
use Symfony \Component \DependencyInjection \Loader \YamlFileLoader ;
13
+ use Throwable ;
13
14
14
15
class LoaderContainer implements LoaderContainerInterface
15
16
{
16
- /** @var array */
17
- protected $ configFiles = [];
18
-
19
- /** @var FactoryContainer */
20
- protected $ factory ;
21
- /** @var ContainerInterface */
22
- protected $ container ;
23
- /** @var CacheWatcher */
24
- protected $ cacheWatcher ;
17
+ /** @var string[] */
18
+ protected array $ configFiles = [];
19
+
20
+ protected FactoryContainer $ factory ;
21
+ protected ?ContainerInterface $ container = null ;
22
+ protected CacheWatcher $ cacheWatcher ;
25
23
/** @var ExtensionInterface[] */
26
- protected $ extensions = [];
24
+ protected array $ extensions = [];
27
25
28
- /** @var string */
29
- protected $ cacheFile = '' ;
30
- /** @var bool */
31
- protected $ checkExpired = true ;
26
+ protected string $ cacheFile = '' ;
27
+ protected bool $ checkExpired = true ;
32
28
33
- /** @var string */
34
- protected $ classContainer = 'AppContainer ' ;
29
+ protected string $ classContainer = 'AppContainer ' ;
35
30
36
31
/**
37
32
* @param string[] $configFiles
@@ -58,10 +53,6 @@ public function setCheckExpired(bool $checkExpired = true): self
58
53
return $ this ;
59
54
}
60
55
61
- /**
62
- * @return ContainerInterface
63
- * @throws \Exception
64
- */
65
56
public function getContainer (): ContainerInterface
66
57
{
67
58
if ($ this ->container === null ) {
@@ -94,18 +85,11 @@ protected function dumpMeta(string $filePath, array $configFiles): void
94
85
{
95
86
try {
96
87
file_put_contents ($ filePath , serialize ($ configFiles ));
97
- } catch (\ Throwable $ throwable ) {
98
- throw new \ RuntimeException ('Can`t dump meta for DI container ' , 0 , $ throwable );
88
+ } catch (Throwable $ throwable ) {
89
+ throw new RuntimeException ('Can`t dump meta for DI container ' , 0 , $ throwable );
99
90
}
100
91
}
101
92
102
- /**
103
- * @param string $filePath
104
- * @param string $className
105
- * @param ContainerBuilder $container
106
- *
107
- * @throws EnvParameterException
108
- */
109
93
protected function dump (string $ filePath , string $ className , ContainerBuilder $ container ): void
110
94
{
111
95
$ dumper = new PhpDumper ($ container );
@@ -114,8 +98,8 @@ protected function dump(string $filePath, string $className, ContainerBuilder $c
114
98
file_put_contents ($ filePath , $ dumper ->dump ([
115
99
'class ' => $ className ,
116
100
]));
117
- } catch (\ Throwable $ throwable ) {
118
- throw new \ RuntimeException ('Can`t dump cache for DI container ' , 0 , $ throwable );
101
+ } catch (Throwable $ throwable ) {
102
+ throw new RuntimeException ('Can`t dump cache for DI container ' , 0 , $ throwable );
119
103
}
120
104
}
121
105
0 commit comments