Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

(no description)

File Size: 352 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 auth/cas/CAS/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'

param: string   $type
return: string[]

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

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

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')

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
return: bool

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

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

getVersion($packageName)   X-Ref

param: string      $packageName
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

getPrettyVersion($packageName)   X-Ref

param: string      $packageName
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

getReference($packageName)   X-Ref

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

getInstallPath($packageName)   X-Ref

param: string      $packageName
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.

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.

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

getInstalled()   X-Ref

return: array[]