MemoryPackage.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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\Version\VersionParser;
  13. /**
  14. * A package with setters for all members to create it dynamically in memory
  15. *
  16. * @author Nils Adermann <naderman@naderman.de>
  17. */
  18. class MemoryPackage extends BasePackage
  19. {
  20. protected $type;
  21. protected $targetDir;
  22. protected $installationSource;
  23. protected $sourceType;
  24. protected $sourceUrl;
  25. protected $sourceReference;
  26. protected $distType;
  27. protected $distUrl;
  28. protected $distReference;
  29. protected $distSha1Checksum;
  30. protected $version;
  31. protected $prettyVersion;
  32. protected $repositories;
  33. protected $license = array();
  34. protected $releaseDate;
  35. protected $keywords;
  36. protected $authors;
  37. protected $description;
  38. protected $homepage;
  39. protected $extra = array();
  40. protected $binaries = array();
  41. protected $scripts = array();
  42. protected $aliases = array();
  43. protected $alias;
  44. protected $prettyAlias;
  45. protected $dev;
  46. // TODO BC change dev to stable end of june?
  47. protected $minimumStability = 'dev';
  48. protected $stabilityFlags = array();
  49. protected $requires = array();
  50. protected $conflicts = array();
  51. protected $provides = array();
  52. protected $replaces = array();
  53. protected $devRequires = array();
  54. protected $suggests = array();
  55. protected $autoload = array();
  56. protected $includePaths = array();
  57. /**
  58. * Creates a new in memory package.
  59. *
  60. * @param string $name The package's name
  61. * @param string $version The package's version
  62. * @param string $prettyVersion The package's non-normalized version
  63. */
  64. public function __construct($name, $version, $prettyVersion)
  65. {
  66. parent::__construct($name);
  67. $this->version = $version;
  68. $this->prettyVersion = $prettyVersion;
  69. $this->stability = VersionParser::parseStability($version);
  70. $this->dev = $this->stability === 'dev';
  71. }
  72. /**
  73. * {@inheritDoc}
  74. */
  75. public function isDev()
  76. {
  77. return $this->dev;
  78. }
  79. /**
  80. * @param string $type
  81. */
  82. public function setType($type)
  83. {
  84. $this->type = $type;
  85. }
  86. /**
  87. * {@inheritDoc}
  88. */
  89. public function getType()
  90. {
  91. return $this->type ?: 'library';
  92. }
  93. /**
  94. * {@inheritDoc}
  95. */
  96. public function getStability()
  97. {
  98. return $this->stability;
  99. }
  100. /**
  101. * @param string $targetDir
  102. */
  103. public function setTargetDir($targetDir)
  104. {
  105. $this->targetDir = $targetDir;
  106. }
  107. /**
  108. * {@inheritDoc}
  109. */
  110. public function getTargetDir()
  111. {
  112. return $this->targetDir;
  113. }
  114. /**
  115. * @param array $extra
  116. */
  117. public function setExtra(array $extra)
  118. {
  119. $this->extra = $extra;
  120. }
  121. /**
  122. * {@inheritDoc}
  123. */
  124. public function getExtra()
  125. {
  126. return $this->extra;
  127. }
  128. /**
  129. * @param array $binaries
  130. */
  131. public function setBinaries(array $binaries)
  132. {
  133. $this->binaries = $binaries;
  134. }
  135. /**
  136. * {@inheritDoc}
  137. */
  138. public function getBinaries()
  139. {
  140. return $this->binaries;
  141. }
  142. /**
  143. * @param array $scripts
  144. */
  145. public function setScripts(array $scripts)
  146. {
  147. $this->scripts = $scripts;
  148. }
  149. /**
  150. * {@inheritDoc}
  151. */
  152. public function getScripts()
  153. {
  154. return $this->scripts;
  155. }
  156. /**
  157. * @param array $aliases
  158. */
  159. public function setAliases(array $aliases)
  160. {
  161. $this->aliases = $aliases;
  162. }
  163. /**
  164. * {@inheritDoc}
  165. */
  166. public function getAliases()
  167. {
  168. return $this->aliases;
  169. }
  170. /**
  171. * @param string $alias
  172. */
  173. public function setAlias($alias)
  174. {
  175. $this->alias = $alias;
  176. }
  177. /**
  178. * {@inheritDoc}
  179. */
  180. public function getAlias()
  181. {
  182. return $this->alias;
  183. }
  184. /**
  185. * @param string $prettyAlias
  186. */
  187. public function setPrettyAlias($prettyAlias)
  188. {
  189. $this->prettyAlias = $prettyAlias;
  190. }
  191. /**
  192. * {@inheritDoc}
  193. */
  194. public function getPrettyAlias()
  195. {
  196. return $this->prettyAlias;
  197. }
  198. /**
  199. * {@inheritDoc}
  200. */
  201. public function setInstallationSource($type)
  202. {
  203. $this->installationSource = $type;
  204. }
  205. /**
  206. * {@inheritDoc}
  207. */
  208. public function getInstallationSource()
  209. {
  210. return $this->installationSource;
  211. }
  212. /**
  213. * @param string $type
  214. */
  215. public function setSourceType($type)
  216. {
  217. $this->sourceType = $type;
  218. }
  219. /**
  220. * {@inheritDoc}
  221. */
  222. public function getSourceType()
  223. {
  224. return $this->sourceType;
  225. }
  226. /**
  227. * @param string $url
  228. */
  229. public function setSourceUrl($url)
  230. {
  231. $this->sourceUrl = $url;
  232. }
  233. /**
  234. * {@inheritDoc}
  235. */
  236. public function getSourceUrl()
  237. {
  238. return $this->sourceUrl;
  239. }
  240. /**
  241. * @param string $reference
  242. */
  243. public function setSourceReference($reference)
  244. {
  245. $this->sourceReference = $reference;
  246. }
  247. /**
  248. * {@inheritDoc}
  249. */
  250. public function getSourceReference()
  251. {
  252. return $this->sourceReference;
  253. }
  254. /**
  255. * @param string $type
  256. */
  257. public function setDistType($type)
  258. {
  259. $this->distType = $type;
  260. }
  261. /**
  262. * {@inheritDoc}
  263. */
  264. public function getDistType()
  265. {
  266. return $this->distType;
  267. }
  268. /**
  269. * @param string $url
  270. */
  271. public function setDistUrl($url)
  272. {
  273. $this->distUrl = $url;
  274. }
  275. /**
  276. * {@inheritDoc}
  277. */
  278. public function getDistUrl()
  279. {
  280. return $this->distUrl;
  281. }
  282. /**
  283. * @param string $reference
  284. */
  285. public function setDistReference($reference)
  286. {
  287. $this->distReference = $reference;
  288. }
  289. /**
  290. * {@inheritDoc}
  291. */
  292. public function getDistReference()
  293. {
  294. return $this->distReference;
  295. }
  296. /**
  297. * @param string $sha1checksum
  298. */
  299. public function setDistSha1Checksum($sha1checksum)
  300. {
  301. $this->distSha1Checksum = $sha1checksum;
  302. }
  303. /**
  304. * {@inheritDoc}
  305. */
  306. public function getDistSha1Checksum()
  307. {
  308. return $this->distSha1Checksum;
  309. }
  310. /**
  311. * Set the repositories
  312. *
  313. * @param string $repositories
  314. */
  315. public function setRepositories($repositories)
  316. {
  317. $this->repositories = $repositories;
  318. }
  319. /**
  320. * {@inheritDoc}
  321. */
  322. public function getRepositories()
  323. {
  324. return $this->repositories;
  325. }
  326. /**
  327. * {@inheritDoc}
  328. */
  329. public function getVersion()
  330. {
  331. return $this->version;
  332. }
  333. /**
  334. * {@inheritDoc}
  335. */
  336. public function getPrettyVersion()
  337. {
  338. return $this->prettyVersion;
  339. }
  340. /**
  341. * Set the license
  342. *
  343. * @param array $license
  344. */
  345. public function setLicense(array $license)
  346. {
  347. $this->license = $license;
  348. }
  349. /**
  350. * {@inheritDoc}
  351. */
  352. public function getLicense()
  353. {
  354. return $this->license;
  355. }
  356. /**
  357. * Set the required packages
  358. *
  359. * @param array $requires A set of package links
  360. */
  361. public function setRequires(array $requires)
  362. {
  363. $this->requires = $requires;
  364. }
  365. /**
  366. * {@inheritDoc}
  367. */
  368. public function getRequires()
  369. {
  370. return $this->requires;
  371. }
  372. /**
  373. * Set the conflicting packages
  374. *
  375. * @param array $conflicts A set of package links
  376. */
  377. public function setConflicts(array $conflicts)
  378. {
  379. $this->conflicts = $conflicts;
  380. }
  381. /**
  382. * {@inheritDoc}
  383. */
  384. public function getConflicts()
  385. {
  386. return $this->conflicts;
  387. }
  388. /**
  389. * Set the provided virtual packages
  390. *
  391. * @param array $provides A set of package links
  392. */
  393. public function setProvides(array $provides)
  394. {
  395. $this->provides = $provides;
  396. }
  397. /**
  398. * {@inheritDoc}
  399. */
  400. public function getProvides()
  401. {
  402. return $this->provides;
  403. }
  404. /**
  405. * Set the packages this one replaces
  406. *
  407. * @param array $replaces A set of package links
  408. */
  409. public function setReplaces(array $replaces)
  410. {
  411. $this->replaces = $replaces;
  412. }
  413. /**
  414. * {@inheritDoc}
  415. */
  416. public function getReplaces()
  417. {
  418. return $this->replaces;
  419. }
  420. /**
  421. * Set the recommended packages
  422. *
  423. * @param array $devRequires A set of package links
  424. */
  425. public function setDevRequires(array $devRequires)
  426. {
  427. $this->devRequires = $devRequires;
  428. }
  429. /**
  430. * {@inheritDoc}
  431. */
  432. public function getDevRequires()
  433. {
  434. return $this->devRequires;
  435. }
  436. /**
  437. * Set the suggested packages
  438. *
  439. * @param array $suggests A set of package names/comments
  440. */
  441. public function setSuggests(array $suggests)
  442. {
  443. $this->suggests = $suggests;
  444. }
  445. /**
  446. * {@inheritDoc}
  447. */
  448. public function getSuggests()
  449. {
  450. return $this->suggests;
  451. }
  452. /**
  453. * Set the releaseDate
  454. *
  455. * @param DateTime $releaseDate
  456. */
  457. public function setReleaseDate(\DateTime $releaseDate)
  458. {
  459. $this->releaseDate = $releaseDate;
  460. }
  461. /**
  462. * {@inheritDoc}
  463. */
  464. public function getReleaseDate()
  465. {
  466. return $this->releaseDate;
  467. }
  468. /**
  469. * Set the keywords
  470. *
  471. * @param array $keywords
  472. */
  473. public function setKeywords(array $keywords)
  474. {
  475. $this->keywords = $keywords;
  476. }
  477. /**
  478. * {@inheritDoc}
  479. */
  480. public function getKeywords()
  481. {
  482. return $this->keywords;
  483. }
  484. /**
  485. * Set the authors
  486. *
  487. * @param array $authors
  488. */
  489. public function setAuthors(array $authors)
  490. {
  491. $this->authors = $authors;
  492. }
  493. /**
  494. * {@inheritDoc}
  495. */
  496. public function getAuthors()
  497. {
  498. return $this->authors;
  499. }
  500. /**
  501. * Set the description
  502. *
  503. * @param string $description
  504. */
  505. public function setDescription($description)
  506. {
  507. $this->description = $description;
  508. }
  509. /**
  510. * {@inheritDoc}
  511. */
  512. public function getDescription()
  513. {
  514. return $this->description;
  515. }
  516. /**
  517. * Set the homepage
  518. *
  519. * @param string $homepage
  520. */
  521. public function setHomepage($homepage)
  522. {
  523. $this->homepage = $homepage;
  524. }
  525. /**
  526. * {@inheritDoc}
  527. */
  528. public function getHomepage()
  529. {
  530. return $this->homepage;
  531. }
  532. /**
  533. * Set the minimumStability
  534. *
  535. * @param string $minimumStability
  536. */
  537. public function setMinimumStability($minimumStability)
  538. {
  539. $this->minimumStability = $minimumStability;
  540. }
  541. /**
  542. * {@inheritDoc}
  543. */
  544. public function getMinimumStability()
  545. {
  546. return $this->minimumStability;
  547. }
  548. /**
  549. * Set the stabilityFlags
  550. *
  551. * @param array $stabilityFlags
  552. */
  553. public function setStabilityFlags(array $stabilityFlags)
  554. {
  555. $this->stabilityFlags = $stabilityFlags;
  556. }
  557. /**
  558. * {@inheritDoc}
  559. */
  560. public function getStabilityFlags()
  561. {
  562. return $this->stabilityFlags;
  563. }
  564. /**
  565. * Set the autoload mapping
  566. *
  567. * @param array $autoload Mapping of autoloading rules
  568. */
  569. public function setAutoload(array $autoload)
  570. {
  571. $this->autoload = $autoload;
  572. }
  573. /**
  574. * {@inheritDoc}
  575. */
  576. public function getAutoload()
  577. {
  578. return $this->autoload;
  579. }
  580. /**
  581. * Sets the list of paths added to PHP's include path.
  582. *
  583. * @param array $includePaths List of directories.
  584. */
  585. public function setIncludePaths(array $includePaths)
  586. {
  587. $this->includePaths = $includePaths;
  588. }
  589. /**
  590. * {@inheritDoc}
  591. */
  592. public function getIncludePaths()
  593. {
  594. return $this->includePaths;
  595. }
  596. }