[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/composer/ -> InstalledVersions.php (summary)

(no description)

File Size: 359 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 vendor/composer/installed.php

Defines 1 class

InstalledVersions:: (14 methods):
  getInstalledPackages()
  getInstalledPackagesByType()
  isInstalled()
  satisfies()
  getVersionRanges()
  getVersion()
  getPrettyVersion()
  getReference()
  getInstallPath()
  getRootPackage()
  getRawData()
  getAllRawData()
  reload()
  getInstalled()


Class: InstalledVersions  - X-Ref

This class is copied in every Composer installed project and available to all

See also https://getcomposer.org/doc/07-runtime.md#installed-versions

To require its presence, you can require `composer-runtime-api ^2.0`

getInstalledPackages()   X-Ref
Returns a list of all package names which are present, either by being installed, replaced or provided

return: string[]

getInstalledPackagesByType($type)   X-Ref
Returns a list of all package names with a specific type e.g. 'library'

return: string[]
param: string   $type

isInstalled($packageName, $includeDevRequirements = true)   X-Ref
Checks whether the given package is installed

This also returns true if the package name is provided or replaced by another package

return: bool
param: string $packageName
param: bool   $includeDevRequirements

satisfies(VersionParser $parser, $packageName, $constraint)   X-Ref
Checks whether the given package satisfies a version constraint

e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:

Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')

return: bool
param: VersionParser $parser      Install composer/semver to have access to this class and functionality
param: string        $packageName
param: string|null   $constraint  A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package

getVersionRanges($packageName)   X-Ref
Returns a version constraint representing all the range(s) which are installed for a given package

It is easier to use this via isInstalled() with the $constraint argument if you need to check
whether a given version of a package is installed, and not just whether it exists

return: string Version constraint usable with composer/semver
param: string $packageName

getVersion($packageName)   X-Ref

return: string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
param: string      $packageName

getPrettyVersion($packageName)   X-Ref

return: string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
param: string      $packageName

getReference($packageName)   X-Ref

return: string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
param: string      $packageName

getInstallPath($packageName)   X-Ref

return: string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
param: string      $packageName

getRootPackage()   X-Ref

return: array

getRawData()   X-Ref
Returns the raw installed.php data for custom implementations

return: array[]

getAllRawData()   X-Ref
Returns the raw data of all installed.php which are currently loaded for custom implementations

return: array[]

reload($data)   X-Ref
Lets you reload the static array from another file

This is only useful for complex integrations in which a project needs to use
this class but then also needs to execute another project's autoloader in process,
and wants to ensure both projects have access to their version of installed.php.

A typical case would be PHPUnit, where it would need to make sure it reads all
the data it needs from this class, then call reload() with
`require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
the project in which it runs can then also use this class safely, without
interference between PHPUnit's dependencies and the project's dependencies.

return: void
param: array[] $data A vendor/composer/installed.php data set

getInstalled()   X-Ref

return: array[]