Skip to content

Commit c83e423

Browse files
committed
Cleanup for SuiteObjectHandler class
1 parent d383edd commit c83e423

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/Magento/FunctionalTestingFramework/Suite/Handlers/SuiteObjectHandler.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SuiteObjectHandler implements ObjectHandlerInterface
2323
*
2424
* @var SuiteObjectHandler
2525
*/
26-
private static $SUITE_OBJECT_HANLDER_INSTANCE;
26+
private static $instance;
2727

2828
/**
2929
* Array of suite objects keyed by suite name.
@@ -33,11 +33,17 @@ class SuiteObjectHandler implements ObjectHandlerInterface
3333
private $suiteObjects;
3434

3535
/**
36-
* SuiteObjectHandler constructor.
36+
* Avoids instantiation of SuiteObjectHandler by new.
3737
*/
3838
private function __construct()
3939
{
40-
// empty constructor
40+
}
41+
42+
/**
43+
* Avoids instantiation of SuiteObjectHandler by clone.
44+
*/
45+
private function __clone()
46+
{
4147
}
4248

4349
/**
@@ -46,14 +52,14 @@ private function __construct()
4652
* @return ObjectHandlerInterface
4753
* @throws XmlException
4854
*/
49-
public static function getInstance()
55+
public static function getInstance(): ObjectHandlerInterface
5056
{
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();
5460
}
5561

56-
return self::$SUITE_OBJECT_HANLDER_INSTANCE;
62+
return self::$instance;
5763
}
5864

5965
/**
@@ -62,7 +68,7 @@ public static function getInstance()
6268
* @param string $objectName
6369
* @return SuiteObject
6470
*/
65-
public function getObject($objectName)
71+
public function getObject($objectName): SuiteObject
6672
{
6773
if (!array_key_exists($objectName, $this->suiteObjects)) {
6874
trigger_error("Suite ${objectName} is not defined.", E_USER_ERROR);
@@ -75,7 +81,7 @@ public function getObject($objectName)
7581
*
7682
* @return array
7783
*/
78-
public function getAllObjects()
84+
public function getAllObjects(): array
7985
{
8086
return $this->suiteObjects;
8187
}
@@ -85,7 +91,7 @@ public function getAllObjects()
8591
*
8692
* @return array
8793
*/
88-
public function getAllTestReferences()
94+
public function getAllTestReferences(): array
8995
{
9096
$testsReferencedInSuites = [];
9197
$suites = $this->getAllObjects();

0 commit comments

Comments
 (0)