InstalledVersions.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. <?php
  2. namespace Composer;
  3. use Composer\Autoload\ClassLoader;
  4. use Composer\Semver\VersionParser;
  5. class InstalledVersions
  6. {
  7. private static $installed = array (
  8. 'root' =>
  9. array (
  10. 'pretty_version' => 'dev-master',
  11. 'version' => 'dev-master',
  12. 'aliases' =>
  13. array (
  14. ),
  15. 'reference' => '9e7f1bfcfef74d916aa745924cca31d7cac72310',
  16. 'name' => 'karsonzhang/fastadmin',
  17. ),
  18. 'versions' =>
  19. array (
  20. 'adbario/php-dot-notation' =>
  21. array (
  22. 'pretty_version' => '2.5.0',
  23. 'version' => '2.5.0.0',
  24. 'aliases' =>
  25. array (
  26. ),
  27. 'reference' => '081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae',
  28. ),
  29. 'alibabacloud/cloudauth-20190307' =>
  30. array (
  31. 'pretty_version' => '2.0.7',
  32. 'version' => '2.0.7.0',
  33. 'aliases' =>
  34. array (
  35. ),
  36. 'reference' => '8c0a3fb533a446d268ee1cca0d60cb995d0f2e55',
  37. ),
  38. 'alibabacloud/credentials' =>
  39. array (
  40. 'pretty_version' => '1.1.5',
  41. 'version' => '1.1.5.0',
  42. 'aliases' =>
  43. array (
  44. ),
  45. 'reference' => '1d8383ceef695974a88a3859c42e235fd2e3981a',
  46. ),
  47. 'alibabacloud/darabonba-openapi' =>
  48. array (
  49. 'pretty_version' => '0.2.9',
  50. 'version' => '0.2.9.0',
  51. 'aliases' =>
  52. array (
  53. ),
  54. 'reference' => '4cdfc36615f345786d668dfbaf68d9a301b6dbe2',
  55. ),
  56. 'alibabacloud/dysmsapi-20170525' =>
  57. array (
  58. 'pretty_version' => '2.0.24',
  59. 'version' => '2.0.24.0',
  60. 'aliases' =>
  61. array (
  62. ),
  63. 'reference' => '75d8a8c7259f53e58ba3330e004150841be6010d',
  64. ),
  65. 'alibabacloud/endpoint-util' =>
  66. array (
  67. 'pretty_version' => '0.1.1',
  68. 'version' => '0.1.1.0',
  69. 'aliases' =>
  70. array (
  71. ),
  72. 'reference' => 'f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5',
  73. ),
  74. 'alibabacloud/gateway-spi' =>
  75. array (
  76. 'pretty_version' => '1.0.0',
  77. 'version' => '1.0.0.0',
  78. 'aliases' =>
  79. array (
  80. ),
  81. 'reference' => '7440f77750c329d8ab252db1d1d967314ccd1fcb',
  82. ),
  83. 'alibabacloud/openapi-util' =>
  84. array (
  85. 'pretty_version' => '0.2.1',
  86. 'version' => '0.2.1.0',
  87. 'aliases' =>
  88. array (
  89. ),
  90. 'reference' => 'f31f7bcd835e08ca24b6b8ba33637eb4eceb093a',
  91. ),
  92. 'alibabacloud/openplatform-20191219' =>
  93. array (
  94. 'pretty_version' => '2.0.1',
  95. 'version' => '2.0.1.0',
  96. 'aliases' =>
  97. array (
  98. ),
  99. 'reference' => '02ffa72369f8649214f1cfa336b52a544735f517',
  100. ),
  101. 'alibabacloud/tea' =>
  102. array (
  103. 'pretty_version' => '3.2.1',
  104. 'version' => '3.2.1.0',
  105. 'aliases' =>
  106. array (
  107. ),
  108. 'reference' => '1619cb96c158384f72b873e1f85de8b299c9c367',
  109. ),
  110. 'alibabacloud/tea-fileform' =>
  111. array (
  112. 'pretty_version' => '0.3.4',
  113. 'version' => '0.3.4.0',
  114. 'aliases' =>
  115. array (
  116. ),
  117. 'reference' => '4bf0c75a045c8115aa8cb1a394bd08d8bb833181',
  118. ),
  119. 'alibabacloud/tea-oss-sdk' =>
  120. array (
  121. 'pretty_version' => '0.3.6',
  122. 'version' => '0.3.6.0',
  123. 'aliases' =>
  124. array (
  125. ),
  126. 'reference' => 'e28e70e2842b2e4da031a774209231bf08d7965c',
  127. ),
  128. 'alibabacloud/tea-oss-utils' =>
  129. array (
  130. 'pretty_version' => '0.3.1',
  131. 'version' => '0.3.1.0',
  132. 'aliases' =>
  133. array (
  134. ),
  135. 'reference' => '19f58fc509347f075664e377742d4f9e18465372',
  136. ),
  137. 'alibabacloud/tea-utils' =>
  138. array (
  139. 'pretty_version' => '0.2.19',
  140. 'version' => '0.2.19.0',
  141. 'aliases' =>
  142. array (
  143. ),
  144. 'reference' => '8dfc1a93e9415818e93a621b644abbb84981aea4',
  145. ),
  146. 'alibabacloud/tea-xml' =>
  147. array (
  148. 'pretty_version' => '0.2.4',
  149. 'version' => '0.2.4.0',
  150. 'aliases' =>
  151. array (
  152. ),
  153. 'reference' => '3e0c000bf536224eebbac913c371bef174c0a16a',
  154. ),
  155. 'easywechat-composer/easywechat-composer' =>
  156. array (
  157. 'pretty_version' => '1.4.1',
  158. 'version' => '1.4.1.0',
  159. 'aliases' =>
  160. array (
  161. ),
  162. 'reference' => '3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd',
  163. ),
  164. 'ezyang/htmlpurifier' =>
  165. array (
  166. 'pretty_version' => 'v4.16.0',
  167. 'version' => '4.16.0.0',
  168. 'aliases' =>
  169. array (
  170. ),
  171. 'reference' => '523407fb06eb9e5f3d59889b3978d5bfe94299c8',
  172. ),
  173. 'guzzlehttp/guzzle' =>
  174. array (
  175. 'pretty_version' => '7.7.0',
  176. 'version' => '7.7.0.0',
  177. 'aliases' =>
  178. array (
  179. ),
  180. 'reference' => 'fb7566caccf22d74d1ab270de3551f72a58399f5',
  181. ),
  182. 'guzzlehttp/promises' =>
  183. array (
  184. 'pretty_version' => '2.0.0',
  185. 'version' => '2.0.0.0',
  186. 'aliases' =>
  187. array (
  188. ),
  189. 'reference' => '3a494dc7dc1d7d12e511890177ae2d0e6c107da6',
  190. ),
  191. 'guzzlehttp/psr7' =>
  192. array (
  193. 'pretty_version' => '1.9.1',
  194. 'version' => '1.9.1.0',
  195. 'aliases' =>
  196. array (
  197. ),
  198. 'reference' => 'e4490cabc77465aaee90b20cfc9a770f8c04be6b',
  199. ),
  200. 'karsonzhang/fastadmin' =>
  201. array (
  202. 'pretty_version' => 'dev-master',
  203. 'version' => 'dev-master',
  204. 'aliases' =>
  205. array (
  206. ),
  207. 'reference' => '9e7f1bfcfef74d916aa745924cca31d7cac72310',
  208. ),
  209. 'karsonzhang/fastadmin-addons' =>
  210. array (
  211. 'pretty_version' => '1.3.3',
  212. 'version' => '1.3.3.0',
  213. 'aliases' =>
  214. array (
  215. ),
  216. 'reference' => 'f5bb4dabda55271b08371a8ae9355a205be48c56',
  217. ),
  218. 'lizhichao/one-sm' =>
  219. array (
  220. 'pretty_version' => '1.10',
  221. 'version' => '1.10.0.0',
  222. 'aliases' =>
  223. array (
  224. ),
  225. 'reference' => '687a012a44a5bfd4d9143a0234e1060543be455a',
  226. ),
  227. 'maennchen/zipstream-php' =>
  228. array (
  229. 'pretty_version' => '2.2.6',
  230. 'version' => '2.2.6.0',
  231. 'aliases' =>
  232. array (
  233. ),
  234. 'reference' => '30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f',
  235. ),
  236. 'markbaker/complex' =>
  237. array (
  238. 'pretty_version' => '3.0.2',
  239. 'version' => '3.0.2.0',
  240. 'aliases' =>
  241. array (
  242. ),
  243. 'reference' => '95c56caa1cf5c766ad6d65b6344b807c1e8405b9',
  244. ),
  245. 'markbaker/matrix' =>
  246. array (
  247. 'pretty_version' => '3.0.1',
  248. 'version' => '3.0.1.0',
  249. 'aliases' =>
  250. array (
  251. ),
  252. 'reference' => '728434227fe21be27ff6d86621a1b13107a2562c',
  253. ),
  254. 'monolog/monolog' =>
  255. array (
  256. 'pretty_version' => '2.9.1',
  257. 'version' => '2.9.1.0',
  258. 'aliases' =>
  259. array (
  260. ),
  261. 'reference' => 'f259e2b15fb95494c83f52d3caad003bbf5ffaa1',
  262. ),
  263. 'myclabs/php-enum' =>
  264. array (
  265. 'pretty_version' => '1.8.4',
  266. 'version' => '1.8.4.0',
  267. 'aliases' =>
  268. array (
  269. ),
  270. 'reference' => 'a867478eae49c9f59ece437ae7f9506bfaa27483',
  271. ),
  272. 'nelexa/zip' =>
  273. array (
  274. 'pretty_version' => '3.3.3',
  275. 'version' => '3.3.3.0',
  276. 'aliases' =>
  277. array (
  278. ),
  279. 'reference' => '501b52f6fc393a599b44ff348a42740e1eaac7c6',
  280. ),
  281. 'overtrue/pinyin' =>
  282. array (
  283. 'pretty_version' => '3.0.6',
  284. 'version' => '3.0.6.0',
  285. 'aliases' =>
  286. array (
  287. ),
  288. 'reference' => '3b781d267197b74752daa32814d3a2cf5d140779',
  289. ),
  290. 'overtrue/socialite' =>
  291. array (
  292. 'pretty_version' => '2.0.24',
  293. 'version' => '2.0.24.0',
  294. 'aliases' =>
  295. array (
  296. ),
  297. 'reference' => 'ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec',
  298. ),
  299. 'overtrue/wechat' =>
  300. array (
  301. 'pretty_version' => '4.9.0',
  302. 'version' => '4.9.0.0',
  303. 'aliases' =>
  304. array (
  305. ),
  306. 'reference' => '92791f5d957269c633b9aa175f842f6006f945b1',
  307. ),
  308. 'paragonie/random_compat' =>
  309. array (
  310. 'pretty_version' => 'v9.99.100',
  311. 'version' => '9.99.100.0',
  312. 'aliases' =>
  313. array (
  314. ),
  315. 'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a',
  316. ),
  317. 'phpoffice/phpspreadsheet' =>
  318. array (
  319. 'pretty_version' => '1.19.0',
  320. 'version' => '1.19.0.0',
  321. 'aliases' =>
  322. array (
  323. ),
  324. 'reference' => 'a9ab55bfae02eecffb3df669a2e19ba0e2f04bbf',
  325. ),
  326. 'pimple/pimple' =>
  327. array (
  328. 'pretty_version' => 'v3.5.0',
  329. 'version' => '3.5.0.0',
  330. 'aliases' =>
  331. array (
  332. ),
  333. 'reference' => 'a94b3a4db7fb774b3d78dad2315ddc07629e1bed',
  334. ),
  335. 'psr/cache' =>
  336. array (
  337. 'pretty_version' => '1.0.1',
  338. 'version' => '1.0.1.0',
  339. 'aliases' =>
  340. array (
  341. ),
  342. 'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8',
  343. ),
  344. 'psr/cache-implementation' =>
  345. array (
  346. 'provided' =>
  347. array (
  348. 0 => '1.0|2.0',
  349. ),
  350. ),
  351. 'psr/container' =>
  352. array (
  353. 'pretty_version' => '2.0.2',
  354. 'version' => '2.0.2.0',
  355. 'aliases' =>
  356. array (
  357. ),
  358. 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963',
  359. ),
  360. 'psr/event-dispatcher' =>
  361. array (
  362. 'pretty_version' => '1.0.0',
  363. 'version' => '1.0.0.0',
  364. 'aliases' =>
  365. array (
  366. ),
  367. 'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0',
  368. ),
  369. 'psr/event-dispatcher-implementation' =>
  370. array (
  371. 'provided' =>
  372. array (
  373. 0 => '1.0',
  374. ),
  375. ),
  376. 'psr/http-client' =>
  377. array (
  378. 'pretty_version' => '1.0.2',
  379. 'version' => '1.0.2.0',
  380. 'aliases' =>
  381. array (
  382. ),
  383. 'reference' => '0955afe48220520692d2d09f7ab7e0f93ffd6a31',
  384. ),
  385. 'psr/http-client-implementation' =>
  386. array (
  387. 'provided' =>
  388. array (
  389. 0 => '1.0',
  390. ),
  391. ),
  392. 'psr/http-factory' =>
  393. array (
  394. 'pretty_version' => '1.0.2',
  395. 'version' => '1.0.2.0',
  396. 'aliases' =>
  397. array (
  398. ),
  399. 'reference' => 'e616d01114759c4c489f93b099585439f795fe35',
  400. ),
  401. 'psr/http-message' =>
  402. array (
  403. 'pretty_version' => '1.1',
  404. 'version' => '1.1.0.0',
  405. 'aliases' =>
  406. array (
  407. ),
  408. 'reference' => 'cb6ce4845ce34a8ad9e68117c10ee90a29919eba',
  409. ),
  410. 'psr/http-message-implementation' =>
  411. array (
  412. 'provided' =>
  413. array (
  414. 0 => '1.0',
  415. ),
  416. ),
  417. 'psr/log' =>
  418. array (
  419. 'pretty_version' => '1.1.4',
  420. 'version' => '1.1.4.0',
  421. 'aliases' =>
  422. array (
  423. ),
  424. 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
  425. ),
  426. 'psr/log-implementation' =>
  427. array (
  428. 'provided' =>
  429. array (
  430. 0 => '1.0.0 || 2.0.0 || 3.0.0',
  431. ),
  432. ),
  433. 'psr/simple-cache' =>
  434. array (
  435. 'pretty_version' => '1.0.1',
  436. 'version' => '1.0.1.0',
  437. 'aliases' =>
  438. array (
  439. ),
  440. 'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
  441. ),
  442. 'psr/simple-cache-implementation' =>
  443. array (
  444. 'provided' =>
  445. array (
  446. 0 => '1.0|2.0',
  447. ),
  448. ),
  449. 'ralouphie/getallheaders' =>
  450. array (
  451. 'pretty_version' => '3.0.3',
  452. 'version' => '3.0.3.0',
  453. 'aliases' =>
  454. array (
  455. ),
  456. 'reference' => '120b605dfeb996808c31b6477290a714d356e822',
  457. ),
  458. 'symfony/cache' =>
  459. array (
  460. 'pretty_version' => 'v5.4.25',
  461. 'version' => '5.4.25.0',
  462. 'aliases' =>
  463. array (
  464. ),
  465. 'reference' => 'e2013521c0f07473ae69a01fce0af78fc3ec0f23',
  466. ),
  467. 'symfony/cache-contracts' =>
  468. array (
  469. 'pretty_version' => 'v2.5.2',
  470. 'version' => '2.5.2.0',
  471. 'aliases' =>
  472. array (
  473. ),
  474. 'reference' => '64be4a7acb83b6f2bf6de9a02cee6dad41277ebc',
  475. ),
  476. 'symfony/cache-implementation' =>
  477. array (
  478. 'provided' =>
  479. array (
  480. 0 => '1.0|2.0',
  481. ),
  482. ),
  483. 'symfony/deprecation-contracts' =>
  484. array (
  485. 'pretty_version' => 'v2.5.2',
  486. 'version' => '2.5.2.0',
  487. 'aliases' =>
  488. array (
  489. ),
  490. 'reference' => 'e8b495ea28c1d97b5e0c121748d6f9b53d075c66',
  491. ),
  492. 'symfony/event-dispatcher' =>
  493. array (
  494. 'pretty_version' => 'v5.4.22',
  495. 'version' => '5.4.22.0',
  496. 'aliases' =>
  497. array (
  498. ),
  499. 'reference' => '1df20e45d56da29a4b1d8259dd6e950acbf1b13f',
  500. ),
  501. 'symfony/event-dispatcher-contracts' =>
  502. array (
  503. 'pretty_version' => 'v2.5.2',
  504. 'version' => '2.5.2.0',
  505. 'aliases' =>
  506. array (
  507. ),
  508. 'reference' => 'f98b54df6ad059855739db6fcbc2d36995283fe1',
  509. ),
  510. 'symfony/event-dispatcher-implementation' =>
  511. array (
  512. 'provided' =>
  513. array (
  514. 0 => '2.0',
  515. ),
  516. ),
  517. 'symfony/finder' =>
  518. array (
  519. 'pretty_version' => 'v5.4.21',
  520. 'version' => '5.4.21.0',
  521. 'aliases' =>
  522. array (
  523. ),
  524. 'reference' => '078e9a5e1871fcfe6a5ce421b539344c21afef19',
  525. ),
  526. 'symfony/http-foundation' =>
  527. array (
  528. 'pretty_version' => 'v5.4.25',
  529. 'version' => '5.4.25.0',
  530. 'aliases' =>
  531. array (
  532. ),
  533. 'reference' => 'f66be2706075c5f6325d2fe2b743a57fb5d23f6b',
  534. ),
  535. 'symfony/polyfill-mbstring' =>
  536. array (
  537. 'pretty_version' => 'v1.27.0',
  538. 'version' => '1.27.0.0',
  539. 'aliases' =>
  540. array (
  541. ),
  542. 'reference' => '8ad114f6b39e2c98a8b0e3bd907732c207c2b534',
  543. ),
  544. 'symfony/polyfill-php73' =>
  545. array (
  546. 'pretty_version' => 'v1.27.0',
  547. 'version' => '1.27.0.0',
  548. 'aliases' =>
  549. array (
  550. ),
  551. 'reference' => '9e8ecb5f92152187c4799efd3c96b78ccab18ff9',
  552. ),
  553. 'symfony/polyfill-php80' =>
  554. array (
  555. 'pretty_version' => 'v1.27.0',
  556. 'version' => '1.27.0.0',
  557. 'aliases' =>
  558. array (
  559. ),
  560. 'reference' => '7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936',
  561. ),
  562. 'symfony/psr-http-message-bridge' =>
  563. array (
  564. 'pretty_version' => 'v2.2.0',
  565. 'version' => '2.2.0.0',
  566. 'aliases' =>
  567. array (
  568. ),
  569. 'reference' => '28a732c05bbad801304ad5a5c674cf2970508993',
  570. ),
  571. 'symfony/service-contracts' =>
  572. array (
  573. 'pretty_version' => 'v1.1.2',
  574. 'version' => '1.1.2.0',
  575. 'aliases' =>
  576. array (
  577. ),
  578. 'reference' => '191afdcb5804db960d26d8566b7e9a2843cab3a0',
  579. ),
  580. 'symfony/var-exporter' =>
  581. array (
  582. 'pretty_version' => 'v4.4.43',
  583. 'version' => '4.4.43.0',
  584. 'aliases' =>
  585. array (
  586. ),
  587. 'reference' => '4a7a3a3d55c471d396e6d28011368b7b83cb518b',
  588. ),
  589. 'topthink/framework' =>
  590. array (
  591. 'pretty_version' => 'dev-master',
  592. 'version' => 'dev-master',
  593. 'aliases' =>
  594. array (
  595. 0 => '9999999-dev',
  596. ),
  597. 'reference' => '096811899433eb0eb0988f1fe1db56ebb521bf34',
  598. ),
  599. 'topthink/think-captcha' =>
  600. array (
  601. 'pretty_version' => 'v1.0.7',
  602. 'version' => '1.0.7.0',
  603. 'aliases' =>
  604. array (
  605. ),
  606. 'reference' => '0c55455df26a1626a60d0dc35d2d89002b741d44',
  607. ),
  608. 'topthink/think-helper' =>
  609. array (
  610. 'pretty_version' => 'v1.0.7',
  611. 'version' => '1.0.7.0',
  612. 'aliases' =>
  613. array (
  614. ),
  615. 'reference' => '5f92178606c8ce131d36b37a57c58eb71e55f019',
  616. ),
  617. 'topthink/think-installer' =>
  618. array (
  619. 'pretty_version' => 'v1.0.14',
  620. 'version' => '1.0.14.0',
  621. 'aliases' =>
  622. array (
  623. ),
  624. 'reference' => 'eae1740ac264a55c06134b6685dfb9f837d004d1',
  625. ),
  626. 'topthink/think-queue' =>
  627. array (
  628. 'pretty_version' => 'v1.1.6',
  629. 'version' => '1.1.6.0',
  630. 'aliases' =>
  631. array (
  632. ),
  633. 'reference' => '250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245',
  634. ),
  635. 'txthinking/mailer' =>
  636. array (
  637. 'pretty_version' => 'v2.0.1',
  638. 'version' => '2.0.1.0',
  639. 'aliases' =>
  640. array (
  641. ),
  642. 'reference' => '09013cf9dad3aac195f66ae5309e8c3343c018e9',
  643. ),
  644. ),
  645. );
  646. private static $canGetVendors;
  647. private static $installedByVendor = array();
  648. public static function getInstalledPackages()
  649. {
  650. $packages = array();
  651. foreach (self::getInstalled() as $installed) {
  652. $packages[] = array_keys($installed['versions']);
  653. }
  654. if (1 === \count($packages)) {
  655. return $packages[0];
  656. }
  657. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  658. }
  659. public static function isInstalled($packageName)
  660. {
  661. foreach (self::getInstalled() as $installed) {
  662. if (isset($installed['versions'][$packageName])) {
  663. return true;
  664. }
  665. }
  666. return false;
  667. }
  668. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  669. {
  670. $constraint = $parser->parseConstraints($constraint);
  671. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  672. return $provided->matches($constraint);
  673. }
  674. public static function getVersionRanges($packageName)
  675. {
  676. foreach (self::getInstalled() as $installed) {
  677. if (!isset($installed['versions'][$packageName])) {
  678. continue;
  679. }
  680. $ranges = array();
  681. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  682. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  683. }
  684. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  685. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  686. }
  687. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  688. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  689. }
  690. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  691. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  692. }
  693. return implode(' || ', $ranges);
  694. }
  695. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  696. }
  697. public static function getVersion($packageName)
  698. {
  699. foreach (self::getInstalled() as $installed) {
  700. if (!isset($installed['versions'][$packageName])) {
  701. continue;
  702. }
  703. if (!isset($installed['versions'][$packageName]['version'])) {
  704. return null;
  705. }
  706. return $installed['versions'][$packageName]['version'];
  707. }
  708. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  709. }
  710. public static function getPrettyVersion($packageName)
  711. {
  712. foreach (self::getInstalled() as $installed) {
  713. if (!isset($installed['versions'][$packageName])) {
  714. continue;
  715. }
  716. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  717. return null;
  718. }
  719. return $installed['versions'][$packageName]['pretty_version'];
  720. }
  721. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  722. }
  723. public static function getReference($packageName)
  724. {
  725. foreach (self::getInstalled() as $installed) {
  726. if (!isset($installed['versions'][$packageName])) {
  727. continue;
  728. }
  729. if (!isset($installed['versions'][$packageName]['reference'])) {
  730. return null;
  731. }
  732. return $installed['versions'][$packageName]['reference'];
  733. }
  734. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  735. }
  736. public static function getRootPackage()
  737. {
  738. $installed = self::getInstalled();
  739. return $installed[0]['root'];
  740. }
  741. public static function getRawData()
  742. {
  743. @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
  744. return self::$installed;
  745. }
  746. public static function getAllRawData()
  747. {
  748. return self::getInstalled();
  749. }
  750. public static function reload($data)
  751. {
  752. self::$installed = $data;
  753. self::$installedByVendor = array();
  754. }
  755. private static function getInstalled()
  756. {
  757. if (null === self::$canGetVendors) {
  758. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  759. }
  760. $installed = array();
  761. if (self::$canGetVendors) {
  762. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  763. if (isset(self::$installedByVendor[$vendorDir])) {
  764. $installed[] = self::$installedByVendor[$vendorDir];
  765. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  766. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  767. }
  768. }
  769. }
  770. $installed[] = self::$installed;
  771. return $installed;
  772. }
  773. }