Merge pull request #1015 from Seldaek/memory
Reduce memory usage by only loading packages that are actually needed, fixes #456main
commit
01593e0628
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Package;
|
||||
|
||||
use Composer\Package\Version\VersionParser;
|
||||
|
||||
/**
|
||||
* Package containing additional metadata that is not used by the solver
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class CompletePackage extends Package implements CompletePackageInterface
|
||||
{
|
||||
protected $repositories;
|
||||
protected $license = array();
|
||||
protected $keywords;
|
||||
protected $authors;
|
||||
protected $description;
|
||||
protected $homepage;
|
||||
protected $scripts = array();
|
||||
protected $support = array();
|
||||
|
||||
/**
|
||||
* @param array $scripts
|
||||
*/
|
||||
public function setScripts(array $scripts)
|
||||
{
|
||||
$this->scripts = $scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getScripts()
|
||||
{
|
||||
return $this->scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the repositories
|
||||
*
|
||||
* @param string $repositories
|
||||
*/
|
||||
public function setRepositories($repositories)
|
||||
{
|
||||
$this->repositories = $repositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRepositories()
|
||||
{
|
||||
return $this->repositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the license
|
||||
*
|
||||
* @param array $license
|
||||
*/
|
||||
public function setLicense(array $license)
|
||||
{
|
||||
$this->license = $license;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getLicense()
|
||||
{
|
||||
return $this->license;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the keywords
|
||||
*
|
||||
* @param array $keywords
|
||||
*/
|
||||
public function setKeywords(array $keywords)
|
||||
{
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getKeywords()
|
||||
{
|
||||
return $this->keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the authors
|
||||
*
|
||||
* @param array $authors
|
||||
*/
|
||||
public function setAuthors(array $authors)
|
||||
{
|
||||
$this->authors = $authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
return $this->authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description
|
||||
*
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the homepage
|
||||
*
|
||||
* @param string $homepage
|
||||
*/
|
||||
public function setHomepage($homepage)
|
||||
{
|
||||
$this->homepage = $homepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getHomepage()
|
||||
{
|
||||
return $this->homepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the support information
|
||||
*
|
||||
* @param array $support
|
||||
*/
|
||||
public function setSupport(array $support)
|
||||
{
|
||||
$this->support = $support;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSupport()
|
||||
{
|
||||
return $this->support;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Package;
|
||||
|
||||
/**
|
||||
* Defines package metadata that is not necessarily needed for solving and installing packages
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
interface CompletePackageInterface extends PackageInterface
|
||||
{
|
||||
/**
|
||||
* Returns the scripts of this package
|
||||
*
|
||||
* @return array array('script name' => array('listeners'))
|
||||
*/
|
||||
public function getScripts();
|
||||
|
||||
/**
|
||||
* Returns an array of repositories
|
||||
*
|
||||
* {"<type>": {<config key/values>}}
|
||||
*
|
||||
* @return array Repositories
|
||||
*/
|
||||
public function getRepositories();
|
||||
|
||||
/**
|
||||
* Returns the package license, e.g. MIT, BSD, GPL
|
||||
*
|
||||
* @return array The package licenses
|
||||
*/
|
||||
public function getLicense();
|
||||
|
||||
/**
|
||||
* Returns an array of keywords relating to the package
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getKeywords();
|
||||
|
||||
/**
|
||||
* Returns the package description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* Returns the package homepage
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHomepage();
|
||||
|
||||
/**
|
||||
* Returns an array of authors of the package
|
||||
*
|
||||
* Each item can contain name/homepage/email keys
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors();
|
||||
|
||||
/**
|
||||
* Returns the support information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSupport();
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Package;
|
||||
|
||||
use Composer\Package\Version\VersionParser;
|
||||
|
||||
/**
|
||||
* The root package represents the project's composer.json and contains additional metadata
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class RootPackage extends CompletePackage implements RootPackageInterface
|
||||
{
|
||||
protected $minimumStability = 'stable';
|
||||
protected $stabilityFlags = array();
|
||||
protected $references = array();
|
||||
|
||||
/**
|
||||
* Set the minimumStability
|
||||
*
|
||||
* @param string $minimumStability
|
||||
*/
|
||||
public function setMinimumStability($minimumStability)
|
||||
{
|
||||
$this->minimumStability = $minimumStability;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMinimumStability()
|
||||
{
|
||||
return $this->minimumStability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stabilityFlags
|
||||
*
|
||||
* @param array $stabilityFlags
|
||||
*/
|
||||
public function setStabilityFlags(array $stabilityFlags)
|
||||
{
|
||||
$this->stabilityFlags = $stabilityFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getStabilityFlags()
|
||||
{
|
||||
return $this->stabilityFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the references
|
||||
*
|
||||
* @param array $references
|
||||
*/
|
||||
public function setReferences(array $references)
|
||||
{
|
||||
$this->references = $references;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getReferences()
|
||||
{
|
||||
return $this->references;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Package;
|
||||
|
||||
/**
|
||||
* Defines additional fields that are only needed for the root package
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
interface RootPackageInterface extends CompletePackageInterface
|
||||
{
|
||||
/**
|
||||
* Returns the minimum stability of the package
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMinimumStability();
|
||||
|
||||
/**
|
||||
* Returns the stability flags to apply to dependencies
|
||||
*
|
||||
* array('foo/bar' => 'dev')
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStabilityFlags();
|
||||
|
||||
/**
|
||||
* Returns a set of package names and source references that must be enforced on them
|
||||
*
|
||||
* array('foo/bar' => 'abcd1234')
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReferences();
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Repository;
|
||||
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
interface StreamableRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return partial package data without loading them all to save on memory
|
||||
*
|
||||
* The function must return an array of package arrays.
|
||||
*
|
||||
* The package array must contain the following fields:
|
||||
* - name: package name (normalized/lowercased)
|
||||
* - repo: reference to the repository instance
|
||||
* - version: normalized version
|
||||
* - replace: array of package name => version constraint, optional
|
||||
* - provide: array of package name => version constraint, optional
|
||||
* - alias: pretty alias that this package should be aliased to, optional
|
||||
* - alias_normalized: normalized alias that this package should be aliased to, optional
|
||||
*
|
||||
* Any additional information can be returned and will be sent back
|
||||
* into loadPackage/loadAliasPackage for completing the package loading
|
||||
* when it's needed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMinimalPackages();
|
||||
|
||||
/**
|
||||
* Loads a package from minimal info of the package
|
||||
*
|
||||
* @param array $data the minimal info as was returned by getMinimalPackage
|
||||
* @return PackageInterface
|
||||
*/
|
||||
public function loadPackage(array $data);
|
||||
|
||||
/**
|
||||
* Loads an alias package from minimal info of the package
|
||||
*
|
||||
* @param array $data the minimal info as was returned by getMinimalPackage
|
||||
* @param PackageInterface $aliasOf the package which this alias is an alias of
|
||||
* @return AliasPackage
|
||||
*/
|
||||
public function loadAliasPackage(array $data, PackageInterface $aliasOf);
|
||||
}
|
Loading…
Reference in New Issue