PackageInterface.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 whether the package is a development virtual package or a concrete one
  63. *
  64. * @return Boolean
  65. */
  66. function isDev();
  67. /**
  68. * Returns the package type, e.g. library
  69. *
  70. * @return string The package type
  71. */
  72. function getType();
  73. /**
  74. * Returns the package targetDir property
  75. *
  76. * @return string The package targetDir
  77. */
  78. function getTargetDir();
  79. /**
  80. * Returns the package extra data
  81. *
  82. * @return array The package extra data
  83. */
  84. function getExtra();
  85. /**
  86. * Sets source from which this package was installed (source/dist).
  87. *
  88. * @param string $type source/dist
  89. */
  90. function setInstallationSource($type);
  91. /**
  92. * Returns source from which this package was installed (source/dist).
  93. *
  94. * @param string $type source/dist
  95. */
  96. function getInstallationSource();
  97. /**
  98. * Returns the repository type of this package, e.g. git, svn
  99. *
  100. * @return string The repository type
  101. */
  102. function getSourceType();
  103. /**
  104. * Returns the repository url of this package, e.g. git://github.com/naderman/composer.git
  105. *
  106. * @return string The repository url
  107. */
  108. function getSourceUrl();
  109. /**
  110. * Returns the repository reference of this package, e.g. master, 1.0.0 or a commit hash for git
  111. *
  112. * @return string The repository reference
  113. */
  114. function getSourceReference();
  115. /**
  116. * Returns the type of the distribution archive of this version, e.g. zip, tarball
  117. *
  118. * @return string The repository type
  119. */
  120. function getDistType();
  121. /**
  122. * Returns the url of the distribution archive of this version
  123. *
  124. * @return string
  125. */
  126. function getDistUrl();
  127. /**
  128. * Returns the reference of the distribution archive of this version, e.g. master, 1.0.0 or a commit hash for git
  129. *
  130. * @return string
  131. */
  132. function getDistReference();
  133. /**
  134. * Returns the sha1 checksum for the distribution archive of this version
  135. *
  136. * @return string
  137. */
  138. function getDistSha1Checksum();
  139. /**
  140. * Returns the scripts of this package
  141. *
  142. * @return array array('script name' => array('listeners'))
  143. */
  144. function getScripts();
  145. /**
  146. * Returns the version of this package
  147. *
  148. * @return string version
  149. */
  150. function getVersion();
  151. /**
  152. * Returns the pretty (i.e. non-normalized) version string of this package
  153. *
  154. * @return string version
  155. */
  156. function getPrettyVersion();
  157. /**
  158. * Returns the package license, e.g. MIT, BSD, GPL
  159. *
  160. * @return string The package license
  161. */
  162. function getLicense();
  163. /**
  164. * Returns a set of links to packages which need to be installed before
  165. * this package can be installed
  166. *
  167. * @return array An array of package links defining required packages
  168. */
  169. function getRequires();
  170. /**
  171. * Returns a set of links to packages which must not be installed at the
  172. * same time as this package
  173. *
  174. * @return array An array of package links defining conflicting packages
  175. */
  176. function getConflicts();
  177. /**
  178. * Returns a set of links to virtual packages that are provided through
  179. * this package
  180. *
  181. * @return array An array of package links defining provided packages
  182. */
  183. function getProvides();
  184. /**
  185. * Returns a set of links to packages which can alternatively be
  186. * satisfied by installing this package
  187. *
  188. * @return array An array of package links defining replaced packages
  189. */
  190. function getReplaces();
  191. /**
  192. * Returns a set of links to packages which are recommended in
  193. * combination with this package. These would most likely be installed
  194. * automatically in combination with this package.
  195. *
  196. * @return array An array of package links defining recommended packages
  197. */
  198. function getRecommends();
  199. /**
  200. * Returns a set of links to packages which are suggested in combination
  201. * with this package. These can be suggested to the user, but will not be
  202. * automatically installed with this package.
  203. *
  204. * @return array An array of package links defining suggested packages
  205. */
  206. function getSuggests();
  207. /**
  208. * Returns an associative array of autoloading rules
  209. *
  210. * {"<type>": {"<namespace": "<directory>"}}
  211. *
  212. * Type is either "psr-0" or "pear". Namespaces are mapped to directories
  213. * for autoloading using the type specified.
  214. *
  215. * @return array Mapping of autoloading rules
  216. */
  217. function getAutoload();
  218. /**
  219. * Returns an array of repositories
  220. *
  221. * {"<type>": {<config key/values>}}
  222. *
  223. * @return array Repositories
  224. */
  225. function getRepositories();
  226. /**
  227. * Stores a reference to the repository that owns the package
  228. *
  229. * @param RepositoryInterface $repository
  230. */
  231. function setRepository(RepositoryInterface $repository);
  232. /**
  233. * Returns a reference to the repository that owns the package
  234. *
  235. * @return RepositoryInterface
  236. */
  237. function getRepository();
  238. /**
  239. * Returns the release date of the package
  240. *
  241. * @return DateTime
  242. */
  243. function getReleaseDate();
  244. /**
  245. * Returns an array of keywords relating to the package
  246. *
  247. * @return array
  248. */
  249. function getKeywords();
  250. /**
  251. * Returns the package description
  252. *
  253. * @return string
  254. */
  255. function getDescription();
  256. /**
  257. * Returns the package binaries
  258. *
  259. * @return string
  260. */
  261. function getBinaries();
  262. /**
  263. * Returns the package homepage
  264. *
  265. * @return string
  266. */
  267. function getHomepage();
  268. /**
  269. * Returns an array of authors of the package
  270. *
  271. * Each item can contain name/homepage/email keys
  272. *
  273. * @return array
  274. */
  275. function getAuthors();
  276. /**
  277. * Returns package unique name, constructed from name and version.
  278. *
  279. * @return string
  280. */
  281. function getUniqueName();
  282. /**
  283. * Converts the package into a readable and unique string
  284. *
  285. * @return string
  286. */
  287. function __toString();
  288. }