Skip to content

Commit 8913e2c

Browse files
author
Ivan Gavryshko
committed
MAGETWO-40176: Show redundant version when checking component dependency in Magento component manager
- changes according to CR
1 parent 447abb0 commit 8913e2c

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/InfoCommand.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
*/
1212
class InfoCommand
1313
{
14+
/**
15+
* Current version
16+
*/
17+
const CURRENT_VERSION = 'current_version';
18+
19+
const VERSIONS = 'versions';
20+
21+
/**
22+
* Available versions
23+
*/
24+
const AVAILABLE_VERSIONS = 'available_versions';
25+
26+
1427
/**
1528
* @var MagentoComposerApplication
1629
*/
@@ -71,20 +84,20 @@ public function run($package, $installed = false)
7184
*/
7285
private function extractVersions($packageInfo)
7386
{
74-
$versions = explode(', ', $packageInfo['versions']);
87+
$versions = explode(', ', $packageInfo[self::VERSIONS]);
7588

7689
if (count($versions) === 1) {
77-
$packageInfo['current_version'] = str_replace('* ', '', $packageInfo['versions']);
78-
$packageInfo['available_versions'] = [];
90+
$packageInfo[self::CURRENT_VERSION] = str_replace('* ', '', $packageInfo[self::VERSIONS]);
91+
$packageInfo[self::AVAILABLE_VERSIONS] = [];
7992
} else {
8093
$currentVersion = array_values(preg_grep("/^\*.*/", $versions));
8194
if ($currentVersion) {
82-
$packageInfo['current_version'] = str_replace('* ', '', $currentVersion[0]);
95+
$packageInfo[self::CURRENT_VERSION] = str_replace('* ', '', $currentVersion[0]);
8396
} else {
84-
$packageInfo['current_version'] = '';
97+
$packageInfo[self::CURRENT_VERSION] = '';
8598
}
8699

87-
$packageInfo['available_versions'] = array_values(preg_grep("/^\*.*/", $versions, PREG_GREP_INVERT));
100+
$packageInfo[self::AVAILABLE_VERSIONS] = array_values(preg_grep("/^\*.*/", $versions, PREG_GREP_INVERT));
88101
}
89102

90103
return $packageInfo;

src/RequireUpdateDryRunCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ protected function generateAdditionalErrorMessage($message, $inputPackages)
110110
return false;
111111
}
112112

113-
$currentVersion = $packageInfo['current_version'];
113+
$currentVersion = $packageInfo[InfoCommand::CURRENT_VERSION];
114114

115-
if (empty($packageInfo['available_versions'])) {
115+
if (empty($packageInfo[InfoCommand::AVAILABLE_VERSIONS])) {
116116
$packageInfo = $this->infoCommand->run($package);
117-
if (empty($packageInfo['available_versions'])) {
117+
if (empty($packageInfo[InfoCommand::AVAILABLE_VERSIONS])) {
118118
return false;
119119
}
120120
}

0 commit comments

Comments
 (0)