32
32
*/
33
33
abstract class TestKernel extends Kernel
34
34
{
35
- protected $ bundleSets = [];
35
+ protected array $ bundleSets = [];
36
36
37
- protected $ requiredBundles = [];
37
+ protected array $ requiredBundles = [];
38
38
39
39
/**
40
40
* Register commonly needed bundle sets and then
41
41
* after initializing the parent kernel, let the
42
42
* concrete kernel configure itself using the abstracvt
43
43
* configure() command.
44
44
*/
45
- public function __construct ($ env , $ debug )
45
+ public function __construct (string $ env , bool $ debug )
46
46
{
47
47
$ defaultBundles = [
48
48
FrameworkBundle::class,
@@ -72,23 +72,25 @@ public function __construct($env, $debug)
72
72
* $this->addBundle(new MyBundle);
73
73
* $this->addBundles(array(new Bundle1, new Bundle2));
74
74
*/
75
- abstract protected function configure ();
75
+ abstract protected function configure (): void ;
76
76
77
77
/**
78
78
* Register a set of bundles with the given name.
79
79
*
80
80
* This method does not add the bundles to the kernel,
81
81
* it just makes a set available.
82
82
*/
83
- public function registerBundleSet ($ name , $ bundles )
83
+ public function registerBundleSet (string $ name , array $ bundles ): void
84
84
{
85
85
$ this ->bundleSets [$ name ] = $ bundles ;
86
86
}
87
87
88
88
/**
89
89
* The bundles in the named sets will be added to the Kernel.
90
+ *
91
+ * @param string[] $names
90
92
*/
91
- public function requireBundleSets (array $ names )
93
+ public function requireBundleSets (array $ names ): void
92
94
{
93
95
foreach ($ names as $ name ) {
94
96
$ this ->requireBundleSet ($ name );
@@ -102,7 +104,7 @@ public function requireBundleSets(array $names)
102
104
* This enables us to declare pre-defined bundle sets without
103
105
* worrying if the bundle is actually present or not.
104
106
*/
105
- public function requireBundleSet ($ name )
107
+ public function requireBundleSet (string $ name ): void
106
108
{
107
109
if (!isset ($ this ->bundleSets [$ name ])) {
108
110
throw new \InvalidArgumentException (sprintf (
@@ -127,7 +129,7 @@ public function requireBundleSet($name)
127
129
/**
128
130
* Add concrete bundles to the kernel.
129
131
*/
130
- public function addBundles (array $ bundles )
132
+ public function addBundles (array $ bundles ): void
131
133
{
132
134
foreach ($ bundles as $ bundle ) {
133
135
$ this ->addBundle ($ bundle );
@@ -137,7 +139,7 @@ public function addBundles(array $bundles)
137
139
/**
138
140
* Add a concrete bundle to the kernel.
139
141
*/
140
- public function addBundle (BundleInterface $ bundle )
142
+ public function addBundle (BundleInterface $ bundle ): void
141
143
{
142
144
$ this ->requiredBundles [] = $ bundle ;
143
145
}
@@ -153,28 +155,22 @@ public function registerBundles(): iterable
153
155
}
154
156
155
157
/**
156
- * Returns the KernelDir of the CHILD class,
158
+ * Returns the project directory of the CHILD class,
157
159
* i.e. the concrete implementation in the bundles
158
160
* src/ directory (or wherever).
159
161
*/
160
- public function getKernelDir ()
161
- {
162
- return $ this ->getProjectDir ();
163
- }
164
-
165
162
public function getProjectDir (): string
166
163
{
167
164
$ refl = new \ReflectionClass ($ this );
168
165
$ fname = $ refl ->getFileName ();
169
- $ kernelDir = \dirname ($ fname );
170
166
171
- return $ kernelDir ;
167
+ return \dirname ( $ fname ) ;
172
168
}
173
169
174
170
public function getCacheDir (): string
175
171
{
176
172
return implode ('/ ' , [
177
- $ this ->getKernelDir (),
173
+ $ this ->getProjectDir (),
178
174
'var ' ,
179
175
'cache ' ,
180
176
]);
@@ -192,7 +188,7 @@ public function getLogDir(): string
192
188
/**
193
189
* Registers the bundles defined in config/bundles.php.
194
190
*/
195
- protected function registerConfiguredBundles ()
191
+ protected function registerConfiguredBundles (): void
196
192
{
197
193
$ bundleFilePath = $ this ->getKernelDir ().'/config/bundles.php ' ;
198
194
if (!file_exists ($ bundleFilePath )) {
0 commit comments