Merge branch 'master' of https://github.com/composer/composer into pull-4690
commit
017a9af672
|
@ -122,18 +122,25 @@ class ClassMapGenerator
|
||||||
$extraTypes .= '|enum';
|
$extraTypes .= '|enum';
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
// Use @ here instead of Silencer to actively suppress 'unhelpful' output
|
||||||
$contents = Silencer::call('php_strip_whitespace', $path);
|
// @link https://github.com/composer/composer/pull/4886
|
||||||
|
$contents = @php_strip_whitespace($path);
|
||||||
if (!$contents) {
|
if (!$contents) {
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
throw new \Exception('File does not exist');
|
$message = 'File at "%s" does not exist, check your classmap definitions';
|
||||||
|
} elseif (!is_readable($path)) {
|
||||||
|
$message = 'File at "%s" is not readable, check its permissions';
|
||||||
|
} elseif ('' === trim(file_get_contents($path))) {
|
||||||
|
// The input file was really empty and thus contains no classes
|
||||||
|
return array();
|
||||||
|
} else {
|
||||||
|
$message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
|
||||||
}
|
}
|
||||||
if (!is_readable($path)) {
|
$error = error_get_last();
|
||||||
throw new \Exception('File is not readable');
|
if (isset($error['message'])) {
|
||||||
|
$message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
|
||||||
}
|
}
|
||||||
}
|
throw new \RuntimeException(sprintf($message, $path));
|
||||||
} catch (\Exception $e) {
|
|
||||||
throw new \RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return early if there is no chance of matching anything in this file
|
// return early if there is no chance of matching anything in this file
|
||||||
|
|
|
@ -453,6 +453,10 @@ EOT
|
||||||
$errors['openssl'] = true;
|
$errors['openssl'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
|
||||||
|
$warnings['openssl_version'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && ini_get('apc.enable_cli')) {
|
if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && ini_get('apc.enable_cli')) {
|
||||||
$warnings['apc_cli'] = true;
|
$warnings['apc_cli'] = true;
|
||||||
}
|
}
|
||||||
|
@ -570,6 +574,15 @@ EOT
|
||||||
$text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
|
$text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'openssl_version':
|
||||||
|
// Attempt to parse version number out, fallback to whole string value.
|
||||||
|
$opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
|
||||||
|
$opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
|
||||||
|
|
||||||
|
$text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
|
||||||
|
$text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
|
||||||
|
break;
|
||||||
|
|
||||||
case 'xdebug_loaded':
|
case 'xdebug_loaded':
|
||||||
$text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
|
$text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
|
||||||
$text .= " Disabling it when using Composer is recommended.";
|
$text .= " Disabling it when using Composer is recommended.";
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
namespace Composer\DependencyResolver;
|
namespace Composer\DependencyResolver;
|
||||||
|
|
||||||
|
use Composer\Package\CompletePackage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nils Adermann <naderman@naderman.de>
|
* @author Nils Adermann <naderman@naderman.de>
|
||||||
*/
|
*/
|
||||||
|
@ -203,25 +205,40 @@ class Rule
|
||||||
if ($targetName === 'php' || $targetName === 'php-64bit' || $targetName === 'hhvm') {
|
if ($targetName === 'php' || $targetName === 'php-64bit' || $targetName === 'hhvm') {
|
||||||
// handle php/hhvm
|
// handle php/hhvm
|
||||||
if (defined('HHVM_VERSION')) {
|
if (defined('HHVM_VERSION')) {
|
||||||
$text .= ' -> your HHVM version does not satisfy that requirement.';
|
return $text . ' -> your HHVM version does not satisfy that requirement.';
|
||||||
} elseif ($targetName === 'hhvm') {
|
} elseif ($targetName === 'hhvm') {
|
||||||
$text .= ' -> you are running this with PHP and not HHVM.';
|
return $text . ' -> you are running this with PHP and not HHVM.';
|
||||||
} else {
|
} else {
|
||||||
$text .= ' -> your PHP version ('. phpversion() .') or value of "config.platform.php" in composer.json does not satisfy that requirement.';
|
$packages = $pool->whatProvides($targetName);
|
||||||
|
$package = count($packages) ? current($packages) : phpversion();
|
||||||
|
|
||||||
|
if (!($package instanceof CompletePackage)) {
|
||||||
|
return $text . ' -> your PHP version ('.phpversion().') does not satisfy that requirement.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$extra = $package->getExtra();
|
||||||
|
|
||||||
|
if (!empty($extra['config.platform'])) {
|
||||||
|
$text .= ' -> your PHP version ('.phpversion().') overriden by "config.platform.php" version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
|
||||||
|
} else {
|
||||||
|
$text .= ' -> your PHP version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
}
|
}
|
||||||
} elseif (0 === strpos($targetName, 'ext-')) {
|
} elseif (0 === strpos($targetName, 'ext-')) {
|
||||||
// handle php extensions
|
// handle php extensions
|
||||||
$ext = substr($targetName, 4);
|
$ext = substr($targetName, 4);
|
||||||
$error = extension_loaded($ext) ? 'has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'is missing from your system';
|
$error = extension_loaded($ext) ? 'has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'is missing from your system';
|
||||||
|
|
||||||
$text .= ' -> the requested PHP extension '.$ext.' '.$error.'.';
|
return $text . ' -> the requested PHP extension '.$ext.' '.$error.'.';
|
||||||
} elseif (0 === strpos($targetName, 'lib-')) {
|
} elseif (0 === strpos($targetName, 'lib-')) {
|
||||||
// handle linked libs
|
// handle linked libs
|
||||||
$lib = substr($targetName, 4);
|
$lib = substr($targetName, 4);
|
||||||
|
|
||||||
$text .= ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
|
return $text . ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
|
||||||
} else {
|
} else {
|
||||||
$text .= ' -> no matching package found.';
|
return $text . ' -> no matching package found.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -512,6 +512,7 @@ class Factory
|
||||||
}
|
}
|
||||||
|
|
||||||
$am = new Archiver\ArchiveManager($dm);
|
$am = new Archiver\ArchiveManager($dm);
|
||||||
|
$am->addArchiver(new Archiver\ZipArchiver);
|
||||||
$am->addArchiver(new Archiver\PharArchiver);
|
$am->addArchiver(new Archiver\PharArchiver);
|
||||||
|
|
||||||
return $am;
|
return $am;
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?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\Package\Archiver;
|
||||||
|
|
||||||
|
use ZipArchive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jan Prieser <jan@prieser.net>
|
||||||
|
*/
|
||||||
|
class ZipArchiver implements ArchiverInterface
|
||||||
|
{
|
||||||
|
protected static $formats = array(
|
||||||
|
'zip' => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function archive($sources, $target, $format, array $excludes = array())
|
||||||
|
{
|
||||||
|
$sources = realpath($sources);
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$res = $zip->open($target, ZipArchive::CREATE);
|
||||||
|
if ($res === true) {
|
||||||
|
$files = new ArchivableFilesFinder($sources, $excludes);
|
||||||
|
foreach($files as $file) {
|
||||||
|
/** @var $file \SplFileInfo */
|
||||||
|
$filepath = $file->getPath()."/".$file->getFilename();
|
||||||
|
$localname = str_replace($sources."/", '', $filepath);
|
||||||
|
$zip->addFile($filepath, $localname);
|
||||||
|
}
|
||||||
|
if ($zip->close()) {
|
||||||
|
return $target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$message = sprintf("Could not create archive '%s' from '%s': %s",
|
||||||
|
$target,
|
||||||
|
$sources,
|
||||||
|
$zip->getStatusString()
|
||||||
|
);
|
||||||
|
throw new \RuntimeException($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function supports($format, $sourceType)
|
||||||
|
{
|
||||||
|
return isset(static::$formats[$format]) && $this->compressionAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function compressionAvailable() {
|
||||||
|
return class_exists('ZipArchive');
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,6 +59,7 @@ class PlatformRepository extends ArrayRepository
|
||||||
$version = $versionParser->normalize($override['version']);
|
$version = $versionParser->normalize($override['version']);
|
||||||
$package = new CompletePackage($override['name'], $version, $override['version']);
|
$package = new CompletePackage($override['name'], $version, $override['version']);
|
||||||
$package->setDescription('Package overridden via config.platform');
|
$package->setDescription('Package overridden via config.platform');
|
||||||
|
$package->setExtra(array('config.platform' => true));
|
||||||
parent::addPackage($package);
|
parent::addPackage($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class ClassMapGeneratorTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
* @expectedExceptionMessage Could not scan for classes inside
|
* @expectedExceptionMessage does not exist
|
||||||
*/
|
*/
|
||||||
public function testFindClassesThrowsWhenFileDoesNotExist()
|
public function testFindClassesThrowsWhenFileDoesNotExist()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
--TEST--
|
||||||
|
|
||||||
|
See Github issue #4319 ( github.com/composer/composer/issues/4319 ).
|
||||||
|
|
||||||
|
Present a clear error message when config.platform.php version results in a conflict rule.
|
||||||
|
|
||||||
|
--CONDITION--
|
||||||
|
!defined('HHVM_VERSION')
|
||||||
|
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{ "name": "a", "version": "1.0.0", "require": { "php": "5.5" } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"a": "~1.0"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"platform": {
|
||||||
|
"php": "5.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--RUN--
|
||||||
|
install
|
||||||
|
|
||||||
|
--EXPECT-OUTPUT--
|
||||||
|
Loading composer repositories with package information
|
||||||
|
Installing dependencies (including require-dev)
|
||||||
|
Your requirements could not be resolved to an installable set of packages.
|
||||||
|
|
||||||
|
Problem 1
|
||||||
|
- Installation request for a ~1.0 -> satisfiable by a[1.0.0].
|
||||||
|
- a 1.0.0 requires php 5.5 -> your PHP version (%s) overriden by "config.platform.php" version (5.3) does not satisfy that requirement.
|
||||||
|
|
||||||
|
--EXPECT--
|
||||||
|
|
||||||
|
--EXPECT-EXIT-CODE--
|
||||||
|
2
|
|
@ -252,7 +252,7 @@ class InstallerTest extends TestCase
|
||||||
$this->assertSame(rtrim($expect), implode("\n", $installationManager->getTrace()));
|
$this->assertSame(rtrim($expect), implode("\n", $installationManager->getTrace()));
|
||||||
|
|
||||||
if ($expectOutput) {
|
if ($expectOutput) {
|
||||||
$this->assertEquals(rtrim($expectOutput), rtrim($output));
|
$this->assertStringMatchesFormat(rtrim($expectOutput), rtrim($output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?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\Package\Archiver;
|
||||||
|
|
||||||
|
use Composer\Package\Archiver\ZipArchiver;
|
||||||
|
|
||||||
|
class ZipArchiverTest extends ArchiverTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testZipArchive()
|
||||||
|
{
|
||||||
|
// Set up repository
|
||||||
|
$this->setupDummyRepo();
|
||||||
|
$package = $this->setupPackage();
|
||||||
|
$target = sys_get_temp_dir().'/composer_archiver_test.zip';
|
||||||
|
|
||||||
|
// Test archive
|
||||||
|
$archiver = new ZipArchiver();
|
||||||
|
$archiver->archive($package->getSourceUrl(), $target, 'zip');
|
||||||
|
$this->assertFileExists($target);
|
||||||
|
|
||||||
|
unlink($target);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a local dummy repository to run tests against!
|
||||||
|
*/
|
||||||
|
protected function setupDummyRepo()
|
||||||
|
{
|
||||||
|
$currentWorkDir = getcwd();
|
||||||
|
chdir($this->testDir);
|
||||||
|
|
||||||
|
$this->writeFile('file.txt', 'content', $currentWorkDir);
|
||||||
|
$this->writeFile('foo/bar/baz', 'content', $currentWorkDir);
|
||||||
|
$this->writeFile('foo/bar/ignoreme', 'content', $currentWorkDir);
|
||||||
|
$this->writeFile('x/baz', 'content', $currentWorkDir);
|
||||||
|
$this->writeFile('x/includeme', 'content', $currentWorkDir);
|
||||||
|
|
||||||
|
chdir($currentWorkDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function writeFile($path, $content, $currentWorkDir)
|
||||||
|
{
|
||||||
|
if (!file_exists(dirname($path))) {
|
||||||
|
mkdir(dirname($path), 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = file_put_contents($path, 'a');
|
||||||
|
if (false === $result) {
|
||||||
|
chdir($currentWorkDir);
|
||||||
|
throw new \RuntimeException('Could not save file.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue