diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 01f38c92c..e850b96d6 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -43,6 +43,7 @@ use Composer\Semver\Semver; * @author Robert Schönthal * @author Jordi Boggiano * @author Jérémy Romey + * @author Mihai Plasoianu */ class ShowCommand extends BaseCommand { @@ -196,9 +197,13 @@ EOT $this->displayPackageTree($package, $installedRepo, $repos); } else { $latestPackage = null; + $exitCode = 0; if ($input->getOption('latest')) { $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion); } + if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) { + $exitCode = 1; + } $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null); $this->printLinks($package, 'requires'); $this->printLinks($package, 'devRequires', 'requires (dev)'); @@ -213,7 +218,7 @@ EOT $this->printLinks($package, 'replaces'); } - return; + return $exitCode; } // show tree view if requested diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 65791848b..54d7f09c0 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -12,6 +12,7 @@ namespace Composer\Package\Version; +use Composer\Repository\PlatformRepository; use Composer\Semver\VersionParser as SemverVersionParser; class VersionParser extends SemverVersionParser @@ -47,7 +48,7 @@ class VersionParser extends SemverVersionParser for ($i = 0, $count = count($pairs); $i < $count; $i++) { $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i])); - if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/')) { + if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $pairs[$i + 1])) { $pair .= ' '.$pairs[$i + 1]; $i++; } diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index aff781bc1..935f6ac90 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -195,6 +195,22 @@ class RemoteFilesystem $originUrl = 'github.com'; } + // Gitlab can be installed in a non-root context (i.e. gitlab.com/foo). When downloading archives the originUrl + // is the host without the path, so we look for the registered gitlab-domains matching the host here + if ( + is_array($this->config->get('gitlab-domains')) + && false === strpos($originUrl, '/') + && !in_array($originUrl, $this->config->get('gitlab-domains')) + ) { + foreach ($this->config->get('gitlab-domains') as $gitlabDomain) { + if (0 === strpos($gitlabDomain, $originUrl)) { + $originUrl = $gitlabDomain; + break; + } + } + unset($gitlabDomain); + } + $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME); $this->bytesMax = 0; $this->originUrl = $originUrl; diff --git a/src/Composer/XdebugHandler.php b/src/Composer/XdebugHandler.php index f7fd8c2a1..e9d719abf 100644 --- a/src/Composer/XdebugHandler.php +++ b/src/Composer/XdebugHandler.php @@ -139,11 +139,6 @@ class XdebugHandler $iniPaths = IniHelper::getAll(); $additional = count($iniPaths) > 1; - if (empty($iniPaths[0])) { - // There is no loaded ini - array_shift($iniPaths); - } - if ($this->writeTmpIni($iniPaths)) { return $this->setEnvironment($additional, $iniPaths); } @@ -156,20 +151,25 @@ class XdebugHandler * * The filename is passed as the -c option when the process restarts. * - * @param array $iniFiles The php.ini locations + * @param array $iniPaths Locations reported by the current process * * @return bool */ - private function writeTmpIni(array $iniFiles) + private function writeTmpIni(array $iniPaths) { if (!$this->tmpIni = tempnam(sys_get_temp_dir(), '')) { return false; } + // $iniPaths has at least one item and it may be empty + if (empty($iniPaths[0])) { + array_shift($iniPaths); + } + $content = ''; $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi'; - foreach ($iniFiles as $file) { + foreach ($iniPaths as $file) { $data = preg_replace($regex, ';$1', file_get_contents($file)); $content .= $data.PHP_EOL; } @@ -203,7 +203,7 @@ class XdebugHandler * Returns true if the restart environment variables were set * * @param bool $additional Whether there were additional inis - * @param array $iniPaths Locations used by the current prcoess + * @param array $iniPaths Locations reported by the current process * * @return bool */ diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php new file mode 100644 index 000000000..4ae2e2a25 --- /dev/null +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -0,0 +1,37 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test\Package\Version; + +use Composer\Package\Version\VersionParser; + +class VersionParserTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getParseNameVersionPairsData + */ + public function testParseNameVersionPairs($pairs, $result) + { + $versionParser = new VersionParser(); + + $this->assertSame($result, $versionParser->parseNameVersionPairs($pairs)); + } + + public function getParseNameVersionPairsData() + { + return array( + array(array('php:^7.0'), array(array('name' => 'php', 'version' => '^7.0'))), + array(array('php', '^7.0'), array(array('name' => 'php', 'version' => '^7.0'))), + array(array('php', 'ext-apcu'), array(array('name' => 'php'), array('name' => 'ext-apcu'))), + ); + } +}