1
0
Fork 0

Remove a few instances of RemoteFilesystem that were not needed

pull/4759/head
Jordi Boggiano 2016-01-10 17:07:54 +00:00
parent 86a911150b
commit cb53bd04cb
3 changed files with 13 additions and 10 deletions

View File

@ -206,13 +206,10 @@ class Factory
$localConfig = static::getComposerFile();
}
$rfs = Factory::createRemoteFilesystem($io);
if (is_string($localConfig)) {
$composerFile = $localConfig;
$rfs = Factory::createRemoteFilesystem($io);
$file = new JsonFile($localConfig, $rfs);
$file = new JsonFile($localConfig, null, $io);
if (!$file->exists()) {
if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
@ -274,7 +271,7 @@ class Factory
$composer->setRepositoryManager($rm);
// load local repository
$this->addLocalRepository($rm, $vendorDir);
$this->addLocalRepository($io, $rm, $vendorDir);
// force-set the version of the global package if not defined as
// guessing it adds no value and only takes time
@ -326,7 +323,7 @@ class Factory
? substr($composerFile, 0, -4).'lock'
: $composerFile . '.lock';
$locker = new Package\Locker($io, new JsonFile($lockFile, $rfs), $rm, $im, file_get_contents($composerFile));
$locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $rm, $im, file_get_contents($composerFile));
$composer->setLocker($locker);
}
@ -361,9 +358,9 @@ class Factory
* @param Repository\RepositoryManager $rm
* @param string $vendorDir
*/
protected function addLocalRepository(RepositoryManager $rm, $vendorDir)
protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir)
{
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json')));
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io)));
}
/**

View File

@ -16,6 +16,7 @@ use JsonSchema\Validator;
use Seld\JsonLint\JsonParser;
use Seld\JsonLint\ParsingException;
use Composer\Util\RemoteFilesystem;
use Composer\IO\IOInterface;
use Composer\Downloader\TransportException;
/**
@ -35,6 +36,7 @@ class JsonFile
private $path;
private $rfs;
private $io;
/**
* Initializes json file reader/parser.
@ -43,7 +45,7 @@ class JsonFile
* @param RemoteFilesystem $rfs required for loading http/https json files
* @throws \InvalidArgumentException
*/
public function __construct($path, RemoteFilesystem $rfs = null)
public function __construct($path, RemoteFilesystem $rfs = null, IOInterface $io = null)
{
$this->path = $path;
@ -51,6 +53,7 @@ class JsonFile
throw new \InvalidArgumentException('http urls require a RemoteFilesystem instance to be passed');
}
$this->rfs = $rfs;
$this->io = $io;
}
/**
@ -83,6 +86,9 @@ class JsonFile
if ($this->rfs) {
$json = $this->rfs->getContents($this->path, $this->path, false);
} else {
if ($this->io && $this->io->isDebug()) {
$this->io->writeError('Reading ' . $this->path);
}
$json = file_get_contents($this->path);
}
} catch (TransportException $e) {

View File

@ -53,7 +53,7 @@ class ConfigValidator
// validate json schema
$laxValid = false;
try {
$json = new JsonFile($file, Factory::createRemoteFilesystem($this->io)); //TODO - can't configure here obviouslyS
$json = new JsonFile($file, null, $this->io);
$manifest = $json->read();
$json->validateSchema(JsonFile::LAX_SCHEMA);