24
24
*/
25
25
final class ExtensionHandler
26
26
{
27
- public function registerExtension (Extension $ extension , TestRunner $ runner ): void
27
+ public function registerExtension (Extension $ extensionConfiguration , TestRunner $ runner ): void
28
28
{
29
- $ object = $ this ->createInstance ($ extension );
29
+ $ extension = $ this ->createInstance ($ extensionConfiguration );
30
30
31
- if (!$ object instanceof Hook) {
31
+ if (!$ extension instanceof Hook) {
32
32
throw new Exception (
33
33
sprintf (
34
34
'Class "%s" does not implement a PHPUnit\Runner\Hook interface ' ,
35
- $ extension ->className ()
35
+ $ extensionConfiguration ->className ()
36
36
)
37
37
);
38
38
}
39
39
40
- $ runner ->addExtension ($ object );
40
+ $ runner ->addExtension ($ extension );
41
41
}
42
42
43
43
/**
44
44
* @deprecated
45
45
*/
46
- public function createTestListenerInstance (Extension $ extension ): TestListener
46
+ public function createTestListenerInstance (Extension $ listenerConfiguration ): TestListener
47
47
{
48
- $ object = $ this ->createInstance ($ extension );
48
+ $ listener = $ this ->createInstance ($ listenerConfiguration );
49
49
50
- if (!$ object instanceof TestListener) {
50
+ if (!$ listener instanceof TestListener) {
51
51
throw new Exception (
52
52
sprintf (
53
53
'Class "%s" does not implement the PHPUnit\Framework\TestListener interface ' ,
54
- $ extension ->className ()
54
+ $ listenerConfiguration ->className ()
55
55
)
56
56
);
57
57
}
58
58
59
- return $ object ;
59
+ return $ listener ;
60
60
}
61
61
62
- private function createInstance (Extension $ extension ): object
62
+ private function createInstance (Extension $ extensionConfiguration ): object
63
63
{
64
- $ this ->ensureClassExists ($ extension );
64
+ $ this ->ensureClassExists ($ extensionConfiguration );
65
65
66
66
try {
67
- $ reflector = new ReflectionClass ($ extension ->className ());
67
+ $ reflector = new ReflectionClass ($ extensionConfiguration ->className ());
68
68
} catch (ReflectionException $ e ) {
69
69
throw new Exception (
70
70
$ e ->getMessage (),
@@ -73,35 +73,35 @@ private function createInstance(Extension $extension): object
73
73
);
74
74
}
75
75
76
- if (!$ extension ->hasArguments ()) {
76
+ if (!$ extensionConfiguration ->hasArguments ()) {
77
77
return $ reflector ->newInstance ();
78
78
}
79
79
80
- return $ reflector ->newInstanceArgs ($ extension ->arguments ());
80
+ return $ reflector ->newInstanceArgs ($ extensionConfiguration ->arguments ());
81
81
}
82
82
83
83
/**
84
84
* @throws Exception
85
85
*/
86
- private function ensureClassExists (Extension $ extension ): void
86
+ private function ensureClassExists (Extension $ extensionConfiguration ): void
87
87
{
88
- if (class_exists ($ extension ->className (), false )) {
88
+ if (class_exists ($ extensionConfiguration ->className (), false )) {
89
89
return ;
90
90
}
91
91
92
- if ($ extension ->hasSourceFile ()) {
92
+ if ($ extensionConfiguration ->hasSourceFile ()) {
93
93
/**
94
94
* @noinspection PhpIncludeInspection
95
95
* @psalm-suppress UnresolvableInclude
96
96
*/
97
- require_once $ extension ->sourceFile ();
97
+ require_once $ extensionConfiguration ->sourceFile ();
98
98
}
99
99
100
- if (!class_exists ($ extension ->className ())) {
100
+ if (!class_exists ($ extensionConfiguration ->className ())) {
101
101
throw new Exception (
102
102
sprintf (
103
103
'Class "%s" does not exist ' ,
104
- $ extension ->className ()
104
+ $ extensionConfiguration ->className ()
105
105
)
106
106
);
107
107
}
0 commit comments