1
0
Fork 0

Add more type info

pull/10086/head
Jordi Boggiano 2021-08-30 17:45:35 +02:00
parent 0761474599
commit 01d734125c
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
27 changed files with 206 additions and 57 deletions

View File

@ -26,6 +26,7 @@ use Composer\DependencyResolver\Operation\UninstallOperation;
*/
class MetapackageInstaller implements InstallerInterface
{
/** @var IOInterface */
private $io;
public function __construct(IOInterface $io)

View File

@ -25,8 +25,11 @@ use Composer\Util\Filesystem;
*/
class ProjectInstaller implements InstallerInterface
{
/** @var string */
private $installPath;
/** @var DownloadManager */
private $downloadManager;
/** @var Filesystem */
private $filesystem;
public function __construct($installPath, DownloadManager $dm, Filesystem $fs)

View File

@ -29,7 +29,7 @@ class SuggestedPackagesReporter
const MODE_BY_SUGGESTION = 4;
/**
* @var array
* @var array<array{source: string, target: string, reason: string}>
*/
protected $suggestedPackages = array();

View File

@ -30,7 +30,7 @@ class StabilityFilter
* @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev'
* @return bool true if any package name is acceptable
*/
public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, $names, $stability)
public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, $stability)
{
foreach ($names as $name) {
// allow if package matches the package-specific stability flag

View File

@ -18,11 +18,14 @@ use Symfony\Component\Process\ExecutableFinder;
class HhvmDetector
{
private static $hhvmVersion;
/** @var string|false|null */
private static $hhvmVersion = null;
/** @var ?ExecutableFinder */
private $executableFinder;
/** @var ?ProcessExecutor */
private $processExecutor;
public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
{
$this->executableFinder = $executableFinder;
$this->processExecutor = $processExecutor;

View File

@ -25,7 +25,7 @@ class Runtime
}
/**
* @param bool $constant
* @param string $constant
* @param class-string $class
* @return mixed
*/

View File

@ -48,7 +48,7 @@ class PreFileDownloadEvent extends Event
private $context;
/**
* @var array
* @var mixed[]
*/
private $transportOptions = array();

View File

@ -16,6 +16,7 @@ use Composer\EventDispatcher\Event;
use Composer\Repository\RepositoryInterface;
use Composer\DependencyResolver\Request;
use Composer\Package\PackageInterface;
use Composer\Package\BasePackage;
/**
* The pre command run event.
@ -33,19 +34,23 @@ class PrePoolCreateEvent extends Event
*/
private $request;
/**
* @var array
* @var int[] array of stability => BasePackage::STABILITY_* value
* @phpstan-var array<string, BasePackage::STABILITY_*>
*/
private $acceptableStabilities;
/**
* @var array
* @var int[] array of package name => BasePackage::STABILITY_* value
* @phpstan-var array<string, BasePackage::STABILITY_*>
*/
private $stabilityFlags;
/**
* @var array
* @var array[] of package => version => [alias, alias_normalized]
* @phpstan-var array<string, array<string, array{alias: string, alias_normalized: string}>>
*/
private $rootAliases;
/**
* @var array
* @var string[]
* @phpstan-var array<string, string>
*/
private $rootReferences;
/**
@ -58,8 +63,17 @@ class PrePoolCreateEvent extends Event
private $unacceptableFixedPackages;
/**
* @param string $name The event name
* @param string $name The event name
* @param RepositoryInterface[] $repositories
* @param int[] $acceptableStabilities array of stability => BasePackage::STABILITY_* value
* @param int[] $stabilityFlags array of package name => BasePackage::STABILITY_* value
* @param array[] $rootAliases array of package => version => [alias, alias_normalized]
* @param string[] $rootReferences
*
* @phpstan-param array<string, BasePackage::STABILITY_*> $acceptableStabilities
* @phpstan-param array<string, BasePackage::STABILITY_*> $stabilityFlags
* @phpstan-param array<string, array<string, array{alias: string, alias_normalized: string}>> $rootAliases
* @phpstan-param array<string, string> $rootReferences
*/
public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
{
@ -92,7 +106,8 @@ class PrePoolCreateEvent extends Event
}
/**
* @return array
* @return int[] array of stability => BasePackage::STABILITY_* value
* @phpstan-return array<string, BasePackage::STABILITY_*>
*/
public function getAcceptableStabilities()
{
@ -100,7 +115,8 @@ class PrePoolCreateEvent extends Event
}
/**
* @return array
* @return int[] array of package name => BasePackage::STABILITY_* value
* @phpstan-return array<string, BasePackage::STABILITY_*>
*/
public function getStabilityFlags()
{
@ -117,7 +133,8 @@ class PrePoolCreateEvent extends Event
}
/**
* @return array
* @return string[]
* @phpstan-return array<string, string>
*/
public function getRootReferences()
{

View File

@ -27,8 +27,11 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
/** @var LoaderInterface */
protected $loader;
/** @var string */
protected $lookup;
/** @var mixed[] */
protected $repoConfig;
/** @var IOInterface */
private $io;
public function __construct(array $repoConfig, IOInterface $io)

View File

@ -44,43 +44,72 @@ use Composer\Util\Url;
*/
class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{
/**
* @var mixed[]
* @phpstan-var array{url: string, options?: mixed[], type?: 'composer', allow_ssl_downgrade?: bool}
*/
private $repoConfig;
/** @var mixed[] */
private $options;
/** @var string */
private $url;
/** @var string */
private $baseUrl;
/** @var IOInterface */
private $io;
/** @var HttpDownloader */
private $httpDownloader;
/** @var Loop */
private $loop;
/** @var Cache */
protected $cache;
protected $notifyUrl;
protected $searchUrl;
/** @var string|null a URL containing %package% which can be queried to get providers of a given name */
protected $providersApiUrl;
/** @var ?string */
protected $notifyUrl = null;
/** @var ?string */
protected $searchUrl = null;
/** @var ?string a URL containing %package% which can be queried to get providers of a given name */
protected $providersApiUrl = null;
/** @var bool */
protected $hasProviders = false;
protected $providersUrl;
protected $listUrl;
/** @var ?string */
protected $providersUrl = null;
/** @var ?string */
protected $listUrl = null;
/** @var bool Indicates whether a comprehensive list of packages this repository might provide is expressed in the repository root. **/
protected $hasAvailablePackageList = false;
protected $availablePackages;
protected $availablePackagePatterns;
protected $lazyProvidersUrl;
/** @var ?array<string> */
protected $availablePackages = null;
/** @var ?array<string> */
protected $availablePackagePatterns = null;
/** @var ?string */
protected $lazyProvidersUrl = null;
/** @var ?array<string, array{sha256: string}> */
protected $providerListing;
/** @var ArrayLoader */
protected $loader;
/** @var bool */
private $allowSslDowngrade = false;
/** @var ?EventDispatcher */
private $eventDispatcher;
/** @var ?array<string, array{url: string, preferred: bool}> */
private $sourceMirrors;
/** @var ?array<string, array{url: string, preferred: bool}> */
private $distMirrors;
/** @var bool */
private $degradedMode = false;
/** @var mixed[]|true */
private $rootData;
private $hasPartialPackages;
private $partialPackagesByName;
/** @var bool */
private $hasPartialPackages = false;
/** @var ?array<string, PackageInterface> */
private $partialPackagesByName = null;
/**
* TODO v3 should make this private once we can drop PHP 5.3 support
* @private
* @var array list of package names which are fresh and can be loaded from the cache directly in case loadPackage is called several times
* useful for v2 metadata repositories with lazy providers
* @phpstan-var array<string, true>
*/
public $freshMetadataUrls = array();
@ -89,11 +118,13 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
* @private
* @var array list of package names which returned a 404 and should not be re-fetched in case loadPackage is called several times
* useful for v2 metadata repositories with lazy providers
* @phpstan-var array<string, true>
*/
public $packagesNotFoundCache = array();
/**
* TODO v3 should make this private once we can drop PHP 5.3 support
* @private
* @var VersionParser
*/
public $versionParser;

View File

@ -23,13 +23,13 @@ class CompositeRepository implements RepositoryInterface
{
/**
* List of repositories
* @var array
* @var RepositoryInterface[]
*/
private $repositories;
/**
* Constructor
* @param array $repositories
* @param RepositoryInterface[] $repositories
*/
public function __construct(array $repositories)
{
@ -169,8 +169,9 @@ class CompositeRepository implements RepositoryInterface
public function removePackage(PackageInterface $package)
{
foreach ($this->repositories as $repository) {
/* @var $repository RepositoryInterface */
$repository->removePackage($package);
if ($repository instanceof WritableRepositoryInterface) {
$repository->removePackage($package);
}
}
}

View File

@ -28,9 +28,13 @@ use Composer\Util\Filesystem;
*/
class FilesystemRepository extends WritableArrayRepository
{
/** @var JsonFile */
protected $file;
/** @var bool */
private $dumpVersions;
/** @var ?RootPackageInterface */
private $rootPackage;
/** @var Filesystem */
private $filesystem;
/**

View File

@ -22,9 +22,13 @@ use Composer\Package\BasePackage;
*/
class FilterRepository implements RepositoryInterface
{
private $only = array();
private $exclude = array();
/** @var ?string */
private $only = null;
/** @var ?string */
private $exclude = null;
/** @var bool */
private $canonical = true;
/** @var RepositoryInterface */
private $repo;
public function __construct(RepositoryInterface $repo, array $options)
@ -174,14 +178,6 @@ class FilterRepository implements RepositoryInterface
return $result;
}
/**
* {@inheritdoc}
*/
public function removePackage(PackageInterface $package)
{
return $this->repo->removePackage($package);
}
/**
* {@inheritdoc}
*/

View File

@ -22,6 +22,7 @@ use Composer\Package\Loader\ValidatingArrayLoader;
*/
class PackageRepository extends ArrayRepository
{
/** @var mixed[] */
private $config;
/**

View File

@ -77,7 +77,8 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
private $url;
/**
* @var array
* @var mixed[]
* @phpstan-var array{url: string, options?: array{symlink?: bool, relative?: bool, versions?: array<string, string>}}
*/
private $repoConfig;
@ -87,7 +88,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
private $process;
/**
* @var array
* @var array{symlink?: bool, relative?: bool, versions?: array<string, string>}
*/
private $options;

View File

@ -46,13 +46,15 @@ class PlatformRepository extends ArrayRepository
/**
* Defines overrides so that the platform can be mocked
*
* Should be an array of package name => version number mappings
* Keyed by package name (lowercased)
*
* @var array
* @var array<string, array{name: string, version: string}>
*/
private $overrides = array();
/** @var Runtime */
private $runtime;
/** @var HhvmDetector */
private $hhvmDetector;
public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)

View File

@ -67,6 +67,10 @@ class RepositorySet
*/
private $stabilityFlags;
/**
* @var ConstraintInterface[]
* @phpstan-var array<string, ConstraintInterface>
*/
private $rootRequires;
/** @var bool */
@ -86,6 +90,8 @@ class RepositorySet
* @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $rootAliases
* @param string[] $rootReferences an array of package name => source reference
* @phpstan-param array<string, string> $rootReferences
* @param ConstraintInterface[] $rootRequires an array of package name => constraint from the root package
* @phpstan-param array<string, ConstraintInterface> $rootRequires
*/
public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
{
@ -112,6 +118,10 @@ class RepositorySet
$this->allowInstalledRepositories = $allow;
}
/**
* @return ConstraintInterface[] an array of package name => constraint from the root package, platform requirements excluded
* @phpstan-return array<string, ConstraintInterface>
*/
public function getRootRequires()
{
return $this->rootRequires;
@ -193,6 +203,12 @@ class RepositorySet
return $result;
}
/**
* @param string $packageName
*
* @return array[] an array with the provider name as key and value of array('name' => '...', 'description' => '...', 'type' => '...')
* @phpstan-return array<string, array{name: string, description: string, type: string}>
*/
public function getProviders($packageName)
{
$providers = array();
@ -205,6 +221,13 @@ class RepositorySet
return $providers;
}
/**
* Check for each given package name whether it would be accepted by this RepositorySet in the given $stability
*
* @param string[] $names
* @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev'
* @return bool
*/
public function isPackageAcceptable($names, $stability)
{
return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);

View File

@ -20,16 +20,27 @@ use Composer\Util\Http\Response;
abstract class BitbucketDriver extends VcsDriver
{
/** @var string */
protected $owner;
/** @var string */
protected $repository;
protected $hasIssues;
/** @var bool */
protected $hasIssues = false;
/** @var ?string */
protected $rootIdentifier;
/** @var array<string, string> Map of tag name to identifier */
protected $tags;
/** @var array<string, string> Map of branch name to identifier */
protected $branches;
/** @var string */
protected $branchesUrl = '';
/** @var string */
protected $tagsUrl = '';
/** @var string */
protected $homeUrl = '';
/** @var string */
protected $website = '';
/** @var string */
protected $cloneHttpsUrl = '';
/**

View File

@ -23,10 +23,15 @@ use Composer\IO\IOInterface;
*/
class FossilDriver extends VcsDriver
{
/** @var array<string, string> Map of tag name to identifier */
protected $tags;
/** @var array<string, string> Map of branch name to identifier */
protected $branches;
protected $rootIdentifier;
protected $repoFile;
/** @var ?string */
protected $rootIdentifier = null;
/** @var ?string */
protected $repoFile = null;
/** @var string */
protected $checkoutDir;
/**

View File

@ -25,9 +25,13 @@ use Composer\Config;
*/
class GitDriver extends VcsDriver
{
/** @var array<string, string> Map of tag name to identifier */
protected $tags;
/** @var array<string, string> Map of branch name to identifier */
protected $branches;
/** @var string */
protected $rootIdentifier;
/** @var string */
protected $repoDir;
/**

View File

@ -25,15 +25,25 @@ use Composer\Util\Http\Response;
*/
class GitHubDriver extends VcsDriver
{
/** @var string */
protected $owner;
/** @var string */
protected $repository;
/** @var array<string, string> Map of tag name to identifier */
protected $tags;
/** @var array<string, string> Map of branch name to identifier */
protected $branches;
/** @var string */
protected $rootIdentifier;
/** @var mixed[] */
protected $repoData;
protected $hasIssues;
/** @var bool */
protected $hasIssues = false;
/** @var bool */
protected $isPrivate = false;
/** @var bool */
private $isArchived = false;
/** @var array<int, array{type: string, url: string}>|false|null */
private $fundingInfo;
/**

View File

@ -29,28 +29,30 @@ use Composer\Util\Http\Response;
*/
class GitLabDriver extends VcsDriver
{
/**
* @var string
* @phpstan-var 'https'|'http'
*/
private $scheme;
/** @var string */
private $namespace;
/** @var string */
private $repository;
/**
* @var array Project data returned by GitLab API
* @var mixed[] Project data returned by GitLab API
*/
private $project;
/**
* @var array Keeps commits returned by GitLab API
* @var array<string, mixed[]> Keeps commits returned by GitLab API
*/
private $commits = array();
/**
* @var array List of tag => reference
*/
/** @var array<string, string> Map of tag name to identifier */
private $tags;
/**
* @var array List of branch => reference
*/
/** @var array<string, string> Map of branch name to identifier */
private $branches;
/**

View File

@ -24,9 +24,13 @@ use Composer\IO\IOInterface;
*/
class HgDriver extends VcsDriver
{
/** @var array<string, string> Map of tag name to identifier */
protected $tags;
/** @var array<string, string> Map of branch name to identifier */
protected $branches;
/** @var string */
protected $rootIdentifier;
/** @var string */
protected $repoDir;
/**

View File

@ -23,7 +23,9 @@ use Composer\Util\Perforce;
*/
class PerforceDriver extends VcsDriver
{
/** @var string */
protected $depot;
/** @var string */
protected $branch;
/** @var ?Perforce */
protected $perforce = null;

View File

@ -28,15 +28,24 @@ use Composer\Downloader\TransportException;
*/
class SvnDriver extends VcsDriver
{
/** @var string */
protected $baseUrl;
/** @var array<string, string> Map of tag name to identifier */
protected $tags;
/** @var array<string, string> Map of branch name to identifier */
protected $branches;
/** @var ?string */
protected $rootIdentifier;
/** @var string|false */
protected $trunkPath = 'trunk';
/** @var string */
protected $branchesPath = 'branches';
/** @var string */
protected $tagsPath = 'tags';
/** @var string */
protected $packagePath = '';
/** @var bool */
protected $cacheCredentials = true;
/**

View File

@ -33,7 +33,7 @@ abstract class VcsDriver implements VcsDriverInterface
protected $url;
/** @var string */
protected $originUrl;
/** @var array */
/** @var array<string, mixed> */
protected $repoConfig;
/** @var IOInterface */
protected $io;
@ -43,7 +43,7 @@ abstract class VcsDriver implements VcsDriverInterface
protected $process;
/** @var HttpDownloader */
protected $httpDownloader;
/** @var array */
/** @var array<string, mixed> */
protected $infoCache = array();
/** @var ?Cache */
protected $cache;

View File

@ -32,25 +32,41 @@ use Composer\Config;
*/
class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
{
/** @var string */
protected $url;
/** @var ?string */
protected $packageName;
/** @var bool */
protected $isVerbose;
/** @var bool */
protected $isVeryVerbose;
/** @var IOInterface */
protected $io;
/** @var Config */
protected $config;
/** @var VersionParser */
protected $versionParser;
/** @var string */
protected $type;
/** @var ?LoaderInterface */
protected $loader;
/** @var array<string, mixed> */
protected $repoConfig;
/** @var HttpDownloader */
protected $httpDownloader;
/** @var ProcessExecutor */
protected $processExecutor;
/** @var bool */
protected $branchErrorOccurred = false;
/** @var array<string, class-string> */
private $drivers;
/** @var ?VcsDriverInterface */
private $driver;
/** @var ?VersionCacheInterface */
private $versionCache;
/** @var string[] */
private $emptyReferences = array();
/** @var array<'tags'|'branches', array<string, \Throwable>> */
private $versionTransportExceptions = array();
public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)