@@ -23,7 +23,7 @@ class SuiteObjectHandler implements ObjectHandlerInterface
23
23
*
24
24
* @var SuiteObjectHandler
25
25
*/
26
- private static $ SUITE_OBJECT_HANLDER_INSTANCE ;
26
+ private static $ instance ;
27
27
28
28
/**
29
29
* Array of suite objects keyed by suite name.
@@ -33,11 +33,17 @@ class SuiteObjectHandler implements ObjectHandlerInterface
33
33
private $ suiteObjects ;
34
34
35
35
/**
36
- * SuiteObjectHandler constructor .
36
+ * Avoids instantiation of SuiteObjectHandler by new .
37
37
*/
38
38
private function __construct ()
39
39
{
40
- // empty constructor
40
+ }
41
+
42
+ /**
43
+ * Avoids instantiation of SuiteObjectHandler by clone.
44
+ */
45
+ private function __clone ()
46
+ {
41
47
}
42
48
43
49
/**
@@ -46,14 +52,14 @@ private function __construct()
46
52
* @return ObjectHandlerInterface
47
53
* @throws XmlException
48
54
*/
49
- public static function getInstance ()
55
+ public static function getInstance (): ObjectHandlerInterface
50
56
{
51
- if (self ::$ SUITE_OBJECT_HANLDER_INSTANCE == null ) {
52
- self ::$ SUITE_OBJECT_HANLDER_INSTANCE = new SuiteObjectHandler ();
53
- self ::$ SUITE_OBJECT_HANLDER_INSTANCE ->initSuiteData ();
57
+ if (self ::$ instance == null ) {
58
+ self ::$ instance = new SuiteObjectHandler ();
59
+ self ::$ instance ->initSuiteData ();
54
60
}
55
61
56
- return self ::$ SUITE_OBJECT_HANLDER_INSTANCE ;
62
+ return self ::$ instance ;
57
63
}
58
64
59
65
/**
@@ -62,7 +68,7 @@ public static function getInstance()
62
68
* @param string $objectName
63
69
* @return SuiteObject
64
70
*/
65
- public function getObject ($ objectName )
71
+ public function getObject ($ objectName ): SuiteObject
66
72
{
67
73
if (!array_key_exists ($ objectName , $ this ->suiteObjects )) {
68
74
trigger_error ("Suite $ {objectName} is not defined. " , E_USER_ERROR );
@@ -75,7 +81,7 @@ public function getObject($objectName)
75
81
*
76
82
* @return array
77
83
*/
78
- public function getAllObjects ()
84
+ public function getAllObjects (): array
79
85
{
80
86
return $ this ->suiteObjects ;
81
87
}
@@ -85,7 +91,7 @@ public function getAllObjects()
85
91
*
86
92
* @return array
87
93
*/
88
- public function getAllTestReferences ()
94
+ public function getAllTestReferences (): array
89
95
{
90
96
$ testsReferencedInSuites = [];
91
97
$ suites = $ this ->getAllObjects ();
0 commit comments