1
0
Fork 0

Add types to root namespace (#10213)

pull/10215/head
Martin Herndl 2021-10-26 12:40:52 +02:00 committed by GitHub
parent f267b01852
commit 3645d3042c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 156 additions and 58 deletions

View File

@ -61,6 +61,8 @@ class Cache
/** /**
* @param bool $readOnly * @param bool $readOnly
*
* @return void
*/ */
public function setReadOnly($readOnly) public function setReadOnly($readOnly)
{ {
@ -76,6 +78,8 @@ class Cache
} }
/** /**
* @param string $path
*
* @return bool * @return bool
*/ */
public static function isUsable($path) public static function isUsable($path)
@ -112,6 +116,8 @@ class Cache
} }
/** /**
* @param string $file
*
* @return string|false * @return string|false
*/ */
public function read($file) public function read($file)
@ -129,6 +135,9 @@ class Cache
} }
/** /**
* @param string $file
* @param string $contents
*
* @return bool * @return bool
*/ */
public function write($file, $contents) public function write($file, $contents)
@ -169,6 +178,10 @@ class Cache
/** /**
* Copy a file into the cache * Copy a file into the cache
*
* @param string $file
* @param string $source
*
* @return bool * @return bool
*/ */
public function copyFrom($file, $source) public function copyFrom($file, $source)
@ -191,6 +204,10 @@ class Cache
/** /**
* Copy a file out of the cache * Copy a file out of the cache
*
* @param string $file
* @param string $target
*
* @return bool * @return bool
*/ */
public function copyTo($file, $target) public function copyTo($file, $target)
@ -237,6 +254,8 @@ class Cache
} }
/** /**
* @param string $file
*
* @return bool * @return bool
*/ */
public function remove($file) public function remove($file)
@ -266,6 +285,9 @@ class Cache
} }
/** /**
* @param int $ttl
* @param int $maxSize
*
* @return bool * @return bool
*/ */
public function gc($ttl, $maxSize) public function gc($ttl, $maxSize)
@ -299,6 +321,8 @@ class Cache
} }
/** /**
* @param string $file
*
* @return string|false * @return string|false
*/ */
public function sha1($file) public function sha1($file)
@ -314,6 +338,8 @@ class Cache
} }
/** /**
* @param string $file
*
* @return string|false * @return string|false
*/ */
public function sha256($file) public function sha256($file)

View File

@ -37,7 +37,10 @@ class Compiler
/** /**
* Compiles composer into a single phar file * Compiles composer into a single phar file
* *
* @param string $pharFile The full path to the file to create * @param string $pharFile The full path to the file to create
*
* @return void
*
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function compile($pharFile = 'composer.phar') public function compile($pharFile = 'composer.phar')
@ -214,7 +217,12 @@ class Compiler
return strtr($relativePath, '\\', '/'); return strtr($relativePath, '\\', '/');
} }
private function addFile($phar, $file, $strip = true) /**
* @param bool $strip
*
* @return void
*/
private function addFile(\Phar $phar, \SplFileInfo $file, $strip = true)
{ {
$path = $this->getRelativeFilePath($file); $path = $this->getRelativeFilePath($file);
$content = file_get_contents($file); $content = file_get_contents($file);
@ -239,7 +247,10 @@ class Compiler
$phar->addFromString($path, $content); $phar->addFromString($path, $content);
} }
private function addComposerBin($phar) /**
* @return void
*/
private function addComposerBin(\Phar $phar)
{ {
$content = file_get_contents(__DIR__.'/../../bin/composer'); $content = file_get_contents(__DIR__.'/../../bin/composer');
$content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content); $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);

View File

@ -141,7 +141,6 @@ class Composer
private $archiveManager; private $archiveManager;
/** /**
* @param RootPackageInterface $package
* @return void * @return void
*/ */
public function setPackage(RootPackageInterface $package) public function setPackage(RootPackageInterface $package)
@ -158,7 +157,7 @@ class Composer
} }
/** /**
* @param Config $config * @return void
*/ */
public function setConfig(Config $config) public function setConfig(Config $config)
{ {
@ -174,7 +173,7 @@ class Composer
} }
/** /**
* @param Locker $locker * @return void
*/ */
public function setLocker(Locker $locker) public function setLocker(Locker $locker)
{ {
@ -190,7 +189,7 @@ class Composer
} }
/** /**
* @param Loop $loop * @return void
*/ */
public function setLoop(Loop $loop) public function setLoop(Loop $loop)
{ {
@ -206,7 +205,7 @@ class Composer
} }
/** /**
* @param RepositoryManager $manager * @return void
*/ */
public function setRepositoryManager(RepositoryManager $manager) public function setRepositoryManager(RepositoryManager $manager)
{ {
@ -222,7 +221,7 @@ class Composer
} }
/** /**
* @param DownloadManager $manager * @return void
*/ */
public function setDownloadManager(DownloadManager $manager) public function setDownloadManager(DownloadManager $manager)
{ {
@ -238,7 +237,7 @@ class Composer
} }
/** /**
* @param ArchiveManager $manager * @return void
*/ */
public function setArchiveManager(ArchiveManager $manager) public function setArchiveManager(ArchiveManager $manager)
{ {
@ -254,7 +253,7 @@ class Composer
} }
/** /**
* @param InstallationManager $manager * @return void
*/ */
public function setInstallationManager(InstallationManager $manager) public function setInstallationManager(InstallationManager $manager)
{ {
@ -270,7 +269,7 @@ class Composer
} }
/** /**
* @param PluginManager $manager * @return void
*/ */
public function setPluginManager(PluginManager $manager) public function setPluginManager(PluginManager $manager)
{ {
@ -286,7 +285,7 @@ class Composer
} }
/** /**
* @param EventDispatcher $eventDispatcher * @return void
*/ */
public function setEventDispatcher(EventDispatcher $eventDispatcher) public function setEventDispatcher(EventDispatcher $eventDispatcher)
{ {
@ -302,7 +301,7 @@ class Composer
} }
/** /**
* @param AutoloadGenerator $autoloadGenerator * @return void
*/ */
public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator) public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
{ {

View File

@ -114,6 +114,9 @@ class Config
$this->baseDir = $baseDir; $this->baseDir = $baseDir;
} }
/**
* @return void
*/
public function setConfigSource(ConfigSourceInterface $source) public function setConfigSource(ConfigSourceInterface $source)
{ {
$this->configSource = $source; $this->configSource = $source;
@ -127,6 +130,9 @@ class Config
return $this->configSource; return $this->configSource;
} }
/**
* @return void
*/
public function setAuthConfigSource(ConfigSourceInterface $source) public function setAuthConfigSource(ConfigSourceInterface $source)
{ {
$this->authConfigSource = $source; $this->authConfigSource = $source;
@ -143,7 +149,9 @@ class Config
/** /**
* Merges new config values with the existing ones (overriding) * Merges new config values with the existing ones (overriding)
* *
* @param array $config * @param array<string, mixed> $config
*
* @return void
*/ */
public function merge($config) public function merge($config)
{ {
@ -184,13 +192,13 @@ class Config
foreach ($newRepos as $name => $repository) { foreach ($newRepos as $name => $repository) {
// disable a repository by name // disable a repository by name
if (false === $repository) { if (false === $repository) {
$this->disableRepoByName($name); $this->disableRepoByName((string) $name);
continue; continue;
} }
// disable a repository with an anonymous {"name": false} repo // disable a repository with an anonymous {"name": false} repo
if (is_array($repository) && 1 === count($repository) && false === current($repository)) { if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
$this->disableRepoByName(key($repository)); $this->disableRepoByName((string) key($repository));
continue; continue;
} }
@ -215,7 +223,7 @@ class Config
} }
/** /**
* @return array * @return array<int|string, mixed>
*/ */
public function getRepositories() public function getRepositories()
{ {
@ -228,6 +236,7 @@ class Config
* @param string $key * @param string $key
* @param int $flags Options (see class constants) * @param int $flags Options (see class constants)
* @throws \RuntimeException * @throws \RuntimeException
*
* @return mixed * @return mixed
*/ */
public function get($key, $flags = 0) public function get($key, $flags = 0)
@ -380,6 +389,8 @@ class Config
} }
/** /**
* @param int $flags
*
* @return array<string, mixed[]> * @return array<string, mixed[]>
*/ */
public function all($flags = 0) public function all($flags = 0)
@ -421,6 +432,7 @@ class Config
* *
* @param string|int|null $value a config string that can contain {$refs-to-other-config} * @param string|int|null $value a config string that can contain {$refs-to-other-config}
* @param int $flags Options (see class constants) * @param int $flags Options (see class constants)
*
* @return string|int|null * @return string|int|null
*/ */
private function process($value, $flags) private function process($value, $flags)
@ -471,6 +483,11 @@ class Config
return false; return false;
} }
/**
* @param string $name
*
* @return void
*/
private function disableRepoByName($name) private function disableRepoByName($name)
{ {
if (isset($this->repositories[$name])) { if (isset($this->repositories[$name])) {
@ -485,6 +502,8 @@ class Config
* *
* @param string $url * @param string $url
* @param IOInterface $io * @param IOInterface $io
*
* @return void
*/ */
public function prohibitUrlByConfig($url, IOInterface $io = null) public function prohibitUrlByConfig($url, IOInterface $io = null)
{ {
@ -527,6 +546,8 @@ class Config
* "vendor/bin/long-running-script --watch" * "vendor/bin/long-running-script --watch"
* ] * ]
* } * }
*
* @return void
*/ */
public static function disableProcessTimeout() public static function disableProcessTimeout()
{ {

View File

@ -88,7 +88,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
if ($this->cache && $this->cache->gcIsNecessary()) { if ($this->cache && $this->cache->gcIsNecessary()) {
$this->io->writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE); $this->io->writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE);
$this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize')); $this->cache->gc((int) $config->get('cache-files-ttl'), (int) $config->get('cache-files-maxsize'));
} }
} }

View File

@ -171,12 +171,13 @@ class Factory
} }
/** /**
* @param IOInterface|null $io * @param string|null $cwd
*
* @return Config * @return Config
*/ */
public static function createConfig(IOInterface $io = null, $cwd = null) public static function createConfig(IOInterface $io = null, $cwd = null)
{ {
$cwd = $cwd ?: getcwd(); $cwd = $cwd ?: (string) getcwd();
$config = new Config(true, $cwd); $config = new Config(true, $cwd);
@ -250,6 +251,8 @@ class Factory
} }
/** /**
* @param string $composerFile
*
* @return string * @return string
*/ */
public static function getLockFile($composerFile) public static function getLockFile($composerFile)
@ -286,18 +289,19 @@ class Factory
/** /**
* Creates a Composer instance * Creates a Composer instance
* *
* @param IOInterface $io IO instance * @param IOInterface $io IO instance
* @param array|string|null $localConfig either a configuration array or a filename to read from, if null it will * @param array<string, mixed>|string|null $localConfig either a configuration array or a filename to read from, if null it will
* read from the default filename * read from the default filename
* @param bool $disablePlugins Whether plugins should not be loaded * @param bool $disablePlugins Whether plugins should not be loaded
* @param bool $fullLoad Whether to initialize everything or only main project stuff (used when loading the global composer) * @param string|null $cwd
* @param bool $fullLoad Whether to initialize everything or only main project stuff (used when loading the global composer)
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
* @return Composer * @return Composer
*/ */
public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true) public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
{ {
$cwd = $cwd ?: getcwd(); $cwd = $cwd ?: (string) getcwd();
// load Composer configuration // load Composer configuration
if (null === $localConfig) { if (null === $localConfig) {
@ -465,6 +469,8 @@ class Factory
/** /**
* @param Repository\RepositoryManager $rm * @param Repository\RepositoryManager $rm
* @param string $vendorDir * @param string $vendorDir
*
* @return void
*/ */
protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage, ProcessExecutor $process = null) protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage, ProcessExecutor $process = null)
{ {
@ -477,7 +483,9 @@ class Factory
} }
/** /**
* @param Config $config * @param bool $disablePlugins
* @param bool $fullLoad
*
* @return Composer|null * @return Composer|null
*/ */
protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false) protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
@ -578,9 +586,7 @@ class Factory
} }
/** /**
* @param Installer\InstallationManager $im * @return void
* @param Composer $composer
* @param IO\IOInterface $io
*/ */
protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null) protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
{ {
@ -594,7 +600,9 @@ class Factory
/** /**
* @param InstalledRepositoryInterface $repo repository to purge packages from * @param InstalledRepositoryInterface $repo repository to purge packages from
* @param Installer\InstallationManager $im manager to check whether packages are still installed * @param Installer\InstallationManager $im manager to check whether packages are still installed
*
* @return void
*/ */
protected function purgePackages(InstalledRepositoryInterface $repo, Installer\InstallationManager $im) protected function purgePackages(InstalledRepositoryInterface $repo, Installer\InstallationManager $im)
{ {
@ -632,7 +640,7 @@ class Factory
* *
* @param IOInterface $io IO instance * @param IOInterface $io IO instance
* @param Config $config Config instance * @param Config $config Config instance
* @param array $options Array of options passed directly to HttpDownloader constructor * @param mixed[] $options Array of options passed directly to HttpDownloader constructor
* @return HttpDownloader * @return HttpDownloader
*/ */
public static function createHttpDownloader(IOInterface $io, Config $config, $options = array()) public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())

View File

@ -372,6 +372,11 @@ class Installer
return 0; return 0;
} }
/**
* @param bool $doInstall
*
* @return int
*/
protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall) protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
{ {
$platformRepo = $this->createPlatformRepo(true); $platformRepo = $this->createPlatformRepo(true);
@ -573,6 +578,13 @@ class Installer
/** /**
* Run the solver a second time on top of the existing update result with only the current result set in the pool * Run the solver a second time on top of the existing update result with only the current result set in the pool
* and see what packages would get removed if we only had the non-dev packages in the solver request * and see what packages would get removed if we only had the non-dev packages in the solver request
*
* @param array<int, array<string, string>> $aliases
*
* @return int
*
* @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
* @phpstan-return self::ERROR_*
*/ */
protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null) protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null)
{ {
@ -740,6 +752,11 @@ class Installer
return 0; return 0;
} }
/**
* @param bool $forUpdate
*
* @return PlatformRepository
*/
protected function createPlatformRepo($forUpdate) protected function createPlatformRepo($forUpdate)
{ {
if ($forUpdate) { if ($forUpdate) {
@ -752,11 +769,13 @@ class Installer
} }
/** /**
* @param bool $forUpdate * @param bool $forUpdate
* @param PlatformRepository $platformRepo * @param array<int, array<string, string>> $rootAliases
* @param array $rootAliases * @param RepositoryInterface|null $lockedRepository
* @param RepositoryInterface|null $lockedRepository *
* @return RepositorySet * @return RepositorySet
*
* @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $rootAliases
*/ */
private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null) private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
{ {
@ -822,6 +841,8 @@ class Installer
} }
/** /**
* @param bool $forUpdate
*
* @return DefaultPolicy * @return DefaultPolicy
*/ */
private function createPolicy($forUpdate) private function createPolicy($forUpdate)
@ -879,6 +900,12 @@ class Installer
return $request; return $request;
} }
/**
* @param LockArrayRepository|null $lockedRepository
* @param bool $includeDevRequires
*
* @return void
*/
private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true) private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true)
{ {
// if we're updating mirrors we want to keep exactly the same versions installed which are in the lock file, but we want current remote metadata // if we're updating mirrors we want to keep exactly the same versions installed which are in the lock file, but we want current remote metadata
@ -907,8 +934,11 @@ class Installer
} }
/** /**
* @param bool $forUpdate * @param bool $forUpdate
* @return array *
* @return array<int, array<string, string>>
*
* @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/ */
private function getRootAliases($forUpdate) private function getRootAliases($forUpdate)
{ {
@ -922,8 +952,9 @@ class Installer
} }
/** /**
* @param array $links * @param Link[] $links
* @return array *
* @return array<string, string>
*/ */
private function extractPlatformRequirements(array $links) private function extractPlatformRequirements(array $links)
{ {
@ -942,7 +973,7 @@ class Installer
* *
* This is to prevent any accidental modification of the existing repos on disk * This is to prevent any accidental modification of the existing repos on disk
* *
* @param RepositoryManager $rm * @return void
*/ */
private function mockLocalRepositories(RepositoryManager $rm) private function mockLocalRepositories(RepositoryManager $rm)
{ {
@ -1208,7 +1239,8 @@ class Installer
* If this is set to false, no platform requirements are ignored * If this is set to false, no platform requirements are ignored
* If this is set to string[], those packages will be ignored * If this is set to string[], those packages will be ignored
* *
* @param bool|array $ignorePlatformReqs * @param bool|string[] $ignorePlatformReqs
*
* @return Installer * @return Installer
*/ */
public function setIgnorePlatformRequirements($ignorePlatformReqs) public function setIgnorePlatformRequirements($ignorePlatformReqs)
@ -1241,7 +1273,8 @@ class Installer
* restrict the update operation to a few packages, all other packages * restrict the update operation to a few packages, all other packages
* that are already installed will be kept at their current version * that are already installed will be kept at their current version
* *
* @param array $packages * @param string[] $packages
*
* @return Installer * @return Installer
*/ */
public function setUpdateAllowList(array $packages) public function setUpdateAllowList(array $packages)

View File

@ -308,7 +308,7 @@ class Locker
/** /**
* @return string[][] * @return string[][]
* *
* @phpstan-return list<array<string, string>> * @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/ */
public function getAliases() public function getAliases()
{ {
@ -350,7 +350,7 @@ class Locker
* *
* @return bool * @return bool
* *
* @phpstan-param list<array<string, string>> $aliases * @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
*/ */
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true) public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
{ {

View File

@ -1132,8 +1132,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
if (isset($data['includes'])) { if (isset($data['includes'])) {
foreach ($data['includes'] as $include => $metadata) { foreach ($data['includes'] as $include => $metadata) {
if (isset($metadata['sha1']) && $this->cache->sha1($include) === $metadata['sha1']) { if (isset($metadata['sha1']) && $this->cache->sha1((string) $include) === $metadata['sha1']) {
$includedData = json_decode($this->cache->read($include), true); $includedData = json_decode($this->cache->read((string) $include), true);
} else { } else {
$includedData = $this->fetchFile($include); $includedData = $this->fetchFile($include);
} }
@ -1215,7 +1215,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} }
$response = $this->httpDownloader->get($filename, $options); $response = $this->httpDownloader->get($filename, $options);
$json = $response->getBody(); $json = (string) $response->getBody();
if ($sha256 && $sha256 !== hash('sha256', $json)) { if ($sha256 && $sha256 !== hash('sha256', $json)) {
// undo downgrade before trying again if http seems to be hijacked or modifying content somehow // undo downgrade before trying again if http seems to be hijacked or modifying content somehow
if ($this->allowSslDowngrade) { if ($this->allowSslDowngrade) {
@ -1247,7 +1247,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$lastModifiedDate = $response->getHeader('last-modified'); $lastModifiedDate = $response->getHeader('last-modified');
if ($lastModifiedDate) { if ($lastModifiedDate) {
$data['last-modified'] = $lastModifiedDate; $data['last-modified'] = $lastModifiedDate;
$json = json_encode($data); $json = JsonFile::encode($data, 0);
} }
} }
$this->cache->write($cacheKey, $json); $this->cache->write($cacheKey, $json);
@ -1329,7 +1329,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} }
$options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime; $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
$response = $this->httpDownloader->get($filename, $options); $response = $this->httpDownloader->get($filename, $options);
$json = $response->getBody(); $json = (string) $response->getBody();
if ($json === '' && $response->getStatusCode() === 304) { if ($json === '' && $response->getStatusCode() === 304) {
return true; return true;
} }
@ -1346,7 +1346,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$response->collect(); $response->collect();
if ($lastModifiedDate) { if ($lastModifiedDate) {
$data['last-modified'] = $lastModifiedDate; $data['last-modified'] = $lastModifiedDate;
$json = json_encode($data); $json = JsonFile::encode($data, 0);
} }
if (!$this->cache->isReadOnly()) { if (!$this->cache->isReadOnly()) {
$this->cache->write($cacheKey, $json); $this->cache->write($cacheKey, $json);
@ -1431,7 +1431,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return array('packages' => array()); return array('packages' => array());
} }
$json = $response->getBody(); $json = (string) $response->getBody();
if ($json === '' && $response->getStatusCode() === 304) { if ($json === '' && $response->getStatusCode() === 304) {
$repo->freshMetadataUrls[$filename] = true; $repo->freshMetadataUrls[$filename] = true;

View File

@ -50,7 +50,7 @@ class FossilDriver extends VcsDriver
if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) { if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
$this->checkoutDir = $this->url; $this->checkoutDir = $this->url;
} else { } else {
if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) { if (!Cache::isUsable((string) $this->config->get('cache-repo-dir')) || !Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled'); throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
} }

View File

@ -47,7 +47,7 @@ class GitDriver extends VcsDriver
$this->repoDir = $this->url; $this->repoDir = $this->url;
$cacheUrl = realpath($this->url); $cacheUrl = realpath($this->url);
} else { } else {
if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) { if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled'); throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
} }

View File

@ -41,7 +41,7 @@ class HgDriver extends VcsDriver
if (Filesystem::isLocalPath($this->url)) { if (Filesystem::isLocalPath($this->url)) {
$this->repoDir = $this->url; $this->repoDir = $this->url;
} else { } else {
if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) { if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled'); throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
} }

View File

@ -60,7 +60,7 @@ class PerforceDriver extends VcsDriver
return; return;
} }
if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) { if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled'); throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
} }

View File

@ -96,7 +96,7 @@ abstract class VcsDriver implements VcsDriverInterface
$composer = $this->getBaseComposerInformation($identifier); $composer = $this->getBaseComposerInformation($identifier);
if ($this->shouldCache($identifier)) { if ($this->shouldCache($identifier)) {
$this->cache->write($identifier, json_encode($composer)); $this->cache->write($identifier, JsonFile::encode($composer, 0));
} }
$this->infoCache[$identifier] = $composer; $this->infoCache[$identifier] = $composer;