PackageInterface.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Package;
  12. use Composer\Package\LinkConstraint\LinkConstraintInterface;
  13. use Composer\Repository\RepositoryInterface;
  14. /**
  15. * @author Nils Adermann <naderman@naderman.de>
  16. */
  17. interface PackageInterface
  18. {
  19. /**
  20. * Returns the package's name without version info, thus not a unique identifier
  21. *
  22. * @return string package name
  23. */
  24. function getName();
  25. /**
  26. * Returns the package's pretty (i.e. with proper case) name
  27. *
  28. * @return string package name
  29. */
  30. function getPrettyName();
  31. /**
  32. * Returns a set of names that could refer to this package
  33. *
  34. * No version or release type information should be included in any of the
  35. * names. Provided or replaced package names need to be returned as well.
  36. *
  37. * @return array An array of strings referring to this package
  38. */
  39. function getNames();
  40. /**
  41. * Allows the solver to set an id for this package to refer to it.
  42. *
  43. * @param int $id
  44. */
  45. function setId($id);
  46. /**
  47. * Retrieves the package's id set through setId
  48. *
  49. * @return int The previously set package id
  50. */
  51. function getId();
  52. /**
  53. * Checks if the package matches the given constraint directly or through
  54. * provided or replaced packages
  55. *
  56. * @param string $name Name of the package to be matched
  57. * @param LinkConstraintInterface $constraint The constraint to verify
  58. * @return bool Whether this package matches the name and constraint
  59. */
  60. function matches($name, LinkConstraintInterface $constraint);
  61. /**
  62. * Returns the package type, e.g. library
  63. *
  64. * @return string The package type
  65. */
  66. function getType();
  67. /**
  68. * Returns the package targetDir property
  69. *
  70. * @return string The package targetDir
  71. */
  72. function getTargetDir();
  73. /**
  74. * Returns the package extra data
  75. *
  76. * @return array The package extra data
  77. */
  78. function getExtra();
  79. /**
  80. * Sets source from which this package was installed (source/dist).
  81. *
  82. * @param string $type source/dist
  83. */
  84. function setInstallationSource($type);
  85. /**
  86. * Returns source from which this package was installed (source/dist).
  87. *
  88. * @param string $type source/dist
  89. */
  90. function getInstallationSource();
  91. /**
  92. * Returns the repository type of this package, e.g. git, svn
  93. *
  94. * @return string The repository type
  95. */
  96. function getSourceType();
  97. /**
  98. * Returns the repository url of this package, e.g. git://github.com/naderman/composer.git
  99. *
  100. * @return string The repository url
  101. */
  102. function getSourceUrl();
  103. /**
  104. * Returns the repository reference of this package, e.g. master, 1.0.0 or a commit hash for git
  105. *
  106. * @return string The repository reference
  107. */
  108. function getSourceReference();
  109. /**
  110. * Returns the type of the distribution archive of this version, e.g. zip, tarball
  111. *
  112. * @return string The repository type
  113. */
  114. function getDistType();
  115. /**
  116. * Returns the url of the distribution archive of this version
  117. *
  118. * @return string
  119. */
  120. function getDistUrl();
  121. /**
  122. * Returns the reference of the distribution archive of this version, e.g. master, 1.0.0 or a commit hash for git
  123. *
  124. * @return string
  125. */
  126. function getDistReference();
  127. /**
  128. * Returns the sha1 checksum for the distribution archive of this version
  129. *
  130. * @return string
  131. */
  132. function getDistSha1Checksum();
  133. /**
  134. * Returns the version of this package
  135. *
  136. * @return string version
  137. */
  138. function getVersion();
  139. /**
  140. * Returns the package license, e.g. MIT, BSD, GPL
  141. *
  142. * @return string The package license
  143. */
  144. function getLicense();
  145. /**
  146. * Returns a set of links to packages which need to be installed before
  147. * this package can be installed
  148. *
  149. * @return array An array of package links defining required packages
  150. */
  151. function getRequires();
  152. /**
  153. * Returns a set of links to packages which must not be installed at the
  154. * same time as this package
  155. *
  156. * @return array An array of package links defining conflicting packages
  157. */
  158. function getConflicts();
  159. /**
  160. * Returns a set of links to virtual packages that are provided through
  161. * this package
  162. *
  163. * @return array An array of package links defining provided packages
  164. */
  165. function getProvides();
  166. /**
  167. * Returns a set of links to packages which can alternatively be
  168. * satisfied by installing this package
  169. *
  170. * @return array An array of package links defining replaced packages
  171. */
  172. function getReplaces();
  173. /**
  174. * Returns a set of links to packages which are recommended in
  175. * combination with this package. These would most likely be installed
  176. * automatically in combination with this package.
  177. *
  178. * @return array An array of package links defining recommended packages
  179. */
  180. function getRecommends();
  181. /**
  182. * Returns a set of links to packages which are suggested in combination
  183. * with this package. These can be suggested to the user, but will not be
  184. * automatically installed with this package.
  185. *
  186. * @return array An array of package links defining suggested packages
  187. */
  188. function getSuggests();
  189. /**
  190. * Returns an associative array of autoloading rules
  191. *
  192. * {"<type>": {"<namespace": "<directory>"}}
  193. *
  194. * Type is either "psr0" or "pear". Namespaces are mapped to directories
  195. * for autoloading using the type specified.
  196. *
  197. * @return array Mapping of autoloading rules
  198. */
  199. function getAutoload();
  200. /**
  201. * Stores a reference to the repository that owns the package
  202. *
  203. * @param RepositoryInterface $repository
  204. */
  205. function setRepository(RepositoryInterface $repository);
  206. /**
  207. * Returns a reference to the repository that owns the package
  208. *
  209. * @return RepositoryInterface
  210. */
  211. function getRepository();
  212. /**
  213. * Returns package unique name, constructed from name, version and release type.
  214. *
  215. * @return string
  216. */
  217. function getUniqueName();
  218. /**
  219. * Converts the package into a readable and unique string
  220. *
  221. * @return string
  222. */
  223. function __toString();
  224. }