1
0
Fork 0

Merge remote-tracking branch 'origin/master' into 2.0

pull/8566/head
Jordi Boggiano 2020-02-11 11:33:52 +01:00
commit be8dd528b8
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
11 changed files with 135 additions and 15 deletions

View File

@ -53,6 +53,7 @@ return PhpCsFixer\Config::create()
'standardize_not_equals' => true, 'standardize_not_equals' => true,
'ternary_operator_spaces' => true, 'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true, 'trailing_comma_in_multiline_array' => true,
'unary_operator_spaces' => true,
)) ))
->setFinder($finder) ->setFinder($finder)
; ;

View File

@ -190,7 +190,7 @@ If you do not want to choose requirements interactively, you can pass them
to the command. to the command.
```sh ```sh
php composer.phar require vendor/package:2.* vendor/package2:dev-master php composer.phar require "vendor/package:2.*" vendor/package2:dev-master
``` ```
If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of matches to require. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of matches to require.
@ -649,7 +649,7 @@ provide a version as third argument, otherwise the latest version is used.
If the directory does not currently exist, it will be created during installation. If the directory does not currently exist, it will be created during installation.
```sh ```sh
php composer.phar create-project doctrine/orm path 2.2.* php composer.phar create-project doctrine/orm path "2.2.*"
``` ```
It is also possible to run the command without params in a directory with an It is also possible to run the command without params in a directory with an

View File

@ -1,7 +1,7 @@
# How do I install Composer programmatically? # How do I install Composer programmatically?
As noted on the download page, the installer script contains a As noted on the download page, the installer script contains a
signature which changes when the installer code changes and as such checksum which changes when the installer code changes and as such
it should not be relied upon in the long term. it should not be relied upon in the long term.
An alternative is to use this script which only works with UNIX utilities: An alternative is to use this script which only works with UNIX utilities:
@ -9,13 +9,13 @@ An alternative is to use this script which only works with UNIX utilities:
```bash ```bash
#!/bin/sh #!/bin/sh
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)" EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then then
>&2 echo 'ERROR: Invalid installer signature' >&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php rm composer-setup.php
exit 1 exit 1
fi fi

View File

@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
failOnRisky="true"
strict="false" strict="false"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"

View File

@ -65,15 +65,21 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$config = Factory::createConfig();
$composer = $this->getComposer(false); $composer = $this->getComposer(false);
$config = null;
if ($composer) { if ($composer) {
$config = $composer->getConfig();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
$eventDispatcher = $composer->getEventDispatcher(); $eventDispatcher = $composer->getEventDispatcher();
$eventDispatcher->dispatch($commandEvent->getName(), $commandEvent); $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
$eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD); $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
} }
if (!$config) {
$config = Factory::createConfig();
}
if (null === $input->getOption('format')) { if (null === $input->getOption('format')) {
$input->setOption('format', $config->get('archive-format')); $input->setOption('format', $config->get('archive-format'));
} }

View File

@ -220,7 +220,12 @@ class Application extends BaseApplication
$io->writeError(sprintf('<warning>Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF'])); $io->writeError(sprintf('<warning>Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
} }
if (!Platform::isWindows() && function_exists('exec') && !getenv('COMPOSER_ALLOW_SUPERUSER') && !file_exists('/.dockerenv')) { if (
!Platform::isWindows()
&& function_exists('exec')
&& !getenv('COMPOSER_ALLOW_SUPERUSER')
&& (ini_get('open_basedir') || !file_exists('/.dockerenv'))
) {
if (function_exists('posix_getuid') && posix_getuid() === 0) { if (function_exists('posix_getuid') && posix_getuid() === 0) {
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') { if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
$io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>'); $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');

View File

@ -13,6 +13,7 @@
namespace Composer\DependencyResolver\Operation; namespace Composer\DependencyResolver\Operation;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;
/** /**
* Solver update operation. * Solver update operation.
@ -85,7 +86,9 @@ class UpdateOperation extends SolverOperation
$toVersion = $this->targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF); $toVersion = $this->targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
} }
return 'Updating '.$this->initialPackage->getPrettyName().' ('.$fromVersion.' => '.$toVersion.')'; $actionName = VersionParser::isUpgrade($this->initialPackage->getVersion(), $this->targetPackage->getVersion()) ? 'Updating' : 'Downgrading';
return $actionName.' '.$this->initialPackage->getPrettyName().' ('.$fromVersion.' => '.$toVersion.')';
} }
/** /**

View File

@ -0,0 +1,103 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Test\Command;
use Composer\Composer;
use Composer\Config;
use Composer\Factory;
use Composer\Test\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
class ArchiveCommandTest extends TestCase
{
public function testUsesConfigFromComposerObject()
{
$input = new ArrayInput(array());
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')
->getMock();
$ed = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()->getMock();
$composer = new Composer;
$config = new Config;
$config->merge(array('config' => array('archive-format' => 'zip')));
$composer->setConfig($config);
$manager = $this->getMockBuilder('Composer\Package\Archiver\ArchiveManager')
->disableOriginalConstructor()->getMock();
$package = $this->getMockBuilder('Composer\Package\RootPackageInterface')
->getMock();
$manager->expects($this->once())->method('archive')
->with($package, 'zip', '.', null, false)->willReturn(getcwd());
$composer->setArchiveManager($manager);
$composer->setEventDispatcher($ed);
$composer->setPackage($package);
$command = $this->getMockBuilder('Composer\Command\ArchiveCommand')
->setMethods(array(
'mergeApplicationDefinition',
'bind',
'getSynopsis',
'initialize',
'isInteractive',
'getComposer',
))->getMock();
$command->expects($this->atLeastOnce())->method('getComposer')
->willReturn($composer);
$command->method('isInteractive')->willReturn(false);
$command->run($input, $output);
}
public function testUsesConfigFromFactoryWhenComposerIsNotDefined()
{
$input = new ArrayInput(array());
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')
->getMock();
$config = Factory::createConfig();
$command = $this->getMockBuilder('Composer\Command\ArchiveCommand')
->setMethods(array(
'mergeApplicationDefinition',
'bind',
'getSynopsis',
'initialize',
'isInteractive',
'getComposer',
'archive',
))->getMock();
$command->expects($this->once())->method('getComposer')
->willReturn(null);
$command->expects($this->once())->method('archive')
->with(
$this->isInstanceOf('Composer\IO\IOInterface'),
$config,
null,
null,
'tar',
'.',
null,
false,
null
);
$command->method('isInteractive')->willReturn(false);
$command->run($input, $output);
}
}

View File

@ -75,7 +75,7 @@ update b/unstable
} }
--EXPECT-- --EXPECT--
Updating a/old (0.9.0 => 1.0.0) Updating a/old (0.9.0 => 1.0.0)
Updating b/unstable (1.1.0-alpha => 1.0.0) Downgrading b/unstable (1.1.0-alpha => 1.0.0)
Updating c/uptodate (2.0.0 => 1.0.0) Downgrading c/uptodate (2.0.0 => 1.0.0)
Installing d/removed (1.0.0) Installing d/removed (1.0.0)
Installing e/newreq (1.0.0) Installing e/newreq (1.0.0)

View File

@ -46,4 +46,4 @@ Downgrading from unstable to more stable package should work even if already ins
--RUN-- --RUN--
update update
--EXPECT-- --EXPECT--
Updating a/a (dev-master abcd => 1.0.0) Downgrading a/a (dev-master abcd => 1.0.0)

View File

@ -37,4 +37,4 @@ Updates packages to their lowest stable version
update --prefer-lowest --prefer-stable update --prefer-lowest --prefer-stable
--EXPECT-- --EXPECT--
Updating a/a (1.0.0-rc1 => 1.0.1) Updating a/a (1.0.0-rc1 => 1.0.1)
Updating a/b (1.0.1 => 1.0.0) Downgrading a/b (1.0.1 => 1.0.0)