MediaWiki
master
ComposerJson.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Wikimedia\Composer
;
4
11
class
ComposerJson
{
15
private
$contents;
16
20
public
function
__construct
( $location ) {
21
$this->contents = json_decode( file_get_contents( $location ),
true
);
22
}
23
29
public
function
getRequiredDependencies
() {
30
$deps = [];
31
if
( isset( $this->contents[
'require'
] ) ) {
32
foreach
( $this->contents[
'require'
] as $package => $version ) {
33
// Examples of package dependencies that don't have a / in the name:
34
// php, ext-xml, composer-plugin-api
35
if
( strpos( $package,
'/'
) !==
false
) {
36
$deps[$package] =
self::normalizeVersion
( $version );
37
}
38
}
39
}
40
41
return
$deps;
42
}
43
50
public
static
function
normalizeVersion
( $version ) {
51
// Composer auto-strips the "v" in front of the tag name
52
return
ltrim( $version,
'v'
);
53
}
54
55
}
Wikimedia\Composer\ComposerJson
Reads a composer.json file and provides accessors to get its hash and the required dependencies.
Definition
ComposerJson.php:11
Wikimedia\Composer\ComposerJson\getRequiredDependencies
getRequiredDependencies()
Dependencies as specified by composer.json.
Definition
ComposerJson.php:29
Wikimedia\Composer\ComposerJson\__construct
__construct( $location)
Definition
ComposerJson.php:20
Wikimedia\Composer\ComposerJson\normalizeVersion
static normalizeVersion( $version)
Strip a leading "v" from the version name.
Definition
ComposerJson.php:50
Wikimedia\Composer
Definition
ComposerInstalled.php:3
includes
libs
composer
ComposerJson.php
Generated on Sat Dec 14 2024 01:24:51 for MediaWiki by
1.10.0