1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00
This commit is contained in:
Jordi Boggiano 2014-06-10 16:02:44 +02:00
parent d036b2390e
commit ac497feaba
53 changed files with 166 additions and 156 deletions

View file

@ -623,7 +623,7 @@ FOOTER;
* *
* Packages of equal weight retain the original order * Packages of equal weight retain the original order
* *
* @param array $packageMap * @param array $packageMap
* @return array * @return array
*/ */
protected function sortPackageMap(array $packageMap) protected function sortPackageMap(array $packageMap)
@ -646,7 +646,7 @@ FOOTER;
$computing = array(); $computing = array();
$computed = array(); $computed = array();
$computeImportance = function($name) use(&$computeImportance, &$computing, &$computed, $usageList) { $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
// reusing computed importance // reusing computed importance
if (isset($computed[$name])) { if (isset($computed[$name])) {
return $computed[$name]; return $computed[$name];
@ -679,17 +679,17 @@ FOOTER;
$weightList[$name] = $weight; $weightList[$name] = $weight;
} }
$stable_sort = function(&$array) { $stable_sort = function (&$array) {
static $transform, $restore; static $transform, $restore;
$i = 0; $i = 0;
if (!$transform) { if (!$transform) {
$transform = function(&$v, $k) use(&$i) { $transform = function (&$v, $k) use (&$i) {
$v = array($v, ++$i, $k, $v); $v = array($v, ++$i, $k, $v);
}; };
$restore = function(&$v, $k) { $restore = function (&$v, $k) {
$v = $v[3]; $v = $v[3];
}; };
} }

View file

@ -202,10 +202,11 @@ class ClassLoader
* Registers a set of PSR-4 directories for a given namespace, * Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace. * replacing any others previously set for this namespace.
* *
* @param string $prefix The prefix/namespace, with trailing '\\' * @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories * @param array|string $paths The PSR-4 base directories
*/ */
public function setPsr4($prefix, $paths) { public function setPsr4($prefix, $paths)
{
if (!$prefix) { if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths; $this->fallbackDirsPsr4 = (array) $paths;
} else { } else {

View file

@ -28,7 +28,7 @@ class ClassMapGenerator
* Generate a class map file * Generate a class map file
* *
* @param \Traversable $dirs Directories or a single path to search in * @param \Traversable $dirs Directories or a single path to search in
* @param string $file The name of the class map file * @param string $file The name of the class map file
*/ */
public static function dump($dirs, $file) public static function dump($dirs, $file)
{ {

View file

@ -144,8 +144,7 @@ class Cache
public function gc($ttl, $maxSize) public function gc($ttl, $maxSize)
{ {
if ($this->enabled) if ($this->enabled) {
{
$expire = new \DateTime(); $expire = new \DateTime();
$expire->modify('-'.$ttl.' seconds'); $expire->modify('-'.$ttl.' seconds');

View file

@ -69,6 +69,7 @@ EOT
if (0 === $returnCode) { if (0 === $returnCode) {
$this->getComposer()->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD); $this->getComposer()->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
} }
return $returnCode; return $returnCode;
} }

View file

@ -19,7 +19,6 @@ use Composer\Installer\ProjectInstaller;
use Composer\Installer\InstallationManager; use Composer\Installer\InstallationManager;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\Repository\ComposerRepository; use Composer\Repository\ComposerRepository;
@ -339,10 +338,10 @@ EOT
/** /**
* 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
* @param InputInterface $input * @param InputInterface $input
* @param boolean $preferSource * @param boolean $preferSource
* @param boolean $preferDist * @param boolean $preferDist
*/ */
protected function updatePreferredOptions(Config $config, InputInterface $input, &$preferSource, &$preferDist) protected function updatePreferredOptions(Config $config, InputInterface $input, &$preferSource, &$preferDist)
{ {

View file

@ -64,6 +64,7 @@ EOT
{ {
if ($args = $input->getArgument('packages')) { if ($args = $input->getArgument('packages')) {
$output->writeln('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>'); $output->writeln('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
return 1; return 1;
} }

View file

@ -269,7 +269,7 @@ class Config
/** /**
* Replaces {$refs} inside a config string * Replaces {$refs} inside a config string
* *
* @param string $value a config string that can contain {$refs-to-other-config} * @param string $value a config string that can contain {$refs-to-other-config}
* @return string * @return string
*/ */
private function process($value) private function process($value)

View file

@ -179,14 +179,15 @@ class JsonConfigSource implements ConfigSourceInterface
/** /**
* Prepend a reference to an element to the beginning of an array. * Prepend a reference to an element to the beginning of an array.
* *
* @param array $array * @param array $array
* @param mixed $value * @param mixed $value
* @return array * @return array
*/ */
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;
} }
} }

View file

@ -227,12 +227,12 @@ class Pool
/** /**
* Searches all packages providing the given package name and match the constraint * Searches all packages providing the given package name and match the constraint
* *
* @param string $name The package name to be searched for * @param string $name The package name to be searched for
* @param LinkConstraintInterface $constraint A constraint that all returned * @param LinkConstraintInterface $constraint A constraint that all returned
* 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 array A set of packages * @return array A set of packages
*/ */
public function whatProvides($name, LinkConstraintInterface $constraint = null, $mustMatchName = false) public function whatProvides($name, LinkConstraintInterface $constraint = null, $mustMatchName = false)
{ {

View file

@ -40,13 +40,13 @@ class RuleSetGenerator
* This rule is of the form (-A|B|C), where B and C are the providers of * This rule is of the form (-A|B|C), where B and C are the providers of
* one requirement of the package A. * one requirement of the package A.
* *
* @param PackageInterface $package The package with a requirement * @param PackageInterface $package The package with a requirement
* @param array $providers The providers of the requirement * @param array $providers The providers of the requirement
* @param int $reason A RULE_* constant describing the * @param int $reason A RULE_* constant describing the
* reason for generating this rule * reason for generating this rule
* @param mixed $reasonData Any data, e.g. the requirement name, * @param mixed $reasonData Any data, e.g. the requirement name,
* that goes with the reason * that goes with the reason
* @return Rule The generated rule or null if tautological * @return Rule The generated rule or null if tautological
*/ */
protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null) protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
{ {
@ -69,10 +69,10 @@ class RuleSetGenerator
* The rule is (A|B|C) with A, B and C different packages. If the given * The rule is (A|B|C) with A, B and C different packages. If the given
* set of packages is empty an impossible rule is generated. * set of packages is empty an impossible rule is generated.
* *
* @param array $packages The set of packages to choose from * @param array $packages The set of packages to choose from
* @param int $reason A RULE_* constant describing the reason for * @param int $reason A RULE_* constant describing the reason for
* generating this rule * generating this rule
* @param array $job The job this rule was created from * @param array $job The job this rule was created from
* @return Rule The generated rule * @return Rule The generated rule
*/ */
protected function createInstallOneOfRule(array $packages, $reason, $job) protected function createInstallOneOfRule(array $packages, $reason, $job)
@ -90,11 +90,11 @@ class RuleSetGenerator
* *
* The rule for a package A is (-A). * The rule for a package A is (-A).
* *
* @param PackageInterface $package The package to be removed * @param PackageInterface $package The package to be removed
* @param int $reason A RULE_* constant describing the * @param int $reason A RULE_* constant describing the
* reason for generating this rule * reason for generating this rule
* @param array $job The job this rule was created from * @param array $job The job this rule was created from
* @return Rule The generated rule * @return Rule The generated rule
*/ */
protected function createRemoveRule(PackageInterface $package, $reason, $job) protected function createRemoveRule(PackageInterface $package, $reason, $job)
{ {
@ -107,13 +107,13 @@ class RuleSetGenerator
* The rule for conflicting packages A and B is (-A|-B). A is called the issuer * The rule for conflicting packages A and B is (-A|-B). A is called the issuer
* and B the provider. * and B the provider.
* *
* @param PackageInterface $issuer The package declaring the conflict * @param PackageInterface $issuer The package declaring the conflict
* @param PackageInterface $provider The package causing the conflict * @param PackageInterface $provider The package causing the conflict
* @param int $reason A RULE_* constant describing the * @param int $reason A RULE_* constant describing the
* reason for generating this rule * reason for generating this rule
* @param mixed $reasonData Any data, e.g. the package name, that * @param mixed $reasonData Any data, e.g. the package name, that
* goes with the reason * goes with the reason
* @return Rule The generated rule * @return Rule The generated rule
*/ */
protected function createConflictRule(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null) protected function createConflictRule(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
{ {
@ -262,7 +262,7 @@ class RuleSetGenerator
* Adds all rules for all update packages of a given package * Adds all rules for all update packages of a given package
* *
* @param PackageInterface $package Rules for this package's updates are to * @param PackageInterface $package Rules for this package's updates are to
* be added * be added
*/ */
private function addRulesForUpdatePackages(PackageInterface $package) private function addRulesForUpdatePackages(PackageInterface $package)
{ {

View file

@ -69,11 +69,11 @@ class RuleWatchGraph
* above example the rule was (-A|+B), then A turning true means that * above example the rule was (-A|+B), then A turning true means that
* B must now be decided true as well. * B must now be decided true as well.
* *
* @param int $decidedLiteral The literal which was decided (A in our example) * @param int $decidedLiteral The literal which was decided (A in our example)
* @param int $level The level at which the decision took place and at which * @param int $level The level at which the decision took place and at which
* all resulting decisions should be made. * all resulting decisions should be made.
* @param Decisions $decisions Used to check previous decisions and to * @param Decisions $decisions Used to check previous decisions and to
* register decisions resulting from propagation * register decisions resulting from propagation
* @return Rule|null If a conflict is found the conflicting rule is returned * @return Rule|null If a conflict is found the conflicting rule is returned
*/ */
public function propagateLiteral($decidedLiteral, $level, $decisions) public function propagateLiteral($decidedLiteral, $level, $decisions)

View file

@ -13,7 +13,6 @@
namespace Composer\DependencyResolver; namespace Composer\DependencyResolver;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
use Composer\DependencyResolver\Operation;
/** /**
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>

View file

@ -13,7 +13,6 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Downloader\DownloaderInterface;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
@ -104,7 +103,7 @@ class DownloadManager
/** /**
* Returns downloader for a specific installation type. * Returns downloader for a specific installation type.
* *
* @param string $type installation type * @param string $type installation type
* @return DownloaderInterface * @return DownloaderInterface
* *
* @throws \InvalidArgumentException if downloader for provided type is not registered * @throws \InvalidArgumentException if downloader for provided type is not registered
@ -122,12 +121,12 @@ class DownloadManager
/** /**
* Returns downloader for already installed package. * Returns downloader for already installed package.
* *
* @param PackageInterface $package package instance * @param PackageInterface $package package instance
* @return DownloaderInterface|null * @return DownloaderInterface|null
* *
* @throws \InvalidArgumentException if package has no installation source specified * @throws \InvalidArgumentException if package has no installation source specified
* @throws \LogicException if specific downloader used to load package with * @throws \LogicException if specific downloader used to load package with
* wrong type * wrong type
*/ */
public function getDownloaderForInstalledPackage(PackageInterface $package) public function getDownloaderForInstalledPackage(PackageInterface $package)
{ {

View file

@ -21,7 +21,6 @@ use Composer\Plugin\PluginEvents;
use Composer\Plugin\PreFileDownloadEvent; use Composer\Plugin\PreFileDownloadEvent;
use Composer\EventDispatcher\EventDispatcher; use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\Util\GitHub;
use Composer\Util\RemoteFilesystem; use Composer\Util\RemoteFilesystem;
/** /**
@ -60,7 +59,6 @@ class FileDownloader implements DownloaderInterface
$this->filesystem = $filesystem ?: new Filesystem(); $this->filesystem = $filesystem ?: new Filesystem();
$this->cache = $cache; $this->cache = $cache;
if ($this->cache && $this->cache->gcIsNecessary()) { if ($this->cache && $this->cache->gcIsNecessary()) {
$this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize')); $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
} }

View file

@ -47,7 +47,7 @@ class GitDownloader extends VcsDownloader
$command = 'git clone --no-checkout %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer'; $command = 'git clone --no-checkout %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer';
$this->io->write(" Cloning ".$ref); $this->io->write(" Cloning ".$ref);
$commandCallable = function($url) use ($ref, $path, $command) { $commandCallable = function ($url) use ($ref, $path, $command) {
return sprintf($command, escapeshellarg($url), escapeshellarg($path), escapeshellarg($ref)); return sprintf($command, escapeshellarg($url), escapeshellarg($path), escapeshellarg($ref));
}; };
@ -77,7 +77,7 @@ class GitDownloader extends VcsDownloader
$this->io->write(" Checking out ".$ref); $this->io->write(" Checking out ".$ref);
$command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer'; $command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
$commandCallable = function($url) use ($command) { $commandCallable = function ($url) use ($command) {
return sprintf($command, escapeshellarg($url)); return sprintf($command, escapeshellarg($url));
}; };
@ -201,10 +201,10 @@ class GitDownloader extends VcsDownloader
/** /**
* Updates the given path to the given commit ref * Updates the given path to the given commit ref
* *
* @param string $path * @param string $path
* @param string $reference * @param string $reference
* @param string $branch * @param string $branch
* @param DateTime $date * @param DateTime $date
* @return null|string if a string is returned, it is the commit reference that was checked out if the original could not be found * @return null|string if a string is returned, it is the commit reference that was checked out if the original could not be found
*/ */
protected function updateToCommit($path, $reference, $branch, $date) protected function updateToCommit($path, $reference, $branch, $date)

View file

@ -68,4 +68,3 @@ class GzipDownloader extends ArchiveDownloader
return $path.'/'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME); return $path.'/'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME);
} }
} }

View file

@ -127,11 +127,11 @@ class PearPackageExtractor
/** /**
* Builds list of copy and list of remove actions that would transform extracted PEAR tarball into installed package. * Builds list of copy and list of remove actions that would transform extracted PEAR tarball into installed package.
* *
* @param string $source string path to extracted files * @param string $source string path to extracted files
* @param array $roles array [role => roleRoot] relative root for files having that role * @param array $roles array [role => roleRoot] relative root for files having that role
* @param array $vars list of values can be used for replacement tasks * @param array $vars list of values can be used for replacement tasks
* @return array array of 'source' => 'target', where source is location of file in the tarball (relative to source * @return array array of 'source' => 'target', where source is location of file in the tarball (relative to source
* path, and target is destination of file (also relative to $source path) * path, and target is destination of file (also relative to $source path)
* @throws \RuntimeException * @throws \RuntimeException
*/ */
private function buildCopyActions($source, array $roles, $vars) private function buildCopyActions($source, array $roles, $vars)

View file

@ -44,10 +44,10 @@ class PerforceDownloader extends VcsDownloader
private function getLabelFromSourceReference($ref) private function getLabelFromSourceReference($ref)
{ {
$pos = strpos($ref,'@'); $pos = strpos($ref,'@');
if (false !== $pos) if (false !== $pos) {
{
return substr($ref, $pos + 1); return substr($ref, $pos + 1);
} }
return null; return null;
} }
@ -55,6 +55,7 @@ class PerforceDownloader extends VcsDownloader
{ {
if (!empty($this->perforce)) { if (!empty($this->perforce)) {
$this->perforce->initializePath($path); $this->perforce->initializePath($path);
return; return;
} }

View file

@ -181,10 +181,10 @@ 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
*/ */
protected function cleanChanges(PackageInterface $package, $path, $update) protected function cleanChanges(PackageInterface $package, $path, $update)

View file

@ -45,7 +45,7 @@ class ZipDownloader extends ArchiveDownloader
} }
$processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput(); $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
} catch(\Exception $e) { } catch (\Exception $e) {
$processError = 'Failed to execute ' . $command . "\n\n" . $e->getMessage(); $processError = 'Failed to execute ' . $command . "\n\n" . $e->getMessage();
} }
} }

View file

@ -178,9 +178,9 @@ class Factory
/** /**
* Creates a Composer instance * Creates a Composer instance
* *
* @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
@ -453,10 +453,10 @@ 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

@ -26,7 +26,6 @@ use Composer\DependencyResolver\SolverProblemsException;
use Composer\Downloader\DownloadManager; use Composer\Downloader\DownloadManager;
use Composer\EventDispatcher\EventDispatcher; use Composer\EventDispatcher\EventDispatcher;
use Composer\Installer\InstallationManager; use Composer\Installer\InstallationManager;
use Composer\Config;
use Composer\Installer\NoopInstaller; use Composer\Installer\NoopInstaller;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
@ -843,7 +842,7 @@ class Installer
/** /**
* Build a regexp from a package name, expanding * globs as required * Build a regexp from a package name, expanding * globs as required
* *
* @param string $whiteListedPattern * @param string $whiteListedPattern
* @return string * @return string
*/ */
private function packageNameToRegexp($whiteListedPattern) private function packageNameToRegexp($whiteListedPattern)
@ -1146,7 +1145,7 @@ class Installer
/** /**
* Should dependencies of whitelisted packages be updated recursively? * Should dependencies of whitelisted packages be updated recursively?
* *
* @param boolean $updateDependencies * @param boolean $updateDependencies
* @return Installer * @return Installer
*/ */
public function setWhitelistDependencies($updateDependencies = true) public function setWhitelistDependencies($updateDependencies = true)

View file

@ -13,7 +13,6 @@
namespace Composer\Json; namespace Composer\Json;
use JsonSchema\Validator; use JsonSchema\Validator;
use JsonSchema\Uri\UriRetriever;
use Seld\JsonLint\JsonParser; use Seld\JsonLint\JsonParser;
use Seld\JsonLint\ParsingException; use Seld\JsonLint\ParsingException;
use Composer\Util\RemoteFilesystem; use Composer\Util\RemoteFilesystem;

View file

@ -30,9 +30,9 @@ class JsonFormatter
* Originally licensed under MIT by Dave Perrett <mail@recursive-design.com> * Originally licensed under MIT by Dave Perrett <mail@recursive-design.com>
* *
* *
* @param string $json * @param string $json
* @param bool $unescapeUnicode Un escape unicode * @param bool $unescapeUnicode Un escape unicode
* @param bool $unescapeSlashes Un escape slashes * @param bool $unescapeSlashes Un escape slashes
* @return string * @return string
*/ */
public static function format($json, $unescapeUnicode, $unescapeSlashes) public static function format($json, $unescapeUnicode, $unescapeSlashes)
@ -66,7 +66,7 @@ class JsonFormatter
if ($unescapeUnicode && function_exists('mb_convert_encoding')) { if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
// http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha // http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha
$buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function($match) { $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
$l = strlen($match[1]); $l = strlen($match[1]);
if ($l % 2) { if ($l % 2) {
@ -76,6 +76,7 @@ class JsonFormatter
'UCS-2BE' 'UCS-2BE'
); );
} }
return $match[0]; return $match[0];
}, $buffer); }, $buffer);
} }

View file

@ -13,7 +13,6 @@
namespace Composer\Package; namespace Composer\Package;
use Composer\Package\LinkConstraint\LinkConstraintInterface; use Composer\Package\LinkConstraint\LinkConstraintInterface;
use Composer\Package\PackageInterface;
/** /**
* Represents a link between two packages, represented by their names * Represents a link between two packages, represented by their names

View file

@ -320,6 +320,7 @@ class RootPackageLoader extends ArrayLoader
if ('9999999-dev' === $version) { if ('9999999-dev' === $version) {
$version = 'dev-'.$matches[3]; $version = 'dev-'.$matches[3];
} }
return $version; return $version;
} }

View file

@ -16,7 +16,6 @@ use Composer\Json\JsonFile;
use Composer\Installer\InstallationManager; use Composer\Installer\InstallationManager;
use Composer\Repository\RepositoryManager; use Composer\Repository\RepositoryManager;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Package\AliasPackage;
use Composer\Repository\ArrayRepository; use Composer\Repository\ArrayRepository;
use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Dumper\ArrayDumper;
use Composer\Package\Loader\ArrayLoader; use Composer\Package\Loader\ArrayLoader;

View file

@ -75,22 +75,23 @@ class ArtifactRepository extends ArrayRepository
} }
/** /**
* Find a file by name, returning the one that has the shortest path. * Find a file by name, returning the one that has the shortest path.
* *
* @param \ZipArchive $zip * @param \ZipArchive $zip
* @param $filename * @param $filename
* @return bool|int * @return bool|int
*/ */
private function locateFile(\ZipArchive $zip, $filename) { private function locateFile(\ZipArchive $zip, $filename)
{
$indexOfShortestMatch = false; $indexOfShortestMatch = false;
$lengthOfShortestMatch = -1; $lengthOfShortestMatch = -1;
for ($i = 0; $i < $zip->numFiles; $i++ ){ for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i); $stat = $zip->statIndex($i);
if (strcmp(basename($stat['name']), $filename) === 0){ if (strcmp(basename($stat['name']), $filename) === 0) {
$directoryName = dirname($stat['name']); $directoryName = dirname($stat['name']);
if ($directoryName == '.') { if ($directoryName == '.') {
//if composer.json is in root directory //if composer.json is in root directory
//it has to be the one to use. //it has to be the one to use.
return $i; return $i;
} }
@ -100,7 +101,7 @@ class ArtifactRepository extends ArrayRepository
//composer.json files below first directory are rejected //composer.json files below first directory are rejected
continue; continue;
} }
$length = strlen($stat['name']); $length = strlen($stat['name']);
if ($indexOfShortestMatch == false || $length < $lengthOfShortestMatch) { if ($indexOfShortestMatch == false || $length < $lengthOfShortestMatch) {
//Check it's not a directory. //Check it's not a directory.
@ -115,7 +116,7 @@ class ArtifactRepository extends ArrayRepository
return $indexOfShortestMatch; return $indexOfShortestMatch;
} }
private function getComposerInformation(\SplFileInfo $file) private function getComposerInformation(\SplFileInfo $file)
{ {
$zip = new \ZipArchive(); $zip = new \ZipArchive();

View file

@ -275,6 +275,7 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
foreach ($package->getDistUrls() as $url) { foreach ($package->getDistUrls() as $url) {
if (strpos($url, $this->baseUrl) === 0) { if (strpos($url, $this->baseUrl) === 0) {
$package->setTransportOptions($this->options); $package->setTransportOptions($this->options);
return; return;
} }
} }

View file

@ -161,7 +161,6 @@ class PlatformRepository extends ArrayRepository
} }
} }
private function buildPackageName($name) private function buildPackageName($name)
{ {
return 'ext-' . str_replace(' ', '-', $name); return 'ext-' . str_replace(' ', '-', $name);

View file

@ -67,7 +67,7 @@ class GitDriver extends VcsDriver
$gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs); $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
$repoDir = $this->repoDir; $repoDir = $this->repoDir;
$commandCallable = function($url) use ($repoDir) { $commandCallable = function ($url) use ($repoDir) {
return sprintf('git clone --mirror %s %s', escapeshellarg($url), escapeshellarg($repoDir)); return sprintf('git clone --mirror %s %s', escapeshellarg($url), escapeshellarg($repoDir));
}; };

View file

@ -54,6 +54,7 @@ class GitHubDriver extends VcsDriver
if (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api']) { if (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api']) {
$this->setupGitDriver($this->url); $this->setupGitDriver($this->url);
return; return;
} }

View file

@ -140,6 +140,7 @@ class PerforceDriver extends VcsDriver
{ {
$this->composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier); $this->composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
$this->composerInfoIdentifier = $identifier; $this->composerInfoIdentifier = $identifier;
return !empty($this->composerInfo); return !empty($this->composerInfo);
} }

View file

@ -37,7 +37,7 @@ class ConfigValidator
/** /**
* Validates the config, and returns the result. * Validates the config, and returns the result.
* *
* @param string $file The path to the file * @param string $file The path to the file
* @param integer $arrayLoaderValidationFlags Flags for ArrayLoader validation * @param integer $arrayLoaderValidationFlags Flags for ArrayLoader validation
* *
* @return array a triple containing the errors, publishable errors, and warnings * @return array a triple containing the errors, publishable errors, and warnings

View file

@ -384,7 +384,7 @@ class Filesystem
/** /**
* Return if the given path is local * Return if the given path is local
* *
* @param string $path * @param string $path
* @return bool * @return bool
*/ */
public static function isLocalPath($path) public static function isLocalPath($path)

View file

@ -150,7 +150,7 @@ class GitHub
if (in_array($e->getCode(), array(403, 401))) { if (in_array($e->getCode(), array(403, 401))) {
// 401 when authentication was supplied, handle 2FA if required. // 401 when authentication was supplied, handle 2FA if required.
if ($this->io->hasAuthentication($originUrl)) { if ($this->io->hasAuthentication($originUrl)) {
$headerNames = array_map(function($header) { $headerNames = array_map(function ($header) {
return strtolower(strstr($header, ':', true)); return strtolower(strstr($header, ':', true));
}, $e->getHeaders()); }, $e->getHeaders());

View file

@ -53,12 +53,14 @@ class Perforce
{ {
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD'); $isWindows = defined('PHP_WINDOWS_VERSION_BUILD');
$perforce = new Perforce($repoConfig, $port, $path, $process, $isWindows, $io); $perforce = new Perforce($repoConfig, $port, $path, $process, $isWindows, $io);
return $perforce; return $perforce;
} }
public static function checkServerExists($url, ProcessExecutor $processExecutor) public static function checkServerExists($url, ProcessExecutor $processExecutor)
{ {
$output = null; $output = null;
return 0 === $processExecutor->execute('p4 -p ' . $url . ' info -s', $output); return 0 === $processExecutor->execute('p4 -p ' . $url . ' info -s', $output);
} }
@ -119,6 +121,7 @@ class Perforce
{ {
$this->commandResult = ""; $this->commandResult = "";
$exit_code = $this->process->execute($command, $this->commandResult); $exit_code = $this->process->execute($command, $this->commandResult);
return $exit_code; return $exit_code;
} }
@ -248,6 +251,7 @@ class Perforce
$command = 'echo $' . $name; $command = 'echo $' . $name;
$this->executeCommand($command); $this->executeCommand($command);
$result = trim($this->commandResult); $result = trim($this->commandResult);
return $result; return $result;
} }
} }
@ -283,18 +287,19 @@ class Perforce
{ {
$command = $this->generateP4Command('login -s', false); $command = $this->generateP4Command('login -s', false);
$exitCode = $this->executeCommand($command); $exitCode = $this->executeCommand($command);
if ($exitCode){ if ($exitCode) {
$errorOutput = $this->process->getErrorOutput(); $errorOutput = $this->process->getErrorOutput();
$index = strpos($errorOutput, $this->getUser()); $index = strpos($errorOutput, $this->getUser());
if ($index === false){ if ($index === false) {
$index = strpos($errorOutput, 'p4'); $index = strpos($errorOutput, 'p4');
if ($index===false){ if ($index === false) {
return false; return false;
} }
throw new \Exception('p4 command not found in path: ' . $errorOutput); throw new \Exception('p4 command not found in path: ' . $errorOutput);
} }
throw new \Exception('Invalid user name: ' . $this->getUser() ); throw new \Exception('Invalid user name: ' . $this->getUser() );
} }
return true; return true;
} }
@ -384,7 +389,7 @@ class Perforce
$command = 'echo ' . $password . ' | ' . $this->generateP4Command(' login -a', false); $command = 'echo ' . $password . ' | ' . $this->generateP4Command(' login -a', false);
$exitCode = $this->executeCommand($command); $exitCode = $this->executeCommand($command);
$result = trim($this->commandResult); $result = trim($this->commandResult);
if ($exitCode){ if ($exitCode) {
throw new \Exception("Error logging in:" . $this->process->getErrorOutput()); throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
} }
} }
@ -471,6 +476,7 @@ class Perforce
$lastCommitNum = $lastCommitArr[1]; $lastCommitNum = $lastCommitArr[1];
$branches = array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum); $branches = array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
return $branches; return $branches;
} }
@ -488,6 +494,7 @@ class Perforce
$tags[$fields[1]] = $this->getStream() . '@' . $fields[1]; $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
} }
} }
return $tags; return $tags;
} }
@ -552,14 +559,13 @@ class Perforce
public function getFilesystem() public function getFilesystem()
{ {
if (empty($this->filesystem)) if (empty($this->filesystem)) {
{
$this->filesystem = new Filesystem($this->process); $this->filesystem = new Filesystem($this->process);
} }
return $this->filesystem; return $this->filesystem;
} }
public function setFilesystem(Filesystem $fs) public function setFilesystem(Filesystem $fs)
{ {
$this->filesystem = $fs; $this->filesystem = $fs;

View file

@ -34,10 +34,10 @@ class ProcessExecutor
/** /**
* runs a process on the commandline * runs a process on the commandline
* *
* @param string $command the command to execute * @param string $command the command to execute
* @param mixed $output the output will be written into this var if passed by ref * @param mixed $output the output will be written into this var if passed by ref
* if a callable is passed it will be used as output handler * if a callable is passed it will be used as output handler
* @param string $cwd the working directory * @param string $cwd the working directory
* @return int statuscode * @return int statuscode
*/ */
public function execute($command, &$output = null, $cwd = null) public function execute($command, &$output = null, $cwd = null)

View file

@ -124,7 +124,7 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase
$testDir = sys_get_temp_dir().'/composer_functional_test'.uniqid(mt_rand(), true); $testDir = sys_get_temp_dir().'/composer_functional_test'.uniqid(mt_rand(), true);
$this->testDir = $testDir; $this->testDir = $testDir;
$varRegex = '#%([a-zA-Z_-]+)%#'; $varRegex = '#%([a-zA-Z_-]+)%#';
$variableReplacer = function($match) use (&$data, $testDir) { $variableReplacer = function ($match) use (&$data, $testDir) {
list(, $var) = $match; list(, $var) = $match;
switch ($var) { switch ($var) {

View file

@ -14,9 +14,9 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
* *
* @dataProvider getLoadClassTests * @dataProvider getLoadClassTests
* *
* @param string $class The fully-qualified class name to test, without preceding namespace separator. * @param string $class The fully-qualified class name to test, without preceding namespace separator.
* @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)
{ {

View file

@ -109,7 +109,7 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
$ioMock = $this->getMock('Composer\IO\IOInterface'); $ioMock = $this->getMock('Composer\IO\IOInterface');
$ioMock->expects($this->any()) $ioMock->expects($this->any())
->method('write') ->method('write')
->will($this->returnCallback(function($messages, $newline = true) use ($path) { ->will($this->returnCallback(function ($messages, $newline = true) use ($path) {
if (is_file($path.'/script.js')) { if (is_file($path.'/script.js')) {
unlink($path.'/script.js'); unlink($path.'/script.js');
} }

View file

@ -65,6 +65,7 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
$config = new Config(); $config = new Config();
$settings = array('config' => array('home' => $this->testPath)); $settings = array('config' => array('home' => $this->testPath));
$config->merge($settings); $config->merge($settings);
return $config; return $config;
} }
@ -77,6 +78,7 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
{ {
$package = $this->getMock('Composer\Package\PackageInterface'); $package = $this->getMock('Composer\Package\PackageInterface');
$package->expects($this->any())->method('getRepository')->will($this->returnValue($repository)); $package->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
return $package; return $package;
} }
@ -92,6 +94,7 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
$args = array($repoConfig, $io, $config); $args = array($repoConfig, $io, $config);
$repository = $this->getMock($class, $methods, $args); $repository = $this->getMock($class, $methods, $args);
$repository->expects($this->any())->method('getRepoConfig')->will($this->returnValue($repoConfig)); $repository->expects($this->any())->method('getRepoConfig')->will($this->returnValue($repoConfig));
return $repository; return $repository;
} }

View file

@ -34,7 +34,7 @@ class JsonFormatterTest extends \PHPUnit_Framework_TestCase
/** /**
* Convert string to character codes split by a plus sign * Convert string to character codes split by a plus sign
* @param string $string * @param string $string
* @return string * @return string
*/ */
protected function getCharacterCodes($string) protected function getCharacterCodes($string)
@ -43,6 +43,7 @@ class JsonFormatterTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < strlen($string); $i++) { for ($i = 0; $i < strlen($string); $i++) {
$codes[] = ord($string[$i]); $codes[] = ord($string[$i]);
} }
return implode('+', $codes); return implode('+', $codes);
} }

View file

@ -25,13 +25,13 @@ class JsonValidationExceptionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($message, $object->getMessage()); $this->assertEquals($message, $object->getMessage());
$this->assertEquals($errors, $object->getErrors()); $this->assertEquals($errors, $object->getErrors());
} }
public function testGetErrorsWhenNoErrorsProvided() public function testGetErrorsWhenNoErrorsProvided()
{ {
$object = new JsonValidationException('test message'); $object = new JsonValidationException('test message');
$this->assertEquals(array(), $object->getErrors()); $this->assertEquals(array(), $object->getErrors());
} }
public function errorProvider() public function errorProvider()
{ {
return array( return array(

View file

@ -35,7 +35,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
$self = $this; $self = $this;
/* Can do away with this mock object when https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81 is fixed */ /* Can do away with this mock object when https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81 is fixed */
$processExecutor = new ProcessExecutorMock(function($command, &$output = null, $cwd = null) use ($self, $commitHash) { $processExecutor = new ProcessExecutorMock(function ($command, &$output = null, $cwd = null) use ($self, $commitHash) {
if (0 === strpos($command, 'git describe')) { if (0 === strpos($command, 'git describe')) {
// simulate not being on a tag // simulate not being on a tag
return 1; return 1;
@ -69,7 +69,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
$self = $this; $self = $this;
/* Can do away with this mock object when https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81 is fixed */ /* Can do away with this mock object when https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81 is fixed */
$processExecutor = new ProcessExecutorMock(function($command, &$output = null, $cwd = null) use ($self) { $processExecutor = new ProcessExecutorMock(function ($command, &$output = null, $cwd = null) use ($self) {
$self->assertEquals('git describe --exact-match --tags', $command); $self->assertEquals('git describe --exact-match --tags', $command);
$output = "v2.0.5-alpha2"; $output = "v2.0.5-alpha2";
@ -98,7 +98,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
$self = $this; $self = $this;
/* Can do away with this mock object when https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81 is fixed */ /* Can do away with this mock object when https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81 is fixed */
$processExecutor = new ProcessExecutorMock(function($command, &$output = null, $cwd = null) use ($self) { $processExecutor = new ProcessExecutorMock(function ($command, &$output = null, $cwd = null) use ($self) {
if ('git describe --exact-match --tags' === $command) { if ('git describe --exact-match --tags' === $command) {
$output = "foo-bar"; $output = "foo-bar";
@ -124,7 +124,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$processExecutor = new ProcessExecutorMock(function($command, &$output = null, $cwd = null) { $processExecutor = new ProcessExecutorMock(function ($command, &$output = null, $cwd = null) {
return 1; return 1;
}); });

View file

@ -198,6 +198,7 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase
{ {
if (!$mustCheck) { if (!$mustCheck) {
$this->assertTrue(true); $this->assertTrue(true);
return; return;
} }
$internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface'); $internalLoader = $this->getMock('Composer\Package\Loader\LoaderInterface');

View file

@ -54,7 +54,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
); );
$self = $this; $self = $this;
$createPackage = function($arr) use ($self) { $createPackage = function ($arr) use ($self) {
$package = $self->getMock('\Composer\Package\PackageInterface'); $package = $self->getMock('\Composer\Package\PackageInterface');
$package->expects($self->once())->method('isDev')->will($self->returnValue(true)); $package->expects($self->once())->method('isDev')->will($self->returnValue(true));
$package->expects($self->once())->method('getSourceType')->will($self->returnValue('git')); $package->expects($self->once())->method('getSourceType')->will($self->returnValue('git'));

View file

@ -28,14 +28,14 @@ class ArtifactRepositoryTest extends TestCase
'vendor3/package1-5.4.3', 'vendor3/package1-5.4.3',
'test/jsonInRoot-1.0.0', 'test/jsonInRoot-1.0.0',
'test/jsonInFirstLevel-1.0.0', 'test/jsonInFirstLevel-1.0.0',
//The files not-an-artifact.zip and jsonSecondLevel are not valid //The files not-an-artifact.zip and jsonSecondLevel are not valid
//artifacts and do not get detected. //artifacts and do not get detected.
); );
$coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts'); $coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts');
$repo = new ArtifactRepository($coordinates, new NullIO(), new Config()); $repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
$foundPackages = array_map(function(BasePackage $package) { $foundPackages = array_map(function (BasePackage $package) {
return "{$package->getPrettyName()}-{$package->getPrettyVersion()}"; return "{$package->getPrettyName()}-{$package->getPrettyVersion()}";
}, $repo->getPackages()); }, $repo->getPackages());
@ -73,7 +73,7 @@ class ArtifactRepositoryTest extends TestCase
// ), // ),
//); //);
// //
//foreach($archivesToCreate as $archiveName => $fileDetails) { //foreach ($archivesToCreate as $archiveName => $fileDetails) {
// $zipFile = new ZipArchive(); // $zipFile = new ZipArchive();
// $zipFile->open("$archiveName.zip", ZIPARCHIVE::CREATE); // $zipFile->open("$archiveName.zip", ZIPARCHIVE::CREATE);
// //
@ -83,4 +83,3 @@ class ArtifactRepositoryTest extends TestCase
// //
// $zipFile->close(); // $zipFile->close();
//} //}

View file

@ -12,7 +12,6 @@
namespace Composer\Repository; namespace Composer\Repository;
use Composer\Repository\FilesystemRepository;
use Composer\TestCase; use Composer\TestCase;
class FilesystemRepositoryTest extends TestCase class FilesystemRepositoryTest extends TestCase

View file

@ -74,6 +74,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
{ {
$config = new Config(); $config = new Config();
$config->merge(array('config'=>array('home'=>$testPath))); $config->merge(array('config'=>array('home'=>$testPath)));
return $config; return $config;
} }
@ -104,6 +105,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
protected function getMockPerforce() protected function getMockPerforce()
{ {
$methods = array('p4login', 'checkStream', 'writeP4ClientSpec', 'connectClient', 'getComposerInformation', 'cleanupClientSpec'); $methods = array('p4login', 'checkStream', 'writeP4ClientSpec', 'connectClient', 'getComposerInformation', 'cleanupClientSpec');
return $this->getMockBuilder('Composer\Util\Perforce', $methods)->disableOriginalConstructor()->getMock(); return $this->getMockBuilder('Composer\Util\Perforce', $methods)->disableOriginalConstructor()->getMock();
} }

View file

@ -139,9 +139,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->createNewPerforceWithWindowsFlag(true); $this->createNewPerforceWithWindowsFlag(true);
$this->perforce->setUser(null); $this->perforce->setUser(null);
$expectedCommand = 'p4 set'; $expectedCommand = 'p4 set';
$callback = function($command, &$output) $callback = function ($command, &$output) {
{
$output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL; $output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL;
return true; return true;
}; };
$this->processExecutor->expects($this->at(0)) $this->processExecutor->expects($this->at(0))
@ -157,9 +157,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->createNewPerforceWithWindowsFlag(false); $this->createNewPerforceWithWindowsFlag(false);
$this->perforce->setUser(null); $this->perforce->setUser(null);
$expectedCommand = 'echo $P4USER'; $expectedCommand = 'echo $P4USER';
$callback = function($command, &$output) $callback = function ($command, &$output) {
{
$output = 'TEST_P4VARIABLE_USER' . PHP_EOL; $output = 'TEST_P4VARIABLE_USER' . PHP_EOL;
return true; return true;
}; };
$this->processExecutor->expects($this->at(0)) $this->processExecutor->expects($this->at(0))
@ -233,9 +233,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$this->createNewPerforceWithWindowsFlag(true); $this->createNewPerforceWithWindowsFlag(true);
$expectedCommand = 'p4 set'; $expectedCommand = 'p4 set';
$callback = function($command, &$output) $callback = function ($command, &$output) {
{
$output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL; $output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
return true; return true;
}; };
$this->processExecutor->expects($this->at(0)) $this->processExecutor->expects($this->at(0))
@ -250,9 +250,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$this->createNewPerforceWithWindowsFlag(false); $this->createNewPerforceWithWindowsFlag(false);
$expectedCommand = 'echo $P4PASSWD'; $expectedCommand = 'echo $P4PASSWD';
$callback = function($command, &$output) $callback = function ($command, &$output) {
{
$output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL; $output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
return true; return true;
}; };
$this->processExecutor->expects($this->at(0)) $this->processExecutor->expects($this->at(0))
@ -357,9 +357,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
) )
); );
$expectedCommand2 = 'p4 -u user -p port changes //depot/branch/...'; $expectedCommand2 = 'p4 -u user -p port changes //depot/branch/...';
$expectedCallback = function($command, &$output) $expectedCallback = function ($command, &$output) {
{
$output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\''; $output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
return true; return true;
}; };
$this->processExecutor->expects($this->at(1)) $this->processExecutor->expects($this->at(1))
@ -374,9 +374,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testGetBranchesWithoutStream() public function testGetBranchesWithoutStream()
{ {
$expectedCommand = 'p4 -u user -p port changes //depot/...'; $expectedCommand = 'p4 -u user -p port changes //depot/...';
$expectedCallback = function($command, &$output) $expectedCallback = function ($command, &$output) {
{
$output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\''; $output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
return true; return true;
}; };
$this->processExecutor->expects($this->once()) $this->processExecutor->expects($this->once())
@ -629,12 +629,12 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor); $result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor);
$this->assertTrue($result); $this->assertTrue($result);
} }
/** /**
* Test if "p4" command is missing. * Test if "p4" command is missing.
* *
* @covers \Composer\Util\Perforce::checkServerExists * @covers \Composer\Util\Perforce::checkServerExists
* *
* @return void * @return void
*/ */
public function testCheckServerClientError() public function testCheckServerClientError()
@ -646,7 +646,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand), $this->equalTo(null)) ->with($this->equalTo($expectedCommand), $this->equalTo(null))
->will($this->returnValue(127)); ->will($this->returnValue(127));
$result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor); $result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor);
$this->assertFalse($result); $this->assertFalse($result);
} }

View file

@ -52,7 +52,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
), ),
array( array(
$a = array('http' => array('method' => 'GET', 'max_redirects' => 20, 'follow_location' => 1)), array('http' => array('method' => 'GET')), $a = array('http' => array('method' => 'GET', 'max_redirects' => 20, 'follow_location' => 1)), array('http' => array('method' => 'GET')),
array('options' => $a, 'notification' => $f = function() {}), array('notification' => $f) array('options' => $a, 'notification' => $f = function () {}), array('notification' => $f)
), ),
); );
} }