main
Jordi Boggiano 10 years ago
parent 751190aafd
commit 94926218e8

@ -54,7 +54,7 @@ class AutoloadGenerator
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '') public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
{ {
$this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array( $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
'optimize' => (bool) $scanPsr0Packages 'optimize' => (bool) $scanPsr0Packages,
)); ));
$filesystem = new Filesystem(); $filesystem = new Filesystem();
@ -255,7 +255,7 @@ EOF;
$packageMap[] = array( $packageMap[] = array(
$package, $package,
$installationManager->getInstallPath($package) $installationManager->getInstallPath($package),
); );
} }
@ -533,7 +533,6 @@ INCLUDEPATH;
REGISTER_AUTOLOAD; REGISTER_AUTOLOAD;
} }
$file .= <<<REGISTER_LOADER $file .= <<<REGISTER_LOADER
@ -551,7 +550,6 @@ REGISTER_LOADER;
INCLUDE_FILES; INCLUDE_FILES;
} }
$file .= <<<METHOD_FOOTER $file .= <<<METHOD_FOOTER
@ -571,7 +569,6 @@ function composerRequire$suffix(\$file)
} }
FOOTER; FOOTER;
} }
protected function parseAutoloadsType(array $packageMap, $type, PackageInterface $mainPackage) protected function parseAutoloadsType(array $packageMap, $type, PackageInterface $mainPackage)

@ -85,7 +85,7 @@ class Cache
try { try {
return file_put_contents($this->root . $file, $contents); return file_put_contents($this->root . $file, $contents);
} catch(\ErrorException $e) { } catch (\ErrorException $e) {
if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) { if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
// Remove partial file. // Remove partial file.
unlink($this->root . $file); unlink($this->root . $file);
@ -150,7 +150,7 @@ class Cache
public function gcIsNecessary() public function gcIsNecessary()
{ {
return (!self::$cacheCollected && !mt_rand(0, 50)); return (!self::$cacheCollected && !mt_rand(0, 50));
} }
public function remove($file) public function remove($file)

@ -40,6 +40,5 @@ EOT
See http://getcomposer.org/ for more information.</comment> See http://getcomposer.org/ for more information.</comment>
EOT EOT
); );
} }
} }

@ -15,7 +15,6 @@ namespace Composer\Command;
use Composer\Factory; use Composer\Factory;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Pool;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Composer\Script\ScriptEvents; use Composer\Script\ScriptEvents;
use Composer\Plugin\CommandEvent; use Composer\Plugin\CommandEvent;

@ -52,11 +52,13 @@ EOT
$cachePath = realpath($cachePath); $cachePath = realpath($cachePath);
if (!$cachePath) { if (!$cachePath) {
$io->write("<info>Cache directory does not exist ($key): $cachePath</info>"); $io->write("<info>Cache directory does not exist ($key): $cachePath</info>");
return; return;
} }
$cache = new Cache($io, $cachePath); $cache = new Cache($io, $cachePath);
if (!$cache->isEnabled()) { if (!$cache->isEnabled()) {
$io->write("<info>Cache is not enabled ($key): $cachePath</info>"); $io->write("<info>Cache is not enabled ($key): $cachePath</info>");
return; return;
} }

@ -160,7 +160,7 @@ EOT
} }
$file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath(); $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
system($editor . ' ' . $file . (defined('PHP_WINDOWS_VERSION_BUILD') ? '': ' > `tty`')); system($editor . ' ' . $file . (defined('PHP_WINDOWS_VERSION_BUILD') ? '' : ' > `tty`'));
return 0; return 0;
} }
@ -359,7 +359,7 @@ EOT
); );
foreach ($uniqueConfigValues as $name => $callbacks) { foreach ($uniqueConfigValues as $name => $callbacks) {
if ($settingKey === $name) { if ($settingKey === $name) {
if ($input->getOption('unset')) { if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey); return $this->configSource->removeConfigSetting($settingKey);
} }

@ -322,7 +322,6 @@ EOT
return new InstallationManager(); return new InstallationManager();
} }
/** /**
* Updated preferSource or preferDist based on the preferredInstall config option * Updated preferSource or preferDist based on the preferredInstall config option
* @param Config $config * @param Config $config

@ -15,7 +15,6 @@ namespace Composer\Command;
use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Pool;
use Composer\Factory; use Composer\Factory;
use Composer\Package\CompletePackageInterface; use Composer\Package\CompletePackageInterface;
use Composer\Package\Loader\InvalidPackageException;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
@ -23,7 +22,6 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Exception\InvalidArgumentException;
/** /**
* @author Robert Schönthal <seroscho@googlemail.com> * @author Robert Schönthal <seroscho@googlemail.com>
@ -92,8 +90,8 @@ EOT
/** /**
* finds a package by name * finds a package by name
* *
* @param RepositoryInterface $repos * @param RepositoryInterface $repos
* @param string $name * @param string $name
* @return CompletePackageInterface * @return CompletePackageInterface
*/ */
protected function getPackage(RepositoryInterface $repos, $name) protected function getPackage(RepositoryInterface $repos, $name)
@ -142,8 +140,8 @@ EOT
/** /**
* initializes the repo * initializes the repo
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return CompositeRepository * @return CompositeRepository
*/ */
private function initializeRepo(InputInterface $input, OutputInterface $output) private function initializeRepo(InputInterface $input, OutputInterface $output)
@ -159,5 +157,4 @@ EOT
return $repo; return $repo;
} }
} }

@ -105,7 +105,7 @@ EOT
} }
if (isset($options['require-dev'])) { if (isset($options['require-dev'])) {
$options['require-dev'] = $this->formatRequirements($options['require-dev']) ; $options['require-dev'] = $this->formatRequirements($options['require-dev']);
if (array() === $options['require-dev']) { if (array() === $options['require-dev']) {
$options['require-dev'] = new \stdClass; $options['require-dev'] = new \stdClass;
} }
@ -311,7 +311,6 @@ EOT
foreach ($requires as $requirement) { foreach ($requires as $requirement) {
if (!isset($requirement['version'])) { if (!isset($requirement['version'])) {
// determine the best version automatically // determine the best version automatically
$version = $this->findBestVersionForPackage($input, $requirement['name']); $version = $this->findBestVersionForPackage($input, $requirement['name']);
$requirement['version'] = $version; $requirement['version'] = $version;
@ -553,8 +552,8 @@ EOT
* *
* This returns a version with the ~ operator prefixed when possible. * This returns a version with the ~ operator prefixed when possible.
* *
* @param InputInterface $input * @param InputInterface $input
* @param string $name * @param string $name
* @return string * @return string
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

@ -115,7 +115,7 @@ EOT
->setDevMode(!$input->getOption('no-dev')) ->setDevMode(!$input->getOption('no-dev'))
->setRunScripts(!$input->getOption('no-scripts')) ->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($optimize) ->setOptimizeAutoloader($optimize)
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')); ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
; ;
if ($input->getOption('no-plugins')) { if ($input->getOption('no-plugins')) {

@ -104,7 +104,7 @@ EOT
->setDevMode($updateDevMode) ->setDevMode($updateDevMode)
->setUpdate(true) ->setUpdate(true)
->setUpdateWhitelist($packages) ->setUpdateWhitelist($packages)
->setWhitelistDependencies($input->getOption('update-with-dependencies')); ->setWhitelistDependencies($input->getOption('update-with-dependencies'))
; ;
$status = $install->run(); $status = $install->run();

@ -130,7 +130,7 @@ EOT
->setDevMode($updateDevMode) ->setDevMode($updateDevMode)
->setUpdate(true) ->setUpdate(true)
->setUpdateWhitelist(array_keys($requirements)) ->setUpdateWhitelist(array_keys($requirements))
->setWhitelistDependencies($input->getOption('update-with-dependencies')); ->setWhitelistDependencies($input->getOption('update-with-dependencies'))
; ;
$status = $install->run(); $status = $install->run();

@ -120,7 +120,7 @@ EOT
->setUpdate(true) ->setUpdate(true)
->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $input->getArgument('packages')) ->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $input->getArgument('packages'))
->setWhitelistDependencies($input->getOption('with-dependencies')) ->setWhitelistDependencies($input->getOption('with-dependencies'))
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')); ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
; ;
if ($input->getOption('no-plugins')) { if ($input->getOption('no-plugins')) {

@ -187,7 +187,7 @@ class JsonConfigSource implements ConfigSourceInterface
private function arrayUnshiftRef(&$array, &$value) private function arrayUnshiftRef(&$array, &$value)
{ {
$return = array_unshift($array, ''); $return = array_unshift($array, '');
$array[0] =& $value; $array[0] = &$value;
return $return; return $return;
} }

@ -25,7 +25,6 @@ use Composer\Factory;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\IO\ConsoleIO; use Composer\IO\ConsoleIO;
use Composer\Json\JsonValidationException; use Composer\Json\JsonValidationException;
use Composer\Json\JsonFile;
use Composer\Util\ErrorHandler; use Composer\Util\ErrorHandler;
/** /**
@ -180,7 +179,8 @@ class Application extends BaseApplication
$output->writeln('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>'); $output->writeln('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>');
} }
} }
} catch (\Exception $e) {} } catch (\Exception $e) {
}
return parent::renderException($exception, $output); return parent::renderException($exception, $output);
} }
@ -206,7 +206,6 @@ class Application extends BaseApplication
$message = $e->getMessage() . ':' . PHP_EOL . $errors; $message = $e->getMessage() . ':' . PHP_EOL . $errors;
throw new JsonValidationException($message); throw new JsonValidationException($message);
} }
} }
return $this->composer; return $this->composer;

@ -232,7 +232,7 @@ class Pool
* packages must match or null to return all * packages must match or null to return all
* @param bool $mustMatchName Whether the name of returned packages * @param bool $mustMatchName Whether the name of returned packages
* must match the given name * must match the given name
* @return PackageInterface[] A set of packages * @return PackageInterface[] A set of packages
*/ */
public function whatProvides($name, LinkConstraintInterface $constraint = null, $mustMatchName = false) public function whatProvides($name, LinkConstraintInterface $constraint = null, $mustMatchName = false)
{ {

@ -83,7 +83,6 @@ class Solver
$conflict = $this->decisions->decisionRule($literal); $conflict = $this->decisions->decisionRule($literal);
if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) { if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
$problem = new Problem($this->pool); $problem = new Problem($this->pool);
$problem->addRule($rule); $problem->addRule($rule);
@ -609,7 +608,6 @@ class Solver
$installedPos = 0; $installedPos = 0;
while (true) { while (true) {
if (1 === $level) { if (1 === $level) {
$conflictRule = $this->propagate($level); $conflictRule = $this->propagate($level);
if (null !== $conflictRule) { if (null !== $conflictRule) {
@ -658,7 +656,6 @@ class Solver
} }
if ($noneSatisfied && count($decisionQueue)) { if ($noneSatisfied && count($decisionQueue)) {
$oLevel = $level; $oLevel = $level;
$level = $this->selectAndInstall($level, $decisionQueue, $disableRules, $rule); $level = $this->selectAndInstall($level, $decisionQueue, $disableRules, $rule);
@ -742,7 +739,6 @@ class Solver
// minimization step // minimization step
if (count($this->branches)) { if (count($this->branches)) {
$lastLiteral = null; $lastLiteral = null;
$lastLevel = null; $lastLevel = null;
$lastBranchIndex = 0; $lastBranchIndex = 0;

@ -55,7 +55,6 @@ class Transaction
if ($literal > 0) { if ($literal > 0) {
if (isset($installMeansUpdateMap[abs($literal)]) && !$package instanceof AliasPackage) { if (isset($installMeansUpdateMap[abs($literal)]) && !$package instanceof AliasPackage) {
$source = $installMeansUpdateMap[abs($literal)]; $source = $installMeansUpdateMap[abs($literal)];
$updateMap[$package->getId()] = array( $updateMap[$package->getId()] = array(
@ -88,7 +87,6 @@ class Transaction
'package' => $package, 'package' => $package,
'reason' => $reason, 'reason' => $reason,
); );
} }
} }

@ -137,7 +137,7 @@ abstract class ArchiveDownloader extends FileDownloader
/** /**
* Returns the folder content, excluding dotfiles * Returns the folder content, excluding dotfiles
* *
* @param string $dir Directory * @param string $dir Directory
* @return \SplFileInfo[] * @return \SplFileInfo[]
*/ */
private function getFolderContent($dir) private function getFolderContent($dir)

@ -101,7 +101,7 @@ class FileDownloader implements DownloaderInterface
} }
} }
} }
$this->io->write(''); $this->io->write('');
} }

@ -138,8 +138,9 @@ class PearPackageExtractor
{ {
/** @var $package \SimpleXmlElement */ /** @var $package \SimpleXmlElement */
$package = simplexml_load_file($this->combine($source, 'package.xml')); $package = simplexml_load_file($this->combine($source, 'package.xml'));
if(false === $package) if (false === $package) {
throw new \RuntimeException('Package definition file is not valid.'); throw new \RuntimeException('Package definition file is not valid.');
}
$packageSchemaVersion = $package['version']; $packageSchemaVersion = $package['version'];
if ('1.0' == $packageSchemaVersion) { if ('1.0' == $packageSchemaVersion) {
@ -203,16 +204,16 @@ class PearPackageExtractor
/** @var $child \SimpleXMLElement */ /** @var $child \SimpleXMLElement */
if ($child->getName() == 'dir') { if ($child->getName() == 'dir') {
$dirSource = $this->combine($source, (string) $child['name']); $dirSource = $this->combine($source, (string) $child['name']);
$dirTarget = $child['baseinstalldir'] ? : $target; $dirTarget = $child['baseinstalldir'] ?: $target;
$dirRole = $child['role'] ? : $role; $dirRole = $child['role'] ?: $role;
$dirFiles = $this->buildSourceList10($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName); $dirFiles = $this->buildSourceList10($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName);
$result = array_merge($result, $dirFiles); $result = array_merge($result, $dirFiles);
} elseif ($child->getName() == 'file') { } elseif ($child->getName() == 'file') {
$fileRole = (string) $child['role'] ? : $role; $fileRole = (string) $child['role'] ?: $role;
if (isset($targetRoles[$fileRole])) { if (isset($targetRoles[$fileRole])) {
$fileName = (string) ($child['name'] ? : $child[0]); // $child[0] means text content $fileName = (string) ($child['name'] ?: $child[0]); // $child[0] means text content
$fileSource = $this->combine($source, $fileName); $fileSource = $this->combine($source, $fileName);
$fileTarget = $this->combine((string) $child['baseinstalldir'] ? : $target, $fileName); $fileTarget = $this->combine((string) $child['baseinstalldir'] ?: $target, $fileName);
if (!in_array($fileRole, self::$rolesWithoutPackageNamePrefix)) { if (!in_array($fileRole, self::$rolesWithoutPackageNamePrefix)) {
$fileTarget = $packageName . '/' . $fileTarget; $fileTarget = $packageName . '/' . $fileTarget;
} }
@ -233,15 +234,15 @@ class PearPackageExtractor
/** @var $child \SimpleXMLElement */ /** @var $child \SimpleXMLElement */
if ('dir' == $child->getName()) { if ('dir' == $child->getName()) {
$dirSource = $this->combine($source, $child['name']); $dirSource = $this->combine($source, $child['name']);
$dirTarget = $child['baseinstalldir'] ? : $target; $dirTarget = $child['baseinstalldir'] ?: $target;
$dirRole = $child['role'] ? : $role; $dirRole = $child['role'] ?: $role;
$dirFiles = $this->buildSourceList20($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName); $dirFiles = $this->buildSourceList20($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName);
$result = array_merge($result, $dirFiles); $result = array_merge($result, $dirFiles);
} elseif ('file' == $child->getName()) { } elseif ('file' == $child->getName()) {
$fileRole = (string) $child['role'] ? : $role; $fileRole = (string) $child['role'] ?: $role;
if (isset($targetRoles[$fileRole])) { if (isset($targetRoles[$fileRole])) {
$fileSource = $this->combine($source, (string) $child['name']); $fileSource = $this->combine($source, (string) $child['name']);
$fileTarget = $this->combine((string) ($child['baseinstalldir'] ? : $target), (string) $child['name']); $fileTarget = $this->combine((string) ($child['baseinstalldir'] ?: $target), (string) $child['name']);
$fileTasks = array(); $fileTasks = array();
foreach ($child->children('http://pear.php.net/dtd/tasks-1.0') as $taskNode) { foreach ($child->children('http://pear.php.net/dtd/tasks-1.0') as $taskNode) {
if ('replace' == $taskNode->getName()) { if ('replace' == $taskNode->getName()) {

@ -42,9 +42,9 @@ class Event
/** /**
* Constructor. * Constructor.
* *
* @param string $name The event name * @param string $name The event name
* @param array $args Arguments passed by the user * @param array $args Arguments passed by the user
* @param array $flags Optional flags to pass data not as argument * @param array $flags Optional flags to pass data not as argument
*/ */
public function __construct($name, array $args = array(), array $flags = array()) public function __construct($name, array $args = array(), array $flags = array())
{ {

@ -79,12 +79,12 @@ class EventDispatcher
/** /**
* Dispatch a script event. * Dispatch a script event.
* *
* @param string $eventName The constant in ScriptEvents * @param string $eventName The constant in ScriptEvents
* @param bool $devMode * @param bool $devMode
* @param array $additionalArgs Arguments passed by the user * @param array $additionalArgs Arguments passed by the user
* @param array $flags Optional flags to pass data not as argument * @param array $flags Optional flags to pass data not as argument
* @return int return code of the executed script if any, for php scripts a false return * @return int return code of the executed script if any, for php scripts a false return
* value is changed to 1, anything else to 0 * value is changed to 1, anything else to 0
*/ */
public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array()) public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
{ {
@ -108,19 +108,18 @@ class EventDispatcher
/** /**
* Dispatch a command event. * Dispatch a command event.
* *
* @param string $eventName The constant in ScriptEvents * @param string $eventName The constant in ScriptEvents
* @param boolean $devMode Whether or not we are in dev mode * @param boolean $devMode Whether or not we are in dev mode
* @param array $additionalArgs Arguments passed by the user * @param array $additionalArgs Arguments passed by the user
* @param array $flags Optional flags to pass data not as argument * @param array $flags Optional flags to pass data not as argument
* @return int return code of the executed script if any, for php scripts a false return * @return int return code of the executed script if any, for php scripts a false return
* value is changed to 1, anything else to 0 * value is changed to 1, anything else to 0
*/ */
public function dispatchCommandEvent($eventName, $devMode, $additionalArgs = array(), $flags = array()) public function dispatchCommandEvent($eventName, $devMode, $additionalArgs = array(), $flags = array())
{ {
return $this->doDispatch(new CommandEvent($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags)); return $this->doDispatch(new CommandEvent($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
} }
/** /**
* Dispatch a installer event. * Dispatch a installer event.
* *
@ -132,7 +131,7 @@ class EventDispatcher
* @param array $operations The list of operations * @param array $operations The list of operations
* *
* @return int return code of the executed script if any, for php scripts a false return * @return int return code of the executed script if any, for php scripts a false return
* value is changed to 1, anything else to 0 * value is changed to 1, anything else to 0
*/ */
public function dispatchInstallerEvent($eventName, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array()) public function dispatchInstallerEvent($eventName, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array())
{ {
@ -142,10 +141,10 @@ class EventDispatcher
/** /**
* Triggers the listeners of an event. * Triggers the listeners of an event.
* *
* @param Event $event The event object to pass to the event handlers/listeners. * @param Event $event The event object to pass to the event handlers/listeners.
* @param string $additionalArgs * @param string $additionalArgs
* @return int return code of the executed script if any, for php scripts a false return * @return int return code of the executed script if any, for php scripts a false return
* value is changed to 1, anything else to 0 * value is changed to 1, anything else to 0
* @throws \RuntimeException * @throws \RuntimeException
* @throws \Exception * @throws \Exception
*/ */

@ -85,7 +85,7 @@ class Factory
} }
/** /**
* @param IOInterface|null $io * @param IOInterface|null $io
* @return Config * @return Config
*/ */
public static function createConfig(IOInterface $io = null) public static function createConfig(IOInterface $io = null)
@ -335,8 +335,8 @@ class Factory
} }
/** /**
* @param Config $config * @param Config $config
* @param string $vendorDir * @param string $vendorDir
* @return Repository\InstalledFilesystemRepository|null * @return Repository\InstalledFilesystemRepository|null
*/ */
protected function createGlobalRepository(Config $config, $vendorDir) protected function createGlobalRepository(Config $config, $vendorDir)
@ -415,9 +415,9 @@ class Factory
} }
/** /**
* @param Composer $composer * @param Composer $composer
* @param IOInterface $io * @param IOInterface $io
* @param RepositoryInterface $globalRepository * @param RepositoryInterface $globalRepository
* @return Plugin\PluginManager * @return Plugin\PluginManager
*/ */
protected function createPluginManager(Composer $composer, IOInterface $io, RepositoryInterface $globalRepository = null) protected function createPluginManager(Composer $composer, IOInterface $io, RepositoryInterface $globalRepository = null)

@ -380,7 +380,7 @@ class Installer
} }
if ($this->update) { if ($this->update) {
$this->io->write('<info>Updating dependencies'.($withDevReqs?' (including require-dev)':'').'</info>'); $this->io->write('<info>Updating dependencies'.($withDevReqs ? ' (including require-dev)' : '').'</info>');
$request->updateAll(); $request->updateAll();
@ -431,7 +431,7 @@ class Installer
} }
} }
} elseif ($installFromLock) { } elseif ($installFromLock) {
$this->io->write('<info>Installing dependencies'.($withDevReqs?' (including require-dev)':'').' from lock file</info>'); $this->io->write('<info>Installing dependencies'.($withDevReqs ? ' (including require-dev)' : '').' from lock file</info>');
if (!$this->locker->isFresh()) { if (!$this->locker->isFresh()) {
$this->io->write('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>'); $this->io->write('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>');
@ -451,7 +451,7 @@ class Installer
$request->install($link->getTarget(), $link->getConstraint()); $request->install($link->getTarget(), $link->getConstraint());
} }
} else { } else {
$this->io->write('<info>Installing dependencies'.($withDevReqs?' (including require-dev)':'').'</info>'); $this->io->write('<info>Installing dependencies'.($withDevReqs ? ' (including require-dev)' : '').'</info>');
if ($withDevReqs) { if ($withDevReqs) {
$links = array_merge($this->package->getRequires(), $this->package->getDevRequires()); $links = array_merge($this->package->getRequires(), $this->package->getDevRequires());

@ -40,7 +40,6 @@ class PluginInstaller extends LibraryInstaller
{ {
parent::__construct($io, $composer, 'composer-plugin'); parent::__construct($io, $composer, 'composer-plugin');
$this->installationManager = $composer->getInstallationManager(); $this->installationManager = $composer->getInstallationManager();
} }
/** /**

@ -188,8 +188,8 @@ class JsonFile
// compact brackets to follow recent php versions // compact brackets to follow recent php versions
if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512)) { if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512)) {
$json = preg_replace('/\[\s+\]/', '[]', $json); $json = preg_replace('/\[\s+\]/', '[]', $json);
$json = preg_replace('/\{\s+\}/', '{}', $json); $json = preg_replace('/\{\s+\}/', '{}', $json);
} }
return $json; return $json;

@ -42,7 +42,7 @@ class JsonManipulator
if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) { if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
throw new \InvalidArgumentException('The json file must be an object ({})'); throw new \InvalidArgumentException('The json file must be an object ({})');
} }
$this->newline = false !== strpos($contents, "\r\n") ? "\r\n": "\n"; $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
$this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents; $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
$this->detectIndenting(); $this->detectIndenting();
} }

@ -50,5 +50,4 @@ abstract class SpecificConstraint implements LinkConstraintInterface
// implementations must implement a method of this format: // implementations must implement a method of this format:
// not declared abstract here because type hinting violates parameter coherence (TODO right word?) // not declared abstract here because type hinting violates parameter coherence (TODO right word?)
// public function matchSpecific(<SpecificConstraintType> $provider); // public function matchSpecific(<SpecificConstraintType> $provider);
} }

@ -67,7 +67,7 @@ class ArrayLoader implements LoaderInterface
throw new \UnexpectedValueException('Package '.$config['name'].'\'s bin key should be an array, '.gettype($config['bin']).' given.'); throw new \UnexpectedValueException('Package '.$config['name'].'\'s bin key should be an array, '.gettype($config['bin']).' given.');
} }
foreach ($config['bin'] as $key => $bin) { foreach ($config['bin'] as $key => $bin) {
$config['bin'][$key]= ltrim($bin, '/'); $config['bin'][$key] = ltrim($bin, '/');
} }
$package->setBinaries($config['bin']); $package->setBinaries($config['bin']);
} }

@ -297,7 +297,7 @@ class Locker
$time = $this->getPackageTime($package) ?: $time; $time = $this->getPackageTime($package) ?: $time;
} }
if (null !== $time) { if (null !== $time) {
$spec['time'] = $time; $spec['time'] = $time;
} }
unset($spec['installation-source']); unset($spec['installation-source']);

@ -150,7 +150,8 @@ class VersionParser
if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) { if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
try { try {
return $this->normalizeBranch($match[1]); return $this->normalizeBranch($match[1]);
} catch (\Exception $e) {} } catch (\Exception $e) {
}
} }
$extraMessage = ''; $extraMessage = '';
@ -365,7 +366,8 @@ class VersionParser
} }
return array(new VersionConstraint($matches[1] ?: '=', $version)); return array(new VersionConstraint($matches[1] ?: '=', $version));
} catch (\Exception $e) { } } catch (\Exception $e) {
}
} }
$message = 'Could not parse version constraint '.$constraint; $message = 'Could not parse version constraint '.$constraint;

@ -37,8 +37,8 @@ class VersionSelector
* Given a package name and optional version, returns the latest PackageInterface * Given a package name and optional version, returns the latest PackageInterface
* that matches. * that matches.
* *
* @param string $packageName * @param string $packageName
* @param string $targetPackageVersion * @param string $targetPackageVersion
* @return PackageInterface|bool * @return PackageInterface|bool
*/ */
public function findBestCandidate($packageName, $targetPackageVersion = null) public function findBestCandidate($packageName, $targetPackageVersion = null)
@ -73,7 +73,7 @@ class VersionSelector
* * dev-master -> ~2.1@dev (dev version with alias) * * dev-master -> ~2.1@dev (dev version with alias)
* * dev-master -> dev-master (dev versions are untouched) * * dev-master -> dev-master (dev versions are untouched)
* *
* @param PackageInterface $package * @param PackageInterface $package
* @return string * @return string
*/ */
public function findRecommendedRequireVersion(PackageInterface $package) public function findRecommendedRequireVersion(PackageInterface $package)
@ -90,6 +90,7 @@ class VersionSelector
$extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count); $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
if ($count) { if ($count) {
$extra = str_replace('.9999999', '.0', $extra); $extra = str_replace('.9999999', '.0', $extra);
return $this->transformVersion($extra, $extra, 'dev'); return $this->transformVersion($extra, $extra, 'dev');
} }
} }

@ -96,7 +96,7 @@ class ArtifactRepository extends ArrayRepository
return $i; return $i;
} }
if(strpos($directoryName, '\\') !== false || if (strpos($directoryName, '\\') !== false ||
strpos($directoryName, '/') !== false) { strpos($directoryName, '/') !== false) {
//composer.json files below first directory are rejected //composer.json files below first directory are rejected
continue; continue;

@ -51,7 +51,7 @@ class PackageDependencyParser
*/ */
private function buildDependency10Info($depArray) private function buildDependency10Info($depArray)
{ {
static $dep10toOperatorMap = array('has'=>'==', 'eq' => '==', 'ge' => '>=', 'gt' => '>', 'le' => '<=', 'lt' => '<', 'not' => '!='); static $dep10toOperatorMap = array('has' => '==', 'eq' => '==', 'ge' => '>=', 'gt' => '>', 'le' => '<=', 'lt' => '<', 'not' => '!=');
$result = array(); $result = array();
@ -255,7 +255,7 @@ class PackageDependencyParser
*/ */
private function parse20VersionConstraint(array $data) private function parse20VersionConstraint(array $data)
{ {
static $dep20toOperatorMap = array('has'=>'==', 'min' => '>=', 'max' => '<=', 'exclude' => '!='); static $dep20toOperatorMap = array('has' => '==', 'min' => '>=', 'max' => '<=', 'exclude' => '!=');
$versions = array(); $versions = array();
$values = array_intersect_key($data, $dep20toOperatorMap); $values = array_intersect_key($data, $dep20toOperatorMap);

@ -203,7 +203,7 @@ class GitDriver extends VcsDriver
foreach ($this->process->splitLines($output) as $branch) { foreach ($this->process->splitLines($output) as $branch) {
if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) { if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+) .*$}', $branch, $match)) { if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
$branches[$match[1]] = $match[2]; $branches[$match[1]] = $match[2];
} }
} }
} }

@ -182,5 +182,4 @@ class PerforceDriver extends VcsDriver
{ {
return $this->branch; return $this->branch;
} }
} }

@ -27,7 +27,6 @@ use Composer\Downloader\TransportException;
*/ */
class SvnDriver extends VcsDriver class SvnDriver extends VcsDriver
{ {
/** /**
* @var Cache * @var Cache
*/ */

@ -126,7 +126,7 @@ class NoProxyPattern
// Now do some bit shifting/switching to convert to ints // Now do some bit shifting/switching to convert to ints
$i = ($a << 24) + ($b << 16) + ($c << 8) + $d; $i = ($a << 24) + ($b << 16) + ($c << 8) + $d;
$mask = $bits == 0 ? 0: (~0 << (32 - $bits)); $mask = $bits == 0 ? 0 : (~0 << (32 - $bits));
// Here's our lowest int // Here's our lowest int
$low = $i & $mask; $low = $i & $mask;

@ -570,5 +570,4 @@ class Perforce
{ {
$this->filesystem = $fs; $this->filesystem = $fs;
} }
} }

@ -105,7 +105,7 @@ class ProcessExecutor
{ {
static::$timeout = $timeout; static::$timeout = $timeout;
} }
/** /**
* Escapes a string to be used as a shell argument. * Escapes a string to be used as a shell argument.
* *
@ -113,9 +113,9 @@ class ProcessExecutor
* *
* @return string The escaped argument * @return string The escaped argument
*/ */
public static function escape ($argument) public static function escape($argument)
{ {
return ProcessUtils::escapeArgument($argument); return ProcessUtils::escapeArgument($argument);
} }
} }

@ -137,7 +137,6 @@ class Svn
// try to authenticate if maximum quantity of tries not reached // try to authenticate if maximum quantity of tries not reached
if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) { if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
// restart the process // restart the process
return $this->execute($command, $url, $cwd, $path, $verbose); return $this->execute($command, $url, $cwd, $path, $verbose);
} }

@ -18,7 +18,7 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
* @param bool $prependSeparator Whether to call ->loadClass() with a class name with preceding * @param bool $prependSeparator Whether to call ->loadClass() with a class name with preceding
* namespace separator, as it happens in PHP 5.3.0 - 5.3.2. See https://bugs.php.net/50731 * namespace separator, as it happens in PHP 5.3.0 - 5.3.2. See https://bugs.php.net/50731
*/ */
public function testLoadClass($class, $prependSeparator = FALSE) public function testLoadClass($class, $prependSeparator = false)
{ {
$loader = new ClassLoader(); $loader = new ClassLoader();
$loader->add('Namespaced\\', __DIR__ . '/Fixtures'); $loader->add('Namespaced\\', __DIR__ . '/Fixtures');

@ -48,7 +48,6 @@ class JsonConfigSourceTest extends \PHPUnit_Framework_TestCase
$value, $value,
$this->fixturePath('addLink/'.$fixtureBasename.'.json'), $this->fixturePath('addLink/'.$fixtureBasename.'.json'),
); );
} }
/** /**

@ -654,8 +654,7 @@ class SolverTest extends TestCase
public function testConflictResultEmpty() public function testConflictResultEmpty()
{ {
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));; $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$packageA->setConflicts(array( $packageA->setConflicts(array(
'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'conflicts'), 'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'conflicts'),
)); ));

@ -25,19 +25,19 @@ class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v1.0', array('php' => '/'), array()); $fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v1.0', array('php' => '/'), array());
$expectedFileActions = array( $expectedFileActions = array(
'Gtk.php' => Array( 'Gtk.php' => array(
'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk.php', 'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk.php',
'to' => 'PEAR/Frontend/Gtk.php', 'to' => 'PEAR/Frontend/Gtk.php',
'role' => 'php', 'role' => 'php',
'tasks' => array(), 'tasks' => array(),
), ),
'Gtk/Config.php' => Array( 'Gtk/Config.php' => array(
'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/Config.php', 'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/Config.php',
'to' => 'PEAR/Frontend/Gtk/Config.php', 'to' => 'PEAR/Frontend/Gtk/Config.php',
'role' => 'php', 'role' => 'php',
'tasks' => array(), 'tasks' => array(),
), ),
'Gtk/xpm/black_close_icon.xpm' => Array( 'Gtk/xpm/black_close_icon.xpm' => array(
'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/xpm/black_close_icon.xpm', 'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/xpm/black_close_icon.xpm',
'to' => 'PEAR/Frontend/Gtk/xpm/black_close_icon.xpm', 'to' => 'PEAR/Frontend/Gtk/xpm/black_close_icon.xpm',
'role' => 'php', 'role' => 'php',
@ -56,7 +56,7 @@ class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.0', array('php' => '/'), array()); $fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.0', array('php' => '/'), array());
$expectedFileActions = array( $expectedFileActions = array(
'URL.php' => Array( 'URL.php' => array(
'from' => 'Net_URL-1.0.15/URL.php', 'from' => 'Net_URL-1.0.15/URL.php',
'to' => 'Net/URL.php', 'to' => 'Net/URL.php',
'role' => 'php', 'role' => 'php',
@ -75,13 +75,13 @@ class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.1', array('php' => '/', 'script' => '/bin'), array()); $fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.1', array('php' => '/', 'script' => '/bin'), array());
$expectedFileActions = array( $expectedFileActions = array(
'php/Zend/Authentication/Storage/StorageInterface.php' => Array( 'php/Zend/Authentication/Storage/StorageInterface.php' => array(
'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Storage/StorageInterface.php', 'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Storage/StorageInterface.php',
'to' => '/php/Zend/Authentication/Storage/StorageInterface.php', 'to' => '/php/Zend/Authentication/Storage/StorageInterface.php',
'role' => 'php', 'role' => 'php',
'tasks' => array(), 'tasks' => array(),
), ),
'php/Zend/Authentication/Result.php' => Array( 'php/Zend/Authentication/Result.php' => array(
'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Result.php', 'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Result.php',
'to' => '/php/Zend/Authentication/Result.php', 'to' => '/php/Zend/Authentication/Result.php',
'role' => 'php', 'role' => 'php',
@ -98,7 +98,7 @@ class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
) )
) )
), ),
'renamedFile.php' => Array( 'renamedFile.php' => array(
'from' => 'Zend_Authentication-2.0.0beta4/renamedFile.php', 'from' => 'Zend_Authentication-2.0.0beta4/renamedFile.php',
'to' => 'correctFile.php', 'to' => 'correctFile.php',
'role' => 'php', 'role' => 'php',

@ -22,7 +22,6 @@ use Composer\IO\IOInterface;
*/ */
class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
{ {
protected $config; protected $config;
protected $downloader; protected $downloader;
protected $io; protected $io;

@ -152,7 +152,7 @@ class InstallerTest extends TestCase
$io->expects($this->any()) $io->expects($this->any())
->method('write') ->method('write')
->will($this->returnCallback(function ($text, $newline) use (&$output) { ->will($this->returnCallback(function ($text, $newline) use (&$output) {
$output .= $text . ($newline ? "\n":""); $output .= $text . ($newline ? "\n" : "");
})); }));
$composer = FactoryMock::create($io, $composerConfig); $composer = FactoryMock::create($io, $composerConfig);

@ -226,5 +226,4 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($json, $file->encode($data, $options)); $this->assertEquals($json, $file->encode($data, $options));
} }
} }
} }

@ -46,5 +46,4 @@ class JsonFormatterTest extends \PHPUnit_Framework_TestCase
return implode('+', $codes); return implode('+', $codes);
} }
} }

@ -36,5 +36,4 @@ class RemoteFilesystemMock extends RemoteFilesystem
throw new TransportException('The "'.$fileUrl.'" file could not be downloaded (NOT FOUND)', 404); throw new TransportException('The "'.$fileUrl.'" file could not be downloaded (NOT FOUND)', 404);
} }
} }

@ -13,7 +13,6 @@
namespace Composer\Test\Package\Archiver; namespace Composer\Test\Package\Archiver;
use Composer\Factory; use Composer\Factory;
use Composer\Package\Archiver;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
class ArchiveManagerTest extends ArchiverTest class ArchiveManagerTest extends ArchiverTest

@ -39,7 +39,7 @@ class PluginInstallerTest extends \PHPUnit_Framework_TestCase
$this->directory = sys_get_temp_dir() . '/' . uniqid(); $this->directory = sys_get_temp_dir() . '/' . uniqid();
for ($i = 1; $i <= 4; $i++) { for ($i = 1; $i <= 4; $i++) {
$filename = '/Fixtures/plugin-v'.$i.'/composer.json'; $filename = '/Fixtures/plugin-v'.$i.'/composer.json';
mkdir(dirname($this->directory . $filename), 0777, TRUE); mkdir(dirname($this->directory . $filename), 0777, true);
$this->packages[] = $loader->load(__DIR__ . $filename); $this->packages[] = $loader->load(__DIR__ . $filename);
} }

@ -16,7 +16,6 @@ use Composer\TestCase;
use Composer\IO\NullIO; use Composer\IO\NullIO;
use Composer\Config; use Composer\Config;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
use Composer\Util\Filesystem;
class ArtifactRepositoryTest extends TestCase class ArtifactRepositoryTest extends TestCase
{ {
@ -67,7 +66,6 @@ class ArtifactRepositoryTest extends TestCase
$this->assertTrue(strpos($package->getDistUrl(), $relativePath) === 0); $this->assertTrue(strpos($package->getDistUrl(), $relativePath) === 0);
} }
} }
} }
//Files jsonInFirstLevel.zip, jsonInRoot.zip and jsonInSecondLevel.zip were generated with: //Files jsonInFirstLevel.zip, jsonInRoot.zip and jsonInSecondLevel.zip were generated with:

@ -73,7 +73,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
protected function getTestConfig($testPath) protected function getTestConfig($testPath)
{ {
$config = new Config(); $config = new Config();
$config->merge(array('config'=>array('home'=>$testPath))); $config->merge(array('config' => array('home' => $testPath)));
return $config; return $config;
} }
@ -173,5 +173,4 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
$this->perforce->expects($this->once())->method('cleanupClientSpec'); $this->perforce->expects($this->once())->method('cleanupClientSpec');
$this->driver->cleanup(); $this->driver->cleanup();
} }
} }

@ -718,5 +718,4 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->perforce->cleanupClientSpec(); $this->perforce->cleanupClientSpec();
} }
} }

Loading…
Cancel
Save