MediaWiki  master
ComposerInstalled.php
Go to the documentation of this file.
1 <?php
2 
13  private $contents;
14 
18  public function __construct( $location ) {
19  $this->contents = json_decode( file_get_contents( $location ), true );
20  }
21 
27  public function getInstalledDependencies() {
28  // Composer version 2 provides the list of installed packages under the 'packages' key.
29  $contents = $this->contents['packages'] ?? $this->contents;
30 
31  $deps = [];
32  foreach ( $contents as $installed ) {
33  $deps[$installed['name']] = [
34  'version' => ComposerJson::normalizeVersion( $installed['version'] ),
35  'type' => $installed['type'],
36  'licenses' => $installed['license'] ?? [],
37  'authors' => $installed['authors'] ?? [],
38  'description' => $installed['description'] ?? '',
39  ];
40  }
41 
42  ksort( $deps );
43  return $deps;
44  }
45 }
Reads an installed.json file and provides accessors to get what is installed.
getInstalledDependencies()
Dependencies currently installed according to installed.json.
static normalizeVersion( $version)
Strip a leading "v" from the version name.