Merge "Bump wikimedia/parsoid to 0.21.0-a11"
[mediawiki.git] / includes / libs / composer / ComposerLock.php
blob4ab3f97f28a5c8f55713d6148c9a2f3dacbc54ad
1 <?php
3 namespace Wikimedia\Composer;
5 /**
6 * Reads a composer.lock file and provides accessors to get
7 * its hash and what is installed
9 * @since 1.25
11 class ComposerLock {
12 /**
13 * @var array[]
14 * @phan-var array{packages:array{name:string,version:string,type:string,license?:string,authors?:mixed,description?:string}}
16 private $contents;
18 /**
19 * @param string $location
21 public function __construct( $location ) {
22 $this->contents = json_decode( file_get_contents( $location ), true );
25 /**
26 * Dependencies currently installed according to composer.lock
28 * @return array[]
30 public function getInstalledDependencies() {
31 $deps = [];
32 foreach ( $this->contents['packages'] 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'] ?? '',
42 return $deps;