1
0
Fork 0
pull/2320/head
Jordi Boggiano 2013-10-11 20:12:02 -03:00
parent 9a806658d6
commit 11a0d16ccc
31 changed files with 62 additions and 49 deletions

View File

@ -317,6 +317,7 @@ EOF;
return array( return array(
$filesCode); $filesCode);
EOF; EOF;
} }

View File

@ -377,6 +377,7 @@ class Pool
if ($constraint === null) { if ($constraint === null) {
return self::MATCH; return self::MATCH;
} }
return $constraint->matches(new VersionConstraint('==', $candidateVersion)) ? self::MATCH : self::MATCH_NAME; return $constraint->matches(new VersionConstraint('==', $candidateVersion)) ? self::MATCH : self::MATCH_NAME;
} }

View File

@ -24,9 +24,9 @@ interface ChangeReportInterface
/** /**
* Checks for changes to the local copy * Checks for changes to the local copy
* *
* @param PackageInterface $package package instance * @param PackageInterface $package package instance
* @param string $path package directory * @param string $path package directory
* @return string|null changes or null * @return string|null changes or null
*/ */
public function getLocalChanges(PackageInterface $package, $path); public function getLocalChanges(PackageInterface $package, $path);
} }

View File

@ -45,12 +45,12 @@ class FileDownloader implements DownloaderInterface
/** /**
* Constructor. * Constructor.
* *
* @param IOInterface $io The IO instance * @param IOInterface $io The IO instance
* @param Config $config The config * @param Config $config The config
* @param EventDispatcher $eventDispatcher The event dispatcher * @param EventDispatcher $eventDispatcher The event dispatcher
* @param Cache $cache Optional cache instance * @param Cache $cache Optional cache instance
* @param RemoteFilesystem $rfs The remote filesystem * @param RemoteFilesystem $rfs The remote filesystem
* @param Filesystem $filesystem The filesystem * @param Filesystem $filesystem The filesystem
*/ */
public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, RemoteFilesystem $rfs = null, Filesystem $filesystem = null) public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, RemoteFilesystem $rfs = null, Filesystem $filesystem = null)
{ {

View File

@ -10,7 +10,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Composer\Downloader; namespace Composer\Downloader;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
@ -75,16 +74,17 @@ class PerforceDownloader extends VcsDownloader
public function getLocalChanges(PackageInterface $package, $path) public function getLocalChanges(PackageInterface $package, $path)
{ {
$this->io->write('Perforce driver does not check for local changes before overriding', true); $this->io->write('Perforce driver does not check for local changes before overriding', true);
return; return;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
protected function getCommitLogs($fromReference, $toReference, $path) protected function getCommitLogs($fromReference, $toReference, $path)
{ {
$commitLogs = $this->perforce->getCommitLogs($fromReference, $toReference); $commitLogs = $this->perforce->getCommitLogs($fromReference, $toReference);
return $commitLogs; return $commitLogs;
} }

View File

@ -148,8 +148,8 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
* Prompt the user to check if changes should be stashed/removed or the operation aborted * Prompt the user to check if changes should be stashed/removed or the operation aborted
* *
* @param PackageInterface $package * @param PackageInterface $package
* @param string $path * @param string $path
* @param bool $update if true (update) the changes can be stashed and reapplied after an update, * @param bool $update if true (update) the changes can be stashed and reapplied after an update,
* if false (remove) the changes should be assumed to be lost if the operation is not aborted * if false (remove) the changes should be assumed to be lost if the operation is not aborted
* @throws \RuntimeException in case the operation must be aborted * @throws \RuntimeException in case the operation must be aborted
*/ */

View File

@ -32,7 +32,7 @@ class Event
/** /**
* Constructor. * Constructor.
* *
* @param string $name The event name * @param string $name The event name
*/ */
public function __construct($name) public function __construct($name)
{ {

View File

@ -202,7 +202,7 @@ class EventDispatcher
/** /**
* Retrieves all listeners for a given event * Retrieves all listeners for a given event
* *
* @param Event $event * @param Event $event
* @return array All listeners: callables and scripts * @return array All listeners: callables and scripts
*/ */
protected function getListeners(Event $event) protected function getListeners(Event $event)

View File

@ -177,7 +177,7 @@ class Factory
* @param IOInterface $io IO instance * @param IOInterface $io IO instance
* @param array|string|null $localConfig either a configuration array or a filename to read from, if null it will * @param array|string|null $localConfig either a configuration array or a filename to read from, if null it will
* read from the default filename * read from the default filename
* @param bool $disablePlugins Whether plugins should not be loaded * @param bool $disablePlugins Whether plugins should not be loaded
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @return Composer * @return Composer
@ -432,7 +432,7 @@ class Factory
* @param IOInterface $io IO instance * @param IOInterface $io IO instance
* @param mixed $config either a configuration array or a filename to read from, if null it will read from * @param mixed $config either a configuration array or a filename to read from, if null it will read from
* the default filename * the default filename
* @param bool $disablePlugins Whether plugins should not be loaded * @param bool $disablePlugins Whether plugins should not be loaded
* @return Composer * @return Composer
*/ */
public static function create(IOInterface $io, $config = null, $disablePlugins = false) public static function create(IOInterface $io, $config = null, $disablePlugins = false)

View File

@ -539,7 +539,6 @@ class Installer
return true; return true;
} }
/** /**
* Workaround: if your packages depend on plugins, we must be sure * Workaround: if your packages depend on plugins, we must be sure
* that those are installed / updated first; else it would lead to packages * that those are installed / updated first; else it would lead to packages
@ -550,7 +549,7 @@ class Installer
* it at least fixes the symptoms and makes usage of composer possible (again) * it at least fixes the symptoms and makes usage of composer possible (again)
* in such scenarios. * in such scenarios.
* *
* @param OperationInterface[] $operations * @param OperationInterface[] $operations
* @return OperationInterface[] reordered operation list * @return OperationInterface[] reordered operation list
*/ */
private function movePluginsToFront(array $operations) private function movePluginsToFront(array $operations)
@ -559,7 +558,7 @@ class Installer
foreach ($operations as $idx => $op) { foreach ($operations as $idx => $op) {
if ($op instanceof InstallOperation) { if ($op instanceof InstallOperation) {
$package = $op->getPackage(); $package = $op->getPackage();
} else if ($op instanceof UpdateOperation) { } elseif ($op instanceof UpdateOperation) {
$package = $op->getTargetPackage(); $package = $op->getTargetPackage();
} else { } else {
continue; continue;

View File

@ -165,6 +165,7 @@ class LibraryInstaller implements InstallerInterface
if (strpos($initialDownloadPath, $targetDownloadPath) === 0) { if (strpos($initialDownloadPath, $targetDownloadPath) === 0) {
$this->removeCode($initial); $this->removeCode($initial);
$this->installCode($target); $this->installCode($target);
return; return;
} }

View File

@ -368,9 +368,9 @@ class VersionParser
* *
* Support function for {@link parseConstraint()} * Support function for {@link parseConstraint()}
* *
* @param array $matches Array with version parts in array indexes 1,2,3,4 * @param array $matches Array with version parts in array indexes 1,2,3,4
* @param int $position 1,2,3,4 - which segment of the version to decrement * @param int $position 1,2,3,4 - which segment of the version to decrement
* @param string $pad The string to pad version parts after $position * @param string $pad The string to pad version parts after $position
* @return string The new version * @return string The new version
*/ */
private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0') private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
@ -378,7 +378,7 @@ class VersionParser
for ($i = 4; $i > 0; $i--) { for ($i = 4; $i > 0; $i--) {
if ($i > $position) { if ($i > $position) {
$matches[$i] = $pad; $matches[$i] = $pad;
} else if ($i == $position && $increment) { } elseif ($i == $position && $increment) {
$matches[$i] += $increment; $matches[$i] += $increment;
// If $matches[$i] was 0, carry the decrement // If $matches[$i] was 0, carry the decrement
if ($matches[$i] < 0) { if ($matches[$i] < 0) {

View File

@ -32,7 +32,7 @@ interface PluginInterface
/** /**
* Apply plugin modifications to composer * Apply plugin modifications to composer
* *
* @param Composer $composer * @param Composer $composer
* @param IOInterface $io * @param IOInterface $io
*/ */
public function activate(Composer $composer, IOInterface $io); public function activate(Composer $composer, IOInterface $io);

View File

@ -35,7 +35,7 @@ class PreFileDownloadEvent extends Event
/** /**
* Constructor. * Constructor.
* *
* @param string $name The event name * @param string $name The event name
* @param RemoteFilesystem $rfs * @param RemoteFilesystem $rfs
* @param string $processedUrl * @param string $processedUrl
*/ */

View File

@ -43,7 +43,6 @@ class PlatformRepository extends ArrayRepository
$version = $versionParser->normalize($prettyVersion); $version = $versionParser->normalize($prettyVersion);
} }
$php = new CompletePackage('php', $version, $prettyVersion); $php = new CompletePackage('php', $version, $prettyVersion);
$php->setDescription('The PHP interpreter'); $php->setDescription('The PHP interpreter');
parent::addPackage($php); parent::addPackage($php);

View File

@ -10,12 +10,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Composer\Repository\Vcs; namespace Composer\Repository\Vcs;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Filesystem;
use Composer\Util\Perforce; use Composer\Util\Perforce;
/** /**
@ -145,6 +143,7 @@ class PerforceDriver extends VcsDriver
if (isset($this->composerInfo)) { if (isset($this->composerInfo)) {
$result = count($this->composerInfo) > 0; $result = count($this->composerInfo) > 0;
} }
return $result; return $result;
} }

View File

@ -44,7 +44,7 @@ class Filesystem
/** /**
* Checks if a directory is empty * Checks if a directory is empty
* *
* @param string $dir * @param string $dir
* @return bool * @return bool
*/ */
public function isDirEmpty($dir) public function isDirEmpty($dir)

View File

@ -105,7 +105,7 @@ class NoProxyPattern
* http://framework.zend.com/svn/framework/extras/incubator/library/ZendX/Whois/Adapter/Cidr.php * http://framework.zend.com/svn/framework/extras/incubator/library/ZendX/Whois/Adapter/Cidr.php
* *
* @param string $cidr IPv4 block in CIDR notation * @param string $cidr IPv4 block in CIDR notation
* @param string $ip IPv4 address * @param string $ip IPv4 address
* *
* @return boolean * @return boolean
*/ */

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Composer. * This file is part of Composer.
* *
@ -9,7 +10,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Composer\Util; namespace Composer\Util;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
@ -20,7 +20,6 @@ use Symfony\Component\Process\Process;
*/ */
class Perforce class Perforce
{ {
protected $path; protected $path;
protected $p4Depot; protected $p4Depot;
protected $p4Client; protected $p4Client;
@ -35,7 +34,6 @@ class Perforce
protected $uniquePerforceClientName; protected $uniquePerforceClientName;
protected $windowsFlag; protected $windowsFlag;
public static function createPerforce($repoConfig, $port, $path, ProcessExecutor $process = null) public static function createPerforce($repoConfig, $port, $path, ProcessExecutor $process = null)
{ {
if (!isset($process)) { if (!isset($process)) {
@ -44,6 +42,7 @@ class Perforce
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD'); $isWindows = defined('PHP_WINDOWS_VERSION_BUILD');
$perforce = new Perforce($repoConfig, $port, $path, $process, $isWindows); $perforce = new Perforce($repoConfig, $port, $path, $process, $isWindows);
return $perforce; return $perforce;
} }
@ -161,6 +160,7 @@ class Perforce
$this->p4Stream = '//' . $this->p4Depot; $this->p4Stream = '//' . $this->p4Depot;
} }
} }
return $this->p4Stream; return $this->p4Stream;
} }
@ -268,6 +268,7 @@ class Perforce
if ($index === false) { if ($index === false) {
return false; return false;
} }
return true; return true;
} }
@ -329,7 +330,6 @@ class Perforce
fclose($spec); fclose($spec);
} }
protected function read($pipe, $name) protected function read($pipe, $name)
{ {
if (feof($pipe)) { if (feof($pipe)) {
@ -347,10 +347,10 @@ class Perforce
{ {
$command = $this->generateP4Command(' login -a'); $command = $this->generateP4Command(' login -a');
$process = new Process($command, null, null, $password); $process = new Process($command, null, null, $password);
return $process->run(); return $process->run();
} }
public function p4Login(IOInterface $io) public function p4Login(IOInterface $io)
{ {
$this->queryP4User($io); $this->queryP4User($io);
@ -369,6 +369,7 @@ class Perforce
{ {
$result = ''; $result = '';
$processExecutor->execute('p4 -p ' . $url . ' info -s', $result); $processExecutor->execute('p4 -p ' . $url . ' info -s', $result);
return false === strpos($result, 'error'); return false === strpos($result, 'error');
} }
@ -380,6 +381,7 @@ class Perforce
return $this->getComposerInformationFromPath($composerJson); return $this->getComposerInformationFromPath($composerJson);
} }
return $this->getComposerInformationFromLabel($identifier, $index); return $this->getComposerInformationFromLabel($identifier, $index);
} }
@ -496,6 +498,7 @@ class Perforce
} }
$fields = explode(' ', $changes); $fields = explode(' ', $changes);
$changeList = $fields[1]; $changeList = $fields[1];
return $changeList; return $changeList;
} }
@ -513,6 +516,7 @@ class Perforce
$main = substr($fromReference, 0, $index) . '/...'; $main = substr($fromReference, 0, $index) . '/...';
$command = $this->generateP4Command('filelog ' . $main . '@' . $fromChangeList. ',' . $toChangeList); $command = $this->generateP4Command('filelog ' . $main . '@' . $fromChangeList. ',' . $toChangeList);
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
return $result; return $result;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Composer. * This file is part of Composer.
* *
@ -9,7 +10,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Composer\Test\Downloader; namespace Composer\Test\Downloader;
use Composer\Downloader\PerforceDownloader; use Composer\Downloader\PerforceDownloader;
@ -41,7 +41,6 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
$this->io = $this->getMock('Composer\IO\IOInterface'); $this->io = $this->getMock('Composer\IO\IOInterface');
} }
public function testDoDownloadGetRepoConfig() public function testDoDownloadGetRepoConfig()
{ {
$downloader = new PerforceDownloader($this->io, $this->config); $downloader = new PerforceDownloader($this->io, $this->config);

View File

@ -17,7 +17,6 @@ use Composer\Config;
use Composer\Installer\PluginInstaller; use Composer\Installer\PluginInstaller;
use Composer\Package\Loader\JsonLoader; use Composer\Package\Loader\JsonLoader;
use Composer\Package\Loader\ArrayLoader; use Composer\Package\Loader\ArrayLoader;
use Composer\Package\PackageInterface;
use Composer\Plugin\PluginManager; use Composer\Plugin\PluginManager;
use Composer\Autoload\AutoloadGenerator; use Composer\Autoload\AutoloadGenerator;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
@ -166,4 +165,3 @@ class PluginInstallerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('installer-v3', $plugins[1]->version); $this->assertEquals('installer-v3', $plugins[1]->version);
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Composer. * This file is part of Composer.
* *
@ -11,7 +12,6 @@
namespace Composer\Test\Repository\Vcs; namespace Composer\Test\Repository\Vcs;
use Composer\Repository\Vcs\PerforceDriver; use Composer\Repository\Vcs\PerforceDriver;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\Config; use Composer\Config;

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Composer. * This file is part of Composer.
* *
@ -9,7 +10,6 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Composer\Test\Util; namespace Composer\Test\Util;
use Composer\Util\Perforce; use Composer\Util\Perforce;
@ -70,7 +70,6 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('//depot/branch', $stream); $this->assertEquals('//depot/branch', $stream);
} }
public function testGetStreamWithoutLabelWithStreamWithoutLabel() public function testGetStreamWithoutLabelWithStreamWithoutLabel()
{ {
$stream = $this->perforce->getStreamWithoutLabel('//depot/branch'); $stream = $this->perforce->getStreamWithoutLabel('//depot/branch');
@ -123,6 +122,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL ; $output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL ;
return true; return true;
} }
) )
@ -146,6 +146,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'TEST_P4VARIABLE_USER' . PHP_EOL; $output = 'TEST_P4VARIABLE_USER' . PHP_EOL;
return true; return true;
} }
) )
@ -237,6 +238,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL; $output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
return true; return true;
} }
) )
@ -260,6 +262,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL; $output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
return true; return true;
} }
) )
@ -357,6 +360,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'Stream //depot/branch mainline none \'branch\'' . PHP_EOL; $output = 'Stream //depot/branch mainline none \'branch\'' . PHP_EOL;
return true; return true;
} }
) )
@ -382,6 +386,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'Label 0.0.1 2013/07/31 \'First Label!\'' . PHP_EOL . 'Label 0.0.2 2013/08/01 \'Second Label!\'' . PHP_EOL; $output = 'Label 0.0.1 2013/07/31 \'First Label!\'' . PHP_EOL . 'Label 0.0.2 2013/08/01 \'Second Label!\'' . PHP_EOL;
return true; return true;
} }
) )
@ -404,6 +409,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'Label 0.0.1 2013/07/31 \'First Label!\'' . PHP_EOL . 'Label 0.0.2 2013/08/01 \'Second Label!\'' . PHP_EOL; $output = 'Label 0.0.1 2013/07/31 \'First Label!\'' . PHP_EOL . 'Label 0.0.2 2013/08/01 \'Second Label!\'' . PHP_EOL;
return true; return true;
} }
) )
@ -428,6 +434,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = 'Depot depot 2013/06/25 stream /p4/1/depots/depot/... \'Created by Me\''; $output = 'Depot depot 2013/06/25 stream /p4/1/depots/depot/... \'Created by Me\'';
return true; return true;
} }
) )
@ -447,6 +454,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = PerforceTest::getComposerJson(); $output = PerforceTest::getComposerJson();
return true; return true;
} }
) )
@ -472,6 +480,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = '//depot/composer.json#1 - branch change 10001 (text)'; $output = '//depot/composer.json#1 - branch change 10001 (text)';
return true; return true;
} }
) )
@ -485,6 +494,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = PerforceTest::getComposerJson(); $output = PerforceTest::getComposerJson();
return true; return true;
} }
) )
@ -513,6 +523,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = PerforceTest::getComposerJson(); $output = PerforceTest::getComposerJson();
return true; return true;
} }
) )
@ -540,6 +551,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = '//depot/composer.json#1 - branch change 10001 (text)'; $output = '//depot/composer.json#1 - branch change 10001 (text)';
return true; return true;
} }
) )
@ -553,6 +565,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = PerforceTest::getComposerJson(); $output = PerforceTest::getComposerJson();
return true; return true;
} }
) )

View File

@ -144,7 +144,6 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
} }
} }
public function testCaptureAuthenticationParamsFromUrl() public function testCaptureAuthenticationParamsFromUrl()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');