diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php
index e116b79ed..b49a76b7d 100644
--- a/src/Composer/Command/BaseDependencyCommand.php
+++ b/src/Composer/Command/BaseDependencyCommand.php
@@ -14,6 +14,7 @@ namespace Composer\Command;
use Composer\Package\Link;
use Composer\Package\PackageInterface;
+use Composer\Package\CompletePackageInterface;
use Composer\Package\RootPackage;
use Composer\Repository\InstalledArrayRepository;
use Composer\Repository\CompositeRepository;
@@ -121,7 +122,7 @@ class BaseDependencyCommand extends BaseCommand
} elseif ($renderTree) {
$this->initStyles($output);
$root = $packages[0];
- $this->getIO()->write(sprintf('%s %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root->getDescription()));
+ $this->getIO()->write(sprintf('%s %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root instanceof CompletePackageInterface ? $root->getDescription() : ''));
$this->printTree($results);
} else {
$this->printTable($output, $results);
diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php
index 75fb8ffdc..1640d0562 100644
--- a/src/Composer/Command/ShowCommand.php
+++ b/src/Composer/Command/ShowCommand.php
@@ -430,7 +430,7 @@ EOT
$packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
$latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
}
- if ($writeDescription) {
+ if ($writeDescription && $package instanceof CompletePackageInterface) {
$packageViewData['description'] = $package->getDescription();
}
if ($writePath) {
diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php
index 8b44547a1..5a2262175 100644
--- a/src/Composer/Repository/ArrayRepository.php
+++ b/src/Composer/Repository/ArrayRepository.php
@@ -38,6 +38,9 @@ class ArrayRepository implements RepositoryInterface
*/
protected $packageMap = null;
+ /**
+ * @param array $packages
+ */
public function __construct(array $packages = array())
{
foreach ($packages as $package) {
@@ -188,6 +191,8 @@ class ArrayRepository implements RepositoryInterface
* Adds a new package to the repository
*
* @param PackageInterface $package
+ *
+ * @return void
*/
public function addPackage(PackageInterface $package)
{
@@ -236,6 +241,9 @@ class ArrayRepository implements RepositoryInterface
/**
* @phpstan-param PackageInterface&BasePackage $package
+ * @param string $alias
+ * @param string $prettyAlias
+ *
* @return AliasPackage|CompleteAliasPackage
*/
protected function createAliasPackage(PackageInterface $package, $alias, $prettyAlias)
@@ -255,6 +263,8 @@ class ArrayRepository implements RepositoryInterface
* Removes package from repository.
*
* @param PackageInterface $package package instance
+ *
+ * @return void
*/
public function removePackage(PackageInterface $package)
{
@@ -305,6 +315,8 @@ class ArrayRepository implements RepositoryInterface
/**
* Initializes the packages array. Mostly meant as an extension point.
+ *
+ * @return void
*/
protected function initialize()
{
diff --git a/src/Composer/Repository/ArtifactRepository.php b/src/Composer/Repository/ArtifactRepository.php
index 02b593a0b..715075dea 100644
--- a/src/Composer/Repository/ArtifactRepository.php
+++ b/src/Composer/Repository/ArtifactRepository.php
@@ -14,6 +14,7 @@ namespace Composer\Repository;
use Composer\IO\IOInterface;
use Composer\Json\JsonFile;
+use Composer\Package\BasePackage;
use Composer\Package\Loader\ArrayLoader;
use Composer\Package\Loader\LoaderInterface;
use Composer\Util\Tar;
@@ -29,11 +30,14 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
/** @var string */
protected $lookup;
- /** @var mixed[] */
+ /** @var array{url: string} */
protected $repoConfig;
/** @var IOInterface */
private $io;
+ /**
+ * @param array{url: string} $repoConfig
+ */
public function __construct(array $repoConfig, IOInterface $io)
{
parent::__construct();
@@ -64,6 +68,11 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
$this->scanDirectory($this->lookup);
}
+ /**
+ * @param string $path
+ *
+ * @return void
+ */
private function scanDirectory($path)
{
$io = $this->io;
@@ -90,6 +99,9 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
}
}
+ /**
+ * @return ?BasePackage
+ */
private function getComposerInformation(\SplFileInfo $file)
{
$json = null;
@@ -114,7 +126,7 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
}
if (null === $json) {
- return false;
+ return null;
}
$package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php
index d28c9b787..8d76e7e39 100644
--- a/src/Composer/Repository/ComposerRepository.php
+++ b/src/Composer/Repository/ComposerRepository.php
@@ -128,6 +128,10 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*/
public $versionParser;
+ /**
+ * @param array $repoConfig
+ * @phpstan-param array{url: string, options?: mixed[], type?: 'composer', allow_ssl_downgrade?: bool} $repoConfig
+ */
public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
{
parent::__construct();
@@ -263,6 +267,13 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return parent::findPackages($name, $constraint);
}
+ /**
+ * @param array $packages
+ * @param ConstraintInterface|null $constraint
+ * @param bool $returnFirstMatch
+ *
+ * @return BasePackage|array|null
+ */
private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
{
if (null === $constraint) {
@@ -324,6 +335,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return parent::getPackages();
}
+ /**
+ * @param string|null $packageFilter
+ *
+ * @return string[]
+ */
public function getPackageNames($packageFilter = null)
{
$hasProviders = $this->hasProviders();
@@ -523,6 +539,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $result;
}
+ /**
+ * @return string[]
+ */
private function getProviderNames()
{
$this->loadRootServerFile();
@@ -543,6 +562,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return array();
}
+ /**
+ * @return void
+ */
protected function configurePackageTransportOptions(PackageInterface $package)
{
foreach ($package->getDistUrls() as $url) {
@@ -554,6 +576,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
}
}
+ /**
+ * @return bool
+ */
private function hasProviders()
{
$this->loadRootServerFile();
@@ -563,7 +588,13 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* @param string $name package name
- * @return array|mixed
+ * @param array|null $acceptableStabilities
+ * @phpstan-param array|null $acceptableStabilities
+ * @param array|null $stabilityFlags an array of package name => BasePackage::STABILITY_* value
+ * @phpstan-param array|null $stabilityFlags
+ * @param array> $alreadyLoaded
+ *
+ * @return array
*/
private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
{
@@ -724,7 +755,14 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
}
/**
- * @param array $packageNames array of package name => ConstraintInterface|null - if a constraint is provided, only packages matching it will be loaded
+ * @param array $packageNames array of package name => ConstraintInterface|null - if a constraint is provided, only packages matching it will be loaded
+ * @param array|null $acceptableStabilities
+ * @phpstan-param array|null $acceptableStabilities
+ * @param array|null $stabilityFlags an array of package name => BasePackage::STABILITY_* value
+ * @phpstan-param array|null $stabilityFlags
+ * @param array> $alreadyLoaded
+ *
+ * @return array{namesFound: array, packages: array}
*/
private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
{
@@ -829,8 +867,17 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* TODO v3 should make this private once we can drop PHP 5.3 support
*
- * @param string $name package name (must be lowercased already)
* @private
+ *
+ * @param ConstraintInterface|null $constraint
+ * @param string $name package name (must be lowercased already)
+ * @param array $versionData
+ * @param array|null $acceptableStabilities
+ * @phpstan-param array|null $acceptableStabilities
+ * @param array|null $stabilityFlags an array of package name => BasePackage::STABILITY_* value
+ * @phpstan-param array|null $stabilityFlags
+ *
+ * @return bool
*/
public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
{
@@ -855,6 +902,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return false;
}
+ /**
+ * @return string
+ */
private function getPackagesJsonUrl()
{
$jsonUrlParts = parse_url($this->url);
@@ -866,6 +916,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $this->url . '/packages.json';
}
+ /**
+ * @return array
+ */
protected function loadRootServerFile()
{
if (null !== $this->rootData) {
@@ -977,6 +1030,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $this->rootData = $data;
}
+ /**
+ * @param string $url
+ *
+ * @return string
+ */
private function canonicalizeUrl($url)
{
if ('/' === $url[0]) {
@@ -990,6 +1048,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $url;
}
+ /**
+ * @return array[]
+ */
private function loadDataFromServer()
{
$data = $this->loadRootServerFile();
@@ -997,6 +1058,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $this->loadIncludes($data);
}
+ /**
+ * @return bool
+ */
private function hasPartialPackages()
{
if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
@@ -1006,6 +1070,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $this->hasPartialPackages;
}
+ /**
+ * @param array{providers?: array, provider-includes?: array} $data
+ *
+ * @return void
+ */
private function loadProviderListings($data)
{
if (isset($data['providers'])) {
@@ -1031,6 +1100,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
}
}
+ /**
+ * @param array[] $data
+ *
+ * @return array[]
+ */
private function loadIncludes($data)
{
$packages = array();
@@ -1072,8 +1146,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* TODO v3 should make this private once we can drop PHP 5.3 support
- *
* @private
+ *
+ * @param array[] $packages
+ * @param string|null $source
+ *
* @return list
*/
public function createPackages(array $packages, $source = null)
@@ -1105,6 +1182,14 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
}
}
+ /**
+ * @param string $filename
+ * @param string|null $cacheKey
+ * @param string|null $sha256
+ * @param bool $storeLastModifiedTime
+ *
+ * @return array
+ */
protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
{
if (null === $cacheKey) {
@@ -1218,6 +1303,13 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return $data;
}
+ /**
+ * @param string $filename
+ * @param string $cacheKey
+ * @param string $lastModifiedTime
+ *
+ * @return array|true
+ */
private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
{
$retries = 3;
@@ -1283,8 +1375,17 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return true;
}
}
+
+ throw new \LogicException('Should not happen');
}
+ /**
+ * @param string $filename
+ * @param string $cacheKey
+ * @param string|null $lastModifiedTime
+ *
+ * @return \React\Promise\PromiseInterface
+ */
private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
{
$retries = 3;
@@ -1410,6 +1511,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
* This initializes the packages key of a partial packages.json that contain some packages inlined + a providers-lazy-url
*
* This should only be called once
+ *
+ * @return void
*/
private function initializePartialPackages()
{
diff --git a/src/Composer/Repository/CompositeRepository.php b/src/Composer/Repository/CompositeRepository.php
index 8426364a5..7f3169fa6 100644
--- a/src/Composer/Repository/CompositeRepository.php
+++ b/src/Composer/Repository/CompositeRepository.php
@@ -49,7 +49,7 @@ class CompositeRepository implements RepositoryInterface
/**
* Returns all the wrapped repositories
*
- * @return array
+ * @return RepositoryInterface[]
*/
public function getRepositories()
{
@@ -164,7 +164,7 @@ class CompositeRepository implements RepositoryInterface
}
/**
- * {@inheritdoc}
+ * @return void
*/
public function removePackage(PackageInterface $package)
{
@@ -193,6 +193,8 @@ class CompositeRepository implements RepositoryInterface
/**
* Add a repository.
* @param RepositoryInterface $repository
+ *
+ * @return void
*/
public function addRepository(RepositoryInterface $repository)
{
diff --git a/src/Composer/Repository/FilesystemRepository.php b/src/Composer/Repository/FilesystemRepository.php
index debdb7a89..6f130ce05 100644
--- a/src/Composer/Repository/FilesystemRepository.php
+++ b/src/Composer/Repository/FilesystemRepository.php
@@ -154,6 +154,12 @@ class FilesystemRepository extends WritableArrayRepository
}
}
+ /**
+ * @param array $array
+ * @param int $level
+ *
+ * @return string
+ */
private function dumpToPhpCode(array $array = array(), $level = 0)
{
$lines = "array(\n";
@@ -186,7 +192,11 @@ class FilesystemRepository extends WritableArrayRepository
}
/**
- * @return ?array
+ * @param array $installPaths
+ * @param bool $devMode
+ * @param string $repoDir
+ *
+ * @return ?array
*/
private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, $devMode, $repoDir)
{
diff --git a/src/Composer/Repository/FilterRepository.php b/src/Composer/Repository/FilterRepository.php
index 8ce7be05f..d29a71f3e 100644
--- a/src/Composer/Repository/FilterRepository.php
+++ b/src/Composer/Repository/FilterRepository.php
@@ -31,6 +31,9 @@ class FilterRepository implements RepositoryInterface
/** @var RepositoryInterface */
private $repo;
+ /**
+ * @param array{only?: array, exclude?: array, canonical?: bool} $options
+ */
public function __construct(RepositoryInterface $repo, array $options)
{
if (isset($options['only'])) {
@@ -191,6 +194,11 @@ class FilterRepository implements RepositoryInterface
return 0;
}
+ /**
+ * @param string $name
+ *
+ * @return bool
+ */
private function isAllowed($name)
{
if (!$this->only && !$this->exclude) {
diff --git a/src/Composer/Repository/InstalledRepository.php b/src/Composer/Repository/InstalledRepository.php
index 13c5fddbb..4c23bf8dc 100644
--- a/src/Composer/Repository/InstalledRepository.php
+++ b/src/Composer/Repository/InstalledRepository.php
@@ -12,6 +12,8 @@
namespace Composer\Repository;
+use Composer\Package\BasePackage;
+use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\Constraint;
@@ -30,6 +32,12 @@ use Composer\Package\Link;
*/
class InstalledRepository extends CompositeRepository
{
+ /**
+ * @param string $name
+ * @param ConstraintInterface|string|null $constraint
+ *
+ * @return BasePackage[]
+ */
public function findPackagesWithReplacersAndProviders($name, $constraint = null)
{
$name = strtolower($name);
@@ -52,7 +60,7 @@ class InstalledRepository extends CompositeRepository
foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
if (
$name === $link->getTarget()
- && ($constraint === null || $link->getConstraint() === null || $constraint->matches($link->getConstraint()))
+ && ($constraint === null || $constraint->matches($link->getConstraint()))
) {
$matches[] = $candidate;
continue 2;
@@ -75,7 +83,9 @@ class InstalledRepository extends CompositeRepository
* @param bool $invert Whether to invert matches to discover reasons for the package *NOT* to be installed.
* @param bool $recurse Whether to recursively expand the requirement tree up to the root package.
* @param string[] $packagesFound Used internally when recurring
- * @return array An associative array of arrays as described above.
+ *
+ * @return array[] An associative array of arrays as described above.
+ * @phpstan-return array
*/
public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
{
@@ -247,8 +257,7 @@ class InstalledRepository extends CompositeRepository
}
/**
- * Add a repository.
- * @param RepositoryInterface $repository
+ * {@inheritDoc}
*/
public function addRepository(RepositoryInterface $repository)
{
@@ -258,7 +267,9 @@ class InstalledRepository extends CompositeRepository
|| $repository instanceof RootPackageRepository
|| $repository instanceof PlatformRepository
) {
- return parent::addRepository($repository);
+ parent::addRepository($repository);
+
+ return;
}
throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
diff --git a/src/Composer/Repository/PackageRepository.php b/src/Composer/Repository/PackageRepository.php
index c5576cf7e..06f987d43 100644
--- a/src/Composer/Repository/PackageRepository.php
+++ b/src/Composer/Repository/PackageRepository.php
@@ -28,7 +28,7 @@ class PackageRepository extends ArrayRepository
/**
* Initializes filesystem repository.
*
- * @param array $config package definition
+ * @param array{package: array} $config package definition
*/
public function __construct(array $config)
{
diff --git a/src/Composer/Repository/PathRepository.php b/src/Composer/Repository/PathRepository.php
index 7232e0368..afdf84749 100644
--- a/src/Composer/Repository/PathRepository.php
+++ b/src/Composer/Repository/PathRepository.php
@@ -95,7 +95,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
/**
* Initializes path repository.
*
- * @param array $repoConfig
+ * @param array{url: string, options?: array{symlink?: bool, relative?: bool, versions?: array}} $repoConfig
* @param IOInterface $io
* @param Config $config
*/
diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php
index 5cd1ae27c..4d5c14e36 100644
--- a/src/Composer/Repository/PlatformRepository.php
+++ b/src/Composer/Repository/PlatformRepository.php
@@ -57,6 +57,9 @@ class PlatformRepository extends ArrayRepository
/** @var HhvmDetector */
private $hhvmDetector;
+ /**
+ * @param array $overrides
+ */
public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
{
$this->runtime = $runtime ?: new Runtime();
@@ -523,6 +526,9 @@ class PlatformRepository extends ArrayRepository
}
/**
+ * @param array{version: string, name: string} $override
+ * @param string|null $name
+ *
* @return CompletePackage
*/
private function addOverriddenPackage(array $override, $name = null)
@@ -545,6 +551,8 @@ class PlatformRepository extends ArrayRepository
*
* @param string $name
* @param null|string $prettyVersion
+ *
+ * @return void
*/
private function addExtension($name, $prettyVersion)
{
@@ -590,6 +598,8 @@ class PlatformRepository extends ArrayRepository
* @param string|null $description
* @param string[] $replaces
* @param string[] $provides
+ *
+ * @return void
*/
private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
{
@@ -640,6 +650,7 @@ class PlatformRepository extends ArrayRepository
* be correct.
*
* @internal
+ * @return string|null
*/
public static function getPlatformPhpVersion()
{
diff --git a/src/Composer/Repository/RepositoryFactory.php b/src/Composer/Repository/RepositoryFactory.php
index 4eeaa14aa..713d4d9c0 100644
--- a/src/Composer/Repository/RepositoryFactory.php
+++ b/src/Composer/Repository/RepositoryFactory.php
@@ -73,7 +73,7 @@ class RepositoryFactory
/**
* @param IOInterface $io
* @param Config $config
- * @param array $repoConfig
+ * @param array $repoConfig
* @return RepositoryInterface
*/
public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
@@ -140,6 +140,8 @@ class RepositoryFactory
}
/**
+ * @param array $repoConfigs
+ *
* @return RepositoryInterface[]
*/
private static function createRepos(RepositoryManager $rm, array $repoConfigs)
@@ -168,6 +170,13 @@ class RepositoryFactory
return $repos;
}
+ /**
+ * @param int|string $index
+ * @param array{url?: string} $repo
+ * @param array $existingRepos
+ *
+ * @return string
+ */
public static function generateRepositoryName($index, array $repo, array $existingRepos)
{
$name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
diff --git a/src/Composer/Repository/RepositoryInterface.php b/src/Composer/Repository/RepositoryInterface.php
index 3b0760e0e..2b7cbb74f 100644
--- a/src/Composer/Repository/RepositoryInterface.php
+++ b/src/Composer/Repository/RepositoryInterface.php
@@ -43,8 +43,7 @@ interface RepositoryInterface extends \Countable
* @param string $name package name
* @param string|ConstraintInterface $constraint package version or version constraint to match against
*
- * @return PackageInterface|null
- * @phpstan-return (BasePackage&PackageInterface)|null
+ * @return BasePackage|null
*/
public function findPackage($name, $constraint);
@@ -54,16 +53,14 @@ interface RepositoryInterface extends \Countable
* @param string $name package name
* @param string|ConstraintInterface $constraint package version or version constraint to match against
*
- * @return PackageInterface[]
- * @phpstan-return array
+ * @return BasePackage[]
*/
public function findPackages($name, $constraint = null);
/**
* Returns list of registered packages.
*
- * @return PackageInterface[]
- * @phpstan-return array
+ * @return BasePackage[]
*/
public function getPackages();
@@ -81,7 +78,7 @@ interface RepositoryInterface extends \Countable
* @return array
*
* @phpstan-param array $packageNameMap
- * @phpstan-return array{namesFound: string[], packages: array}
+ * @phpstan-return array{namesFound: array, packages: array}
*/
public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
diff --git a/src/Composer/Repository/RepositoryManager.php b/src/Composer/Repository/RepositoryManager.php
index 12123ce7b..a230c25e9 100644
--- a/src/Composer/Repository/RepositoryManager.php
+++ b/src/Composer/Repository/RepositoryManager.php
@@ -32,7 +32,7 @@ class RepositoryManager
private $localRepository;
/** @var list */
private $repositories = array();
- /** @var array */
+ /** @var array> */
private $repositoryClasses = array();
/** @var IOInterface */
private $io;
@@ -97,6 +97,8 @@ class RepositoryManager
* Adds repository
*
* @param RepositoryInterface $repository repository instance
+ *
+ * @return void
*/
public function addRepository(RepositoryInterface $repository)
{
@@ -109,6 +111,8 @@ class RepositoryManager
* This is useful when injecting additional repositories that should trump Packagist, e.g. from a plugin.
*
* @param RepositoryInterface $repository repository instance
+ *
+ * @return void
*/
public function prependRepository(RepositoryInterface $repository)
{
@@ -119,7 +123,7 @@ class RepositoryManager
* Returns a new repository for a specific installation type.
*
* @param string $type repository type
- * @param array $config repository configuration
+ * @param array $config repository configuration
* @param string $name repository name
* @throws \InvalidArgumentException if repository for provided type is not registered
* @return RepositoryInterface
@@ -154,7 +158,9 @@ class RepositoryManager
* Stores repository class for a specific installation type.
*
* @param string $type installation type
- * @param string $class class name of the repo implementation
+ * @param class-string $class class name of the repo implementation
+ *
+ * @return void
*/
public function setRepositoryClass($type, $class)
{
@@ -175,6 +181,8 @@ class RepositoryManager
* Sets local repository for the project.
*
* @param InstalledRepositoryInterface $repository repository instance
+ *
+ * @return void
*/
public function setLocalRepository(InstalledRepositoryInterface $repository)
{
diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php
index d87a334b3..019e0d541 100644
--- a/src/Composer/Repository/RepositorySet.php
+++ b/src/Composer/Repository/RepositorySet.php
@@ -23,6 +23,7 @@ use Composer\Package\AliasPackage;
use Composer\Package\CompleteAliasPackage;
use Composer\Package\CompletePackage;
use Composer\Package\CompletePackageInterface;
+use Composer\Package\PackageInterface;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Package\Version\StabilityFilter;
@@ -113,6 +114,11 @@ class RepositorySet
}
}
+ /**
+ * @param bool $allow
+ *
+ * @return void
+ */
public function allowInstalledRepositories($allow = true)
{
$this->allowInstalledRepositories = $allow;
@@ -134,6 +140,8 @@ class RepositorySet
* repository the search for that package ends, and following repos will not be consulted.
*
* @param RepositoryInterface $repo A package repository
+ *
+ * @return void
*/
public function addRepository(RepositoryInterface $repo)
{
@@ -160,7 +168,7 @@ class RepositorySet
* @param string $name
* @param ConstraintInterface|null $constraint
* @param int $flags any of the ALLOW_* constants from this class to tweak what is returned
- * @return array
+ * @return BasePackage[]
*/
public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
{
@@ -292,12 +300,22 @@ class RepositorySet
return new Pool($packages);
}
- // TODO unify this with above in some simpler version without "request"?
+ /**
+ * @param string $packageName
+ *
+ * @return Pool
+ */
public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
{
+ // TODO unify this with above in some simpler version without "request"?
return $this->createPoolForPackages(array($packageName), $lockedRepo);
}
+ /**
+ * @param string[] $packageNames
+ *
+ * @return Pool
+ */
public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
{
$request = new Request($lockedRepo);
@@ -313,6 +331,12 @@ class RepositorySet
return $this->createPool($request, new NullIO());
}
+ /**
+ * @param array[] $aliases
+ * @phpstan-param list $aliases
+ *
+ * @return array>
+ */
private static function getRootAliasesPerPackage(array $aliases)
{
$normalizedAliases = array();
diff --git a/src/Composer/Repository/Vcs/BitbucketDriver.php b/src/Composer/Repository/Vcs/BitbucketDriver.php
index 8bd47a7a2..cf3175d8e 100644
--- a/src/Composer/Repository/Vcs/BitbucketDriver.php
+++ b/src/Composer/Repository/Vcs/BitbucketDriver.php
@@ -393,9 +393,9 @@ abstract class BitbucketDriver extends VcsDriver
}
if (!$this->io->isInteractive() && $fetchingRepoData) {
- if ($this->attemptCloneFallback()) {
- return new Response(array('url' => 'dummy'), 200, array(), 'null');
- }
+ $this->attemptCloneFallback();
+
+ return new Response(array('url' => 'dummy'), 200, array(), 'null');
}
}
@@ -412,6 +412,9 @@ abstract class BitbucketDriver extends VcsDriver
/**
* @phpstan-impure
+ *
+ * @return true
+ * @throws \RuntimeException
*/
protected function attemptCloneFallback()
{
@@ -437,7 +440,7 @@ abstract class BitbucketDriver extends VcsDriver
abstract protected function setupFallbackDriver($url);
/**
- * @param array $cloneLinks
+ * @param array $cloneLinks
* @return void
*/
protected function parseCloneUrls(array $cloneLinks)
@@ -452,7 +455,7 @@ abstract class BitbucketDriver extends VcsDriver
}
/**
- * @return array|null
+ * @return (array{name: string}&mixed[])|null
*/
protected function getMainBranchData()
{
diff --git a/src/Composer/Repository/Vcs/FossilDriver.php b/src/Composer/Repository/Vcs/FossilDriver.php
index c4c468f40..0556f79c6 100644
--- a/src/Composer/Repository/Vcs/FossilDriver.php
+++ b/src/Composer/Repository/Vcs/FossilDriver.php
@@ -67,6 +67,8 @@ class FossilDriver extends VcsDriver
/**
* Check that fossil can be invoked via command line.
+ *
+ * @return void
*/
protected function checkFossil()
{
@@ -77,6 +79,8 @@ class FossilDriver extends VcsDriver
/**
* Clone or update existing local fossil repository.
+ *
+ * @return void
*/
protected function updateLocalRepo()
{
diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php
index 6115eee81..dadf1c781 100644
--- a/src/Composer/Repository/Vcs/GitHubDriver.php
+++ b/src/Composer/Repository/Vcs/GitHubDriver.php
@@ -77,6 +77,9 @@ class GitHubDriver extends VcsDriver
$this->fetchRootIdentifier();
}
+ /**
+ * @return string
+ */
public function getRepositoryUrl()
{
return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
@@ -107,7 +110,7 @@ class GitHubDriver extends VcsDriver
}
/**
- * {@inheritDoc}
+ * @return string
*/
protected function getApiUrl()
{
@@ -192,6 +195,9 @@ class GitHubDriver extends VcsDriver
return $this->infoCache[$identifier];
}
+ /**
+ * @return array|false
+ */
private function getFundingInfo()
{
if (null !== $this->fundingInfo) {
@@ -388,7 +394,7 @@ class GitHubDriver extends VcsDriver
/**
* Gives back the loaded /repos// result
*
- * @return array|null
+ * @return mixed[]|null
*/
public function getRepoData()
{
@@ -413,6 +419,8 @@ class GitHubDriver extends VcsDriver
/**
* {@inheritDoc}
+ *
+ * @param bool $fetchingRepoData
*/
protected function getContents($url, $fetchingRepoData = false)
{
@@ -434,9 +442,9 @@ class GitHubDriver extends VcsDriver
}
if (!$this->io->isInteractive()) {
- if ($this->attemptCloneFallback()) {
- return new Response(array('url' => 'dummy'), 200, array(), 'null');
- }
+ $this->attemptCloneFallback();
+
+ return new Response(array('url' => 'dummy'), 200, array(), 'null');
}
$scopesIssued = array();
@@ -464,9 +472,9 @@ class GitHubDriver extends VcsDriver
}
if (!$this->io->isInteractive() && $fetchingRepoData) {
- if ($this->attemptCloneFallback()) {
- return new Response(array('url' => 'dummy'), 200, array(), 'null');
- }
+ $this->attemptCloneFallback();
+
+ return new Response(array('url' => 'dummy'), 200, array(), 'null');
}
$rateLimited = $gitHubUtil->isRateLimited((array) $e->getHeaders());
@@ -502,6 +510,7 @@ class GitHubDriver extends VcsDriver
/**
* Fetch root identifier from GitHub
*
+ * @return void
* @throws TransportException
*/
protected function fetchRootIdentifier()
@@ -540,6 +549,12 @@ class GitHubDriver extends VcsDriver
$this->isArchived = !empty($this->repoData['archived']);
}
+ /**
+ * @phpstan-impure
+ *
+ * @return true
+ * @throws \RuntimeException
+ */
protected function attemptCloneFallback()
{
$this->isPrivate = true;
@@ -560,6 +575,11 @@ class GitHubDriver extends VcsDriver
}
}
+ /**
+ * @param string $url
+ *
+ * @return void
+ */
protected function setupGitDriver($url)
{
$this->gitDriver = new GitDriver(
@@ -572,12 +592,14 @@ class GitHubDriver extends VcsDriver
$this->gitDriver->initialize();
}
+ /**
+ * @return string|null
+ */
protected function getNextPage(Response $response)
{
$header = $response->getHeader('link');
-
if (!$header) {
- return;
+ return null;
}
$links = explode(',', $header);
@@ -586,5 +608,7 @@ class GitHubDriver extends VcsDriver
return $match[1];
}
}
+
+ return null;
}
}
diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php
index 8e9d9059d..f3f47e768 100644
--- a/src/Composer/Repository/Vcs/GitLabDriver.php
+++ b/src/Composer/Repository/Vcs/GitLabDriver.php
@@ -132,6 +132,8 @@ class GitLabDriver extends VcsDriver
* Mainly useful for tests.
*
* @internal
+ *
+ * @return void
*/
public function setHttpDownloader(HttpDownloader $httpDownloader)
{
@@ -223,7 +225,7 @@ class GitLabDriver extends VcsDriver
}
/**
- * {@inheritDoc}
+ * @return string
*/
public function getRepositoryUrl()
{
@@ -373,6 +375,9 @@ class GitLabDriver extends VcsDriver
return $references;
}
+ /**
+ * @return void
+ */
protected function fetchProject()
{
// we need to fetch the default branch from the api
@@ -386,6 +391,12 @@ class GitLabDriver extends VcsDriver
}
}
+ /**
+ * @phpstan-impure
+ *
+ * @return true
+ * @throws \RuntimeException
+ */
protected function attemptCloneFallback()
{
if ($this->isPrivate === false) {
@@ -423,11 +434,19 @@ class GitLabDriver extends VcsDriver
return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
}
+ /**
+ * @return string
+ */
protected function generatePublicUrl()
{
return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
}
+ /**
+ * @param string $url
+ *
+ * @return void
+ */
protected function setupGitDriver($url)
{
$this->gitDriver = new GitDriver(
@@ -442,6 +461,8 @@ class GitLabDriver extends VcsDriver
/**
* {@inheritDoc}
+ *
+ * @param bool $fetchingRepoData
*/
protected function getContents($url, $fetchingRepoData = false)
{
@@ -470,7 +491,9 @@ class GitLabDriver extends VcsDriver
if (!$moreThanGuestAccess) {
$this->io->writeError('GitLab token with Guest only access detected');
- return $this->attemptCloneFallback();
+ $this->attemptCloneFallback();
+
+ return new Response(array('url' => 'dummy'), 200, array(), 'null');
}
}
@@ -501,9 +524,9 @@ class GitLabDriver extends VcsDriver
}
if (!$this->io->isInteractive()) {
- if ($this->attemptCloneFallback()) {
- return new Response(array('url' => 'dummy'), 200, array(), 'null');
- }
+ $this->attemptCloneFallback();
+
+ return new Response(array('url' => 'dummy'), 200, array(), 'null');
}
$this->io->writeError('Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '');
$gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata ('.$this->url.')');
@@ -516,9 +539,9 @@ class GitLabDriver extends VcsDriver
}
if (!$this->io->isInteractive() && $fetchingRepoData) {
- if ($this->attemptCloneFallback()) {
- return new Response(array('url' => 'dummy'), 200, array(), 'null');
- }
+ $this->attemptCloneFallback();
+
+ return new Response(array('url' => 'dummy'), 200, array(), 'null');
}
throw $e;
@@ -558,6 +581,9 @@ class GitLabDriver extends VcsDriver
return true;
}
+ /**
+ * @return string|null
+ */
protected function getNextPage(Response $response)
{
$header = $response->getHeader('link');
@@ -568,13 +594,17 @@ class GitLabDriver extends VcsDriver
return $match[1];
}
}
+
+ return null;
}
/**
- * @param array $configuredDomains
- * @param string $guessedDomain
- * @param array $urlParts
- * @return bool|string
+ * @param array $configuredDomains
+ * @param string $guessedDomain
+ * @param array $urlParts
+ * @param string $portNumber
+ *
+ * @return string|false
*/
private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
{
diff --git a/src/Composer/Repository/Vcs/PerforceDriver.php b/src/Composer/Repository/Vcs/PerforceDriver.php
index c6f9fc816..602cf4dd9 100644
--- a/src/Composer/Repository/Vcs/PerforceDriver.php
+++ b/src/Composer/Repository/Vcs/PerforceDriver.php
@@ -49,6 +49,11 @@ class PerforceDriver extends VcsDriver
$this->perforce->connectClient();
}
+ /**
+ * @param array $repoConfig
+ *
+ * @return void
+ */
private function initPerforce($repoConfig)
{
if (!empty($this->perforce)) {
@@ -171,11 +176,17 @@ class PerforceDriver extends VcsDriver
$this->perforce = null;
}
+ /**
+ * @return string
+ */
public function getDepot()
{
return $this->depot;
}
+ /**
+ * @return string
+ */
public function getBranch()
{
return $this->branch;
diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php
index 7e287e33c..22c70211f 100644
--- a/src/Composer/Repository/Vcs/VcsDriver.php
+++ b/src/Composer/Repository/Vcs/VcsDriver.php
@@ -51,7 +51,7 @@ abstract class VcsDriver implements VcsDriverInterface
/**
* Constructor.
*
- * @param array $repoConfig The repository configuration
+ * @param array{url: string}&array $repoConfig The repository configuration
* @param IOInterface $io The IO instance
* @param Config $config The composer configuration
* @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking
@@ -105,6 +105,11 @@ abstract class VcsDriver implements VcsDriverInterface
return $this->infoCache[$identifier];
}
+ /**
+ * @param string $identifier
+ *
+ * @return array|null
+ */
protected function getBaseComposerInformation($identifier)
{
$composerFileContent = $this->getFileContent('composer.json', $identifier);
diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php
index 1b7c72949..8469a33c8 100644
--- a/src/Composer/Repository/VcsRepository.php
+++ b/src/Composer/Repository/VcsRepository.php
@@ -58,7 +58,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
protected $processExecutor;
/** @var bool */
protected $branchErrorOccurred = false;
- /** @var array */
+ /** @var array> */
private $drivers;
/** @var ?VcsDriverInterface */
private $driver;
@@ -69,6 +69,10 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
/** @var array<'tags'|'branches', array> */
private $versionTransportExceptions = array();
+ /**
+ * @param array{url: string, type?: string}&array $repoConfig
+ * @param array>|null $drivers
+ */
public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
{
parent::__construct();
@@ -113,11 +117,17 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
return $this->repoConfig;
}
+ /**
+ * @return void
+ */
public function setLoader(LoaderInterface $loader)
{
$this->loader = $loader;
}
+ /**
+ * @return VcsDriverInterface|null
+ */
public function getDriver()
{
if ($this->driver) {
@@ -149,18 +159,29 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
return $this->driver;
}
}
+
+ return null;
}
+ /**
+ * @return bool
+ */
public function hadInvalidBranches()
{
return $this->branchErrorOccurred;
}
+ /**
+ * @return string[]
+ */
public function getEmptyReferences()
{
return $this->emptyReferences;
}
+ /**
+ * @return array<'tags'|'branches', array>
+ */
public function getVersionTransportExceptions()
{
return $this->versionTransportExceptions;
@@ -399,6 +420,13 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
}
}
+ /**
+ * @param VcsDriverInterface $driver
+ * @param array{name?: string, dist?: array{type: string, url: string, reference: string, shasum: string}, source?: array{type: string, url: string, reference: string}} $data
+ * @param string $identifier
+ *
+ * @return array{name: string|null, dist: array{type: string, url: string, reference: string, shasum: string}|null, source: array{type: string, url: string, reference: string}}
+ */
protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
{
// keep the name of the main identifier for all packages
@@ -417,6 +445,11 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
return $data;
}
+ /**
+ * @param string $branch
+ *
+ * @return string|false
+ */
private function validateBranch($branch)
{
try {
@@ -432,6 +465,11 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
return false;
}
+ /**
+ * @param string $version
+ *
+ * @return string|false
+ */
private function validateTag($version)
{
try {
@@ -442,10 +480,19 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
return false;
}
+ /**
+ * @param string $version
+ * @param string $identifier
+ * @param bool $isVerbose
+ * @param bool $isVeryVerbose
+ * @param bool $isDefaultBranch
+ *
+ * @return \Composer\Package\CompletePackage|\Composer\Package\CompleteAliasPackage|null|false null if no cache present, false if the absence of a version was cached
+ */
private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
{
if (!$this->versionCache) {
- return;
+ return null;
}
$cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);