From b39df32d4bfa78f3399e87e4ed2000e80e997000 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 19 Aug 2013 01:20:34 +0200 Subject: [PATCH] Minor fixes --- src/Composer/Package/Package.php | 12 +++++++----- src/Composer/Util/ComposerMirror.php | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Composer/Package/Package.php b/src/Composer/Package/Package.php index 970068cd2..6dbd78911 100644 --- a/src/Composer/Package/Package.php +++ b/src/Composer/Package/Package.php @@ -582,15 +582,17 @@ class Package extends BasePackage protected function getUrls($url, $mirrors, $ref, $type) { - $urls = array(); - if ($url) { - $urls[] = $url; + if (!$url) { + return array(); } + $urls = array($url); if ($mirrors) { foreach ($mirrors as $mirror) { $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type); - $func = $mirror['preferred'] ? 'array_unshift' : 'array_push'; - $func($urls, $mirrorUrl); + if (!in_array($urls, $mirrorUrl)) { + $func = $mirror['preferred'] ? 'array_unshift' : 'array_push'; + $func($urls, $mirrorUrl); + } } } diff --git a/src/Composer/Util/ComposerMirror.php b/src/Composer/Util/ComposerMirror.php index 710f52cce..f5c2000db 100644 --- a/src/Composer/Util/ComposerMirror.php +++ b/src/Composer/Util/ComposerMirror.php @@ -1,22 +1,22 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Composer\Util; - - - - - +/** + * Composer mirror utilities + * + * @author Jordi Boggiano + */ class ComposerMirror { public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)