main
Jordi Boggiano 10 years ago
parent d036b2390e
commit ac497feaba

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

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

@ -28,7 +28,7 @@ class ClassMapGenerator
* Generate a class map file
*
* @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)
{

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

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

@ -19,7 +19,6 @@ use Composer\Installer\ProjectInstaller;
use Composer\Installer\InstallationManager;
use Composer\IO\IOInterface;
use Composer\Package\BasePackage;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\Repository\ComposerRepository;
@ -339,10 +338,10 @@ EOT
/**
* Updated preferSource or preferDist based on the preferredInstall config option
* @param Config $config
* @param Config $config
* @param InputInterface $input
* @param boolean $preferSource
* @param boolean $preferDist
* @param boolean $preferSource
* @param boolean $preferDist
*/
protected function updatePreferredOptions(Config $config, InputInterface $input, &$preferSource, &$preferDist)
{

@ -64,6 +64,7 @@ EOT
{
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>');
return 1;
}

@ -269,7 +269,7 @@ class Config
/**
* 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
*/
private function process($value)

@ -179,14 +179,15 @@ class JsonConfigSource implements ConfigSourceInterface
/**
* Prepend a reference to an element to the beginning of an array.
*
* @param array $array
* @param mixed $value
* @param array $array
* @param mixed $value
* @return array
*/
private function arrayUnshiftRef(&$array, &$value)
{
$return = array_unshift($array, '');
$array[0] =& $value;
return $return;
}
}

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

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

@ -69,11 +69,11 @@ class RuleWatchGraph
* above example the rule was (-A|+B), then A turning true means that
* B must now be decided true as well.
*
* @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
* all resulting decisions should be made.
* @param Decisions $decisions Used to check previous decisions and to
* register decisions resulting from propagation
* @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
* all resulting decisions should be made.
* @param Decisions $decisions Used to check previous decisions and to
* register decisions resulting from propagation
* @return Rule|null If a conflict is found the conflicting rule is returned
*/
public function propagateLiteral($decidedLiteral, $level, $decisions)

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

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

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

@ -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';
$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));
};
@ -77,7 +77,7 @@ class GitDownloader extends VcsDownloader
$this->io->write(" Checking out ".$ref);
$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));
};
@ -201,10 +201,10 @@ class GitDownloader extends VcsDownloader
/**
* Updates the given path to the given commit ref
*
* @param string $path
* @param string $reference
* @param string $branch
* @param DateTime $date
* @param string $path
* @param string $reference
* @param string $branch
* @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
*/
protected function updateToCommit($path, $reference, $branch, $date)

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

@ -127,11 +127,11 @@ class PearPackageExtractor
/**
* 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 array $roles array [role => roleRoot] relative root for files having that role
* @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
* path, and target is destination of file (also relative to $source path)
* @param string $source string path to extracted files
* @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
* @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)
* @throws \RuntimeException
*/
private function buildCopyActions($source, array $roles, $vars)

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

@ -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
*
* @param PackageInterface $package
* @param string $path
* @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
* @param PackageInterface $package
* @param string $path
* @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
* @throws \RuntimeException in case the operation must be aborted
*/
protected function cleanChanges(PackageInterface $package, $path, $update)

@ -45,7 +45,7 @@ class ZipDownloader extends ArchiveDownloader
}
$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();
}
}

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

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

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

@ -30,9 +30,9 @@ class JsonFormatter
* Originally licensed under MIT by Dave Perrett <mail@recursive-design.com>
*
*
* @param string $json
* @param bool $unescapeUnicode Un escape unicode
* @param bool $unescapeSlashes Un escape slashes
* @param string $json
* @param bool $unescapeUnicode Un escape unicode
* @param bool $unescapeSlashes Un escape slashes
* @return string
*/
public static function format($json, $unescapeUnicode, $unescapeSlashes)
@ -66,7 +66,7 @@ class JsonFormatter
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
$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]);
if ($l % 2) {
@ -76,6 +76,7 @@ class JsonFormatter
'UCS-2BE'
);
}
return $match[0];
}, $buffer);
}

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

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

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

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

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

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

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

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

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

@ -37,7 +37,7 @@ class ConfigValidator
/**
* 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
*
* @return array a triple containing the errors, publishable errors, and warnings

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

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

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

@ -34,10 +34,10 @@ class ProcessExecutor
/**
* runs a process on the commandline
*
* @param string $command the command to execute
* @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
* @param string $cwd the working directory
* @param string $command the command to execute
* @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
* @param string $cwd the working directory
* @return int statuscode
*/
public function execute($command, &$output = null, $cwd = null)

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

@ -14,9 +14,9 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
*
* @dataProvider getLoadClassTests
*
* @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
* namespace separator, as it happens in PHP 5.3.0 - 5.3.2. See https://bugs.php.net/50731
* @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
* 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)
{

@ -109,7 +109,7 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
$ioMock = $this->getMock('Composer\IO\IOInterface');
$ioMock->expects($this->any())
->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')) {
unlink($path.'/script.js');
}

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

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

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

@ -35,7 +35,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
$self = $this;
/* 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')) {
// simulate not being on a tag
return 1;
@ -69,7 +69,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
$self = $this;
/* 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);
$output = "v2.0.5-alpha2";
@ -98,7 +98,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
$self = $this;
/* 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) {
$output = "foo-bar";
@ -124,7 +124,7 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$processExecutor = new ProcessExecutorMock(function($command, &$output = null, $cwd = null) {
$processExecutor = new ProcessExecutorMock(function ($command, &$output = null, $cwd = null) {
return 1;
});

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

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

@ -28,14 +28,14 @@ class ArtifactRepositoryTest extends TestCase
'vendor3/package1-5.4.3',
'test/jsonInRoot-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.
);
$coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts');
$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()}";
}, $repo->getPackages());
@ -73,7 +73,7 @@ class ArtifactRepositoryTest extends TestCase
// ),
//);
//
//foreach($archivesToCreate as $archiveName => $fileDetails) {
//foreach ($archivesToCreate as $archiveName => $fileDetails) {
// $zipFile = new ZipArchive();
// $zipFile->open("$archiveName.zip", ZIPARCHIVE::CREATE);
//
@ -83,4 +83,3 @@ class ArtifactRepositoryTest extends TestCase
//
// $zipFile->close();
//}

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

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

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

@ -52,7 +52,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
),
array(
$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)
),
);
}

Loading…
Cancel
Save