PHP Class Wikimedia\Composer\Merge\ExtraPackage

Author: Bryan Davis ([email protected])
Show file Open project: wikimedia/composer-merge-plugin Class Usage Examples

Protected Properties

Property Type Description
$composer Composer\Composer
$json array
$logger Wikimedia\Composer\Logger
$package Composer\Package\CompletePackage
$path string
$versionParser Composer\Package\Version\VersionParser

Public Methods

Method Description
__construct ( string $path, Composer\Composer $composer, Wikimedia\Composer\Logger $logger )
getIncludes ( ) : array Get list of additional packages to include if precessing recursively.
getRequires ( ) : array Get list of additional packages to require if precessing recursively.
mergeDevInto ( Composer\Package\RootPackageInterface $root, PluginState $state ) Merge just the dev portion into a RootPackageInterface
mergeExtra ( Composer\Package\RootPackageInterface $root, PluginState $state ) Merge extra config into a RootPackageInterface
mergeExtraArray ( boolean $mergeDeep, array $array1, array $array2 ) : array Merges two arrays either via arrayMergeDeep or via array_merge.
mergeInto ( Composer\Package\RootPackageInterface $root, PluginState $state ) Merge this package into a RootPackageInterface
unwrapIfNeeded ( Composer\Package\RootPackageInterface $root, string $method = 'setExtra' ) : Composer\Package\RootPackageInterface | Composer\Package\RootPackage Get a full featured Package from a RootPackageInterface.

Protected Methods

Method Description
extractReferences ( array $requires, array $references ) : array Extract vcs revision from version constraint (dev-master#abc123.
fixRelativePaths ( array $paths ) : array Fix a collection of paths that are relative to this package to be relative to the base package.
loadPackage ( array $json ) : Composer\Package\CompletePackage
mergeAutoload ( string $type, Composer\Package\RootPackageInterface $root ) Merge autoload or autoload-dev into a RootPackageInterface
mergeOrDefer ( string $type, array $origin, array $merge, PluginState $state ) : array Merge two collections of package links and collect duplicates for subsequent processing.
mergePackageLinks ( string $type, Composer\Package\RootPackageInterface $root ) Merge package links of the given type into a RootPackageInterface
mergeReferences ( Composer\Package\RootPackageInterface $root ) Update the root packages reference information.
mergeRequires ( string $type, Composer\Package\RootPackageInterface $root, PluginState $state ) Merge require or require-dev into a RootPackageInterface
mergeStabilityFlags ( Composer\Package\RootPackageInterface $root, array $requires ) Extract and merge stability flags from the given collection of requires and merge them into a RootPackageInterface
mergeSuggests ( Composer\Package\RootPackageInterface $root ) Merge suggested packages into a RootPackageInterface
prependRepositories ( Composer\Package\RootPackageInterface $root ) Add a collection of repositories described by the given configuration to the given package and the global repository manager.
readPackageJson ( string $path ) : array Read the contents of a composer.json style file into an array.
replaceSelfVersionDependencies ( string $type, array $links, Composer\Package\RootPackageInterface $root ) : array Update Links with a 'self.version' constraint with the root package's version.

Method Details

__construct() public method

public __construct ( string $path, Composer\Composer $composer, Wikimedia\Composer\Logger $logger )
$path string Path to composer.json file
$composer Composer\Composer
$logger Wikimedia\Composer\Logger

extractReferences() protected method

Extract vcs revision from version constraint (dev-master#abc123.
See also: RootPackageLoader::extractReferences()
protected extractReferences ( array $requires, array $references ) : array
$requires array
$references array
return array

fixRelativePaths() protected method

Fix a collection of paths that are relative to this package to be relative to the base package.
protected fixRelativePaths ( array $paths ) : array
$paths array
return array

getIncludes() public method

Get list of additional packages to include if precessing recursively.
public getIncludes ( ) : array
return array

getRequires() public method

Get list of additional packages to require if precessing recursively.
public getRequires ( ) : array
return array

loadPackage() protected method

protected loadPackage ( array $json ) : Composer\Package\CompletePackage
$json array
return Composer\Package\CompletePackage

mergeAutoload() protected method

Merge autoload or autoload-dev into a RootPackageInterface
protected mergeAutoload ( string $type, Composer\Package\RootPackageInterface $root )
$type string 'autoload' or 'devAutoload'
$root Composer\Package\RootPackageInterface

mergeDevInto() public method

Merge just the dev portion into a RootPackageInterface
public mergeDevInto ( Composer\Package\RootPackageInterface $root, PluginState $state )
$root Composer\Package\RootPackageInterface
$state PluginState

mergeExtra() public method

Merge extra config into a RootPackageInterface
public mergeExtra ( Composer\Package\RootPackageInterface $root, PluginState $state )
$root Composer\Package\RootPackageInterface
$state PluginState

mergeExtraArray() public static method

Merges two arrays either via arrayMergeDeep or via array_merge.
public static mergeExtraArray ( boolean $mergeDeep, array $array1, array $array2 ) : array
$mergeDeep boolean
$array1 array
$array2 array
return array

mergeInto() public method

Merge this package into a RootPackageInterface
public mergeInto ( Composer\Package\RootPackageInterface $root, PluginState $state )
$root Composer\Package\RootPackageInterface
$state PluginState

mergeOrDefer() protected method

Merge two collections of package links and collect duplicates for subsequent processing.
protected mergeOrDefer ( string $type, array $origin, array $merge, PluginState $state ) : array
$type string 'require' or 'require-dev'
$origin array Primary collection
$merge array Additional collection
$state PluginState
return array Merged collection

mergeReferences() protected method

Update the root packages reference information.
protected mergeReferences ( Composer\Package\RootPackageInterface $root )
$root Composer\Package\RootPackageInterface

mergeRequires() protected method

Merge require or require-dev into a RootPackageInterface
protected mergeRequires ( string $type, Composer\Package\RootPackageInterface $root, PluginState $state )
$type string 'require' or 'require-dev'
$root Composer\Package\RootPackageInterface
$state PluginState

mergeStabilityFlags() protected method

Extract and merge stability flags from the given collection of requires and merge them into a RootPackageInterface
protected mergeStabilityFlags ( Composer\Package\RootPackageInterface $root, array $requires )
$root Composer\Package\RootPackageInterface
$requires array

mergeSuggests() protected method

Merge suggested packages into a RootPackageInterface
protected mergeSuggests ( Composer\Package\RootPackageInterface $root )
$root Composer\Package\RootPackageInterface

prependRepositories() protected method

Add a collection of repositories described by the given configuration to the given package and the global repository manager.
protected prependRepositories ( Composer\Package\RootPackageInterface $root )
$root Composer\Package\RootPackageInterface

readPackageJson() protected method

The package contents are fixed up to be usable to create a Package object by providing dummy "name" and "version" values if they have not been provided in the file. This is consistent with the default root package loading behavior of Composer.
protected readPackageJson ( string $path ) : array
$path string
return array

replaceSelfVersionDependencies() protected method

Update Links with a 'self.version' constraint with the root package's version.
protected replaceSelfVersionDependencies ( string $type, array $links, Composer\Package\RootPackageInterface $root ) : array
$type string Link type
$links array
$root Composer\Package\RootPackageInterface
return array

unwrapIfNeeded() public static method

In Composer versions before 599ad77 the RootPackageInterface only defines a sub-set of operations needed by composer-merge-plugin and RootAliasPackage only implemented those methods defined by the interface. Most of the unimplemented methods in RootAliasPackage can be worked around because the getter methods that are implemented proxy to the aliased package which we can modify by unwrapping. The exception being modifying the 'conflicts', 'provides' and 'replaces' collections. We have no way to actually modify those collections unfortunately in older versions of Composer.
public static unwrapIfNeeded ( Composer\Package\RootPackageInterface $root, string $method = 'setExtra' ) : Composer\Package\RootPackageInterface | Composer\Package\RootPackage
$root Composer\Package\RootPackageInterface
$method string Method needed
return Composer\Package\RootPackageInterface | Composer\Package\RootPackage

Property Details

$composer protected property

protected Composer,Composer $composer
return Composer\Composer

$json protected property

protected array $json
return array

$logger protected property

protected Logger,Wikimedia\Composer $logger
return Wikimedia\Composer\Logger

$package protected property

protected CompletePackage,Composer\Package $package
return Composer\Package\CompletePackage

$path protected property

protected string $path
return string

$versionParser protected property

protected VersionParser,Composer\Package\Version $versionParser
return Composer\Package\Version\VersionParser