Lots of typing improvements

main
Jordi Boggiano 3 years ago
parent 1e3f7cfcba
commit d1c8a4d1b4
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -33,7 +33,7 @@ class ClassMapGenerator
/** /**
* Generate a class map file * Generate a class map file
* *
* @param \Traversable|array<string> $dirs Directories or a single path to search in * @param \Traversable<string>|array<string> $dirs Directories or a single path to search in
* @param string $file The name of the class map file * @param string $file The name of the class map file
*/ */
public static function dump($dirs, $file) public static function dump($dirs, $file)
@ -58,6 +58,8 @@ class ClassMapGenerator
* *
* @throws \RuntimeException When the path is neither an existing file nor directory * @throws \RuntimeException When the path is neither an existing file nor directory
* @return array A class map array * @return array A class map array
*
* @phpstan-param \Traversable<\SplFileInfo>|string|array<string> $path
*/ */
public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array()) public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
{ {

@ -24,12 +24,19 @@ use Symfony\Component\Finder\Finder;
*/ */
class Cache class Cache
{ {
/** @var bool|null */
private static $cacheCollected = null; private static $cacheCollected = null;
/** @var IOInterface */
private $io; private $io;
/** @var string */
private $root; private $root;
/** @var bool */
private $enabled = true; private $enabled = true;
/** @var string */
private $allowlist; private $allowlist;
/** @var Filesystem */
private $filesystem; private $filesystem;
/** @var bool */
private $readOnly; private $readOnly;
/** /**

@ -203,7 +203,7 @@ class BaseDependencyCommand extends BaseCommand
/** /**
* @var PackageInterface $package * @var PackageInterface $package
* @var Link $link * @var Link $link
* @var array|bool $children * @var mixed[]|bool $children
*/ */
list($package, $link, $children) = $result; list($package, $link, $children) = $result;

@ -27,8 +27,11 @@ use Seld\PharUtils\Linter;
*/ */
class Compiler class Compiler
{ {
/** @var string */
private $version; private $version;
/** @var string */
private $branchAliasVersion = ''; private $branchAliasVersion = '';
/** @var \DateTime */
private $versionDate; private $versionDate;
/** /**
@ -313,7 +316,7 @@ EOF;
// add warning once the phar is older than 60 days // add warning once the phar is older than 60 days
if (preg_match('{^[a-f0-9]+$}', $this->version)) { if (preg_match('{^[a-f0-9]+$}', $this->version)) {
$warningTime = $this->versionDate->format('U') + 60 * 86400; $warningTime = ((int) $this->versionDate->format('U')) + 60 * 86400;
$stub .= "define('COMPOSER_DEV_WARNING_TIME', $warningTime);\n"; $stub .= "define('COMPOSER_DEV_WARNING_TIME', $warningTime);\n";
} }

@ -25,6 +25,7 @@ class Config
{ {
const RELATIVE_PATHS = 1; const RELATIVE_PATHS = 1;
/** @var array<string, mixed> */
public static $defaultConfig = array( public static $defaultConfig = array(
'process-timeout' => 300, 'process-timeout' => 300,
'use-include-path' => false, 'use-include-path' => false,
@ -77,6 +78,7 @@ class Config
// bearer // bearer
); );
/** @var array<string, mixed> */
public static $defaultRepositories = array( public static $defaultRepositories = array(
'packagist.org' => array( 'packagist.org' => array(
'type' => 'composer', 'type' => 'composer',
@ -84,14 +86,19 @@ class Config
), ),
); );
/** @var array<string, mixed> */
private $config; private $config;
/** @var ?string */
private $baseDir; private $baseDir;
/** @var array<int|string, mixed> */
private $repositories; private $repositories;
/** @var ConfigSourceInterface */ /** @var ConfigSourceInterface */
private $configSource; private $configSource;
/** @var ConfigSourceInterface */ /** @var ConfigSourceInterface */
private $authConfigSource; private $authConfigSource;
/** @var bool */
private $useEnvironment; private $useEnvironment;
/** @var array<string, true> */
private $warnedHosts = array(); private $warnedHosts = array();
/** /**

@ -23,8 +23,11 @@ interface ConfigSourceInterface
/** /**
* Add a repository * Add a repository
* *
* @param string $name Name * @param string $name Name
* @param array|false $config Configuration * @param mixed[]|false $config Configuration
* @param bool $append Whether the repo should be appended (true) or prepended (false)
*
* @return void
*/ */
public function addRepository($name, $config, $append = true); public function addRepository($name, $config, $append = true);
@ -32,14 +35,18 @@ interface ConfigSourceInterface
* Remove a repository * Remove a repository
* *
* @param string $name * @param string $name
*
* @return void
*/ */
public function removeRepository($name); public function removeRepository($name);
/** /**
* Add a config setting * Add a config setting
* *
* @param string $name Name * @param string $name Name
* @param string|array $value Value * @param mixed $value Value
*
* @return void
*/ */
public function addConfigSetting($name, $value); public function addConfigSetting($name, $value);
@ -47,6 +54,8 @@ interface ConfigSourceInterface
* Remove a config setting * Remove a config setting
* *
* @param string $name * @param string $name
*
* @return void
*/ */
public function removeConfigSetting($name); public function removeConfigSetting($name);
@ -55,6 +64,8 @@ interface ConfigSourceInterface
* *
* @param string $name Name * @param string $name Name
* @param string $value Value * @param string $value Value
*
* @return void
*/ */
public function addProperty($name, $value); public function addProperty($name, $value);
@ -62,6 +73,8 @@ interface ConfigSourceInterface
* Remove a property * Remove a property
* *
* @param string $name * @param string $name
*
* @return void
*/ */
public function removeProperty($name); public function removeProperty($name);
@ -71,6 +84,8 @@ interface ConfigSourceInterface
* @param string $type Type (require, require-dev, provide, suggest, replace, conflict) * @param string $type Type (require, require-dev, provide, suggest, replace, conflict)
* @param string $name Name * @param string $name Name
* @param string $value Value * @param string $value Value
*
* @return void
*/ */
public function addLink($type, $name, $value); public function addLink($type, $name, $value);
@ -79,6 +94,8 @@ interface ConfigSourceInterface
* *
* @param string $type Type (require, require-dev, provide, suggest, replace, conflict) * @param string $type Type (require, require-dev, provide, suggest, replace, conflict)
* @param string $name Name * @param string $name Name
*
* @return void
*/ */
public function removeLink($type, $name); public function removeLink($type, $name);

@ -13,13 +13,25 @@
namespace Composer\DependencyResolver; namespace Composer\DependencyResolver;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Semver\Constraint\Constraint;
/** /**
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
*/ */
interface PolicyInterface interface PolicyInterface
{ {
/**
* @param string $operator
* @return bool
*
* @phpstan-param Constraint::STR_OP_* $operator
*/
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator); public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
/**
* @param int[] $literals
* @param ?string $requiredPackage
* @return int[]
*/
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null); public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
} }

@ -33,6 +33,7 @@ interface DownloaderInterface
/** /**
* This should do any network-related tasks to prepare for an upcoming install/update * This should do any network-related tasks to prepare for an upcoming install/update
* *
* @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, $path, PackageInterface $prevPackage = null);

@ -42,7 +42,7 @@ interface EventSubscriberInterface
* * array('eventName' => array('methodName', $priority)) * * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2')) * * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
* *
* @return array The event names to listen to * @return array<string, string|array{0: string, 1?: int}|array<array{0: string, 1?: int}>> The event names to listen to
*/ */
public static function getSubscribedEvents(); public static function getSubscribedEvents();
} }

@ -66,56 +66,68 @@ interface IOInterface extends LoggerInterface
/** /**
* Writes a message to the output. * Writes a message to the output.
* *
* @param string|array $messages The message as an array of lines or a single string * @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not * @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants * @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/ */
public function write($messages, $newline = true, $verbosity = self::NORMAL); public function write($messages, $newline = true, $verbosity = self::NORMAL);
/** /**
* Writes a message to the error output. * Writes a message to the error output.
* *
* @param string|array $messages The message as an array of lines or a single string * @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not * @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants * @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/ */
public function writeError($messages, $newline = true, $verbosity = self::NORMAL); public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
/** /**
* Writes a message to the output, without formatting it. * Writes a message to the output, without formatting it.
* *
* @param string|array $messages The message as an array of lines or a single string * @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not * @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants * @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/ */
public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL); public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
/** /**
* Writes a message to the error output, without formatting it. * Writes a message to the error output, without formatting it.
* *
* @param string|array $messages The message as an array of lines or a single string * @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not * @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants * @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/ */
public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL); public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
/** /**
* Overwrites a previous message to the output. * Overwrites a previous message to the output.
* *
* @param string|array $messages The message as an array of lines or a single string * @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not * @param bool $newline Whether to add a newline or not
* @param int $size The size of line * @param int $size The size of line
* @param int $verbosity Verbosity level from the VERBOSITY_* constants * @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/ */
public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL); public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
/** /**
* Overwrites a previous message to the error output. * Overwrites a previous message to the error output.
* *
* @param string|array $messages The message as an array of lines or a single string * @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not * @param bool $newline Whether to add a newline or not
* @param int $size The size of line * @param int $size The size of line
* @param int $verbosity Verbosity level from the VERBOSITY_* constants * @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/ */
public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL); public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
@ -172,21 +184,21 @@ interface IOInterface extends LoggerInterface
* Asks the user to select a value. * Asks the user to select a value.
* *
* @param string $question The question to ask * @param string $question The question to ask
* @param array $choices List of choices to pick from * @param string[] $choices List of choices to pick from
* @param bool|string $default The default answer if the user enters nothing * @param bool|string $default The default answer if the user enters nothing
* @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite)
* @param string $errorMessage Message which will be shown if invalid value from choice list would be picked * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked
* @param bool $multiselect Select more than one value separated by comma * @param bool $multiselect Select more than one value separated by comma
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return int|string|array|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($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
/** /**
* Get all authentication information entered. * Get all authentication information entered.
* *
* @return array The map of authentication data * @return array<string, array{username: string, password: string}> The map of authentication data
*/ */
public function getAuthentications(); public function getAuthentications();
@ -204,16 +216,18 @@ interface IOInterface extends LoggerInterface
* *
* @param string $repositoryName The unique name of repository * @param string $repositoryName The unique name of repository
* *
* @return array The 'username' and 'password' * @return array{username: string|null, password: string|null}
*/ */
public function getAuthentication($repositoryName); public function getAuthentication($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 ?string $password The password
*
* @return void
*/ */
public function setAuthentication($repositoryName, $username, $password = null); public function setAuthentication($repositoryName, $username, $password = null);
@ -221,6 +235,8 @@ interface IOInterface extends LoggerInterface
* Loads authentications from a config instance * Loads authentications from a config instance
* *
* @param Config $config * @param Config $config
*
* @return void
*/ */
public function loadConfiguration(Config $config); public function loadConfiguration(Config $config);
} }

@ -24,8 +24,21 @@ use Composer\Semver\VersionParser;
*/ */
class InstalledVersions class InstalledVersions
{ {
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
*/
private static $installed; private static $installed;
/**
* @var bool|null
*/
private static $canGetVendors; private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static $installedByVendor = array(); private static $installedByVendor = array();
/** /**

@ -117,23 +117,41 @@ class Installer
*/ */
protected $autoloadGenerator; protected $autoloadGenerator;
/** @var bool */
protected $preferSource = false; protected $preferSource = false;
/** @var bool */
protected $preferDist = false; protected $preferDist = false;
/** @var bool */
protected $optimizeAutoloader = false; protected $optimizeAutoloader = false;
/** @var bool */
protected $classMapAuthoritative = false; protected $classMapAuthoritative = false;
/** @var bool */
protected $apcuAutoloader = false; protected $apcuAutoloader = false;
protected $apcuAutoloaderPrefix; /** @var string|null */
protected $apcuAutoloaderPrefix = null;
/** @var bool */
protected $devMode = false; protected $devMode = false;
/** @var bool */
protected $dryRun = false; protected $dryRun = false;
/** @var bool */
protected $verbose = false; protected $verbose = false;
/** @var bool */
protected $update = false; protected $update = false;
/** @var bool */
protected $install = true; protected $install = true;
/** @var bool */
protected $dumpAutoloader = true; protected $dumpAutoloader = true;
/** @var bool */
protected $runScripts = true; protected $runScripts = true;
/** @var bool|string[] */
protected $ignorePlatformReqs = false; protected $ignorePlatformReqs = false;
/** @var bool */
protected $preferStable = false; protected $preferStable = false;
/** @var bool */
protected $preferLowest = false; protected $preferLowest = false;
/** @var bool */
protected $writeLock; protected $writeLock;
/** @var bool */
protected $executeOperations = true; protected $executeOperations = true;
/** @var bool */ /** @var bool */
@ -141,9 +159,10 @@ class Installer
/** /**
* Array of package names/globs flagged for update * Array of package names/globs flagged for update
* *
* @var array|null * @var string[]|null
*/ */
protected $updateAllowList = null; protected $updateAllowList = null;
/** @var Request::UPDATE_* */
protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED; protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
/** /**

@ -25,6 +25,8 @@ interface BinaryPresenceInterface
* Make sure binaries are installed for a given package. * Make sure binaries are installed for a given package.
* *
* @param PackageInterface $package package instance * @param PackageInterface $package package instance
*
* @return void
*/ */
public function ensureBinariesPresence(PackageInterface $package); public function ensureBinariesPresence(PackageInterface $package);
} }

@ -20,11 +20,17 @@ use Composer\Package\Version\VersionParser;
*/ */
class AliasPackage extends BasePackage class AliasPackage extends BasePackage
{ {
/** @var string */
protected $version; protected $version;
/** @var string */
protected $prettyVersion; protected $prettyVersion;
/** @var bool */
protected $dev; protected $dev;
/** @var bool */
protected $rootPackageAlias = false; protected $rootPackageAlias = false;
/** @var string */
protected $stability; protected $stability;
/** @var bool */
protected $hasSelfVersionRequires = false; protected $hasSelfVersionRequires = false;
/** @var BasePackage */ /** @var BasePackage */

@ -17,6 +17,7 @@ use PharData;
class ArchivableFilesFilter extends FilterIterator class ArchivableFilesFilter extends FilterIterator
{ {
/** @var string[] */
private $dirs = array(); private $dirs = array();
/** /**

@ -22,10 +22,11 @@ interface ArchiverInterface
/** /**
* Create an archive from the sources. * Create an archive from the sources.
* *
* @param string $sources The sources directory * @param string $sources The sources directory
* @param string $target The target file * @param string $target The target file
* @param string $format The format used for archive * @param string $format The format used for archive
* @param array $excludes A list of patterns for files to exclude * @param string[] $excludes A list of patterns for files to exclude
* @param bool $ignoreFilters Whether to ignore filters when looking for files
* *
* @return string The path to the written archive file * @return string The path to the written archive file
*/ */

@ -25,7 +25,7 @@ abstract class BaseExcludeFilter
protected $sourcePath; protected $sourcePath;
/** /**
* @var array * @var array<array{0: string, 1: bool, 2: bool}> array of [$pattern, $negate, $stripLeadingSlash] arrays
*/ */
protected $excludePatterns; protected $excludePatterns;

@ -19,6 +19,7 @@ namespace Composer\Package\Archiver;
*/ */
class PharArchiver implements ArchiverInterface class PharArchiver implements ArchiverInterface
{ {
/** @var array<string, int> */
protected static $formats = array( protected static $formats = array(
'zip' => \Phar::ZIP, 'zip' => \Phar::ZIP,
'tar' => \Phar::TAR, 'tar' => \Phar::TAR,
@ -26,6 +27,7 @@ class PharArchiver implements ArchiverInterface
'tar.bz2' => \Phar::TAR, 'tar.bz2' => \Phar::TAR,
); );
/** @var array<string, int> */
protected static $compressFormats = array( protected static $compressFormats = array(
'tar.gz' => \Phar::GZ, 'tar.gz' => \Phar::GZ,
'tar.bz2' => \Phar::BZ2, 'tar.bz2' => \Phar::BZ2,

@ -20,8 +20,9 @@ use Composer\Util\Filesystem;
*/ */
class ZipArchiver implements ArchiverInterface class ZipArchiver implements ArchiverInterface
{ {
/** @var array<string, bool> */
protected static $formats = array( protected static $formats = array(
'zip' => 1, 'zip' => true,
); );
/** /**

@ -40,6 +40,7 @@ abstract class BasePackage implements PackageInterface
const STABILITY_ALPHA = 15; const STABILITY_ALPHA = 15;
const STABILITY_DEV = 20; const STABILITY_DEV = 20;
/** @var array<string, self::STABILITY_*> */
public static $stabilities = array( public static $stabilities = array(
'stable' => self::STABILITY_STABLE, 'stable' => self::STABILITY_STABLE,
'RC' => self::STABILITY_RC, 'RC' => self::STABILITY_RC,

@ -19,8 +19,11 @@ namespace Composer\Package\Comparer;
*/ */
class Comparer class Comparer
{ {
/** @var string Source directory */
private $source; private $source;
/** @var string Target directory */
private $update; private $update;
/** @var array{changed?: string[], removed?: string[], added?: string[]} */
private $changed; private $changed;
public function setSource($source) public function setSource($source)

@ -19,17 +19,29 @@ namespace Composer\Package;
*/ */
class CompletePackage extends Package implements CompletePackageInterface class CompletePackage extends Package implements CompletePackageInterface
{ {
/** @var mixed[] */
protected $repositories = array(); protected $repositories = array();
/** @var string[] */
protected $license = array(); protected $license = array();
/** @var string[] */
protected $keywords = array(); protected $keywords = array();
/** @var array<array{name?: string, homepage?: string, email?: string, role?: string}> */
protected $authors = array(); protected $authors = array();
protected $description; /** @var ?string */
protected $homepage; protected $description = null;
/** @var ?string */
protected $homepage = null;
/** @var array<string, string[]> Map of script name to array of handlers */
protected $scripts = array(); protected $scripts = array();
/** @var array{issues?: string, forum?: string, wiki?: string, source?: string, email?: string, irc?: string, docs?: string, rss?: string, chat?: string} */
protected $support = array(); protected $support = array();
/** @var array<array{url?: string, type?: string}> */
protected $funding = array(); protected $funding = array();
/** @var bool|string */
protected $abandoned = false; protected $abandoned = false;
protected $archiveName; /** @var ?string */
protected $archiveName = null;
/** @var string[] */
protected $archiveExcludes = array(); protected $archiveExcludes = array();
/** /**

@ -22,7 +22,7 @@ interface CompletePackageInterface extends PackageInterface
/** /**
* Returns the scripts of this package * Returns the scripts of this package
* *
* @return array<string, string[]> array('script name' => array('listeners')) * @return array<string, string[]> Map of script name to array of handlers
*/ */
public function getScripts(); public function getScripts();
@ -35,14 +35,14 @@ interface CompletePackageInterface extends PackageInterface
/** /**
* Returns an array of repositories * Returns an array of repositories
* *
* @return array<array{type: string, url?: string}> Repositories * @return mixed[] Repositories
*/ */
public function getRepositories(); public function getRepositories();
/** /**
* Set the repositories * Set the repositories
* *
* @param array<array{type: string, url?: string}> $repositories * @param mixed[] $repositories
* @return void * @return void
*/ */
public function setRepositories(array $repositories); public function setRepositories(array $repositories);
@ -80,7 +80,7 @@ interface CompletePackageInterface extends PackageInterface
/** /**
* Returns the package description * Returns the package description
* *
* @return string * @return ?string
*/ */
public function getDescription(); public function getDescription();
@ -95,7 +95,7 @@ interface CompletePackageInterface extends PackageInterface
/** /**
* Returns the package homepage * Returns the package homepage
* *
* @return string * @return ?string
*/ */
public function getHomepage(); public function getHomepage();
@ -127,14 +127,14 @@ interface CompletePackageInterface extends PackageInterface
/** /**
* Returns the support information * Returns the support information
* *
* @return array<string, string> * @return array{issues?: string, forum?: string, wiki?: string, source?: string, email?: string, irc?: string, docs?: string, rss?: string, chat?: string}
*/ */
public function getSupport(); public function getSupport();
/** /**
* Set the support information * Set the support information
* *
* @param array<string, string> $support * @param array{issues?: string, forum?: string, wiki?: string, source?: string, email?: string, irc?: string, docs?: string, rss?: string, chat?: string} $support
* @return void * @return void
*/ */
public function setSupport(array $support); public function setSupport(array $support);
@ -144,14 +144,14 @@ interface CompletePackageInterface extends PackageInterface
* *
* Each item will contain type and url keys * Each item will contain type and url keys
* *
* @return array<array{type: string, url: string}> * @return array<array{type?: string, url?: string}>
*/ */
public function getFunding(); public function getFunding();
/** /**
* Set the funding * Set the funding
* *
* @param array<array{type: string, url: string}> $funding * @param array<array{type?: string, url?: string}> $funding
* @return void * @return void
*/ */
public function setFunding(array $funding); public function setFunding(array $funding);
@ -179,7 +179,7 @@ interface CompletePackageInterface extends PackageInterface
/** /**
* Returns default base filename for archive * Returns default base filename for archive
* *
* @return array * @return ?string
*/ */
public function getArchiveName(); public function getArchiveName();
@ -194,7 +194,7 @@ interface CompletePackageInterface extends PackageInterface
/** /**
* Returns a list of patterns to exclude from package archives * Returns a list of patterns to exclude from package archives
* *
* @return array * @return string[]
*/ */
public function getArchiveExcludes(); public function getArchiveExcludes();

@ -31,7 +31,9 @@ use Composer\Package\Version\VersionParser;
*/ */
class ArrayLoader implements LoaderInterface class ArrayLoader implements LoaderInterface
{ {
/** @var VersionParser */
protected $versionParser; protected $versionParser;
/** @var bool */
protected $loadOptions; protected $loadOptions;
public function __construct(VersionParser $parser = null, $loadOptions = false) public function __construct(VersionParser $parser = null, $loadOptions = false)

@ -17,8 +17,11 @@ namespace Composer\Package\Loader;
*/ */
class InvalidPackageException extends \Exception class InvalidPackageException extends \Exception
{ {
/** @var string[] */
private $errors; private $errors;
/** @var string[] */
private $warnings; private $warnings;
/** @var mixed[] package config */
private $data; private $data;
public function __construct(array $errors, array $warnings, array $data) public function __construct(array $errors, array $warnings, array $data)

@ -21,6 +21,7 @@ use Composer\Package\CompleteAliasPackage;
*/ */
class JsonLoader class JsonLoader
{ {
/** @var LoaderInterface */
private $loader; private $loader;
public function __construct(LoaderInterface $loader) public function __construct(LoaderInterface $loader)

@ -12,6 +12,12 @@
namespace Composer\Package\Loader; namespace Composer\Package\Loader;
use Composer\Package\CompletePackageInterface;
use Composer\Package\CompletePackage;
use Composer\Package\CompleteAliasPackage;
use Composer\Package\RootAliasPackage;
use Composer\Package\RootPackage;
/** /**
* Defines a loader that takes an array to create package instances * Defines a loader that takes an array to create package instances
* *
@ -22,9 +28,14 @@ interface LoaderInterface
/** /**
* Converts a package from an array to a real instance * Converts a package from an array to a real instance
* *
* @param array $package Package config * @template PackageClass of CompletePackageInterface
* @param string $class Package class to use *
* @return \Composer\Package\PackageInterface * @param mixed[] $config package data
* @param string $class FQCN to be instantiated
*
* @return CompletePackage|CompleteAliasPackage|RootPackage|RootAliasPackage
*
* @phpstan-param class-string<PackageClass> $class
*/ */
public function load(array $package, $class = 'Composer\Package\CompletePackage'); public function load(array $config, $class = 'Composer\Package\CompletePackage');
} }

@ -59,10 +59,11 @@ class RootPackageLoader extends ArrayLoader
/** /**
* @template PackageClass of RootPackage * @template PackageClass of RootPackage
* @param array $config package data *
* @param class-string<PackageClass> $class FQCN to be instantiated
* @param string $cwd cwd of the root package to be used to guess the version if it is not provided * @param string $cwd cwd of the root package to be used to guess the version if it is not provided
* @return RootPackage|RootAliasPackage * @return RootPackage|RootAliasPackage
*
* @phpstan-param class-string<PackageClass> $class
*/ */
public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null) public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
{ {
@ -183,6 +184,9 @@ class RootPackageLoader extends ArrayLoader
return $package; return $package;
} }
/**
* @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
*/
private function extractAliases(array $requires, array $aliases) private function extractAliases(array $requires, array $aliases)
{ {
foreach ($requires as $reqName => $reqVersion) { foreach ($requires as $reqName => $reqVersion) {
@ -203,6 +207,7 @@ class RootPackageLoader extends ArrayLoader
/** /**
* @internal * @internal
* @return array<string, BasePackage::STABILITY_*>
*/ */
public static function extractStabilityFlags(array $requires, $minimumStability, array $stabilityFlags) public static function extractStabilityFlags(array $requires, $minimumStability, array $stabilityFlags)
{ {
@ -259,6 +264,7 @@ class RootPackageLoader extends ArrayLoader
/** /**
* @internal * @internal
* @return array<string, string>
*/ */
public static function extractReferences(array $requires, array $references) public static function extractReferences(array $requires, array $references)
{ {

@ -27,12 +27,19 @@ class ValidatingArrayLoader implements LoaderInterface
const CHECK_UNBOUND_CONSTRAINTS = 1; const CHECK_UNBOUND_CONSTRAINTS = 1;
const CHECK_STRICT_CONSTRAINTS = 2; const CHECK_STRICT_CONSTRAINTS = 2;
/** @var LoaderInterface */
private $loader; private $loader;
/** @var VersionParser */
private $versionParser; private $versionParser;
/** @var string[] */
private $errors; private $errors;
/** @var string[] */
private $warnings; private $warnings;
/** @var mixed[] */
private $config; private $config;
/** @var bool */
private $strictName; private $strictName;
/** @var int One or more of self::CHECK_* constants */
private $flags; private $flags;
public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0) public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
@ -388,7 +395,7 @@ class ValidatingArrayLoader implements LoaderInterface
} }
$package = $this->loader->load($this->config, $class); $package = $this->loader->load($this->config, $class);
$this->config = null; $this->config = array();
return $package; return $package;
} }

@ -46,8 +46,10 @@ class Locker
private $dumper; private $dumper;
/** @var ProcessExecutor */ /** @var ProcessExecutor */
private $process; private $process;
private $lockDataCache; /** @var mixed[]|null */
private $virtualFileWritten; private $lockDataCache = null;
/** @var bool */
private $virtualFileWritten = false;
/** /**
* Initializes packages locker. * Initializes packages locker.

@ -34,7 +34,7 @@ class Package extends BasePackage
protected $sourceUrl; protected $sourceUrl;
/** @var ?string */ /** @var ?string */
protected $sourceReference; protected $sourceReference;
/** @var ?array */ /** @var ?array<int, array{url: string, preferred: bool}> */
protected $sourceMirrors; protected $sourceMirrors;
/** @var ?string */ /** @var ?string */
protected $distType; protected $distType;
@ -44,7 +44,7 @@ class Package extends BasePackage
protected $distReference; protected $distReference;
/** @var ?string */ /** @var ?string */
protected $distSha1Checksum; protected $distSha1Checksum;
/** @var ?array */ /** @var ?array<int, array{url: string, preferred: bool}> */
protected $distMirrors; protected $distMirrors;
/** @var string */ /** @var string */
protected $version; protected $version;

@ -55,6 +55,8 @@ interface PackageInterface
* Allows the solver to set an id for this package to refer to it. * Allows the solver to set an id for this package to refer to it.
* *
* @param int $id * @param int $id
*
* @return void
*/ */
public function setId($id); public function setId($id);
@ -98,6 +100,8 @@ interface PackageInterface
* *
* @param string $type source/dist * @param string $type source/dist
* @phpstan-param 'source'|'dist'|null $type * @phpstan-param 'source'|'dist'|null $type
*
* @return void
*/ */
public function setInstallationSource($type); public function setInstallationSource($type);
@ -140,12 +144,12 @@ interface PackageInterface
/** /**
* Returns the source mirrors of this package * Returns the source mirrors of this package
* *
* @return ?array * @return ?array<int, array{url: string, preferred: bool}>
*/ */
public function getSourceMirrors(); public function getSourceMirrors();
/** /**
* @param ?array $mirrors * @param ?array<int, array{url: string, preferred: bool}> $mirrors
* @return void * @return void
*/ */
public function setSourceMirrors($mirrors); public function setSourceMirrors($mirrors);
@ -188,12 +192,12 @@ interface PackageInterface
/** /**
* Returns the dist mirrors of this package * Returns the dist mirrors of this package
* *
* @return ?array * @return ?array<int, array{url: string, preferred: bool}>
*/ */
public function getDistMirrors(); public function getDistMirrors();
/** /**
* @param ?array $mirrors * @param ?array<int, array{url: string, preferred: bool}> $mirrors
* @return void * @return void
*/ */
public function setDistMirrors($mirrors); public function setDistMirrors($mirrors);
@ -326,6 +330,8 @@ interface PackageInterface
* Stores a reference to the repository that owns the package * Stores a reference to the repository that owns the package
* *
* @param RepositoryInterface $repository * @param RepositoryInterface $repository
*
* @return void
*/ */
public function setRepository(RepositoryInterface $repository); public function setRepository(RepositoryInterface $repository);
@ -386,6 +392,8 @@ interface PackageInterface
/** /**
* Configures the list of options to download package dist files * Configures the list of options to download package dist files
* *
* @param mixed[] $options
*
* @return void * @return void
*/ */
public function setTransportOptions(array $options); public function setTransportOptions(array $options);

@ -21,11 +21,17 @@ class RootPackage extends CompletePackage implements RootPackageInterface
{ {
const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set'; const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
/** @var string */
protected $minimumStability = 'stable'; protected $minimumStability = 'stable';
/** @var bool */
protected $preferStable = false; protected $preferStable = false;
/** @var array<string, BasePackage::STABILITY_*> Map of package name to stability constant */
protected $stabilityFlags = array(); protected $stabilityFlags = array();
/** @var mixed[] */
protected $config = array(); protected $config = array();
/** @var array<string, string> Map of package name to reference/commit hash */
protected $references = array(); protected $references = array();
/** @var array<array{package: string, version: string, alias: string, alias_normalized: string}> */
protected $aliases = array(); protected $aliases = array();
/** /**

@ -22,7 +22,7 @@ interface RootPackageInterface extends CompletePackageInterface
/** /**
* Returns a set of package names and their aliases * Returns a set of package names and their aliases
* *
* @return array * @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
*/ */
public function getAliases(); public function getAliases();
@ -38,7 +38,7 @@ interface RootPackageInterface extends CompletePackageInterface
* *
* array('foo/bar' => 'dev') * array('foo/bar' => 'dev')
* *
* @return array * @return array<string, BasePackage::STABILITY_*>
*/ */
public function getStabilityFlags(); public function getStabilityFlags();
@ -47,7 +47,7 @@ interface RootPackageInterface extends CompletePackageInterface
* *
* array('foo/bar' => 'abcd1234') * array('foo/bar' => 'abcd1234')
* *
* @return array * @return array<string, string>
*/ */
public function getReferences(); public function getReferences();
@ -61,7 +61,7 @@ interface RootPackageInterface extends CompletePackageInterface
/** /**
* Returns the root package's configuration * Returns the root package's configuration
* *
* @return array * @return mixed[]
*/ */
public function getConfig(); public function getConfig();
@ -69,6 +69,8 @@ interface RootPackageInterface extends CompletePackageInterface
* Set the required packages * Set the required packages
* *
* @param Link[] $requires A set of package links * @param Link[] $requires A set of package links
*
* @return void
*/ */
public function setRequires(array $requires); public function setRequires(array $requires);
@ -76,6 +78,8 @@ interface RootPackageInterface extends CompletePackageInterface
* Set the recommended packages * Set the recommended packages
* *
* @param Link[] $devRequires A set of package links * @param Link[] $devRequires A set of package links
*
* @return void
*/ */
public function setDevRequires(array $devRequires); public function setDevRequires(array $devRequires);
@ -83,6 +87,8 @@ interface RootPackageInterface extends CompletePackageInterface
* Set the conflicting packages * Set the conflicting packages
* *
* @param Link[] $conflicts A set of package links * @param Link[] $conflicts A set of package links
*
* @return void
*/ */
public function setConflicts(array $conflicts); public function setConflicts(array $conflicts);
@ -90,6 +96,8 @@ interface RootPackageInterface extends CompletePackageInterface
* Set the provided virtual packages * Set the provided virtual packages
* *
* @param Link[] $provides A set of package links * @param Link[] $provides A set of package links
*
* @return void
*/ */
public function setProvides(array $provides); public function setProvides(array $provides);
@ -97,34 +105,44 @@ interface RootPackageInterface extends CompletePackageInterface
* Set the packages this one replaces * Set the packages this one replaces
* *
* @param Link[] $replaces A set of package links * @param Link[] $replaces A set of package links
*
* @return void
*/ */
public function setReplaces(array $replaces); public function setReplaces(array $replaces);
/** /**
* Set the repositories * Set the repositories
* *
* @param array $repositories * @param mixed[] $repositories
*
* @return void
*/ */
public function setRepositories(array $repositories); public function setRepositories(array $repositories);
/** /**
* Set the autoload mapping * Set the autoload mapping
* *
* @param array $autoload Mapping of autoloading rules * @param array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} $autoload Mapping of autoloading rules
*
* @return void
*/ */
public function setAutoload(array $autoload); public function setAutoload(array $autoload);
/** /**
* Set the dev autoload mapping * Set the dev autoload mapping
* *
* @param array $devAutoload Mapping of dev autoloading rules * @param array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>} $devAutoload Mapping of dev autoloading rules
*
* @return void
*/ */
public function setDevAutoload(array $devAutoload); public function setDevAutoload(array $devAutoload);
/** /**
* Set the stabilityFlags * Set the stabilityFlags
* *
* @param array $stabilityFlags * @param array<string, BasePackage::STABILITY_*> $stabilityFlags
*
* @return void
*/ */
public function setStabilityFlags(array $stabilityFlags); public function setStabilityFlags(array $stabilityFlags);
@ -132,6 +150,8 @@ interface RootPackageInterface extends CompletePackageInterface
* Set the minimumStability * Set the minimumStability
* *
* @param string $minimumStability * @param string $minimumStability
*
* @return void
*/ */
public function setMinimumStability($minimumStability); public function setMinimumStability($minimumStability);
@ -139,39 +159,51 @@ interface RootPackageInterface extends CompletePackageInterface
* Set the preferStable * Set the preferStable
* *
* @param bool $preferStable * @param bool $preferStable
*
* @return void
*/ */
public function setPreferStable($preferStable); public function setPreferStable($preferStable);
/** /**
* Set the config * Set the config
* *
* @param array $config * @param mixed[] $config
*
* @return void
*/ */
public function setConfig(array $config); public function setConfig(array $config);
/** /**
* Set the references * Set the references
* *
* @param array $references * @param array<string, string> $references
*
* @return void
*/ */
public function setReferences(array $references); public function setReferences(array $references);
/** /**
* Set the aliases * Set the aliases
* *
* @param array $aliases * @param array<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
*
* @return void
*/ */
public function setAliases(array $aliases); public function setAliases(array $aliases);
/** /**
* Set the suggested packages * Set the suggested packages
* *
* @param array $suggests A set of package names/comments * @param array<string, string> $suggests A set of package names/comments
*
* @return void
*/ */
public function setSuggests(array $suggests); public function setSuggests(array $suggests);
/** /**
* @param array $extra * @param mixed[] $extra
*
* @return void
*/ */
public function setExtra(array $extra); public function setExtra(array $extra);
} }

@ -15,11 +15,13 @@ namespace Composer\Package\Version;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Semver\VersionParser as SemverVersionParser; use Composer\Semver\VersionParser as SemverVersionParser;
use Composer\Semver\Semver; use Composer\Semver\Semver;
use Composer\Semver\Constraint\ConstraintInterface;
class VersionParser extends SemverVersionParser class VersionParser extends SemverVersionParser
{ {
const DEFAULT_BRANCH_ALIAS = '9999999-dev'; const DEFAULT_BRANCH_ALIAS = '9999999-dev';
/** @var array<string, ConstraintInterface> Constraint parsing cache */
private static $constraints = array(); private static $constraints = array();
/** /**

@ -21,6 +21,7 @@ use Composer\Package\Dumper\ArrayDumper;
use Composer\Repository\RepositorySet; use Composer\Repository\RepositorySet;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\Constraint;
use Composer\Semver\Constraint\ConstraintInterface;
/** /**
* Selects the best possible version for a package * Selects the best possible version for a package
@ -30,10 +31,13 @@ use Composer\Semver\Constraint\Constraint;
*/ */
class VersionSelector class VersionSelector
{ {
/** @var RepositorySet */
private $repositorySet; private $repositorySet;
/** @var array<string, ConstraintInterface[]> */
private $platformConstraints = array(); private $platformConstraints = array();
/** @var VersionParser */
private $parser; private $parser;
/** /**

@ -39,6 +39,8 @@ interface PluginInterface
* *
* @param Composer $composer * @param Composer $composer
* @param IOInterface $io * @param IOInterface $io
*
* @return void
*/ */
public function activate(Composer $composer, IOInterface $io); public function activate(Composer $composer, IOInterface $io);
@ -51,6 +53,8 @@ interface PluginInterface
* *
* @param Composer $composer * @param Composer $composer
* @param IOInterface $io * @param IOInterface $io
*
* @return void
*/ */
public function deactivate(Composer $composer, IOInterface $io); public function deactivate(Composer $composer, IOInterface $io);
@ -61,6 +65,8 @@ interface PluginInterface
* *
* @param Composer $composer * @param Composer $composer
* @param IOInterface $io * @param IOInterface $io
*
* @return void
*/ */
public function uninstall(Composer $composer, IOInterface $io); public function uninstall(Composer $composer, IOInterface $io);
} }

@ -91,9 +91,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
private $allowSslDowngrade = false; private $allowSslDowngrade = false;
/** @var ?EventDispatcher */ /** @var ?EventDispatcher */
private $eventDispatcher; private $eventDispatcher;
/** @var ?array<string, array{url: string, preferred: bool}> */ /** @var ?array<string, array<int, array{url: string, preferred: bool}>> */
private $sourceMirrors; private $sourceMirrors;
/** @var ?array<string, array{url: string, preferred: bool}> */ /** @var ?array<int, array{url: string, preferred: bool}> */
private $distMirrors; private $distMirrors;
/** @var bool */ /** @var bool */
private $degradedMode = false; private $degradedMode = false;

@ -19,5 +19,8 @@ namespace Composer\Repository;
*/ */
interface ConfigurableRepositoryInterface interface ConfigurableRepositoryInterface
{ {
/**
* @return mixed[]
*/
public function getRepoConfig(); public function getRepoConfig();
} }

@ -47,8 +47,6 @@ class PerforceDriver extends VcsDriver
$this->perforce->writeP4ClientSpec(); $this->perforce->writeP4ClientSpec();
$this->perforce->connectClient(); $this->perforce->connectClient();
return true;
} }
private function initPerforce($repoConfig) private function initPerforce($repoConfig)

@ -22,14 +22,16 @@ interface VcsDriverInterface
{ {
/** /**
* Initializes the driver (git clone, svn checkout, fetch info etc) * Initializes the driver (git clone, svn checkout, fetch info etc)
*
* @return void
*/ */
public function initialize(); public function initialize();
/** /**
* Return the composer.json file information * Return the composer.json file information
* *
* @param string $identifier Any identifier to a specific branch/tag/commit * @param string $identifier Any identifier to a specific branch/tag/commit
* @return array containing all infos from the composer.json file * @return mixed[] containing all infos from the composer.json file
*/ */
public function getComposerInformation($identifier); public function getComposerInformation($identifier);
@ -60,26 +62,28 @@ interface VcsDriverInterface
/** /**
* Return list of branches in the repository * Return list of branches in the repository
* *
* @return array Branch names as keys, identifiers as values * @return array<string, string> Branch names as keys, identifiers as values
*/ */
public function getBranches(); public function getBranches();
/** /**
* Return list of tags in the repository * Return list of tags in the repository
* *
* @return array Tag names as keys, identifiers as values * @return array<string, string> Tag names as keys, identifiers as values
*/ */
public function getTags(); public function getTags();
/** /**
* @param string $identifier Any identifier to a specific branch/tag/commit * @param string $identifier Any identifier to a specific branch/tag/commit
* @return array|null With type, url reference and shasum keys. *
* @return array{type: string, url: string, reference: string, shasum: string}|null
*/ */
public function getDist($identifier); public function getDist($identifier);
/** /**
* @param string $identifier Any identifier to a specific branch/tag/commit * @param string $identifier Any identifier to a specific branch/tag/commit
* @return array With type, url and reference keys. *
* @return array{type: string, url: string, reference: string}
*/ */
public function getSource($identifier); public function getSource($identifier);
@ -101,6 +105,8 @@ interface VcsDriverInterface
/** /**
* Performs any cleanup necessary as the driver is not longer needed * Performs any cleanup necessary as the driver is not longer needed
*
* @return void
*/ */
public function cleanup(); public function cleanup();

@ -15,9 +15,9 @@ namespace Composer\Repository;
interface VersionCacheInterface interface VersionCacheInterface
{ {
/** /**
* @param string $version * @param string $version
* @param string $identifier * @param string $identifier
* @return array|null|false Package version data if found, false to indicate the identifier is known but has no package, null for an unknown identifier * @return mixed[]|null|false Package version data if found, false to indicate the identifier is known but has no package, null for an unknown identifier
*/ */
public function getVersionPackage($version, $identifier); public function getVersionPackage($version, $identifier);
} }

@ -26,6 +26,7 @@ interface WritableRepositoryInterface extends RepositoryInterface
* Writes repository (f.e. to the disc). * Writes repository (f.e. to the disc).
* *
* @param bool $devMode Whether dev requirements were included or not in this installation * @param bool $devMode Whether dev requirements were included or not in this installation
* @return void
*/ */
public function write($devMode, InstallationManager $installationManager); public function write($devMode, InstallationManager $installationManager);
@ -33,6 +34,7 @@ interface WritableRepositoryInterface extends RepositoryInterface
* Adds package to the repository. * Adds package to the repository.
* *
* @param PackageInterface $package package instance * @param PackageInterface $package package instance
* @return void
*/ */
public function addPackage(PackageInterface $package); public function addPackage(PackageInterface $package);
@ -40,6 +42,7 @@ interface WritableRepositoryInterface extends RepositoryInterface
* Removes package from the repository. * Removes package from the repository.
* *
* @param PackageInterface $package package instance * @param PackageInterface $package package instance
* @return void
*/ */
public function removePackage(PackageInterface $package); public function removePackage(PackageInterface $package);
@ -52,11 +55,14 @@ interface WritableRepositoryInterface extends RepositoryInterface
/** /**
* Forces a reload of all packages. * Forces a reload of all packages.
*
* @return void
*/ */
public function reload(); public function reload();
/** /**
* @param string[] $devPackageNames * @param string[] $devPackageNames
* @return void
*/ */
public function setDevPackageNames(array $devPackageNames); public function setDevPackageNames(array $devPackageNames);

@ -120,8 +120,11 @@ class AuthHelper
$message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit'); $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
$gitLabUtil = new GitLab($this->io, $this->config, null); $gitLabUtil = new GitLab($this->io, $this->config, null);
if ($this->io->hasAuthentication($origin) && ($auth = $this->io->getAuthentication($origin)) && in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) { if ($this->io->hasAuthentication($origin)) {
throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode); $auth = $this->io->getAuthentication($origin);
if (in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
}
} }
if (!$gitLabUtil->authorizeOAuth($origin) if (!$gitLabUtil->authorizeOAuth($origin)

@ -22,13 +22,20 @@ use Composer\Util\Url;
*/ */
class ProxyManager class ProxyManager
{ {
private $error; /** @var ?string */
private $error = null;
/** @var array{http: ?string, https: ?string} */
private $fullProxy; private $fullProxy;
/** @var array{http: ?string, https: ?string} */
private $safeProxy; private $safeProxy;
/** @var array{http: array{options: mixed[]|null}, https: array{options: mixed[]|null}} */
private $streams; private $streams;
/** @var bool */
private $hasProxy; private $hasProxy;
private $info; /** @var ?string */
private $lastProxy; private $info = null;
/** @var ?string */
private $lastProxy = null;
/** @var ?NoProxyPattern */ /** @var ?NoProxyPattern */
private $noProxyHandler = null; private $noProxyHandler = null;
@ -154,7 +161,7 @@ class ProxyManager
* Sets initial data * Sets initial data
* *
* @param string $url Proxy url * @param string $url Proxy url
* @param string $scheme Environment variable scheme * @param 'http'|'https' $scheme Environment variable scheme
*/ */
private function setData($url, $scheme) private function setData($url, $scheme)
{ {

@ -20,23 +20,39 @@ use Symfony\Component\Process\Process;
*/ */
class Perforce class Perforce
{ {
/** @var string */
protected $path; protected $path;
/** @var ?string */
protected $p4Depot; protected $p4Depot;
/** @var string */
protected $p4Client; protected $p4Client;
/** @var ?string */
protected $p4User; protected $p4User;
/** @var ?string */
protected $p4Password; protected $p4Password;
/** @var int */
protected $p4Port; protected $p4Port;
/** @var string */
protected $p4Stream; protected $p4Stream;
/** @var string */
protected $p4ClientSpec; protected $p4ClientSpec;
/** @var ?string */
protected $p4DepotType; protected $p4DepotType;
/** @var ?string */
protected $p4Branch; protected $p4Branch;
/** @var ProcessExecutor */
protected $process; protected $process;
/** @var string */
protected $uniquePerforceClientName; protected $uniquePerforceClientName;
/** @var bool */
protected $windowsFlag; protected $windowsFlag;
/** @var string */
protected $commandResult; protected $commandResult;
/** @var IOInterface */
protected $io; protected $io;
/** @var Filesystem */
protected $filesystem; protected $filesystem;
public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io) public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)

Loading…
Cancel
Save