Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1430823
ComposerJson.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ComposerJson.php
View Options
<?php
namespace
Wikimedia\Composer
;
/**
* Reads a composer.json file and provides accessors to get
* its hash and the required dependencies
*
* @since 1.25
*/
class
ComposerJson
{
/**
* @var array[]
*/
private
$contents
;
/**
* @param string $location
*/
public
function
__construct
(
$location
)
{
$this
->
contents
=
json_decode
(
file_get_contents
(
$location
),
true
);
}
/**
* Dependencies as specified by composer.json
*
* @return string[]
*/
public
function
getRequiredDependencies
()
{
$deps
=
[];
if
(
isset
(
$this
->
contents
[
'require'
]
)
)
{
foreach
(
$this
->
contents
[
'require'
]
as
$package
=>
$version
)
{
// Examples of package dependencies that don't have a / in the name:
// php, ext-xml, composer-plugin-api
if
(
strpos
(
$package
,
'/'
)
!==
false
)
{
$deps
[
$package
]
=
self
::
normalizeVersion
(
$version
);
}
}
}
return
$deps
;
}
/**
* Strip a leading "v" from the version name
*
* @param string $version
* @return string
*/
public
static
function
normalizeVersion
(
$version
)
{
// Composer auto-strips the "v" in front of the tag name
return
ltrim
(
$version
,
'v'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 19:38 (3 h, 55 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
57/6e/419721d3450791bf657b44992405
Default Alt Text
ComposerJson.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment