PackageInterface.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 pretty (i.e. non-normalized) version string of this package
  141. *
  142. * @return string version
  143. */
  144. function getPrettyVersion();
  145. /**
  146. * Returns the package license, e.g. MIT, BSD, GPL
  147. *
  148. * @return string The package license
  149. */
  150. function getLicense();
  151. /**
  152. * Returns a set of links to packages which need to be installed before
  153. * this package can be installed
  154. *
  155. * @return array An array of package links defining required packages
  156. */
  157. function getRequires();
  158. /**
  159. * Returns a set of links to packages which must not be installed at the
  160. * same time as this package
  161. *
  162. * @return array An array of package links defining conflicting packages
  163. */
  164. function getConflicts();
  165. /**
  166. * Returns a set of links to virtual packages that are provided through
  167. * this package
  168. *
  169. * @return array An array of package links defining provided packages
  170. */
  171. function getProvides();
  172. /**
  173. * Returns a set of links to packages which can alternatively be
  174. * satisfied by installing this package
  175. *
  176. * @return array An array of package links defining replaced packages
  177. */
  178. function getReplaces();
  179. /**
  180. * Returns a set of links to packages which are recommended in
  181. * combination with this package. These would most likely be installed
  182. * automatically in combination with this package.
  183. *
  184. * @return array An array of package links defining recommended packages
  185. */
  186. function getRecommends();
  187. /**
  188. * Returns a set of links to packages which are suggested in combination
  189. * with this package. These can be suggested to the user, but will not be
  190. * automatically installed with this package.
  191. *
  192. * @return array An array of package links defining suggested packages
  193. */
  194. function getSuggests();
  195. /**
  196. * Returns an associative array of autoloading rules
  197. *
  198. * {"<type>": {"<namespace": "<directory>"}}
  199. *
  200. * Type is either "psr-0" or "pear". Namespaces are mapped to directories
  201. * for autoloading using the type specified.
  202. *
  203. * @return array Mapping of autoloading rules
  204. */
  205. function getAutoload();
  206. /**
  207. * Returns an array of repositories
  208. *
  209. * {"<type>": {<config key/values>}}
  210. *
  211. * @return array Repositories
  212. */
  213. function getRepositories();
  214. /**
  215. * Stores a reference to the repository that owns the package
  216. *
  217. * @param RepositoryInterface $repository
  218. */
  219. function setRepository(RepositoryInterface $repository);
  220. /**
  221. * Returns a reference to the repository that owns the package
  222. *
  223. * @return RepositoryInterface
  224. */
  225. function getRepository();
  226. /**
  227. * Returns the release date of the package
  228. *
  229. * @return DateTime
  230. */
  231. function getReleaseDate();
  232. /**
  233. * Returns an array of keywords relating to the package
  234. *
  235. * @return array
  236. */
  237. function getKeywords();
  238. /**
  239. * Returns an array of authors of the package
  240. *
  241. * Each item can contain name/homepage/email keys
  242. *
  243. * @return array
  244. */
  245. function getAuthors();
  246. /**
  247. * Returns package unique name, constructed from name and version.
  248. *
  249. * @return string
  250. */
  251. function getUniqueName();
  252. /**
  253. * Converts the package into a readable and unique string
  254. *
  255. * @return string
  256. */
  257. function __toString();
  258. }