Merge "Bump wikimedia/parsoid to 0.21.0-a11"
[mediawiki.git] / includes / libs / composer / ComposerInstalled.php
blob9e96736154898794818584e4173e16d2c9cb18ff
1 <?php
3 namespace Wikimedia\Composer;
5 /**
6 * Reads an installed.json file and provides accessors to get what is
7 * installed
9 * @since 1.27
11 class ComposerInstalled {
12 /**
13 * @var array[]
15 private $contents;
17 /**
18 * @param string $location
20 public function __construct( $location ) {
21 $this->contents = json_decode( file_get_contents( $location ), true );
24 /**
25 * Dependencies currently installed according to installed.json
27 * @return array[]
29 public function getInstalledDependencies() {
30 $contents = $this->contents['packages'];
32 $deps = [];
33 foreach ( $contents as $installed ) {
34 $deps[$installed['name']] = [
35 'version' => ComposerJson::normalizeVersion( $installed['version'] ),
36 'type' => $installed['type'],
37 'licenses' => $installed['license'] ?? [],
38 'authors' => $installed['authors'] ?? [],
39 'description' => $installed['description'] ?? '',
43 ksort( $deps );
44 return $deps;