Skip to content

Commit

Permalink
Merge pull request #1 from Seldaek/refactoring
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
everzet committed Sep 24, 2011
2 parents 10bd9c3 + 6d667a8 commit cce4d3a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 36 deletions.
2 changes: 1 addition & 1 deletion bin/composer
Expand Up @@ -23,7 +23,7 @@ $composer->setRepository('Platform', new Repository\PlatformRepository());
$composer->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));

// initialize package
$loader = new Package\Loader\Json();
$loader = new Package\Loader\JsonLoader();
$package = $loader->load('composer.json');

// initialize lock
Expand Down
2 changes: 1 addition & 1 deletion doc/composer-schema.json
Expand Up @@ -9,7 +9,7 @@
"required": true
},
"type": {
"description": "Package type, either 'Library', or the parent project it applies to if it's a plugin for a framework or application (e.g. 'Symfony2', 'Typo3', 'Drupal', ..).",
"description": "Package type, either 'Library', or the parent project it applies to if it's a plugin for a framework or application (e.g. 'Symfony2', 'Typo3', 'Drupal', ..), note that this has to be defined and communicated by any project implementing a custom composer installer, those are just unreliable examples.",
"type": "string",
"optional": true
},
Expand Down
4 changes: 3 additions & 1 deletion src/Composer/Command/InstallCommand.php
Expand Up @@ -13,6 +13,8 @@
namespace Composer\Command;

use Composer\DependencyResolver;
use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Request;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand Down Expand Up @@ -43,7 +45,7 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->getLock()->isLocked()) {
$this->writeln('<info>Found lockfile. Reading</info>');
$output->writeln('<info>Found lockfile. Reading</info>');

foreach ($this->getLock()->getLockedPackages() as $package) {
$installer = $this->getComposer()->getInstaller($package->getType());
Expand Down
1 change: 1 addition & 0 deletions src/Composer/Composer.php
Expand Up @@ -13,6 +13,7 @@
namespace Composer;

use Composer\Installer\InstallerInterface;
use Composer\Repository\RepositoryInterface;

/**
* @author Jordi Boggiano <j.boggiano@seld.be>
Expand Down
7 changes: 2 additions & 5 deletions src/Composer/Package/Loader/ArrayLoader.php
Expand Up @@ -36,7 +36,7 @@ public function load($config)
$version = $versionParser->parse($config['version']);
$package = new Package\MemoryPackage($config['name'], $version['version'], $version['type']);

$package->setType($config['type']);
$package->setType(isset($config['type']) ? $config['type'] : 'library');

if (isset($config['extra'])) {
$package->setExtra($config['extra']);
Expand Down Expand Up @@ -99,17 +99,14 @@ private function loadLinksFromConfig($srcPackageName, $description, array $links
$links[] = new Package\Link($srcPackageName, $packageName, $constraint, $description);
}

return $requirements;
return $links;
}

private function validateConfig(array $config)
{
if (!isset($config['name'])) {
throw new \UnexpectedValueException('name is required for package');
}
if (!isset($config['type'])) {
throw new \UnexpectedValueException('type is required for package');
}
if (!isset($config['version'])) {
throw new \UnexpectedValueException('version is required for package');
}
Expand Down
9 changes: 6 additions & 3 deletions src/Composer/Repository/PlatformRepository.php
Expand Up @@ -14,6 +14,7 @@

use Composer\Package\MemoryPackage;
use Composer\Package\BasePackage;
use Composer\Package\Version\VersionParser;

/**
* @author Jordi Boggiano <j.boggiano@seld.be>
Expand All @@ -24,10 +25,12 @@ protected function initialize()
{
parent::initialize();

$versionParser = new VersionParser();

try {
$version = BasePackage::parseVersion(PHP_VERSION);
$version = $versionParser->parse(PHP_VERSION);
} catch (\UnexpectedValueException $e) {
$version = BasePackage::parseVersion(preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION));
$version = $versionParser->parse(preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION));
}

$php = new MemoryPackage('php', $version['version'], $version['type']);
Expand All @@ -40,7 +43,7 @@ protected function initialize()

$reflExt = new \ReflectionExtension($ext);
try {
$version = BasePackage::parseVersion($reflExt->getVersion());
$version = $versionParser->parse($reflExt->getVersion());
} catch (\UnexpectedValueException $e) {
$version = array('version' => '0', 'type' => 'stable');
}
Expand Down
3 changes: 0 additions & 3 deletions src/Composer/Repository/RepositoryInterface.php
Expand Up @@ -17,8 +17,5 @@
*/
interface RepositoryInterface extends \Countable
{
static function supports($type, $name = '', $url = '');
static function create($type, $name = '', $url = '');

function getPackages();
}
22 changes: 0 additions & 22 deletions tests/Composer/Test/DependencyResolver/SolverTest.php
Expand Up @@ -213,28 +213,6 @@ public function testInstallOneOfTwoAlternatives()
));
}

/**
* @TODO: fix packagist.org bug
*/
public function BROKEN_testSolverWithComposerRepo()
{
$this->repoInstalled = new PlatformRepository;

// overwrite solver with custom installed repo
$this->solver = new Solver($this->policy, $this->pool, $this->repoInstalled);

$this->repo = new ComposerRepository('http://packagist.org');
list($monolog) = $this->repo->getPackages();

$this->reposComplete();

$this->request->install('Monolog');

$this->checkSolverResult(array(
array('job' => 'install', 'package' => $monolog),
));
}

protected function reposComplete()
{
$this->pool->addRepository($this->repoInstalled);
Expand Down

0 comments on commit cce4d3a

Please sign in to comment.