diff --git a/doc/articles/custom-installers.md b/doc/articles/custom-installers.md
index a3c937a5e..791c04956 100644
--- a/doc/articles/custom-installers.md
+++ b/doc/articles/custom-installers.md
@@ -85,10 +85,16 @@ Example:
},
"require": {
"composer-plugin-api": "^1.0"
+ },
+ "require-dev": {
+ "composer/composer": "^1.3"
}
}
```
+The example above has Composer itself in its require-dev, which allows you to use
+the Composer classes in your test suite for example.
+
### The Plugin class
The class defining the Composer plugin must implement the
diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php
index b74d34858..753446e44 100644
--- a/src/Composer/EventDispatcher/EventDispatcher.php
+++ b/src/Composer/EventDispatcher/EventDispatcher.php
@@ -177,13 +177,13 @@ class EventDispatcher
if (substr($callable, 0, 10) === '@composer ') {
$exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9);
if (0 !== ($exitCode = $this->process->execute($exec))) {
- $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()));
+ $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()), true, IOInterface::QUIET);
throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
}
} else {
if (!$this->getListeners(new Event($scriptName))) {
- $this->io->writeError(sprintf('You made a reference to a non-existent script %s', $callable));
+ $this->io->writeError(sprintf('You made a reference to a non-existent script %s', $callable), true, IOInterface::QUIET);
}
$return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags));
@@ -193,11 +193,11 @@ class EventDispatcher
$methodName = substr($callable, strpos($callable, '::') + 2);
if (!class_exists($className)) {
- $this->io->writeError('Class '.$className.' is not autoloadable, can not call '.$event->getName().' script');
+ $this->io->writeError('Class '.$className.' is not autoloadable, can not call '.$event->getName().' script', true, IOInterface::QUIET);
continue;
}
if (!is_callable($callable)) {
- $this->io->writeError('Method '.$callable.' is not callable, can not call '.$event->getName().' script');
+ $this->io->writeError('Method '.$callable.' is not callable, can not call '.$event->getName().' script', true, IOInterface::QUIET);
continue;
}
@@ -205,7 +205,7 @@ class EventDispatcher
$return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
} catch (\Exception $e) {
$message = "Script %s handling the %s event terminated with an exception";
- $this->io->writeError(''.sprintf($message, $callable, $event->getName()).'');
+ $this->io->writeError(''.sprintf($message, $callable, $event->getName()).'', true, IOInterface::QUIET);
throw $e;
}
} else {
@@ -233,7 +233,7 @@ class EventDispatcher
}
if (0 !== ($exitCode = $this->process->execute($exec))) {
- $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()));
+ $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()), true, IOInterface::QUIET);
throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
}
diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php
index ce030ff0e..011ac376d 100644
--- a/src/Composer/Package/Version/VersionGuesser.php
+++ b/src/Composer/Package/Version/VersionGuesser.php
@@ -65,17 +65,17 @@ class VersionGuesser
{
if (function_exists('proc_open')) {
$versionData = $this->guessGitVersion($packageConfig, $path);
- if (null !== $versionData) {
+ if (null !== $versionData && null !== $versionData['version']) {
return $versionData;
}
$versionData = $this->guessHgVersion($packageConfig, $path);
- if (null !== $versionData) {
+ if (null !== $versionData && null !== $versionData['version']) {
return $versionData;
}
$versionData = $this->guessFossilVersion($packageConfig, $path);
- if (null !== $versionData) {
+ if (null !== $versionData && null !== $versionData['version']) {
return $versionData;
}
diff --git a/src/Composer/Script/ScriptEvents.php b/src/Composer/Script/ScriptEvents.php
index 7ae1fea26..491c6bc65 100644
--- a/src/Composer/Script/ScriptEvents.php
+++ b/src/Composer/Script/ScriptEvents.php
@@ -95,7 +95,7 @@ class ScriptEvents
/**
* The POST_ROOT_PACKAGE_INSTALL event occurs after the root package has been installed.
*
- * The event listener method receives a Composer\Installer\PackageEvent instance.
+ * The event listener method receives a Composer\Script\Event instance.
*
* @var string
*/
@@ -105,7 +105,7 @@ class ScriptEvents
* The POST_CREATE_PROJECT event occurs after the create-project command has been executed.
* Note: Event occurs after POST_INSTALL_CMD
*
- * The event listener method receives a Composer\Installer\PackageEvent instance.
+ * The event listener method receives a Composer\Script\Event instance.
*
* @var string
*/
diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php
index 5b137686d..e974d69d7 100644
--- a/src/Composer/Util/RemoteFilesystem.php
+++ b/src/Composer/Util/RemoteFilesystem.php
@@ -348,7 +348,7 @@ class RemoteFilesystem
if ($originUrl === 'bitbucket.org'
&& !$this->isPublicBitBucketDownload($fileUrl)
&& substr($fileUrl, -4) === '.zip'
- && preg_match('{^text/html\b}i', $contentType)
+ && $contentType && preg_match('{^text/html\b}i', $contentType)
) {
$result = false;
if ($this->retryAuthFailure) {
@@ -385,7 +385,8 @@ class RemoteFilesystem
// decode gzip
if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http' && !$hasFollowedRedirect) {
- $decode = 'gzip' === strtolower($this->findHeaderValue($http_response_header, 'content-encoding'));
+ $contentEncoding = $this->findHeaderValue($http_response_header, 'content-encoding');
+ $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
if ($decode) {
try {