From 4a8c416a024785eaa4094edf3a2eafec515972c3 Mon Sep 17 00:00:00 2001 From: Ahammar Yassine Date: Thu, 13 Sep 2018 11:17:30 +0000 Subject: [PATCH 01/20] Update ValidateCommand.php Skip publish and lock check even in strict check mode when the user want so. Example : `composer validate --no-check-lock --strict composer.json`. Issue : #7624 --- src/Composer/Command/ValidateCommand.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Composer/Command/ValidateCommand.php b/src/Composer/Command/ValidateCommand.php index 52bba1838..b86fd92ea 100644 --- a/src/Composer/Command/ValidateCommand.php +++ b/src/Composer/Command/ValidateCommand.php @@ -95,9 +95,10 @@ EOT $lockErrors[] = 'The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update`.'; } - $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true); + $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true, $isStrict); - $exitCode = $errors || ($publishErrors && $checkPublish) || ($lockErrors && $checkLock) ? 2 : ($isStrict && $warnings ? 1 : 0); + // $errors include publish and lock errors when exists + $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0); if ($input->getOption('with-dependencies')) { $localRepo = $composer->getRepositoryManager()->getLocalRepository(); @@ -108,7 +109,7 @@ EOT list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll); $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors); - $depCode = $errors || ($publishErrors && $checkPublish) ? 2 : ($isStrict && $warnings ? 1 : 0); + $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0); $exitCode = max($depCode, $exitCode); } } @@ -121,7 +122,7 @@ EOT return $exitCode; } - private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false) + private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false, $isStrict = false) { if (!$errors && !$publishErrors && !$warnings) { $io->write('' . $name . ' is valid'); @@ -141,16 +142,18 @@ EOT } // If checking publish errors, display them as errors, otherwise just show them as warnings + // Skip when it is a strict check and we don't want to check publish errors if ($checkPublish) { $errors = array_merge($errors, $publishErrors); - } else { + } elseif (!$isStrict) { $warnings = array_merge($warnings, $publishErrors); } // If checking lock errors, display them as errors, otherwise just show them as warnings + // Skip when it is a strict check and we don't want to check lock errors if ($checkLock) { $errors = array_merge($errors, $lockErrors); - } else { + } elseif (!$isStrict) { $warnings = array_merge($warnings, $lockErrors); } From 96347fbea17e2e67a0a264b1b3a57cace5385477 Mon Sep 17 00:00:00 2001 From: David Manners Date: Sun, 14 Oct 2018 11:15:25 +0000 Subject: [PATCH 02/20] composer/composer#7384: add chat to support options - update schema documents to note that chat is allowed, - validate that chat must be a string and a url similar to forum options --- doc/04-schema.md | 1 + src/Composer/Package/Loader/ValidatingArrayLoader.php | 4 ++-- .../Test/Package/Loader/ValidatingArrayLoaderTest.php | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/04-schema.md b/doc/04-schema.md index 42addb10f..0f44d47f9 100644 --- a/doc/04-schema.md +++ b/doc/04-schema.md @@ -243,6 +243,7 @@ Support information includes the following: * **source:** URL to browse or download the sources. * **docs:** URL to the documentation. * **rss:** URL to the RSS feed. +* **chat:** URL to chat server. An example: diff --git a/src/Composer/Package/Loader/ValidatingArrayLoader.php b/src/Composer/Package/Loader/ValidatingArrayLoader.php index 2a71be6cb..f4753025b 100644 --- a/src/Composer/Package/Loader/ValidatingArrayLoader.php +++ b/src/Composer/Package/Loader/ValidatingArrayLoader.php @@ -161,7 +161,7 @@ class ValidatingArrayLoader implements LoaderInterface } if ($this->validateArray('support') && !empty($this->config['support'])) { - foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss') as $key) { + foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) { if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) { $this->errors[] = 'support.'.$key.' : invalid value, must be a string'; unset($this->config['support'][$key]); @@ -178,7 +178,7 @@ class ValidatingArrayLoader implements LoaderInterface unset($this->config['support']['irc']); } - foreach (array('issues', 'forum', 'wiki', 'source', 'docs') as $key) { + foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) { if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) { $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL'; unset($this->config['support'][$key]); diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index cc66ab399..ebe6871fe 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -71,6 +71,7 @@ class ValidatingArrayLoaderTest extends TestCase 'source' => 'http://example.org/', 'irc' => 'irc://example.org/example', 'rss' => 'http://example.org/rss', + 'chat' => 'http://example.org/chat', ), 'require' => array( 'a/b' => '1.*', @@ -305,6 +306,7 @@ class ValidatingArrayLoaderTest extends TestCase 'forum' => 'foo:bar', 'issues' => 'foo:bar', 'wiki' => 'foo:bar', + 'chat' => 'foo:bar', ), ), array( @@ -312,6 +314,7 @@ class ValidatingArrayLoaderTest extends TestCase 'support.forum : invalid value (foo:bar), must be an http/https URL', 'support.issues : invalid value (foo:bar), must be an http/https URL', 'support.wiki : invalid value (foo:bar), must be an http/https URL', + 'support.chat : invalid value (foo:bar), must be an http/https URL', ), ), array( From a1ab75a703c666e96cb753872e8cd1427725f1cb Mon Sep 17 00:00:00 2001 From: David Manners Date: Sun, 14 Oct 2018 14:19:08 +0000 Subject: [PATCH 03/20] composer/composer#7159: make the remove command to a regex lookup on package name - if you have multiple vendor modules installed you should be able to do composer remove vendor/* to remove all - update remove and also remove from alternative type to also do a preg_grep for what the user has inputed --- src/Composer/Command/RemoveCommand.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index c97130c3a..9646d6db1 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -94,12 +94,25 @@ EOT if (isset($composer[$type][$package])) { $json->removeLink($type, $composer[$type][$package]); } elseif (isset($composer[$altType][$package])) { - $io->writeError(''.$composer[$altType][$package].' could not be found in '.$type.' but it is present in '.$altType.''); + $io->writeError('' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . ''); if ($io->isInteractive()) { - if ($io->askConfirmation('Do you want to remove it from '.$altType.' [yes]? ', true)) { + if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [yes]? ', true)) { $json->removeLink($altType, $composer[$altType][$package]); } } + } elseif (isset($composer[$type]) && $matches = preg_grep('#^'.$package.'#', array_keys($composer[$type]))) { + foreach ($matches as $matchedPackage) { + $json->removeLink($type, $matchedPackage); + } + } elseif (isset($composer[$altType]) && $matches = preg_grep('#^'.$package.'#', array_keys($composer[$altType]))) { + foreach ($matches as $matchedPackage) { + $io->writeError('' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . ''); + if ($io->isInteractive()) { + if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [yes]? ', true)) { + $json->removeLink($altType, $matchedPackage); + } + } + } } else { $io->writeError(''.$package.' is not required in your composer.json and has not been removed'); } From e92eda56786844c6e30c97b91a0cf4706e0b3085 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Mon, 22 Oct 2018 10:11:34 +0200 Subject: [PATCH 04/20] composer/composer#7384: update chat note based on code review feedback Co-Authored-By: dmanners --- doc/04-schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/04-schema.md b/doc/04-schema.md index 0f44d47f9..7c66813af 100644 --- a/doc/04-schema.md +++ b/doc/04-schema.md @@ -243,7 +243,7 @@ Support information includes the following: * **source:** URL to browse or download the sources. * **docs:** URL to the documentation. * **rss:** URL to the RSS feed. -* **chat:** URL to chat server. +* **chat:** URL to the chat channel. An example: From 04098153c8c4f3c2b2f329aa13f868bb5735032a Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Mon, 26 Nov 2018 12:32:31 +0100 Subject: [PATCH 05/20] Add support for running composer with phpdbg (#7798) --- bin/composer | 2 +- src/Composer/EventDispatcher/EventDispatcher.php | 7 ++++--- src/Composer/Util/StreamContextFactory.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/composer b/bin/composer index 7a80288b6..5e142662c 100755 --- a/bin/composer +++ b/bin/composer @@ -1,7 +1,7 @@ #!/usr/bin/env php find(); + $phpPath = $finder->find(false); if (!$phpPath) { throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath); } - + $phpArgs = $finder->findArguments(); + $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : ''; $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen')); $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions')); $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit')); - return ProcessExecutor::escape($phpPath) . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag; + return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag; } /** diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index 4e9b7f480..8dfd6624a 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -40,7 +40,7 @@ final class StreamContextFactory )); // Handle HTTP_PROXY/http_proxy on CLI only for security reasons - if (PHP_SAPI === 'cli' && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) { + if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) { $proxy = parse_url(!empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY']); } From b0b00ad1fa1abe2601774b49f0355dcbf533cf77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Mon, 26 Nov 2018 12:35:41 +0100 Subject: [PATCH 06/20] Call a script recursively with extra parameters (#7720) * Added support for calling scripts recursively (fixes #7562) --- doc/articles/scripts.md | 11 +++++ .../EventDispatcher/EventDispatcher.php | 8 +++- .../EventDispatcher/EventDispatcherTest.php | 40 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/doc/articles/scripts.md b/doc/articles/scripts.md index 79ea01519..e0c27b10f 100644 --- a/doc/articles/scripts.md +++ b/doc/articles/scripts.md @@ -238,6 +238,17 @@ one by prefixing the command name with `@`: } ``` +You can also refer a script and pass it new arguments: + +```json +{ + "scripts": { + "tests": "phpunit", + "testsVerbose": "@tests -vvv" + } +} +``` + ## Calling Composer commands To call Composer commands, you can use `@composer` which will automatically diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 7f62f6890..0fb978fd4 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -176,8 +176,12 @@ class EventDispatcher $return = false === call_user_func($callable, $event) ? 1 : 0; } elseif ($this->isComposerScript($callable)) { $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE); - $scriptName = substr($callable, 1); - $args = $event->getArguments(); + + $script = explode(' ', substr($callable, 1)); + $scriptName = $script[0]; + unset($script[0]); + + $args = array_merge($script, $event->getArguments()); $flags = $event->getFlags(); if (substr($callable, 0, 10) === '@composer ') { $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9); diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php index 689462bbd..5e68ebcc9 100644 --- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php +++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php @@ -14,6 +14,7 @@ namespace Composer\Test\EventDispatcher; use Composer\EventDispatcher\Event; use Composer\EventDispatcher\EventDispatcher; +use Composer\EventDispatcher\ScriptExecutionException; use Composer\Installer\InstallerEvents; use Composer\Config; use Composer\Composer; @@ -274,6 +275,45 @@ class EventDispatcherTest extends TestCase $this->assertEquals($expected, $io->getOutput()); } + public function testRecursionInScriptsNames() + { + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); + $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') + ->setConstructorArgs(array( + $composer = $this->createComposerInstance(), + $io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE), + $process + )) + ->setMethods(array( + 'getListeners' + )) + ->getMock(); + + $process->expects($this->exactly(1)) + ->method('execute') + ->will($this->returnValue(0)); + + $dispatcher->expects($this->atLeastOnce()) + ->method('getListeners') + ->will($this->returnCallback(function (Event $event) { + if($event->getName() === 'hello') { + return array('echo Hello'); + } + + if($event->getName() === 'helloWorld') { + return array('@hello World'); + } + + return array(); + })); + + $dispatcher->dispatch('helloWorld', new CommandEvent('helloWorld', $composer, $io)); + $expected = "> helloWorld: @hello World".PHP_EOL. + "> hello: echo Hello " .escapeshellarg('World').PHP_EOL; + + $this->assertEquals($expected, $io->getOutput()); + } + /** * @expectedException RuntimeException */ From f9234222d17bcd9f7a57a30d3c3b38d0c70e60cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 26 Nov 2018 13:37:56 +0200 Subject: [PATCH 07/20] add lib-imagick to show -p output (#7762) --- src/Composer/Repository/PlatformRepository.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 0a2e79f35..5ebb6c9db 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -157,6 +157,18 @@ class PlatformRepository extends ArrayRepository break; + case 'imagick': + $reflector = new \ReflectionExtension('imagick'); + + ob_start(); + $reflector->info(); + $output = ob_get_clean(); + + preg_match('/^Imagick using ImageMagick library version => ImageMagick ([\d.]+)-(\d+)/m', $output, $matches); + $prettyVersion = "{$matches[1]}.{$matches[2]}"; + + break; + case 'libxml': $prettyVersion = LIBXML_DOTTED_VERSION; break; From 42e88ac27afd15293c6a7bbfe8406364c32ade03 Mon Sep 17 00:00:00 2001 From: Shalvah Date: Mon, 26 Nov 2018 12:57:38 +0100 Subject: [PATCH 08/20] Add interactive option to install dependencies after running init command (#7521) * Add interactive option to install dependencies after running init command * Only ask to install dependencies when dependencies where defined --- src/Composer/Command/InitCommand.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 760826d22..515a16943 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -22,6 +22,7 @@ use Composer\Repository\CompositeRepository; use Composer\Repository\PlatformRepository; use Composer\Repository\RepositoryFactory; use Composer\Util\ProcessExecutor; +use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -145,6 +146,11 @@ EOT } } } + + $question = 'Would you like to install dependencies now [yes]? '; + if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question, true)) { + $this->installDependencies($output); + } } /** @@ -767,4 +773,23 @@ EOT return array_keys(array_slice($similarPackages, 0, 5)); } + + private function installDependencies($output) + { + try { + $installCommand = $this->getApplication()->find('install'); + $installCommand->run(new ArrayInput(array()), $output); + } catch (\Exception $e) { + $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.'); + } + + } + + private function hasDependencies($options) + { + $requires = (array) $options['require']; + $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array(); + + return !empty($requires) || !empty($devRequires); + } } From 6e6fb844ddb35868f04c6db9d40b6b24cc6ad31a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 26 Nov 2018 12:59:54 +0100 Subject: [PATCH 09/20] Avoid validating package name if it has a newline at the end --- src/Composer/Command/InitCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 515a16943..3022360ee 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -214,7 +214,7 @@ EOT } $name = strtolower($name); } else { - if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $name)) { + if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $name)) { throw new \InvalidArgumentException( 'The package name '.$name.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+' ); @@ -228,7 +228,7 @@ EOT return $name; } - if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $value)) { + if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) { throw new \InvalidArgumentException( 'The package name '.$value.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+' ); From acdf8f83f1c5e0cbdd16be2325206c4b42e43679 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 26 Nov 2018 13:12:18 +0100 Subject: [PATCH 10/20] Bypass version check for explicitly versioned packages in require command when --no-update is given, fixes #7800 --- src/Composer/Command/InitCommand.php | 4 ++-- src/Composer/Command/RequireCommand.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index be56b23fb..78628a085 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -381,7 +381,7 @@ EOT return $this->repos; } - protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), $phpVersion = null, $preferredStability = 'stable') + protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), $phpVersion = null, $preferredStability = 'stable', $checkProvidedVersions = true) { if ($requires) { $requires = $this->normalizeRequirements($requires); @@ -404,7 +404,7 @@ EOT )); } else { // check that the specified version/constraint exists before we proceed - list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $phpVersion, $preferredStability, $requirement['version'], 'dev'); + list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $phpVersion, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev'); // replace package name from packagist.org $requirement['name'] = $name; diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 01439207f..262519315 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -61,7 +61,7 @@ class RequireCommand extends InitCommand <<repos->findPackage('php', '*')->getPrettyVersion(); - $requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'), $phpVersion, $preferredStability); + $requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'), $phpVersion, $preferredStability, !$input->getOption('no-update')); $requireKey = $input->getOption('dev') ? 'require-dev' : 'require'; $removeKey = $input->getOption('dev') ? 'require' : 'require-dev'; From 55c40e8853038e337364c3205cab9ad1832a2a3f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 26 Nov 2018 13:43:24 +0100 Subject: [PATCH 11/20] Add note about CS fixes to contribution notes --- .github/CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5f85c6bd9..a0fd0ce54 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -21,6 +21,11 @@ If your issue involves installing, updating or resolving dependencies, the chance of us being able to reproduce your issue will be much higher if you share your `composer.json` with us. +Coding Style Fixes +------------------ + +We do not accept CS fixes pull requests. Fixes are done by the project maintainers when appropriate to avoid causing too many unnecessary conflicts between branches and pull requests. + Security Reports ---------------- From b89daf5322711ac154d5583ce4443588e43c1716 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 26 Nov 2018 19:52:05 +0100 Subject: [PATCH 12/20] Add support.chat to schema, refs #7714 --- res/composer-schema.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/res/composer-schema.json b/res/composer-schema.json index 2ff405f1e..ce80c209b 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -490,6 +490,11 @@ "description": "IRC channel for support, as irc://server/channel.", "format": "uri" }, + "chat": { + "type": "string", + "description": "URL to the support chat.", + "format": "uri" + }, "source": { "type": "string", "description": "URL to browse or download the sources.", From 66d84f60c6e6c869ba739db239f23366c66cb144 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 26 Nov 2018 20:09:26 +0100 Subject: [PATCH 13/20] Fix pattern matching for remove wildcard, refs #7715 --- src/Composer/Command/RemoveCommand.php | 5 +++-- src/Composer/Installer.php | 18 +++--------------- src/Composer/Package/BasePackage.php | 13 +++++++++++++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index 9646d6db1..27be1a0ca 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -22,6 +22,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; +use Composer\Package\BasePackage; /** * @author Pierre du Plessis @@ -100,11 +101,11 @@ EOT $json->removeLink($altType, $composer[$altType][$package]); } } - } elseif (isset($composer[$type]) && $matches = preg_grep('#^'.$package.'#', array_keys($composer[$type]))) { + } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) { foreach ($matches as $matchedPackage) { $json->removeLink($type, $matchedPackage); } - } elseif (isset($composer[$altType]) && $matches = preg_grep('#^'.$package.'#', array_keys($composer[$altType]))) { + } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) { foreach ($matches as $matchedPackage) { $io->writeError('' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . ''); if ($io->isInteractive()) { diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 2ace251af..bd0d22e3c 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -33,6 +33,7 @@ use Composer\Installer\NoopInstaller; use Composer\Installer\SuggestedPackagesReporter; use Composer\IO\IOInterface; use Composer\Package\AliasPackage; +use Composer\Package\BasePackage; use Composer\Package\CompletePackage; use Composer\Package\Link; use Composer\Package\Loader\ArrayLoader; @@ -1254,7 +1255,7 @@ class Installer } foreach ($this->updateWhitelist as $whiteListedPattern => $void) { - $patternRegexp = $this->packageNameToRegexp($whiteListedPattern); + $patternRegexp = BasePackage::packageNameToRegexp($whiteListedPattern); if (preg_match($patternRegexp, $package->getName())) { return true; } @@ -1263,19 +1264,6 @@ class Installer return false; } - /** - * Build a regexp from a package name, expanding * globs as required - * - * @param string $whiteListedPattern - * @return string - */ - private function packageNameToRegexp($whiteListedPattern) - { - $cleanedWhiteListedPattern = str_replace('\\*', '.*', preg_quote($whiteListedPattern)); - - return "{^" . $cleanedWhiteListedPattern . "$}i"; - } - /** * @param array $links * @return array @@ -1341,7 +1329,7 @@ class Installer // check if the name is a glob pattern that did not match directly if (!$nameMatchesRequiredPackage) { - $whitelistPatternRegexp = $this->packageNameToRegexp($packageName); + $whitelistPatternRegexp = BasePackage::packageNameToRegexp($packageName); foreach ($rootRequiredPackageNames as $rootRequiredPackageName) { if (preg_match($whitelistPatternRegexp, $rootRequiredPackageName)) { $nameMatchesRequiredPackage = true; diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index 1e3081c7e..65ea6860f 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -234,4 +234,17 @@ abstract class BasePackage implements PackageInterface $this->repository = null; $this->id = -1; } + + /** + * Build a regexp from a package name, expanding * globs as required + * + * @param string $whiteListedPattern + * @return string + */ + public static function packageNameToRegexp($whiteListedPattern) + { + $cleanedWhiteListedPattern = str_replace('\\*', '.*', preg_quote($whiteListedPattern)); + + return "{^" . $cleanedWhiteListedPattern . "$}i"; + } } From 17fd933fd59fc5c8dad6fffb77f795739293b9ec Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 27 Nov 2018 12:22:32 +0100 Subject: [PATCH 14/20] Update dependencies --- composer.lock | 92 +++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/composer.lock b/composer.lock index db4aacb10..b1fcfa36d 100644 --- a/composer.lock +++ b/composer.lock @@ -126,16 +126,16 @@ }, { "name": "composer/spdx-licenses", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/composer/spdx-licenses.git", - "reference": "cb17687e9f936acd7e7245ad3890f953770dec1b" + "reference": "7a9556b22bd9d4df7cad89876b00af58ef20d3a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/cb17687e9f936acd7e7245ad3890f953770dec1b", - "reference": "cb17687e9f936acd7e7245ad3890f953770dec1b", + "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/7a9556b22bd9d4df7cad89876b00af58ef20d3a2", + "reference": "7a9556b22bd9d4df7cad89876b00af58ef20d3a2", "shasum": "" }, "require": { @@ -183,7 +183,7 @@ "spdx", "validator" ], - "time": "2018-04-30T10:33:04+00:00" + "time": "2018-11-01T09:45:54+00:00" }, { "name": "composer/xdebug-handler", @@ -297,16 +297,16 @@ }, { "name": "psr/log", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "shasum": "" }, "require": { @@ -340,7 +340,7 @@ "psr", "psr-3" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2018-11-20T15:27:04+00:00" }, { "name": "seld/jsonlint", @@ -437,16 +437,16 @@ }, { "name": "symfony/console", - "version": "v2.8.45", + "version": "v2.8.48", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0c1fcbb9afb5cff992c982ff99c0434f0146dcfc" + "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0c1fcbb9afb5cff992c982ff99c0434f0146dcfc", - "reference": "0c1fcbb9afb5cff992c982ff99c0434f0146dcfc", + "url": "https://api.github.com/repos/symfony/console/zipball/cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", + "reference": "cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12", "shasum": "" }, "require": { @@ -494,20 +494,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:13:39+00:00" + "time": "2018-11-20T15:55:20+00:00" }, { "name": "symfony/debug", - "version": "v2.8.45", + "version": "v2.8.48", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "cbb8a5f212148964efbc414838c527229f9951b7" + "reference": "74251c8d50dd3be7c4ce0c7b862497cdc641a5d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/cbb8a5f212148964efbc414838c527229f9951b7", - "reference": "cbb8a5f212148964efbc414838c527229f9951b7", + "url": "https://api.github.com/repos/symfony/debug/zipball/74251c8d50dd3be7c4ce0c7b862497cdc641a5d0", + "reference": "74251c8d50dd3be7c4ce0c7b862497cdc641a5d0", "shasum": "" }, "require": { @@ -551,20 +551,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2018-08-03T09:45:57+00:00" + "time": "2018-11-11T11:18:13+00:00" }, { "name": "symfony/filesystem", - "version": "v2.8.45", + "version": "v2.8.48", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "0b252f4e25b7da17abb5a98eb60755b71d082c9c" + "reference": "7ae46872dad09dffb7fe1e93a0937097339d0080" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/0b252f4e25b7da17abb5a98eb60755b71d082c9c", - "reference": "0b252f4e25b7da17abb5a98eb60755b71d082c9c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/7ae46872dad09dffb7fe1e93a0937097339d0080", + "reference": "7ae46872dad09dffb7fe1e93a0937097339d0080", "shasum": "" }, "require": { @@ -601,20 +601,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2018-08-07T09:12:42+00:00" + "time": "2018-11-11T11:18:13+00:00" }, { "name": "symfony/finder", - "version": "v2.8.45", + "version": "v2.8.48", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "f0de0b51913eb2caab7dfed6413b87e14fca780e" + "reference": "1444eac52273e345d9b95129bf914639305a9ba4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/f0de0b51913eb2caab7dfed6413b87e14fca780e", - "reference": "f0de0b51913eb2caab7dfed6413b87e14fca780e", + "url": "https://api.github.com/repos/symfony/finder/zipball/1444eac52273e345d9b95129bf914639305a9ba4", + "reference": "1444eac52273e345d9b95129bf914639305a9ba4", "shasum": "" }, "require": { @@ -650,11 +650,11 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:13:39+00:00" + "time": "2018-11-11T11:18:13+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.9.0", + "version": "v1.10.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -712,16 +712,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.9.0", + "version": "v1.10.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", "shasum": "" }, "require": { @@ -767,20 +767,20 @@ "portable", "shim" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2018-09-21T13:07:52+00:00" }, { "name": "symfony/process", - "version": "v2.8.45", + "version": "v2.8.48", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "4be278e19064c3492095de50c9e375caae569ae1" + "reference": "c3591a09c78639822b0b290d44edb69bf9f05dc8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/4be278e19064c3492095de50c9e375caae569ae1", - "reference": "4be278e19064c3492095de50c9e375caae569ae1", + "url": "https://api.github.com/repos/symfony/process/zipball/c3591a09c78639822b0b290d44edb69bf9f05dc8", + "reference": "c3591a09c78639822b0b290d44edb69bf9f05dc8", "shasum": "" }, "require": { @@ -816,7 +816,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-08-03T09:45:57+00:00" + "time": "2018-11-11T11:18:13+00:00" } ], "packages-dev": [ @@ -1736,16 +1736,16 @@ }, { "name": "symfony/yaml", - "version": "v2.8.45", + "version": "v2.8.48", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "fbf876678e29dc634430dcf0096e216eb0004467" + "reference": "02c1859112aa779d9ab394ae4f3381911d84052b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/fbf876678e29dc634430dcf0096e216eb0004467", - "reference": "fbf876678e29dc634430dcf0096e216eb0004467", + "url": "https://api.github.com/repos/symfony/yaml/zipball/02c1859112aa779d9ab394ae4f3381911d84052b", + "reference": "02c1859112aa779d9ab394ae4f3381911d84052b", "shasum": "" }, "require": { @@ -1782,7 +1782,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-07-26T09:03:18+00:00" + "time": "2018-11-11T11:18:13+00:00" } ], "aliases": [], From 489e0d4b124905a26310c9026d83eb82eb0e57ce Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 27 Nov 2018 14:26:03 +0100 Subject: [PATCH 15/20] Add support for imagemagick <3.3, refs #7762 --- src/Composer/Repository/PlatformRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 5ebb6c9db..1e680e3b5 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -164,7 +164,7 @@ class PlatformRepository extends ArrayRepository $reflector->info(); $output = ob_get_clean(); - preg_match('/^Imagick using ImageMagick library version => ImageMagick ([\d.]+)-(\d+)/m', $output, $matches); + preg_match('/^(Imagick using ImageMagick library version|ImageMagick version) => ImageMagick ([\d.]+)-(\d+)/m', $output, $matches); $prettyVersion = "{$matches[1]}.{$matches[2]}"; break; From 5ce5560040052bcb6a23bb5de2eb5e7c9ead10e4 Mon Sep 17 00:00:00 2001 From: meyerbaptiste Date: Tue, 27 Nov 2018 16:27:01 +0100 Subject: [PATCH 16/20] Fix support for imagemagick <3.3, refs #7762 --- src/Composer/Repository/PlatformRepository.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 1e680e3b5..6d6e04d2f 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -158,15 +158,10 @@ class PlatformRepository extends ArrayRepository break; case 'imagick': - $reflector = new \ReflectionExtension('imagick'); - - ob_start(); - $reflector->info(); - $output = ob_get_clean(); - - preg_match('/^(Imagick using ImageMagick library version|ImageMagick version) => ImageMagick ([\d.]+)-(\d+)/m', $output, $matches); + $imagick = new \Imagick(); + $imageMagickVersion = $imagick->getVersion(); + preg_match('/^ImageMagick ([\d.]+)-(\d+)/', $imageMagickVersion['versionString'], $matches); $prettyVersion = "{$matches[1]}.{$matches[2]}"; - break; case 'libxml': From 7ab633a2af81ba12c5200c98d172f6467b9c1669 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 28 Nov 2018 08:44:45 +0100 Subject: [PATCH 17/20] Prepare 1.8.0 changelog --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7e13cf55..ec7c72ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +### [1.8.0] 2018-11-XX + + * Changed `post-package-install` / `post-package-update` event to be fired *after* the lock file has been updated as opposed to before + * Added support for removing packages using a wildcard with the `remove` command, e.g. `composer remove foo/*` + * Added `chat` to the list of `support` channels you can list in composer.json + * Added signal handling on require command to restore the composer.json in case of abort + * Added `--ignore` to `outdated` command to pass one or more packages that you do not want to be listed + * Added `--no-dev` to `check-platform-reqs` command to skip dev requirements even if they are installed + * Added support for running plugin commands from sub-directories within a project much like other Composer commands + * Added support for running Composer via phpdbg + * Added `lib-imagick` platform package + * Fixed validate command always checking for disabled checks when used with `--strict` + ### [1.7.3] 2018-11-01 * Fixed handling of replace/conflict rules. This may affect dependency resolution in some edge cases. @@ -696,6 +709,7 @@ * Initial release +[1.8.0]: https://github.com/composer/composer/compare/1.7.3...1.8.0 [1.7.3]: https://github.com/composer/composer/compare/1.7.2...1.7.3 [1.7.2]: https://github.com/composer/composer/compare/1.7.1...1.7.2 [1.7.1]: https://github.com/composer/composer/compare/1.7.0...1.7.1 From ab165cfcd6c00a46dbfb712807086fcec786f166 Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Thu, 29 Nov 2018 14:25:01 +0000 Subject: [PATCH 18/20] Update xdebug-handler, fixes #7807 --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index d4e7f847f..13638dbbc 100644 --- a/composer.lock +++ b/composer.lock @@ -187,16 +187,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.3.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c" + "reference": "dc523135366eb68f22268d069ea7749486458562" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/b8e9745fb9b06ea6664d8872c4505fb16df4611c", - "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/dc523135366eb68f22268d069ea7749486458562", + "reference": "dc523135366eb68f22268d069ea7749486458562", "shasum": "" }, "require": { @@ -227,7 +227,7 @@ "Xdebug", "performance" ], - "time": "2018-08-31T19:20:00+00:00" + "time": "2018-11-29T10:59:02+00:00" }, { "name": "justinrainbow/json-schema", From 02ee50ac1d240dbbb3507734ef20dacb8094b000 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 3 Dec 2018 10:21:52 +0100 Subject: [PATCH 19/20] Prepare 1.8.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec7c72ad4..cf06a0fd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### [1.8.0] 2018-11-XX +### [1.8.0] 2018-12-03 * Changed `post-package-install` / `post-package-update` event to be fired *after* the lock file has been updated as opposed to before * Added support for removing packages using a wildcard with the `remove` command, e.g. `composer remove foo/*` From 4301c19ce3b2468ad841ca9f5f35ca5558fb005f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 3 Dec 2018 10:39:36 +0100 Subject: [PATCH 20/20] Update target for master --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a1efaa17..41048903b 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.9-dev" } }, "autoload": {