diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index b068ac2de..9eaf0a3f2 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -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))); } /** diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index ee4f04e84..4a6eb89ca 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -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) { diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index 1878dcf52..bf1070c62 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -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);