Add parameter types to all the things
parent
c9baeda95b
commit
6da38f83a0
|
@ -16,8 +16,8 @@ $finder = PhpCsFixer\Finder::create()
|
||||||
->in(__DIR__.'/tests')
|
->in(__DIR__.'/tests')
|
||||||
->name('*.php')
|
->name('*.php')
|
||||||
->notPath('Fixtures')
|
->notPath('Fixtures')
|
||||||
->notPath(__DIR__.'/src/Composer/Autoload/ClassLoader.php')
|
->notPath('Composer/Autoload/ClassLoader.php')
|
||||||
->notPath(__DIR__.'/src/Composer/InstalledVersions.php')
|
->notPath('Composer/InstalledVersions.php')
|
||||||
;
|
;
|
||||||
|
|
||||||
$config = new PhpCsFixer\Config();
|
$config = new PhpCsFixer\Config();
|
||||||
|
@ -70,7 +70,11 @@ return $config->setRules([
|
||||||
'combine_nested_dirname' => true,
|
'combine_nested_dirname' => true,
|
||||||
'random_api_migration' => true,
|
'random_api_migration' => true,
|
||||||
'ternary_to_null_coalescing' => true,
|
'ternary_to_null_coalescing' => true,
|
||||||
|
'phpdoc_to_param_type' => true,
|
||||||
//'declare_strict_types' => true,
|
//'declare_strict_types' => true,
|
||||||
|
|
||||||
|
// TODO php 7.4 migration (one day..)
|
||||||
|
// 'phpdoc_to_property_type' => true,
|
||||||
])
|
])
|
||||||
->setUsingCache(true)
|
->setUsingCache(true)
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$cwd = getcwd();
|
$cwd = getcwd();
|
||||||
|
assert(is_string($cwd));
|
||||||
chdir(__DIR__.'/../');
|
chdir(__DIR__.'/../');
|
||||||
$ts = rtrim(shell_exec('git log -n1 --pretty=%ct HEAD'));
|
$ts = rtrim(shell_exec('git log -n1 --pretty=%ct HEAD'));
|
||||||
if (!is_numeric($ts)) {
|
if (!is_numeric($ts)) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class AutoloadGenerator
|
||||||
* @param bool $devMode
|
* @param bool $devMode
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setDevMode($devMode = true)
|
public function setDevMode(bool $devMode = true)
|
||||||
{
|
{
|
||||||
$this->devMode = (bool) $devMode;
|
$this->devMode = (bool) $devMode;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class AutoloadGenerator
|
||||||
* @param bool $classMapAuthoritative
|
* @param bool $classMapAuthoritative
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
public function setClassMapAuthoritative(bool $classMapAuthoritative)
|
||||||
{
|
{
|
||||||
$this->classMapAuthoritative = (bool) $classMapAuthoritative;
|
$this->classMapAuthoritative = (bool) $classMapAuthoritative;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ class AutoloadGenerator
|
||||||
* @param string|null $apcuPrefix
|
* @param string|null $apcuPrefix
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setApcu($apcu, $apcuPrefix = null)
|
public function setApcu(bool $apcu, ?string $apcuPrefix = null)
|
||||||
{
|
{
|
||||||
$this->apcu = (bool) $apcu;
|
$this->apcu = (bool) $apcu;
|
||||||
$this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
|
$this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
|
||||||
|
@ -124,7 +124,7 @@ class AutoloadGenerator
|
||||||
* @param bool $runScripts
|
* @param bool $runScripts
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setRunScripts($runScripts = true)
|
public function setRunScripts(bool $runScripts = true)
|
||||||
{
|
{
|
||||||
$this->runScripts = (bool) $runScripts;
|
$this->runScripts = (bool) $runScripts;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ class AutoloadGenerator
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Seld\JsonLint\ParsingException
|
* @throws \Seld\JsonLint\ParsingException
|
||||||
*/
|
*/
|
||||||
public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
|
public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, string $targetDir, bool $scanPsrPackages = false, string $suffix = '')
|
||||||
{
|
{
|
||||||
if ($this->classMapAuthoritative) {
|
if ($this->classMapAuthoritative) {
|
||||||
// Force scanPsrPackages when classmap is authoritative
|
// Force scanPsrPackages when classmap is authoritative
|
||||||
|
@ -200,7 +200,7 @@ class AutoloadGenerator
|
||||||
// Do not remove double realpath() calls.
|
// Do not remove double realpath() calls.
|
||||||
// Fixes failing Windows realpath() implementation.
|
// Fixes failing Windows realpath() implementation.
|
||||||
// See https://bugs.php.net/bug.php?id=72738
|
// See https://bugs.php.net/bug.php?id=72738
|
||||||
$basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
|
$basePath = $filesystem->normalizePath(realpath(realpath(Platform::getCwd())));
|
||||||
$vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
|
$vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
|
||||||
$useGlobalIncludePath = (bool) $config->get('use-include-path');
|
$useGlobalIncludePath = (bool) $config->get('use-include-path');
|
||||||
$prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
|
$prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
|
||||||
|
@ -433,15 +433,15 @@ EOF;
|
||||||
* @param string $basePath
|
* @param string $basePath
|
||||||
* @param string $vendorPath
|
* @param string $vendorPath
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param ?array<int, string> $excluded
|
* @param null|array<int, string> $excluded
|
||||||
* @param ?string $namespaceFilter
|
* @param null|string $namespaceFilter
|
||||||
* @param ?string $autoloadType
|
* @param null|string $autoloadType
|
||||||
* @param array<class-string, string> $classMap
|
* @param array<class-string, string> $classMap
|
||||||
* @param array<class-string, array<int, string>> $ambiguousClasses
|
* @param array<class-string, array<int, string>> $ambiguousClasses
|
||||||
* @param array<string, true> $scannedFiles
|
* @param array<string, true> $scannedFiles
|
||||||
* @return array<class-string, string>
|
* @return array<class-string, string>
|
||||||
*/
|
*/
|
||||||
private function addClassMapCode(Filesystem $filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles): array
|
private function addClassMapCode(Filesystem $filesystem, string $basePath, string $vendorPath, string $dir, ?array $excluded, ?string $namespaceFilter, ?string $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles): array
|
||||||
{
|
{
|
||||||
foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
|
foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
|
||||||
$pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
|
$pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
|
||||||
|
@ -457,14 +457,14 @@ EOF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param ?array<int, string> $excluded
|
* @param null|array<int, string> $excluded
|
||||||
* @param ?string $namespaceFilter
|
* @param null|string $namespaceFilter
|
||||||
* @param ?string $autoloadType
|
* @param null|string $autoloadType
|
||||||
* @param bool $showAmbiguousWarning
|
* @param bool $showAmbiguousWarning
|
||||||
* @param array<string, true> $scannedFiles
|
* @param array<string, true> $scannedFiles
|
||||||
* @return array<class-string, string>
|
* @return array<class-string, string>
|
||||||
*/
|
*/
|
||||||
private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles): array
|
private function generateClassMap(string $dir, ?array $excluded, ?string $namespaceFilter, ?string $autoloadType, bool $showAmbiguousWarning, array &$scannedFiles): array
|
||||||
{
|
{
|
||||||
if ($excluded) {
|
if ($excluded) {
|
||||||
// filter excluded patterns here to only use those matching $dir
|
// filter excluded patterns here to only use those matching $dir
|
||||||
|
@ -586,10 +586,10 @@ EOF;
|
||||||
* Registers an autoloader based on an autoload-map returned by parseAutoloads
|
* Registers an autoloader based on an autoload-map returned by parseAutoloads
|
||||||
*
|
*
|
||||||
* @param array<string, mixed[]> $autoloads see parseAutoloads return value
|
* @param array<string, mixed[]> $autoloads see parseAutoloads return value
|
||||||
* @param ?string $vendorDir
|
* @param null|string $vendorDir
|
||||||
* @return ClassLoader
|
* @return ClassLoader
|
||||||
*/
|
*/
|
||||||
public function createLoader(array $autoloads, $vendorDir = null)
|
public function createLoader(array $autoloads, ?string $vendorDir = null)
|
||||||
{
|
{
|
||||||
$loader = new ClassLoader($vendorDir);
|
$loader = new ClassLoader($vendorDir);
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ EOF;
|
||||||
* @param string $appBaseDirCode
|
* @param string $appBaseDirCode
|
||||||
* @return ?string
|
* @return ?string
|
||||||
*/
|
*/
|
||||||
protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
|
protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
|
||||||
{
|
{
|
||||||
$includePaths = array();
|
$includePaths = array();
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ EOF;
|
||||||
* @param string $appBaseDirCode
|
* @param string $appBaseDirCode
|
||||||
* @return ?string
|
* @return ?string
|
||||||
*/
|
*/
|
||||||
protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
|
protected function getIncludeFilesFile(array $files, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
|
||||||
{
|
{
|
||||||
$filesCode = '';
|
$filesCode = '';
|
||||||
foreach ($files as $fileIdentifier => $functionFile) {
|
foreach ($files as $fileIdentifier => $functionFile) {
|
||||||
|
@ -712,7 +712,7 @@ EOF;
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
|
protected function getPathCode(Filesystem $filesystem, string $basePath, string $vendorPath, string $path)
|
||||||
{
|
{
|
||||||
if (!$filesystem->isAbsolutePath($path)) {
|
if (!$filesystem->isAbsolutePath($path)) {
|
||||||
$path = $basePath . '/' . $path;
|
$path = $basePath . '/' . $path;
|
||||||
|
@ -748,7 +748,7 @@ EOF;
|
||||||
* @param string[] $devPackageNames
|
* @param string[] $devPackageNames
|
||||||
* @return ?string
|
* @return ?string
|
||||||
*/
|
*/
|
||||||
protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
|
protected function getPlatformCheck(array $packageMap, bool $checkPlatform, array $devPackageNames)
|
||||||
{
|
{
|
||||||
$lowestPhpVersion = Bound::zero();
|
$lowestPhpVersion = Bound::zero();
|
||||||
$requiredExtensions = array();
|
$requiredExtensions = array();
|
||||||
|
@ -906,7 +906,7 @@ PLATFORM_CHECK;
|
||||||
* @param string $suffix
|
* @param string $suffix
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
|
protected function getAutoloadFile(string $vendorPathToTargetDirCode, string $suffix)
|
||||||
{
|
{
|
||||||
$lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
|
$lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
|
||||||
if ("'" === $lastChar || '"' === $lastChar) {
|
if ("'" === $lastChar || '"' === $lastChar) {
|
||||||
|
@ -930,7 +930,7 @@ AUTOLOAD;
|
||||||
/**
|
/**
|
||||||
* @param bool $useClassMap
|
* @param bool $useClassMap
|
||||||
* @param bool $useIncludePath
|
* @param bool $useIncludePath
|
||||||
* @param ?string $targetDirLoader
|
* @param null|string $targetDirLoader
|
||||||
* @param bool $useIncludeFiles
|
* @param bool $useIncludeFiles
|
||||||
* @param string $vendorPathCode unused in this method
|
* @param string $vendorPathCode unused in this method
|
||||||
* @param string $appBaseDirCode unused in this method
|
* @param string $appBaseDirCode unused in this method
|
||||||
|
@ -940,7 +940,7 @@ AUTOLOAD;
|
||||||
* @param bool $checkPlatform
|
* @param bool $checkPlatform
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform)
|
protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform)
|
||||||
{
|
{
|
||||||
$file = <<<HEADER
|
$file = <<<HEADER
|
||||||
<?php
|
<?php
|
||||||
|
@ -1092,7 +1092,7 @@ FOOTER;
|
||||||
* @param string $basePath input for findShortestPathCode
|
* @param string $basePath input for findShortestPathCode
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath)
|
protected function getStaticFile(string $suffix, string $targetDir, string $vendorPath, string $basePath)
|
||||||
{
|
{
|
||||||
$file = <<<HEADER
|
$file = <<<HEADER
|
||||||
<?php
|
<?php
|
||||||
|
@ -1185,7 +1185,7 @@ INITIALIZER;
|
||||||
* @param string $type one of: 'psr-0'|'psr-4'|'classmap'|'files'
|
* @param string $type one of: 'psr-0'|'psr-4'|'classmap'|'files'
|
||||||
* @return array<int, string>|array<string, array<string>>|array<string, string>
|
* @return array<int, string>|array<string, array<string>>|array<string, string>
|
||||||
*/
|
*/
|
||||||
protected function parseAutoloadsType(array $packageMap, $type, RootPackageInterface $rootPackage)
|
protected function parseAutoloadsType(array $packageMap, string $type, RootPackageInterface $rootPackage)
|
||||||
{
|
{
|
||||||
$autoloads = array();
|
$autoloads = array();
|
||||||
|
|
||||||
|
@ -1240,7 +1240,7 @@ INITIALIZER;
|
||||||
$path
|
$path
|
||||||
);
|
);
|
||||||
if (empty($installPath)) {
|
if (empty($installPath)) {
|
||||||
$installPath = strtr(getcwd(), '\\', '/');
|
$installPath = strtr(Platform::getCwd(), '\\', '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$resolvedPath = realpath($installPath . '/' . $updir);
|
$resolvedPath = realpath($installPath . '/' . $updir);
|
||||||
|
@ -1271,7 +1271,7 @@ INITIALIZER;
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getFileIdentifier(PackageInterface $package, $path)
|
protected function getFileIdentifier(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
return md5($package->getName() . ':' . $path);
|
return md5($package->getName() . ':' . $path);
|
||||||
}
|
}
|
||||||
|
@ -1369,7 +1369,7 @@ INITIALIZER;
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function composerRequire($fileIdentifier, $file)
|
function composerRequire(string $fileIdentifier, string $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
namespace Composer\Autoload;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
use Composer\Pcre\Preg;
|
use Composer\Pcre\Preg;
|
||||||
|
use Composer\Util\Platform;
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
|
@ -38,7 +39,7 @@ class ClassMapGenerator
|
||||||
* @param string $file The name of the class map file
|
* @param string $file The name of the class map file
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function dump($dirs, $file): void
|
public static function dump(iterable $dirs, string $file): void
|
||||||
{
|
{
|
||||||
$maps = array();
|
$maps = array();
|
||||||
|
|
||||||
|
@ -55,13 +56,13 @@ class ClassMapGenerator
|
||||||
* @param \Traversable<\SplFileInfo>|string|array<string> $path The path to search in or an iterator
|
* @param \Traversable<\SplFileInfo>|string|array<string> $path The path to search in or an iterator
|
||||||
* @param string $excluded Regex that matches file paths to be excluded from the classmap
|
* @param string $excluded Regex that matches file paths to be excluded from the classmap
|
||||||
* @param ?IOInterface $io IO object
|
* @param ?IOInterface $io IO object
|
||||||
* @param ?string $namespace Optional namespace prefix to filter by
|
* @param null|string $namespace Optional namespace prefix to filter by
|
||||||
* @param ?string $autoloadType psr-0|psr-4 Optional autoload standard to use mapping rules
|
* @param null|string $autoloadType psr-0|psr-4 Optional autoload standard to use mapping rules
|
||||||
* @param array<string, true> $scannedFiles
|
* @param array<string, true> $scannedFiles
|
||||||
* @return array<class-string, string> A class map array
|
* @return array<class-string, string> A class map array
|
||||||
* @throws \RuntimeException When the path is neither an existing file nor directory
|
* @throws \RuntimeException When the path is neither an existing file nor directory
|
||||||
*/
|
*/
|
||||||
public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array()): array
|
public static function createMap($path, string $excluded = null, IOInterface $io = null, ?string $namespace = null, ?string $autoloadType = null, array &$scannedFiles = array()): array
|
||||||
{
|
{
|
||||||
$basePath = $path;
|
$basePath = $path;
|
||||||
if (is_string($path)) {
|
if (is_string($path)) {
|
||||||
|
@ -81,7 +82,7 @@ class ClassMapGenerator
|
||||||
|
|
||||||
$map = array();
|
$map = array();
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$cwd = realpath(getcwd());
|
$cwd = realpath(Platform::getCwd());
|
||||||
|
|
||||||
foreach ($path as $file) {
|
foreach ($path as $file) {
|
||||||
$filePath = $file->getPathname();
|
$filePath = $file->getPathname();
|
||||||
|
@ -157,7 +158,7 @@ class ClassMapGenerator
|
||||||
* @param ?IOInterface $io IO object
|
* @param ?IOInterface $io IO object
|
||||||
* @return array<int, class-string> valid classes
|
* @return array<int, class-string> valid classes
|
||||||
*/
|
*/
|
||||||
private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io): array
|
private static function filterByNamespace(array $classes, string $filePath, string $baseNamespace, string $namespaceType, string $basePath, ?IOInterface $io): array
|
||||||
{
|
{
|
||||||
$validClasses = array();
|
$validClasses = array();
|
||||||
$rejectedClasses = array();
|
$rejectedClasses = array();
|
||||||
|
@ -198,7 +199,7 @@ class ClassMapGenerator
|
||||||
if (empty($validClasses)) {
|
if (empty($validClasses)) {
|
||||||
foreach ($rejectedClasses as $class) {
|
foreach ($rejectedClasses as $class) {
|
||||||
if ($io) {
|
if ($io) {
|
||||||
$io->writeError("<warning>Class $class located in ".Preg::replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
|
$io->writeError("<warning>Class $class located in ".Preg::replace('{^'.preg_quote(Platform::getCwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +216,7 @@ class ClassMapGenerator
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @return array<int, class-string> The found classes
|
* @return array<int, class-string> The found classes
|
||||||
*/
|
*/
|
||||||
private static function findClasses($path): array
|
private static function findClasses(string $path): array
|
||||||
{
|
{
|
||||||
$extraTypes = self::getExtraTypes();
|
$extraTypes = self::getExtraTypes();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class PhpFileCleaner
|
||||||
* @param string[] $types
|
* @param string[] $types
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function setTypeConfig($types): void
|
public static function setTypeConfig(array $types): void
|
||||||
{
|
{
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
self::$typeConfig[$type[0]] = array(
|
self::$typeConfig[$type[0]] = array(
|
||||||
|
@ -68,7 +68,7 @@ class PhpFileCleaner
|
||||||
* @param string $contents
|
* @param string $contents
|
||||||
* @param int $maxMatches
|
* @param int $maxMatches
|
||||||
*/
|
*/
|
||||||
public function __construct($contents, $maxMatches)
|
public function __construct(string $contents, int $maxMatches)
|
||||||
{
|
{
|
||||||
$this->contents = $contents;
|
$this->contents = $contents;
|
||||||
$this->len = \strlen($this->contents);
|
$this->len = \strlen($this->contents);
|
||||||
|
@ -168,7 +168,7 @@ class PhpFileCleaner
|
||||||
* @param string $delimiter
|
* @param string $delimiter
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function skipString($delimiter): void
|
private function skipString(string $delimiter): void
|
||||||
{
|
{
|
||||||
$this->index += 1;
|
$this->index += 1;
|
||||||
while ($this->index < $this->len) {
|
while ($this->index < $this->len) {
|
||||||
|
@ -217,7 +217,7 @@ class PhpFileCleaner
|
||||||
* @param string $delimiter
|
* @param string $delimiter
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function skipHeredoc($delimiter): void
|
private function skipHeredoc(string $delimiter): void
|
||||||
{
|
{
|
||||||
$firstDelimiterChar = $delimiter[0];
|
$firstDelimiterChar = $delimiter[0];
|
||||||
$delimiterLength = \strlen($delimiter);
|
$delimiterLength = \strlen($delimiter);
|
||||||
|
@ -260,14 +260,14 @@ class PhpFileCleaner
|
||||||
* @param string $char
|
* @param string $char
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function peek($char): bool
|
private function peek(string $char): bool
|
||||||
{
|
{
|
||||||
return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
|
return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param non-empty-string $regex
|
* @param non-empty-string $regex
|
||||||
* @param ?array<int, string> $match
|
* @param null|array<int, string> $match
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function match($regex, array &$match = null): bool
|
private function match($regex, array &$match = null): bool
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Cache
|
||||||
* @param Filesystem $filesystem optional filesystem instance
|
* @param Filesystem $filesystem optional filesystem instance
|
||||||
* @param bool $readOnly whether the cache is in readOnly mode
|
* @param bool $readOnly whether the cache is in readOnly mode
|
||||||
*/
|
*/
|
||||||
public function __construct(IOInterface $io, $cacheDir, $allowlist = 'a-z0-9.', Filesystem $filesystem = null, $readOnly = false)
|
public function __construct(IOInterface $io, string $cacheDir, string $allowlist = 'a-z0-9.', Filesystem $filesystem = null, bool $readOnly = false)
|
||||||
{
|
{
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->root = rtrim($cacheDir, '/\\') . '/';
|
$this->root = rtrim($cacheDir, '/\\') . '/';
|
||||||
|
@ -66,7 +66,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setReadOnly($readOnly)
|
public function setReadOnly(bool $readOnly)
|
||||||
{
|
{
|
||||||
$this->readOnly = (bool) $readOnly;
|
$this->readOnly = (bool) $readOnly;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isUsable($path)
|
public static function isUsable(string $path)
|
||||||
{
|
{
|
||||||
return !Preg::isMatch('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
|
return !Preg::isMatch('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function read($file)
|
public function read(string $file)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled()) {
|
if ($this->isEnabled()) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
@ -142,7 +142,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function write($file, $contents)
|
public function write(string $file, string $contents)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled() && !$this->readOnly) {
|
if ($this->isEnabled() && !$this->readOnly) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
@ -186,7 +186,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function copyFrom($file, $source)
|
public function copyFrom(string $file, string $source)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled() && !$this->readOnly) {
|
if ($this->isEnabled() && !$this->readOnly) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
@ -212,7 +212,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function copyTo($file, $target)
|
public function copyTo(string $file, string $target)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled()) {
|
if ($this->isEnabled()) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
@ -256,7 +256,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function remove($file)
|
public function remove(string $file)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled()) {
|
if ($this->isEnabled()) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
@ -287,7 +287,7 @@ class Cache
|
||||||
* @return int|false
|
* @return int|false
|
||||||
* @phpstan-return int<0, max>|false
|
* @phpstan-return int<0, max>|false
|
||||||
*/
|
*/
|
||||||
public function getAge($file)
|
public function getAge(string $file)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled()) {
|
if ($this->isEnabled()) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
@ -305,7 +305,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gc($ttl, $maxSize)
|
public function gc(int $ttl, int $maxSize)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled()) {
|
if ($this->isEnabled()) {
|
||||||
$expire = new \DateTime();
|
$expire = new \DateTime();
|
||||||
|
@ -340,7 +340,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function sha1($file)
|
public function sha1(string $file)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled()) {
|
if ($this->isEnabled()) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
@ -357,7 +357,7 @@ class Cache
|
||||||
*
|
*
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function sha256($file)
|
public function sha256(string $file)
|
||||||
{
|
{
|
||||||
if ($this->isEnabled()) {
|
if ($this->isEnabled()) {
|
||||||
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Composer\Plugin\CommandEvent;
|
||||||
use Composer\Plugin\PluginEvents;
|
use Composer\Plugin\PluginEvents;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
use Composer\Util\Loop;
|
use Composer\Util\Loop;
|
||||||
|
use Composer\Util\Platform;
|
||||||
use Composer\Util\ProcessExecutor;
|
use Composer\Util\ProcessExecutor;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
@ -136,7 +137,7 @@ EOT
|
||||||
$io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
|
$io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
|
||||||
$packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
|
$packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
|
||||||
$fs = new Filesystem;
|
$fs = new Filesystem;
|
||||||
$shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
|
$shortPath = $fs->findShortestPath(Platform::getCwd(), $packagePath, true);
|
||||||
|
|
||||||
$io->writeError('Created: ', false);
|
$io->writeError('Created: ', false);
|
||||||
$io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
|
$io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
|
||||||
|
@ -150,7 +151,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return (BasePackage&CompletePackageInterface)|false
|
* @return (BasePackage&CompletePackageInterface)|false
|
||||||
*/
|
*/
|
||||||
protected function selectPackage(IOInterface $io, $packageName, $version = null)
|
protected function selectPackage(IOInterface $io, string $packageName, ?string $version = null)
|
||||||
{
|
{
|
||||||
$io->writeError('<info>Searching for the specified package.</info>');
|
$io->writeError('<info>Searching for the specified package.</info>');
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ abstract class BaseCommand extends Command
|
||||||
* @return Composer|null
|
* @return Composer|null
|
||||||
* @deprecated since Composer 2.3.0 use requireComposer or tryComposer depending on whether you have $required set to true or false
|
* @deprecated since Composer 2.3.0 use requireComposer or tryComposer depending on whether you have $required set to true or false
|
||||||
*/
|
*/
|
||||||
public function getComposer($required = true, $disablePlugins = null, $disableScripts = null)
|
public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null)
|
||||||
{
|
{
|
||||||
if ($required) {
|
if ($required) {
|
||||||
return $this->requireComposer($disablePlugins, $disableScripts);
|
return $this->requireComposer($disablePlugins, $disableScripts);
|
||||||
|
@ -226,7 +226,7 @@ abstract class BaseCommand extends Command
|
||||||
*
|
*
|
||||||
* @return bool[] An array composed of the preferSource and preferDist values
|
* @return bool[] An array composed of the preferSource and preferDist values
|
||||||
*/
|
*/
|
||||||
protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
|
protected function getPreferredInstallOptions(Config $config, InputInterface $input, bool $keepVcsRequiresPreferSource = false)
|
||||||
{
|
{
|
||||||
$preferSource = false;
|
$preferSource = false;
|
||||||
$preferDist = false;
|
$preferDist = false;
|
||||||
|
|
|
@ -50,7 +50,7 @@ class BaseDependencyCommand extends BaseCommand
|
||||||
* @param bool $inverted Whether to invert matching process (why-not vs why behaviour)
|
* @param bool $inverted Whether to invert matching process (why-not vs why behaviour)
|
||||||
* @return int Exit code of the operation.
|
* @return int Exit code of the operation.
|
||||||
*/
|
*/
|
||||||
protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false): int
|
protected function doExecute(InputInterface $input, OutputInterface $output, bool $inverted = false): int
|
||||||
{
|
{
|
||||||
// Emit command event on startup
|
// Emit command event on startup
|
||||||
$composer = $this->requireComposer();
|
$composer = $this->requireComposer();
|
||||||
|
@ -197,7 +197,7 @@ class BaseDependencyCommand extends BaseCommand
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function printTree($results, $prefix = '', $level = 1): void
|
protected function printTree(array $results, string $prefix = '', int $level = 1): void
|
||||||
{
|
{
|
||||||
$count = count($results);
|
$count = count($results);
|
||||||
$idx = 0;
|
$idx = 0;
|
||||||
|
@ -223,7 +223,7 @@ class BaseDependencyCommand extends BaseCommand
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function writeTreeLine($line): void
|
private function writeTreeLine(string $line): void
|
||||||
{
|
{
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
if (!$io->isDecorated()) {
|
if (!$io->isDecorated()) {
|
||||||
|
|
|
@ -174,7 +174,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function printTable(OutputInterface $output, $results): void
|
protected function printTable(OutputInterface $output, array $results): void
|
||||||
{
|
{
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
|
|
|
@ -175,7 +175,7 @@ EOT
|
||||||
if (
|
if (
|
||||||
($configFile === 'composer.json' || $configFile === './composer.json')
|
($configFile === 'composer.json' || $configFile === './composer.json')
|
||||||
&& !file_exists($configFile)
|
&& !file_exists($configFile)
|
||||||
&& realpath(getcwd()) === realpath($this->config->get('home'))
|
&& realpath(Platform::getCwd()) === realpath($this->config->get('home'))
|
||||||
) {
|
) {
|
||||||
file_put_contents($configFile, "{\n}\n");
|
file_put_contents($configFile, "{\n}\n");
|
||||||
}
|
}
|
||||||
|
@ -810,7 +810,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function handleSingleValue($key, array $callbacks, array $values, $method): void
|
protected function handleSingleValue(string $key, array $callbacks, array $values, string $method): void
|
||||||
{
|
{
|
||||||
list($validator, $normalizer) = $callbacks;
|
list($validator, $normalizer) = $callbacks;
|
||||||
if (1 !== count($values)) {
|
if (1 !== count($values)) {
|
||||||
|
@ -845,7 +845,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function handleMultiValue($key, array $callbacks, array $values, $method): void
|
protected function handleMultiValue(string $key, array $callbacks, array $values, string $method): void
|
||||||
{
|
{
|
||||||
list($validator, $normalizer) = $callbacks;
|
list($validator, $normalizer) = $callbacks;
|
||||||
if (true !== $validation = $validator($values)) {
|
if (true !== $validation = $validator($values)) {
|
||||||
|
@ -868,7 +868,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null, $showSource = false): void
|
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, ?string $k = null, bool $showSource = false): void
|
||||||
{
|
{
|
||||||
$origK = $k;
|
$origK = $k;
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
|
|
|
@ -187,9 +187,9 @@ EOT
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName = null, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $noInstall = false, PlatformRequirementFilterInterface $platformRequirementFilter = null, $secureHttp = true, $addRepository = false): int
|
public function installProject(IOInterface $io, Config $config, InputInterface $input, ?string $packageName = null, ?string $directory = null, ?string $packageVersion = null, ?string $stability = 'stable', bool $preferSource = false, bool $preferDist = false, bool $installDevPackages = false, $repositories = null, bool $disablePlugins = false, bool $disableScripts = false, bool $noProgress = false, bool $noInstall = false, PlatformRequirementFilterInterface $platformRequirementFilter = null, bool $secureHttp = true, bool $addRepository = false): int
|
||||||
{
|
{
|
||||||
$oldCwd = getcwd();
|
$oldCwd = Platform::getCwd();
|
||||||
|
|
||||||
if ($repositories !== null && !is_array($repositories)) {
|
if ($repositories !== null && !is_array($repositories)) {
|
||||||
$repositories = (array) $repositories;
|
$repositories = (array) $repositories;
|
||||||
|
@ -284,7 +284,7 @@ EOT
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
|
$finder->depth(0)->directories()->in(Platform::getCwd())->ignoreVCS(false)->ignoreDotFiles(false);
|
||||||
foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
|
foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
|
||||||
$finder->name($vcsName);
|
$finder->name($vcsName);
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ EOT
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
protected function installRootPackage(IOInterface $io, Config $config, $packageName, PlatformRequirementFilterInterface $platformRequirementFilter, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, array $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $secureHttp = true): bool
|
protected function installRootPackage(IOInterface $io, Config $config, string $packageName, PlatformRequirementFilterInterface $platformRequirementFilter, ?string $directory = null, ?string $packageVersion = null, ?string $stability = 'stable', bool $preferSource = false, bool $preferDist = false, bool $installDevPackages = false, array $repositories = null, bool $disablePlugins = false, bool $disableScripts = false, bool $noProgress = false, bool $secureHttp = true): bool
|
||||||
{
|
{
|
||||||
if (!$secureHttp) {
|
if (!$secureHttp) {
|
||||||
$config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);
|
$config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);
|
||||||
|
@ -366,16 +366,16 @@ EOT
|
||||||
// if no directory was specified, use the 2nd part of the package name
|
// if no directory was specified, use the 2nd part of the package name
|
||||||
if (null === $directory) {
|
if (null === $directory) {
|
||||||
$parts = explode("/", $name, 2);
|
$parts = explode("/", $name, 2);
|
||||||
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
|
$directory = Platform::getCwd() . DIRECTORY_SEPARATOR . array_pop($parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
$process = new ProcessExecutor($io);
|
$process = new ProcessExecutor($io);
|
||||||
$fs = new Filesystem($process);
|
$fs = new Filesystem($process);
|
||||||
if (!$fs->isAbsolutePath($directory)) {
|
if (!$fs->isAbsolutePath($directory)) {
|
||||||
$directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
|
$directory = Platform::getCwd() . DIRECTORY_SEPARATOR . $directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
|
$io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(Platform::getCwd(), $directory, true) . '"</info>');
|
||||||
|
|
||||||
if (file_exists($directory)) {
|
if (file_exists($directory)) {
|
||||||
if (!is_dir($directory)) {
|
if (!is_dir($directory)) {
|
||||||
|
|
|
@ -245,7 +245,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return string|string[]|true
|
* @return string|string[]|true
|
||||||
*/
|
*/
|
||||||
private function checkHttp($proto, Config $config)
|
private function checkHttp(string $proto, Config $config)
|
||||||
{
|
{
|
||||||
$result = $this->checkConnectivity();
|
$result = $this->checkConnectivity();
|
||||||
if ($result !== true) {
|
if ($result !== true) {
|
||||||
|
@ -315,7 +315,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return string|true|\Exception
|
* @return string|true|\Exception
|
||||||
*/
|
*/
|
||||||
private function checkGithubOauth($domain, $token)
|
private function checkGithubOauth(string $domain, string $token)
|
||||||
{
|
{
|
||||||
$result = $this->checkConnectivity();
|
$result = $this->checkConnectivity();
|
||||||
if ($result !== true) {
|
if ($result !== true) {
|
||||||
|
@ -346,7 +346,7 @@ EOT
|
||||||
* @throws TransportException
|
* @throws TransportException
|
||||||
* @return mixed|string
|
* @return mixed|string
|
||||||
*/
|
*/
|
||||||
private function getGithubRateLimit($domain, $token = null)
|
private function getGithubRateLimit(string $domain, string $token = null)
|
||||||
{
|
{
|
||||||
$result = $this->checkConnectivity();
|
$result = $this->checkConnectivity();
|
||||||
if ($result !== true) {
|
if ($result !== true) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ EOT
|
||||||
// If the CWD was modified, we restore it to what it was initially, as it was
|
// If the CWD was modified, we restore it to what it was initially, as it was
|
||||||
// most likely modified by the global command, and we want exec to run in the local working directory
|
// most likely modified by the global command, and we want exec to run in the local working directory
|
||||||
// not the global one
|
// not the global one
|
||||||
if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {
|
if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory() && $this->getApplication()->getInitialWorkingDirectory() !== false) {
|
||||||
try {
|
try {
|
||||||
chdir($this->getApplication()->getInitialWorkingDirectory());
|
chdir($this->getApplication()->getInitialWorkingDirectory());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ EOT
|
||||||
* @param bool $showOnly
|
* @param bool $showOnly
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly): bool
|
private function handlePackage(CompletePackageInterface $package, bool $showHomepage, bool $showOnly): bool
|
||||||
{
|
{
|
||||||
$support = $package->getSupport();
|
$support = $package->getSupport();
|
||||||
$url = $support['source'] ?? $package->getSourceUrl();
|
$url = $support['source'] ?? $package->getSourceUrl();
|
||||||
|
@ -128,7 +128,7 @@ EOT
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function openBrowser($url): void
|
private function openBrowser(string $url): void
|
||||||
{
|
{
|
||||||
$url = ProcessExecutor::escape($url);
|
$url = ProcessExecutor::escape($url);
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ EOT
|
||||||
* @param string $author
|
* @param string $author
|
||||||
* @return array{name: string, email: string|null}
|
* @return array{name: string, email: string|null}
|
||||||
*/
|
*/
|
||||||
public function parseAuthorString($author)
|
public function parseAuthorString(string $author)
|
||||||
{
|
{
|
||||||
if (Preg::isMatch('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+)(?:\s+<(?P<email>.+?)>)?$/u', $author, $match)) {
|
if (Preg::isMatch('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+)(?:\s+<(?P<email>.+?)>)?$/u', $author, $match)) {
|
||||||
$hasEmail = isset($match['email']) && '' !== $match['email'];
|
$hasEmail = isset($match['email']) && '' !== $match['email'];
|
||||||
|
@ -485,7 +485,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return array<int, array{name: string, email?: string}>
|
* @return array<int, array{name: string, email?: string}>
|
||||||
*/
|
*/
|
||||||
protected function formatAuthors($author)
|
protected function formatAuthors(string $author)
|
||||||
{
|
{
|
||||||
$author = $this->parseAuthorString($author);
|
$author = $this->parseAuthorString($author);
|
||||||
if (null === $author['email']) {
|
if (null === $author['email']) {
|
||||||
|
@ -504,7 +504,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function namespaceFromPackageName($packageName)
|
public function namespaceFromPackageName(string $packageName)
|
||||||
{
|
{
|
||||||
if (!$packageName || strpos($packageName, '/') === false) {
|
if (!$packageName || strpos($packageName, '/') === false) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -567,7 +567,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
|
protected function hasVendorIgnore(string $ignoreFile, string $vendor = 'vendor')
|
||||||
{
|
{
|
||||||
if (!file_exists($ignoreFile)) {
|
if (!file_exists($ignoreFile)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -591,7 +591,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
|
protected function addVendorIgnore(string $ignoreFile, string $vendor = '/vendor/')
|
||||||
{
|
{
|
||||||
$contents = "";
|
$contents = "";
|
||||||
if (file_exists($ignoreFile)) {
|
if (file_exists($ignoreFile)) {
|
||||||
|
@ -610,7 +610,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isValidEmail($email)
|
protected function isValidEmail(string $email)
|
||||||
{
|
{
|
||||||
// assume it's valid if we can't validate it
|
// assume it's valid if we can't validate it
|
||||||
if (!function_exists('filter_var')) {
|
if (!function_exists('filter_var')) {
|
||||||
|
@ -652,7 +652,7 @@ EOT
|
||||||
* @param array<string, string|array<string>> $options
|
* @param array<string, string|array<string>> $options
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function hasDependencies($options): bool
|
private function hasDependencies(array $options): bool
|
||||||
{
|
{
|
||||||
$requires = (array) $options['require'];
|
$requires = (array) $options['require'];
|
||||||
$devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
|
$devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
|
||||||
|
|
|
@ -163,7 +163,7 @@ EOT
|
||||||
* @param array<string, PackageInterface> $bucket
|
* @param array<string, PackageInterface> $bucket
|
||||||
* @return array<string, PackageInterface>
|
* @return array<string, PackageInterface>
|
||||||
*/
|
*/
|
||||||
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array()): array
|
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, array $bucket = array()): array
|
||||||
{
|
{
|
||||||
$requires = array_keys($package->getRequires());
|
$requires = array_keys($package->getRequires());
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ EOT
|
||||||
* @param string $requireKey
|
* @param string $requireKey
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function getInconsistentRequireKeys(array $newRequirements, $requireKey): array
|
private function getInconsistentRequireKeys(array $newRequirements, string $requireKey): array
|
||||||
{
|
{
|
||||||
$requireKeys = $this->getPackagesByRequireKey();
|
$requireKeys = $this->getPackagesByRequireKey();
|
||||||
$inconsistentRequirements = array();
|
$inconsistentRequirements = array();
|
||||||
|
@ -351,7 +351,7 @@ EOT
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey): int
|
private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, string $requireKey, string $removeKey): int
|
||||||
{
|
{
|
||||||
// Update packages
|
// Update packages
|
||||||
$this->resetComposer();
|
$this->resetComposer();
|
||||||
|
@ -449,7 +449,7 @@ EOT
|
||||||
* @param bool $sortPackages
|
* @param bool $sortPackages
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function updateFileCleanly(JsonFile $json, array $new, $requireKey, $removeKey, $sortPackages): bool
|
private function updateFileCleanly(JsonFile $json, array $new, string $requireKey, string $removeKey, bool $sortPackages): bool
|
||||||
{
|
{
|
||||||
$contents = file_get_contents($json->getPath());
|
$contents = file_get_contents($json->getPath());
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ EOT
|
||||||
* @param bool $hardExit
|
* @param bool $hardExit
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function revertComposerFile($hardExit = true)
|
public function revertComposerFile(bool $hardExit = true)
|
||||||
{
|
{
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
|
|
||||||
|
|
|
@ -27,14 +27,10 @@ class ScriptAliasCommand extends BaseCommand
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $description;
|
private $description;
|
||||||
|
|
||||||
/**
|
public function __construct(string $script, ?string $description)
|
||||||
* @param string $script
|
|
||||||
* @param string $description
|
|
||||||
*/
|
|
||||||
public function __construct($script, $description)
|
|
||||||
{
|
{
|
||||||
$this->script = $script;
|
$this->script = $script;
|
||||||
$this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
|
$this->description = $description ?? 'Runs the '.$script.' script as defined in composer.json.';
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,7 +397,7 @@ TAGSPUBKEY
|
||||||
* @return int
|
* @return int
|
||||||
* @throws FilesystemException
|
* @throws FilesystemException
|
||||||
*/
|
*/
|
||||||
protected function rollback(OutputInterface $output, $rollbackDir, $localFilename): int
|
protected function rollback(OutputInterface $output, string $rollbackDir, string $localFilename): int
|
||||||
{
|
{
|
||||||
$rollbackVersion = $this->getLastBackupVersion($rollbackDir);
|
$rollbackVersion = $this->getLastBackupVersion($rollbackDir);
|
||||||
if (!$rollbackVersion) {
|
if (!$rollbackVersion) {
|
||||||
|
@ -431,7 +431,7 @@ TAGSPUBKEY
|
||||||
* @throws FilesystemException If the file cannot be moved
|
* @throws FilesystemException If the file cannot be moved
|
||||||
* @return bool Whether the phar is valid and has been moved
|
* @return bool Whether the phar is valid and has been moved
|
||||||
*/
|
*/
|
||||||
protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null): bool
|
protected function setLocalPhar(string $localFilename, string $newFilename, string $backupTarget = null): bool
|
||||||
{
|
{
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
@chmod($newFilename, fileperms($localFilename));
|
@chmod($newFilename, fileperms($localFilename));
|
||||||
|
@ -483,7 +483,7 @@ TAGSPUBKEY
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function cleanBackups($rollbackDir, $except = null): void
|
protected function cleanBackups(string $rollbackDir, ?string $except = null): void
|
||||||
{
|
{
|
||||||
$finder = $this->getOldInstallationFinder($rollbackDir);
|
$finder = $this->getOldInstallationFinder($rollbackDir);
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
|
@ -503,7 +503,7 @@ TAGSPUBKEY
|
||||||
* @param string $rollbackDir
|
* @param string $rollbackDir
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
protected function getLastBackupVersion($rollbackDir)
|
protected function getLastBackupVersion(string $rollbackDir)
|
||||||
{
|
{
|
||||||
$finder = $this->getOldInstallationFinder($rollbackDir);
|
$finder = $this->getOldInstallationFinder($rollbackDir);
|
||||||
$finder->sortByName();
|
$finder->sortByName();
|
||||||
|
@ -520,7 +520,7 @@ TAGSPUBKEY
|
||||||
* @param string $rollbackDir
|
* @param string $rollbackDir
|
||||||
* @return Finder
|
* @return Finder
|
||||||
*/
|
*/
|
||||||
protected function getOldInstallationFinder($rollbackDir): Finder
|
protected function getOldInstallationFinder(string $rollbackDir): Finder
|
||||||
{
|
{
|
||||||
return Finder::create()
|
return Finder::create()
|
||||||
->depth(0)
|
->depth(0)
|
||||||
|
@ -541,7 +541,7 @@ TAGSPUBKEY
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @return bool If the operation succeeded
|
* @return bool If the operation succeeded
|
||||||
*/
|
*/
|
||||||
protected function validatePhar($pharFile, &$error): bool
|
protected function validatePhar(string $pharFile, ?string &$error): bool
|
||||||
{
|
{
|
||||||
if (ini_get('phar.readonly')) {
|
if (ini_get('phar.readonly')) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -590,7 +590,7 @@ TAGSPUBKEY
|
||||||
* @param string $newFilename The downloaded or backup phar
|
* @param string $newFilename The downloaded or backup phar
|
||||||
* @return bool Whether composer.phar has been updated
|
* @return bool Whether composer.phar has been updated
|
||||||
*/
|
*/
|
||||||
protected function tryAsWindowsAdmin($localFilename, $newFilename): bool
|
protected function tryAsWindowsAdmin(string $localFilename, string $newFilename): bool
|
||||||
{
|
{
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ EOT
|
||||||
|
|
||||||
if ($input->getOption('no-dev')) {
|
if ($input->getOption('no-dev')) {
|
||||||
$packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
|
$packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
|
||||||
$repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg): \Composer\Package\PackageInterface {
|
$repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg): PackageInterface {
|
||||||
return clone $pkg;
|
return clone $pkg;
|
||||||
}, $packages))));
|
}, $packages))));
|
||||||
}
|
}
|
||||||
|
@ -628,7 +628,7 @@ EOT
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return array{CompletePackageInterface|null, array<string, string>}
|
* @return array{CompletePackageInterface|null, array<string, string>}
|
||||||
*/
|
*/
|
||||||
protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
|
protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, string $name, $version = null)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
$constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
|
$constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
|
||||||
|
@ -802,7 +802,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
|
protected function printLinks(CompletePackageInterface $package, string $linkType, string $title = null)
|
||||||
{
|
{
|
||||||
$title = $title ?: $linkType;
|
$title = $title ?: $linkType;
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
|
@ -923,7 +923,7 @@ EOT
|
||||||
* @param array<string, string> $versions
|
* @param array<string, string> $versions
|
||||||
* @return array<string, string|string[]|null>
|
* @return array<string, string|string[]|null>
|
||||||
*/
|
*/
|
||||||
private function appendVersions($json, array $versions): array
|
private function appendVersions(array $json, array $versions): array
|
||||||
{
|
{
|
||||||
uasort($versions, 'version_compare');
|
uasort($versions, 'version_compare');
|
||||||
$versions = array_keys(array_reverse($versions));
|
$versions = array_keys(array_reverse($versions));
|
||||||
|
@ -936,7 +936,7 @@ EOT
|
||||||
* @param array<string, string|string[]|null> $json
|
* @param array<string, string|string[]|null> $json
|
||||||
* @return array<string, string|string[]|null>
|
* @return array<string, string|string[]|null>
|
||||||
*/
|
*/
|
||||||
private function appendLicenses($json, CompletePackageInterface $package): array
|
private function appendLicenses(array $json, CompletePackageInterface $package): array
|
||||||
{
|
{
|
||||||
if ($licenses = $package->getLicense()) {
|
if ($licenses = $package->getLicense()) {
|
||||||
$spdxLicenses = new SpdxLicenses();
|
$spdxLicenses = new SpdxLicenses();
|
||||||
|
@ -963,7 +963,7 @@ EOT
|
||||||
* @param array<string, string|string[]|null> $json
|
* @param array<string, string|string[]|null> $json
|
||||||
* @return array<string, string|string[]|null>
|
* @return array<string, string|string[]|null>
|
||||||
*/
|
*/
|
||||||
private function appendAutoload($json, CompletePackageInterface $package): array
|
private function appendAutoload(array $json, CompletePackageInterface $package): array
|
||||||
{
|
{
|
||||||
if ($package->getAutoload()) {
|
if ($package->getAutoload()) {
|
||||||
$autoload = array();
|
$autoload = array();
|
||||||
|
@ -996,7 +996,7 @@ EOT
|
||||||
* @param array<string, string|string[]|null> $json
|
* @param array<string, string|string[]|null> $json
|
||||||
* @return array<string, string|string[]|null>
|
* @return array<string, string|string[]|null>
|
||||||
*/
|
*/
|
||||||
private function appendLinks($json, CompletePackageInterface $package): array
|
private function appendLinks(array $json, CompletePackageInterface $package): array
|
||||||
{
|
{
|
||||||
foreach (Link::$TYPES as $linkType) {
|
foreach (Link::$TYPES as $linkType) {
|
||||||
$json = $this->appendLink($json, $package, $linkType);
|
$json = $this->appendLink($json, $package, $linkType);
|
||||||
|
@ -1010,7 +1010,7 @@ EOT
|
||||||
* @param string $linkType
|
* @param string $linkType
|
||||||
* @return array<string, string|string[]|null>
|
* @return array<string, string|string[]|null>
|
||||||
*/
|
*/
|
||||||
private function appendLink($json, CompletePackageInterface $package, $linkType): array
|
private function appendLink(array $json, CompletePackageInterface $package, string $linkType): array
|
||||||
{
|
{
|
||||||
$links = $package->{'get' . ucfirst($linkType)}();
|
$links = $package->{'get' . ucfirst($linkType)}();
|
||||||
|
|
||||||
|
@ -1147,8 +1147,8 @@ EOT
|
||||||
protected function displayTree(
|
protected function displayTree(
|
||||||
$package,
|
$package,
|
||||||
array $packagesInTree,
|
array $packagesInTree,
|
||||||
$previousTreeBar = '├',
|
string $previousTreeBar = '├',
|
||||||
$level = 1
|
int $level = 1
|
||||||
) {
|
) {
|
||||||
$previousTreeBar = str_replace('├', '│', $previousTreeBar);
|
$previousTreeBar = str_replace('├', '│', $previousTreeBar);
|
||||||
if (is_array($package) && isset($package['requires'])) {
|
if (is_array($package) && isset($package['requires'])) {
|
||||||
|
@ -1197,7 +1197,7 @@ EOT
|
||||||
* @return array<int, array<string, array<int, array<string, string>>|string>>
|
* @return array<int, array<string, array<int, array<string, string>>|string>>
|
||||||
*/
|
*/
|
||||||
protected function addTree(
|
protected function addTree(
|
||||||
$name,
|
string $name,
|
||||||
Link $link,
|
Link $link,
|
||||||
InstalledRepository $installedRepo,
|
InstalledRepository $installedRepo,
|
||||||
RepositoryInterface $remoteRepos,
|
RepositoryInterface $remoteRepos,
|
||||||
|
@ -1240,7 +1240,7 @@ EOT
|
||||||
* @param string $updateStatus
|
* @param string $updateStatus
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function updateStatusToVersionStyle($updateStatus): string
|
private function updateStatusToVersionStyle(string $updateStatus): string
|
||||||
{
|
{
|
||||||
// 'up-to-date' is printed green
|
// 'up-to-date' is printed green
|
||||||
// 'semver-safe-update' is printed red
|
// 'semver-safe-update' is printed red
|
||||||
|
@ -1275,7 +1275,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function writeTreeLine($line): void
|
private function writeTreeLine(string $line): void
|
||||||
{
|
{
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
if (!$io->isDecorated()) {
|
if (!$io->isDecorated()) {
|
||||||
|
@ -1342,7 +1342,7 @@ EOT
|
||||||
* @param array<PackageInterface> $bucket
|
* @param array<PackageInterface> $bucket
|
||||||
* @return array<PackageInterface>
|
* @return array<PackageInterface>
|
||||||
*/
|
*/
|
||||||
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array()): array
|
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, array $bucket = array()): array
|
||||||
{
|
{
|
||||||
$requires = $package->getRequires();
|
$requires = $package->getRequires();
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ EOT
|
||||||
* @param string $constraint
|
* @param string $constraint
|
||||||
* @return Link
|
* @return Link
|
||||||
*/
|
*/
|
||||||
private function appendConstraintToLink(Link $link, $constraint): Link
|
private function appendConstraintToLink(Link $link, string $constraint): Link
|
||||||
{
|
{
|
||||||
$parser = new VersionParser;
|
$parser = new VersionParser;
|
||||||
$oldPrettyString = $link->getConstraint()->getPrettyString();
|
$oldPrettyString = $link->getConstraint()->getPrettyString();
|
||||||
|
|
|
@ -169,7 +169,7 @@ EOT
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function outputResult(IOInterface $io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false): void
|
private function outputResult(IOInterface $io, string $name, array &$errors, array &$warnings, bool $checkPublish = false, array $publishErrors = array(), bool $checkLock = false, array $lockErrors = array(), bool $printSchemaUrl = false): void
|
||||||
{
|
{
|
||||||
$doPrintSchemaUrl = false;
|
$doPrintSchemaUrl = false;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Compiler
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function compile($pharFile = 'composer.phar'): void
|
public function compile(string $pharFile = 'composer.phar'): void
|
||||||
{
|
{
|
||||||
if (file_exists($pharFile)) {
|
if (file_exists($pharFile)) {
|
||||||
unlink($pharFile);
|
unlink($pharFile);
|
||||||
|
@ -201,7 +201,7 @@ class Compiler
|
||||||
* @param \SplFileInfo $file
|
* @param \SplFileInfo $file
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getRelativeFilePath($file): string
|
private function getRelativeFilePath(\SplFileInfo $file): string
|
||||||
{
|
{
|
||||||
$realPath = $file->getRealPath();
|
$realPath = $file->getRealPath();
|
||||||
$pathPrefix = dirname(__DIR__, 2).DIRECTORY_SEPARATOR;
|
$pathPrefix = dirname(__DIR__, 2).DIRECTORY_SEPARATOR;
|
||||||
|
@ -217,7 +217,7 @@ class Compiler
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function addFile(\Phar $phar, \SplFileInfo $file, $strip = true): void
|
private function addFile(\Phar $phar, \SplFileInfo $file, bool $strip = true): void
|
||||||
{
|
{
|
||||||
$path = $this->getRelativeFilePath($file);
|
$path = $this->getRelativeFilePath($file);
|
||||||
$content = file_get_contents($file);
|
$content = file_get_contents($file);
|
||||||
|
@ -258,7 +258,7 @@ class Compiler
|
||||||
* @param string $source A PHP string
|
* @param string $source A PHP string
|
||||||
* @return string The PHP string with the whitespace removed
|
* @return string The PHP string with the whitespace removed
|
||||||
*/
|
*/
|
||||||
private function stripWhitespace($source): string
|
private function stripWhitespace(string $source): string
|
||||||
{
|
{
|
||||||
if (!function_exists('token_get_all')) {
|
if (!function_exists('token_get_all')) {
|
||||||
return $source;
|
return $source;
|
||||||
|
|
|
@ -112,9 +112,9 @@ class Config
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $useEnvironment Use COMPOSER_ environment variables to replace config settings
|
* @param bool $useEnvironment Use COMPOSER_ environment variables to replace config settings
|
||||||
* @param string $baseDir Optional base directory of the config
|
* @param ?string $baseDir Optional base directory of the config
|
||||||
*/
|
*/
|
||||||
public function __construct($useEnvironment = true, $baseDir = null)
|
public function __construct(bool $useEnvironment = true, ?string $baseDir = null)
|
||||||
{
|
{
|
||||||
// load defaults
|
// load defaults
|
||||||
$this->config = static::$defaultConfig;
|
$this->config = static::$defaultConfig;
|
||||||
|
@ -126,7 +126,7 @@ class Config
|
||||||
|
|
||||||
$this->repositories = static::$defaultRepositories;
|
$this->repositories = static::$defaultRepositories;
|
||||||
$this->useEnvironment = (bool) $useEnvironment;
|
$this->useEnvironment = (bool) $useEnvironment;
|
||||||
$this->baseDir = $baseDir;
|
$this->baseDir = is_string($baseDir) && '' !== $baseDir ? $baseDir : null;
|
||||||
|
|
||||||
foreach ($this->config as $configKey => $configValue) {
|
foreach ($this->config as $configKey => $configValue) {
|
||||||
$this->setSourceOfConfigValue($configValue, $configKey, self::SOURCE_DEFAULT);
|
$this->setSourceOfConfigValue($configValue, $configKey, self::SOURCE_DEFAULT);
|
||||||
|
@ -177,7 +177,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function merge($config, $source = self::SOURCE_UNKNOWN): void
|
public function merge(array $config, string $source = self::SOURCE_UNKNOWN): void
|
||||||
{
|
{
|
||||||
// override defaults with given config
|
// override defaults with given config
|
||||||
if (!empty($config['config']) && is_array($config['config'])) {
|
if (!empty($config['config']) && is_array($config['config'])) {
|
||||||
|
@ -277,7 +277,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($key, $flags = 0)
|
public function get(string $key, int $flags = 0)
|
||||||
{
|
{
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
// strings/paths with env var and {$refs} support
|
// strings/paths with env var and {$refs} support
|
||||||
|
@ -441,7 +441,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return array<string, mixed[]>
|
* @return array<string, mixed[]>
|
||||||
*/
|
*/
|
||||||
public function all($flags = 0): array
|
public function all(int $flags = 0): array
|
||||||
{
|
{
|
||||||
$all = array(
|
$all = array(
|
||||||
'repositories' => $this->getRepositories(),
|
'repositories' => $this->getRepositories(),
|
||||||
|
@ -457,7 +457,7 @@ class Config
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSourceOfValue($key): string
|
public function getSourceOfValue(string $key): string
|
||||||
{
|
{
|
||||||
$this->get($key);
|
$this->get($key);
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function setSourceOfConfigValue($configValue, $path, $source): void
|
private function setSourceOfConfigValue($configValue, string $path, string $source): void
|
||||||
{
|
{
|
||||||
$this->sourceOfConfigValue[$path] = $source;
|
$this->sourceOfConfigValue[$path] = $source;
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ class Config
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function has($key): bool
|
public function has(string $key): bool
|
||||||
{
|
{
|
||||||
return array_key_exists($key, $this->config);
|
return array_key_exists($key, $this->config);
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return string|int|null
|
* @return string|int|null
|
||||||
*/
|
*/
|
||||||
private function process($value, $flags)
|
private function process($value, int $flags)
|
||||||
{
|
{
|
||||||
if (!is_string($value)) {
|
if (!is_string($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -531,9 +531,9 @@ class Config
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function realpath($path): string
|
private function realpath(string $path): string
|
||||||
{
|
{
|
||||||
if (Preg::isMatch('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
|
if (Preg::isMatch('{^(?:/|[a-z]:|[a-z0-9.]+://|\\\\\\\\)}i', $path)) {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ class Config
|
||||||
* @param string $var
|
* @param string $var
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
private function getComposerEnv($var)
|
private function getComposerEnv(string $var)
|
||||||
{
|
{
|
||||||
if ($this->useEnvironment) {
|
if ($this->useEnvironment) {
|
||||||
return Platform::getEnv($var);
|
return Platform::getEnv($var);
|
||||||
|
@ -563,7 +563,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function disableRepoByName($name): void
|
private function disableRepoByName(string $name): void
|
||||||
{
|
{
|
||||||
if (isset($this->repositories[$name])) {
|
if (isset($this->repositories[$name])) {
|
||||||
unset($this->repositories[$name]);
|
unset($this->repositories[$name]);
|
||||||
|
@ -580,7 +580,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function prohibitUrlByConfig($url, IOInterface $io = null): void
|
public function prohibitUrlByConfig(string $url, IOInterface $io = null): void
|
||||||
{
|
{
|
||||||
// Return right away if the URL is malformed or custom (see issue #5173)
|
// Return right away if the URL is malformed or custom (see issue #5173)
|
||||||
if (false === filter_var($url, FILTER_VALIDATE_URL)) {
|
if (false === filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addRepository($name, $config, $append = true);
|
public function addRepository(string $name, $config, bool $append = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a repository
|
* Remove a repository
|
||||||
|
@ -38,7 +38,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeRepository($name);
|
public function removeRepository(string $name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a config setting
|
* Add a config setting
|
||||||
|
@ -48,7 +48,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addConfigSetting($name, $value);
|
public function addConfigSetting(string $name, $value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a config setting
|
* Remove a config setting
|
||||||
|
@ -57,7 +57,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeConfigSetting($name);
|
public function removeConfigSetting(string $name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a property
|
* Add a property
|
||||||
|
@ -67,7 +67,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addProperty($name, $value);
|
public function addProperty(string $name, $value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a property
|
* Remove a property
|
||||||
|
@ -76,7 +76,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeProperty($name);
|
public function removeProperty(string $name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a package link
|
* Add a package link
|
||||||
|
@ -87,7 +87,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addLink($type, $name, $value);
|
public function addLink(string $type, string $name, string $value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a package link
|
* Remove a package link
|
||||||
|
@ -97,7 +97,7 @@ interface ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeLink($type, $name);
|
public function removeLink(string $type, string $name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives a user-friendly name to this source (file path or so)
|
* Gives a user-friendly name to this source (file path or so)
|
||||||
|
|
|
@ -43,7 +43,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
||||||
* @param JsonFile $file
|
* @param JsonFile $file
|
||||||
* @param bool $authConfig
|
* @param bool $authConfig
|
||||||
*/
|
*/
|
||||||
public function __construct(JsonFile $file, $authConfig = false)
|
public function __construct(JsonFile $file, bool $authConfig = false)
|
||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
$this->authConfig = $authConfig;
|
$this->authConfig = $authConfig;
|
||||||
|
@ -214,7 +214,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function manipulateJson($method, $fallback, ...$args): void
|
private function manipulateJson(string $method, callable $fallback, ...$args): void
|
||||||
{
|
{
|
||||||
if ($this->file->exists()) {
|
if ($this->file->exists()) {
|
||||||
if (!is_writable($this->file->getPath())) {
|
if (!is_writable($this->file->getPath())) {
|
||||||
|
@ -297,7 +297,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function arrayUnshiftRef(&$array, &$value): int
|
private function arrayUnshiftRef(array &$array, &$value): int
|
||||||
{
|
{
|
||||||
$return = array_unshift($array, '');
|
$return = array_unshift($array, '');
|
||||||
$array[0] = &$value;
|
$array[0] = &$value;
|
||||||
|
|
|
@ -74,7 +74,7 @@ class Application extends BaseApplication
|
||||||
private $disableScriptsByDefault = false;
|
private $disableScriptsByDefault = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Store the initial working directory at startup time
|
* @var string|false Store the initial working directory at startup time
|
||||||
*/
|
*/
|
||||||
private $initialWorkingDirectory;
|
private $initialWorkingDirectory;
|
||||||
|
|
||||||
|
@ -151,10 +151,11 @@ class Application extends BaseApplication
|
||||||
|
|
||||||
// switch working dir
|
// switch working dir
|
||||||
if ($newWorkDir = $this->getNewWorkingDir($input)) {
|
if ($newWorkDir = $this->getNewWorkingDir($input)) {
|
||||||
$oldWorkingDir = getcwd();
|
$oldWorkingDir = Platform::getCwd(true);
|
||||||
chdir($newWorkDir);
|
chdir($newWorkDir);
|
||||||
$this->initialWorkingDirectory = $newWorkDir;
|
$this->initialWorkingDirectory = $newWorkDir;
|
||||||
$io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
|
$cwd = Platform::getCwd(true);
|
||||||
|
$io->writeError('Changed CWD to ' . ($cwd !== '' ? $cwd : $newWorkDir), true, IOInterface::DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine command name to be executed without including plugin commands
|
// determine command name to be executed without including plugin commands
|
||||||
|
@ -171,7 +172,7 @@ class Application extends BaseApplication
|
||||||
|
|
||||||
// prompt user for dir change if no composer.json is present in current dir
|
// prompt user for dir change if no composer.json is present in current dir
|
||||||
if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile()) && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false) {
|
if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile()) && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false) {
|
||||||
$dir = dirname(getcwd());
|
$dir = dirname(Platform::getCwd(true));
|
||||||
$home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/');
|
$home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/');
|
||||||
|
|
||||||
// abort when we reach the home dir or top of the filesystem
|
// abort when we reach the home dir or top of the filesystem
|
||||||
|
@ -183,7 +184,7 @@ class Application extends BaseApplication
|
||||||
} else {
|
} else {
|
||||||
$io->writeError('<info>Always want to use the parent dir? Use "composer config --global use-parent-dir true" to change the default.</info>');
|
$io->writeError('<info>Always want to use the parent dir? Use "composer config --global use-parent-dir true" to change the default.</info>');
|
||||||
}
|
}
|
||||||
$oldWorkingDir = getcwd();
|
$oldWorkingDir = Platform::getCwd(true);
|
||||||
chdir($dir);
|
chdir($dir);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -330,7 +331,7 @@ class Application extends BaseApplication
|
||||||
$result = parent::doRun($input, $output);
|
$result = parent::doRun($input, $output);
|
||||||
|
|
||||||
// chdir back to $oldWorkingDir if set
|
// chdir back to $oldWorkingDir if set
|
||||||
if (isset($oldWorkingDir)) {
|
if (isset($oldWorkingDir) && '' !== $oldWorkingDir) {
|
||||||
Silencer::call('chdir', $oldWorkingDir);
|
Silencer::call('chdir', $oldWorkingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +425,7 @@ class Application extends BaseApplication
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return ?\Composer\Composer If $required is true then the return value is guaranteed
|
* @return ?\Composer\Composer If $required is true then the return value is guaranteed
|
||||||
*/
|
*/
|
||||||
public function getComposer($required = true, $disablePlugins = null, $disableScripts = null)
|
public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null)
|
||||||
{
|
{
|
||||||
if (null === $disablePlugins) {
|
if (null === $disablePlugins) {
|
||||||
$disablePlugins = $this->disablePluginsByDefault;
|
$disablePlugins = $this->disablePluginsByDefault;
|
||||||
|
@ -585,7 +586,7 @@ class Application extends BaseApplication
|
||||||
/**
|
/**
|
||||||
* Get the working directory at startup time
|
* Get the working directory at startup time
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function getInitialWorkingDirectory()
|
public function getInitialWorkingDirectory()
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class GithubActionError
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function emit($message, $file = null, $line = null): void
|
public function emit(string $message, ?string $file = null, ?int $line = null): void
|
||||||
{
|
{
|
||||||
if (Platform::getEnv('GITHUB_ACTIONS') && !Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
|
if (Platform::getEnv('GITHUB_ACTIONS') && !Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
|
||||||
$message = $this->escapeData($message);
|
$message = $this->escapeData($message);
|
||||||
|
@ -55,7 +55,7 @@ final class GithubActionError
|
||||||
* @param string $data
|
* @param string $data
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function escapeData($data): string
|
private function escapeData(string $data): string
|
||||||
{
|
{
|
||||||
// see https://github.com/actions/toolkit/blob/4f7fb6513a355689f69f0849edeb369a4dc81729/packages/core/src/command.ts#L80-L85
|
// see https://github.com/actions/toolkit/blob/4f7fb6513a355689f69f0849edeb369a4dc81729/packages/core/src/command.ts#L80-L85
|
||||||
$data = str_replace("%", '%25', $data);
|
$data = str_replace("%", '%25', $data);
|
||||||
|
@ -69,7 +69,7 @@ final class GithubActionError
|
||||||
* @param string $property
|
* @param string $property
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function escapeProperty($property): string
|
private function escapeProperty(string $property): string
|
||||||
{
|
{
|
||||||
// see https://github.com/actions/toolkit/blob/4f7fb6513a355689f69f0849edeb369a4dc81729/packages/core/src/command.ts#L87-L94
|
// see https://github.com/actions/toolkit/blob/4f7fb6513a355689f69f0849edeb369a4dc81729/packages/core/src/command.ts#L87-L94
|
||||||
$property = str_replace("%", '%25', $property);
|
$property = str_replace("%", '%25', $property);
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function decide($literal, $level, Rule $why): void
|
public function decide(int $literal, int $level, Rule $why): void
|
||||||
{
|
{
|
||||||
$this->addDecision($literal, $level);
|
$this->addDecision($literal, $level);
|
||||||
$this->decisionQueue[] = array(
|
$this->decisionQueue[] = array(
|
||||||
|
@ -56,7 +56,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $literal
|
* @param int $literal
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function satisfy($literal): bool
|
public function satisfy(int $literal): bool
|
||||||
{
|
{
|
||||||
$packageId = abs($literal);
|
$packageId = abs($literal);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $literal
|
* @param int $literal
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function conflict($literal): bool
|
public function conflict(int $literal): bool
|
||||||
{
|
{
|
||||||
$packageId = abs($literal);
|
$packageId = abs($literal);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $literalOrPackageId
|
* @param int $literalOrPackageId
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function decided($literalOrPackageId): bool
|
public function decided(int $literalOrPackageId): bool
|
||||||
{
|
{
|
||||||
return !empty($this->decisionMap[abs($literalOrPackageId)]);
|
return !empty($this->decisionMap[abs($literalOrPackageId)]);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $literalOrPackageId
|
* @param int $literalOrPackageId
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function undecided($literalOrPackageId): bool
|
public function undecided(int $literalOrPackageId): bool
|
||||||
{
|
{
|
||||||
return empty($this->decisionMap[abs($literalOrPackageId)]);
|
return empty($this->decisionMap[abs($literalOrPackageId)]);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $literalOrPackageId
|
* @param int $literalOrPackageId
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function decidedInstall($literalOrPackageId): bool
|
public function decidedInstall(int $literalOrPackageId): bool
|
||||||
{
|
{
|
||||||
$packageId = abs($literalOrPackageId);
|
$packageId = abs($literalOrPackageId);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $literalOrPackageId
|
* @param int $literalOrPackageId
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function decisionLevel($literalOrPackageId): int
|
public function decisionLevel(int $literalOrPackageId): int
|
||||||
{
|
{
|
||||||
$packageId = abs($literalOrPackageId);
|
$packageId = abs($literalOrPackageId);
|
||||||
if (isset($this->decisionMap[$packageId])) {
|
if (isset($this->decisionMap[$packageId])) {
|
||||||
|
@ -127,7 +127,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $literalOrPackageId
|
* @param int $literalOrPackageId
|
||||||
* @return Rule|null
|
* @return Rule|null
|
||||||
*/
|
*/
|
||||||
public function decisionRule($literalOrPackageId): ?Rule
|
public function decisionRule(int $literalOrPackageId): ?Rule
|
||||||
{
|
{
|
||||||
$packageId = abs($literalOrPackageId);
|
$packageId = abs($literalOrPackageId);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $queueOffset
|
* @param int $queueOffset
|
||||||
* @return array{0: int, 1: Rule} a literal and decision reason
|
* @return array{0: int, 1: Rule} a literal and decision reason
|
||||||
*/
|
*/
|
||||||
public function atOffset($queueOffset): array
|
public function atOffset(int $queueOffset): array
|
||||||
{
|
{
|
||||||
return $this->decisionQueue[$queueOffset];
|
return $this->decisionQueue[$queueOffset];
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $queueOffset
|
* @param int $queueOffset
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function validOffset($queueOffset): bool
|
public function validOffset(int $queueOffset): bool
|
||||||
{
|
{
|
||||||
return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
|
return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function resetToOffset($offset): void
|
public function resetToOffset(int $offset): void
|
||||||
{
|
{
|
||||||
while (\count($this->decisionQueue) > $offset + 1) {
|
while (\count($this->decisionQueue) > $offset + 1) {
|
||||||
$decision = array_pop($this->decisionQueue);
|
$decision = array_pop($this->decisionQueue);
|
||||||
|
@ -252,7 +252,7 @@ class Decisions implements \Iterator, \Countable
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function addDecision($literal, $level): void
|
protected function addDecision(int $literal, int $level): void
|
||||||
{
|
{
|
||||||
$packageId = abs($literal);
|
$packageId = abs($literal);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class DefaultPolicy implements PolicyInterface
|
||||||
* @param bool $preferStable
|
* @param bool $preferStable
|
||||||
* @param bool $preferLowest
|
* @param bool $preferLowest
|
||||||
*/
|
*/
|
||||||
public function __construct($preferStable = false, $preferLowest = false)
|
public function __construct(bool $preferStable = false, bool $preferLowest = false)
|
||||||
{
|
{
|
||||||
$this->preferStable = $preferStable;
|
$this->preferStable = $preferStable;
|
||||||
$this->preferLowest = $preferLowest;
|
$this->preferLowest = $preferLowest;
|
||||||
|
@ -44,7 +44,7 @@ class DefaultPolicy implements PolicyInterface
|
||||||
*
|
*
|
||||||
* @phpstan-param Constraint::STR_OP_* $operator
|
* @phpstan-param Constraint::STR_OP_* $operator
|
||||||
*/
|
*/
|
||||||
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator): bool
|
public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool
|
||||||
{
|
{
|
||||||
if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
|
if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
|
||||||
return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
|
return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
|
||||||
|
@ -61,7 +61,7 @@ class DefaultPolicy implements PolicyInterface
|
||||||
* @param string $requiredPackage
|
* @param string $requiredPackage
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null): array
|
public function selectPreferredPackages(Pool $pool, array $literals, string $requiredPackage = null): array
|
||||||
{
|
{
|
||||||
$packages = $this->groupLiteralsByName($pool, $literals);
|
$packages = $this->groupLiteralsByName($pool, $literals);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class DefaultPolicy implements PolicyInterface
|
||||||
* @param int[] $literals
|
* @param int[] $literals
|
||||||
* @return array<string, int[]>
|
* @return array<string, int[]>
|
||||||
*/
|
*/
|
||||||
protected function groupLiteralsByName(Pool $pool, $literals): array
|
protected function groupLiteralsByName(Pool $pool, array $literals): array
|
||||||
{
|
{
|
||||||
$packages = array();
|
$packages = array();
|
||||||
foreach ($literals as $literal) {
|
foreach ($literals as $literal) {
|
||||||
|
@ -107,11 +107,11 @@ class DefaultPolicy implements PolicyInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param ?string $requiredPackage
|
* @param null|string $requiredPackage
|
||||||
* @param bool $ignoreReplace
|
* @param bool $ignoreReplace
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, $requiredPackage = null, $ignoreReplace = false): int
|
public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, ?string $requiredPackage = null, bool $ignoreReplace = false): int
|
||||||
{
|
{
|
||||||
// prefer aliases to the original package
|
// prefer aliases to the original package
|
||||||
if ($a->getName() === $b->getName()) {
|
if ($a->getName() === $b->getName()) {
|
||||||
|
@ -182,7 +182,7 @@ class DefaultPolicy implements PolicyInterface
|
||||||
* @param int[] $literals
|
* @param int[] $literals
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
protected function pruneToBestVersion(Pool $pool, $literals): array
|
protected function pruneToBestVersion(Pool $pool, array $literals): array
|
||||||
{
|
{
|
||||||
$operator = $this->preferLowest ? '<' : '>';
|
$operator = $this->preferLowest ? '<' : '>';
|
||||||
$bestLiterals = array($literals[0]);
|
$bestLiterals = array($literals[0]);
|
||||||
|
|
|
@ -106,7 +106,7 @@ class LockTransaction extends Transaction
|
||||||
* @param bool $updateMirrors
|
* @param bool $updateMirrors
|
||||||
* @return BasePackage[]
|
* @return BasePackage[]
|
||||||
*/
|
*/
|
||||||
public function getNewLockPackages($devMode, $updateMirrors = false): array
|
public function getNewLockPackages(bool $devMode, bool $updateMirrors = false): array
|
||||||
{
|
{
|
||||||
$packages = array();
|
$packages = array();
|
||||||
foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
|
foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
|
||||||
|
@ -119,7 +119,7 @@ class LockTransaction extends Transaction
|
||||||
if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
|
if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
|
||||||
$package->setSourceDistReferences($presentPackage->getSourceReference());
|
$package->setSourceDistReferences($presentPackage->getSourceReference());
|
||||||
}
|
}
|
||||||
if ($presentPackage->getReleaseDate() && $package instanceof Package) {
|
if ($presentPackage->getReleaseDate() !== null && $package instanceof Package) {
|
||||||
$package->setReleaseDate($presentPackage->getReleaseDate());
|
$package->setReleaseDate($presentPackage->getReleaseDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ class LockTransaction extends Transaction
|
||||||
* @param array<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
|
* @param array<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
|
||||||
* @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
|
* @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
|
||||||
*/
|
*/
|
||||||
public function getAliases($aliases): array
|
public function getAliases(array $aliases): array
|
||||||
{
|
{
|
||||||
$usedAliases = array();
|
$usedAliases = array();
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ class InstallOperation extends SolverOperation implements OperationInterface
|
||||||
* @param bool $lock
|
* @param bool $lock
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function format(PackageInterface $package, $lock = false)
|
public static function format(PackageInterface $package, bool $lock = false)
|
||||||
{
|
{
|
||||||
return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
|
return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ interface OperationInterface
|
||||||
* @param bool $lock Whether this is an operation on the lock file
|
* @param bool $lock Whether this is an operation on the lock file
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function show($lock);
|
public function show(bool $lock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the operation in a human readable format
|
* Serializes the operation in a human readable format
|
||||||
|
|
|
@ -55,7 +55,7 @@ class UninstallOperation extends SolverOperation implements OperationInterface
|
||||||
* @param bool $lock
|
* @param bool $lock
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function format(PackageInterface $package, $lock = false): string
|
public static function format(PackageInterface $package, bool $lock = false): string
|
||||||
{
|
{
|
||||||
return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
|
return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class UpdateOperation extends SolverOperation implements OperationInterface
|
||||||
* @param bool $lock
|
* @param bool $lock
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false): string
|
public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, bool $lock = false): string
|
||||||
{
|
{
|
||||||
$fromVersion = $initialPackage->getFullPrettyVersion();
|
$fromVersion = $initialPackage->getFullPrettyVersion();
|
||||||
$toVersion = $targetPackage->getFullPrettyVersion();
|
$toVersion = $targetPackage->getFullPrettyVersion();
|
||||||
|
|
|
@ -26,12 +26,12 @@ interface PolicyInterface
|
||||||
*
|
*
|
||||||
* @phpstan-param Constraint::STR_OP_* $operator
|
* @phpstan-param Constraint::STR_OP_* $operator
|
||||||
*/
|
*/
|
||||||
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator): bool;
|
public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int[] $literals
|
* @param int[] $literals
|
||||||
* @param ?string $requiredPackage
|
* @param null|string $requiredPackage
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null): array;
|
public function selectPreferredPackages(Pool $pool, array $literals, ?string $requiredPackage = null): array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Pool implements \Countable
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
public function getRemovedVersions($name, ConstraintInterface $constraint): array
|
public function getRemovedVersions(string $name, ConstraintInterface $constraint): array
|
||||||
{
|
{
|
||||||
if (!isset($this->removedVersions[$name])) {
|
if (!isset($this->removedVersions[$name])) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -80,7 +80,7 @@ class Pool implements \Countable
|
||||||
* @param string $objectHash
|
* @param string $objectHash
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
public function getRemovedVersionsByPackage($objectHash): array
|
public function getRemovedVersionsByPackage(string $objectHash): array
|
||||||
{
|
{
|
||||||
if (!isset($this->removedVersionsByPackage[$objectHash])) {
|
if (!isset($this->removedVersionsByPackage[$objectHash])) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -122,7 +122,7 @@ class Pool implements \Countable
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return BasePackage
|
* @return BasePackage
|
||||||
*/
|
*/
|
||||||
public function packageById($id): BasePackage
|
public function packageById(int $id): BasePackage
|
||||||
{
|
{
|
||||||
return $this->packages[$id - 1];
|
return $this->packages[$id - 1];
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ class Pool implements \Countable
|
||||||
* packages must match or null to return all
|
* packages must match or null to return all
|
||||||
* @return BasePackage[] A set of packages
|
* @return BasePackage[] A set of packages
|
||||||
*/
|
*/
|
||||||
public function whatProvides($name, ConstraintInterface $constraint = null): array
|
public function whatProvides(string $name, ConstraintInterface $constraint = null): array
|
||||||
{
|
{
|
||||||
$key = (string) $constraint;
|
$key = (string) $constraint;
|
||||||
if (isset($this->providerCache[$name][$key])) {
|
if (isset($this->providerCache[$name][$key])) {
|
||||||
|
@ -159,7 +159,7 @@ class Pool implements \Countable
|
||||||
* packages must match or null to return all
|
* packages must match or null to return all
|
||||||
* @return BasePackage[]
|
* @return BasePackage[]
|
||||||
*/
|
*/
|
||||||
private function computeWhatProvides($name, ConstraintInterface $constraint = null): array
|
private function computeWhatProvides(string $name, ConstraintInterface $constraint = null): array
|
||||||
{
|
{
|
||||||
if (!isset($this->packageByName[$name])) {
|
if (!isset($this->packageByName[$name])) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -180,7 +180,7 @@ class Pool implements \Countable
|
||||||
* @param int $literal
|
* @param int $literal
|
||||||
* @return BasePackage
|
* @return BasePackage
|
||||||
*/
|
*/
|
||||||
public function literalToPackage($literal): BasePackage
|
public function literalToPackage(int $literal): BasePackage
|
||||||
{
|
{
|
||||||
$packageId = abs($literal);
|
$packageId = abs($literal);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ class Pool implements \Countable
|
||||||
* @param array<int, BasePackage> $installedMap
|
* @param array<int, BasePackage> $installedMap
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function literalToPrettyString($literal, $installedMap): string
|
public function literalToPrettyString(int $literal, array $installedMap): string
|
||||||
{
|
{
|
||||||
$package = $this->literalToPackage($literal);
|
$package = $this->literalToPackage($literal);
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ class Pool implements \Countable
|
||||||
* @param string $name Name of the package to be matched
|
* @param string $name Name of the package to be matched
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function match(BasePackage $candidate, $name, ConstraintInterface $constraint = null): bool
|
public function match(BasePackage $candidate, string $name, ConstraintInterface $constraint = null): bool
|
||||||
{
|
{
|
||||||
$candidateName = $candidate->getName();
|
$candidateName = $candidate->getName();
|
||||||
$candidateVersion = $candidate->getVersion();
|
$candidateVersion = $candidate->getVersion();
|
||||||
|
|
|
@ -300,7 +300,7 @@ class PoolBuilder
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint): void
|
private function markPackageNameForLoading(Request $request, string $name, ConstraintInterface $constraint): void
|
||||||
{
|
{
|
||||||
// Skip platform requires at this stage
|
// Skip platform requires at this stage
|
||||||
if (PlatformRepository::isPlatformPackage($name)) {
|
if (PlatformRepository::isPlatformPackage($name)) {
|
||||||
|
@ -396,7 +396,7 @@ class PoolBuilder
|
||||||
* @param RepositoryInterface[] $repositories
|
* @param RepositoryInterface[] $repositories
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function loadPackage(Request $request, array $repositories, BasePackage $package, $propagateUpdate): void
|
private function loadPackage(Request $request, array $repositories, BasePackage $package, bool $propagateUpdate): void
|
||||||
{
|
{
|
||||||
$index = $this->indexCounter++;
|
$index = $this->indexCounter++;
|
||||||
$this->packages[$index] = $package;
|
$this->packages[$index] = $package;
|
||||||
|
@ -501,7 +501,7 @@ class PoolBuilder
|
||||||
* @param string $name packageName
|
* @param string $name packageName
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isRootRequire(Request $request, $name): bool
|
private function isRootRequire(Request $request, string $name): bool
|
||||||
{
|
{
|
||||||
$rootRequires = $request->getRequires();
|
$rootRequires = $request->getRequires();
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ class PoolBuilder
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function getSkippedRootRequires(Request $request, $name): array
|
private function getSkippedRootRequires(Request $request, string $name): array
|
||||||
{
|
{
|
||||||
if (!isset($this->skippedLoad[$name])) {
|
if (!isset($this->skippedLoad[$name])) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -602,7 +602,7 @@ class PoolBuilder
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function unlockPackage(Request $request, array $repositories, $name): void
|
private function unlockPackage(Request $request, array $repositories, string $name): void
|
||||||
{
|
{
|
||||||
foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
|
foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
|
||||||
// if we unfixed a replaced package name, we also need to unfix the replacer itself
|
// if we unfixed a replaced package name, we also need to unfix the replacer itself
|
||||||
|
@ -668,7 +668,7 @@ class PoolBuilder
|
||||||
* @param int $index
|
* @param int $index
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function removeLoadedPackage(Request $request, array $repositories, BasePackage $package, $index): void
|
private function removeLoadedPackage(Request $request, array $repositories, BasePackage $package, int $index): void
|
||||||
{
|
{
|
||||||
$repoIndex = array_search($package->getRepository(), $repositories, true);
|
$repoIndex = array_search($package->getRepository(), $repositories, true);
|
||||||
|
|
||||||
|
|
|
@ -322,7 +322,7 @@ class PoolOptimizer
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function markPackageForRemoval($id): void
|
private function markPackageForRemoval(int $id): void
|
||||||
{
|
{
|
||||||
// We are not allowed to remove packages if they have been marked as irremovable
|
// We are not allowed to remove packages if they have been marked as irremovable
|
||||||
if (isset($this->irremovablePackages[$id])) {
|
if (isset($this->irremovablePackages[$id])) {
|
||||||
|
@ -337,7 +337,7 @@ class PoolOptimizer
|
||||||
* @param array<int, array<string, array{groupHash: string, dependencyHash: string}>> $packageIdenticalDefinitionLookup
|
* @param array<int, array<string, array{groupHash: string, dependencyHash: string}>> $packageIdenticalDefinitionLookup
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function keepPackage(BasePackage $package, $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup): void
|
private function keepPackage(BasePackage $package, array $identicalDefinitionsPerPackage, array $packageIdenticalDefinitionLookup): void
|
||||||
{
|
{
|
||||||
unset($this->packagesToRemove[$package->id]);
|
unset($this->packagesToRemove[$package->id]);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Problem
|
||||||
* @param array<Rule[]> $learnedPool
|
* @param array<Rule[]> $learnedPool
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
|
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
|
||||||
{
|
{
|
||||||
// TODO doesn't this entirely defeat the purpose of the problem sections? what's the point of sections?
|
// TODO doesn't this entirely defeat the purpose of the problem sections? what's the point of sections?
|
||||||
$reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
|
$reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
|
||||||
|
@ -117,7 +117,7 @@ class Problem
|
||||||
* @return string
|
* @return string
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
|
public static function formatDeduplicatedRules(array $rules, string $indent, RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
|
||||||
{
|
{
|
||||||
$messages = array();
|
$messages = array();
|
||||||
$templates = array();
|
$templates = array();
|
||||||
|
@ -185,7 +185,7 @@ class Problem
|
||||||
* @param Rule $reason The reason descriptor
|
* @param Rule $reason The reason descriptor
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function addReason($id, Rule $reason): void
|
protected function addReason(string $id, Rule $reason): void
|
||||||
{
|
{
|
||||||
// TODO: if a rule is part of a problem description in two sections, isn't this going to remove a message
|
// TODO: if a rule is part of a problem description in two sections, isn't this going to remove a message
|
||||||
// that is important to understand the issue?
|
// that is important to understand the issue?
|
||||||
|
@ -210,7 +210,7 @@ class Problem
|
||||||
* @param string $packageName
|
* @param string $packageName
|
||||||
* @return array{0: string, 1: string}
|
* @return array{0: string, 1: string}
|
||||||
*/
|
*/
|
||||||
public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, ConstraintInterface $constraint = null): array
|
public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, string $packageName, ConstraintInterface $constraint = null): array
|
||||||
{
|
{
|
||||||
if (PlatformRepository::isPlatformPackage($packageName)) {
|
if (PlatformRepository::isPlatformPackage($packageName)) {
|
||||||
// handle php/php-*/hhvm
|
// handle php/php-*/hhvm
|
||||||
|
@ -382,7 +382,7 @@ class Problem
|
||||||
* @param bool $useRemovedVersionGroup
|
* @param bool $useRemovedVersionGroup
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getPackageList(array $packages, $isVerbose, Pool $pool = null, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false): string
|
public static function getPackageList(array $packages, bool $isVerbose, Pool $pool = null, ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
|
||||||
{
|
{
|
||||||
$prepared = array();
|
$prepared = array();
|
||||||
$hasDefaultBranch = array();
|
$hasDefaultBranch = array();
|
||||||
|
@ -427,7 +427,7 @@ class Problem
|
||||||
* @param string $version the effective runtime version of the platform package
|
* @param string $version the effective runtime version of the platform package
|
||||||
* @return ?string a version string or null if it appears the package was artificially disabled
|
* @return ?string a version string or null if it appears the package was artificially disabled
|
||||||
*/
|
*/
|
||||||
private static function getPlatformPackageVersion(Pool $pool, $packageName, $version): ?string
|
private static function getPlatformPackageVersion(Pool $pool, string $packageName, string $version): ?string
|
||||||
{
|
{
|
||||||
$available = $pool->whatProvides($packageName);
|
$available = $pool->whatProvides($packageName);
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ class Problem
|
||||||
* @param int $maxDev
|
* @param int $maxDev
|
||||||
* @return list<string> a list of pretty versions and '...' where versions were removed
|
* @return list<string> a list of pretty versions and '...' where versions were removed
|
||||||
*/
|
*/
|
||||||
private static function condenseVersionList(array $versions, $max, $maxDev = 16): array
|
private static function condenseVersionList(array $versions, int $max, int $maxDev = 16): array
|
||||||
{
|
{
|
||||||
if (count($versions) <= $max) {
|
if (count($versions) <= $max) {
|
||||||
return $versions;
|
return $versions;
|
||||||
|
@ -527,7 +527,7 @@ class Problem
|
||||||
* @param string $reason
|
* @param string $reason
|
||||||
* @return array{0: string, 1: string}
|
* @return array{0: string, 1: string}
|
||||||
*/
|
*/
|
||||||
private static function computeCheckForLowerPrioRepo(Pool $pool, $isVerbose, $packageName, array $higherRepoPackages, array $allReposPackages, $reason, ConstraintInterface $constraint = null): array
|
private static function computeCheckForLowerPrioRepo(Pool $pool, bool $isVerbose, string $packageName, array $higherRepoPackages, array $allReposPackages, string $reason, ConstraintInterface $constraint = null): array
|
||||||
{
|
{
|
||||||
$nextRepoPackages = array();
|
$nextRepoPackages = array();
|
||||||
$nextRepo = null;
|
$nextRepo = null;
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Request
|
||||||
* @param string $packageName
|
* @param string $packageName
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function requireName($packageName, ConstraintInterface $constraint = null): void
|
public function requireName(string $packageName, ConstraintInterface $constraint = null): void
|
||||||
{
|
{
|
||||||
$packageName = strtolower($packageName);
|
$packageName = strtolower($packageName);
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ class Request
|
||||||
* @param false|self::UPDATE_* $updateAllowTransitiveDependencies
|
* @param false|self::UPDATE_* $updateAllowTransitiveDependencies
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies): void
|
public function setUpdateAllowList(array $updateAllowList, $updateAllowTransitiveDependencies): void
|
||||||
{
|
{
|
||||||
$this->updateAllowList = $updateAllowList;
|
$this->updateAllowList = $updateAllowList;
|
||||||
$this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
|
$this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
|
||||||
|
@ -222,7 +222,7 @@ class Request
|
||||||
* Some locked packages may not be in the pool,
|
* Some locked packages may not be in the pool,
|
||||||
* so they have a package->id of -1
|
* so they have a package->id of -1
|
||||||
*/
|
*/
|
||||||
public function getPresentMap($packageIds = false): array
|
public function getPresentMap(bool $packageIds = false): array
|
||||||
{
|
{
|
||||||
$presentMap = array();
|
$presentMap = array();
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ abstract class Rule
|
||||||
* @param array<Rule[]> $learnedPool
|
* @param array<Rule[]> $learnedPool
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
|
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
|
||||||
{
|
{
|
||||||
$literals = $this->getLiterals();
|
$literals = $this->getLiterals();
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ abstract class Rule
|
||||||
* @param bool $useRemovedVersionGroup
|
* @param bool $useRemovedVersionGroup
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function formatPackagesUnique(Pool $pool, array $packages, $isVerbose, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false): string
|
protected function formatPackagesUnique(Pool $pool, array $packages, bool $isVerbose, ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
|
||||||
{
|
{
|
||||||
foreach ($packages as $index => $package) {
|
foreach ($packages as $index => $package) {
|
||||||
if (!\is_object($package)) {
|
if (!\is_object($package)) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Rule2Literals extends Rule
|
||||||
*
|
*
|
||||||
* @phpstan-param ReasonData $reasonData
|
* @phpstan-param ReasonData $reasonData
|
||||||
*/
|
*/
|
||||||
public function __construct($literal1, $literal2, $reason, $reasonData)
|
public function __construct(int $literal1, int $literal2, $reason, $reasonData)
|
||||||
{
|
{
|
||||||
parent::__construct($reason, $reasonData);
|
parent::__construct($reason, $reasonData);
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ class RuleSet implements \IteratorAggregate, \Countable
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return Rule
|
* @return Rule
|
||||||
*/
|
*/
|
||||||
public function ruleById($id): Rule
|
public function ruleById(int $id): Rule
|
||||||
{
|
{
|
||||||
return $this->ruleById[$id];
|
return $this->ruleById[$id];
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ class RuleSet implements \IteratorAggregate, \Countable
|
||||||
* @param bool $isVerbose
|
* @param bool $isVerbose
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false): string
|
public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, bool $isVerbose = false): string
|
||||||
{
|
{
|
||||||
$string = "\n";
|
$string = "\n";
|
||||||
foreach ($this->rules as $type => $rules) {
|
foreach ($this->rules as $type => $rules) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ class RuleSetGenerator
|
||||||
* @param BasePackage[] $packages The set of packages to choose from
|
* @param BasePackage[] $packages The set of packages to choose from
|
||||||
* @param Rule::RULE_* $reason A RULE_* constant describing the reason for
|
* @param Rule::RULE_* $reason A RULE_* constant describing the reason for
|
||||||
* generating this rule
|
* generating this rule
|
||||||
* @param array $reasonData Additional data like the root require or fix request info
|
* @param mixed $reasonData Additional data like the root require or fix request info
|
||||||
* @return Rule The generated rule
|
* @return Rule The generated rule
|
||||||
*
|
*
|
||||||
* @phpstan-param ReasonData $reasonData
|
* @phpstan-param ReasonData $reasonData
|
||||||
|
|
|
@ -29,7 +29,7 @@ class RuleWatchChain extends \SplDoublyLinkedList
|
||||||
* @param int $offset The offset to seek to.
|
* @param int $offset The offset to seek to.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function seek($offset): void
|
public function seek(int $offset): void
|
||||||
{
|
{
|
||||||
$this->rewind();
|
$this->rewind();
|
||||||
for ($i = 0; $i < $offset; $i++, $this->next());
|
for ($i = 0; $i < $offset; $i++, $this->next());
|
||||||
|
|
|
@ -88,7 +88,7 @@ class RuleWatchGraph
|
||||||
* register decisions resulting from propagation
|
* register decisions resulting from propagation
|
||||||
* @return Rule|null If a conflict is found the conflicting rule is returned
|
* @return Rule|null If a conflict is found the conflicting rule is returned
|
||||||
*/
|
*/
|
||||||
public function propagateLiteral($decidedLiteral, $level, Decisions $decisions): ?Rule
|
public function propagateLiteral(int $decidedLiteral, int $level, Decisions $decisions): ?Rule
|
||||||
{
|
{
|
||||||
// we invert the decided literal here, example:
|
// we invert the decided literal here, example:
|
||||||
// A was decided => (-A|B) now requires B to be true, so we look for
|
// A was decided => (-A|B) now requires B to be true, so we look for
|
||||||
|
@ -156,7 +156,7 @@ class RuleWatchGraph
|
||||||
* @param RuleWatchNode $node The rule node to be moved
|
* @param RuleWatchNode $node The rule node to be moved
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function moveWatch($fromLiteral, $toLiteral, RuleWatchNode $node): void
|
protected function moveWatch(int $fromLiteral, int $toLiteral, RuleWatchNode $node): void
|
||||||
{
|
{
|
||||||
if (!isset($this->watchChains[$toLiteral])) {
|
if (!isset($this->watchChains[$toLiteral])) {
|
||||||
$this->watchChains[$toLiteral] = new RuleWatchChain;
|
$this->watchChains[$toLiteral] = new RuleWatchChain;
|
||||||
|
|
|
@ -91,7 +91,7 @@ class RuleWatchNode
|
||||||
* @param int $literal The watched literal that should not be returned
|
* @param int $literal The watched literal that should not be returned
|
||||||
* @return int A literal
|
* @return int A literal
|
||||||
*/
|
*/
|
||||||
public function getOtherWatch($literal): int
|
public function getOtherWatch(int $literal): int
|
||||||
{
|
{
|
||||||
if ($this->watch1 == $literal) {
|
if ($this->watch1 == $literal) {
|
||||||
return $this->watch2;
|
return $this->watch2;
|
||||||
|
@ -107,7 +107,7 @@ class RuleWatchNode
|
||||||
* @param int $to The literal to be watched now
|
* @param int $to The literal to be watched now
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function moveWatch($from, $to): void
|
public function moveWatch(int $from, int $to): void
|
||||||
{
|
{
|
||||||
if ($this->watch1 == $from) {
|
if ($this->watch1 == $from) {
|
||||||
$this->watch1 = $to;
|
$this->watch1 = $to;
|
||||||
|
|
|
@ -233,7 +233,7 @@ class Solver
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @return Rule|null A rule on conflict, otherwise null.
|
* @return Rule|null A rule on conflict, otherwise null.
|
||||||
*/
|
*/
|
||||||
protected function propagate($level): ?Rule
|
protected function propagate(int $level): ?Rule
|
||||||
{
|
{
|
||||||
while ($this->decisions->validOffset($this->propagateIndex)) {
|
while ($this->decisions->validOffset($this->propagateIndex)) {
|
||||||
$decision = $this->decisions->atOffset($this->propagateIndex);
|
$decision = $this->decisions->atOffset($this->propagateIndex);
|
||||||
|
@ -261,7 +261,7 @@ class Solver
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function revert($level): void
|
private function revert(int $level): void
|
||||||
{
|
{
|
||||||
while (!$this->decisions->isEmpty()) {
|
while (!$this->decisions->isEmpty()) {
|
||||||
$literal = $this->decisions->lastLiteral();
|
$literal = $this->decisions->lastLiteral();
|
||||||
|
@ -302,7 +302,7 @@ class Solver
|
||||||
* @param string|int $literal
|
* @param string|int $literal
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function setPropagateLearn($level, $literal, Rule $rule): int
|
private function setPropagateLearn(int $level, $literal, Rule $rule): int
|
||||||
{
|
{
|
||||||
$level++;
|
$level++;
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ class Solver
|
||||||
* @param int[] $decisionQueue
|
* @param int[] $decisionQueue
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function selectAndInstall($level, array $decisionQueue, Rule $rule): int
|
private function selectAndInstall(int $level, array $decisionQueue, Rule $rule): int
|
||||||
{
|
{
|
||||||
// choose best package to install from decisionQueue
|
// choose best package to install from decisionQueue
|
||||||
$literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
|
$literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
|
||||||
|
@ -370,7 +370,7 @@ class Solver
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @return array{int, int, GenericRule, int}
|
* @return array{int, int, GenericRule, int}
|
||||||
*/
|
*/
|
||||||
protected function analyze($level, Rule $rule): array
|
protected function analyze(int $level, Rule $rule): array
|
||||||
{
|
{
|
||||||
$analyzedRule = $rule;
|
$analyzedRule = $rule;
|
||||||
$ruleLevel = 1;
|
$ruleLevel = 1;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class SolverBugException extends \RuntimeException
|
||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
public function __construct($message)
|
public function __construct(string $message)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message."\nThis exception was most likely caused by a bug in Composer.\n".
|
$message."\nThis exception was most likely caused by a bug in Composer.\n".
|
||||||
|
|
|
@ -46,7 +46,7 @@ class SolverProblemsException extends \RuntimeException
|
||||||
* @param bool $isDevExtraction
|
* @param bool $isDevExtraction
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false): string
|
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, bool $isDevExtraction = false): string
|
||||||
{
|
{
|
||||||
$installedMap = $request->getPresentMap(true);
|
$installedMap = $request->getPresentMap(true);
|
||||||
$missingExtensions = array();
|
$missingExtensions = array();
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Transaction
|
||||||
* @param PackageInterface[] $presentPackages
|
* @param PackageInterface[] $presentPackages
|
||||||
* @param PackageInterface[] $resultPackages
|
* @param PackageInterface[] $resultPackages
|
||||||
*/
|
*/
|
||||||
public function __construct($presentPackages, $resultPackages)
|
public function __construct(array $presentPackages, array $resultPackages)
|
||||||
{
|
{
|
||||||
$this->presentPackages = $presentPackages;
|
$this->presentPackages = $presentPackages;
|
||||||
$this->setResultPackageMaps($resultPackages);
|
$this->setResultPackageMaps($resultPackages);
|
||||||
|
@ -69,7 +69,7 @@ class Transaction
|
||||||
* @param PackageInterface[] $resultPackages
|
* @param PackageInterface[] $resultPackages
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function setResultPackageMaps($resultPackages): void
|
private function setResultPackageMaps(array $resultPackages): void
|
||||||
{
|
{
|
||||||
$packageSort = function (PackageInterface $a, PackageInterface $b): int {
|
$packageSort = function (PackageInterface $a, PackageInterface $b): int {
|
||||||
// sort alias packages by the same name behind their non alias version
|
// sort alias packages by the same name behind their non alias version
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
namespace Composer\Downloader;
|
namespace Composer\Downloader;
|
||||||
|
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
|
use Composer\Util\Platform;
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
use React\Promise\PromiseInterface;
|
use React\Promise\PromiseInterface;
|
||||||
use Composer\DependencyResolver\Operation\InstallOperation;
|
use Composer\DependencyResolver\Operation\InstallOperation;
|
||||||
|
@ -34,7 +35,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
/**
|
/**
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
|
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
unset($this->cleanupExecuted[$package->getName()]);
|
unset($this->cleanupExecuted[$package->getName()]);
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
/**
|
/**
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
|
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
$this->cleanupExecuted[$package->getName()] = true;
|
$this->cleanupExecuted[$package->getName()] = true;
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @throws \UnexpectedValueException
|
* @throws \UnexpectedValueException
|
||||||
*/
|
*/
|
||||||
public function install(PackageInterface $package, $path, $output = true)
|
public function install(PackageInterface $package, string $path, bool $output = true)
|
||||||
{
|
{
|
||||||
if ($output) {
|
if ($output) {
|
||||||
$this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
|
$this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
|
||||||
|
@ -83,7 +84,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
$this->addCleanupPath($package, $temporaryDir);
|
$this->addCleanupPath($package, $temporaryDir);
|
||||||
// avoid cleaning up $path if installing in "." for eg create-project as we can not
|
// avoid cleaning up $path if installing in "." for eg create-project as we can not
|
||||||
// delete the directory we are currently in on windows
|
// delete the directory we are currently in on windows
|
||||||
if (!is_dir($path) || realpath($path) !== getcwd()) {
|
if (!is_dir($path) || realpath($path) !== Platform::getCwd()) {
|
||||||
$this->addCleanupPath($package, $path);
|
$this->addCleanupPath($package, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
$filesystem->removeDirectory($temporaryDir);
|
$filesystem->removeDirectory($temporaryDir);
|
||||||
if (is_dir($path) && realpath($path) !== getcwd()) {
|
if (is_dir($path) && realpath($path) !== Platform::getCwd()) {
|
||||||
$filesystem->removeDirectory($path);
|
$filesystem->removeDirectory($path);
|
||||||
}
|
}
|
||||||
$this->removeCleanupPath($package, $temporaryDir);
|
$this->removeCleanupPath($package, $temporaryDir);
|
||||||
|
@ -214,7 +215,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function getInstallOperationAppendix(PackageInterface $package, $path)
|
protected function getInstallOperationAppendix(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
return ': Extracting archive';
|
return ': Extracting archive';
|
||||||
}
|
}
|
||||||
|
@ -228,5 +229,5 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
* @throws \UnexpectedValueException If can not extract downloaded file to path
|
* @throws \UnexpectedValueException If can not extract downloaded file to path
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
abstract protected function extract(PackageInterface $package, $file, $path);
|
abstract protected function extract(PackageInterface $package, string $file, string $path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,5 +28,5 @@ interface ChangeReportInterface
|
||||||
* @param string $path package directory
|
* @param string $path package directory
|
||||||
* @return string|null changes or null
|
* @return string|null changes or null
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $path);
|
public function getLocalChanges(PackageInterface $package, string $path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class DownloadManager
|
||||||
* @param bool $preferSource prefer downloading from source
|
* @param bool $preferSource prefer downloading from source
|
||||||
* @param Filesystem|null $filesystem custom Filesystem object
|
* @param Filesystem|null $filesystem custom Filesystem object
|
||||||
*/
|
*/
|
||||||
public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
|
public function __construct(IOInterface $io, bool $preferSource = false, Filesystem $filesystem = null)
|
||||||
{
|
{
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->preferSource = $preferSource;
|
$this->preferSource = $preferSource;
|
||||||
|
@ -59,7 +59,7 @@ class DownloadManager
|
||||||
* @param bool $preferSource prefer downloading from source
|
* @param bool $preferSource prefer downloading from source
|
||||||
* @return DownloadManager
|
* @return DownloadManager
|
||||||
*/
|
*/
|
||||||
public function setPreferSource($preferSource): DownloadManager
|
public function setPreferSource(bool $preferSource): DownloadManager
|
||||||
{
|
{
|
||||||
$this->preferSource = $preferSource;
|
$this->preferSource = $preferSource;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class DownloadManager
|
||||||
* @param bool $preferDist prefer downloading from dist
|
* @param bool $preferDist prefer downloading from dist
|
||||||
* @return DownloadManager
|
* @return DownloadManager
|
||||||
*/
|
*/
|
||||||
public function setPreferDist($preferDist): DownloadManager
|
public function setPreferDist(bool $preferDist): DownloadManager
|
||||||
{
|
{
|
||||||
$this->preferDist = $preferDist;
|
$this->preferDist = $preferDist;
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class DownloadManager
|
||||||
* @param DownloaderInterface $downloader downloader instance
|
* @param DownloaderInterface $downloader downloader instance
|
||||||
* @return DownloadManager
|
* @return DownloadManager
|
||||||
*/
|
*/
|
||||||
public function setDownloader($type, DownloaderInterface $downloader): DownloadManager
|
public function setDownloader(string $type, DownloaderInterface $downloader): DownloadManager
|
||||||
{
|
{
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
$this->downloaders[$type] = $downloader;
|
$this->downloaders[$type] = $downloader;
|
||||||
|
@ -115,7 +115,7 @@ class DownloadManager
|
||||||
* @throws \InvalidArgumentException if downloader for provided type is not registered
|
* @throws \InvalidArgumentException if downloader for provided type is not registered
|
||||||
* @return DownloaderInterface
|
* @return DownloaderInterface
|
||||||
*/
|
*/
|
||||||
public function getDownloader($type): DownloaderInterface
|
public function getDownloader(string $type): DownloaderInterface
|
||||||
{
|
{
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
if (!isset($this->downloaders[$type])) {
|
if (!isset($this->downloaders[$type])) {
|
||||||
|
@ -184,7 +184,7 @@ class DownloadManager
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @return PromiseInterface
|
* @return PromiseInterface
|
||||||
*/
|
*/
|
||||||
public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null): PromiseInterface
|
public function download(PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): PromiseInterface
|
||||||
{
|
{
|
||||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||||
$this->filesystem->ensureDirectoryExists(dirname($targetDir));
|
$this->filesystem->ensureDirectoryExists(dirname($targetDir));
|
||||||
|
@ -253,7 +253,7 @@ class DownloadManager
|
||||||
*
|
*
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
|
public function prepare(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||||
$downloader = $this->getDownloaderForPackage($package);
|
$downloader = $this->getDownloaderForPackage($package);
|
||||||
|
@ -274,7 +274,7 @@ class DownloadManager
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function install(PackageInterface $package, $targetDir): ?PromiseInterface
|
public function install(PackageInterface $package, string $targetDir): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||||
$downloader = $this->getDownloaderForPackage($package);
|
$downloader = $this->getDownloaderForPackage($package);
|
||||||
|
@ -295,7 +295,7 @@ class DownloadManager
|
||||||
* @throws \InvalidArgumentException if initial package is not installed
|
* @throws \InvalidArgumentException if initial package is not installed
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function update(PackageInterface $initial, PackageInterface $target, $targetDir): ?PromiseInterface
|
public function update(PackageInterface $initial, PackageInterface $target, string $targetDir): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||||
$downloader = $this->getDownloaderForPackage($target);
|
$downloader = $this->getDownloaderForPackage($target);
|
||||||
|
@ -352,7 +352,7 @@ class DownloadManager
|
||||||
*
|
*
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $targetDir): ?PromiseInterface
|
public function remove(PackageInterface $package, string $targetDir): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||||
$downloader = $this->getDownloaderForPackage($package);
|
$downloader = $this->getDownloaderForPackage($package);
|
||||||
|
@ -373,7 +373,7 @@ class DownloadManager
|
||||||
*
|
*
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
|
public function cleanup(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||||
$downloader = $this->getDownloaderForPackage($package);
|
$downloader = $this->getDownloaderForPackage($package);
|
||||||
|
@ -461,7 +461,7 @@ class DownloadManager
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function normalizeTargetDir($dir): string
|
private function normalizeTargetDir(string $dir): string
|
||||||
{
|
{
|
||||||
if ($dir === '\\' || $dir === '/') {
|
if ($dir === '\\' || $dir === '/') {
|
||||||
return $dir;
|
return $dir;
|
||||||
|
|
|
@ -36,7 +36,7 @@ interface DownloaderInterface
|
||||||
* @param string $path download path
|
* @param string $path download path
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
|
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do anything that needs to be done between all downloads have been completed and the actual operation is executed
|
* Do anything that needs to be done between all downloads have been completed and the actual operation is executed
|
||||||
|
@ -52,7 +52,7 @@ interface DownloaderInterface
|
||||||
* @param PackageInterface $prevPackage previous package instance in case of an update
|
* @param PackageInterface $prevPackage previous package instance in case of an update
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
|
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs specific package into specific folder.
|
* Installs specific package into specific folder.
|
||||||
|
@ -61,7 +61,7 @@ interface DownloaderInterface
|
||||||
* @param string $path download path
|
* @param string $path download path
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function install(PackageInterface $package, $path);
|
public function install(PackageInterface $package, string $path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates specific package in specific folder from initial to target version.
|
* Updates specific package in specific folder from initial to target version.
|
||||||
|
@ -71,7 +71,7 @@ interface DownloaderInterface
|
||||||
* @param string $path download path
|
* @param string $path download path
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function update(PackageInterface $initial, PackageInterface $target, $path);
|
public function update(PackageInterface $initial, PackageInterface $target, string $path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes specific package from specific folder.
|
* Removes specific package from specific folder.
|
||||||
|
@ -80,7 +80,7 @@ interface DownloaderInterface
|
||||||
* @param string $path download path
|
* @param string $path download path
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $path);
|
public function remove(PackageInterface $package, string $path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do anything to cleanup changes applied in the prepare or install/update/uninstall steps
|
* Do anything to cleanup changes applied in the prepare or install/update/uninstall steps
|
||||||
|
@ -95,5 +95,5 @@ interface DownloaderInterface
|
||||||
* @param PackageInterface $prevPackage previous package instance in case of an update
|
* @param PackageInterface $prevPackage previous package instance in case of an update
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
|
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,5 +28,5 @@ interface DvcsDownloaderInterface
|
||||||
* @param string $path package directory
|
* @param string $path package directory
|
||||||
* @return string|null changes or null
|
* @return string|null changes or null
|
||||||
*/
|
*/
|
||||||
public function getUnpushedChanges(PackageInterface $package, $path);
|
public function getUnpushedChanges(PackageInterface $package, string $path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ use Composer\Plugin\PostFileDownloadEvent;
|
||||||
use Composer\Plugin\PreFileDownloadEvent;
|
use Composer\Plugin\PreFileDownloadEvent;
|
||||||
use Composer\EventDispatcher\EventDispatcher;
|
use Composer\EventDispatcher\EventDispatcher;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
|
use Composer\Util\Platform;
|
||||||
use Composer\Util\Silencer;
|
use Composer\Util\Silencer;
|
||||||
use Composer\Util\HttpDownloader;
|
use Composer\Util\HttpDownloader;
|
||||||
use Composer\Util\Url as UrlUtil;
|
use Composer\Util\Url as UrlUtil;
|
||||||
|
@ -112,7 +113,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
*
|
*
|
||||||
* @param bool $output
|
* @param bool $output
|
||||||
*/
|
*/
|
||||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
|
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true)
|
||||||
{
|
{
|
||||||
if (!$package->getDistUrl()) {
|
if (!$package->getDistUrl()) {
|
||||||
throw new \InvalidArgumentException('The given package is missing url information');
|
throw new \InvalidArgumentException('The given package is missing url information');
|
||||||
|
@ -295,7 +296,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
|
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
return \React\Promise\resolve();
|
return \React\Promise\resolve();
|
||||||
}
|
}
|
||||||
|
@ -303,7 +304,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
|
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
$fileName = $this->getFileName($package, $path);
|
$fileName = $this->getFileName($package, $path);
|
||||||
if (file_exists($fileName)) {
|
if (file_exists($fileName)) {
|
||||||
|
@ -323,7 +324,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($dirsToCleanUp as $dir) {
|
foreach ($dirsToCleanUp as $dir) {
|
||||||
if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
|
if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== Platform::getCwd()) {
|
||||||
$this->filesystem->removeDirectoryPhp($dir);
|
$this->filesystem->removeDirectoryPhp($dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +337,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
*
|
*
|
||||||
* @param bool $output
|
* @param bool $output
|
||||||
*/
|
*/
|
||||||
public function install(PackageInterface $package, $path, $output = true)
|
public function install(PackageInterface $package, string $path, bool $output = true)
|
||||||
{
|
{
|
||||||
if ($output) {
|
if ($output) {
|
||||||
$this->io->writeError(" - " . InstallOperation::format($package));
|
$this->io->writeError(" - " . InstallOperation::format($package));
|
||||||
|
@ -375,7 +376,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function addCleanupPath(PackageInterface $package, $path)
|
protected function addCleanupPath(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
$this->additionalCleanupPaths[$package->getName()][] = $path;
|
$this->additionalCleanupPaths[$package->getName()][] = $path;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +386,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function removeCleanupPath(PackageInterface $package, $path)
|
protected function removeCleanupPath(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
if (isset($this->additionalCleanupPaths[$package->getName()])) {
|
if (isset($this->additionalCleanupPaths[$package->getName()])) {
|
||||||
$idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
|
$idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
|
||||||
|
@ -398,7 +399,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function update(PackageInterface $initial, PackageInterface $target, $path)
|
public function update(PackageInterface $initial, PackageInterface $target, string $path)
|
||||||
{
|
{
|
||||||
$this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
|
$this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
|
||||||
|
|
||||||
|
@ -422,7 +423,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
*
|
*
|
||||||
* @param bool $output
|
* @param bool $output
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $path, $output = true)
|
public function remove(PackageInterface $package, string $path, bool $output = true)
|
||||||
{
|
{
|
||||||
if ($output) {
|
if ($output) {
|
||||||
$this->io->writeError(" - " . UninstallOperation::format($package));
|
$this->io->writeError(" - " . UninstallOperation::format($package));
|
||||||
|
@ -443,7 +444,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
* @param string $path download path
|
* @param string $path download path
|
||||||
* @return string file name
|
* @return string file name
|
||||||
*/
|
*/
|
||||||
protected function getFileName(PackageInterface $package, $path)
|
protected function getFileName(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
|
return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
|
||||||
}
|
}
|
||||||
|
@ -455,7 +456,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
* @param string $path download path
|
* @param string $path download path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getInstallOperationAppendix(PackageInterface $package, $path)
|
protected function getInstallOperationAppendix(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -468,7 +469,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
* @throws \RuntimeException If any problem with the url
|
* @throws \RuntimeException If any problem with the url
|
||||||
* @return string url
|
* @return string url
|
||||||
*/
|
*/
|
||||||
protected function processUrl(PackageInterface $package, $url)
|
protected function processUrl(PackageInterface $package, string $url)
|
||||||
{
|
{
|
||||||
if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
|
if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
|
||||||
throw new \RuntimeException('You must enable the openssl extension to download files via https');
|
throw new \RuntimeException('You must enable the openssl extension to download files via https');
|
||||||
|
@ -485,7 +486,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $targetDir)
|
public function getLocalChanges(PackageInterface $package, string $targetDir)
|
||||||
{
|
{
|
||||||
$prevIO = $this->io;
|
$prevIO = $this->io;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class FilesystemException extends \Exception
|
||||||
* @param int $code
|
* @param int $code
|
||||||
* @param \Exception|null $previous
|
* @param \Exception|null $previous
|
||||||
*/
|
*/
|
||||||
public function __construct($message = '', $code = 0, \Exception $previous = null)
|
public function __construct(string $message = '', int $code = 0, \Exception $previous = null)
|
||||||
{
|
{
|
||||||
parent::__construct("Filesystem exception: \n".$message, $code, $previous);
|
parent::__construct("Filesystem exception: \n".$message, $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class FossilDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||||
{
|
{
|
||||||
return \React\Promise\resolve();
|
return \React\Promise\resolve();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class FossilDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doInstall(PackageInterface $package, $path, $url): ?PromiseInterface
|
protected function doInstall(PackageInterface $package, string $path, string $url): ?PromiseInterface
|
||||||
{
|
{
|
||||||
// Ensure we are allowed to use this URL by config
|
// Ensure we are allowed to use this URL by config
|
||||||
$this->config->prohibitUrlByConfig($url, $this->io);
|
$this->config->prohibitUrlByConfig($url, $this->io);
|
||||||
|
@ -61,7 +61,7 @@ class FossilDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url): ?PromiseInterface
|
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): ?PromiseInterface
|
||||||
{
|
{
|
||||||
// Ensure we are allowed to use this URL by config
|
// Ensure we are allowed to use this URL by config
|
||||||
$this->config->prohibitUrlByConfig($url, $this->io);
|
$this->config->prohibitUrlByConfig($url, $this->io);
|
||||||
|
@ -84,7 +84,7 @@ class FossilDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $path): ?string
|
public function getLocalChanges(PackageInterface $package, string $path): ?string
|
||||||
{
|
{
|
||||||
if (!$this->hasMetadataRepository($path)) {
|
if (!$this->hasMetadataRepository($path)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -98,7 +98,7 @@ class FossilDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function getCommitLogs($fromReference, $toReference, $path): string
|
protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
|
||||||
{
|
{
|
||||||
$command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
|
$command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ class FossilDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function hasMetadataRepository($path): bool
|
protected function hasMetadataRepository(string $path): bool
|
||||||
{
|
{
|
||||||
return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
|
return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
|
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
GitUtil::cleanEnv();
|
GitUtil::cleanEnv();
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doInstall(PackageInterface $package, $path, $url)
|
protected function doInstall(PackageInterface $package, string $path, string $url)
|
||||||
{
|
{
|
||||||
GitUtil::cleanEnv();
|
GitUtil::cleanEnv();
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
@ -114,7 +114,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
|
|
||||||
$this->io->writeError($msg);
|
$this->io->writeError($msg);
|
||||||
|
|
||||||
$commandCallable = function ($url) use ($path, $command, $cachePath): string {
|
$commandCallable = function (string $url) use ($path, $command, $cachePath): string {
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
|
array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
|
||||||
array(
|
array(
|
||||||
|
@ -148,7 +148,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
|
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url)
|
||||||
{
|
{
|
||||||
GitUtil::cleanEnv();
|
GitUtil::cleanEnv();
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
@ -213,7 +213,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $path)
|
public function getLocalChanges(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
GitUtil::cleanEnv();
|
GitUtil::cleanEnv();
|
||||||
if (!$this->hasMetadataRepository($path)) {
|
if (!$this->hasMetadataRepository($path)) {
|
||||||
|
@ -231,7 +231,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public function getUnpushedChanges(PackageInterface $package, $path)
|
public function getUnpushedChanges(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
GitUtil::cleanEnv();
|
GitUtil::cleanEnv();
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
@ -328,7 +328,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function cleanChanges(PackageInterface $package, $path, $update)
|
protected function cleanChanges(PackageInterface $package, string $path, bool $update)
|
||||||
{
|
{
|
||||||
GitUtil::cleanEnv();
|
GitUtil::cleanEnv();
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
@ -415,7 +415,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function reapplyChanges($path)
|
protected function reapplyChanges(string $path)
|
||||||
{
|
{
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
if (!empty($this->hasStashedChanges[$path])) {
|
if (!empty($this->hasStashedChanges[$path])) {
|
||||||
|
@ -438,7 +438,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @return null|string if a string is returned, it is the commit reference that was checked out if the original could not be found
|
* @return null|string if a string is returned, it is the commit reference that was checked out if the original could not be found
|
||||||
*/
|
*/
|
||||||
protected function updateToCommit(PackageInterface $package, $path, $reference, $prettyVersion)
|
protected function updateToCommit(PackageInterface $package, string $path, string $reference, string $prettyVersion)
|
||||||
{
|
{
|
||||||
$force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
|
$force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function updateOriginUrl($path, $url)
|
protected function updateOriginUrl(string $path, string $url)
|
||||||
{
|
{
|
||||||
$this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
|
$this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
|
||||||
$this->setPushUrl($path, $url);
|
$this->setPushUrl($path, $url);
|
||||||
|
@ -517,7 +517,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function setPushUrl($path, $url)
|
protected function setPushUrl(string $path, string $url)
|
||||||
{
|
{
|
||||||
// set push url for github projects
|
// set push url for github projects
|
||||||
if (Preg::isMatch('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
|
if (Preg::isMatch('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
|
||||||
|
@ -534,7 +534,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function getCommitLogs($fromReference, $toReference, $path)
|
protected function getCommitLogs(string $fromReference, string $toReference, string $path)
|
||||||
{
|
{
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
$command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
|
$command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
|
||||||
|
@ -553,7 +553,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
protected function discardChanges($path)
|
protected function discardChanges(string $path)
|
||||||
{
|
{
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
|
if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
|
||||||
|
@ -572,7 +572,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
protected function stashChanges($path)
|
protected function stashChanges(string $path)
|
||||||
{
|
{
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
|
if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
|
||||||
|
@ -591,7 +591,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
protected function viewDiff($path)
|
protected function viewDiff(string $path)
|
||||||
{
|
{
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
|
if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
|
||||||
|
@ -606,7 +606,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function normalizePath($path)
|
protected function normalizePath(string $path)
|
||||||
{
|
{
|
||||||
if (Platform::isWindows() && strlen($path) > 0) {
|
if (Platform::isWindows() && strlen($path) > 0) {
|
||||||
$basePath = $path;
|
$basePath = $path;
|
||||||
|
@ -630,7 +630,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function hasMetadataRepository($path)
|
protected function hasMetadataRepository(string $path)
|
||||||
{
|
{
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
||||||
* @param string $reference
|
* @param string $reference
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getShortHash($reference)
|
protected function getShortHash(string $reference)
|
||||||
{
|
{
|
||||||
if (!$this->io->isVerbose() && Preg::isMatch('{^[0-9a-f]{40}$}', $reference)) {
|
if (!$this->io->isVerbose() && Preg::isMatch('{^[0-9a-f]{40}$}', $reference)) {
|
||||||
return substr($reference, 0, 10);
|
return substr($reference, 0, 10);
|
||||||
|
|
|
@ -24,7 +24,7 @@ use Composer\Util\ProcessExecutor;
|
||||||
*/
|
*/
|
||||||
class GzipDownloader extends ArchiveDownloader
|
class GzipDownloader extends ArchiveDownloader
|
||||||
{
|
{
|
||||||
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
|
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
|
$filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
|
||||||
$targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
|
$targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
|
||||||
|
@ -60,7 +60,7 @@ class GzipDownloader extends ArchiveDownloader
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function extractUsingExt($file, $targetFilepath): void
|
private function extractUsingExt(string $file, string $targetFilepath): void
|
||||||
{
|
{
|
||||||
$archiveFile = gzopen($file, 'rb');
|
$archiveFile = gzopen($file, 'rb');
|
||||||
$targetFile = fopen($targetFilepath, 'wb');
|
$targetFile = fopen($targetFilepath, 'wb');
|
||||||
|
|
|
@ -25,7 +25,7 @@ class HgDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||||
{
|
{
|
||||||
if (null === HgUtils::getVersion($this->process)) {
|
if (null === HgUtils::getVersion($this->process)) {
|
||||||
throw new \RuntimeException('hg was not found in your PATH, skipping source download');
|
throw new \RuntimeException('hg was not found in your PATH, skipping source download');
|
||||||
|
@ -37,11 +37,11 @@ class HgDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doInstall(PackageInterface $package, $path, $url): ?PromiseInterface
|
protected function doInstall(PackageInterface $package, string $path, string $url): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
||||||
|
|
||||||
$cloneCommand = function ($url) use ($path): string {
|
$cloneCommand = function (string $url) use ($path): string {
|
||||||
return sprintf('hg clone -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
|
return sprintf('hg clone -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class HgDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url): ?PromiseInterface
|
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class HgDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $path): ?string
|
public function getLocalChanges(PackageInterface $package, string $path): ?string
|
||||||
{
|
{
|
||||||
if (!is_dir($path.'/.hg')) {
|
if (!is_dir($path.'/.hg')) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -96,7 +96,7 @@ class HgDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function getCommitLogs($fromReference, $toReference, $path): string
|
protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
|
||||||
{
|
{
|
||||||
$command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
|
$command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class HgDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function hasMetadataRepository($path): bool
|
protected function hasMetadataRepository(string $path): bool
|
||||||
{
|
{
|
||||||
return is_dir($path . '/.hg');
|
return is_dir($path . '/.hg');
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true): ?PromiseInterface
|
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$path = Filesystem::trimTrailingSlash($path);
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
$url = $package->getDistUrl();
|
$url = $package->getDistUrl();
|
||||||
|
@ -75,7 +75,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function install(PackageInterface $package, $path, $output = true): ?PromiseInterface
|
public function install(PackageInterface $package, string $path, bool $output = true): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$path = Filesystem::trimTrailingSlash($path);
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
$url = $package->getDistUrl();
|
$url = $package->getDistUrl();
|
||||||
|
@ -113,7 +113,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
} else {
|
} else {
|
||||||
$absolutePath = $path;
|
$absolutePath = $path;
|
||||||
if (!$this->filesystem->isAbsolutePath($absolutePath)) {
|
if (!$this->filesystem->isAbsolutePath($absolutePath)) {
|
||||||
$absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
|
$absolutePath = Platform::getCwd() . DIRECTORY_SEPARATOR . $path;
|
||||||
}
|
}
|
||||||
$shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
|
$shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
|
||||||
$path = rtrim($path, "/");
|
$path = rtrim($path, "/");
|
||||||
|
@ -161,7 +161,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $path, $output = true): ?PromiseInterface
|
public function remove(PackageInterface $package, string $path, bool $output = true): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$path = Filesystem::trimTrailingSlash($path);
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
/**
|
/**
|
||||||
|
@ -190,8 +190,8 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
// not using realpath here as we do not want to resolve the symlink to the original dist url
|
// not using realpath here as we do not want to resolve the symlink to the original dist url
|
||||||
// it points to
|
// it points to
|
||||||
$fs = new Filesystem;
|
$fs = new Filesystem;
|
||||||
$absPath = $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path;
|
$absPath = $fs->isAbsolutePath($path) ? $path : Platform::getCwd() . '/' . $path;
|
||||||
$absDistUrl = $fs->isAbsolutePath($package->getDistUrl()) ? $package->getDistUrl() : getcwd() . '/' . $package->getDistUrl();
|
$absDistUrl = $fs->isAbsolutePath($package->getDistUrl()) ? $package->getDistUrl() : Platform::getCwd() . '/' . $package->getDistUrl();
|
||||||
if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) {
|
if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) {
|
||||||
if ($output) {
|
if ($output) {
|
||||||
$this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
|
$this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
|
||||||
|
@ -206,7 +206,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getVcsReference(PackageInterface $package, $path): ?string
|
public function getVcsReference(PackageInterface $package, string $path): ?string
|
||||||
{
|
{
|
||||||
$path = Filesystem::trimTrailingSlash($path);
|
$path = Filesystem::trimTrailingSlash($path);
|
||||||
$parser = new VersionParser;
|
$parser = new VersionParser;
|
||||||
|
@ -224,7 +224,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function getInstallOperationAppendix(PackageInterface $package, $path): string
|
protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
|
||||||
{
|
{
|
||||||
$realUrl = realpath($package->getDistUrl());
|
$realUrl = realpath($package->getDistUrl());
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||||
{
|
{
|
||||||
return \React\Promise\resolve();
|
return \React\Promise\resolve();
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function doInstall(PackageInterface $package, $path, $url): ?PromiseInterface
|
public function doInstall(PackageInterface $package, string $path, string $url): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$ref = $package->getSourceReference();
|
$ref = $package->getSourceReference();
|
||||||
$label = $this->getLabelFromSourceReference((string) $ref);
|
$label = $this->getLabelFromSourceReference((string) $ref);
|
||||||
|
@ -58,7 +58,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
private function getLabelFromSourceReference($ref): ?string
|
private function getLabelFromSourceReference(string $ref): ?string
|
||||||
{
|
{
|
||||||
$pos = strpos($ref, '@');
|
$pos = strpos($ref, '@');
|
||||||
if (false !== $pos) {
|
if (false !== $pos) {
|
||||||
|
@ -74,7 +74,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initPerforce(PackageInterface $package, $path, $url): void
|
public function initPerforce(PackageInterface $package, string $path, string $url): void
|
||||||
{
|
{
|
||||||
if (!empty($this->perforce)) {
|
if (!empty($this->perforce)) {
|
||||||
$this->perforce->initializePath($path);
|
$this->perforce->initializePath($path);
|
||||||
|
@ -101,7 +101,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url): ?PromiseInterface
|
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): ?PromiseInterface
|
||||||
{
|
{
|
||||||
return $this->doInstall($target, $path, $url);
|
return $this->doInstall($target, $path, $url);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $path): ?string
|
public function getLocalChanges(PackageInterface $package, string $path): ?string
|
||||||
{
|
{
|
||||||
$this->io->writeError('Perforce driver does not check for local changes before overriding');
|
$this->io->writeError('Perforce driver does not check for local changes before overriding');
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function getCommitLogs($fromReference, $toReference, $path): string
|
protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
|
||||||
{
|
{
|
||||||
return $this->perforce->getCommitLogs($fromReference, $toReference);
|
return $this->perforce->getCommitLogs($fromReference, $toReference);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function hasMetadataRepository($path): bool
|
protected function hasMetadataRepository(string $path): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class PharDownloader extends ArchiveDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
|
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||||
{
|
{
|
||||||
// Can throw an UnexpectedValueException
|
// Can throw an UnexpectedValueException
|
||||||
$archive = new \Phar($file);
|
$archive = new \Phar($file);
|
||||||
|
|
|
@ -28,7 +28,7 @@ use RarArchive;
|
||||||
*/
|
*/
|
||||||
class RarDownloader extends ArchiveDownloader
|
class RarDownloader extends ArchiveDownloader
|
||||||
{
|
{
|
||||||
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
|
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$processError = null;
|
$processError = null;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
|
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
SvnUtil::cleanEnv();
|
SvnUtil::cleanEnv();
|
||||||
$util = new SvnUtil($url, $this->io, $this->config, $this->process);
|
$util = new SvnUtil($url, $this->io, $this->config, $this->process);
|
||||||
|
@ -45,7 +45,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doInstall(PackageInterface $package, $path, $url)
|
protected function doInstall(PackageInterface $package, string $path, string $url)
|
||||||
{
|
{
|
||||||
SvnUtil::cleanEnv();
|
SvnUtil::cleanEnv();
|
||||||
$ref = $package->getSourceReference();
|
$ref = $package->getSourceReference();
|
||||||
|
@ -67,7 +67,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
|
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url)
|
||||||
{
|
{
|
||||||
SvnUtil::cleanEnv();
|
SvnUtil::cleanEnv();
|
||||||
$ref = $target->getSourceReference();
|
$ref = $target->getSourceReference();
|
||||||
|
@ -91,7 +91,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $path)
|
public function getLocalChanges(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
if (!$this->hasMetadataRepository($path)) {
|
if (!$this->hasMetadataRepository($path)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -114,7 +114,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
|
protected function execute(PackageInterface $package, string $baseUrl, string $command, string $url, string $cwd = null, string $path = null)
|
||||||
{
|
{
|
||||||
$util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
|
$util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
|
||||||
$util->setCacheCredentials($this->cacheCredentials);
|
$util->setCacheCredentials($this->cacheCredentials);
|
||||||
|
@ -130,7 +130,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function cleanChanges(PackageInterface $package, $path, $update)
|
protected function cleanChanges(PackageInterface $package, string $path, bool $update)
|
||||||
{
|
{
|
||||||
if (!$changes = $this->getLocalChanges($package, $path)) {
|
if (!$changes = $this->getLocalChanges($package, $path)) {
|
||||||
return \React\Promise\resolve();
|
return \React\Promise\resolve();
|
||||||
|
@ -191,7 +191,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function getCommitLogs($fromReference, $toReference, $path)
|
protected function getCommitLogs(string $fromReference, string $toReference, string $path)
|
||||||
{
|
{
|
||||||
if (Preg::isMatch('{@(\d+)$}', $fromReference) && Preg::isMatch('{@(\d+)$}', $toReference)) {
|
if (Preg::isMatch('{@(\d+)$}', $fromReference) && Preg::isMatch('{@(\d+)$}', $toReference)) {
|
||||||
// retrieve the svn base url from the checkout folder
|
// retrieve the svn base url from the checkout folder
|
||||||
|
@ -236,7 +236,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
*
|
*
|
||||||
* @return PromiseInterface
|
* @return PromiseInterface
|
||||||
*/
|
*/
|
||||||
protected function discardChanges($path)
|
protected function discardChanges(string $path)
|
||||||
{
|
{
|
||||||
if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
|
if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
|
||||||
throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
|
throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
|
||||||
|
@ -248,7 +248,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function hasMetadataRepository($path)
|
protected function hasMetadataRepository(string $path)
|
||||||
{
|
{
|
||||||
return is_dir($path.'/.svn');
|
return is_dir($path.'/.svn');
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TarDownloader extends ArchiveDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function extract(PackageInterface $package, $file, $path)
|
protected function extract(PackageInterface $package, string $file, string $path)
|
||||||
{
|
{
|
||||||
// Can throw an UnexpectedValueException
|
// Can throw an UnexpectedValueException
|
||||||
$archive = new \PharData($file);
|
$archive = new \PharData($file);
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TransportException extends \RuntimeException
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setHeaders($headers): void
|
public function setHeaders(array $headers): void
|
||||||
{
|
{
|
||||||
$this->headers = $headers;
|
$this->headers = $headers;
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ class TransportException extends \RuntimeException
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ?string $response
|
* @param null|string $response
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setResponse($response): void
|
public function setResponse(?string $response): void
|
||||||
{
|
{
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,5 +28,5 @@ interface VcsCapableDownloaderInterface
|
||||||
* @param string $path package directory
|
* @param string $path package directory
|
||||||
* @return string|null reference or null
|
* @return string|null reference or null
|
||||||
*/
|
*/
|
||||||
public function getVcsReference(PackageInterface $package, $path);
|
public function getVcsReference(PackageInterface $package, string $path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
|
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
if (!$package->getSourceReference()) {
|
if (!$package->getSourceReference()) {
|
||||||
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
||||||
|
@ -93,7 +93,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
|
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
if ($type === 'update') {
|
if ($type === 'update') {
|
||||||
$this->cleanChanges($prevPackage, $path, true);
|
$this->cleanChanges($prevPackage, $path, true);
|
||||||
|
@ -110,7 +110,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
|
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||||
{
|
{
|
||||||
if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
|
if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
|
||||||
$this->reapplyChanges($path);
|
$this->reapplyChanges($path);
|
||||||
|
@ -123,7 +123,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function install(PackageInterface $package, $path)
|
public function install(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
if (!$package->getSourceReference()) {
|
if (!$package->getSourceReference()) {
|
||||||
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
||||||
|
@ -158,7 +158,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function update(PackageInterface $initial, PackageInterface $target, $path)
|
public function update(PackageInterface $initial, PackageInterface $target, string $path)
|
||||||
{
|
{
|
||||||
if (!$target->getSourceReference()) {
|
if (!$target->getSourceReference()) {
|
||||||
throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
|
throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
|
||||||
|
@ -194,12 +194,12 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
$message = 'Pulling in changes:';
|
$message = 'Pulling in changes:';
|
||||||
$logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
|
$logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
|
||||||
|
|
||||||
if (!trim($logs)) {
|
if ('' === trim($logs)) {
|
||||||
$message = 'Rolling back changes:';
|
$message = 'Rolling back changes:';
|
||||||
$logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
|
$logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($logs)) {
|
if ('' !== trim($logs)) {
|
||||||
$logs = implode("\n", array_map(function ($line): string {
|
$logs = implode("\n", array_map(function ($line): string {
|
||||||
return ' ' . $line;
|
return ' ' . $line;
|
||||||
}, explode("\n", $logs)));
|
}, explode("\n", $logs)));
|
||||||
|
@ -222,13 +222,13 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $path)
|
public function remove(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
$this->io->writeError(" - " . UninstallOperation::format($package));
|
$this->io->writeError(" - " . UninstallOperation::format($package));
|
||||||
|
|
||||||
$promise = $this->filesystem->removeDirectoryAsync($path);
|
$promise = $this->filesystem->removeDirectoryAsync($path);
|
||||||
|
|
||||||
return $promise->then(function ($result) use ($path) {
|
return $promise->then(function (bool $result) use ($path) {
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
|
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getVcsReference(PackageInterface $package, $path)
|
public function getVcsReference(PackageInterface $package, string $path)
|
||||||
{
|
{
|
||||||
$parser = new VersionParser;
|
$parser = new VersionParser;
|
||||||
$guesser = new VersionGuesser($this->config, $this->process, $parser);
|
$guesser = new VersionGuesser($this->config, $this->process, $parser);
|
||||||
|
@ -264,7 +264,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException in case the operation must be aborted
|
* @throws \RuntimeException in case the operation must be aborted
|
||||||
*/
|
*/
|
||||||
protected function cleanChanges(PackageInterface $package, $path, $update)
|
protected function cleanChanges(PackageInterface $package, string $path, bool $update)
|
||||||
{
|
{
|
||||||
// the default implementation just fails if there are any changes, override in child classes to provide stash-ability
|
// the default implementation just fails if there are any changes, override in child classes to provide stash-ability
|
||||||
if (null !== $this->getLocalChanges($package, $path)) {
|
if (null !== $this->getLocalChanges($package, $path)) {
|
||||||
|
@ -283,7 +283,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException in case the operation must be aborted or the patch does not apply cleanly
|
* @throws \RuntimeException in case the operation must be aborted or the patch does not apply cleanly
|
||||||
*/
|
*/
|
||||||
protected function reapplyChanges($path)
|
protected function reapplyChanges(string $path)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
*
|
*
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
|
abstract protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads specific package into specific folder.
|
* Downloads specific package into specific folder.
|
||||||
|
@ -308,7 +308,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
*
|
*
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
abstract protected function doInstall(PackageInterface $package, $path, $url);
|
abstract protected function doInstall(PackageInterface $package, string $path, string $url);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates specific package in specific folder from initial to target version.
|
* Updates specific package in specific folder from initial to target version.
|
||||||
|
@ -320,7 +320,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
*
|
*
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
|
abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the commit logs between two commits
|
* Fetches the commit logs between two commits
|
||||||
|
@ -330,7 +330,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
* @param string $path the package path
|
* @param string $path the package path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function getCommitLogs($fromReference, $toReference, $path);
|
abstract protected function getCommitLogs(string $fromReference, string $toReference, string $path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if VCS metadata repository has been initialized
|
* Checks if VCS metadata repository has been initialized
|
||||||
|
@ -339,7 +339,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
abstract protected function hasMetadataRepository($path);
|
abstract protected function hasMetadataRepository(string $path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $urls
|
* @param string[] $urls
|
||||||
|
|
|
@ -24,7 +24,7 @@ use Composer\Util\ProcessExecutor;
|
||||||
*/
|
*/
|
||||||
class XzDownloader extends ArchiveDownloader
|
class XzDownloader extends ArchiveDownloader
|
||||||
{
|
{
|
||||||
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
|
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||||
{
|
{
|
||||||
$command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
|
$command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ use Composer\Util\IniHelper;
|
||||||
use Composer\Util\Platform;
|
use Composer\Util\Platform;
|
||||||
use Composer\Util\ProcessExecutor;
|
use Composer\Util\ProcessExecutor;
|
||||||
use Symfony\Component\Process\ExecutableFinder;
|
use Symfony\Component\Process\ExecutableFinder;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
use React\Promise\PromiseInterface;
|
use React\Promise\PromiseInterface;
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
|
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true)
|
||||||
{
|
{
|
||||||
if (null === self::$unzipCommands) {
|
if (null === self::$unzipCommands) {
|
||||||
self::$unzipCommands = array();
|
self::$unzipCommands = array();
|
||||||
|
@ -105,7 +106,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
* @param string $path Path where to extract file
|
* @param string $path Path where to extract file
|
||||||
* @return PromiseInterface
|
* @return PromiseInterface
|
||||||
*/
|
*/
|
||||||
private function extractWithSystemUnzip(PackageInterface $package, $file, $path): PromiseInterface
|
private function extractWithSystemUnzip(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||||
{
|
{
|
||||||
// Force Exception throwing if the other alternative extraction method is not available
|
// Force Exception throwing if the other alternative extraction method is not available
|
||||||
$isLastChance = !self::$hasZipArchive;
|
$isLastChance = !self::$hasZipArchive;
|
||||||
|
@ -127,7 +128,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
$executable = $commandSpec[0];
|
$executable = $commandSpec[0];
|
||||||
|
|
||||||
$io = $this->io;
|
$io = $this->io;
|
||||||
$tryFallback = function ($processError) use ($isLastChance, $io, $file, $path, $package, $executable): \React\Promise\PromiseInterface {
|
$tryFallback = function (\Throwable $processError) use ($isLastChance, $io, $file, $path, $package, $executable): \React\Promise\PromiseInterface {
|
||||||
if ($isLastChance) {
|
if ($isLastChance) {
|
||||||
throw $processError;
|
throw $processError;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
try {
|
try {
|
||||||
$promise = $this->process->executeAsync($command);
|
$promise = $this->process->executeAsync($command);
|
||||||
|
|
||||||
return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) {
|
return $promise->then(function (Process $process) use ($tryFallback, $command, $package, $file) {
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
if (isset($this->cleanupExecuted[$package->getName()])) {
|
if (isset($this->cleanupExecuted[$package->getName()])) {
|
||||||
throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
|
throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
|
||||||
|
@ -172,7 +173,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
* @param string $path Path where to extract file
|
* @param string $path Path where to extract file
|
||||||
* @return PromiseInterface
|
* @return PromiseInterface
|
||||||
*/
|
*/
|
||||||
private function extractWithZipArchive(PackageInterface $package, $file, $path): PromiseInterface
|
private function extractWithZipArchive(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||||
{
|
{
|
||||||
$processError = null;
|
$processError = null;
|
||||||
$zipArchive = $this->zipArchiveObject ?: new ZipArchive();
|
$zipArchive = $this->zipArchiveObject ?: new ZipArchive();
|
||||||
|
@ -207,7 +208,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
* @param string $path Path where to extract file
|
* @param string $path Path where to extract file
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
protected function extract(PackageInterface $package, $file, $path)
|
protected function extract(PackageInterface $package, string $file, string $path)
|
||||||
{
|
{
|
||||||
return $this->extractWithSystemUnzip($package, $file, $path);
|
return $this->extractWithSystemUnzip($package, $file, $path);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +220,7 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getErrorMessage($retval, $file)
|
protected function getErrorMessage(int $retval, string $file): string
|
||||||
{
|
{
|
||||||
switch ($retval) {
|
switch ($retval) {
|
||||||
case ZipArchive::ER_EXISTS:
|
case ZipArchive::ER_EXISTS:
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Event
|
||||||
* @param string[] $args Arguments passed by the user
|
* @param string[] $args Arguments passed by the user
|
||||||
* @param mixed[] $flags Optional flags to pass data not as argument
|
* @param mixed[] $flags Optional flags to pass data not as argument
|
||||||
*/
|
*/
|
||||||
public function __construct($name, array $args = array(), array $flags = array())
|
public function __construct(string $name, array $args = array(), array $flags = array())
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->args = $args;
|
$this->args = $args;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
namespace Composer\EventDispatcher;
|
namespace Composer\EventDispatcher;
|
||||||
|
|
||||||
use Composer\Autoload\AutoloadGenerator;
|
|
||||||
use Composer\DependencyResolver\Transaction;
|
use Composer\DependencyResolver\Transaction;
|
||||||
use Composer\Installer\InstallerEvent;
|
use Composer\Installer\InstallerEvent;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
|
@ -82,7 +81,7 @@ class EventDispatcher
|
||||||
* @param bool $runScripts
|
* @param bool $runScripts
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setRunScripts($runScripts = true)
|
public function setRunScripts(bool $runScripts = true)
|
||||||
{
|
{
|
||||||
$this->runScripts = (bool) $runScripts;
|
$this->runScripts = (bool) $runScripts;
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ class EventDispatcher
|
||||||
* @return int return code of the executed script if any, for php scripts a false return
|
* @return int return code of the executed script if any, for php scripts a false return
|
||||||
* value is changed to 1, anything else to 0
|
* value is changed to 1, anything else to 0
|
||||||
*/
|
*/
|
||||||
public function dispatch($eventName, Event $event = null)
|
public function dispatch(string $eventName, Event $event = null)
|
||||||
{
|
{
|
||||||
if (null === $event) {
|
if (null === $event) {
|
||||||
$event = new Event($eventName);
|
$event = new Event($eventName);
|
||||||
|
@ -116,7 +115,7 @@ class EventDispatcher
|
||||||
* @return int return code of the executed script if any, for php scripts a false return
|
* @return int return code of the executed script if any, for php scripts a false return
|
||||||
* value is changed to 1, anything else to 0
|
* value is changed to 1, anything else to 0
|
||||||
*/
|
*/
|
||||||
public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
|
public function dispatchScript(string $eventName, bool $devMode = false, array $additionalArgs = array(), array $flags = array())
|
||||||
{
|
{
|
||||||
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ class EventDispatcher
|
||||||
* @return int return code of the executed script if any, for php scripts a false return
|
* @return int return code of the executed script if any, for php scripts a false return
|
||||||
* value is changed to 1, anything else to 0
|
* value is changed to 1, anything else to 0
|
||||||
*/
|
*/
|
||||||
public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
|
public function dispatchPackageEvent(string $eventName, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
|
||||||
{
|
{
|
||||||
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
||||||
|
|
||||||
|
@ -153,7 +152,7 @@ class EventDispatcher
|
||||||
* @return int return code of the executed script if any, for php scripts a false return
|
* @return int return code of the executed script if any, for php scripts a false return
|
||||||
* value is changed to 1, anything else to 0
|
* value is changed to 1, anything else to 0
|
||||||
*/
|
*/
|
||||||
public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
|
public function dispatchInstallerEvent(string $eventName, bool $devMode, bool $executeOperations, Transaction $transaction)
|
||||||
{
|
{
|
||||||
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
||||||
|
|
||||||
|
@ -343,7 +342,7 @@ class EventDispatcher
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
protected function executeTty($exec)
|
protected function executeTty(string $exec)
|
||||||
{
|
{
|
||||||
if ($this->io->isInteractive()) {
|
if ($this->io->isInteractive()) {
|
||||||
return $this->process->executeTty($exec);
|
return $this->process->executeTty($exec);
|
||||||
|
@ -378,7 +377,7 @@ class EventDispatcher
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function executeEventPhpScript($className, $methodName, Event $event)
|
protected function executeEventPhpScript(string $className, string $methodName, Event $event)
|
||||||
{
|
{
|
||||||
if ($this->io->isVerbose()) {
|
if ($this->io->isVerbose()) {
|
||||||
$this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
|
$this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
|
||||||
|
@ -398,7 +397,7 @@ class EventDispatcher
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addListener($eventName, $listener, $priority = 0)
|
public function addListener(string $eventName, callable $listener, int $priority = 0)
|
||||||
{
|
{
|
||||||
$this->listeners[$eventName][$priority][] = $listener;
|
$this->listeners[$eventName][$priority][] = $listener;
|
||||||
}
|
}
|
||||||
|
@ -520,7 +519,7 @@ class EventDispatcher
|
||||||
* @param string $callable
|
* @param string $callable
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isPhpScript($callable)
|
protected function isPhpScript(string $callable)
|
||||||
{
|
{
|
||||||
return false === strpos($callable, ' ') && false !== strpos($callable, '::');
|
return false === strpos($callable, ' ') && false !== strpos($callable, '::');
|
||||||
}
|
}
|
||||||
|
@ -531,7 +530,7 @@ class EventDispatcher
|
||||||
* @param string $callable
|
* @param string $callable
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isComposerScript($callable)
|
protected function isComposerScript(string $callable)
|
||||||
{
|
{
|
||||||
return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
|
return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ class Factory
|
||||||
|
|
||||||
public static function createConfig(IOInterface $io = null, ?string $cwd = null): Config
|
public static function createConfig(IOInterface $io = null, ?string $cwd = null): Config
|
||||||
{
|
{
|
||||||
$cwd = $cwd ?: (string) getcwd();
|
$cwd = $cwd ?? Platform::getCwd(true);
|
||||||
|
|
||||||
$config = new Config(true, $cwd);
|
$config = new Config(true, $cwd);
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ class Factory
|
||||||
*/
|
*/
|
||||||
public function createComposer(IOInterface $io, $localConfig = null, bool $disablePlugins = false, ?string $cwd = null, bool $fullLoad = true, bool $disableScripts = false)
|
public function createComposer(IOInterface $io, $localConfig = null, bool $disablePlugins = false, ?string $cwd = null, bool $fullLoad = true, bool $disableScripts = false)
|
||||||
{
|
{
|
||||||
$cwd = $cwd ?: (string) getcwd();
|
$cwd = $cwd ?? Platform::getCwd(true);
|
||||||
|
|
||||||
// load Composer configuration
|
// load Composer configuration
|
||||||
if (null === $localConfig) {
|
if (null === $localConfig) {
|
||||||
|
@ -454,7 +454,7 @@ class Factory
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage, ProcessExecutor $process = null): void
|
protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, string $vendorDir, RootPackageInterface $rootPackage, ProcessExecutor $process = null): void
|
||||||
{
|
{
|
||||||
$fs = null;
|
$fs = null;
|
||||||
if ($process) {
|
if ($process) {
|
||||||
|
@ -621,7 +621,7 @@ class Factory
|
||||||
* @param mixed[] $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()): HttpDownloader
|
public static function createHttpDownloader(IOInterface $io, Config $config, array $options = array()): HttpDownloader
|
||||||
{
|
{
|
||||||
static $warned = false;
|
static $warned = false;
|
||||||
$disableTls = false;
|
$disableTls = false;
|
||||||
|
|
|
@ -20,7 +20,7 @@ final class IgnoreAllPlatformRequirementFilter implements PlatformRequirementFil
|
||||||
* @param string $req
|
* @param string $req
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isIgnored($req): bool
|
public function isIgnored(string $req): bool
|
||||||
{
|
{
|
||||||
return PlatformRepository::isPlatformPackage($req);
|
return PlatformRepository::isPlatformPackage($req);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFi
|
||||||
* @param string $req
|
* @param string $req
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isIgnored($req): bool
|
public function isIgnored(string $req): bool
|
||||||
{
|
{
|
||||||
if (!PlatformRepository::isPlatformPackage($req)) {
|
if (!PlatformRepository::isPlatformPackage($req)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -68,7 +68,7 @@ final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFi
|
||||||
* @param string $req
|
* @param string $req
|
||||||
* @return ConstraintInterface
|
* @return ConstraintInterface
|
||||||
*/
|
*/
|
||||||
public function filterConstraint($req, ConstraintInterface $constraint): ConstraintInterface
|
public function filterConstraint(string $req, ConstraintInterface $constraint): ConstraintInterface
|
||||||
{
|
{
|
||||||
if (!PlatformRepository::isPlatformPackage($req)) {
|
if (!PlatformRepository::isPlatformPackage($req)) {
|
||||||
return $constraint;
|
return $constraint;
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class IgnoreNothingPlatformRequirementFilter implements PlatformRequiremen
|
||||||
* @param string $req
|
* @param string $req
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
public function isIgnored($req): bool
|
public function isIgnored(string $req): bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,5 +18,5 @@ interface PlatformRequirementFilterInterface
|
||||||
* @param string $req
|
* @param string $req
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isIgnored($req): bool;
|
public function isIgnored(string $req): bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ abstract class BaseIO implements IOInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->write($messages, $newline, $verbosity);
|
$this->write($messages, $newline, $verbosity);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ abstract class BaseIO implements IOInterface
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->writeError($messages, $newline, $verbosity);
|
$this->writeError($messages, $newline, $verbosity);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ abstract class BaseIO implements IOInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
|
protected function checkAndSetAuthentication(string $repositoryName, string $username, string $password = null)
|
||||||
{
|
{
|
||||||
if ($this->hasAuthentication($repositoryName)) {
|
if ($this->hasAuthentication($repositoryName)) {
|
||||||
$auth = $this->getAuthentication($repositoryName);
|
$auth = $this->getAuthentication($repositoryName);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BufferIO extends ConsoleIO
|
||||||
* @param int $verbosity
|
* @param int $verbosity
|
||||||
* @param OutputFormatterInterface|null $formatter
|
* @param OutputFormatterInterface|null $formatter
|
||||||
*/
|
*/
|
||||||
public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
|
public function __construct(string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
|
||||||
{
|
{
|
||||||
$input = new StringInput($input);
|
$input = new StringInput($input);
|
||||||
$input->setInteractive(false);
|
$input->setInteractive(false);
|
||||||
|
|
|
@ -71,7 +71,7 @@ class ConsoleIO extends BaseIO
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function enableDebugging($startTime)
|
public function enableDebugging(float $startTime)
|
||||||
{
|
{
|
||||||
$this->startTime = $startTime;
|
$this->startTime = $startTime;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class ConsoleIO extends BaseIO
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function write($messages, $newline = true, $verbosity = self::NORMAL)
|
public function write($messages, bool $newline = true, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->doWrite($messages, $newline, false, $verbosity);
|
$this->doWrite($messages, $newline, false, $verbosity);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ class ConsoleIO extends BaseIO
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
|
public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->doWrite($messages, $newline, true, $verbosity);
|
$this->doWrite($messages, $newline, true, $verbosity);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class ConsoleIO extends BaseIO
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->doWrite($messages, $newline, false, $verbosity, true);
|
$this->doWrite($messages, $newline, false, $verbosity, true);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ class ConsoleIO extends BaseIO
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->doWrite($messages, $newline, true, $verbosity, true);
|
$this->doWrite($messages, $newline, true, $verbosity, true);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ class ConsoleIO extends BaseIO
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false): void
|
private function doWrite($messages, bool $newline, bool $stderr, int $verbosity, bool $raw = false): void
|
||||||
{
|
{
|
||||||
$sfVerbosity = $this->verbosityMap[$verbosity];
|
$sfVerbosity = $this->verbosityMap[$verbosity];
|
||||||
if ($sfVerbosity > $this->output->getVerbosity()) {
|
if ($sfVerbosity > $this->output->getVerbosity()) {
|
||||||
|
@ -194,7 +194,7 @@ class ConsoleIO extends BaseIO
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
|
public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->doOverwrite($messages, $newline, $size, false, $verbosity);
|
$this->doOverwrite($messages, $newline, $size, false, $verbosity);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ class ConsoleIO extends BaseIO
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
|
public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
|
||||||
{
|
{
|
||||||
$this->doOverwrite($messages, $newline, $size, true, $verbosity);
|
$this->doOverwrite($messages, $newline, $size, true, $verbosity);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ class ConsoleIO extends BaseIO
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function doOverwrite($messages, $newline, $size, $stderr, $verbosity): void
|
private function doOverwrite($messages, bool $newline, ?int $size, bool $stderr, int $verbosity): void
|
||||||
{
|
{
|
||||||
// messages can be an array, let's convert it to string anyway
|
// messages can be an array, let's convert it to string anyway
|
||||||
$messages = implode($newline ? "\n" : '', (array) $messages);
|
$messages = implode($newline ? "\n" : '', (array) $messages);
|
||||||
|
@ -258,7 +258,7 @@ class ConsoleIO extends BaseIO
|
||||||
* @param int $max
|
* @param int $max
|
||||||
* @return ProgressBar
|
* @return ProgressBar
|
||||||
*/
|
*/
|
||||||
public function getProgressBar($max = 0)
|
public function getProgressBar(int $max = 0)
|
||||||
{
|
{
|
||||||
return new ProgressBar($this->getErrorOutput(), $max);
|
return new ProgressBar($this->getErrorOutput(), $max);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function write($messages, $newline = true, $verbosity = self::NORMAL);
|
public function write($messages, bool $newline = true, int $verbosity = self::NORMAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a message to the error output.
|
* Writes a message to the error output.
|
||||||
|
@ -83,7 +83,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
|
public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a message to the output, without formatting it.
|
* Writes a message to the output, without formatting it.
|
||||||
|
@ -94,7 +94,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
|
public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a message to the error output, without formatting it.
|
* Writes a message to the error output, without formatting it.
|
||||||
|
@ -105,7 +105,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
|
public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrites a previous message to the output.
|
* Overwrites a previous message to the output.
|
||||||
|
@ -117,7 +117,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
|
public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrites a previous message to the error output.
|
* Overwrites a previous message to the error output.
|
||||||
|
@ -129,7 +129,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
|
public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks a question to the user.
|
* Asks a question to the user.
|
||||||
|
@ -140,7 +140,7 @@ interface IOInterface extends LoggerInterface
|
||||||
* @throws \RuntimeException If there is no data to read in the input stream
|
* @throws \RuntimeException If there is no data to read in the input stream
|
||||||
* @return mixed The user answer
|
* @return mixed The user answer
|
||||||
*/
|
*/
|
||||||
public function ask($question, $default = null);
|
public function ask(string $question, $default = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks a confirmation to the user.
|
* Asks a confirmation to the user.
|
||||||
|
@ -152,7 +152,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return bool true if the user has confirmed, false otherwise
|
* @return bool true if the user has confirmed, false otherwise
|
||||||
*/
|
*/
|
||||||
public function askConfirmation($question, $default = true);
|
public function askConfirmation(string $question, bool $default = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks for a value and validates the response.
|
* Asks for a value and validates the response.
|
||||||
|
@ -169,7 +169,7 @@ interface IOInterface extends LoggerInterface
|
||||||
* @throws \Exception When any of the validators return an error
|
* @throws \Exception When any of the validators return an error
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function askAndValidate($question, $validator, $attempts = null, $default = null);
|
public function askAndValidate(string $question, callable $validator, ?int $attempts = null, $default = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks a question to the user and hide the answer.
|
* Asks a question to the user and hide the answer.
|
||||||
|
@ -178,7 +178,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return string|null The answer
|
* @return string|null The answer
|
||||||
*/
|
*/
|
||||||
public function askAndHideAnswer($question);
|
public function askAndHideAnswer(string $question);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks the user to select a value.
|
* Asks the user to select a value.
|
||||||
|
@ -193,7 +193,7 @@ interface IOInterface extends LoggerInterface
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return int|string|string[]|bool The selected value or values (the key of the choices array)
|
* @return int|string|string[]|bool The selected value or values (the key of the choices array)
|
||||||
*/
|
*/
|
||||||
public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
|
public function select(string $question, array $choices, $default, $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all authentication information entered.
|
* Get all authentication information entered.
|
||||||
|
@ -209,7 +209,7 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasAuthentication($repositoryName);
|
public function hasAuthentication(string $repositoryName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the username and password of repository.
|
* Get the username and password of repository.
|
||||||
|
@ -218,18 +218,18 @@ interface IOInterface extends LoggerInterface
|
||||||
*
|
*
|
||||||
* @return array{username: string|null, password: string|null}
|
* @return array{username: string|null, password: string|null}
|
||||||
*/
|
*/
|
||||||
public function getAuthentication($repositoryName);
|
public function getAuthentication(string $repositoryName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the authentication information for the repository.
|
* Set the authentication information for the repository.
|
||||||
*
|
*
|
||||||
* @param string $repositoryName The unique name of repository
|
* @param string $repositoryName The unique name of repository
|
||||||
* @param string $username The username
|
* @param string $username The username
|
||||||
* @param ?string $password The password
|
* @param null|string $password The password
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setAuthentication($repositoryName, $username, $password = null);
|
public function setAuthentication(string $repositoryName, string $username, ?string $password = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads authentications from a config instance
|
* Loads authentications from a config instance
|
||||||
|
|
|
@ -62,28 +62,28 @@ class NullIO extends BaseIO
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function write($messages, $newline = true, $verbosity = self::NORMAL): void
|
public function write($messages, bool $newline = true, int $verbosity = self::NORMAL): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function writeError($messages, $newline = true, $verbosity = self::NORMAL): void
|
public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL): void
|
public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL): void
|
public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ class Installer
|
||||||
* @return int
|
* @return int
|
||||||
* @phpstan-return self::ERROR_*
|
* @phpstan-return self::ERROR_*
|
||||||
*/
|
*/
|
||||||
protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall): int
|
protected function doUpdate(InstalledRepositoryInterface $localRepo, bool $doInstall): int
|
||||||
{
|
{
|
||||||
$platformRepo = $this->createPlatformRepo(true);
|
$platformRepo = $this->createPlatformRepo(true);
|
||||||
$aliases = $this->getRootAliases(true);
|
$aliases = $this->getRootAliases(true);
|
||||||
|
@ -648,7 +648,7 @@ class Installer
|
||||||
* @return int exit code
|
* @return int exit code
|
||||||
* @phpstan-return self::ERROR_*
|
* @phpstan-return self::ERROR_*
|
||||||
*/
|
*/
|
||||||
protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false): int
|
protected function doInstall(InstalledRepositoryInterface $localRepo, bool $alreadySolved = false): int
|
||||||
{
|
{
|
||||||
$this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
|
$this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ class Installer
|
||||||
*
|
*
|
||||||
* @return PlatformRepository
|
* @return PlatformRepository
|
||||||
*/
|
*/
|
||||||
protected function createPlatformRepo($forUpdate): PlatformRepository
|
protected function createPlatformRepo(bool $forUpdate): PlatformRepository
|
||||||
{
|
{
|
||||||
if ($forUpdate) {
|
if ($forUpdate) {
|
||||||
$platformOverrides = $this->config->get('platform') ?: array();
|
$platformOverrides = $this->config->get('platform') ?: array();
|
||||||
|
@ -789,7 +789,7 @@ class Installer
|
||||||
*
|
*
|
||||||
* @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $rootAliases
|
* @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): RepositorySet
|
private function createRepositorySet(bool $forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), ?RepositoryInterface $lockedRepository = null): RepositorySet
|
||||||
{
|
{
|
||||||
if ($forUpdate) {
|
if ($forUpdate) {
|
||||||
$minimumStability = $this->package->getMinimumStability();
|
$minimumStability = $this->package->getMinimumStability();
|
||||||
|
@ -858,7 +858,7 @@ class Installer
|
||||||
*
|
*
|
||||||
* @return DefaultPolicy
|
* @return DefaultPolicy
|
||||||
*/
|
*/
|
||||||
private function createPolicy($forUpdate): DefaultPolicy
|
private function createPolicy(bool $forUpdate): DefaultPolicy
|
||||||
{
|
{
|
||||||
$preferStable = null;
|
$preferStable = null;
|
||||||
$preferLowest = null;
|
$preferLowest = null;
|
||||||
|
@ -919,7 +919,7 @@ class Installer
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true): void
|
private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, bool $includeDevRequires = true): void
|
||||||
{
|
{
|
||||||
// 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
|
||||||
if ($this->updateMirrors) {
|
if ($this->updateMirrors) {
|
||||||
|
@ -953,7 +953,7 @@ class Installer
|
||||||
*
|
*
|
||||||
* @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}>
|
* @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}>
|
||||||
*/
|
*/
|
||||||
private function getRootAliases($forUpdate): array
|
private function getRootAliases(bool $forUpdate): array
|
||||||
{
|
{
|
||||||
if ($forUpdate) {
|
if ($forUpdate) {
|
||||||
$aliases = $this->package->getAliases();
|
$aliases = $this->package->getAliases();
|
||||||
|
@ -1062,7 +1062,7 @@ class Installer
|
||||||
* @param bool $dryRun
|
* @param bool $dryRun
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setDryRun($dryRun = true): Installer
|
public function setDryRun(bool $dryRun = true): Installer
|
||||||
{
|
{
|
||||||
$this->dryRun = (bool) $dryRun;
|
$this->dryRun = (bool) $dryRun;
|
||||||
|
|
||||||
|
@ -1085,7 +1085,7 @@ class Installer
|
||||||
* @param bool $preferSource
|
* @param bool $preferSource
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setPreferSource($preferSource = true): Installer
|
public function setPreferSource(bool $preferSource = true): Installer
|
||||||
{
|
{
|
||||||
$this->preferSource = (bool) $preferSource;
|
$this->preferSource = (bool) $preferSource;
|
||||||
|
|
||||||
|
@ -1098,7 +1098,7 @@ class Installer
|
||||||
* @param bool $preferDist
|
* @param bool $preferDist
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setPreferDist($preferDist = true): Installer
|
public function setPreferDist(bool $preferDist = true): Installer
|
||||||
{
|
{
|
||||||
$this->preferDist = (bool) $preferDist;
|
$this->preferDist = (bool) $preferDist;
|
||||||
|
|
||||||
|
@ -1111,7 +1111,7 @@ class Installer
|
||||||
* @param bool $optimizeAutoloader
|
* @param bool $optimizeAutoloader
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setOptimizeAutoloader($optimizeAutoloader): Installer
|
public function setOptimizeAutoloader(bool $optimizeAutoloader): Installer
|
||||||
{
|
{
|
||||||
$this->optimizeAutoloader = (bool) $optimizeAutoloader;
|
$this->optimizeAutoloader = (bool) $optimizeAutoloader;
|
||||||
if (!$this->optimizeAutoloader) {
|
if (!$this->optimizeAutoloader) {
|
||||||
|
@ -1130,7 +1130,7 @@ class Installer
|
||||||
* @param bool $classMapAuthoritative
|
* @param bool $classMapAuthoritative
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setClassMapAuthoritative($classMapAuthoritative): Installer
|
public function setClassMapAuthoritative(bool $classMapAuthoritative): Installer
|
||||||
{
|
{
|
||||||
$this->classMapAuthoritative = (bool) $classMapAuthoritative;
|
$this->classMapAuthoritative = (bool) $classMapAuthoritative;
|
||||||
if ($this->classMapAuthoritative) {
|
if ($this->classMapAuthoritative) {
|
||||||
|
@ -1148,7 +1148,7 @@ class Installer
|
||||||
* @param string|null $apcuAutoloaderPrefix
|
* @param string|null $apcuAutoloaderPrefix
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null): Installer
|
public function setApcuAutoloader(bool $apcuAutoloader, ?string $apcuAutoloaderPrefix = null): Installer
|
||||||
{
|
{
|
||||||
$this->apcuAutoloader = $apcuAutoloader;
|
$this->apcuAutoloader = $apcuAutoloader;
|
||||||
$this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
|
$this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
|
||||||
|
@ -1162,7 +1162,7 @@ class Installer
|
||||||
* @param bool $update
|
* @param bool $update
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setUpdate($update): Installer
|
public function setUpdate(bool $update): Installer
|
||||||
{
|
{
|
||||||
$this->update = (bool) $update;
|
$this->update = (bool) $update;
|
||||||
|
|
||||||
|
@ -1175,7 +1175,7 @@ class Installer
|
||||||
* @param bool $install
|
* @param bool $install
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setInstall($install): Installer
|
public function setInstall(bool $install): Installer
|
||||||
{
|
{
|
||||||
$this->install = (bool) $install;
|
$this->install = (bool) $install;
|
||||||
|
|
||||||
|
@ -1188,7 +1188,7 @@ class Installer
|
||||||
* @param bool $devMode
|
* @param bool $devMode
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setDevMode($devMode = true): Installer
|
public function setDevMode(bool $devMode = true): Installer
|
||||||
{
|
{
|
||||||
$this->devMode = (bool) $devMode;
|
$this->devMode = (bool) $devMode;
|
||||||
|
|
||||||
|
@ -1203,7 +1203,7 @@ class Installer
|
||||||
* @param bool $dumpAutoloader
|
* @param bool $dumpAutoloader
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setDumpAutoloader($dumpAutoloader = true): Installer
|
public function setDumpAutoloader(bool $dumpAutoloader = true): Installer
|
||||||
{
|
{
|
||||||
$this->dumpAutoloader = (bool) $dumpAutoloader;
|
$this->dumpAutoloader = (bool) $dumpAutoloader;
|
||||||
|
|
||||||
|
@ -1219,7 +1219,7 @@ class Installer
|
||||||
* @return Installer
|
* @return Installer
|
||||||
* @deprecated Use setRunScripts(false) on the EventDispatcher instance being injected instead
|
* @deprecated Use setRunScripts(false) on the EventDispatcher instance being injected instead
|
||||||
*/
|
*/
|
||||||
public function setRunScripts($runScripts = true): Installer
|
public function setRunScripts(bool $runScripts = true): Installer
|
||||||
{
|
{
|
||||||
$this->runScripts = (bool) $runScripts;
|
$this->runScripts = (bool) $runScripts;
|
||||||
|
|
||||||
|
@ -1245,7 +1245,7 @@ class Installer
|
||||||
* @param bool $verbose
|
* @param bool $verbose
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setVerbose($verbose = true): Installer
|
public function setVerbose(bool $verbose = true): Installer
|
||||||
{
|
{
|
||||||
$this->verbose = (bool) $verbose;
|
$this->verbose = (bool) $verbose;
|
||||||
|
|
||||||
|
@ -1299,7 +1299,7 @@ class Installer
|
||||||
* @param bool $updateMirrors
|
* @param bool $updateMirrors
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setUpdateMirrors($updateMirrors): Installer
|
public function setUpdateMirrors(bool $updateMirrors): Installer
|
||||||
{
|
{
|
||||||
$this->updateMirrors = $updateMirrors;
|
$this->updateMirrors = $updateMirrors;
|
||||||
|
|
||||||
|
@ -1330,7 +1330,7 @@ class Installer
|
||||||
* @param int $updateAllowTransitiveDependencies One of the UPDATE_ constants on the Request class
|
* @param int $updateAllowTransitiveDependencies One of the UPDATE_ constants on the Request class
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies): Installer
|
public function setUpdateAllowTransitiveDependencies(int $updateAllowTransitiveDependencies): Installer
|
||||||
{
|
{
|
||||||
if (!in_array($updateAllowTransitiveDependencies, array(Request::UPDATE_ONLY_LISTED, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS), true)) {
|
if (!in_array($updateAllowTransitiveDependencies, array(Request::UPDATE_ONLY_LISTED, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS), true)) {
|
||||||
throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
|
throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
|
||||||
|
@ -1347,7 +1347,7 @@ class Installer
|
||||||
* @param bool $preferStable
|
* @param bool $preferStable
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setPreferStable($preferStable = true): Installer
|
public function setPreferStable(bool $preferStable = true): Installer
|
||||||
{
|
{
|
||||||
$this->preferStable = (bool) $preferStable;
|
$this->preferStable = (bool) $preferStable;
|
||||||
|
|
||||||
|
@ -1360,7 +1360,7 @@ class Installer
|
||||||
* @param bool $preferLowest
|
* @param bool $preferLowest
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setPreferLowest($preferLowest = true): Installer
|
public function setPreferLowest(bool $preferLowest = true): Installer
|
||||||
{
|
{
|
||||||
$this->preferLowest = (bool) $preferLowest;
|
$this->preferLowest = (bool) $preferLowest;
|
||||||
|
|
||||||
|
@ -1375,7 +1375,7 @@ class Installer
|
||||||
* @param bool $writeLock
|
* @param bool $writeLock
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setWriteLock($writeLock = true): Installer
|
public function setWriteLock(bool $writeLock = true): Installer
|
||||||
{
|
{
|
||||||
$this->writeLock = (bool) $writeLock;
|
$this->writeLock = (bool) $writeLock;
|
||||||
|
|
||||||
|
@ -1390,7 +1390,7 @@ class Installer
|
||||||
* @param bool $executeOperations
|
* @param bool $executeOperations
|
||||||
* @return Installer
|
* @return Installer
|
||||||
*/
|
*/
|
||||||
public function setExecuteOperations($executeOperations = true): Installer
|
public function setExecuteOperations(bool $executeOperations = true): Installer
|
||||||
{
|
{
|
||||||
$this->executeOperations = (bool) $executeOperations;
|
$this->executeOperations = (bool) $executeOperations;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class BinaryInstaller
|
||||||
* @param Filesystem $filesystem
|
* @param Filesystem $filesystem
|
||||||
* @param string|null $vendorDir
|
* @param string|null $vendorDir
|
||||||
*/
|
*/
|
||||||
public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null, $vendorDir = null)
|
public function __construct(IOInterface $io, string $binDir, string $binCompat, Filesystem $filesystem = null, ?string $vendorDir = null)
|
||||||
{
|
{
|
||||||
$this->binDir = $binDir;
|
$this->binDir = $binDir;
|
||||||
$this->binCompat = $binCompat;
|
$this->binCompat = $binCompat;
|
||||||
|
@ -62,7 +62,7 @@ class BinaryInstaller
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true): void
|
public function installBinaries(PackageInterface $package, string $installPath, bool $warnOnOverwrite = true): void
|
||||||
{
|
{
|
||||||
$binaries = $this->getBinaries($package);
|
$binaries = $this->getBinaries($package);
|
||||||
if (!$binaries) {
|
if (!$binaries) {
|
||||||
|
@ -149,7 +149,7 @@ class BinaryInstaller
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function determineBinaryCaller($bin): string
|
public static function determineBinaryCaller(string $bin): string
|
||||||
{
|
{
|
||||||
if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
|
if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
|
||||||
return 'call';
|
return 'call';
|
||||||
|
@ -180,7 +180,7 @@ class BinaryInstaller
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package): void
|
protected function installFullBinaries(string $binPath, string $link, string $bin, PackageInterface $package): void
|
||||||
{
|
{
|
||||||
// add unixy support for cygwin and similar environments
|
// add unixy support for cygwin and similar environments
|
||||||
if ('.bat' !== substr($binPath, -4)) {
|
if ('.bat' !== substr($binPath, -4)) {
|
||||||
|
@ -202,7 +202,7 @@ class BinaryInstaller
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function installUnixyProxyBinaries($binPath, $link): void
|
protected function installUnixyProxyBinaries(string $binPath, string $link): void
|
||||||
{
|
{
|
||||||
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
|
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
|
||||||
Silencer::call('chmod', $link, 0777 & ~umask());
|
Silencer::call('chmod', $link, 0777 & ~umask());
|
||||||
|
@ -223,7 +223,7 @@ class BinaryInstaller
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function generateWindowsProxyCode($bin, $link): string
|
protected function generateWindowsProxyCode(string $bin, string $link): string
|
||||||
{
|
{
|
||||||
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
||||||
$caller = self::determineBinaryCaller($bin);
|
$caller = self::determineBinaryCaller($bin);
|
||||||
|
@ -252,7 +252,7 @@ class BinaryInstaller
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function generateUnixyProxyCode($bin, $link): string
|
protected function generateUnixyProxyCode(string $bin, string $link): string
|
||||||
{
|
{
|
||||||
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ class InstallationManager
|
||||||
* @throws \InvalidArgumentException if installer for provided type is not registered
|
* @throws \InvalidArgumentException if installer for provided type is not registered
|
||||||
* @return InstallerInterface
|
* @return InstallerInterface
|
||||||
*/
|
*/
|
||||||
public function getInstaller($type)
|
public function getInstaller(string $type)
|
||||||
{
|
{
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute(InstalledRepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
|
public function execute(InstalledRepositoryInterface $repo, array $operations, bool $devMode = true, bool $runScripts = true)
|
||||||
{
|
{
|
||||||
/** @var PromiseInterface[] */
|
/** @var PromiseInterface[] */
|
||||||
$cleanupPromises = array();
|
$cleanupPromises = array();
|
||||||
|
@ -316,7 +316,7 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations): void
|
private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, bool $devMode, bool $runScripts, array $allOperations): void
|
||||||
{
|
{
|
||||||
$promises = array();
|
$promises = array();
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations): void
|
private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, bool $devMode, bool $runScripts, array $allOperations): void
|
||||||
{
|
{
|
||||||
$promises = array();
|
$promises = array();
|
||||||
$postExecCallbacks = array();
|
$postExecCallbacks = array();
|
||||||
|
@ -627,7 +627,7 @@ class InstallationManager
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setOutputProgress($outputProgress)
|
public function setOutputProgress(bool $outputProgress)
|
||||||
{
|
{
|
||||||
$this->outputProgress = $outputProgress;
|
$this->outputProgress = $outputProgress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class InstallerEvent extends Event
|
||||||
* @param bool $executeOperations
|
* @param bool $executeOperations
|
||||||
* @param Transaction $transaction
|
* @param Transaction $transaction
|
||||||
*/
|
*/
|
||||||
public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
|
public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, bool $executeOperations, Transaction $transaction)
|
||||||
{
|
{
|
||||||
parent::__construct($eventName);
|
parent::__construct($eventName);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ interface InstallerInterface
|
||||||
* @param string $packageType
|
* @param string $packageType
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function supports($packageType);
|
public function supports(string $packageType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that provided package is installed.
|
* Checks that provided package is installed.
|
||||||
|
@ -65,7 +65,7 @@ interface InstallerInterface
|
||||||
* @param PackageInterface $prevPackage previous package instance in case of an update
|
* @param PackageInterface $prevPackage previous package instance in case of an update
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
|
public function prepare(string $type, PackageInterface $package, PackageInterface $prevPackage = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs specific package.
|
* Installs specific package.
|
||||||
|
@ -108,7 +108,7 @@ interface InstallerInterface
|
||||||
* @param PackageInterface $prevPackage previous package instance in case of an update
|
* @param PackageInterface $prevPackage previous package instance in case of an update
|
||||||
* @return PromiseInterface|null
|
* @return PromiseInterface|null
|
||||||
*/
|
*/
|
||||||
public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
|
public function cleanup(string $type, PackageInterface $package, PackageInterface $prevPackage = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute installation path of a package.
|
* Returns the absolute installation path of a package.
|
||||||
|
|
|
@ -56,7 +56,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
|
||||||
* @param Filesystem $filesystem
|
* @param Filesystem $filesystem
|
||||||
* @param BinaryInstaller $binaryInstaller
|
* @param BinaryInstaller $binaryInstaller
|
||||||
*/
|
*/
|
||||||
public function __construct(IOInterface $io, PartialComposer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
|
public function __construct(IOInterface $io, PartialComposer $composer, ?string $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
|
||||||
{
|
{
|
||||||
$this->composer = $composer;
|
$this->composer = $composer;
|
||||||
$this->downloadManager = $composer instanceof Composer ? $composer->getDownloadManager() : null;
|
$this->downloadManager = $composer instanceof Composer ? $composer->getDownloadManager() : null;
|
||||||
|
|
|
@ -66,7 +66,7 @@ class PackageEvent extends Event
|
||||||
* @param OperationInterface[] $operations
|
* @param OperationInterface[] $operations
|
||||||
* @param OperationInterface $operation
|
* @param OperationInterface $operation
|
||||||
*/
|
*/
|
||||||
public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
|
public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
|
||||||
{
|
{
|
||||||
parent::__construct($eventName);
|
parent::__construct($eventName);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ProjectInstaller implements InstallerInterface
|
||||||
/**
|
/**
|
||||||
* @param string $installPath
|
* @param string $installPath
|
||||||
*/
|
*/
|
||||||
public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
|
public function __construct(string $installPath, DownloadManager $dm, Filesystem $fs)
|
||||||
{
|
{
|
||||||
$this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
|
$this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
|
||||||
$this->downloadManager = $dm;
|
$this->downloadManager = $dm;
|
||||||
|
@ -49,7 +49,7 @@ class ProjectInstaller implements InstallerInterface
|
||||||
* @param string $packageType
|
* @param string $packageType
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function supports($packageType): bool
|
public function supports(string $packageType): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class SuggestedPackagesReporter
|
||||||
* @param string $reason Reason the target package to be suggested
|
* @param string $reason Reason the target package to be suggested
|
||||||
* @return SuggestedPackagesReporter
|
* @return SuggestedPackagesReporter
|
||||||
*/
|
*/
|
||||||
public function addPackage($source, $target, $reason): SuggestedPackagesReporter
|
public function addPackage(string $source, string $target, string $reason): SuggestedPackagesReporter
|
||||||
{
|
{
|
||||||
$this->suggestedPackages[] = array(
|
$this->suggestedPackages[] = array(
|
||||||
'source' => $source,
|
'source' => $source,
|
||||||
|
@ -104,7 +104,7 @@ class SuggestedPackagesReporter
|
||||||
* @param PackageInterface|null $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown
|
* @param PackageInterface|null $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null): void
|
public function output(int $mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null): void
|
||||||
{
|
{
|
||||||
$suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
|
$suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ class SuggestedPackagesReporter
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function escapeOutput($string): string
|
private function escapeOutput(string $string): string
|
||||||
{
|
{
|
||||||
return OutputFormatter::escape(
|
return OutputFormatter::escape(
|
||||||
$this->removeControlCharacters($string)
|
$this->removeControlCharacters($string)
|
||||||
|
@ -231,7 +231,7 @@ class SuggestedPackagesReporter
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function removeControlCharacters($string): string
|
private function removeControlCharacters(string $string): string
|
||||||
{
|
{
|
||||||
return Preg::replace(
|
return Preg::replace(
|
||||||
'/[[:cntrl:]]/',
|
'/[[:cntrl:]]/',
|
||||||
|
|
|
@ -55,7 +55,7 @@ class JsonFile
|
||||||
* @param ?IOInterface $io
|
* @param ?IOInterface $io
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
|
public function __construct(string $path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
|
||||||
{
|
{
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class JsonFile
|
||||||
* @throws \UnexpectedValueException|\Exception
|
* @throws \UnexpectedValueException|\Exception
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function write(array $hash, $options = JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
|
public function write(array $hash, int $options = JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
|
||||||
{
|
{
|
||||||
if ($this->path === 'php://memory') {
|
if ($this->path === 'php://memory') {
|
||||||
file_put_contents($this->path, static::encode($hash, $options));
|
file_put_contents($this->path, static::encode($hash, $options));
|
||||||
|
@ -169,7 +169,7 @@ class JsonFile
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return int|false
|
* @return int|false
|
||||||
*/
|
*/
|
||||||
private function filePutContentsIfModified($path, $content)
|
private function filePutContentsIfModified(string $path, string $content)
|
||||||
{
|
{
|
||||||
$currentContent = @file_get_contents($path);
|
$currentContent = @file_get_contents($path);
|
||||||
if (!$currentContent || ($currentContent != $content)) {
|
if (!$currentContent || ($currentContent != $content)) {
|
||||||
|
@ -188,7 +188,7 @@ class JsonFile
|
||||||
* @throws ParsingException
|
* @throws ParsingException
|
||||||
* @return bool true on success
|
* @return bool true on success
|
||||||
*/
|
*/
|
||||||
public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
|
public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null)
|
||||||
{
|
{
|
||||||
$content = file_get_contents($this->path);
|
$content = file_get_contents($this->path);
|
||||||
$data = json_decode($content);
|
$data = json_decode($content);
|
||||||
|
@ -239,7 +239,7 @@ class JsonFile
|
||||||
* @param int $options json_encode options (defaults to JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
|
* @param int $options json_encode options (defaults to JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
|
||||||
* @return string Encoded json
|
* @return string Encoded json
|
||||||
*/
|
*/
|
||||||
public static function encode($data, $options = 448)
|
public static function encode($data, int $options = 448)
|
||||||
{
|
{
|
||||||
$json = json_encode($data, $options);
|
$json = json_encode($data, $options);
|
||||||
if (false === $json) {
|
if (false === $json) {
|
||||||
|
@ -256,7 +256,7 @@ class JsonFile
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function throwEncodeError($code): void
|
private static function throwEncodeError(int $code): void
|
||||||
{
|
{
|
||||||
switch ($code) {
|
switch ($code) {
|
||||||
case JSON_ERROR_DEPTH:
|
case JSON_ERROR_DEPTH:
|
||||||
|
@ -281,13 +281,13 @@ class JsonFile
|
||||||
/**
|
/**
|
||||||
* Parses json string and returns hash.
|
* Parses json string and returns hash.
|
||||||
*
|
*
|
||||||
* @param ?string $json json string
|
* @param null|string $json json string
|
||||||
* @param string $file the json file
|
* @param string $file the json file
|
||||||
*
|
*
|
||||||
* @throws ParsingException
|
* @throws ParsingException
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function parseJson($json, $file = null)
|
public static function parseJson(?string $json, string $file = null)
|
||||||
{
|
{
|
||||||
if (null === $json) {
|
if (null === $json) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -309,7 +309,7 @@ class JsonFile
|
||||||
* @throws ParsingException
|
* @throws ParsingException
|
||||||
* @return bool true on success
|
* @return bool true on success
|
||||||
*/
|
*/
|
||||||
protected static function validateSyntax($json, $file = null)
|
protected static function validateSyntax(string $json, string $file = null)
|
||||||
{
|
{
|
||||||
$parser = new JsonParser();
|
$parser = new JsonParser();
|
||||||
$result = $parser->lint($json);
|
$result = $parser->lint($json);
|
||||||
|
|
|
@ -38,7 +38,7 @@ class JsonFormatter
|
||||||
* @param bool $unescapeSlashes Un escape slashes
|
* @param bool $unescapeSlashes Un escape slashes
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function format($json, $unescapeUnicode, $unescapeSlashes): string
|
public static function format(string $json, bool $unescapeUnicode, bool $unescapeSlashes): string
|
||||||
{
|
{
|
||||||
$result = '';
|
$result = '';
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
|
|
|
@ -41,7 +41,7 @@ class JsonManipulator
|
||||||
/**
|
/**
|
||||||
* @param string $contents
|
* @param string $contents
|
||||||
*/
|
*/
|
||||||
public function __construct($contents)
|
public function __construct(string $contents)
|
||||||
{
|
{
|
||||||
$contents = trim($contents);
|
$contents = trim($contents);
|
||||||
if ($contents === '') {
|
if ($contents === '') {
|
||||||
|
@ -70,7 +70,7 @@ class JsonManipulator
|
||||||
* @param bool $sortPackages
|
* @param bool $sortPackages
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function addLink($type, $package, $constraint, $sortPackages = false)
|
public function addLink(string $type, string $package, string $constraint, bool $sortPackages = false)
|
||||||
{
|
{
|
||||||
$decoded = JsonFile::parseJson($this->contents);
|
$decoded = JsonFile::parseJson($this->contents);
|
||||||
|
|
||||||
|
@ -166,11 +166,11 @@ class JsonManipulator
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array<string, mixed> $config
|
* @param array<string, mixed>|false $config
|
||||||
* @param bool $append
|
* @param bool $append
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function addRepository($name, $config, $append = true)
|
public function addRepository(string $name, $config, bool $append = true)
|
||||||
{
|
{
|
||||||
return $this->addSubNode('repositories', $name, $config, $append);
|
return $this->addSubNode('repositories', $name, $config, $append);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ class JsonManipulator
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function removeRepository($name)
|
public function removeRepository(string $name)
|
||||||
{
|
{
|
||||||
return $this->removeSubNode('repositories', $name);
|
return $this->removeSubNode('repositories', $name);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ class JsonManipulator
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function addConfigSetting($name, $value)
|
public function addConfigSetting(string $name, $value)
|
||||||
{
|
{
|
||||||
return $this->addSubNode('config', $name, $value);
|
return $this->addSubNode('config', $name, $value);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ class JsonManipulator
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function removeConfigSetting($name)
|
public function removeConfigSetting(string $name)
|
||||||
{
|
{
|
||||||
return $this->removeSubNode('config', $name);
|
return $this->removeSubNode('config', $name);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ class JsonManipulator
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function addProperty($name, $value)
|
public function addProperty(string $name, $value)
|
||||||
{
|
{
|
||||||
if (strpos($name, 'suggest.') === 0) {
|
if (strpos($name, 'suggest.') === 0) {
|
||||||
return $this->addSubNode('suggest', substr($name, 8), $value);
|
return $this->addSubNode('suggest', substr($name, 8), $value);
|
||||||
|
@ -229,7 +229,7 @@ class JsonManipulator
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function removeProperty($name)
|
public function removeProperty(string $name)
|
||||||
{
|
{
|
||||||
if (strpos($name, 'suggest.') === 0) {
|
if (strpos($name, 'suggest.') === 0) {
|
||||||
return $this->removeSubNode('suggest', substr($name, 8));
|
return $this->removeSubNode('suggest', substr($name, 8));
|
||||||
|
@ -253,7 +253,7 @@ class JsonManipulator
|
||||||
* @param bool $append
|
* @param bool $append
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function addSubNode($mainNode, $name, $value, $append = true)
|
public function addSubNode(string $mainNode, string $name, $value, bool $append = true)
|
||||||
{
|
{
|
||||||
$decoded = JsonFile::parseJson($this->contents);
|
$decoded = JsonFile::parseJson($this->contents);
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ class JsonManipulator
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function removeSubNode($mainNode, $name)
|
public function removeSubNode(string $mainNode, string $name)
|
||||||
{
|
{
|
||||||
$decoded = JsonFile::parseJson($this->contents);
|
$decoded = JsonFile::parseJson($this->contents);
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ class JsonManipulator
|
||||||
* @param mixed $content
|
* @param mixed $content
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function addMainKey($key, $content)
|
public function addMainKey(string $key, $content)
|
||||||
{
|
{
|
||||||
$decoded = JsonFile::parseJson($this->contents);
|
$decoded = JsonFile::parseJson($this->contents);
|
||||||
$content = $this->format($content);
|
$content = $this->format($content);
|
||||||
|
@ -512,7 +512,7 @@ class JsonManipulator
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function removeMainKey($key)
|
public function removeMainKey(string $key)
|
||||||
{
|
{
|
||||||
$decoded = JsonFile::parseJson($this->contents);
|
$decoded = JsonFile::parseJson($this->contents);
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ class JsonManipulator
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function removeMainKeyIfEmpty($key)
|
public function removeMainKeyIfEmpty(string $key)
|
||||||
{
|
{
|
||||||
$decoded = JsonFile::parseJson($this->contents);
|
$decoded = JsonFile::parseJson($this->contents);
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ class JsonManipulator
|
||||||
* @param int $depth
|
* @param int $depth
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function format($data, $depth = 0)
|
public function format($data, int $depth = 0)
|
||||||
{
|
{
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
reset($data);
|
reset($data);
|
||||||
|
|
|
@ -28,7 +28,7 @@ class JsonValidationException extends Exception
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string[] $errors
|
* @param string[] $errors
|
||||||
*/
|
*/
|
||||||
public function __construct($message, array $errors = array(), Exception $previous = null)
|
public function __construct(string $message, array $errors = array(), Exception $previous = null)
|
||||||
{
|
{
|
||||||
$this->errors = $errors;
|
$this->errors = $errors;
|
||||||
parent::__construct((string) $message, 0, $previous);
|
parent::__construct((string) $message, 0, $previous);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue