Skip to content

Commit e1b6729

Browse files
committed
Fix errors found by static test
1 parent f4d3015 commit e1b6729

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

lib/internal/Magento/Framework/Module/DependencyChecker.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ class DependencyChecker
1515
/**
1616
* @var PackageInfo
1717
*/
18-
protected $packageInfo;
18+
private $packageInfo;
1919

2020
/**
2121
* @var ModuleList
2222
*/
2323
private $list;
24+
2425
/**
2526
* @var ModuleList\Loader
2627
*/
@@ -46,6 +47,7 @@ public function __construct(ModuleList $list, ModuleList\Loader $loader, Package
4647
* @param string[] $toBeDisabledModules
4748
* @param string[] $currentlyEnabledModules
4849
* @return array
50+
* @throws \Magento\Framework\Exception\LocalizedException
4951
*/
5052
public function checkDependenciesWhenDisableModules($toBeDisabledModules, $currentlyEnabledModules = null)
5153
{
@@ -61,8 +63,9 @@ public function checkDependenciesWhenDisableModules($toBeDisabledModules, $curre
6163
* @param string[] $toBeEnabledModules
6264
* @param string[] $currentlyEnabledModules
6365
* @return array
66+
* @throws \Magento\Framework\Exception\LocalizedException
6467
*/
65-
public function checkDependenciesWhenEnableModules($toBeEnabledModules, $currentlyEnabledModules = null)
68+
public function checkDependenciesWhenEnableModules(array $toBeEnabledModules, array $currentlyEnabledModules = null)
6669
{
6770
$masterList = $currentlyEnabledModules ?? $this->list->getNames();
6871
// assume enable succeeds: union of currently enabled modules and to-be-enabled modules
@@ -79,19 +82,19 @@ public function checkDependenciesWhenEnableModules($toBeEnabledModules, $current
7982
* @return array
8083
* @throws \Magento\Framework\Exception\LocalizedException
8184
*/
82-
private function checkDependencyGraph($isEnable, $moduleNames, $enabledModules)
85+
private function checkDependencyGraph(bool $isEnable, array $moduleNames, array $enabledModules)
8386
{
8487
$fullModuleList = $this->loader->load();
8588
$graph = $this->createGraph($fullModuleList);
8689
$dependenciesMissingAll = [];
8790
$graphMode = $isEnable ? Graph::DIRECTIONAL : Graph::INVERSE;
91+
$modules = array_merge(
92+
array_keys($fullModuleList),
93+
$this->packageInfo->getNonExistingDependencies()
94+
);
8895
foreach ($moduleNames as $moduleName) {
8996
$dependenciesMissing = [];
9097
$paths = $graph->findPathsToReachableNodes($moduleName, $graphMode);
91-
$modules = array_merge(
92-
array_keys($fullModuleList),
93-
$this->packageInfo->getNonExistingDependencies()
94-
);
9598
foreach ($modules as $module) {
9699
if (isset($paths[$module])) {
97100
if ($isEnable && !in_array($module, $enabledModules)) {
@@ -112,7 +115,7 @@ private function checkDependencyGraph($isEnable, $moduleNames, $enabledModules)
112115
* @param array $fullModuleList
113116
* @return Graph
114117
*/
115-
private function createGraph($fullModuleList)
118+
private function createGraph(array $fullModuleList): Graph
116119
{
117120
$nodes = [];
118121
$dependencies = [];

lib/internal/Magento/Framework/Module/Test/Unit/DependencyCheckerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ protected function setUp()
4444
->method('getRequire')
4545
->will($this->returnValueMap($requireMap));
4646

47-
48-
4947
$this->listMock = $this->createMock(\Magento\Framework\Module\ModuleList::class);
5048
$this->loaderMock = $this->createMock(\Magento\Framework\Module\ModuleList\Loader::class);
5149
$this->loaderMock

setup/src/Magento/Setup/Model/ConfigOptionsListCollector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public function __construct(
7777

7878
/**
7979
* Auto discover ConfigOptionsList class and collect them.
80+
*
8081
* These classes should reside in <module>/Setup directories.
8182
*
8283
* @return \Magento\Framework\Setup\ConfigOptionsListInterface[]
@@ -86,7 +87,7 @@ public function collectOptionsLists()
8687
$optionsList = [];
8788

8889
$modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE);
89-
foreach ($modulePaths as $moduleName => $modulePath) {
90+
foreach (array_keys($modulePaths) as $moduleName) {
9091
$optionsClassName = str_replace('_', '\\', $moduleName) . '\Setup\ConfigOptionsList';
9192
if (class_exists($optionsClassName)) {
9293
$optionsClass = $this->objectManagerProvider->get()->create($optionsClassName);

0 commit comments

Comments
 (0)