MediaWiki REL1_31
ComposerJson.php
Go to the documentation of this file.
1<?php
2
10
14 public function __construct( $location ) {
15 $this->contents = json_decode( file_get_contents( $location ), true );
16 }
17
23 public function getRequiredDependencies() {
24 $deps = [];
25 if ( isset( $this->contents['require'] ) ) {
26 foreach ( $this->contents['require'] as $package => $version ) {
27 // Examples of package dependancies that don't have a / in the name:
28 // php, ext-xml, composer-plugin-api
29 if ( strpos( $package, '/' ) !== false ) {
30 $deps[$package] = self::normalizeVersion( $version );
31 }
32 }
33 }
34
35 return $deps;
36 }
37
44 public static function normalizeVersion( $version ) {
45 if ( strpos( $version, 'v' ) === 0 ) {
46 // Composer auto-strips the "v" in front of the tag name
47 $version = ltrim( $version, 'v' );
48 }
49
50 return $version;
51 }
52
53}
Reads a composer.json file and provides accessors to get its hash and the required dependencies.
static normalizeVersion( $version)
Strip a leading "v" from the version name.
getRequiredDependencies()
Dependencies as specified by composer.json.
__construct( $location)
Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database such as a description of the tables and their contents
Definition database.txt:9