1 | <?php |
||
14 | class Bootstrap |
||
15 | { |
||
16 | protected static $serviceManager; |
||
17 | protected static $config; |
||
18 | |||
19 | public static function init() |
||
20 | { |
||
21 | // Load the user-defined test configuration file, if it exists; otherwise, load |
||
22 | if (is_readable(__DIR__ . '/TestConfig.php')) { |
||
23 | $testConfig = include __DIR__ . '/TestConfig.php'; |
||
24 | } else { |
||
25 | $testConfig = include __DIR__ . '/TestConfig.php.dist'; |
||
26 | } |
||
27 | |||
28 | $zf2ModulePaths = array(); |
||
29 | |||
30 | if (isset($testConfig['module_listener_options']['module_paths'])) { |
||
31 | $modulePaths = $testConfig['module_listener_options']['module_paths']; |
||
32 | foreach ($modulePaths as $modulePath) { |
||
33 | if (($path = static::findParentPath($modulePath))) { |
||
34 | $zf2ModulePaths[] = $path; |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | |||
39 | $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR; |
||
40 | $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : ''); |
||
41 | |||
42 | static::initAutoloader(); |
||
43 | |||
44 | // use ModuleManager to load this module and it's dependencies |
||
45 | $baseConfig = array( |
||
46 | 'module_listener_options' => array( |
||
47 | 'module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths), |
||
48 | ), |
||
49 | ); |
||
50 | |||
51 | $config = ArrayUtils::merge($baseConfig, $testConfig); |
||
52 | |||
53 | $serviceManager = new ServiceManager(new ServiceManagerConfig()); |
||
54 | $serviceManager->setService('ApplicationConfig', $config); |
||
55 | $serviceManager->get('ModuleManager')->loadModules(); |
||
56 | |||
57 | static::$serviceManager = $serviceManager; |
||
58 | static::$config = $config; |
||
59 | } |
||
60 | |||
61 | public static function getServiceManager() |
||
65 | |||
66 | public static function getConfig() |
||
70 | |||
71 | protected static function initAutoloader() |
||
97 | |||
98 | protected static function findParentPath($path) |
||
111 | } |
||
112 | |||
114 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.