composer.phar 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of Composer.
  5. *
  6. * (c) Nils Adermann <naderman@naderman.de>
  7. * Jordi Boggiano <j.boggiano@seld.be>
  8. *
  9. * For the full copyright and license information, please view
  10. * the license that is located at the bottom of this file.
  11. */
  12. // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
  13. if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) {
  14. if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
  15. ini_set('apc.cache_by_default', 0);
  16. } else {
  17. fwrite(STDERR, 'Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.'.PHP_EOL);
  18. fwrite(STDERR, 'Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.'.PHP_EOL);
  19. }
  20. }
  21. Phar::mapPhar('composer.phar');
  22. require 'phar://composer.phar/bin/composer';
  23. __HALT_COMPILER(); ?>
  24. .Ÿ�������� ���composer.phar����+���src/Composer/Autoload/AutoloadGenerator.php+€���e`+€��É‹Ýg¤������+���src/Composer/Autoload/ClassMapGenerator.phpÔ���e`Ô��ñ§¤���������src/Composer/Cache.phpJ���e`J��ˆ¿/‰¤������%���src/Composer/Command/AboutCommand.phpØ���e`Ø��ö÷;‡¤������'���src/Composer/Command/ArchiveCommand.phpÀ���e`À��Á’ =¤������$���src/Composer/Command/BaseCommand.phpE���e`E��Õ7z·¤������.���src/Composer/Command/BaseDependencyCommand.phpS���e`S��ªƒ"Ť������1���src/Composer/Command/CheckPlatformReqsCommand.php¹���e`¹��hV—¯¤������*���src/Composer/Command/ClearCacheCommand.phpó���e`ó��ˆ(*Ô¤������&���src/Composer/Command/ConfigCommand.phpûW���e`ûW���©»!¤������-���src/Composer/Command/CreateProjectCommand.php¤B���e`¤B��3t*%¤������'���src/Composer/Command/DependsCommand.phpñ���e`ñ��kU‹{¤������(���src/Composer/Command/DiagnoseCommand.phpWJ���e`WJ��Ã
  25. œ¤������,���src/Composer/Command/DumpAutoloadCommand.php±���e`±��a#®¤������$���src/Composer/Command/ExecCommand.phpœ���e`œ��
  26. ;…)¤������$���src/Composer/Command/FundCommand.php3 ���e`3 ��.½¤������&���src/Composer/Command/GlobalCommand.phpÅ ���e`Å ��©O:ü¤������$���src/Composer/Command/HomeCommand.php���e`��p—Τ������$���src/Composer/Command/InitCommand.phpy[���e`y[��›Uʤ������'���src/Composer/Command/InstallCommand.phpP���e`P��µœ¤������(���src/Composer/Command/LicensesCommand.phpZ���e`Z��OT@0¤������(���src/Composer/Command/OutdatedCommand.php� ���e`� ��7~½=¤������)���src/Composer/Command/ProhibitsCommand.php���e`��_¤éS¤������&���src/Composer/Command/RemoveCommand.php´)���e`´)��Y;”¤������'���src/Composer/Command/RequireCommand.php 7���e` 7��Í·Ǥ������)���src/Composer/Command/RunScriptCommand.phpF���e`F��8{O{¤������+���src/Composer/Command/ScriptAliasCommand.php¯���e`¯��?=Ѥ������&���src/Composer/Command/SearchCommand.phpT ���e`T ��ZÕ±¤������*���src/Composer/Command/SelfUpdateCommand.phpE���e`E��2ièϤ������$���src/Composer/Command/ShowCommand.phpf‹���e`f‹��Ï„X+¤������&���src/Composer/Command/StatusCommand.phpë���e`ë��£c}¤������(���src/Composer/Command/SuggestsCommand.php˜ ���e`˜ ��=c{à¤������&���src/Composer/Command/UpdateCommand.php3���e`3���æÀ¤������(���src/Composer/Command/ValidateCommand.phpG���e`G��§ a¤���������src/Composer/Composer.php ���e` ��sf2¤���������src/Composer/Config.php&���e`&��‡™ro¤������-���src/Composer/Config/ConfigSourceInterface.php���e`���û¤������(���src/Composer/Config/JsonConfigSource.phpi���e`i��9jQ*¤������$���src/Composer/Console/Application.php <���e` <��šÖH¨¤������*���src/Composer/Console/GithubActionError.phph���e`h��œQÆt¤������,���src/Composer/Console/HtmlOutputFormatter.php0���e`0��^КҤ������-���src/Composer/DependencyResolver/Decisions.phpº���e`º��:ÎK¤������1���src/Composer/DependencyResolver/DefaultPolicy.phpñ���e`ñ��róM¦¤������/���src/Composer/DependencyResolver/GenericRule.php¡���e`¡��v'ù
  27. ¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.phpQ���e`Q��í6Ĥ������3���src/Composer/DependencyResolver/LockTransaction.phps
  28. ���e`s
  29. ��­CÆ“¤������5���src/Composer/DependencyResolver/MultiConflictRule.php,���e`,��ðá¬$¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.php·���e`·��#Ò­’¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.phpß���e`ß��=Ù÷À¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.phpå���e`å��‡°¸/¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÚ����e`Ú���Qâè¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.php���e`��mÑa¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpŸ���e`Ÿ��o ±(¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpG���e`G��–ˆ
  30. ¤������3���src/Composer/DependencyResolver/PolicyInterface.php7���e`7��ŽþR¤������(���src/Composer/DependencyResolver/Pool.phpO���e`O���(ž ¤������/���src/Composer/DependencyResolver/PoolBuilder.php:1���e`:1��Û Ü ¤������+���src/Composer/DependencyResolver/Problem.phpð8���e`ð8��+œ‹¤������+���src/Composer/DependencyResolver/Request.phpë���e`ë��qid¤������(���src/Composer/DependencyResolver/Rule.phpJ'���e`J'��gë2¤������1���src/Composer/DependencyResolver/Rule2Literals.php���e`��^ Wá¤������+���src/Composer/DependencyResolver/RuleSet.phpr ���e`r ��bZ¬”¤������4���src/Composer/DependencyResolver/RuleSetGenerator.php¤���e`¤��Å�ÓÚ¤������3���src/Composer/DependencyResolver/RuleSetIterator.php ���e` ��…gØ,¤������2���src/Composer/DependencyResolver/RuleWatchChain.phpi���e`i��hïš,¤������2���src/Composer/DependencyResolver/RuleWatchGraph.php8 ���e`8 ��8ӎȤ������1���src/Composer/DependencyResolver/RuleWatchNode.php2���e`2��ü;㔤������*���src/Composer/DependencyResolver/Solver.php8���e`8��žN�’¤������6���src/Composer/DependencyResolver/SolverBugException.php™���e`™��Xg6¤������;���src/Composer/DependencyResolver/SolverProblemsException.php ���e` ��ºì C¤������/���src/Composer/DependencyResolver/Transaction.php°���e`°��-­ïߤ������-���src/Composer/Downloader/ArchiveDownloader.php���e`��nÑΉ¤������1���src/Composer/Downloader/ChangeReportInterface.phpÌ����e`Ì���¯à¨¿¤������+���src/Composer/Downloader/DownloadManager.php4���e`4��]n(v¤������/���src/Composer/Downloader/DownloaderInterface.php���e`��<ê ¤������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ����e`Ñ���&Áœ¿¤������*���src/Composer/Downloader/FileDownloader.php,���e`,��Ñòš»¤������/���src/Composer/Downloader/FilesystemException.php
  31. ���e`
  32. ��.-‹¤������,���src/Composer/Downloader/FossilDownloader.phpÓ ���e`Ó ��™ó,¤������)���src/Composer/Downloader/GitDownloader.phpw>���e`w>��Ã
  33. \¤������*���src/Composer/Downloader/GzipDownloader.phpÂ���e`Â�� Åtx¤������(���src/Composer/Downloader/HgDownloader.php› ���e`› ��ÕQ)'¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phps����e`s���Ù¢ ñ¤������*���src/Composer/Downloader/PathDownloader.phpg���e`g��èŽÖð¤������.���src/Composer/Downloader/PerforceDownloader.php ���e` ��=Ëw(¤������*���src/Composer/Downloader/PharDownloader.php'���e`'��i(¶¤������)���src/Composer/Downloader/RarDownloader.phpø���e`ø��6uÚ¤������)���src/Composer/Downloader/SvnDownloader.php���e`��ÀЀ£¤������)���src/Composer/Downloader/TarDownloader.php%���e`%��7³Øm¤������.���src/Composer/Downloader/TransportException.php���e`��¥¬ï‰¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ����e`Ô���`§ôö¤������)���src/Composer/Downloader/VcsDownloader.php7���e`7��³ÌûY¤������(���src/Composer/Downloader/XzDownloader.php3���e`3��4ÍYä������)���src/Composer/Downloader/ZipDownloader.phpî���e`î��Eý½¤������&���src/Composer/EventDispatcher/Event.php ���e` ��±™jï¤������0���src/Composer/EventDispatcher/EventDispatcher.php{0���e`{0��‘G¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©����e`©���h·0¤������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv����e`v���wZ8S¤������9���src/Composer/Exception/IrrecoverableDownloadException.phpv����e`v���DM½y¤������)���src/Composer/Exception/NoSslException.phph����e`h���ˆdñÓ¤���������src/Composer/Factory.phpÔB���e`ÔB��ÑZµ¤���������src/Composer/IO/BaseIO.php ���e` ��Ƈa¤���������src/Composer/IO/BufferIO.php¶���e`¶��ȼ†¦¤���������src/Composer/IO/ConsoleIO.php¬���e`¬��¡ã;N¤���������src/Composer/IO/IOInterface.phpØ���e`Ø��Fò°ð¤���������src/Composer/IO/NullIO.phpÀ���e`À��F`sʤ������"���src/Composer/InstalledVersions.phpü���e`ü��˜m`Q¤���������src/Composer/Installer.phpww���e`ww��†s¾r¤������*���src/Composer/Installer/BinaryInstaller.php3���e`3��šÁ¤������2���src/Composer/Installer/BinaryPresenceInterface.phpË����e`Ë���À5š¨¤������.���src/Composer/Installer/InstallationManager.phps3���e`s3��<û=)¤������)���src/Composer/Installer/InstallerEvent.phpå���e`å��ÎE N¤������*���src/Composer/Installer/InstallerEvents.php…����e`…���nÜ<Á¤������-���src/Composer/Installer/InstallerInterface.phpI���e`I��µªØ\¤������+���src/Composer/Installer/LibraryInstaller.phpk���e`k��¸/ý—¤������/���src/Composer/Installer/MetapackageInstaller.phpÍ���e`Í��·p(ù¤������(���src/Composer/Installer/NoopInstaller.php]���e`]��Û‰öÓ¤������'���src/Composer/Installer/PackageEvent.php–���e`–��=¯³X¤������(���src/Composer/Installer/PackageEvents.php¸���e`¸��dbØs¤������*���src/Composer/Installer/PluginInstaller.phpå
  34. ���e`å
  35. ��ÿ|gp¤������+���src/Composer/Installer/ProjectInstaller.phpf���e`f��ÙÇ“B¤������4���src/Composer/Installer/SuggestedPackagesReporter.php���e`��îÐD¤���������src/Composer/Json/JsonFile.php©���e`©��AÚ>¤������#���src/Composer/Json/JsonFormatter.phpS���e`S��†e¤������%���src/Composer/Json/JsonManipulator.php¸7���e`¸7��hy¤������-���src/Composer/Json/JsonValidationException.php\���e`\��.Xóܤ������%���src/Composer/Package/AliasPackage.phpè���e`è��lÞ½­¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php ���e` ��yY+¦¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpæ���e`æ��U`Ƥ������0���src/Composer/Package/Archiver/ArchiveManager.php^���e`^��?b"7¤������3���src/Composer/Package/Archiver/ArchiverInterface.php���e`��ñ´> ¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php~���e`~��!Ê p¤������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php���e`��‹SZ0¤������2���src/Composer/Package/Archiver/GitExcludeFilter.phpr���e`r��3‘Mh¤������1���src/Composer/Package/Archiver/HgExcludeFilter.php
  36. ���e`
  37. ��&ðm(¤������.���src/Composer/Package/Archiver/PharArchiver.php8���e`8��Fx'M¤������-���src/Composer/Package/Archiver/ZipArchiver.php¤���e`¤��!Yò�¤������$���src/Composer/Package/BasePackage.php���e`�� `¼ ¤������*���src/Composer/Package/Comparer/Comparer.php©���e`©��þí%†¤������(���src/Composer/Package/CompletePackage.php§���e`§�� h“¤������1���src/Composer/Package/CompletePackageInterface.php���e`��2%ž¤������+���src/Composer/Package/Dumper/ArrayDumper.php ���e` ��Ã@Q¤���������src/Composer/Package/Link.phpÝ���e`Ý��ÃðÿФ������+���src/Composer/Package/Loader/ArrayLoader.phpñ'���e`ñ'��¹•# ¤������7���src/Composer/Package/Loader/InvalidPackageException.phpE���e`E��xb¾¤������*���src/Composer/Package/Loader/JsonLoader.php°���e`°��Vœ\‹¤������/���src/Composer/Package/Loader/LoaderInterface.php²����e`²���¦}úΤ������1���src/Composer/Package/Loader/RootPackageLoader.phpñ���e`ñ��9JÛ¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.phpžA���e`žA�� _‚ï¤���������src/Composer/Package/Locker.php!%���e`!%��ÑÞ¤������ ���src/Composer/Package/Package.php���e`��åwQ0¤������)���src/Composer/Package/PackageInterface.php� ���e`� ��H^K_¤������)���src/Composer/Package/RootAliasPackage.phpH ���e`H ��ëie`¤������$���src/Composer/Package/RootPackage.phpI���e`I��q]V¤������-���src/Composer/Package/RootPackageInterface.php¹���e`¹��"maV¤������0���src/Composer/Package/Version/StabilityFilter.phpé���e`é��Äi— ¤������/���src/Composer/Package/Version/VersionGuesser.php§$���e`§$��É"=å¤������.���src/Composer/Package/Version/VersionParser.php���e`�� ·s)¤������0���src/Composer/Package/Version/VersionSelector.php‹���e`‹��Ó‘úo¤������&���src/Composer/Platform/HhvmDetector.phpñ���e`ñ��”\龤������!���src/Composer/Platform/Runtime.phpA���e`A��ò¥|¤������!���src/Composer/Platform/Version.php”���e`”��÷ða©¤������-���src/Composer/Plugin/Capability/Capability.phpW����e`W���æ_¨1¤������2���src/Composer/Plugin/Capability/CommandProvider.php—����e`—���ûOâ>¤���������src/Composer/Plugin/Capable.php����e`���Æq+¤������$���src/Composer/Plugin/CommandEvent.phpâ���e`â��³ÆÇW¤������$���src/Composer/Plugin/PluginEvents.phpe���e`e��*U~r¤������'���src/Composer/Plugin/PluginInterface.phpŽ���e`Ž���4%~¤������%���src/Composer/Plugin/PluginManager.phpª/���e`ª/��êp!ª¤������-���src/Composer/Plugin/PostFileDownloadEvent.phpá���e`á��M+æ¤������*���src/Composer/Plugin/PreCommandRunEvent.phpõ���e`õ��:ðd¤������,���src/Composer/Plugin/PreFileDownloadEvent.phpO���e`O��¾­wÀ¤������*���src/Composer/Plugin/PrePoolCreateEvent.phpA���e`A��x¼”y¤������4���src/Composer/Question/StrictConfirmationQuestion.php���e`��'.³è¤������+���src/Composer/Repository/ArrayRepository.phpæ���e`æ��­J—¤������.���src/Composer/Repository/ArtifactRepository.phpó ���e`ó ��æ¦í‚¤������.���src/Composer/Repository/ComposerRepository.php/‹���e`/‹��,’�¤������/���src/Composer/Repository/CompositeRepository.phpO ���e`O ��¤¾ŸŽ¤������;���src/Composer/Repository/ConfigurableRepositoryInterface.php…����e`…���±Ÿ_¤������0���src/Composer/Repository/FilesystemRepository.php_���e`_��-ä������,���src/Composer/Repository/FilterRepository.php���e`��×y¯¢¤������4���src/Composer/Repository/InstalledArrayRepository.php1���e`1��]«×¤������9���src/Composer/Repository/InstalledFilesystemRepository.php1���e`1��y&êͤ������/���src/Composer/Repository/InstalledRepository.php¸���e`¸��Ëõ¤������8���src/Composer/Repository/InstalledRepositoryInterface.php¥����e`¥���Ã%¤������6���src/Composer/Repository/InvalidRepositoryException.phpn����e`n���à“똤������/���src/Composer/Repository/LockArrayRepository.php¤����e`¤���E™†S¤������-���src/Composer/Repository/PackageRepository.phpÑ���e`Ñ��«‰´¤������*���src/Composer/Repository/PathRepository.php(���e`(��b2L¤������*���src/Composer/Repository/PearRepository.phpæ����e`æ���¤5‘¤������.���src/Composer/Repository/PlatformRepository.phpÂH���e`ÂH��õ*!¤������-���src/Composer/Repository/RepositoryFactory.php¥���e`¥��»í�N¤������/���src/Composer/Repository/RepositoryInterface.php;���e`;�� _‹¤������-���src/Composer/Repository/RepositoryManager.php ���e` ��´=x¤������7���src/Composer/Repository/RepositorySecurityException.phpo����e`o���pÕ«ª¤������)���src/Composer/Repository/RepositorySet.php¶���e`¶��\Oo¤������1���src/Composer/Repository/RootPackageRepository.php@���e`@��X¦Ž¤������/���src/Composer/Repository/Vcs/BitbucketDriver.php… ���e`… ��Ôðpñ¤������,���src/Composer/Repository/Vcs/FossilDriver.phpe���e`e�� n�¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpè���e`è��8$ë¤������)���src/Composer/Repository/Vcs/GitDriver.php€���e`€��G/�¤������,���src/Composer/Repository/Vcs/GitHubDriver.phpï4���e`ï4���äw¤������,���src/Composer/Repository/Vcs/GitLabDriver.php +���e` +��úIÞ?¤������1���src/Composer/Repository/Vcs/HgBitbucketDriver.phpâ���e`â��¾Â`Y¤������(���src/Composer/Repository/Vcs/HgDriver.php ���e` ��{濤������.���src/Composer/Repository/Vcs/PerforceDriver.php¾ ���e`¾ ��ˆáÀ¤������)���src/Composer/Repository/Vcs/SvnDriver.php’���e`’��qh|š¤������)���src/Composer/Repository/Vcs/VcsDriver.phpd
  38. ���e`d
  39. ��=1\Ǥ������2���src/Composer/Repository/Vcs/VcsDriverInterface.php÷���e`÷��ÇX[‰¤������)���src/Composer/Repository/VcsRepository.php^2���e`^2��¤:®²¤������1���src/Composer/Repository/VersionCacheInterface.php”����e`”���A?Rï¤������3���src/Composer/Repository/WritableArrayRepository.phpO���e`O��‰Ýê¤������7���src/Composer/Repository/WritableRepositoryInterface.phpS���e`S��5CgÓ¤���������src/Composer/Script/Event.phpš���e`š��Óô©¤������$���src/Composer/Script/ScriptEvents.phpÜ���e`Ü��ÆíÁ¤������ ���src/Composer/SelfUpdate/Keys.phpœ���e`œ��zeƒŽ¤������$���src/Composer/SelfUpdate/Versions.php6���e`6��0鮤������ ���src/Composer/Util/AuthHelper.php���e`��„‰ó]¤���������src/Composer/Util/Bitbucket.phpØ���e`Ø��¬5èõ¤������$���src/Composer/Util/ComposerMirror.php±���e`±��­½øؤ������%���src/Composer/Util/ConfigValidator.php1���e`1��È ¤������"���src/Composer/Util/ErrorHandler.phpº���e`º��ª¤������ ���src/Composer/Util/Filesystem.php•3���e`•3��Ó,å¤���������src/Composer/Util/Git.phpº0���e`º0��÷KŒ¤���������src/Composer/Util/GitHub.phpU ���e`U ��½Qjø¤���������src/Composer/Util/GitLab.phpq���e`q��$͆¤���������src/Composer/Util/Hg.phpô���e`ô��æégŽ¤������)���src/Composer/Util/Http/CurlDownloader.phpG?���e`G?��¸Šù�¤������'���src/Composer/Util/Http/CurlResponse.php]���e`]��Dæñ@¤������&���src/Composer/Util/Http/ProxyHelper.php9
  40. ���e`9
  41. ��´·]¤������'���src/Composer/Util/Http/ProxyManager.phpŠ
  42. ���e`Š
  43. �� â¤������'���src/Composer/Util/Http/RequestProxy.php���e`��üA8¤������#���src/Composer/Util/Http/Response.php!���e`!��ö˜„Ò¤������$���src/Composer/Util/HttpDownloader.phpé%���e`é%��h Rè¤���������src/Composer/Util/IniHelper.phph���e`h��;FP¤���������src/Composer/Util/Loop.php˜���e`˜��IyþŒ¤������&���src/Composer/Util/MetadataMinifier.php¹���e`¹��Ñ«²Ù¤������$���src/Composer/Util/NoProxyPattern.phpt���e`t��¨­6¯¤������#���src/Composer/Util/PackageSorter.phpø���e`ø��Oê♤���������src/Composer/Util/Perforce.php\2���e`\2��.ÞÑõ¤���������src/Composer/Util/Platform.php�
  44. ���e`�
  45. ��c¤������%���src/Composer/Util/ProcessExecutor.phpˆ���e`ˆ��k¶1¤������&���src/Composer/Util/RemoteFilesystem.phprM���e`rM��É—n‘¤���������src/Composer/Util/Silencer.phpè���e`è��¿5ѳ¤������*���src/Composer/Util/StreamContextFactory.php¨���e`¨��lçë¤���������src/Composer/Util/Svn.php!���e`!��:ÚÒl¤������ ���src/Composer/Util/SyncHelper.phpE���e`E��åá‰Ç¤���������src/Composer/Util/Tar.phpb���e`b��å]–¤���������src/Composer/Util/TlsHelper.phpH
  46. ���e`H
  47. ��ÌÚ¤���������src/Composer/Util/Url.php ���e` ��qX¤���������src/Composer/Util/Zip.php&���e`&��Ì>vT¤���������src/bootstrap.php¹���e`¹��I}œ¤������%���src/Composer/Autoload/ClassLoader.php8���e`8��l=ú-¤������#���res/composer-repository-schema.jsonñ���e`ñ��|0à„¤���������res/composer-schema.jsonÿª���e`ÿª��Ûp…¤���������vendor/autoload.php‚����e`‚���VW„¤���������vendor/composer/ClassLoader.phpó���e`ó��3ç7¤������%���vendor/composer/InstalledVersions.phpi���e`i��G¹—3¤������%���vendor/composer/autoload_classmap.phpµ����e`µ���x’ý»¤������"���vendor/composer/autoload_files.phpŒ���e`Œ��� ¤������'���vendor/composer/autoload_namespaces.php¢����e`¢����R7c¤������!���vendor/composer/autoload_psr4.php÷���e`÷��Å*š¤������!���vendor/composer/autoload_real.phpc���e`c��èQ¸¤������#���vendor/composer/autoload_static.php¹ ���e`¹ ��”zËó¤������!���vendor/composer/ca-bundle/LICENSE���e`��G _¤������(���vendor/composer/ca-bundle/res/cacert.pemê`��e`ê`�­3 ¤������*���vendor/composer/ca-bundle/src/CaBundle.phpg���e`g��Axð�¤���������vendor/composer/installed.phpy ���e`y ��™›D¤���������vendor/composer/semver/LICENSE���e`��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php���e`��^ÝŠ’¤������/���vendor/composer/semver/src/CompilingMatcher.phpo���e`o��Æ7L§¤������/���vendor/composer/semver/src/Constraint/Bound.phpq���e`q�� �]¤������4���vendor/composer/semver/src/Constraint/Constraint.phpb���e`b��¡ó�w¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php˜���e`˜��œ?[¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php§���e`§��ÃÛé¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÁ���e`Á��ê´ �¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.php ���e` ��’Q\ä������'���vendor/composer/semver/src/Interval.phpæ���e`æ��=[i¤������(���vendor/composer/semver/src/Intervals.phpÓ+���e`Ó+��7ؤ������%���vendor/composer/semver/src/Semver.phpù���e`ù��á-i¤������,���vendor/composer/semver/src/VersionParser.php—+���e`—+��=
  48. �‚¤������%���vendor/composer/spdx-licenses/LICENSE���e`��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ���e`¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.jsonu°���e`u°��›ý…T¤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.phpH���e`H��͉T¤������&���vendor/composer/xdebug-handler/LICENSE+���e`+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php´���e`´��*D’�¤������.���vendor/composer/xdebug-handler/src/Process.phpk ���e`k ��ŽUÿߤ������-���vendor/composer/xdebug-handler/src/Status.php
  49. ���e`
  50. ��$Ÿv-¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.php£$���e`£$�� € D¤������(���vendor/justinrainbow/json-schema/LICENSE"���e`"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ���e`¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpƒ
  51. ���e`ƒ
  52. ��ž¸=š¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php§ ���e`§ ��›Vؤ������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼���e`¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php\���e`\��_}ý¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpà ���e`à ��ë’_”¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps���e`s��d Þ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpƒ ���e`ƒ ��e� ¨¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php·���e`·��%l¬ö¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php& ���e`& ��78÷¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.phpz���e`z��ùfÅ~¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa���e`a�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—���e`—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰���e`‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php���e`��ª%}¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php,"���e`,"��‰-¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè���e`è��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI����e`I���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•����e`•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl����e`l���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl����e`l���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu����e`u���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw����e`w���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ���e`Þ��\¸
  53. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo����e`o���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…����e`…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€����e`€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj����e`j���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf����e`f���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ���e`þ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ���e` ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php“ ���e`“ ��&zß^¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php���e`��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá����e`á���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php£���e`£��Ç’ô¦¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php ���e` ��£Á¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,���e`,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®����e`®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ���e` ��æP¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php@���e`@��5Î3¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ����e`ƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…����e`…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phps���e`s��ßÁ‘#¤���������vendor/psr/log/LICENSE?���e`?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;���e`;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`����e``��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû����e`û���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|����e`|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§����e`§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ���e`È��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk���e`k��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ����e`Ÿ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp����e`p���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ���e` ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<���e`<��þ(åI¤���������vendor/react/promise/LICENSE'���e`'��¶-º„¤������F���vendor/react/promise/src/React/Promise/CancellablePromiseInterface.php�����e`���� ƒ<�¤������3���vendor/react/promise/src/React/Promise/Deferred.phpð ���e`ð ��o(ퟤ������:���vendor/react/promise/src/React/Promise/DeferredPromise.phpÇ���e`Ç��º`W¤������;���vendor/react/promise/src/React/Promise/DeferredResolver.phpÃ���e`Ã��7Ëu¤������;���vendor/react/promise/src/React/Promise/FulfilledPromise.phpÍ���e`Í��´–U¤������6���vendor/react/promise/src/React/Promise/LazyPromise.php���e`��Š»¤������2���vendor/react/promise/src/React/Promise/Promise.php���e`��º6Jµ¤������;���vendor/react/promise/src/React/Promise/PromiseInterface.phpŸ����e`Ÿ��� ½¨n¤������<���vendor/react/promise/src/React/Promise/PromisorInterface.php\����e`\���Wèêà¤������:���vendor/react/promise/src/React/Promise/RejectedPromise.php¾���e`¾��fC¿¤������<���vendor/react/promise/src/React/Promise/ResolverInterface.php¼����e`¼���û �O¤������/���vendor/react/promise/src/React/Promise/Util.phpè����e`è���Ëý$:¤������/���vendor/react/promise/src/React/Promise/When.phpÇ���e`Ç��¤o¤������4���vendor/react/promise/src/React/Promise/functions.phpÐ ���e`Ð ��!³O¤������<���vendor/react/promise/src/React/Promise/functions_include.php\����e`\���1…‰^¤���������vendor/seld/jsonlint/LICENSE$���e`$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.phpk���e`k��Zù¶Ã¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php62���e`62��28ˤ������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php#���e`#��Úá@,¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php%���e`%��`a„|¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>����e`>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$���e`$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpÍ���e`Í��H:›¤������)���vendor/seld/phar-utils/src/Timestamps.phpœ ���e`œ ��kL€¤������&���vendor/symfony/console/Application.php+X���e`+X��«­yX¤������*���vendor/symfony/console/Command/Command.phpä"���e`ä"���¤Ê¤������.���vendor/symfony/console/Command/HelpCommand.phpØ���e`Ø��¦Ú-:¤������.���vendor/symfony/console/Command/ListCommand.phpZ���e`Z��»w`¤������(���vendor/symfony/console/ConsoleEvents.phpé����e`é���RÛÔe¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÏ���e`Ï��<ŽUî¤������0���vendor/symfony/console/Descriptor/Descriptor.php����e`���¿N•¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü����e`ü���±Qµ¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ���e`Ü ��*û�ɤ������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶���e`¶��·Ô;ݤ������4���vendor/symfony/console/Descriptor/TextDescriptor.php·���e`·��c“q€¤������3���vendor/symfony/console/Descriptor/XmlDescriptor.php���e`��b{<¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°���e`°��!�Ȥ������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ���e`Å��ÒxÛ\¤������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php���e`��á2é¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz���e`z��³,îL¤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ���e`Ô��È÷ L¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpf����e`f���¡ABª¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦����e`¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦����e`¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’����e`’���ÍO\e¤������5���vendor/symfony/console/Exception/RuntimeException.php–����e`–���Ùí,6¤������4���vendor/symfony/console/Formatter/OutputFormatter.php3���e`3��àפ������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ���e`Œ��òññÀ¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF���e`F��𦴤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„���e`„��÷½G¤������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@���e`@��G¨ýU¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy���e`y��Ì8ÆФ������2���vendor/symfony/console/Helper/DescriptorHelper.phpw���e`w��|¦C¤������.���vendor/symfony/console/Helper/DialogHelper.phpð���e`ð��ÔÈ7¤������1���vendor/symfony/console/Helper/FormatterHelper.phpd���e`d��§×,¸¤������(���vendor/symfony/console/Helper/Helper.php©���e`©��Õ'ƒ±¤������1���vendor/symfony/console/Helper/HelperInterface.phpå����e`å���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpÊ���e`Ê��áÏW"¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc���e`c��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ���e`Ó ��©w‚R¤������-���vendor/symfony/console/Helper/ProgressBar.phpc%���e`c%��C&w¤������0���vendor/symfony/console/Helper/ProgressHelper.phpY���e`Y��R!�/¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpM���e`M��ü�‡¤������0���vendor/symfony/console/Helper/QuestionHelper.php[���e`[��¯6}ñ¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php•
  54. ���e`•
  55. ���]~R¤������'���vendor/symfony/console/Helper/Table.php¼*���e`¼*��fêý!¤������+���vendor/symfony/console/Helper/TableCell.php€���e`€��‹ƒ[¤������-���vendor/symfony/console/Helper/TableHelper.php ���e` ��›uô™¤������0���vendor/symfony/console/Helper/TableSeparator.phpÊ����e`Ê���az¤������,���vendor/symfony/console/Helper/TableStyle.php
  56. ���e`
  57. ��_ÍI"¤������*���vendor/symfony/console/Input/ArgvInput.php���e`��ªèB-¤������+���vendor/symfony/console/Input/ArrayInput.php) ���e`) ��¥ÑC¤������&���vendor/symfony/console/Input/Input.php£ ���e`£ ��f¡?¤������.���vendor/symfony/console/Input/InputArgument.php���e`��D £¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜����e`˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php†���e`†��¤U)¤¤������/���vendor/symfony/console/Input/InputInterface.php£���e`£��ÆBŒ'¤������,���vendor/symfony/console/Input/InputOption.php ���e` ��\¢Ü=¤������,���vendor/symfony/console/Input/StringInput.php™���e`™��{Šœþ¤���������vendor/symfony/console/LICENSE+���e`+��²‹ g¤������/���vendor/symfony/console/Logger/ConsoleLogger.php- ���e`- ��ghT›¤������0���vendor/symfony/console/Output/BufferedOutput.php_���e`_��‹ >P¤������/���vendor/symfony/console/Output/ConsoleOutput.php±���e`±��nì!f¤������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà����e`à���‡†Æʤ������,���vendor/symfony/console/Output/NullOutput.phpÉ���e`É��™0ïf¤������(���vendor/symfony/console/Output/Output.php˜ ���e`˜ ��0p¤������1���vendor/symfony/console/Output/OutputInterface.php���e`���ì&¤������.���vendor/symfony/console/Output/StreamOutput.php›���e`›��.¡îî¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpv
  58. ���e`v
  59. ��‹²WP¤������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè���e`è��/Ô�¤������,���vendor/symfony/console/Question/Question.phpÎ ���e`Î ��lF¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$���e`�$��•�¥v¤������ ���vendor/symfony/console/Shell.phpã���e`ã��‰ÁŽå¤������,���vendor/symfony/console/Style/OutputStyle.php\���e`\��wפ¤������/���vendor/symfony/console/Style/StyleInterface.phpÏ���e`Ï��&nÅѤ������-���vendor/symfony/console/Style/SymfonyStyle.phpÛ���e`Û��§ðcä¤������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ���e`Ï��sž9i¤������/���vendor/symfony/console/Tester/CommandTester.php¨���e`¨��<œ•¤������(���vendor/symfony/debug/BufferingLogger.phpt���e`t��=�hܤ���������vendor/symfony/debug/Debug.php+���e`+��.À=©¤������)���vendor/symfony/debug/DebugClassLoader.php°���e`°��^æ*ñ¤������%���vendor/symfony/debug/ErrorHandler.phpýG���e`ýG��¿zL¤������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–���e`–��i‰æô¤������8���vendor/symfony/debug/Exception/ContextErrorException.php˜���e`˜��-
  60. d2¤������1���vendor/symfony/debug/Exception/DummyException.php���e`��®+Ãê¤������6���vendor/symfony/debug/Exception/FatalErrorException.php ���e` ��4ç$¤¤������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW���e`W��?àèK¤������3���vendor/symfony/debug/Exception/FlattenException.php»���e`»��+a&¤������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~����e`~���ë¨oâ¤������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš���e`š���ñJÀ¤������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜���e`˜��nöêؤ������)���vendor/symfony/debug/ExceptionHandler.php$3���e`$3��Eë×£¤������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php5���e`5��ŠÁ*V¤������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php���e`��ĹBV¤������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx���e`x��~ò"¤������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpN���e`N��'€³ˆ¤���������vendor/symfony/debug/LICENSE+���e`+��²‹ g¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi����e`i���$ ÿ›¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼���e`¼��pí\¶¤������3���vendor/symfony/filesystem/Exception/IOException.php‡���e`‡��€ü#Ѥ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦����e`¦���jÙwM¤������(���vendor/symfony/filesystem/Filesystem.phpM4���e`M4��ãz_¤������!���vendor/symfony/filesystem/LICENSE+���e`+��²‹ g¤������)���vendor/symfony/filesystem/LockHandler.phpò���e`ò��~3ŸZ¤������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ���e`\ ��hˆB¤������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.phpƒ���e`ƒ��kM Þ¤������2���vendor/symfony/finder/Adapter/AdapterInterface.php›���e`›��Mþ¤������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php2���e`2��ƒ€D)¤������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php���e`��¦äàO¤������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô���e`ô��Þdè;¤������/���vendor/symfony/finder/Comparator/Comparator.php����e`���¾üœµ¤������3���vendor/symfony/finder/Comparator/DateComparator.php#���e`#��°Τ������5���vendor/symfony/finder/Comparator/NumberComparator.php{���e`{��€ÚùY¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„����e`„���½¾sœ¤������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬���e`¬��wR¤������6���vendor/symfony/finder/Exception/ExceptionInterface.php„����e`„���Gz-¤������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)���e`)��x§e¤������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº���e`º��˜þ˜¤������/���vendor/symfony/finder/Expression/Expression.php���e`��i¥:Ť������)���vendor/symfony/finder/Expression/Glob.phpf���e`f��DÞcj¤������*���vendor/symfony/finder/Expression/Regex.php���e`��§;M)¤������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ���e`Í��\p4†¤������ ���vendor/symfony/finder/Finder.phpc.���e`c.��:ˆ5g¤���������vendor/symfony/finder/Glob.phpL���e`L��jÍ9פ������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]���e`]��ÎoÅƤ������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx���e`x��ôP¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî���e`î��üÍ�q¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí���e`í��nõH¤������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#���e`#��G?T½¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ���e`Z��(&ø¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5���e`5��ší¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr���e`r��tu¤������1���vendor/symfony/finder/Iterator/FilterIterator.phpÂ���e`Â���㯤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php*���e`*��Œž�¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ���e`Ð��‚c¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ���e` ��O}Cä¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe���e`e��Ÿ’áé¤������3���vendor/symfony/finder/Iterator/SortableIterator.php+���e`+��õÝË ¤���������vendor/symfony/finder/LICENSE+���e`+��²‹ g¤������'���vendor/symfony/finder/Shell/Command.php> ���e`> ��_~u ¤������%���vendor/symfony/finder/Shell/Shell.phpq���e`q��·ÓŠ0¤������%���vendor/symfony/finder/SplFileInfo.php���e`��þ�íù¤������'���vendor/symfony/polyfill-ctype/Ctype.phpH ���e`H ��³�Õݤ������%���vendor/symfony/polyfill-ctype/LICENSE+���e`+��…»E:¤������+���vendor/symfony/polyfill-ctype/bootstrap.phpú���e`ú��|p:¤������(���vendor/symfony/polyfill-mbstring/LICENSE+���e`+��øÛ{¤������-���vendor/symfony/polyfill-mbstring/Mbstring.php~G���e`~G��úì¡T¤������D���vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8Ë���e`Ë��Ú�.‚¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷T���e`÷T��ß2ª?¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã���e`ã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpîU���e`îU��`þ8Q¤������.���vendor/symfony/polyfill-mbstring/bootstrap.php���e`��þJ¾¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpf����e`f���]ö>T¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨����e`¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”����e`”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx���e`x��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php���e`��﫤������5���vendor/symfony/process/Exception/RuntimeException.php˜����e`˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.phpœ���e`œ��çÁ̤���������vendor/symfony/process/LICENSE+���e`+��²‹ g¤������.���vendor/symfony/process/PhpExecutableFinder.phpÍ���e`Í��í0ã¤������%���vendor/symfony/process/PhpProcess.phpù���e`ù��c¶ßĤ������.���vendor/symfony/process/Pipes/AbstractPipes.php¸���e`¸��xÓ,§¤������/���vendor/symfony/process/Pipes/PipesInterface.phpD���e`D��vØ������*���vendor/symfony/process/Pipes/UnixPipes.php7���e`7��bÜp„¤������-���vendor/symfony/process/Pipes/WindowsPipes.phpi ���e`i ��Ó
  61.  Ä¤������"���vendor/symfony/process/Process.php R���e` R��×Ó¥¹¤������)���vendor/symfony/process/ProcessBuilder.phpá
  62. ���e`á
  63. ��ñ6I•¤������'���vendor/symfony/process/ProcessUtils.phpJ���e`J��{ñC¤������ ���bin/composer8���e`8��³âéñ¤���������LICENSE.���e`.�� Õ¤������<?php
  64. namespace Composer\Autoload;
  65. use Composer\Config;
  66. use Composer\EventDispatcher\EventDispatcher;
  67. use Composer\Installer\InstallationManager;
  68. use Composer\IO\IOInterface;
  69. use Composer\Package\AliasPackage;
  70. use Composer\Package\PackageInterface;
  71. use Composer\Package\RootPackageInterface;
  72. use Composer\Repository\InstalledRepositoryInterface;
  73. use Composer\Repository\PlatformRepository;
  74. use Composer\Semver\Constraint\Bound;
  75. use Composer\Semver\Constraint\MatchAllConstraint;
  76. use Composer\Util\Filesystem;
  77. use Composer\Script\ScriptEvents;
  78. use Composer\Util\PackageSorter;
  79. class AutoloadGenerator
  80. {
  81. private $eventDispatcher;
  82. private $io;
  83. private $devMode = false;
  84. private $classMapAuthoritative = false;
  85. private $apcu = false;
  86. private $apcuPrefix;
  87. private $runScripts = false;
  88. private $ignorePlatformReqs = false;
  89. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  90. {
  91. $this->eventDispatcher = $eventDispatcher;
  92. $this->io = $io;
  93. }
  94. public function setDevMode($devMode = true)
  95. {
  96. $this->devMode = (bool) $devMode;
  97. }
  98. public function setClassMapAuthoritative($classMapAuthoritative)
  99. {
  100. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  101. }
  102. public function setApcu($apcu, $apcuPrefix = null)
  103. {
  104. $this->apcu = (bool) $apcu;
  105. $this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
  106. }
  107. public function setRunScripts($runScripts = true)
  108. {
  109. $this->runScripts = (bool) $runScripts;
  110. }
  111. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  112. {
  113. if (is_array($ignorePlatformReqs)) {
  114. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  115. return PlatformRepository::isPlatformPackage($req);
  116. });
  117. } else {
  118. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  119. }
  120. }
  121. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
  122. {
  123. if ($this->classMapAuthoritative) {
  124. $scanPsrPackages = true;
  125. }
  126. if ($this->runScripts) {
  127. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  128. 'optimize' => (bool) $scanPsrPackages,
  129. ));
  130. }
  131. $filesystem = new Filesystem();
  132. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  133. $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
  134. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  135. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  136. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  137. $targetDir = $vendorPath.'/'.$targetDir;
  138. $filesystem->ensureDirectoryExists($targetDir);
  139. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  140. $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
  141. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  142. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  143. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  144. $namespacesFile = <<<EOF
  145. <?php
  146. // autoload_namespaces.php @generated by Composer
  147. \$vendorDir = $vendorPathCode52;
  148. \$baseDir = $appBaseDirCode;
  149. return array(
  150. EOF;
  151. $psr4File = <<<EOF
  152. <?php
  153. // autoload_psr4.php @generated by Composer
  154. \$vendorDir = $vendorPathCode52;
  155. \$baseDir = $appBaseDirCode;
  156. return array(
  157. EOF;
  158. $devPackageNames = $localRepo->getDevPackageNames();
  159. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  160. if ($this->devMode) {
  161. $filteredDevPackages = false;
  162. } else {
  163. $filteredDevPackages = $devPackageNames ?: true;
  164. }
  165. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  166. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  167. $exportedPaths = array();
  168. foreach ($paths as $path) {
  169. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  170. }
  171. $exportedPrefix = var_export($namespace, true);
  172. $namespacesFile .= " $exportedPrefix => ";
  173. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  174. }
  175. $namespacesFile .= ");\n";
  176. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  177. $exportedPaths = array();
  178. foreach ($paths as $path) {
  179. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  180. }
  181. $exportedPrefix = var_export($namespace, true);
  182. $psr4File .= " $exportedPrefix => ";
  183. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  184. }
  185. $psr4File .= ");\n";
  186. $classmapFile = <<<EOF
  187. <?php
  188. // autoload_classmap.php @generated by Composer
  189. \$vendorDir = $vendorPathCode52;
  190. \$baseDir = $appBaseDirCode;
  191. return array(
  192. EOF;
  193. $targetDirLoader = null;
  194. $mainAutoload = $rootPackage->getAutoload();
  195. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  196. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  197. $prefixes = implode(', ', array_map(function ($prefix) {
  198. return var_export($prefix, true);
  199. }, array_keys($mainAutoload['psr-0'])));
  200. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  201. $targetDirLoader = <<<EOF
  202. public static function autoload(\$class)
  203. {
  204. \$dir = $baseDirFromTargetDirCode . '/';
  205. \$prefixes = array($prefixes);
  206. foreach (\$prefixes as \$prefix) {
  207. if (0 !== strpos(\$class, \$prefix)) {
  208. continue;
  209. }
  210. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  211. if (!\$path = stream_resolve_include_path(\$path)) {
  212. return false;
  213. }
  214. require \$path;
  215. return true;
  216. }
  217. }
  218. EOF;
  219. }
  220. $excluded = null;
  221. if (!empty($autoloads['exclude-from-classmap'])) {
  222. $excluded = $autoloads['exclude-from-classmap'];
  223. }
  224. $classMap = array();
  225. $ambiguousClasses = array();
  226. $scannedFiles = array();
  227. foreach ($autoloads['classmap'] as $dir) {
  228. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, null, null, $classMap, $ambiguousClasses, $scannedFiles);
  229. }
  230. if ($scanPsrPackages) {
  231. $namespacesToScan = array();
  232. foreach (array('psr-4', 'psr-0') as $psrType) {
  233. foreach ($autoloads[$psrType] as $namespace => $paths) {
  234. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  235. }
  236. }
  237. krsort($namespacesToScan);
  238. foreach ($namespacesToScan as $namespace => $groups) {
  239. foreach ($groups as $group) {
  240. foreach ($group['paths'] as $dir) {
  241. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  242. if (!is_dir($dir)) {
  243. continue;
  244. }
  245. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespace, $group['type'], $classMap, $ambiguousClasses, $scannedFiles);
  246. }
  247. }
  248. }
  249. }
  250. foreach ($ambiguousClasses as $className => $ambigiousPaths) {
  251. $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);
  252. $this->io->writeError(
  253. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  254. ' was found '. (count($ambigiousPaths) + 1) .'x: in "'.$cleanPath.'" and "'. implode('", "', $ambigiousPaths) .'", the first will be used.</warning>'
  255. );
  256. }
  257. $classMap['Composer\\InstalledVersions'] = "\$vendorDir . '/composer/InstalledVersions.php',\n";
  258. ksort($classMap);
  259. foreach ($classMap as $class => $code) {
  260. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  261. }
  262. $classmapFile .= ");\n";
  263. if (!$suffix) {
  264. if (!$config->get('autoloader-suffix') && is_readable($vendorPath.'/autoload.php')) {
  265. $content = file_get_contents($vendorPath.'/autoload.php');
  266. if (preg_match('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  267. $suffix = $match[1];
  268. }
  269. }
  270. if (!$suffix) {
  271. $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
  272. }
  273. }
  274. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  275. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  276. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  277. $includePathFilePath = $targetDir.'/include_paths.php';
  278. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  279. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  280. } elseif (file_exists($includePathFilePath)) {
  281. unlink($includePathFilePath);
  282. }
  283. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  284. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  285. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  286. } elseif (file_exists($includeFilesFilePath)) {
  287. unlink($includeFilesFilePath);
  288. }
  289. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
  290. $checkPlatform = $config->get('platform-check') && $this->ignorePlatformReqs !== true;
  291. $platformCheckContent = null;
  292. if ($checkPlatform) {
  293. $platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array(), $config->get('platform-check'), $devPackageNames);
  294. if (null === $platformCheckContent) {
  295. $checkPlatform = false;
  296. }
  297. }
  298. if ($checkPlatform) {
  299. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  300. } elseif (file_exists($targetDir.'/platform_check.php')) {
  301. unlink($targetDir.'/platform_check.php');
  302. }
  303. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  304. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
  305. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  306. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  307. if ($this->runScripts) {
  308. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  309. 'optimize' => (bool) $scanPsrPackages,
  310. ));
  311. }
  312. return count($classMap);
  313. }
  314. private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles)
  315. {
  316. foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
  317. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  318. if (!isset($classMap[$class])) {
  319. $classMap[$class] = $pathCode;
  320. } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  321. $ambiguousClasses[$class][] = $path;
  322. }
  323. }
  324. return $classMap;
  325. }
  326. private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles)
  327. {
  328. if ($excluded) {
  329. if (file_exists($dir)) {
  330. $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));
  331. foreach ($excluded as $index => $pattern) {
  332. $pattern = preg_replace('{^(([^.+*?\[^\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\[^\]$(){}=!<>|:#-])*).*}', '$1', $pattern);
  333. if (0 !== strpos($pattern, $dirMatch) && 0 !== strpos($dirMatch, $pattern)) {
  334. unset($excluded[$index]);
  335. }
  336. }
  337. }
  338. $excluded = $excluded ? '{(' . implode('|', $excluded) . ')}' : null;
  339. }
  340. return ClassMapGenerator::createMap($dir, $excluded, $showAmbiguousWarning ? $this->io : null, $namespaceFilter, $autoloadType, $scannedFiles);
  341. }
  342. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  343. {
  344. $packageMap = array(array($rootPackage, ''));
  345. foreach ($packages as $package) {
  346. if ($package instanceof AliasPackage) {
  347. continue;
  348. }
  349. $this->validatePackage($package);
  350. $packageMap[] = array(
  351. $package,
  352. $installationManager->getInstallPath($package),
  353. );
  354. }
  355. return $packageMap;
  356. }
  357. protected function validatePackage(PackageInterface $package)
  358. {
  359. $autoload = $package->getAutoload();
  360. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  361. $name = $package->getName();
  362. $package->getTargetDir();
  363. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  364. }
  365. if (!empty($autoload['psr-4'])) {
  366. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  367. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  368. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  369. }
  370. }
  371. }
  372. }
  373. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  374. {
  375. $rootPackageMap = array_shift($packageMap);
  376. if (is_array($filteredDevPackages)) {
  377. $packageMap = array_filter($packageMap, function ($item) use ($filteredDevPackages) {
  378. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  379. });
  380. } elseif ($filteredDevPackages) {
  381. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  382. }
  383. $sortedPackageMap = $this->sortPackageMap($packageMap);
  384. $sortedPackageMap[] = $rootPackageMap;
  385. array_unshift($packageMap, $rootPackageMap);
  386. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $rootPackage);
  387. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $rootPackage);
  388. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $rootPackage);
  389. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  390. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  391. krsort($psr0);
  392. krsort($psr4);
  393. return array(
  394. 'psr-0' => $psr0,
  395. 'psr-4' => $psr4,
  396. 'classmap' => $classmap,
  397. 'files' => $files,
  398. 'exclude-from-classmap' => $exclude,
  399. );
  400. }
  401. public function createLoader(array $autoloads, $vendorDir = null)
  402. {
  403. $loader = new ClassLoader($vendorDir);
  404. if (isset($autoloads['psr-0'])) {
  405. foreach ($autoloads['psr-0'] as $namespace => $path) {
  406. $loader->add($namespace, $path);
  407. }
  408. }
  409. if (isset($autoloads['psr-4'])) {
  410. foreach ($autoloads['psr-4'] as $namespace => $path) {
  411. $loader->addPsr4($namespace, $path);
  412. }
  413. }
  414. if (isset($autoloads['classmap'])) {
  415. $excluded = null;
  416. if (!empty($autoloads['exclude-from-classmap'])) {
  417. $excluded = $autoloads['exclude-from-classmap'];
  418. }
  419. $scannedFiles = array();
  420. foreach ($autoloads['classmap'] as $dir) {
  421. try {
  422. $loader->addClassMap($this->generateClassMap($dir, $excluded, null, null, false, $scannedFiles));
  423. } catch (\RuntimeException $e) {
  424. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  425. }
  426. }
  427. }
  428. return $loader;
  429. }
  430. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  431. {
  432. $includePaths = array();
  433. foreach ($packageMap as $item) {
  434. list($package, $installPath) = $item;
  435. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  436. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  437. }
  438. foreach ($package->getIncludePaths() as $includePath) {
  439. $includePath = trim($includePath, '/');
  440. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  441. }
  442. }
  443. if (!$includePaths) {
  444. return;
  445. }
  446. $includePathsCode = '';
  447. foreach ($includePaths as $path) {
  448. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  449. }
  450. return <<<EOF
  451. <?php
  452. // include_paths.php @generated by Composer
  453. \$vendorDir = $vendorPathCode;
  454. \$baseDir = $appBaseDirCode;
  455. return array(
  456. $includePathsCode);
  457. EOF;
  458. }
  459. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  460. {
  461. $filesCode = '';
  462. foreach ($files as $fileIdentifier => $functionFile) {
  463. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  464. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  465. }
  466. if (!$filesCode) {
  467. return false;
  468. }
  469. return <<<EOF
  470. <?php
  471. // autoload_files.php @generated by Composer
  472. \$vendorDir = $vendorPathCode;
  473. \$baseDir = $appBaseDirCode;
  474. return array(
  475. $filesCode);
  476. EOF;
  477. }
  478. protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
  479. {
  480. if (!$filesystem->isAbsolutePath($path)) {
  481. $path = $basePath . '/' . $path;
  482. }
  483. $path = $filesystem->normalizePath($path);
  484. $baseDir = '';
  485. if (strpos($path.'/', $vendorPath.'/') === 0) {
  486. $path = substr($path, strlen($vendorPath));
  487. $baseDir = '$vendorDir';
  488. if ($path !== false) {
  489. $baseDir .= " . ";
  490. }
  491. } else {
  492. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  493. if (!$filesystem->isAbsolutePath($path)) {
  494. $baseDir = '$baseDir . ';
  495. $path = '/' . $path;
  496. }
  497. }
  498. if (strpos($path, '.phar') !== false) {
  499. $baseDir = "'phar://' . " . $baseDir;
  500. }
  501. return $baseDir . (($path !== false) ? var_export($path, true) : "");
  502. }
  503. protected function getPlatformCheck(array $packageMap, array $ignorePlatformReqs, $checkPlatform, array $devPackageNames)
  504. {
  505. $lowestPhpVersion = Bound::zero();
  506. $requiredExtensions = array();
  507. $extensionProviders = array();
  508. foreach ($packageMap as $item) {
  509. $package = $item[0];
  510. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  511. if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  512. $extensionProviders[$match[1]][] = $link->getConstraint() ?: new MatchAllConstraint();
  513. }
  514. }
  515. }
  516. foreach ($packageMap as $item) {
  517. $package = $item[0];
  518. if (in_array($package->getName(), $devPackageNames, true)) {
  519. continue;
  520. }
  521. foreach ($package->getRequires() as $link) {
  522. if (in_array($link->getTarget(), $ignorePlatformReqs, true)) {
  523. continue;
  524. }
  525. if ('php' === $link->getTarget() && ($constraint = $link->getConstraint())) {
  526. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  527. $lowestPhpVersion = $constraint->getLowerBound();
  528. }
  529. }
  530. if ($checkPlatform === true && preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  531. if (isset($extensionProviders[$match[1]])) {
  532. foreach ($extensionProviders[$match[1]] as $provided) {
  533. if (!$link->getConstraint() || $provided->matches($link->getConstraint())) {
  534. continue 2;
  535. }
  536. }
  537. }
  538. if ($match[1] === 'zend-opcache') {
  539. $match[1] = 'zend opcache';
  540. }
  541. $extension = var_export($match[1], true);
  542. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  543. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  544. } else {
  545. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  546. }
  547. }
  548. }
  549. }
  550. ksort($requiredExtensions);
  551. $formatToPhpVersionId = function (Bound $bound) {
  552. if ($bound->isZero()) {
  553. return 0;
  554. }
  555. if ($bound->isPositiveInfinity()) {
  556. return 99999;
  557. }
  558. $version = str_replace('-', '.', $bound->getVersion());
  559. $chunks = array_map('intval', explode('.', $version));
  560. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  561. };
  562. $formatToHumanReadable = function (Bound $bound) {
  563. if ($bound->isZero()) {
  564. return 0;
  565. }
  566. if ($bound->isPositiveInfinity()) {
  567. return 99999;
  568. }
  569. $version = str_replace('-', '.', $bound->getVersion());
  570. $chunks = explode('.', $version);
  571. $chunks = array_slice($chunks, 0, 3);
  572. return implode('.', $chunks);
  573. };
  574. $requiredPhp = '';
  575. $requiredPhpError = '';
  576. if (!$lowestPhpVersion->isZero()) {
  577. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  578. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  579. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  580. }
  581. if ($requiredPhp) {
  582. $requiredPhp = <<<PHP_CHECK
  583. if (!($requiredPhp)) {
  584. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  585. }
  586. PHP_CHECK;
  587. }
  588. $requiredExtensions = implode('', $requiredExtensions);
  589. if ('' !== $requiredExtensions) {
  590. $requiredExtensions = <<<EXT_CHECKS
  591. \$missingExtensions = array();
  592. $requiredExtensions
  593. if (\$missingExtensions) {
  594. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  595. }
  596. EXT_CHECKS;
  597. }
  598. if (!$requiredPhp && !$requiredExtensions) {
  599. return null;
  600. }
  601. return <<<PLATFORM_CHECK
  602. <?php
  603. // platform_check.php @generated by Composer
  604. \$issues = array();
  605. ${requiredPhp}${requiredExtensions}
  606. if (\$issues) {
  607. if (!headers_sent()) {
  608. header('HTTP/1.1 500 Internal Server Error');
  609. }
  610. if (!ini_get('display_errors')) {
  611. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  612. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  613. } elseif (!headers_sent()) {
  614. echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, \$issues)) . PHP_EOL.PHP_EOL;
  615. }
  616. }
  617. trigger_error(
  618. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  619. E_USER_ERROR
  620. );
  621. }
  622. PLATFORM_CHECK;
  623. }
  624. protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
  625. {
  626. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  627. if ("'" === $lastChar || '"' === $lastChar) {
  628. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  629. } else {
  630. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  631. }
  632. return <<<AUTOLOAD
  633. <?php
  634. // autoload.php @generated by Composer
  635. require_once $vendorPathToTargetDirCode;
  636. return ComposerAutoloaderInit$suffix::getLoader();
  637. AUTOLOAD;
  638. }
  639. protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)
  640. {
  641. $file = <<<HEADER
  642. <?php
  643. // autoload_real.php @generated by Composer
  644. class ComposerAutoloaderInit$suffix
  645. {
  646. private static \$loader;
  647. public static function loadClassLoader(\$class)
  648. {
  649. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  650. require __DIR__ . '/ClassLoader.php';
  651. }
  652. }
  653. /**
  654. * @return \Composer\Autoload\ClassLoader
  655. */
  656. public static function getLoader()
  657. {
  658. if (null !== self::\$loader) {
  659. return self::\$loader;
  660. }
  661. HEADER;
  662. if ($checkPlatform) {
  663. $file .= <<<'PLATFORM_CHECK'
  664. require __DIR__ . '/platform_check.php';
  665. PLATFORM_CHECK;
  666. }
  667. $file .= <<<CLASSLOADER_INIT
  668. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  669. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(\\dirname(__FILE__)));
  670. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  671. CLASSLOADER_INIT;
  672. if ($useIncludePath) {
  673. $file .= <<<'INCLUDE_PATH'
  674. $includePaths = require __DIR__ . '/include_paths.php';
  675. $includePaths[] = get_include_path();
  676. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  677. INCLUDE_PATH;
  678. }
  679. $file .= <<<STATIC_INIT
  680. \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  681. if (\$useStaticLoader) {
  682. require __DIR__ . '/autoload_static.php';
  683. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  684. } else {
  685. STATIC_INIT;
  686. if (!$this->classMapAuthoritative) {
  687. $file .= <<<'PSR04'
  688. $map = require __DIR__ . '/autoload_namespaces.php';
  689. foreach ($map as $namespace => $path) {
  690. $loader->set($namespace, $path);
  691. }
  692. $map = require __DIR__ . '/autoload_psr4.php';
  693. foreach ($map as $namespace => $path) {
  694. $loader->setPsr4($namespace, $path);
  695. }
  696. PSR04;
  697. }
  698. if ($useClassMap) {
  699. $file .= <<<'CLASSMAP'
  700. $classMap = require __DIR__ . '/autoload_classmap.php';
  701. if ($classMap) {
  702. $loader->addClassMap($classMap);
  703. }
  704. CLASSMAP;
  705. }
  706. $file .= " }\n\n";
  707. if ($this->classMapAuthoritative) {
  708. $file .= <<<'CLASSMAPAUTHORITATIVE'
  709. $loader->setClassMapAuthoritative(true);
  710. CLASSMAPAUTHORITATIVE;
  711. }
  712. if ($this->apcu) {
  713. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  714. $file .= <<<APCU
  715. \$loader->setApcuPrefix($apcuPrefix);
  716. APCU;
  717. }
  718. if ($useGlobalIncludePath) {
  719. $file .= <<<'INCLUDEPATH'
  720. $loader->setUseIncludePath(true);
  721. INCLUDEPATH;
  722. }
  723. if ($targetDirLoader) {
  724. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  725. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  726. REGISTER_TARGET_DIR_AUTOLOAD;
  727. }
  728. $file .= <<<REGISTER_LOADER
  729. \$loader->register($prependAutoloader);
  730. REGISTER_LOADER;
  731. if ($useIncludeFiles) {
  732. $file .= <<<INCLUDE_FILES
  733. if (\$useStaticLoader) {
  734. \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
  735. } else {
  736. \$includeFiles = require __DIR__ . '/autoload_files.php';
  737. }
  738. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  739. composerRequire$suffix(\$fileIdentifier, \$file);
  740. }
  741. INCLUDE_FILES;
  742. }
  743. $file .= <<<METHOD_FOOTER
  744. return \$loader;
  745. }
  746. METHOD_FOOTER;
  747. $file .= $targetDirLoader;
  748. if ($useIncludeFiles) {
  749. return $file . <<<FOOTER
  750. }
  751. function composerRequire$suffix(\$fileIdentifier, \$file)
  752. {
  753. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  754. require \$file;
  755. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  756. }
  757. }
  758. FOOTER;
  759. }
  760. return $file . <<<FOOTER
  761. }
  762. FOOTER;
  763. }
  764. protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
  765. {
  766. $staticPhpVersion = 50600;
  767. $file = <<<HEADER
  768. <?php
  769. // autoload_static.php @generated by Composer
  770. namespace Composer\Autoload;
  771. class ComposerStaticInit$suffix
  772. {
  773. HEADER;
  774. $loader = new ClassLoader();
  775. $map = require $targetDir . '/autoload_namespaces.php';
  776. foreach ($map as $namespace => $path) {
  777. $loader->set($namespace, $path);
  778. }
  779. $map = require $targetDir . '/autoload_psr4.php';
  780. foreach ($map as $namespace => $path) {
  781. $loader->setPsr4($namespace, $path);
  782. }
  783. $classMap = require $targetDir . '/autoload_classmap.php';
  784. if ($classMap) {
  785. $loader->addClassMap($classMap);
  786. }
  787. $filesystem = new Filesystem();
  788. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  789. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  790. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  791. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  792. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  793. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  794. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  795. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  796. $initializer = '';
  797. $prefix = "\0Composer\Autoload\ClassLoader\0";
  798. $prefixLen = strlen($prefix);
  799. if (file_exists($targetDir . '/autoload_files.php')) {
  800. $maps = array('files' => require $targetDir . '/autoload_files.php');
  801. } else {
  802. $maps = array();
  803. }
  804. foreach ((array) $loader as $prop => $value) {
  805. if ($value && 0 === strpos($prop, $prefix)) {
  806. $maps[substr($prop, $prefixLen)] = $value;
  807. }
  808. }
  809. foreach ($maps as $prop => $value) {
  810. if (count($value) > 32767) {
  811. $staticPhpVersion = 70000;
  812. }
  813. $value = strtr(
  814. var_export($value, true),
  815. array(
  816. $absoluteVendorPathCode => $vendorPathCode,
  817. $absoluteVendorPharPathCode => $vendorPharPathCode,
  818. $absoluteAppBaseDirCode => $appBaseDirCode,
  819. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  820. )
  821. );
  822. $value = ltrim(preg_replace('/^ */m', ' $0$0', $value));
  823. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  824. if ('files' !== $prop) {
  825. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  826. }
  827. }
  828. return $file . <<<INITIALIZER
  829. public static function getInitializer(ClassLoader \$loader)
  830. {
  831. return \Closure::bind(function () use (\$loader) {
  832. $initializer
  833. }, null, ClassLoader::class);
  834. }
  835. }
  836. INITIALIZER;
  837. }
  838. protected function parseAutoloadsType(array $packageMap, $type, RootPackageInterface $rootPackage)
  839. {
  840. $autoloads = array();
  841. foreach ($packageMap as $item) {
  842. list($package, $installPath) = $item;
  843. $autoload = $package->getAutoload();
  844. if ($this->devMode && $package === $rootPackage) {
  845. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  846. }
  847. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  848. continue;
  849. }
  850. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  851. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  852. }
  853. foreach ($autoload[$type] as $namespace => $paths) {
  854. foreach ((array) $paths as $path) {
  855. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !is_readable($installPath.'/'.$path)) {
  856. if ($package === $rootPackage) {
  857. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  858. $path = ltrim(preg_replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  859. } else {
  860. $path = $package->getTargetDir() . '/' . $path;
  861. }
  862. }
  863. if ($type === 'exclude-from-classmap') {
  864. $path = preg_replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  865. $path = strtr($path, array('\\*\\*' => '.+?', '\\*' => '[^/]+?'));
  866. $updir = null;
  867. $path = preg_replace_callback(
  868. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  869. function ($matches) use (&$updir) {
  870. if (isset($matches[1])) {
  871. $updir = str_replace('\\.', '.', $matches[1]);
  872. }
  873. return '';
  874. },
  875. $path
  876. );
  877. if (empty($installPath)) {
  878. $installPath = strtr(getcwd(), '\\', '/');
  879. }
  880. $resolvedPath = realpath($installPath . '/' . $updir);
  881. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  882. continue;
  883. }
  884. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  885. if ($type === 'files') {
  886. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  887. continue;
  888. }
  889. if ($type === 'classmap') {
  890. $autoloads[] = $relativePath;
  891. continue;
  892. }
  893. $autoloads[$namespace][] = $relativePath;
  894. }
  895. }
  896. }
  897. return $autoloads;
  898. }
  899. protected function getFileIdentifier(PackageInterface $package, $path)
  900. {
  901. return md5($package->getName() . ':' . $path);
  902. }
  903. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  904. {
  905. $packages = array();
  906. $include = array();
  907. $replacedBy = array();
  908. foreach ($packageMap as $item) {
  909. $package = $item[0];
  910. $name = $package->getName();
  911. $packages[$name] = $package;
  912. foreach ($package->getReplaces() as $replace) {
  913. $replacedBy[$replace->getTarget()] = $name;
  914. }
  915. }
  916. $add = function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy) {
  917. foreach ($package->getRequires() as $link) {
  918. $target = $link->getTarget();
  919. if (isset($replacedBy[$target])) {
  920. $target = $replacedBy[$target];
  921. }
  922. if (!isset($include[$target])) {
  923. $include[$target] = true;
  924. if (isset($packages[$target])) {
  925. $add($packages[$target]);
  926. }
  927. }
  928. }
  929. };
  930. $add($rootPackage);
  931. return array_filter(
  932. $packageMap,
  933. function ($item) use ($include) {
  934. $package = $item[0];
  935. foreach ($package->getNames() as $name) {
  936. if (isset($include[$name])) {
  937. return true;
  938. }
  939. }
  940. return false;
  941. }
  942. );
  943. }
  944. protected function sortPackageMap(array $packageMap)
  945. {
  946. $packages = array();
  947. $paths = array();
  948. foreach ($packageMap as $item) {
  949. list($package, $path) = $item;
  950. $name = $package->getName();
  951. $packages[$name] = $package;
  952. $paths[$name] = $path;
  953. }
  954. $sortedPackages = PackageSorter::sortPackages($packages);
  955. $sortedPackageMap = array();
  956. foreach ($sortedPackages as $package) {
  957. $name = $package->getName();
  958. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  959. }
  960. return $sortedPackageMap;
  961. }
  962. }
  963. <?php
  964. namespace Composer\Autoload;
  965. use Symfony\Component\Finder\Finder;
  966. use Composer\IO\IOInterface;
  967. use Composer\Util\Filesystem;
  968. class ClassMapGenerator
  969. {
  970. public static function dump($dirs, $file)
  971. {
  972. $maps = array();
  973. foreach ($dirs as $dir) {
  974. $maps = array_merge($maps, static::createMap($dir));
  975. }
  976. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  977. }
  978. public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
  979. {
  980. $basePath = $path;
  981. if (is_string($path)) {
  982. if (is_file($path)) {
  983. $path = array(new \SplFileInfo($path));
  984. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  985. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  986. } else {
  987. throw new \RuntimeException(
  988. 'Could not scan for classes inside "'.$path.
  989. '" which does not appear to be a file nor a folder'
  990. );
  991. }
  992. } elseif (null !== $autoloadType) {
  993. throw new \RuntimeException('Path must be a string when specifying an autoload type');
  994. }
  995. $map = array();
  996. $filesystem = new Filesystem();
  997. $cwd = realpath(getcwd());
  998. foreach ($path as $file) {
  999. $filePath = $file->getPathname();
  1000. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  1001. continue;
  1002. }
  1003. if (!$filesystem->isAbsolutePath($filePath)) {
  1004. $filePath = $cwd . '/' . $filePath;
  1005. $filePath = $filesystem->normalizePath($filePath);
  1006. } else {
  1007. $filePath = preg_replace('{[\\\\/]{2,}}', '/', $filePath);
  1008. }
  1009. $realPath = realpath($filePath);
  1010. if (isset($scannedFiles[$realPath])) {
  1011. continue;
  1012. }
  1013. if ($excluded && preg_match($excluded, strtr($realPath, '\\', '/'))) {
  1014. continue;
  1015. }
  1016. if ($excluded && preg_match($excluded, strtr($filePath, '\\', '/'))) {
  1017. continue;
  1018. }
  1019. $classes = self::findClasses($filePath);
  1020. if (null !== $autoloadType) {
  1021. $classes = self::filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath, $io);
  1022. if ($classes) {
  1023. $scannedFiles[$realPath] = true;
  1024. }
  1025. } else {
  1026. $scannedFiles[$realPath] = true;
  1027. }
  1028. foreach ($classes as $class) {
  1029. if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
  1030. continue;
  1031. }
  1032. if (!isset($map[$class])) {
  1033. $map[$class] = $filePath;
  1034. } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  1035. $io->writeError(
  1036. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1037. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  1038. );
  1039. }
  1040. }
  1041. }
  1042. return $map;
  1043. }
  1044. private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io)
  1045. {
  1046. $validClasses = array();
  1047. $rejectedClasses = array();
  1048. $realSubPath = substr($filePath, strlen($basePath) + 1);
  1049. $realSubPath = substr($realSubPath, 0, strrpos($realSubPath, '.'));
  1050. foreach ($classes as $class) {
  1051. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  1052. continue;
  1053. }
  1054. if ('psr-0' === $namespaceType) {
  1055. $namespaceLength = strrpos($class, '\\');
  1056. if (false !== $namespaceLength) {
  1057. $namespace = substr($class, 0, $namespaceLength + 1);
  1058. $className = substr($class, $namespaceLength + 1);
  1059. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  1060. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  1061. } else {
  1062. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  1063. }
  1064. } elseif ('psr-4' === $namespaceType) {
  1065. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  1066. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  1067. } else {
  1068. throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");
  1069. }
  1070. if ($subPath === $realSubPath) {
  1071. $validClasses[] = $class;
  1072. } else {
  1073. $rejectedClasses[] = $class;
  1074. }
  1075. }
  1076. if (empty($validClasses)) {
  1077. foreach ($rejectedClasses as $class) {
  1078. if ($io) {
  1079. $io->writeError("<warning>Class $class located in ".preg_replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
  1080. }
  1081. }
  1082. return array();
  1083. }
  1084. return $validClasses;
  1085. }
  1086. private static function findClasses($path)
  1087. {
  1088. $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
  1089. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
  1090. $extraTypes .= '|enum';
  1091. }
  1092. $contents = @php_strip_whitespace($path);
  1093. if (!$contents) {
  1094. if (!file_exists($path)) {
  1095. $message = 'File at "%s" does not exist, check your classmap definitions';
  1096. } elseif (!is_readable($path)) {
  1097. $message = 'File at "%s" is not readable, check its permissions';
  1098. } elseif ('' === trim(file_get_contents($path))) {
  1099. return array();
  1100. } else {
  1101. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  1102. }
  1103. $error = error_get_last();
  1104. if (isset($error['message'])) {
  1105. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  1106. }
  1107. throw new \RuntimeException(sprintf($message, $path));
  1108. }
  1109. if (!preg_match('{\b(?:class|interface'.$extraTypes.')\s}i', $contents)) {
  1110. return array();
  1111. }
  1112. $contents = preg_replace('{<<<[ \t]*([\'"]?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)(?:\s*)\\2(?=\s+|[;,.)])}s', 'null', $contents);
  1113. $contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
  1114. if (strpos($contents, '<?') !== 0) {
  1115. $contents = preg_replace('{^.+?<\?}s', '<?', $contents, 1, $replacements);
  1116. if ($replacements === 0) {
  1117. return array();
  1118. }
  1119. }
  1120. $contents = preg_replace('{\?>(?:[^<]++|<(?!\?))*+<\?}s', '?><?', $contents);
  1121. $pos = strrpos($contents, '?>');
  1122. if (false !== $pos && false === strpos(substr($contents, $pos), '<?')) {
  1123. $contents = substr($contents, 0, $pos);
  1124. }
  1125. if (preg_match('{(<\?)(?!(php|hh))}i', $contents)) {
  1126. $contents = preg_replace('{//.* | /\*(?:[^*]++|\*(?!/))*\*/}x', '', $contents);
  1127. }
  1128. preg_match_all('{
  1129. (?:
  1130. \b(?<![\$:>])(?P<type>class|interface'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  1131. | \b(?<![\$:>])(?P<ns>namespace) (?P<nsname>\s++[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\s*+\\\\\s*+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+)? \s*+ [\{;]
  1132. )
  1133. }ix', $contents, $matches);
  1134. $classes = array();
  1135. $namespace = '';
  1136. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  1137. if (!empty($matches['ns'][$i])) {
  1138. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
  1139. } else {
  1140. $name = $matches['name'][$i];
  1141. if ($name === 'extends' || $name === 'implements') {
  1142. continue;
  1143. }
  1144. if ($name[0] === ':') {
  1145. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  1146. } elseif ($matches['type'][$i] === 'enum') {
  1147. $name = rtrim($name, ':');
  1148. }
  1149. $classes[] = ltrim($namespace . $name, '\\');
  1150. }
  1151. }
  1152. return $classes;
  1153. }
  1154. }
  1155. <?php
  1156. namespace Composer;
  1157. use Composer\IO\IOInterface;
  1158. use Composer\Util\Filesystem;
  1159. use Composer\Util\Silencer;
  1160. use Symfony\Component\Finder\Finder;
  1161. class Cache
  1162. {
  1163. private static $cacheCollected = false;
  1164. private $io;
  1165. private $root;
  1166. private $enabled = true;
  1167. private $allowlist;
  1168. private $filesystem;
  1169. private $readOnly;
  1170. public function __construct(IOInterface $io, $cacheDir, $allowlist = 'a-z0-9.', Filesystem $filesystem = null, $readOnly = false)
  1171. {
  1172. $this->io = $io;
  1173. $this->root = rtrim($cacheDir, '/\\') . '/';
  1174. $this->allowlist = $allowlist;
  1175. $this->filesystem = $filesystem ?: new Filesystem();
  1176. $this->readOnly = (bool) $readOnly;
  1177. if (!self::isUsable($cacheDir)) {
  1178. $this->enabled = false;
  1179. return;
  1180. }
  1181. if (
  1182. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1183. || !is_writable($this->root)
  1184. ) {
  1185. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  1186. $this->enabled = false;
  1187. }
  1188. }
  1189. public function setReadOnly($readOnly)
  1190. {
  1191. $this->readOnly = (bool) $readOnly;
  1192. }
  1193. public function isReadOnly()
  1194. {
  1195. return $this->readOnly;
  1196. }
  1197. public static function isUsable($path)
  1198. {
  1199. return !preg_match('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1200. }
  1201. public function isEnabled()
  1202. {
  1203. return $this->enabled;
  1204. }
  1205. public function getRoot()
  1206. {
  1207. return $this->root;
  1208. }
  1209. public function read($file)
  1210. {
  1211. if ($this->enabled) {
  1212. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1213. if (file_exists($this->root . $file)) {
  1214. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1215. return file_get_contents($this->root . $file);
  1216. }
  1217. }
  1218. return false;
  1219. }
  1220. public function write($file, $contents)
  1221. {
  1222. if ($this->enabled && !$this->readOnly) {
  1223. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1224. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1225. $tempFileName = $this->root . $file . uniqid('.', true) . '.tmp';
  1226. try {
  1227. return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
  1228. } catch (\ErrorException $e) {
  1229. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1230. if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1231. unlink($tempFileName);
  1232. $message = sprintf(
  1233. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  1234. $tempFileName,
  1235. $m[1],
  1236. $m[2],
  1237. @disk_free_space(dirname($tempFileName))
  1238. );
  1239. $this->io->writeError($message);
  1240. return false;
  1241. }
  1242. throw $e;
  1243. }
  1244. }
  1245. return false;
  1246. }
  1247. public function copyFrom($file, $source)
  1248. {
  1249. if ($this->enabled && !$this->readOnly) {
  1250. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1251. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1252. if (!file_exists($source)) {
  1253. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1254. } elseif ($this->io->isDebug()) {
  1255. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1256. }
  1257. return copy($source, $this->root . $file);
  1258. }
  1259. return false;
  1260. }
  1261. public function copyTo($file, $target)
  1262. {
  1263. if ($this->enabled) {
  1264. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1265. if (file_exists($this->root . $file)) {
  1266. try {
  1267. touch($this->root . $file, filemtime($this->root . $file), time());
  1268. } catch (\ErrorException $e) {
  1269. Silencer::call('touch', $this->root . $file);
  1270. }
  1271. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1272. return copy($this->root . $file, $target);
  1273. }
  1274. }
  1275. return false;
  1276. }
  1277. public function gcIsNecessary()
  1278. {
  1279. return (!self::$cacheCollected && !mt_rand(0, 50));
  1280. }
  1281. public function remove($file)
  1282. {
  1283. if ($this->enabled) {
  1284. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1285. if (file_exists($this->root . $file)) {
  1286. return $this->filesystem->unlink($this->root . $file);
  1287. }
  1288. }
  1289. return false;
  1290. }
  1291. public function clear()
  1292. {
  1293. if ($this->enabled) {
  1294. $this->filesystem->emptyDirectory($this->root);
  1295. return true;
  1296. }
  1297. return false;
  1298. }
  1299. public function gc($ttl, $maxSize)
  1300. {
  1301. if ($this->enabled) {
  1302. $expire = new \DateTime();
  1303. $expire->modify('-'.$ttl.' seconds');
  1304. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1305. foreach ($finder as $file) {
  1306. $this->filesystem->unlink($file->getPathname());
  1307. }
  1308. $totalSize = $this->filesystem->size($this->root);
  1309. if ($totalSize > $maxSize) {
  1310. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1311. while ($totalSize > $maxSize && $iterator->valid()) {
  1312. $filepath = $iterator->current()->getPathname();
  1313. $totalSize -= $this->filesystem->size($filepath);
  1314. $this->filesystem->unlink($filepath);
  1315. $iterator->next();
  1316. }
  1317. }
  1318. self::$cacheCollected = true;
  1319. return true;
  1320. }
  1321. return false;
  1322. }
  1323. public function sha1($file)
  1324. {
  1325. if ($this->enabled) {
  1326. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1327. if (file_exists($this->root . $file)) {
  1328. return sha1_file($this->root . $file);
  1329. }
  1330. }
  1331. return false;
  1332. }
  1333. public function sha256($file)
  1334. {
  1335. if ($this->enabled) {
  1336. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1337. if (file_exists($this->root . $file)) {
  1338. return hash_file('sha256', $this->root . $file);
  1339. }
  1340. }
  1341. return false;
  1342. }
  1343. protected function getFinder()
  1344. {
  1345. return Finder::create()->in($this->root)->files();
  1346. }
  1347. }
  1348. <?php
  1349. namespace Composer\Command;
  1350. use Symfony\Component\Console\Input\InputInterface;
  1351. use Symfony\Component\Console\Output\OutputInterface;
  1352. class AboutCommand extends BaseCommand
  1353. {
  1354. protected function configure()
  1355. {
  1356. $this
  1357. ->setName('about')
  1358. ->setDescription('Shows the short information about Composer.')
  1359. ->setHelp(
  1360. <<<EOT
  1361. <info>php composer.phar about</info>
  1362. EOT
  1363. )
  1364. ;
  1365. }
  1366. protected function execute(InputInterface $input, OutputInterface $output)
  1367. {
  1368. $this->getIO()->write(
  1369. <<<EOT
  1370. <info>Composer - Dependency Manager for PHP</info>
  1371. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1372. See https://getcomposer.org/ for more information.</comment>
  1373. EOT
  1374. );
  1375. return 0;
  1376. }
  1377. }
  1378. <?php
  1379. namespace Composer\Command;
  1380. use Composer\Factory;
  1381. use Composer\IO\IOInterface;
  1382. use Composer\Config;
  1383. use Composer\Composer;
  1384. use Composer\Repository\CompositeRepository;
  1385. use Composer\Repository\RepositoryFactory;
  1386. use Composer\Script\ScriptEvents;
  1387. use Composer\Plugin\CommandEvent;
  1388. use Composer\Plugin\PluginEvents;
  1389. use Composer\Util\Filesystem;
  1390. use Composer\Util\Loop;
  1391. use Composer\Util\ProcessExecutor;
  1392. use Symfony\Component\Console\Input\InputArgument;
  1393. use Symfony\Component\Console\Input\InputInterface;
  1394. use Symfony\Component\Console\Input\InputOption;
  1395. use Symfony\Component\Console\Output\OutputInterface;
  1396. class ArchiveCommand extends BaseCommand
  1397. {
  1398. protected function configure()
  1399. {
  1400. $this
  1401. ->setName('archive')
  1402. ->setDescription('Creates an archive of this composer package.')
  1403. ->setDefinition(array(
  1404. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1405. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1406. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'),
  1407. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1408. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1409. .' Note that the format will be appended.'),
  1410. new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1411. ))
  1412. ->setHelp(
  1413. <<<EOT
  1414. The <info>archive</info> command creates an archive of the specified format
  1415. containing the files and directories of the Composer project or the specified
  1416. package in the specified version and writes it to the specified directory.
  1417. <info>php composer.phar archive [--format=zip] [--dir=/foo] [package [version]]</info>
  1418. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1419. EOT
  1420. )
  1421. ;
  1422. }
  1423. protected function execute(InputInterface $input, OutputInterface $output)
  1424. {
  1425. $composer = $this->getComposer(false);
  1426. $config = null;
  1427. if ($composer) {
  1428. $config = $composer->getConfig();
  1429. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1430. $eventDispatcher = $composer->getEventDispatcher();
  1431. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1432. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1433. }
  1434. if (!$config) {
  1435. $config = Factory::createConfig();
  1436. }
  1437. if (null === $input->getOption('format')) {
  1438. $input->setOption('format', $config->get('archive-format'));
  1439. }
  1440. if (null === $input->getOption('dir')) {
  1441. $input->setOption('dir', $config->get('archive-dir'));
  1442. }
  1443. $returnCode = $this->archive(
  1444. $this->getIO(),
  1445. $config,
  1446. $input->getArgument('package'),
  1447. $input->getArgument('version'),
  1448. $input->getOption('format'),
  1449. $input->getOption('dir'),
  1450. $input->getOption('file'),
  1451. $input->getOption('ignore-filters'),
  1452. $composer
  1453. );
  1454. if (0 === $returnCode && $composer) {
  1455. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1456. }
  1457. return $returnCode;
  1458. }
  1459. protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
  1460. {
  1461. if ($composer) {
  1462. $archiveManager = $composer->getArchiveManager();
  1463. } else {
  1464. $factory = new Factory;
  1465. $process = new ProcessExecutor();
  1466. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1467. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1468. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1469. }
  1470. if ($packageName) {
  1471. $package = $this->selectPackage($io, $packageName, $version);
  1472. if (!$package) {
  1473. return 1;
  1474. }
  1475. } else {
  1476. $package = $this->getComposer()->getPackage();
  1477. }
  1478. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1479. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1480. $fs = new Filesystem;
  1481. $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
  1482. $io->writeError('Created: ', false);
  1483. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1484. return 0;
  1485. }
  1486. protected function selectPackage(IOInterface $io, $packageName, $version = null)
  1487. {
  1488. $io->writeError('<info>Searching for the specified package.</info>');
  1489. if ($composer = $this->getComposer(false)) {
  1490. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1491. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1492. } else {
  1493. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1494. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1495. $repo = new CompositeRepository($defaultRepos);
  1496. }
  1497. $packages = $repo->findPackages($packageName, $version);
  1498. if (count($packages) > 1) {
  1499. $package = reset($packages);
  1500. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1501. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {
  1502. return $p->getPrettyString();
  1503. }, $packages)).'.');
  1504. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1505. } elseif ($packages) {
  1506. $package = reset($packages);
  1507. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1508. } else {
  1509. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1510. return false;
  1511. }
  1512. return $package;
  1513. }
  1514. }
  1515. <?php
  1516. namespace Composer\Command;
  1517. use Composer\Composer;
  1518. use Composer\Config;
  1519. use Composer\Console\Application;
  1520. use Composer\Factory;
  1521. use Composer\IO\IOInterface;
  1522. use Composer\IO\NullIO;
  1523. use Composer\Plugin\PreCommandRunEvent;
  1524. use Composer\Package\Version\VersionParser;
  1525. use Composer\Plugin\PluginEvents;
  1526. use Symfony\Component\Console\Helper\Table;
  1527. use Symfony\Component\Console\Input\InputInterface;
  1528. use Symfony\Component\Console\Output\OutputInterface;
  1529. use Symfony\Component\Console\Command\Command;
  1530. abstract class BaseCommand extends Command
  1531. {
  1532. private $composer;
  1533. private $io;
  1534. public function getComposer($required = true, $disablePlugins = null)
  1535. {
  1536. if (null === $this->composer) {
  1537. $application = $this->getApplication();
  1538. if ($application instanceof Application) {
  1539. $this->composer = $application->getComposer($required, $disablePlugins);
  1540. } elseif ($required) {
  1541. throw new \RuntimeException(
  1542. 'Could not create a Composer\Composer instance, you must inject '.
  1543. 'one if this command is not used with a Composer\Console\Application instance'
  1544. );
  1545. }
  1546. }
  1547. return $this->composer;
  1548. }
  1549. public function setComposer(Composer $composer)
  1550. {
  1551. $this->composer = $composer;
  1552. }
  1553. public function resetComposer()
  1554. {
  1555. $this->composer = null;
  1556. $this->getApplication()->resetComposer();
  1557. }
  1558. public function isProxyCommand()
  1559. {
  1560. return false;
  1561. }
  1562. public function getIO()
  1563. {
  1564. if (null === $this->io) {
  1565. $application = $this->getApplication();
  1566. if ($application instanceof Application) {
  1567. $this->io = $application->getIO();
  1568. } else {
  1569. $this->io = new NullIO();
  1570. }
  1571. }
  1572. return $this->io;
  1573. }
  1574. public function setIO(IOInterface $io)
  1575. {
  1576. $this->io = $io;
  1577. }
  1578. protected function initialize(InputInterface $input, OutputInterface $output)
  1579. {
  1580. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1581. $composer = $this->getComposer(false, $disablePlugins);
  1582. if (null === $composer) {
  1583. $composer = Factory::createGlobal($this->getIO(), $disablePlugins);
  1584. }
  1585. if ($composer) {
  1586. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1587. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1588. }
  1589. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1590. $input->setOption('no-progress', true);
  1591. }
  1592. parent::initialize($input, $output);
  1593. }
  1594. protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
  1595. {
  1596. $preferSource = false;
  1597. $preferDist = false;
  1598. switch ($config->get('preferred-install')) {
  1599. case 'source':
  1600. $preferSource = true;
  1601. break;
  1602. case 'dist':
  1603. $preferDist = true;
  1604. break;
  1605. case 'auto':
  1606. default:
  1607. break;
  1608. }
  1609. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1610. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1611. $preferDist = (bool) $input->getOption('prefer-dist');
  1612. }
  1613. return array($preferSource, $preferDist);
  1614. }
  1615. protected function formatRequirements(array $requirements)
  1616. {
  1617. $requires = array();
  1618. $requirements = $this->normalizeRequirements($requirements);
  1619. foreach ($requirements as $requirement) {
  1620. if (!isset($requirement['version'])) {
  1621. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  1622. }
  1623. $requires[$requirement['name']] = $requirement['version'];
  1624. }
  1625. return $requires;
  1626. }
  1627. protected function normalizeRequirements(array $requirements)
  1628. {
  1629. $parser = new VersionParser();
  1630. return $parser->parseNameVersionPairs($requirements);
  1631. }
  1632. protected function renderTable(array $table, OutputInterface $output)
  1633. {
  1634. $renderer = new Table($output);
  1635. $renderer->setStyle('compact');
  1636. $rendererStyle = $renderer->getStyle();
  1637. if (method_exists($rendererStyle, 'setVerticalBorderChars')) {
  1638. $rendererStyle->setVerticalBorderChars('');
  1639. } else {
  1640. $rendererStyle->setVerticalBorderChar('');
  1641. }
  1642. $rendererStyle->setCellRowContentFormat('%s ');
  1643. $renderer->setRows($table)->render();
  1644. }
  1645. }
  1646. <?php
  1647. namespace Composer\Command;
  1648. use Composer\Package\Link;
  1649. use Composer\Package\PackageInterface;
  1650. use Composer\Package\RootPackage;
  1651. use Composer\Repository\InstalledArrayRepository;
  1652. use Composer\Repository\CompositeRepository;
  1653. use Composer\Repository\RootPackageRepository;
  1654. use Composer\Repository\InstalledRepository;
  1655. use Composer\Repository\PlatformRepository;
  1656. use Composer\Repository\RepositoryFactory;
  1657. use Composer\Plugin\CommandEvent;
  1658. use Composer\Plugin\PluginEvents;
  1659. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1660. use Composer\Package\Version\VersionParser;
  1661. use Symfony\Component\Console\Input\InputArgument;
  1662. use Symfony\Component\Console\Input\InputInterface;
  1663. use Symfony\Component\Console\Input\InputOption;
  1664. use Symfony\Component\Console\Output\OutputInterface;
  1665. class BaseDependencyCommand extends BaseCommand
  1666. {
  1667. const ARGUMENT_PACKAGE = 'package';
  1668. const ARGUMENT_CONSTRAINT = 'constraint';
  1669. const OPTION_RECURSIVE = 'recursive';
  1670. const OPTION_TREE = 'tree';
  1671. protected $colors;
  1672. protected function configure()
  1673. {
  1674. $this->setDefinition(array(
  1675. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  1676. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::OPTIONAL, 'Optional version constraint', '*'),
  1677. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  1678. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  1679. ));
  1680. }
  1681. protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
  1682. {
  1683. $composer = $this->getComposer();
  1684. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1685. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1686. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1687. $installedRepo = new InstalledRepository(array(
  1688. new RootPackageRepository($composer->getPackage()),
  1689. $composer->getRepositoryManager()->getLocalRepository(),
  1690. new PlatformRepository(array(), $platformOverrides),
  1691. ));
  1692. list($needle, $textConstraint) = array_pad(
  1693. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1694. 2,
  1695. $input->getArgument(self::ARGUMENT_CONSTRAINT)
  1696. );
  1697. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  1698. if (empty($packages)) {
  1699. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1700. }
  1701. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  1702. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  1703. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  1704. $installedRepo->addRepository(new InstalledArrayRepository(array(clone $match)));
  1705. }
  1706. }
  1707. $needles = array($needle);
  1708. if ($inverted) {
  1709. foreach ($packages as $package) {
  1710. $needles = array_merge($needles, array_map(function (Link $link) {
  1711. return $link->getTarget();
  1712. }, $package->getReplaces()));
  1713. }
  1714. }
  1715. if ('*' !== $textConstraint) {
  1716. $versionParser = new VersionParser();
  1717. $constraint = $versionParser->parseConstraints($textConstraint);
  1718. } else {
  1719. $constraint = null;
  1720. }
  1721. $renderTree = $input->getOption(self::OPTION_TREE);
  1722. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  1723. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  1724. if (empty($results)) {
  1725. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  1726. $this->getIO()->writeError(sprintf(
  1727. '<info>There is no installed package depending on "%s"%s</info>',
  1728. $needle,
  1729. $extra
  1730. ));
  1731. } elseif ($renderTree) {
  1732. $this->initStyles($output);
  1733. $root = $packages[0];
  1734. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root->getDescription()));
  1735. $this->printTree($results);
  1736. } else {
  1737. $this->printTable($output, $results);
  1738. }
  1739. return 0;
  1740. }
  1741. protected function printTable(OutputInterface $output, $results)
  1742. {
  1743. $table = array();
  1744. $doubles = array();
  1745. do {
  1746. $queue = array();
  1747. $rows = array();
  1748. foreach ($results as $result) {
  1749. list($package, $link, $children) = $result;
  1750. $unique = (string) $link;
  1751. if (isset($doubles[$unique])) {
  1752. continue;
  1753. }
  1754. $doubles[$unique] = true;
  1755. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  1756. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  1757. if ($children) {
  1758. $queue = array_merge($queue, $children);
  1759. }
  1760. }
  1761. $results = $queue;
  1762. $table = array_merge($rows, $table);
  1763. } while (!empty($results));
  1764. $this->renderTable($table, $output);
  1765. }
  1766. protected function initStyles(OutputInterface $output)
  1767. {
  1768. $this->colors = array(
  1769. 'green',
  1770. 'yellow',
  1771. 'cyan',
  1772. 'magenta',
  1773. 'blue',
  1774. );
  1775. foreach ($this->colors as $color) {
  1776. $style = new OutputFormatterStyle($color);
  1777. $output->getFormatter()->setStyle($color, $style);
  1778. }
  1779. }
  1780. protected function printTree($results, $prefix = '', $level = 1)
  1781. {
  1782. $count = count($results);
  1783. $idx = 0;
  1784. foreach ($results as $result) {
  1785. list($package, $link, $children) = $result;
  1786. $color = $this->colors[$level % count($this->colors)];
  1787. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  1788. $isLast = (++$idx == $count);
  1789. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  1790. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  1791. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  1792. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  1793. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  1794. if ($children) {
  1795. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  1796. }
  1797. }
  1798. }
  1799. private function writeTreeLine($line)
  1800. {
  1801. $io = $this->getIO();
  1802. if (!$io->isDecorated()) {
  1803. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  1804. }
  1805. $io->write($line);
  1806. }
  1807. }
  1808. <?php
  1809. namespace Composer\Command;
  1810. use Composer\Package\Link;
  1811. use Composer\Semver\Constraint\Constraint;
  1812. use Symfony\Component\Console\Input\InputInterface;
  1813. use Symfony\Component\Console\Input\InputOption;
  1814. use Symfony\Component\Console\Output\OutputInterface;
  1815. use Composer\Repository\PlatformRepository;
  1816. use Composer\Repository\RootPackageRepository;
  1817. use Composer\Repository\InstalledRepository;
  1818. class CheckPlatformReqsCommand extends BaseCommand
  1819. {
  1820. protected function configure()
  1821. {
  1822. $this->setName('check-platform-reqs')
  1823. ->setDescription('Check that platform requirements are satisfied.')
  1824. ->setDefinition(array(
  1825. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  1826. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  1827. ))
  1828. ->setHelp(
  1829. <<<EOT
  1830. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  1831. Unlike update/install, this command will ignore config.platform settings and check the real platform packages so you can be certain you have the required platform dependencies.
  1832. <info>php composer.phar check-platform-reqs</info>
  1833. EOT
  1834. );
  1835. }
  1836. protected function execute(InputInterface $input, OutputInterface $output)
  1837. {
  1838. $composer = $this->getComposer();
  1839. $requires = array();
  1840. $removePackages = array();
  1841. if ($input->getOption('lock')) {
  1842. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  1843. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  1844. } else {
  1845. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  1846. if (!$installedRepo->getPackages()) {
  1847. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  1848. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  1849. } else {
  1850. if ($input->getOption('no-dev')) {
  1851. $removePackages = $installedRepo->getDevPackageNames();
  1852. }
  1853. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  1854. }
  1855. }
  1856. if (!$input->getOption('no-dev')) {
  1857. $requires += $composer->getPackage()->getDevRequires();
  1858. }
  1859. foreach ($requires as $require => $link) {
  1860. $requires[$require] = array($link);
  1861. }
  1862. $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
  1863. foreach ($installedRepo->getPackages() as $package) {
  1864. if (in_array($package->getName(), $removePackages, true)) {
  1865. continue;
  1866. }
  1867. foreach ($package->getRequires() as $require => $link) {
  1868. $requires[$require][] = $link;
  1869. }
  1870. }
  1871. ksort($requires);
  1872. $installedRepo->addRepository(new PlatformRepository(array(), array()));
  1873. $results = array();
  1874. $exitCode = 0;
  1875. foreach ($requires as $require => $links) {
  1876. if (PlatformRepository::isPlatformPackage($require)) {
  1877. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  1878. if ($candidates) {
  1879. $reqResults = array();
  1880. foreach ($candidates as $candidate) {
  1881. $candidateConstraint = null;
  1882. if ($candidate->getName() === $require) {
  1883. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  1884. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  1885. } else {
  1886. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  1887. if ($link->getTarget() === $require) {
  1888. $candidateConstraint = $link->getConstraint();
  1889. break;
  1890. }
  1891. }
  1892. }
  1893. if (!$candidateConstraint) {
  1894. continue;
  1895. }
  1896. foreach ($links as $link) {
  1897. if (!$link->getConstraint()->matches($candidateConstraint)) {
  1898. $reqResults[] = array(
  1899. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1900. $candidateConstraint->getPrettyString(),
  1901. $link,
  1902. '<error>failed</error>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1903. );
  1904. continue 2;
  1905. }
  1906. }
  1907. $results[] = array(
  1908. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1909. $candidateConstraint->getPrettyString(),
  1910. null,
  1911. '<info>success</info>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1912. );
  1913. continue 2;
  1914. }
  1915. $results = array_merge($results, $reqResults);
  1916. $exitCode = max($exitCode, 1);
  1917. continue;
  1918. }
  1919. $results[] = array(
  1920. $require,
  1921. 'n/a',
  1922. $links[0],
  1923. '<error>missing</error>',
  1924. );
  1925. $exitCode = max($exitCode, 2);
  1926. }
  1927. }
  1928. $this->printTable($output, $results);
  1929. return $exitCode;
  1930. }
  1931. protected function printTable(OutputInterface $output, $results)
  1932. {
  1933. $rows = array();
  1934. foreach ($results as $result) {
  1935. list($platformPackage, $version, $link, $status) = $result;
  1936. $rows[] = array(
  1937. $platformPackage,
  1938. $version,
  1939. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  1940. $status,
  1941. );
  1942. }
  1943. $this->renderTable($rows, $output);
  1944. }
  1945. }
  1946. <?php
  1947. namespace Composer\Command;
  1948. use Composer\Cache;
  1949. use Composer\Factory;
  1950. use Symfony\Component\Console\Input\InputInterface;
  1951. use Symfony\Component\Console\Output\OutputInterface;
  1952. class ClearCacheCommand extends BaseCommand
  1953. {
  1954. protected function configure()
  1955. {
  1956. $this
  1957. ->setName('clear-cache')
  1958. ->setAliases(array('clearcache', 'cc'))
  1959. ->setDescription('Clears composer\'s internal package cache.')
  1960. ->setHelp(
  1961. <<<EOT
  1962. The <info>clear-cache</info> deletes all cached packages from composer's
  1963. cache directory.
  1964. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  1965. EOT
  1966. )
  1967. ;
  1968. }
  1969. protected function execute(InputInterface $input, OutputInterface $output)
  1970. {
  1971. $config = Factory::createConfig();
  1972. $io = $this->getIO();
  1973. $cachePaths = array(
  1974. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  1975. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  1976. 'cache-files-dir' => $config->get('cache-files-dir'),
  1977. 'cache-dir' => $config->get('cache-dir'),
  1978. );
  1979. foreach ($cachePaths as $key => $cachePath) {
  1980. $cachePath = realpath($cachePath);
  1981. if (!$cachePath) {
  1982. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  1983. continue;
  1984. }
  1985. $cache = new Cache($io, $cachePath);
  1986. $cache->setReadOnly($config->get('cache-read-only'));
  1987. if (!$cache->isEnabled()) {
  1988. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  1989. continue;
  1990. }
  1991. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  1992. $cache->clear();
  1993. }
  1994. $io->writeError('<info>All caches cleared.</info>');
  1995. return 0;
  1996. }
  1997. }
  1998. <?php
  1999. namespace Composer\Command;
  2000. use Composer\Util\Platform;
  2001. use Composer\Util\Silencer;
  2002. use Symfony\Component\Console\Input\InputInterface;
  2003. use Symfony\Component\Console\Input\InputArgument;
  2004. use Symfony\Component\Console\Input\InputOption;
  2005. use Symfony\Component\Console\Output\OutputInterface;
  2006. use Composer\Config;
  2007. use Composer\Config\JsonConfigSource;
  2008. use Composer\Factory;
  2009. use Composer\IO\IOInterface;
  2010. use Composer\Json\JsonFile;
  2011. use Composer\Semver\VersionParser;
  2012. use Composer\Package\BasePackage;
  2013. class ConfigCommand extends BaseCommand
  2014. {
  2015. protected $config;
  2016. protected $configFile;
  2017. protected $configSource;
  2018. protected $authConfigFile;
  2019. protected $authConfigSource;
  2020. protected function configure()
  2021. {
  2022. $this
  2023. ->setName('config')
  2024. ->setDescription('Sets config options.')
  2025. ->setDefinition(array(
  2026. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  2027. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  2028. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  2029. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  2030. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  2031. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  2032. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  2033. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  2034. new InputOption('merge', 'm', InputOption::VALUE_NONE, 'Merge the setting value with the current value, to be used with extra.* keys in combination with --json'),
  2035. new InputOption('append', null, InputOption::VALUE_NONE, 'When adding a repository, append it (lowest priority) to the existing ones instead of prepending it (highest priority)'),
  2036. new InputArgument('setting-key', null, 'Setting key'),
  2037. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  2038. ))
  2039. ->setHelp(
  2040. <<<EOT
  2041. This command allows you to edit composer config settings and repositories
  2042. in either the local composer.json file or the global config.json file.
  2043. Additionally it lets you edit most properties in the local composer.json.
  2044. To set a config setting:
  2045. <comment>%command.full_name% bin-dir bin/</comment>
  2046. To read a config setting:
  2047. <comment>%command.full_name% bin-dir</comment>
  2048. Outputs: <info>bin</info>
  2049. To edit the global config.json file:
  2050. <comment>%command.full_name% --global</comment>
  2051. To add a repository:
  2052. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  2053. To remove a repository (repo is a short alias for repositories):
  2054. <comment>%command.full_name% --unset repo.foo</comment>
  2055. To disable packagist:
  2056. <comment>%command.full_name% repo.packagist false</comment>
  2057. You can alter repositories in the global config.json file by passing in the
  2058. <info>--global</info> option.
  2059. To add or edit suggested packages you can use:
  2060. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  2061. To add or edit extra properties you can use:
  2062. <comment>%command.full_name% extra.property value</comment>
  2063. Or to add a complex value you can use json with:
  2064. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  2065. To edit the file in an external editor:
  2066. <comment>%command.full_name% --editor</comment>
  2067. To choose your editor you can set the "EDITOR" env variable.
  2068. To get a list of configuration values in the file:
  2069. <comment>%command.full_name% --list</comment>
  2070. You can always pass more than one option. As an example, if you want to edit the
  2071. global config.json file.
  2072. <comment>%command.full_name% --editor --global</comment>
  2073. Read more at https://getcomposer.org/doc/03-cli.md#config
  2074. EOT
  2075. )
  2076. ;
  2077. }
  2078. protected function initialize(InputInterface $input, OutputInterface $output)
  2079. {
  2080. parent::initialize($input, $output);
  2081. if ($input->getOption('global') && null !== $input->getOption('file')) {
  2082. throw new \RuntimeException('--file and --global can not be combined');
  2083. }
  2084. $io = $this->getIO();
  2085. $this->config = Factory::createConfig($io);
  2086. $configFile = $input->getOption('global')
  2087. ? ($this->config->get('home') . '/config.json')
  2088. : ($input->getOption('file') ?: Factory::getComposerFile());
  2089. if (
  2090. ($configFile === 'composer.json' || $configFile === './composer.json')
  2091. && !file_exists($configFile)
  2092. && realpath(getcwd()) === realpath($this->config->get('home'))
  2093. ) {
  2094. file_put_contents($configFile, "{\n}\n");
  2095. }
  2096. $this->configFile = new JsonFile($configFile, null, $io);
  2097. $this->configSource = new JsonConfigSource($this->configFile);
  2098. $authConfigFile = $input->getOption('global')
  2099. ? ($this->config->get('home') . '/auth.json')
  2100. : dirname(realpath($configFile)) . '/auth.json';
  2101. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  2102. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  2103. if ($input->getOption('global') && !$this->configFile->exists()) {
  2104. touch($this->configFile->getPath());
  2105. $this->configFile->write(array('config' => new \ArrayObject));
  2106. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  2107. }
  2108. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  2109. touch($this->authConfigFile->getPath());
  2110. $this->authConfigFile->write(array('bitbucket-oauth' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject, 'gitlab-token' => new \ArrayObject, 'http-basic' => new \ArrayObject, 'bearer' => new \ArrayObject));
  2111. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  2112. }
  2113. if (!$this->configFile->exists()) {
  2114. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  2115. }
  2116. }
  2117. protected function execute(InputInterface $input, OutputInterface $output)
  2118. {
  2119. if ($input->getOption('editor')) {
  2120. $editor = escapeshellcmd(getenv('EDITOR'));
  2121. if (!$editor) {
  2122. if (Platform::isWindows()) {
  2123. $editor = 'notepad';
  2124. } else {
  2125. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  2126. if (exec('which '.$candidate)) {
  2127. $editor = $candidate;
  2128. break;
  2129. }
  2130. }
  2131. }
  2132. }
  2133. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  2134. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  2135. return 0;
  2136. }
  2137. if (!$input->getOption('global')) {
  2138. $this->config->merge($this->configFile->read());
  2139. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
  2140. }
  2141. if ($input->getOption('list')) {
  2142. $this->listConfiguration($this->config->all(), $this->config->raw(), $output);
  2143. return 0;
  2144. }
  2145. $settingKey = $input->getArgument('setting-key');
  2146. if (!$settingKey || !is_string($settingKey)) {
  2147. return 0;
  2148. }
  2149. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  2150. throw new \RuntimeException('You can not combine a setting value with --unset');
  2151. }
  2152. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  2153. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  2154. $rawData = $this->configFile->read();
  2155. $data = $this->config->all();
  2156. if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  2157. if (!isset($matches[1]) || $matches[1] === '') {
  2158. $value = isset($data['repositories']) ? $data['repositories'] : array();
  2159. } else {
  2160. if (!isset($data['repositories'][$matches[1]])) {
  2161. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  2162. }
  2163. $value = $data['repositories'][$matches[1]];
  2164. }
  2165. } elseif (strpos($settingKey, '.')) {
  2166. $bits = explode('.', $settingKey);
  2167. if ($bits[0] === 'extra') {
  2168. $data = $rawData;
  2169. } else {
  2170. $data = $data['config'];
  2171. }
  2172. $match = false;
  2173. foreach ($bits as $bit) {
  2174. $key = isset($key) ? $key.'.'.$bit : $bit;
  2175. $match = false;
  2176. if (isset($data[$key])) {
  2177. $match = true;
  2178. $data = $data[$key];
  2179. unset($key);
  2180. }
  2181. }
  2182. if (!$match) {
  2183. throw new \RuntimeException($settingKey.' is not defined.');
  2184. }
  2185. $value = $data;
  2186. } elseif (isset($data['config'][$settingKey])) {
  2187. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  2188. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  2189. $value = $rawData[$settingKey];
  2190. } else {
  2191. throw new \RuntimeException($settingKey.' is not defined');
  2192. }
  2193. if (is_array($value)) {
  2194. $value = json_encode($value);
  2195. }
  2196. $this->getIO()->write($value, true, IOInterface::QUIET);
  2197. return 0;
  2198. }
  2199. $values = $input->getArgument('setting-value');
  2200. $booleanValidator = function ($val) {
  2201. return in_array($val, array('true', 'false', '1', '0'), true);
  2202. };
  2203. $booleanNormalizer = function ($val) {
  2204. return $val !== 'false' && (bool) $val;
  2205. };
  2206. $uniqueConfigValues = array(
  2207. 'process-timeout' => array('is_numeric', 'intval'),
  2208. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  2209. 'use-github-api' => array($booleanValidator, $booleanNormalizer),
  2210. 'preferred-install' => array(
  2211. function ($val) {
  2212. return in_array($val, array('auto', 'source', 'dist'), true);
  2213. },
  2214. function ($val) {
  2215. return $val;
  2216. },
  2217. ),
  2218. 'store-auths' => array(
  2219. function ($val) {
  2220. return in_array($val, array('true', 'false', 'prompt'), true);
  2221. },
  2222. function ($val) {
  2223. if ('prompt' === $val) {
  2224. return 'prompt';
  2225. }
  2226. return $val !== 'false' && (bool) $val;
  2227. },
  2228. ),
  2229. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  2230. 'vendor-dir' => array('is_string', function ($val) {
  2231. return $val;
  2232. }),
  2233. 'bin-dir' => array('is_string', function ($val) {
  2234. return $val;
  2235. }),
  2236. 'archive-dir' => array('is_string', function ($val) {
  2237. return $val;
  2238. }),
  2239. 'archive-format' => array('is_string', function ($val) {
  2240. return $val;
  2241. }),
  2242. 'data-dir' => array('is_string', function ($val) {
  2243. return $val;
  2244. }),
  2245. 'cache-dir' => array('is_string', function ($val) {
  2246. return $val;
  2247. }),
  2248. 'cache-files-dir' => array('is_string', function ($val) {
  2249. return $val;
  2250. }),
  2251. 'cache-repo-dir' => array('is_string', function ($val) {
  2252. return $val;
  2253. }),
  2254. 'cache-vcs-dir' => array('is_string', function ($val) {
  2255. return $val;
  2256. }),
  2257. 'cache-ttl' => array('is_numeric', 'intval'),
  2258. 'cache-files-ttl' => array('is_numeric', 'intval'),
  2259. 'cache-files-maxsize' => array(
  2260. function ($val) {
  2261. return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0;
  2262. },
  2263. function ($val) {
  2264. return $val;
  2265. },
  2266. ),
  2267. 'bin-compat' => array(
  2268. function ($val) {
  2269. return in_array($val, array('auto', 'full'));
  2270. },
  2271. function ($val) {
  2272. return $val;
  2273. },
  2274. ),
  2275. 'discard-changes' => array(
  2276. function ($val) {
  2277. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  2278. },
  2279. function ($val) {
  2280. if ('stash' === $val) {
  2281. return 'stash';
  2282. }
  2283. return $val !== 'false' && (bool) $val;
  2284. },
  2285. ),
  2286. 'autoloader-suffix' => array('is_string', function ($val) {
  2287. return $val === 'null' ? null : $val;
  2288. }),
  2289. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  2290. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  2291. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  2292. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  2293. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  2294. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  2295. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  2296. 'cafile' => array(
  2297. function ($val) {
  2298. return file_exists($val) && is_readable($val);
  2299. },
  2300. function ($val) {
  2301. return $val === 'null' ? null : $val;
  2302. },
  2303. ),
  2304. 'capath' => array(
  2305. function ($val) {
  2306. return is_dir($val) && is_readable($val);
  2307. },
  2308. function ($val) {
  2309. return $val === 'null' ? null : $val;
  2310. },
  2311. ),
  2312. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  2313. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  2314. 'lock' => array($booleanValidator, $booleanNormalizer),
  2315. 'platform-check' => array(
  2316. function ($val) {
  2317. return in_array($val, array('php-only', 'true', 'false', '1', '0'), true);
  2318. },
  2319. function ($val) {
  2320. if ('php-only' === $val) {
  2321. return 'php-only';
  2322. }
  2323. return $val !== 'false' && (bool) $val;
  2324. },
  2325. ),
  2326. );
  2327. $multiConfigValues = array(
  2328. 'github-protocols' => array(
  2329. function ($vals) {
  2330. if (!is_array($vals)) {
  2331. return 'array expected';
  2332. }
  2333. foreach ($vals as $val) {
  2334. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2335. return 'valid protocols include: git, https, ssh';
  2336. }
  2337. }
  2338. return true;
  2339. },
  2340. function ($vals) {
  2341. return $vals;
  2342. },
  2343. ),
  2344. 'github-domains' => array(
  2345. function ($vals) {
  2346. if (!is_array($vals)) {
  2347. return 'array expected';
  2348. }
  2349. return true;
  2350. },
  2351. function ($vals) {
  2352. return $vals;
  2353. },
  2354. ),
  2355. 'gitlab-domains' => array(
  2356. function ($vals) {
  2357. if (!is_array($vals)) {
  2358. return 'array expected';
  2359. }
  2360. return true;
  2361. },
  2362. function ($vals) {
  2363. return $vals;
  2364. },
  2365. ),
  2366. );
  2367. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2368. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  2369. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2370. }
  2371. $this->configSource->removeConfigSetting($settingKey);
  2372. return 0;
  2373. }
  2374. if (isset($uniqueConfigValues[$settingKey])) {
  2375. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2376. return 0;
  2377. }
  2378. if (isset($multiConfigValues[$settingKey])) {
  2379. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2380. return 0;
  2381. }
  2382. if (preg_match('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  2383. if ($input->getOption('unset')) {
  2384. $this->configSource->removeConfigSetting($settingKey);
  2385. return 0;
  2386. }
  2387. list($validator) = $uniqueConfigValues['preferred-install'];
  2388. if (!$validator($values[0])) {
  2389. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  2390. }
  2391. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2392. return 0;
  2393. }
  2394. $uniqueProps = array(
  2395. 'name' => array('is_string', function ($val) {
  2396. return $val;
  2397. }),
  2398. 'type' => array('is_string', function ($val) {
  2399. return $val;
  2400. }),
  2401. 'description' => array('is_string', function ($val) {
  2402. return $val;
  2403. }),
  2404. 'homepage' => array('is_string', function ($val) {
  2405. return $val;
  2406. }),
  2407. 'version' => array('is_string', function ($val) {
  2408. return $val;
  2409. }),
  2410. 'minimum-stability' => array(
  2411. function ($val) {
  2412. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2413. },
  2414. function ($val) {
  2415. return VersionParser::normalizeStability($val);
  2416. },
  2417. ),
  2418. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2419. );
  2420. $multiProps = array(
  2421. 'keywords' => array(
  2422. function ($vals) {
  2423. if (!is_array($vals)) {
  2424. return 'array expected';
  2425. }
  2426. return true;
  2427. },
  2428. function ($vals) {
  2429. return $vals;
  2430. },
  2431. ),
  2432. 'license' => array(
  2433. function ($vals) {
  2434. if (!is_array($vals)) {
  2435. return 'array expected';
  2436. }
  2437. return true;
  2438. },
  2439. function ($vals) {
  2440. return $vals;
  2441. },
  2442. ),
  2443. );
  2444. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  2445. throw new \InvalidArgumentException('The '.$settingKey.' property can not be set in the global config.json file. Use `composer global config` to apply changes to the global composer.json');
  2446. }
  2447. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2448. $this->configSource->removeProperty($settingKey);
  2449. return 0;
  2450. }
  2451. if (isset($uniqueProps[$settingKey])) {
  2452. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2453. return 0;
  2454. }
  2455. if (isset($multiProps[$settingKey])) {
  2456. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2457. return 0;
  2458. }
  2459. if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2460. if ($input->getOption('unset')) {
  2461. $this->configSource->removeRepository($matches[1]);
  2462. return 0;
  2463. }
  2464. if (2 === count($values)) {
  2465. $this->configSource->addRepository($matches[1], array(
  2466. 'type' => $values[0],
  2467. 'url' => $values[1],
  2468. ), $input->getOption('append'));
  2469. return 0;
  2470. }
  2471. if (1 === count($values)) {
  2472. $value = strtolower($values[0]);
  2473. if (true === $booleanValidator($value)) {
  2474. if (false === $booleanNormalizer($value)) {
  2475. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  2476. return 0;
  2477. }
  2478. } else {
  2479. $value = JsonFile::parseJson($values[0]);
  2480. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  2481. return 0;
  2482. }
  2483. }
  2484. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2485. }
  2486. if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
  2487. if ($input->getOption('unset')) {
  2488. $this->configSource->removeProperty($settingKey);
  2489. return 0;
  2490. }
  2491. $value = $values[0];
  2492. if ($input->getOption('json')) {
  2493. $value = JsonFile::parseJson($value);
  2494. if ($input->getOption('merge')) {
  2495. $currentValue = $this->configFile->read();
  2496. $bits = explode('.', $settingKey);
  2497. foreach ($bits as $bit) {
  2498. $currentValue = isset($currentValue[$bit]) ? $currentValue[$bit] : null;
  2499. }
  2500. if (is_array($currentValue)) {
  2501. $value = array_merge($currentValue, $value);
  2502. }
  2503. }
  2504. }
  2505. $this->configSource->addProperty($settingKey, $value);
  2506. return 0;
  2507. }
  2508. if (preg_match('/^suggest\.(.+)/', $settingKey, $matches)) {
  2509. if ($input->getOption('unset')) {
  2510. $this->configSource->removeProperty($settingKey);
  2511. return 0;
  2512. }
  2513. $this->configSource->addProperty($settingKey, implode(' ', $values));
  2514. return 0;
  2515. }
  2516. if (in_array($settingKey, array('suggest', 'extra'), true) && $input->getOption('unset')) {
  2517. $this->configSource->removeProperty($settingKey);
  2518. return 0;
  2519. }
  2520. if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
  2521. if ($input->getOption('unset')) {
  2522. $this->configSource->removeConfigSetting($settingKey);
  2523. return 0;
  2524. }
  2525. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2526. return 0;
  2527. }
  2528. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2529. $this->configSource->removeConfigSetting($settingKey);
  2530. return 0;
  2531. }
  2532. if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  2533. if ($input->getOption('unset')) {
  2534. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2535. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2536. return 0;
  2537. }
  2538. if ($matches[1] === 'bitbucket-oauth') {
  2539. if (2 !== count($values)) {
  2540. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2541. }
  2542. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2543. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2544. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  2545. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2546. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'token' => $values[1]));
  2547. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
  2548. if (1 !== count($values)) {
  2549. throw new \RuntimeException('Too many arguments, expected only one token');
  2550. }
  2551. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2552. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2553. } elseif ($matches[1] === 'http-basic') {
  2554. if (2 !== count($values)) {
  2555. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2556. }
  2557. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2558. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2559. }
  2560. return 0;
  2561. }
  2562. if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
  2563. if ($input->getOption('unset')) {
  2564. $this->configSource->removeProperty($settingKey);
  2565. return 0;
  2566. }
  2567. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2568. return 0;
  2569. }
  2570. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2571. }
  2572. protected function handleSingleValue($key, array $callbacks, array $values, $method)
  2573. {
  2574. list($validator, $normalizer) = $callbacks;
  2575. if (1 !== count($values)) {
  2576. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2577. }
  2578. if (true !== $validation = $validator($values[0])) {
  2579. throw new \RuntimeException(sprintf(
  2580. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2581. $values[0]
  2582. ));
  2583. }
  2584. $normalizedValue = $normalizer($values[0]);
  2585. if ($key === 'disable-tls') {
  2586. if (!$normalizedValue && $this->config->get('disable-tls')) {
  2587. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2588. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  2589. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  2590. }
  2591. }
  2592. return call_user_func(array($this->configSource, $method), $key, $normalizedValue);
  2593. }
  2594. protected function handleMultiValue($key, array $callbacks, array $values, $method)
  2595. {
  2596. list($validator, $normalizer) = $callbacks;
  2597. if (true !== $validation = $validator($values)) {
  2598. throw new \RuntimeException(sprintf(
  2599. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2600. json_encode($values)
  2601. ));
  2602. }
  2603. return call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2604. }
  2605. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
  2606. {
  2607. $origK = $k;
  2608. $io = $this->getIO();
  2609. foreach ($contents as $key => $value) {
  2610. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2611. continue;
  2612. }
  2613. $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
  2614. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2615. $k .= preg_replace('{^config\.}', '', $key . '.');
  2616. $this->listConfiguration($value, $rawVal, $output, $k);
  2617. $k = $origK;
  2618. continue;
  2619. }
  2620. if (is_array($value)) {
  2621. $value = array_map(function ($val) {
  2622. return is_array($val) ? json_encode($val) : $val;
  2623. }, $value);
  2624. $value = '['.implode(', ', $value).']';
  2625. }
  2626. if (is_bool($value)) {
  2627. $value = var_export($value, true);
  2628. }
  2629. if (is_string($rawVal) && $rawVal != $value) {
  2630. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>', true, IOInterface::QUIET);
  2631. } else {
  2632. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>', true, IOInterface::QUIET);
  2633. }
  2634. }
  2635. }
  2636. }
  2637. <?php
  2638. namespace Composer\Command;
  2639. use Composer\Config;
  2640. use Composer\Factory;
  2641. use Composer\Installer;
  2642. use Composer\Installer\ProjectInstaller;
  2643. use Composer\Installer\SuggestedPackagesReporter;
  2644. use Composer\IO\IOInterface;
  2645. use Composer\Package\BasePackage;
  2646. use Composer\DependencyResolver\Operation\InstallOperation;
  2647. use Composer\Package\Version\VersionSelector;
  2648. use Composer\Package\AliasPackage;
  2649. use Composer\Repository\RepositoryFactory;
  2650. use Composer\Repository\CompositeRepository;
  2651. use Composer\Repository\PlatformRepository;
  2652. use Composer\Repository\InstalledFilesystemRepository;
  2653. use Composer\Repository\RepositorySet;
  2654. use Composer\Script\ScriptEvents;
  2655. use Composer\Util\Silencer;
  2656. use Symfony\Component\Console\Input\InputArgument;
  2657. use Symfony\Component\Console\Input\InputInterface;
  2658. use Symfony\Component\Console\Input\InputOption;
  2659. use Symfony\Component\Console\Output\OutputInterface;
  2660. use Symfony\Component\Finder\Finder;
  2661. use Composer\Json\JsonFile;
  2662. use Composer\Config\JsonConfigSource;
  2663. use Composer\Util\Filesystem;
  2664. use Composer\Util\ProcessExecutor;
  2665. use Composer\Package\Version\VersionParser;
  2666. class CreateProjectCommand extends BaseCommand
  2667. {
  2668. protected $suggestedPackagesReporter;
  2669. protected function configure()
  2670. {
  2671. $this
  2672. ->setName('create-project')
  2673. ->setDescription('Creates new project from a package into given directory.')
  2674. ->setDefinition(array(
  2675. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  2676. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  2677. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  2678. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  2679. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  2680. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  2681. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories to look the package up, either by URL or using JSON arrays'),
  2682. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  2683. new InputOption('add-repository', null, InputOption::VALUE_NONE, 'Add the custom repository in the composer.json. If a lock file is present it will be deleted and an update will be run instead of install.'),
  2684. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  2685. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  2686. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  2687. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  2688. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  2689. new InputOption('no-secure-http', null, InputOption::VALUE_NONE, 'Disable the secure-http config option temporarily while installing the root package. Use at your own risk. Using this flag is a bad idea.'),
  2690. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  2691. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  2692. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  2693. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  2694. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  2695. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  2696. ))
  2697. ->setHelp(
  2698. <<<EOT
  2699. The <info>create-project</info> command creates a new project from a given
  2700. package into a new directory. If executed without params and in a directory
  2701. with a composer.json file it installs the packages for the current project.
  2702. You can use this command to bootstrap new projects or setup a clean
  2703. version-controlled installation for developers of your project.
  2704. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  2705. You can also specify the version with the package name using = or : as separator.
  2706. <info>php composer.phar create-project vendor/project:version target-directory</info>
  2707. To install unstable packages, either specify the version you want, or use the
  2708. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  2709. To setup a developer workable version you should create the project using the source
  2710. controlled code by appending the <info>'--prefer-source'</info> flag.
  2711. To install a package from another repository than the default one you
  2712. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  2713. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  2714. EOT
  2715. )
  2716. ;
  2717. }
  2718. protected function execute(InputInterface $input, OutputInterface $output)
  2719. {
  2720. $config = Factory::createConfig();
  2721. $io = $this->getIO();
  2722. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  2723. if ($input->getOption('dev')) {
  2724. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  2725. }
  2726. if ($input->getOption('no-custom-installers')) {
  2727. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  2728. $input->setOption('no-plugins', true);
  2729. }
  2730. if ($input->isInteractive() && $input->getOption('ask')) {
  2731. $parts = explode("/", strtolower($input->getArgument('package')), 2);
  2732. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  2733. }
  2734. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  2735. return $this->installProject(
  2736. $io,
  2737. $config,
  2738. $input,
  2739. $input->getArgument('package'),
  2740. $input->getArgument('directory'),
  2741. $input->getArgument('version'),
  2742. $input->getOption('stability'),
  2743. $preferSource,
  2744. $preferDist,
  2745. !$input->getOption('no-dev'),
  2746. $input->getOption('repository') ?: $input->getOption('repository-url'),
  2747. $input->getOption('no-plugins'),
  2748. $input->getOption('no-scripts'),
  2749. $input->getOption('no-progress'),
  2750. $input->getOption('no-install'),
  2751. $ignorePlatformReqs,
  2752. !$input->getOption('no-secure-http'),
  2753. $input->getOption('add-repository')
  2754. );
  2755. }
  2756. public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $noScripts = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, $secureHttp = true, $addRepository = false)
  2757. {
  2758. $oldCwd = getcwd();
  2759. if ($repositories !== null && !is_array($repositories)) {
  2760. $repositories = (array) $repositories;
  2761. }
  2762. $io->loadConfiguration($config);
  2763. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  2764. if ($packageName !== null) {
  2765. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $noScripts, $noProgress, $ignorePlatformReqs, $secureHttp);
  2766. } else {
  2767. $installedFromVcs = false;
  2768. }
  2769. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  2770. unlink('composer.lock');
  2771. }
  2772. $composer = Factory::create($io, null, $disablePlugins);
  2773. if ($repositories !== null && $addRepository) {
  2774. foreach ($repositories as $index => $repo) {
  2775. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  2776. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  2777. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  2778. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2779. if (
  2780. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2781. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2782. ) {
  2783. $configSource->addRepository('packagist.org', false);
  2784. } else {
  2785. $configSource->addRepository($name, $repoConfig, false);
  2786. }
  2787. $composer = Factory::create($io, null, $disablePlugins);
  2788. }
  2789. }
  2790. $process = new ProcessExecutor($io);
  2791. $fs = new Filesystem($process);
  2792. if ($noScripts === false) {
  2793. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  2794. }
  2795. $config = $composer->getConfig();
  2796. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  2797. if ($noInstall === false) {
  2798. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  2799. $installer = Installer::create($io, $composer);
  2800. $installer->setPreferSource($preferSource)
  2801. ->setPreferDist($preferDist)
  2802. ->setDevMode($installDevPackages)
  2803. ->setRunScripts(!$noScripts)
  2804. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  2805. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  2806. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  2807. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  2808. ->setApcuAutoloader($config->get('apcu-autoloader'));
  2809. if (!$composer->getLocker()->isLocked()) {
  2810. $installer->setUpdate(true);
  2811. }
  2812. if ($disablePlugins) {
  2813. $installer->disablePlugins();
  2814. }
  2815. $status = $installer->run();
  2816. if (0 !== $status) {
  2817. return $status;
  2818. }
  2819. }
  2820. $hasVcs = $installedFromVcs;
  2821. if (
  2822. !$input->getOption('keep-vcs')
  2823. && $installedFromVcs
  2824. && (
  2825. $input->getOption('remove-vcs')
  2826. || !$io->isInteractive()
  2827. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  2828. )
  2829. ) {
  2830. $finder = new Finder();
  2831. $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
  2832. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  2833. $finder->name($vcsName);
  2834. }
  2835. try {
  2836. $dirs = iterator_to_array($finder);
  2837. unset($finder);
  2838. foreach ($dirs as $dir) {
  2839. if (!$fs->removeDirectory($dir)) {
  2840. throw new \RuntimeException('Could not remove '.$dir);
  2841. }
  2842. }
  2843. } catch (\Exception $e) {
  2844. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  2845. }
  2846. $hasVcs = false;
  2847. }
  2848. if (!$hasVcs) {
  2849. $package = $composer->getPackage();
  2850. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2851. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  2852. foreach ($package->{'get'.$meta['method']}() as $link) {
  2853. if ($link->getPrettyConstraint() === 'self.version') {
  2854. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  2855. }
  2856. }
  2857. }
  2858. }
  2859. if ($noScripts === false) {
  2860. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  2861. }
  2862. chdir($oldCwd);
  2863. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  2864. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  2865. Silencer::call('rmdir', $vendorComposerDir);
  2866. $vendorDir = $config->get('vendor-dir');
  2867. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  2868. Silencer::call('rmdir', $vendorDir);
  2869. }
  2870. }
  2871. return 0;
  2872. }
  2873. protected function installRootPackage(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, array $repositories = null, $disablePlugins = false, $noScripts = false, $noProgress = false, $ignorePlatformReqs = false, $secureHttp = true)
  2874. {
  2875. if (!$secureHttp) {
  2876. $config->merge(array('config' => array('secure-http' => false)));
  2877. }
  2878. $parser = new VersionParser();
  2879. $requirements = $parser->parseNameVersionPairs(array($packageName));
  2880. $name = strtolower($requirements[0]['name']);
  2881. if (!$packageVersion && isset($requirements[0]['version'])) {
  2882. $packageVersion = $requirements[0]['version'];
  2883. }
  2884. if (null === $directory) {
  2885. $parts = explode("/", $name, 2);
  2886. $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  2887. }
  2888. $process = new ProcessExecutor($io);
  2889. $fs = new Filesystem($process);
  2890. if (!$fs->isAbsolutePath($directory)) {
  2891. $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
  2892. }
  2893. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
  2894. if (file_exists($directory)) {
  2895. if (!is_dir($directory)) {
  2896. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  2897. }
  2898. if (!$fs->isDirEmpty($directory)) {
  2899. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  2900. }
  2901. }
  2902. if (null === $stability) {
  2903. if (null === $packageVersion) {
  2904. $stability = 'stable';
  2905. } elseif (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  2906. $stability = $match[1];
  2907. } else {
  2908. $stability = VersionParser::parseStability($packageVersion);
  2909. }
  2910. }
  2911. $stability = VersionParser::normalizeStability($stability);
  2912. if (!isset(BasePackage::$stabilities[$stability])) {
  2913. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  2914. }
  2915. $composer = Factory::create($io, $config->all(), $disablePlugins);
  2916. $config = $composer->getConfig();
  2917. $rm = $composer->getRepositoryManager();
  2918. $repositorySet = new RepositorySet($stability);
  2919. if (null === $repositories) {
  2920. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  2921. } else {
  2922. foreach ($repositories as $repo) {
  2923. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  2924. if (
  2925. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2926. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2927. ) {
  2928. continue;
  2929. }
  2930. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  2931. }
  2932. }
  2933. $platformOverrides = $config->get('platform') ?: array();
  2934. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  2935. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  2936. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $ignorePlatformReqs);
  2937. if (!$package) {
  2938. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  2939. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $packageVersion, $stability, true)) {
  2940. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  2941. }
  2942. throw new \InvalidArgumentException($errorMessage .'.');
  2943. }
  2944. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  2945. @mkdir($directory, 0777, true);
  2946. if ($realDir = realpath($directory)) {
  2947. pcntl_async_signals(true);
  2948. pcntl_signal(SIGINT, function () use ($realDir) {
  2949. $fs = new Filesystem();
  2950. $fs->removeDirectory($realDir);
  2951. exit(130);
  2952. });
  2953. }
  2954. }
  2955. if (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') {
  2956. @mkdir($directory, 0777, true);
  2957. if ($realDir = realpath($directory)) {
  2958. sapi_windows_set_ctrl_handler(function () use ($realDir) {
  2959. $fs = new Filesystem();
  2960. $fs->removeDirectory($realDir);
  2961. exit(130);
  2962. });
  2963. }
  2964. }
  2965. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  2966. $package = $package->getAliasOf();
  2967. }
  2968. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  2969. if ($disablePlugins) {
  2970. $io->writeError('<info>Plugins have been disabled.</info>');
  2971. }
  2972. if ($package instanceof AliasPackage) {
  2973. $package = $package->getAliasOf();
  2974. }
  2975. $dm = $composer->getDownloadManager();
  2976. $dm->setPreferSource($preferSource)
  2977. ->setPreferDist($preferDist);
  2978. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  2979. $im = $composer->getInstallationManager();
  2980. $im->setOutputProgress(!$noProgress);
  2981. $im->addInstaller($projectInstaller);
  2982. $im->execute(new InstalledFilesystemRepository(new JsonFile('php://memory')), array(new InstallOperation($package)));
  2983. $im->notifyInstalls($io);
  2984. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  2985. $installedFromVcs = 'source' === $package->getInstallationSource();
  2986. $io->writeError('<info>Created project in ' . $directory . '</info>');
  2987. chdir($directory);
  2988. $_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion();
  2989. putenv('COMPOSER_ROOT_VERSION='.$_SERVER['COMPOSER_ROOT_VERSION']);
  2990. return $installedFromVcs;
  2991. }
  2992. }
  2993. <?php
  2994. namespace Composer\Command;
  2995. use Symfony\Component\Console\Input\InputInterface;
  2996. use Symfony\Component\Console\Output\OutputInterface;
  2997. class DependsCommand extends BaseDependencyCommand
  2998. {
  2999. protected function configure()
  3000. {
  3001. parent::configure();
  3002. $this
  3003. ->setName('depends')
  3004. ->setAliases(array('why'))
  3005. ->setDescription('Shows which packages cause the given package to be installed.')
  3006. ->setHelp(
  3007. <<<EOT
  3008. Displays detailed information about where a package is referenced.
  3009. <info>php composer.phar depends composer/composer</info>
  3010. Read more at https://getcomposer.org/doc/03-cli.md#depends-why-
  3011. EOT
  3012. )
  3013. ;
  3014. }
  3015. protected function execute(InputInterface $input, OutputInterface $output)
  3016. {
  3017. return parent::doExecute($input, $output);
  3018. }
  3019. }
  3020. <?php
  3021. namespace Composer\Command;
  3022. use Composer\Composer;
  3023. use Composer\Factory;
  3024. use Composer\Config;
  3025. use Composer\Downloader\TransportException;
  3026. use Composer\Repository\PlatformRepository;
  3027. use Composer\Plugin\CommandEvent;
  3028. use Composer\Plugin\PluginEvents;
  3029. use Composer\Util\ConfigValidator;
  3030. use Composer\Util\IniHelper;
  3031. use Composer\Util\ProcessExecutor;
  3032. use Composer\Util\HttpDownloader;
  3033. use Composer\Util\StreamContextFactory;
  3034. use Composer\SelfUpdate\Keys;
  3035. use Composer\SelfUpdate\Versions;
  3036. use Composer\IO\NullIO;
  3037. use Symfony\Component\Console\Input\InputInterface;
  3038. use Symfony\Component\Console\Output\OutputInterface;
  3039. use Symfony\Component\Process\ExecutableFinder;
  3040. class DiagnoseCommand extends BaseCommand
  3041. {
  3042. protected $httpDownloader;
  3043. protected $process;
  3044. protected $exitCode = 0;
  3045. protected function configure()
  3046. {
  3047. $this
  3048. ->setName('diagnose')
  3049. ->setDescription('Diagnoses the system to identify common errors.')
  3050. ->setHelp(
  3051. <<<EOT
  3052. The <info>diagnose</info> command checks common errors to help debugging problems.
  3053. The process exit code will be 1 in case of warnings and 2 for errors.
  3054. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  3055. EOT
  3056. )
  3057. ;
  3058. }
  3059. protected function execute(InputInterface $input, OutputInterface $output)
  3060. {
  3061. $composer = $this->getComposer(false);
  3062. $io = $this->getIO();
  3063. if ($composer) {
  3064. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  3065. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3066. $io->write('Checking composer.json: ', false);
  3067. $this->outputResult($this->checkComposerSchema());
  3068. }
  3069. if ($composer) {
  3070. $config = $composer->getConfig();
  3071. } else {
  3072. $config = Factory::createConfig();
  3073. }
  3074. $config->merge(array('config' => array('secure-http' => false)));
  3075. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  3076. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  3077. $this->process = new ProcessExecutor($io);
  3078. $io->write('Checking platform settings: ', false);
  3079. $this->outputResult($this->checkPlatform());
  3080. $io->write('Checking git settings: ', false);
  3081. $this->outputResult($this->checkGit());
  3082. $io->write('Checking http connectivity to packagist: ', false);
  3083. $this->outputResult($this->checkHttp('http', $config));
  3084. $io->write('Checking https connectivity to packagist: ', false);
  3085. $this->outputResult($this->checkHttp('https', $config));
  3086. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  3087. if (!empty($opts['http']['proxy'])) {
  3088. $io->write('Checking HTTP proxy: ', false);
  3089. $this->outputResult($this->checkHttpProxy());
  3090. }
  3091. if ($oauth = $config->get('github-oauth')) {
  3092. foreach ($oauth as $domain => $token) {
  3093. $io->write('Checking '.$domain.' oauth access: ', false);
  3094. $this->outputResult($this->checkGithubOauth($domain, $token));
  3095. }
  3096. } else {
  3097. $io->write('Checking github.com rate limit: ', false);
  3098. try {
  3099. $rate = $this->getGithubRateLimit('github.com');
  3100. if (!is_array($rate)) {
  3101. $this->outputResult($rate);
  3102. } elseif (10 > $rate['remaining']) {
  3103. $io->write('<warning>WARNING</warning>');
  3104. $io->write(sprintf(
  3105. '<comment>Github has a rate limit on their API. '
  3106. . 'You currently have <options=bold>%u</options=bold> '
  3107. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  3108. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  3109. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  3110. $rate['remaining'],
  3111. $rate['limit']
  3112. ));
  3113. } else {
  3114. $this->outputResult(true);
  3115. }
  3116. } catch (\Exception $e) {
  3117. if ($e instanceof TransportException && $e->getCode() === 401) {
  3118. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  3119. } else {
  3120. $this->outputResult($e);
  3121. }
  3122. }
  3123. }
  3124. $io->write('Checking disk free space: ', false);
  3125. $this->outputResult($this->checkDiskSpace($config));
  3126. if (strpos(__FILE__, 'phar:') === 0) {
  3127. $io->write('Checking pubkeys: ', false);
  3128. $this->outputResult($this->checkPubKeys($config));
  3129. $io->write('Checking composer version: ', false);
  3130. $this->outputResult($this->checkVersion($config));
  3131. }
  3132. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  3133. $platformOverrides = $config->get('platform') ?: array();
  3134. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3135. $phpPkg = $platformRepo->findPackage('php', '*');
  3136. $phpVersion = $phpPkg->getPrettyVersion();
  3137. if (false !== strpos($phpPkg->getDescription(), 'overridden')) {
  3138. $phpVersion .= ' - ' . $phpPkg->getDescription();
  3139. }
  3140. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  3141. if (defined('PHP_BINARY')) {
  3142. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  3143. }
  3144. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  3145. $io->write('cURL version: ' . $this->getCurlVersion());
  3146. $finder = new ExecutableFinder;
  3147. $hasSystemUnzip = (bool) $finder->find('unzip');
  3148. $io->write(
  3149. 'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
  3150. . ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
  3151. );
  3152. return $this->exitCode;
  3153. }
  3154. private function checkComposerSchema()
  3155. {
  3156. $validator = new ConfigValidator($this->getIO());
  3157. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  3158. if ($errors || $warnings) {
  3159. $messages = array(
  3160. 'error' => $errors,
  3161. 'warning' => $warnings,
  3162. );
  3163. $output = '';
  3164. foreach ($messages as $style => $msgs) {
  3165. foreach ($msgs as $msg) {
  3166. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  3167. }
  3168. }
  3169. return rtrim($output);
  3170. }
  3171. return true;
  3172. }
  3173. private function checkGit()
  3174. {
  3175. $this->process->execute('git config color.ui', $output);
  3176. if (strtolower(trim($output)) === 'always') {
  3177. return '<comment>Your git color.ui setting is set to always, this is known to create issues. Use "git config --global color.ui true" to set it correctly.</comment>';
  3178. }
  3179. return true;
  3180. }
  3181. private function checkHttp($proto, Config $config)
  3182. {
  3183. $result = $this->checkConnectivity();
  3184. if ($result !== true) {
  3185. return $result;
  3186. }
  3187. $result = array();
  3188. if ($proto === 'https' && $config->get('disable-tls') === true) {
  3189. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  3190. }
  3191. try {
  3192. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  3193. } catch (TransportException $e) {
  3194. if ($hints = HttpDownloader::getExceptionHints($e)) {
  3195. foreach ($hints as $hint) {
  3196. $result[] = $hint;
  3197. }
  3198. }
  3199. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  3200. }
  3201. if (isset($tlsWarning)) {
  3202. $result[] = $tlsWarning;
  3203. }
  3204. if (count($result) > 0) {
  3205. return $result;
  3206. }
  3207. return true;
  3208. }
  3209. private function checkHttpProxy()
  3210. {
  3211. $result = $this->checkConnectivity();
  3212. if ($result !== true) {
  3213. return $result;
  3214. }
  3215. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  3216. try {
  3217. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  3218. $hash = reset($json['provider-includes']);
  3219. $hash = $hash['sha256'];
  3220. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  3221. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  3222. if (hash('sha256', $provider) !== $hash) {
  3223. return 'It seems that your proxy is modifying http traffic on the fly';
  3224. }
  3225. } catch (\Exception $e) {
  3226. return $e;
  3227. }
  3228. return true;
  3229. }
  3230. private function checkGithubOauth($domain, $token)
  3231. {
  3232. $result = $this->checkConnectivity();
  3233. if ($result !== true) {
  3234. return $result;
  3235. }
  3236. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3237. try {
  3238. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  3239. return $this->httpDownloader->get($url, array(
  3240. 'retry-auth-failure' => false,
  3241. )) ? true : 'Unexpected error';
  3242. } catch (\Exception $e) {
  3243. if ($e instanceof TransportException && $e->getCode() === 401) {
  3244. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  3245. }
  3246. return $e;
  3247. }
  3248. }
  3249. private function getGithubRateLimit($domain, $token = null)
  3250. {
  3251. $result = $this->checkConnectivity();
  3252. if ($result !== true) {
  3253. return $result;
  3254. }
  3255. if ($token) {
  3256. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3257. }
  3258. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  3259. $data = $this->httpDownloader->get($url, array('retry-auth-failure' => false))->decodeJson();
  3260. return $data['resources']['core'];
  3261. }
  3262. private function checkDiskSpace($config)
  3263. {
  3264. $minSpaceFree = 1024 * 1024;
  3265. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  3266. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  3267. ) {
  3268. return '<error>The disk hosting '.$dir.' is full</error>';
  3269. }
  3270. return true;
  3271. }
  3272. private function checkPubKeys($config)
  3273. {
  3274. $home = $config->get('home');
  3275. $errors = array();
  3276. $io = $this->getIO();
  3277. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  3278. $io->write('');
  3279. }
  3280. if (file_exists($home.'/keys.tags.pub')) {
  3281. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  3282. } else {
  3283. $errors[] = '<error>Missing pubkey for tags verification</error>';
  3284. }
  3285. if (file_exists($home.'/keys.dev.pub')) {
  3286. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  3287. } else {
  3288. $errors[] = '<error>Missing pubkey for dev verification</error>';
  3289. }
  3290. if ($errors) {
  3291. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  3292. }
  3293. return $errors ?: true;
  3294. }
  3295. private function checkVersion($config)
  3296. {
  3297. $result = $this->checkConnectivity();
  3298. if ($result !== true) {
  3299. return $result;
  3300. }
  3301. $versionsUtil = new Versions($config, $this->httpDownloader);
  3302. try {
  3303. $latest = $versionsUtil->getLatest();
  3304. } catch (\Exception $e) {
  3305. return $e;
  3306. }
  3307. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  3308. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  3309. }
  3310. return true;
  3311. }
  3312. private function getCurlVersion()
  3313. {
  3314. if (extension_loaded('curl')) {
  3315. if (!HttpDownloader::isCurlEnabled()) {
  3316. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  3317. }
  3318. $version = curl_version();
  3319. return '<comment>'.$version['version'].'</comment> '.
  3320. 'libz <comment>'.(isset($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  3321. 'ssl <comment>'.(isset($version['ssl_version']) ? $version['ssl_version'] : 'missing').'</comment>';
  3322. }
  3323. return '<error>missing, using php streams fallback, which reduces performance</error>';
  3324. }
  3325. private function outputResult($result)
  3326. {
  3327. $io = $this->getIO();
  3328. if (true === $result) {
  3329. $io->write('<info>OK</info>');
  3330. return;
  3331. }
  3332. $hadError = false;
  3333. $hadWarning = false;
  3334. if ($result instanceof \Exception) {
  3335. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  3336. }
  3337. if (!$result) {
  3338. $hadError = true;
  3339. } else {
  3340. if (!is_array($result)) {
  3341. $result = array($result);
  3342. }
  3343. foreach ($result as $message) {
  3344. if (false !== strpos($message, '<error>')) {
  3345. $hadError = true;
  3346. } elseif (false !== strpos($message, '<warning>')) {
  3347. $hadWarning = true;
  3348. }
  3349. }
  3350. }
  3351. if ($hadError) {
  3352. $io->write('<error>FAIL</error>');
  3353. $this->exitCode = max($this->exitCode, 2);
  3354. } elseif ($hadWarning) {
  3355. $io->write('<warning>WARNING</warning>');
  3356. $this->exitCode = max($this->exitCode, 1);
  3357. }
  3358. if ($result) {
  3359. foreach ($result as $message) {
  3360. $io->write($message);
  3361. }
  3362. }
  3363. }
  3364. private function checkPlatform()
  3365. {
  3366. $output = '';
  3367. $out = function ($msg, $style) use (&$output) {
  3368. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  3369. };
  3370. $errors = array();
  3371. $warnings = array();
  3372. $displayIniMessage = false;
  3373. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  3374. $iniMessage .= PHP_EOL.'If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.';
  3375. if (!function_exists('json_decode')) {
  3376. $errors['json'] = true;
  3377. }
  3378. if (!extension_loaded('Phar')) {
  3379. $errors['phar'] = true;
  3380. }
  3381. if (!extension_loaded('filter')) {
  3382. $errors['filter'] = true;
  3383. }
  3384. if (!extension_loaded('hash')) {
  3385. $errors['hash'] = true;
  3386. }
  3387. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  3388. $errors['iconv_mbstring'] = true;
  3389. }
  3390. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  3391. $errors['allow_url_fopen'] = true;
  3392. }
  3393. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  3394. $errors['ioncube'] = ioncube_loader_version();
  3395. }
  3396. if (PHP_VERSION_ID < 50302) {
  3397. $errors['php'] = PHP_VERSION;
  3398. }
  3399. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  3400. $warnings['php'] = PHP_VERSION;
  3401. }
  3402. if (!extension_loaded('openssl')) {
  3403. $errors['openssl'] = true;
  3404. }
  3405. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  3406. $warnings['openssl_version'] = true;
  3407. }
  3408. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  3409. $warnings['apc_cli'] = true;
  3410. }
  3411. if (!extension_loaded('zlib')) {
  3412. $warnings['zlib'] = true;
  3413. }
  3414. ob_start();
  3415. phpinfo(INFO_GENERAL);
  3416. $phpinfo = ob_get_clean();
  3417. if (preg_match('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  3418. $configure = $match[1];
  3419. if (false !== strpos($configure, '--enable-sigchild')) {
  3420. $warnings['sigchild'] = true;
  3421. }
  3422. if (false !== strpos($configure, '--with-curlwrappers')) {
  3423. $warnings['curlwrappers'] = true;
  3424. }
  3425. }
  3426. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  3427. $warnings['xdebug_profile'] = true;
  3428. } elseif (extension_loaded('xdebug')) {
  3429. $warnings['xdebug_loaded'] = true;
  3430. }
  3431. if (defined('PHP_WINDOWS_VERSION_BUILD')
  3432. && (version_compare(PHP_VERSION, '7.2.23', '<')
  3433. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  3434. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  3435. $warnings['onedrive'] = PHP_VERSION;
  3436. }
  3437. if (!empty($errors)) {
  3438. foreach ($errors as $error => $current) {
  3439. switch ($error) {
  3440. case 'json':
  3441. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  3442. $text .= "Install it or recompile php without --disable-json";
  3443. break;
  3444. case 'phar':
  3445. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3446. $text .= "Install it or recompile php without --disable-phar";
  3447. break;
  3448. case 'filter':
  3449. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3450. $text .= "Install it or recompile php without --disable-filter";
  3451. break;
  3452. case 'hash':
  3453. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3454. $text .= "Install it or recompile php without --disable-hash";
  3455. break;
  3456. case 'iconv_mbstring':
  3457. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3458. $text .= "Install either of them or recompile php without --disable-iconv";
  3459. break;
  3460. case 'php':
  3461. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  3462. break;
  3463. case 'allow_url_fopen':
  3464. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3465. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3466. $text .= " allow_url_fopen = On";
  3467. $displayIniMessage = true;
  3468. break;
  3469. case 'ioncube':
  3470. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3471. $text .= "Upgrade to ionCube 4.0.9 or higher or remove this line (path may be different) from your `php.ini` to disable it:".PHP_EOL;
  3472. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3473. $displayIniMessage = true;
  3474. break;
  3475. case 'openssl':
  3476. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3477. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3478. break;
  3479. default:
  3480. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  3481. }
  3482. $out($text, 'error');
  3483. }
  3484. $output .= PHP_EOL;
  3485. }
  3486. if (!empty($warnings)) {
  3487. foreach ($warnings as $warning => $current) {
  3488. switch ($warning) {
  3489. case 'apc_cli':
  3490. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3491. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3492. $text .= " apc.enable_cli = Off";
  3493. $displayIniMessage = true;
  3494. break;
  3495. case 'zlib':
  3496. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3497. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3498. $displayIniMessage = true;
  3499. break;
  3500. case 'sigchild':
  3501. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3502. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3503. $text .= " https://bugs.php.net/bug.php?id=22999";
  3504. break;
  3505. case 'curlwrappers':
  3506. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3507. $text .= " Recompile it without this flag if possible";
  3508. break;
  3509. case 'php':
  3510. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  3511. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  3512. break;
  3513. case 'openssl_version':
  3514. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3515. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3516. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3517. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3518. break;
  3519. case 'xdebug_loaded':
  3520. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3521. $text .= " Disabling it when using Composer is recommended.";
  3522. break;
  3523. case 'xdebug_profile':
  3524. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3525. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3526. $text .= " xdebug.profiler_enabled = 0";
  3527. $displayIniMessage = true;
  3528. break;
  3529. case 'onedrive':
  3530. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  3531. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  3532. break;
  3533. default:
  3534. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  3535. }
  3536. $out($text, 'comment');
  3537. }
  3538. }
  3539. if ($displayIniMessage) {
  3540. $out($iniMessage, 'comment');
  3541. }
  3542. return !$warnings && !$errors ? true : $output;
  3543. }
  3544. private function checkConnectivity()
  3545. {
  3546. if (!ini_get('allow_url_fopen')) {
  3547. return '<info>Skipped because allow_url_fopen is missing.</info>';
  3548. }
  3549. return true;
  3550. }
  3551. }
  3552. <?php
  3553. namespace Composer\Command;
  3554. use Composer\Plugin\CommandEvent;
  3555. use Composer\Plugin\PluginEvents;
  3556. use Symfony\Component\Console\Input\InputInterface;
  3557. use Symfony\Component\Console\Input\InputOption;
  3558. use Symfony\Component\Console\Output\OutputInterface;
  3559. class DumpAutoloadCommand extends BaseCommand
  3560. {
  3561. protected function configure()
  3562. {
  3563. $this
  3564. ->setName('dump-autoload')
  3565. ->setAliases(array('dumpautoload'))
  3566. ->setDescription('Dumps the autoloader.')
  3567. ->setDefinition(array(
  3568. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  3569. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3570. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3571. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3572. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  3573. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules.'),
  3574. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3575. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3576. ))
  3577. ->setHelp(
  3578. <<<EOT
  3579. <info>php composer.phar dump-autoload</info>
  3580. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
  3581. EOT
  3582. )
  3583. ;
  3584. }
  3585. protected function execute(InputInterface $input, OutputInterface $output)
  3586. {
  3587. $composer = $this->getComposer();
  3588. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3589. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3590. $installationManager = $composer->getInstallationManager();
  3591. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3592. $package = $composer->getPackage();
  3593. $config = $composer->getConfig();
  3594. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3595. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3596. $apcuPrefix = $input->getOption('apcu-prefix');
  3597. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  3598. if ($authoritative) {
  3599. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  3600. } elseif ($optimize) {
  3601. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  3602. } else {
  3603. $this->getIO()->write('<info>Generating autoload files</info>');
  3604. }
  3605. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  3606. $generator = $composer->getAutoloadGenerator();
  3607. $generator->setDevMode(!$input->getOption('no-dev'));
  3608. $generator->setClassMapAuthoritative($authoritative);
  3609. $generator->setApcu($apcu, $apcuPrefix);
  3610. $generator->setRunScripts(!$input->getOption('no-scripts'));
  3611. $generator->setIgnorePlatformRequirements($ignorePlatformReqs);
  3612. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3613. if ($authoritative) {
  3614. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3615. } elseif ($optimize) {
  3616. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3617. } else {
  3618. $this->getIO()->write('<info>Generated autoload files</info>');
  3619. }
  3620. return 0;
  3621. }
  3622. }
  3623. <?php
  3624. namespace Composer\Command;
  3625. use Symfony\Component\Console\Input\InputInterface;
  3626. use Symfony\Component\Console\Input\InputOption;
  3627. use Symfony\Component\Console\Output\OutputInterface;
  3628. use Symfony\Component\Console\Input\InputArgument;
  3629. class ExecCommand extends BaseCommand
  3630. {
  3631. protected function configure()
  3632. {
  3633. $this
  3634. ->setName('exec')
  3635. ->setDescription('Executes a vendored binary/script.')
  3636. ->setDefinition(array(
  3637. new InputOption('list', 'l', InputOption::VALUE_NONE),
  3638. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  3639. new InputArgument(
  3640. 'args',
  3641. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  3642. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  3643. ),
  3644. ))
  3645. ->setHelp(
  3646. <<<EOT
  3647. Executes a vendored binary/script.
  3648. Read more at https://getcomposer.org/doc/03-cli.md#exec
  3649. EOT
  3650. )
  3651. ;
  3652. }
  3653. protected function execute(InputInterface $input, OutputInterface $output)
  3654. {
  3655. $composer = $this->getComposer();
  3656. $binDir = $composer->getConfig()->get('bin-dir');
  3657. if ($input->getOption('list') || !$input->getArgument('binary')) {
  3658. $bins = glob($binDir . '/*');
  3659. $bins = array_merge($bins, array_map(function ($e) {
  3660. return "$e (local)";
  3661. }, $composer->getPackage()->getBinaries()));
  3662. if (!$bins) {
  3663. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  3664. }
  3665. $this->getIO()->write(
  3666. <<<EOT
  3667. <comment>Available binaries:</comment>
  3668. EOT
  3669. );
  3670. foreach ($bins as $bin) {
  3671. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  3672. continue;
  3673. }
  3674. $previousBin = $bin;
  3675. $bin = basename($bin);
  3676. $this->getIO()->write(
  3677. <<<EOT
  3678. <info>- $bin</info>
  3679. EOT
  3680. );
  3681. }
  3682. return 0;
  3683. }
  3684. $binary = $input->getArgument('binary');
  3685. $dispatcher = $composer->getEventDispatcher();
  3686. $dispatcher->addListener('__exec_command', $binary);
  3687. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {
  3688. try {
  3689. chdir($this->getApplication()->getInitialWorkingDirectory());
  3690. } catch (\Exception $e) {
  3691. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  3692. }
  3693. }
  3694. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  3695. }
  3696. }
  3697. <?php
  3698. namespace Composer\Command;
  3699. use Composer\Package\CompletePackageInterface;
  3700. use Composer\Package\AliasPackage;
  3701. use Composer\Package\BasePackage;
  3702. use Composer\Semver\Constraint\MatchAllConstraint;
  3703. use Composer\Repository\CompositeRepository;
  3704. use Symfony\Component\Console\Input\InputInterface;
  3705. use Symfony\Component\Console\Output\OutputInterface;
  3706. class FundCommand extends BaseCommand
  3707. {
  3708. protected function configure()
  3709. {
  3710. $this->setName('fund')
  3711. ->setDescription('Discover how to help fund the maintenance of your dependencies.')
  3712. ;
  3713. }
  3714. protected function execute(InputInterface $input, OutputInterface $output)
  3715. {
  3716. $composer = $this->getComposer();
  3717. $repo = $composer->getRepositoryManager()->getLocalRepository();
  3718. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  3719. $fundings = array();
  3720. $packagesToLoad = array();
  3721. foreach ($repo->getPackages() as $package) {
  3722. if ($package instanceof AliasPackage) {
  3723. continue;
  3724. }
  3725. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  3726. }
  3727. $result = $remoteRepos->loadPackages($packagesToLoad, array('dev' => BasePackage::STABILITY_DEV), array());
  3728. foreach ($result['packages'] as $package) {
  3729. if (
  3730. !$package instanceof AliasPackage
  3731. && $package instanceof CompletePackageInterface
  3732. && $package->isDefaultBranch()
  3733. && $package->getFunding()
  3734. && isset($packagesToLoad[$package->getName()])
  3735. ) {
  3736. $fundings = $this->insertFundingData($fundings, $package);
  3737. unset($packagesToLoad[$package->getName()]);
  3738. }
  3739. }
  3740. foreach ($repo->getPackages() as $package) {
  3741. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  3742. continue;
  3743. }
  3744. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  3745. $fundings = $this->insertFundingData($fundings, $package);
  3746. }
  3747. }
  3748. ksort($fundings);
  3749. $io = $this->getIO();
  3750. if ($fundings) {
  3751. $prev = null;
  3752. $io->write('The following packages were found in your dependencies which publish funding information:');
  3753. foreach ($fundings as $vendor => $links) {
  3754. $io->write('');
  3755. $io->write(sprintf("<comment>%s</comment>", $vendor));
  3756. foreach ($links as $url => $packages) {
  3757. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  3758. if ($prev !== $line) {
  3759. $io->write($line);
  3760. $prev = $line;
  3761. }
  3762. $io->write(sprintf(' %s', $url));
  3763. }
  3764. }
  3765. $io->write("");
  3766. $io->write("Please consider following these links and sponsoring the work of package authors!");
  3767. $io->write("Thank you!");
  3768. } else {
  3769. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  3770. }
  3771. return 0;
  3772. }
  3773. private function insertFundingData(array $fundings, CompletePackageInterface $package)
  3774. {
  3775. foreach ($package->getFunding() as $fundingOption) {
  3776. list($vendor, $packageName) = explode('/', $package->getPrettyName());
  3777. if (empty($fundingOption['url'])) {
  3778. continue;
  3779. }
  3780. $url = $fundingOption['url'];
  3781. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && preg_match('{^https://github.com/([^/]+)$}', $url, $match)) {
  3782. $url = 'https://github.com/sponsors/'.$match[1];
  3783. }
  3784. $fundings[$vendor][$url][] = $packageName;
  3785. }
  3786. return $fundings;
  3787. }
  3788. }
  3789. <?php
  3790. namespace Composer\Command;
  3791. use Composer\Factory;
  3792. use Composer\Util\Filesystem;
  3793. use Symfony\Component\Console\Input\InputInterface;
  3794. use Symfony\Component\Console\Input\InputArgument;
  3795. use Symfony\Component\Console\Input\StringInput;
  3796. use Symfony\Component\Console\Output\OutputInterface;
  3797. class GlobalCommand extends BaseCommand
  3798. {
  3799. protected function configure()
  3800. {
  3801. $this
  3802. ->setName('global')
  3803. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  3804. ->setDefinition(array(
  3805. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  3806. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  3807. ))
  3808. ->setHelp(
  3809. <<<EOT
  3810. Use this command as a wrapper to run other Composer commands
  3811. within the global context of COMPOSER_HOME.
  3812. You can use this to install CLI utilities globally, all you need
  3813. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  3814. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  3815. and /home/<user>/.composer on unix systems.
  3816. If your system uses freedesktop.org standards, then it will first check
  3817. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  3818. Note: This path may vary depending on customizations to bin-dir in
  3819. composer.json or the environmental variable COMPOSER_BIN_DIR.
  3820. Read more at https://getcomposer.org/doc/03-cli.md#global
  3821. EOT
  3822. )
  3823. ;
  3824. }
  3825. public function run(InputInterface $input, OutputInterface $output)
  3826. {
  3827. $tokens = preg_split('{\s+}', $input->__toString());
  3828. $args = array();
  3829. foreach ($tokens as $token) {
  3830. if ($token && $token[0] !== '-') {
  3831. $args[] = $token;
  3832. if (count($args) >= 2) {
  3833. break;
  3834. }
  3835. }
  3836. }
  3837. if (count($args) < 2) {
  3838. return parent::run($input, $output);
  3839. }
  3840. if (getenv('COMPOSER')) {
  3841. putenv('COMPOSER');
  3842. unset($_SERVER['COMPOSER']);
  3843. }
  3844. $config = Factory::createConfig();
  3845. $home = $config->get('home');
  3846. if (!is_dir($home)) {
  3847. $fs = new Filesystem();
  3848. $fs->ensureDirectoryExists($home);
  3849. if (!is_dir($home)) {
  3850. throw new \RuntimeException('Could not create home directory');
  3851. }
  3852. }
  3853. try {
  3854. chdir($home);
  3855. } catch (\Exception $e) {
  3856. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  3857. }
  3858. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  3859. $input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  3860. $this->getApplication()->resetComposer();
  3861. return $this->getApplication()->run($input, $output);
  3862. }
  3863. public function isProxyCommand()
  3864. {
  3865. return true;
  3866. }
  3867. }
  3868. <?php
  3869. namespace Composer\Command;
  3870. use Composer\Package\CompletePackageInterface;
  3871. use Composer\Repository\RepositoryInterface;
  3872. use Composer\Repository\RootPackageRepository;
  3873. use Composer\Repository\RepositoryFactory;
  3874. use Composer\Util\Platform;
  3875. use Composer\Util\ProcessExecutor;
  3876. use Symfony\Component\Console\Input\InputArgument;
  3877. use Symfony\Component\Console\Input\InputOption;
  3878. use Symfony\Component\Console\Input\InputInterface;
  3879. use Symfony\Component\Console\Output\OutputInterface;
  3880. class HomeCommand extends BaseCommand
  3881. {
  3882. protected function configure()
  3883. {
  3884. $this
  3885. ->setName('browse')
  3886. ->setAliases(array('home'))
  3887. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  3888. ->setDefinition(array(
  3889. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  3890. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  3891. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  3892. ))
  3893. ->setHelp(
  3894. <<<EOT
  3895. The home command opens or shows a package's repository URL or
  3896. homepage in your default browser.
  3897. To open the homepage by default, use -H or --homepage.
  3898. To show instead of open the repository or homepage URL, use -s or --show.
  3899. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  3900. EOT
  3901. );
  3902. }
  3903. protected function execute(InputInterface $input, OutputInterface $output)
  3904. {
  3905. $repos = $this->initializeRepos();
  3906. $io = $this->getIO();
  3907. $return = 0;
  3908. $packages = $input->getArgument('packages');
  3909. if (!$packages) {
  3910. $io->writeError('No package specified, opening homepage for the root package');
  3911. $packages = array($this->getComposer()->getPackage()->getName());
  3912. }
  3913. foreach ($packages as $packageName) {
  3914. $handled = false;
  3915. $packageExists = false;
  3916. foreach ($repos as $repo) {
  3917. foreach ($repo->findPackages($packageName) as $package) {
  3918. $packageExists = true;
  3919. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  3920. $handled = true;
  3921. break 2;
  3922. }
  3923. }
  3924. }
  3925. if (!$packageExists) {
  3926. $return = 1;
  3927. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  3928. }
  3929. if (!$handled) {
  3930. $return = 1;
  3931. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  3932. }
  3933. }
  3934. return $return;
  3935. }
  3936. private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
  3937. {
  3938. $support = $package->getSupport();
  3939. $url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
  3940. if (!$url || $showHomepage) {
  3941. $url = $package->getHomepage();
  3942. }
  3943. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  3944. return false;
  3945. }
  3946. if ($showOnly) {
  3947. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  3948. } else {
  3949. $this->openBrowser($url);
  3950. }
  3951. return true;
  3952. }
  3953. private function openBrowser($url)
  3954. {
  3955. $url = ProcessExecutor::escape($url);
  3956. $process = new ProcessExecutor($this->getIO());
  3957. if (Platform::isWindows()) {
  3958. return $process->execute('start "web" explorer "' . $url . '"', $output);
  3959. }
  3960. $linux = $process->execute('which xdg-open', $output);
  3961. $osx = $process->execute('which open', $output);
  3962. if (0 === $linux) {
  3963. $process->execute('xdg-open ' . $url, $output);
  3964. } elseif (0 === $osx) {
  3965. $process->execute('open ' . $url, $output);
  3966. } else {
  3967. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  3968. }
  3969. }
  3970. private function initializeRepos()
  3971. {
  3972. $composer = $this->getComposer(false);
  3973. if ($composer) {
  3974. return array_merge(
  3975. array(new RootPackageRepository($composer->getPackage())),
  3976. array($composer->getRepositoryManager()->getLocalRepository()),
  3977. $composer->getRepositoryManager()->getRepositories()
  3978. );
  3979. }
  3980. return RepositoryFactory::defaultRepos($this->getIO());
  3981. }
  3982. }
  3983. <?php
  3984. namespace Composer\Command;
  3985. use Composer\Factory;
  3986. use Composer\Json\JsonFile;
  3987. use Composer\Package\BasePackage;
  3988. use Composer\Package\Package;
  3989. use Composer\Package\Version\VersionParser;
  3990. use Composer\Package\Version\VersionSelector;
  3991. use Composer\Repository\CompositeRepository;
  3992. use Composer\Repository\PlatformRepository;
  3993. use Composer\Repository\RepositoryFactory;
  3994. use Composer\Repository\RepositorySet;
  3995. use Composer\Util\ProcessExecutor;
  3996. use Symfony\Component\Console\Input\ArrayInput;
  3997. use Symfony\Component\Console\Input\InputInterface;
  3998. use Symfony\Component\Console\Input\InputOption;
  3999. use Symfony\Component\Console\Output\OutputInterface;
  4000. use Symfony\Component\Process\ExecutableFinder;
  4001. use Symfony\Component\Process\Process;
  4002. class InitCommand extends BaseCommand
  4003. {
  4004. protected $repos;
  4005. private $gitConfig;
  4006. private $repositorySets;
  4007. protected function configure()
  4008. {
  4009. $this
  4010. ->setName('init')
  4011. ->setDescription('Creates a basic composer.json file in current directory.')
  4012. ->setDefinition(array(
  4013. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  4014. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  4015. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  4016. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  4017. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  4018. new InputOption('require', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Package to require with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"'),
  4019. new InputOption('require-dev', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Package to require for development with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"'),
  4020. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  4021. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  4022. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  4023. ))
  4024. ->setHelp(
  4025. <<<EOT
  4026. The <info>init</info> command creates a basic composer.json file
  4027. in the current directory.
  4028. <info>php composer.phar init</info>
  4029. Read more at https://getcomposer.org/doc/03-cli.md#init
  4030. EOT
  4031. )
  4032. ;
  4033. }
  4034. protected function execute(InputInterface $input, OutputInterface $output)
  4035. {
  4036. $io = $this->getIO();
  4037. $allowlist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license');
  4038. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  4039. if (isset($options['author'])) {
  4040. $options['authors'] = $this->formatAuthors($options['author']);
  4041. unset($options['author']);
  4042. }
  4043. $repositories = $input->getOption('repository');
  4044. if ($repositories) {
  4045. $config = Factory::createConfig($io);
  4046. foreach ($repositories as $repo) {
  4047. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  4048. }
  4049. }
  4050. if (isset($options['stability'])) {
  4051. $options['minimum-stability'] = $options['stability'];
  4052. unset($options['stability']);
  4053. }
  4054. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  4055. if (array() === $options['require']) {
  4056. $options['require'] = new \stdClass;
  4057. }
  4058. if (isset($options['require-dev'])) {
  4059. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  4060. if (array() === $options['require-dev']) {
  4061. $options['require-dev'] = new \stdClass;
  4062. }
  4063. }
  4064. $file = new JsonFile(Factory::getComposerFile());
  4065. $json = JsonFile::encode($options);
  4066. if ($input->isInteractive()) {
  4067. $io->writeError(array('', $json, ''));
  4068. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  4069. $io->writeError('<error>Command aborted</error>');
  4070. return 1;
  4071. }
  4072. } else {
  4073. if (json_encode($options) === '{"require":{}}') {
  4074. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  4075. }
  4076. $io->writeError('Writing composer.json');
  4077. }
  4078. $file->write($options);
  4079. if ($input->isInteractive() && is_dir('.git')) {
  4080. $ignoreFile = realpath('.gitignore');
  4081. if (false === $ignoreFile) {
  4082. $ignoreFile = realpath('.') . '/.gitignore';
  4083. }
  4084. if (!$this->hasVendorIgnore($ignoreFile)) {
  4085. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  4086. if ($io->askConfirmation($question)) {
  4087. $this->addVendorIgnore($ignoreFile);
  4088. }
  4089. }
  4090. }
  4091. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  4092. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  4093. $this->installDependencies($output);
  4094. }
  4095. return 0;
  4096. }
  4097. protected function interact(InputInterface $input, OutputInterface $output)
  4098. {
  4099. $git = $this->getGitConfig();
  4100. $io = $this->getIO();
  4101. $formatter = $this->getHelperSet()->get('formatter');
  4102. $repositories = $input->getOption('repository');
  4103. if ($repositories) {
  4104. $config = Factory::createConfig($io);
  4105. $repos = array(new PlatformRepository);
  4106. $createDefaultPackagistRepo = true;
  4107. foreach ($repositories as $repo) {
  4108. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4109. if (
  4110. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  4111. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  4112. ) {
  4113. $createDefaultPackagistRepo = false;
  4114. continue;
  4115. }
  4116. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig);
  4117. }
  4118. if ($createDefaultPackagistRepo) {
  4119. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  4120. 'type' => 'composer',
  4121. 'url' => 'https://repo.packagist.org',
  4122. ));
  4123. }
  4124. $this->repos = new CompositeRepository($repos);
  4125. unset($repos, $config, $repositories);
  4126. }
  4127. $io->writeError(array(
  4128. '',
  4129. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  4130. '',
  4131. ));
  4132. $io->writeError(array(
  4133. '',
  4134. 'This command will guide you through creating your composer.json config.',
  4135. '',
  4136. ));
  4137. $cwd = realpath(".");
  4138. if (!$name = $input->getOption('name')) {
  4139. $name = basename($cwd);
  4140. $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  4141. $name = strtolower($name);
  4142. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  4143. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  4144. } elseif (isset($git['github.user'])) {
  4145. $name = $git['github.user'] . '/' . $name;
  4146. } elseif (!empty($_SERVER['USERNAME'])) {
  4147. $name = $_SERVER['USERNAME'] . '/' . $name;
  4148. } elseif (!empty($_SERVER['USER'])) {
  4149. $name = $_SERVER['USER'] . '/' . $name;
  4150. } elseif (get_current_user()) {
  4151. $name = get_current_user() . '/' . $name;
  4152. } else {
  4153. $name .= '/' . $name;
  4154. }
  4155. $name = strtolower($name);
  4156. } else {
  4157. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $name)) {
  4158. throw new \InvalidArgumentException(
  4159. 'The package name '.$name.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
  4160. );
  4161. }
  4162. }
  4163. $name = $io->askAndValidate(
  4164. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  4165. function ($value) use ($name) {
  4166. if (null === $value) {
  4167. return $name;
  4168. }
  4169. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  4170. throw new \InvalidArgumentException(
  4171. 'The package name '.$value.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
  4172. );
  4173. }
  4174. return $value;
  4175. },
  4176. null,
  4177. $name
  4178. );
  4179. $input->setOption('name', $name);
  4180. $description = $input->getOption('description') ?: false;
  4181. $description = $io->ask(
  4182. 'Description [<comment>'.$description.'</comment>]: ',
  4183. $description
  4184. );
  4185. $input->setOption('description', $description);
  4186. if (null === $author = $input->getOption('author')) {
  4187. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  4188. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  4189. } elseif (isset($git['user.name'])) {
  4190. $author_name = $git['user.name'];
  4191. }
  4192. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  4193. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  4194. } elseif (isset($git['user.email'])) {
  4195. $author_email = $git['user.email'];
  4196. }
  4197. if (isset($author_name, $author_email)) {
  4198. $author = sprintf('%s <%s>', $author_name, $author_email);
  4199. }
  4200. }
  4201. $self = $this;
  4202. $author = $io->askAndValidate(
  4203. 'Author [<comment>'.$author.'</comment>, n to skip]: ',
  4204. function ($value) use ($self, $author) {
  4205. if ($value === 'n' || $value === 'no') {
  4206. return;
  4207. }
  4208. $value = $value ?: $author;
  4209. $author = $self->parseAuthorString($value);
  4210. return sprintf('%s <%s>', $author['name'], $author['email']);
  4211. },
  4212. null,
  4213. $author
  4214. );
  4215. $input->setOption('author', $author);
  4216. $minimumStability = $input->getOption('stability') ?: null;
  4217. $minimumStability = $io->askAndValidate(
  4218. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  4219. function ($value) use ($minimumStability) {
  4220. if (null === $value) {
  4221. return $minimumStability;
  4222. }
  4223. if (!isset(BasePackage::$stabilities[$value])) {
  4224. throw new \InvalidArgumentException(
  4225. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  4226. implode(', ', array_keys(BasePackage::$stabilities))
  4227. );
  4228. }
  4229. return $value;
  4230. },
  4231. null,
  4232. $minimumStability
  4233. );
  4234. $input->setOption('stability', $minimumStability);
  4235. $type = $input->getOption('type') ?: false;
  4236. $type = $io->ask(
  4237. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  4238. $type
  4239. );
  4240. $input->setOption('type', $type);
  4241. if (null === $license = $input->getOption('license')) {
  4242. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  4243. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  4244. }
  4245. }
  4246. $license = $io->ask(
  4247. 'License [<comment>'.$license.'</comment>]: ',
  4248. $license
  4249. );
  4250. $input->setOption('license', $license);
  4251. $io->writeError(array('', 'Define your dependencies.', ''));
  4252. $repos = $this->getRepos();
  4253. $preferredStability = $minimumStability ?: 'stable';
  4254. $platformRepo = null;
  4255. if ($repos instanceof CompositeRepository) {
  4256. foreach ($repos->getRepositories() as $candidateRepo) {
  4257. if ($candidateRepo instanceof PlatformRepository) {
  4258. $platformRepo = $candidateRepo;
  4259. break;
  4260. }
  4261. }
  4262. }
  4263. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  4264. $require = $input->getOption('require');
  4265. $requirements = array();
  4266. if ($require || $io->askConfirmation($question)) {
  4267. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  4268. }
  4269. $input->setOption('require', $requirements);
  4270. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  4271. $requireDev = $input->getOption('require-dev');
  4272. $devRequirements = array();
  4273. if ($requireDev || $io->askConfirmation($question)) {
  4274. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  4275. }
  4276. $input->setOption('require-dev', $devRequirements);
  4277. }
  4278. public function parseAuthorString($author)
  4279. {
  4280. if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
  4281. if ($this->isValidEmail($match['email'])) {
  4282. return array(
  4283. 'name' => trim($match['name']),
  4284. 'email' => $match['email'],
  4285. );
  4286. }
  4287. }
  4288. throw new \InvalidArgumentException(
  4289. 'Invalid author string. Must be in the format: '.
  4290. 'John Smith <john@example.com>'
  4291. );
  4292. }
  4293. protected function findPackages($name)
  4294. {
  4295. return $this->getRepos()->search($name);
  4296. }
  4297. protected function getRepos()
  4298. {
  4299. if (!$this->repos) {
  4300. $this->repos = new CompositeRepository(array_merge(
  4301. array(new PlatformRepository),
  4302. RepositoryFactory::defaultRepos($this->getIO())
  4303. ));
  4304. }
  4305. return $this->repos;
  4306. }
  4307. final protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), PlatformRepository $platformRepo = null, $preferredStability = 'stable', $checkProvidedVersions = true, $fixed = false)
  4308. {
  4309. if ($requires) {
  4310. $requires = $this->normalizeRequirements($requires);
  4311. $result = array();
  4312. $io = $this->getIO();
  4313. foreach ($requires as $requirement) {
  4314. if (!isset($requirement['version'])) {
  4315. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);
  4316. $requirement['version'] = $version;
  4317. $requirement['name'] = $name;
  4318. $io->writeError(sprintf(
  4319. 'Using version <info>%s</info> for <info>%s</info>',
  4320. $requirement['version'],
  4321. $requirement['name']
  4322. ));
  4323. } else {
  4324. list($name) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed);
  4325. $requirement['name'] = $name;
  4326. }
  4327. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  4328. }
  4329. return $result;
  4330. }
  4331. $versionParser = new VersionParser();
  4332. $composer = $this->getComposer(false);
  4333. $installedRepo = $composer ? $composer->getRepositoryManager()->getLocalRepository() : null;
  4334. $existingPackages = array();
  4335. if ($installedRepo) {
  4336. foreach ($installedRepo->getPackages() as $package) {
  4337. $existingPackages[] = $package->getName();
  4338. }
  4339. }
  4340. unset($composer, $installedRepo);
  4341. $io = $this->getIO();
  4342. while (null !== $package = $io->ask('Search for a package: ')) {
  4343. $matches = $this->findPackages($package);
  4344. if (count($matches)) {
  4345. foreach ($matches as $position => $foundPackage) {
  4346. if (in_array($foundPackage['name'], $existingPackages, true)) {
  4347. unset($matches[$position]);
  4348. }
  4349. }
  4350. $matches = array_values($matches);
  4351. $exactMatch = null;
  4352. $choices = array();
  4353. foreach ($matches as $position => $foundPackage) {
  4354. $abandoned = '';
  4355. if (isset($foundPackage['abandoned'])) {
  4356. if (is_string($foundPackage['abandoned'])) {
  4357. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  4358. } else {
  4359. $replacement = 'No replacement was suggested';
  4360. }
  4361. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  4362. }
  4363. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  4364. if ($foundPackage['name'] === $package) {
  4365. $exactMatch = true;
  4366. break;
  4367. }
  4368. }
  4369. if (!$exactMatch) {
  4370. $io->writeError(array(
  4371. '',
  4372. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  4373. '',
  4374. ));
  4375. $io->writeError($choices);
  4376. $io->writeError('');
  4377. $validator = function ($selection) use ($matches, $versionParser) {
  4378. if ('' === $selection) {
  4379. return false;
  4380. }
  4381. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  4382. $package = $matches[(int) $selection];
  4383. return $package['name'];
  4384. }
  4385. if (preg_match('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  4386. if (isset($packageMatches['version'])) {
  4387. $versionParser->parseConstraints($packageMatches['version']);
  4388. return $packageMatches['name'].' '.$packageMatches['version'];
  4389. }
  4390. return $packageMatches['name'];
  4391. }
  4392. throw new \Exception('Not a valid selection');
  4393. };
  4394. $package = $io->askAndValidate(
  4395. 'Enter package # to add, or the complete package name if it is not listed: ',
  4396. $validator,
  4397. 3,
  4398. false
  4399. );
  4400. }
  4401. if (false !== $package && false === strpos($package, ' ')) {
  4402. $validator = function ($input) {
  4403. $input = trim($input);
  4404. return $input ?: false;
  4405. };
  4406. $constraint = $io->askAndValidate(
  4407. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  4408. $validator,
  4409. 3,
  4410. false
  4411. );
  4412. if (false === $constraint) {
  4413. list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
  4414. $io->writeError(sprintf(
  4415. 'Using version <info>%s</info> for <info>%s</info>',
  4416. $constraint,
  4417. $package
  4418. ));
  4419. }
  4420. $package .= ' '.$constraint;
  4421. }
  4422. if (false !== $package) {
  4423. $requires[] = $package;
  4424. $existingPackages[] = substr($package, 0, strpos($package, ' '));
  4425. }
  4426. }
  4427. }
  4428. return $requires;
  4429. }
  4430. protected function formatAuthors($author)
  4431. {
  4432. return array($this->parseAuthorString($author));
  4433. }
  4434. protected function getGitConfig()
  4435. {
  4436. if (null !== $this->gitConfig) {
  4437. return $this->gitConfig;
  4438. }
  4439. $finder = new ExecutableFinder();
  4440. $gitBin = $finder->find('git');
  4441. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  4442. $cmd = new Process(array($gitBin, 'config', '-l'));
  4443. } else {
  4444. $cmd = new Process(sprintf('%s config -l', ProcessExecutor::escape($gitBin)));
  4445. }
  4446. $cmd->run();
  4447. if ($cmd->isSuccessful()) {
  4448. $this->gitConfig = array();
  4449. preg_match_all('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches, PREG_SET_ORDER);
  4450. foreach ($matches as $match) {
  4451. $this->gitConfig[$match[1]] = $match[2];
  4452. }
  4453. return $this->gitConfig;
  4454. }
  4455. return $this->gitConfig = array();
  4456. }
  4457. protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
  4458. {
  4459. if (!file_exists($ignoreFile)) {
  4460. return false;
  4461. }
  4462. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  4463. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  4464. foreach ($lines as $line) {
  4465. if (preg_match($pattern, $line)) {
  4466. return true;
  4467. }
  4468. }
  4469. return false;
  4470. }
  4471. protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
  4472. {
  4473. $contents = "";
  4474. if (file_exists($ignoreFile)) {
  4475. $contents = file_get_contents($ignoreFile);
  4476. if (strpos($contents, "\n") !== 0) {
  4477. $contents .= "\n";
  4478. }
  4479. }
  4480. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  4481. }
  4482. protected function isValidEmail($email)
  4483. {
  4484. if (!function_exists('filter_var')) {
  4485. return true;
  4486. }
  4487. if (PHP_VERSION_ID < 50303) {
  4488. return true;
  4489. }
  4490. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  4491. }
  4492. private function getRepositorySet(InputInterface $input, $minimumStability = null)
  4493. {
  4494. $key = $minimumStability ?: 'default';
  4495. if (!isset($this->repositorySets[$key])) {
  4496. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?: $this->getMinimumStability($input));
  4497. $repositorySet->addRepository($this->getRepos());
  4498. }
  4499. return $this->repositorySets[$key];
  4500. }
  4501. private function getMinimumStability(InputInterface $input)
  4502. {
  4503. if ($input->hasOption('stability')) {
  4504. return VersionParser::normalizeStability($input->getOption('stability') ?: 'stable');
  4505. }
  4506. $file = Factory::getComposerFile();
  4507. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  4508. if (!empty($composer['minimum-stability'])) {
  4509. return VersionParser::normalizeStability($composer['minimum-stability']);
  4510. }
  4511. }
  4512. return 'stable';
  4513. }
  4514. private function findBestVersionAndNameForPackage(InputInterface $input, $name, PlatformRepository $platformRepo = null, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null, $fixed = null)
  4515. {
  4516. $ignorePlatformReqs = false;
  4517. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  4518. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4519. }
  4520. $versionSelector = new VersionSelector($this->getRepositorySet($input, $minimumStability), $platformRepo);
  4521. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs);
  4522. if (!$package) {
  4523. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($name, $ignorePlatformReqs))) && PlatformRepository::isPlatformPackage($name)) {
  4524. return array($name, $requiredVersion ?: '*');
  4525. }
  4526. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, true)) {
  4527. throw new \InvalidArgumentException(sprintf(
  4528. 'Package %s%s has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version',
  4529. $name,
  4530. $requiredVersion ? ' at version '.$requiredVersion : ''
  4531. ));
  4532. }
  4533. if ($package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  4534. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4535. throw new \InvalidArgumentException(
  4536. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages with higher priority do not match your minimum-stability and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.'
  4537. );
  4538. }
  4539. throw new \InvalidArgumentException(sprintf(
  4540. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  4541. $name,
  4542. $this->getMinimumStability($input)
  4543. ));
  4544. }
  4545. if ($requiredVersion && $package = $versionSelector->findBestCandidate($name, null, $preferredStability, $ignorePlatformReqs)) {
  4546. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, false, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4547. throw new \InvalidArgumentException(
  4548. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.'
  4549. );
  4550. }
  4551. throw new \InvalidArgumentException(sprintf(
  4552. 'Could not find package %s in a version matching %s',
  4553. $name,
  4554. $requiredVersion
  4555. ));
  4556. }
  4557. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, null, $preferredStability, true)) {
  4558. throw new \InvalidArgumentException(sprintf(
  4559. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version',
  4560. $name
  4561. ));
  4562. }
  4563. $similar = $this->findSimilar($name);
  4564. if ($similar) {
  4565. throw new \InvalidArgumentException(sprintf(
  4566. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  4567. $name,
  4568. implode("\n ", $similar)
  4569. ));
  4570. }
  4571. throw new \InvalidArgumentException(sprintf(
  4572. 'Could not find a matching version of package %s. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (%s).',
  4573. $name,
  4574. $this->getMinimumStability($input)
  4575. ));
  4576. }
  4577. return array(
  4578. $package->getPrettyName(),
  4579. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  4580. );
  4581. }
  4582. private function findSimilar($package)
  4583. {
  4584. try {
  4585. $results = $this->repos->search($package);
  4586. } catch (\Exception $e) {
  4587. return array();
  4588. }
  4589. $similarPackages = array();
  4590. $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
  4591. foreach ($results as $result) {
  4592. if ($installedRepo->findPackage($result['name'], '*')) {
  4593. continue;
  4594. }
  4595. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  4596. }
  4597. asort($similarPackages);
  4598. return array_keys(array_slice($similarPackages, 0, 5));
  4599. }
  4600. private function installDependencies($output)
  4601. {
  4602. try {
  4603. $installCommand = $this->getApplication()->find('install');
  4604. $installCommand->run(new ArrayInput(array()), $output);
  4605. } catch (\Exception $e) {
  4606. $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.');
  4607. }
  4608. }
  4609. private function hasDependencies($options)
  4610. {
  4611. $requires = (array) $options['require'];
  4612. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  4613. return !empty($requires) || !empty($devRequires);
  4614. }
  4615. }
  4616. <?php
  4617. namespace Composer\Command;
  4618. use Composer\Installer;
  4619. use Composer\Plugin\CommandEvent;
  4620. use Composer\Plugin\PluginEvents;
  4621. use Composer\Util\HttpDownloader;
  4622. use Symfony\Component\Console\Input\InputInterface;
  4623. use Symfony\Component\Console\Input\InputOption;
  4624. use Symfony\Component\Console\Input\InputArgument;
  4625. use Symfony\Component\Console\Output\OutputInterface;
  4626. class InstallCommand extends BaseCommand
  4627. {
  4628. protected function configure()
  4629. {
  4630. $this
  4631. ->setName('install')
  4632. ->setAliases(array('i'))
  4633. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  4634. ->setDefinition(array(
  4635. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4636. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  4637. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4638. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4639. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  4640. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4641. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  4642. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4643. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4644. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  4645. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  4646. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4647. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4648. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4649. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4650. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4651. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4652. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  4653. ))
  4654. ->setHelp(
  4655. <<<EOT
  4656. The <info>install</info> command reads the composer.lock file from
  4657. the current directory, processes it, and downloads and installs all the
  4658. libraries and dependencies outlined in that file. If the file does not
  4659. exist it will look for composer.json and do the same.
  4660. <info>php composer.phar install</info>
  4661. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  4662. EOT
  4663. )
  4664. ;
  4665. }
  4666. protected function execute(InputInterface $input, OutputInterface $output)
  4667. {
  4668. $io = $this->getIO();
  4669. if ($input->getOption('dev')) {
  4670. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  4671. }
  4672. if ($input->getOption('no-suggest')) {
  4673. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  4674. }
  4675. if ($args = $input->getArgument('packages')) {
  4676. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  4677. return 1;
  4678. }
  4679. if ($input->getOption('no-install')) {
  4680. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  4681. return 1;
  4682. }
  4683. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4684. if ((!$composer->getLocker() || !$composer->getLocker()->isLocked()) && !HttpDownloader::isCurlEnabled()) {
  4685. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  4686. }
  4687. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  4688. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4689. $install = Installer::create($io, $composer);
  4690. $config = $composer->getConfig();
  4691. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  4692. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  4693. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4694. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  4695. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  4696. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4697. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  4698. $install
  4699. ->setDryRun($input->getOption('dry-run'))
  4700. ->setVerbose($input->getOption('verbose'))
  4701. ->setPreferSource($preferSource)
  4702. ->setPreferDist($preferDist)
  4703. ->setDevMode(!$input->getOption('no-dev'))
  4704. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  4705. ->setRunScripts(!$input->getOption('no-scripts'))
  4706. ->setOptimizeAutoloader($optimize)
  4707. ->setClassMapAuthoritative($authoritative)
  4708. ->setApcuAutoloader($apcu, $apcuPrefix)
  4709. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  4710. ;
  4711. if ($input->getOption('no-plugins')) {
  4712. $install->disablePlugins();
  4713. }
  4714. return $install->run();
  4715. }
  4716. }
  4717. <?php
  4718. namespace Composer\Command;
  4719. use Composer\Json\JsonFile;
  4720. use Composer\Plugin\CommandEvent;
  4721. use Composer\Plugin\PluginEvents;
  4722. use Composer\Package\PackageInterface;
  4723. use Composer\Repository\RepositoryInterface;
  4724. use Symfony\Component\Console\Helper\Table;
  4725. use Symfony\Component\Console\Input\InputInterface;
  4726. use Symfony\Component\Console\Input\InputOption;
  4727. use Symfony\Component\Console\Output\OutputInterface;
  4728. use Symfony\Component\Console\Style\SymfonyStyle;
  4729. class LicensesCommand extends BaseCommand
  4730. {
  4731. protected function configure()
  4732. {
  4733. $this
  4734. ->setName('licenses')
  4735. ->setDescription('Shows information about licenses of dependencies.')
  4736. ->setDefinition(array(
  4737. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  4738. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4739. ))
  4740. ->setHelp(
  4741. <<<EOT
  4742. The license command displays detailed information about the licenses of
  4743. the installed dependencies.
  4744. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  4745. EOT
  4746. )
  4747. ;
  4748. }
  4749. protected function execute(InputInterface $input, OutputInterface $output)
  4750. {
  4751. $composer = $this->getComposer();
  4752. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  4753. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4754. $root = $composer->getPackage();
  4755. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4756. if ($input->getOption('no-dev')) {
  4757. $packages = $this->filterRequiredPackages($repo, $root);
  4758. } else {
  4759. $packages = $this->appendPackages($repo->getPackages(), array());
  4760. }
  4761. ksort($packages);
  4762. $io = $this->getIO();
  4763. switch ($format = $input->getOption('format')) {
  4764. case 'text':
  4765. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  4766. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  4767. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  4768. $io->write('Dependencies:');
  4769. $io->write('');
  4770. $table = new Table($output);
  4771. $table->setStyle('compact');
  4772. $tableStyle = $table->getStyle();
  4773. if (method_exists($tableStyle, 'setVerticalBorderChars')) {
  4774. $tableStyle->setVerticalBorderChars('');
  4775. } else {
  4776. $tableStyle->setVerticalBorderChar('');
  4777. }
  4778. $tableStyle->setCellRowContentFormat('%s ');
  4779. $table->setHeaders(array('Name', 'Version', 'License'));
  4780. foreach ($packages as $package) {
  4781. $table->addRow(array(
  4782. $package->getPrettyName(),
  4783. $package->getFullPrettyVersion(),
  4784. implode(', ', $package->getLicense()) ?: 'none',
  4785. ));
  4786. }
  4787. $table->render();
  4788. break;
  4789. case 'json':
  4790. $dependencies = array();
  4791. foreach ($packages as $package) {
  4792. $dependencies[$package->getPrettyName()] = array(
  4793. 'version' => $package->getFullPrettyVersion(),
  4794. 'license' => $package->getLicense(),
  4795. );
  4796. }
  4797. $io->write(JsonFile::encode(array(
  4798. 'name' => $root->getPrettyName(),
  4799. 'version' => $root->getFullPrettyVersion(),
  4800. 'license' => $root->getLicense(),
  4801. 'dependencies' => $dependencies,
  4802. )));
  4803. break;
  4804. case 'summary':
  4805. $usedLicenses = array();
  4806. foreach ($packages as $package) {
  4807. $license = $package->getLicense();
  4808. $licenseName = $license[0];
  4809. if (!isset($usedLicenses[$licenseName])) {
  4810. $usedLicenses[$licenseName] = 0;
  4811. }
  4812. $usedLicenses[$licenseName]++;
  4813. }
  4814. arsort($usedLicenses, SORT_NUMERIC);
  4815. $rows = array();
  4816. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  4817. $rows[] = array($usedLicense, $numberOfDependencies);
  4818. }
  4819. $symfonyIo = new SymfonyStyle($input, $output);
  4820. $symfonyIo->table(
  4821. array('License', 'Number of dependencies'),
  4822. $rows
  4823. );
  4824. break;
  4825. default:
  4826. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4827. }
  4828. return 0;
  4829. }
  4830. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  4831. {
  4832. $requires = array_keys($package->getRequires());
  4833. $packageListNames = array_keys($bucket);
  4834. $packages = array_filter(
  4835. $repo->getPackages(),
  4836. function ($package) use ($requires, $packageListNames) {
  4837. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  4838. }
  4839. );
  4840. $bucket = $this->appendPackages($packages, $bucket);
  4841. foreach ($packages as $package) {
  4842. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  4843. }
  4844. return $bucket;
  4845. }
  4846. public function appendPackages(array $packages, array $bucket)
  4847. {
  4848. foreach ($packages as $package) {
  4849. $bucket[$package->getName()] = $package;
  4850. }
  4851. return $bucket;
  4852. }
  4853. }
  4854. <?php
  4855. namespace Composer\Command;
  4856. use Symfony\Component\Console\Input\InputInterface;
  4857. use Symfony\Component\Console\Input\InputArgument;
  4858. use Symfony\Component\Console\Input\ArrayInput;
  4859. use Symfony\Component\Console\Input\InputOption;
  4860. use Symfony\Component\Console\Output\OutputInterface;
  4861. class OutdatedCommand extends ShowCommand
  4862. {
  4863. protected function configure()
  4864. {
  4865. $this
  4866. ->setName('outdated')
  4867. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  4868. ->setDefinition(array(
  4869. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  4870. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  4871. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  4872. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  4873. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  4874. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  4875. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  4876. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4877. new InputOption('ignore', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore specified package(s). Use it with the --outdated option if you don\'t want to be informed about new versions of some packages.'),
  4878. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4879. ))
  4880. ->setHelp(
  4881. <<<EOT
  4882. The outdated command is just a proxy for `composer show -l`
  4883. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  4884. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  4885. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  4886. compatibility breaks according to semver, so upgrade when you can but it
  4887. may involve work.
  4888. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  4889. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  4890. EOT
  4891. )
  4892. ;
  4893. }
  4894. protected function execute(InputInterface $input, OutputInterface $output)
  4895. {
  4896. $args = array(
  4897. 'command' => 'show',
  4898. '--latest' => true,
  4899. );
  4900. if (!$input->getOption('all')) {
  4901. $args['--outdated'] = true;
  4902. }
  4903. if ($input->getOption('direct')) {
  4904. $args['--direct'] = true;
  4905. }
  4906. if ($input->getArgument('package')) {
  4907. $args['package'] = $input->getArgument('package');
  4908. }
  4909. if ($input->getOption('strict')) {
  4910. $args['--strict'] = true;
  4911. }
  4912. if ($input->getOption('minor-only')) {
  4913. $args['--minor-only'] = true;
  4914. }
  4915. if ($input->getOption('locked')) {
  4916. $args['--locked'] = true;
  4917. }
  4918. if ($input->getOption('no-dev')) {
  4919. $args['--no-dev'] = true;
  4920. }
  4921. $args['--format'] = $input->getOption('format');
  4922. $args['--ignore'] = $input->getOption('ignore');
  4923. $input = new ArrayInput($args);
  4924. return $this->getApplication()->run($input, $output);
  4925. }
  4926. public function isProxyCommand()
  4927. {
  4928. return true;
  4929. }
  4930. }
  4931. <?php
  4932. namespace Composer\Command;
  4933. use Symfony\Component\Console\Input\InputInterface;
  4934. use Symfony\Component\Console\Output\OutputInterface;
  4935. class ProhibitsCommand extends BaseDependencyCommand
  4936. {
  4937. protected function configure()
  4938. {
  4939. parent::configure();
  4940. $this
  4941. ->setName('prohibits')
  4942. ->setAliases(array('why-not'))
  4943. ->setDescription('Shows which packages prevent the given package from being installed.')
  4944. ->setHelp(
  4945. <<<EOT
  4946. Displays detailed information about why a package cannot be installed.
  4947. <info>php composer.phar prohibits composer/composer</info>
  4948. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  4949. EOT
  4950. )
  4951. ;
  4952. }
  4953. protected function execute(InputInterface $input, OutputInterface $output)
  4954. {
  4955. return parent::doExecute($input, $output, true);
  4956. }
  4957. }
  4958. <?php
  4959. namespace Composer\Command;
  4960. use Composer\Config\JsonConfigSource;
  4961. use Composer\DependencyResolver\Request;
  4962. use Composer\Installer;
  4963. use Composer\Plugin\CommandEvent;
  4964. use Composer\Plugin\PluginEvents;
  4965. use Composer\Json\JsonFile;
  4966. use Composer\Factory;
  4967. use Symfony\Component\Console\Input\InputInterface;
  4968. use Symfony\Component\Console\Input\InputOption;
  4969. use Symfony\Component\Console\Input\InputArgument;
  4970. use Symfony\Component\Console\Output\OutputInterface;
  4971. use Composer\Package\BasePackage;
  4972. class RemoveCommand extends BaseCommand
  4973. {
  4974. protected function configure()
  4975. {
  4976. $this
  4977. ->setName('remove')
  4978. ->setDescription('Removes a package from the require or require-dev.')
  4979. ->setDefinition(array(
  4980. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  4981. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  4982. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4983. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4984. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  4985. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  4986. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4987. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  4988. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  4989. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  4990. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  4991. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  4992. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  4993. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4994. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4995. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4996. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4997. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4998. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4999. ))
  5000. ->setHelp(
  5001. <<<EOT
  5002. The <info>remove</info> command removes a package from the current
  5003. list of installed packages
  5004. <info>php composer.phar remove</info>
  5005. Read more at https://getcomposer.org/doc/03-cli.md#remove
  5006. EOT
  5007. )
  5008. ;
  5009. }
  5010. protected function interact(InputInterface $input, OutputInterface $output)
  5011. {
  5012. if ($input->getOption('unused')) {
  5013. $composer = $this->getComposer();
  5014. $locker = $composer->getLocker();
  5015. if (!$locker->isLocked()) {
  5016. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  5017. }
  5018. $lockedPackages = $locker->getLockedRepository()->getPackages();
  5019. $required = array();
  5020. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  5021. $required[$link->getTarget()] = true;
  5022. }
  5023. do {
  5024. $found = false;
  5025. foreach ($lockedPackages as $index => $package) {
  5026. foreach ($package->getNames() as $name) {
  5027. if (isset($required[$name])) {
  5028. foreach ($package->getRequires() as $link) {
  5029. $required[$link->getTarget()] = true;
  5030. }
  5031. $found = true;
  5032. unset($lockedPackages[$index]);
  5033. break;
  5034. }
  5035. }
  5036. }
  5037. } while ($found);
  5038. $unused = array();
  5039. foreach ($lockedPackages as $package) {
  5040. $unused[] = $package->getName();
  5041. }
  5042. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  5043. if (!$input->getArgument('packages')) {
  5044. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  5045. $this->setCode(function () {
  5046. return 0;
  5047. });
  5048. }
  5049. }
  5050. }
  5051. protected function execute(InputInterface $input, OutputInterface $output)
  5052. {
  5053. $packages = $input->getArgument('packages');
  5054. $packages = array_map('strtolower', $packages);
  5055. $file = Factory::getComposerFile();
  5056. $jsonFile = new JsonFile($file);
  5057. $composer = $jsonFile->read();
  5058. $composerBackup = file_get_contents($jsonFile->getPath());
  5059. $json = new JsonConfigSource($jsonFile);
  5060. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5061. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5062. $io = $this->getIO();
  5063. if ($input->getOption('update-with-dependencies')) {
  5064. $io->writeError('<warning>You are using the deprecated option "update-with-dependencies". This is now default behaviour. The --no-update-with-dependencies option can be used to remove a package without its dependencies.</warning>');
  5065. }
  5066. foreach (array('require', 'require-dev') as $linkType) {
  5067. if (isset($composer[$linkType])) {
  5068. foreach ($composer[$linkType] as $name => $version) {
  5069. $composer[$linkType][strtolower($name)] = $name;
  5070. }
  5071. }
  5072. }
  5073. $dryRun = $input->getOption('dry-run');
  5074. $toRemove = array();
  5075. foreach ($packages as $package) {
  5076. if (isset($composer[$type][$package])) {
  5077. if ($dryRun) {
  5078. $toRemove[$type][] = $composer[$type][$package];
  5079. } else {
  5080. $json->removeLink($type, $composer[$type][$package]);
  5081. }
  5082. } elseif (isset($composer[$altType][$package])) {
  5083. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5084. if ($io->isInteractive()) {
  5085. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5086. if ($dryRun) {
  5087. $toRemove[$altType][] = $composer[$altType][$package];
  5088. } else {
  5089. $json->removeLink($altType, $composer[$altType][$package]);
  5090. }
  5091. }
  5092. }
  5093. } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  5094. foreach ($matches as $matchedPackage) {
  5095. if ($dryRun) {
  5096. $toRemove[$type][] = $matchedPackage;
  5097. } else {
  5098. $json->removeLink($type, $matchedPackage);
  5099. }
  5100. }
  5101. } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  5102. foreach ($matches as $matchedPackage) {
  5103. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5104. if ($io->isInteractive()) {
  5105. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5106. if ($dryRun) {
  5107. $toRemove[$altType][] = $matchedPackage;
  5108. } else {
  5109. $json->removeLink($altType, $matchedPackage);
  5110. }
  5111. }
  5112. }
  5113. }
  5114. } else {
  5115. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5116. }
  5117. }
  5118. $io->writeError('<info>'.$file.' has been updated</info>');
  5119. if ($input->getOption('no-update')) {
  5120. return 0;
  5121. }
  5122. $this->resetComposer();
  5123. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5124. if ($dryRun) {
  5125. $rootPackage = $composer->getPackage();
  5126. $links = array(
  5127. 'require' => $rootPackage->getRequires(),
  5128. 'require-dev' => $rootPackage->getDevRequires(),
  5129. );
  5130. foreach ($toRemove as $type => $names) {
  5131. foreach ($names as $name) {
  5132. unset($links[$type][$name]);
  5133. }
  5134. }
  5135. $rootPackage->setRequires($links['require']);
  5136. $rootPackage->setDevRequires($links['require-dev']);
  5137. }
  5138. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5139. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5140. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5141. $install = Installer::create($io, $composer);
  5142. $updateDevMode = !$input->getOption('update-no-dev');
  5143. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5144. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5145. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5146. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5147. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5148. $flags = '';
  5149. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5150. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5151. $flags .= ' --with-all-dependencies';
  5152. } elseif ($input->getOption('no-update-with-dependencies')) {
  5153. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5154. $flags .= ' --with-dependencies';
  5155. }
  5156. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5157. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5158. $install
  5159. ->setVerbose($input->getOption('verbose'))
  5160. ->setDevMode($updateDevMode)
  5161. ->setOptimizeAutoloader($optimize)
  5162. ->setClassMapAuthoritative($authoritative)
  5163. ->setApcuAutoloader($apcu, $apcuPrefix)
  5164. ->setUpdate(true)
  5165. ->setInstall(!$input->getOption('no-install'))
  5166. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5167. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5168. ->setRunScripts(!$input->getOption('no-scripts'))
  5169. ->setDryRun($dryRun)
  5170. ;
  5171. if ($composer->getLocker()->isLocked()) {
  5172. $install->setUpdateAllowList($packages);
  5173. }
  5174. $status = $install->run();
  5175. if ($status !== 0) {
  5176. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5177. file_put_contents($jsonFile->getPath(), $composerBackup);
  5178. }
  5179. if (!$dryRun) {
  5180. foreach ($packages as $package) {
  5181. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5182. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5183. return 2;
  5184. }
  5185. }
  5186. }
  5187. return $status;
  5188. }
  5189. }
  5190. <?php
  5191. namespace Composer\Command;
  5192. use Composer\DependencyResolver\Request;
  5193. use Symfony\Component\Console\Input\InputInterface;
  5194. use Symfony\Component\Console\Input\InputArgument;
  5195. use Symfony\Component\Console\Input\InputOption;
  5196. use Symfony\Component\Console\Output\OutputInterface;
  5197. use Composer\Factory;
  5198. use Composer\Installer;
  5199. use Composer\Json\JsonFile;
  5200. use Composer\Json\JsonManipulator;
  5201. use Composer\Package\Version\VersionParser;
  5202. use Composer\Package\Loader\ArrayLoader;
  5203. use Composer\Package\BasePackage;
  5204. use Composer\Plugin\CommandEvent;
  5205. use Composer\Plugin\PluginEvents;
  5206. use Composer\Repository\CompositeRepository;
  5207. use Composer\Repository\PlatformRepository;
  5208. use Composer\IO\IOInterface;
  5209. use Composer\Util\Silencer;
  5210. class RequireCommand extends InitCommand
  5211. {
  5212. private $newlyCreated;
  5213. private $firstRequire;
  5214. private $json;
  5215. private $file;
  5216. private $composerBackup;
  5217. private $lock;
  5218. private $lockBackup;
  5219. protected function configure()
  5220. {
  5221. $this
  5222. ->setName('require')
  5223. ->setDescription('Adds required packages to your composer.json and installs them.')
  5224. ->setDefinition(array(
  5225. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Optional package name can also include a version constraint, e.g. foo/bar or foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"'),
  5226. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5227. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5228. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5229. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  5230. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5231. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5232. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5233. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5234. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5235. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5236. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5237. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5238. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5239. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5240. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5241. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5242. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5243. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5244. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5245. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5246. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5247. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5248. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5249. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5250. ))
  5251. ->setHelp(
  5252. <<<EOT
  5253. The require command adds required packages to your composer.json and installs them.
  5254. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5255. matches to require.
  5256. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5257. If you do not want to install the new dependencies immediately you can call it with --no-update
  5258. Read more at https://getcomposer.org/doc/03-cli.md#require
  5259. EOT
  5260. )
  5261. ;
  5262. }
  5263. protected function execute(InputInterface $input, OutputInterface $output)
  5264. {
  5265. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  5266. pcntl_async_signals(true);
  5267. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  5268. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  5269. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  5270. }
  5271. $this->file = Factory::getComposerFile();
  5272. $io = $this->getIO();
  5273. if ($input->getOption('no-suggest')) {
  5274. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5275. }
  5276. $this->newlyCreated = !file_exists($this->file);
  5277. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  5278. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  5279. return 1;
  5280. }
  5281. if (!is_readable($this->file) && false === Silencer::call('file_get_contents', $this->file)) {
  5282. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  5283. return 1;
  5284. }
  5285. if (filesize($this->file) === 0) {
  5286. file_put_contents($this->file, "{\n}\n");
  5287. }
  5288. $this->json = new JsonFile($this->file);
  5289. $this->lock = Factory::getLockFile($this->file);
  5290. $this->composerBackup = file_get_contents($this->json->getPath());
  5291. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  5292. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  5293. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  5294. return 1;
  5295. }
  5296. if ($input->getOption('fixed') === true) {
  5297. $config = $this->json->read();
  5298. $packageType = empty($config['type']) ? 'library' : $config['type'];
  5299. if ($packageType !== 'project') {
  5300. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  5301. if (empty($config['type'])) {
  5302. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  5303. }
  5304. return 1;
  5305. }
  5306. }
  5307. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5308. $repos = $composer->getRepositoryManager()->getRepositories();
  5309. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5310. $this->repos = new CompositeRepository(array_merge(
  5311. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  5312. $repos
  5313. ));
  5314. if ($composer->getPackage()->getPreferStable()) {
  5315. $preferredStability = 'stable';
  5316. } else {
  5317. $preferredStability = $composer->getPackage()->getMinimumStability();
  5318. }
  5319. try {
  5320. $requirements = $this->determineRequirements(
  5321. $input,
  5322. $output,
  5323. $input->getArgument('packages'),
  5324. $platformRepo,
  5325. $preferredStability,
  5326. !$input->getOption('no-update'),
  5327. $input->getOption('fixed')
  5328. );
  5329. } catch (\Exception $e) {
  5330. if ($this->newlyCreated) {
  5331. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  5332. }
  5333. throw $e;
  5334. }
  5335. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  5336. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  5337. $requirements = $this->formatRequirements($requirements);
  5338. $versionParser = new VersionParser();
  5339. foreach ($requirements as $package => $constraint) {
  5340. if (strtolower($package) === $composer->getPackage()->getName()) {
  5341. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  5342. return 1;
  5343. }
  5344. $versionParser->parseConstraints($constraint);
  5345. }
  5346. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  5347. $this->firstRequire = $this->newlyCreated;
  5348. if (!$this->firstRequire) {
  5349. $composerDefinition = $this->json->read();
  5350. if (empty($composerDefinition['require']) && empty($composerDefinition['require-dev'])) {
  5351. $this->firstRequire = true;
  5352. }
  5353. }
  5354. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  5355. $composerDefinition = $this->json->read();
  5356. foreach ($requirements as $package => $version) {
  5357. $composerDefinition[$requireKey][$package] = $version;
  5358. unset($composerDefinition[$removeKey][$package]);
  5359. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  5360. unset($composerDefinition[$removeKey]);
  5361. }
  5362. }
  5363. $this->json->write($composerDefinition);
  5364. }
  5365. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  5366. if ($input->getOption('no-update')) {
  5367. return 0;
  5368. }
  5369. try {
  5370. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  5371. } catch (\Exception $e) {
  5372. $this->revertComposerFile(false);
  5373. throw $e;
  5374. }
  5375. }
  5376. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
  5377. {
  5378. $this->resetComposer();
  5379. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5380. if ($input->getOption('dry-run')) {
  5381. $rootPackage = $composer->getPackage();
  5382. $links = array(
  5383. 'require' => $rootPackage->getRequires(),
  5384. 'require-dev' => $rootPackage->getDevRequires(),
  5385. );
  5386. $loader = new ArrayLoader();
  5387. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['description'], $requirements);
  5388. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  5389. foreach ($requirements as $package => $constraint) {
  5390. unset($links[$removeKey][$package]);
  5391. }
  5392. $rootPackage->setRequires($links['require']);
  5393. $rootPackage->setDevRequires($links['require-dev']);
  5394. }
  5395. $updateDevMode = !$input->getOption('update-no-dev');
  5396. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5397. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5398. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5399. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5400. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5401. $flags = '';
  5402. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5403. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5404. $flags .= ' --with-all-dependencies';
  5405. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  5406. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5407. $flags .= ' --with-dependencies';
  5408. }
  5409. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  5410. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  5411. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5412. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5413. $install = Installer::create($io, $composer);
  5414. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5415. $install
  5416. ->setDryRun($input->getOption('dry-run'))
  5417. ->setVerbose($input->getOption('verbose'))
  5418. ->setPreferSource($input->getOption('prefer-source'))
  5419. ->setPreferDist($input->getOption('prefer-dist'))
  5420. ->setDevMode($updateDevMode)
  5421. ->setRunScripts(!$input->getOption('no-scripts'))
  5422. ->setOptimizeAutoloader($optimize)
  5423. ->setClassMapAuthoritative($authoritative)
  5424. ->setApcuAutoloader($apcu, $apcuPrefix)
  5425. ->setUpdate(true)
  5426. ->setInstall(!$input->getOption('no-install'))
  5427. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5428. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5429. ->setPreferStable($input->getOption('prefer-stable'))
  5430. ->setPreferLowest($input->getOption('prefer-lowest'))
  5431. ;
  5432. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  5433. $install->setUpdateAllowList(array_keys($requirements));
  5434. }
  5435. $status = $install->run();
  5436. if ($status !== 0) {
  5437. $this->revertComposerFile(false);
  5438. }
  5439. return $status;
  5440. }
  5441. private function updateFileCleanly($json, array $new, $requireKey, $removeKey, $sortPackages)
  5442. {
  5443. $contents = file_get_contents($json->getPath());
  5444. $manipulator = new JsonManipulator($contents);
  5445. foreach ($new as $package => $constraint) {
  5446. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  5447. return false;
  5448. }
  5449. if (!$manipulator->removeSubNode($removeKey, $package)) {
  5450. return false;
  5451. }
  5452. }
  5453. $manipulator->removeMainKeyIfEmpty($removeKey);
  5454. file_put_contents($json->getPath(), $manipulator->getContents());
  5455. return true;
  5456. }
  5457. protected function interact(InputInterface $input, OutputInterface $output)
  5458. {
  5459. return;
  5460. }
  5461. public function revertComposerFile($hardExit = true)
  5462. {
  5463. $io = $this->getIO();
  5464. if ($this->newlyCreated) {
  5465. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  5466. unlink($this->json->getPath());
  5467. if (file_exists($this->lock)) {
  5468. unlink($this->lock);
  5469. }
  5470. } else {
  5471. $msg = ' to its ';
  5472. if ($this->lockBackup) {
  5473. $msg = ' and '.$this->lock.' to their ';
  5474. }
  5475. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  5476. file_put_contents($this->json->getPath(), $this->composerBackup);
  5477. if ($this->lockBackup) {
  5478. file_put_contents($this->lock, $this->lockBackup);
  5479. }
  5480. }
  5481. if ($hardExit) {
  5482. exit(1);
  5483. }
  5484. }
  5485. }
  5486. <?php
  5487. namespace Composer\Command;
  5488. use Composer\Script\Event as ScriptEvent;
  5489. use Composer\Script\ScriptEvents;
  5490. use Composer\Util\ProcessExecutor;
  5491. use Symfony\Component\Console\Input\InputInterface;
  5492. use Symfony\Component\Console\Input\InputOption;
  5493. use Symfony\Component\Console\Input\InputArgument;
  5494. use Symfony\Component\Console\Output\OutputInterface;
  5495. class RunScriptCommand extends BaseCommand
  5496. {
  5497. protected $scriptEvents = array(
  5498. ScriptEvents::PRE_INSTALL_CMD,
  5499. ScriptEvents::POST_INSTALL_CMD,
  5500. ScriptEvents::PRE_UPDATE_CMD,
  5501. ScriptEvents::POST_UPDATE_CMD,
  5502. ScriptEvents::PRE_STATUS_CMD,
  5503. ScriptEvents::POST_STATUS_CMD,
  5504. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  5505. ScriptEvents::POST_CREATE_PROJECT_CMD,
  5506. ScriptEvents::PRE_ARCHIVE_CMD,
  5507. ScriptEvents::POST_ARCHIVE_CMD,
  5508. ScriptEvents::PRE_AUTOLOAD_DUMP,
  5509. ScriptEvents::POST_AUTOLOAD_DUMP,
  5510. );
  5511. protected function configure()
  5512. {
  5513. $this
  5514. ->setName('run-script')
  5515. ->setAliases(array('run'))
  5516. ->setDescription('Runs the scripts defined in composer.json.')
  5517. ->setDefinition(array(
  5518. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  5519. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5520. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  5521. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5522. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5523. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  5524. ))
  5525. ->setHelp(
  5526. <<<EOT
  5527. The <info>run-script</info> command runs scripts defined in composer.json:
  5528. <info>php composer.phar run-script post-update-cmd</info>
  5529. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5530. EOT
  5531. )
  5532. ;
  5533. }
  5534. protected function execute(InputInterface $input, OutputInterface $output)
  5535. {
  5536. if ($input->getOption('list')) {
  5537. return $this->listScripts($output);
  5538. }
  5539. if (!$input->getArgument('script')) {
  5540. throw new \RuntimeException('Missing required argument "script"');
  5541. }
  5542. $script = $input->getArgument('script');
  5543. if (!in_array($script, $this->scriptEvents)) {
  5544. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  5545. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  5546. }
  5547. }
  5548. $composer = $this->getComposer();
  5549. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  5550. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  5551. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  5552. if (!$hasListeners) {
  5553. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  5554. }
  5555. $args = $input->getArgument('args');
  5556. if (null !== $timeout = $input->getOption('timeout')) {
  5557. if (!ctype_digit($timeout)) {
  5558. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  5559. }
  5560. ProcessExecutor::setTimeout((int) $timeout);
  5561. }
  5562. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  5563. }
  5564. protected function listScripts(OutputInterface $output)
  5565. {
  5566. $scripts = $this->getComposer()->getPackage()->getScripts();
  5567. if (!count($scripts)) {
  5568. return 0;
  5569. }
  5570. $io = $this->getIO();
  5571. $io->writeError('<info>scripts:</info>');
  5572. $table = array();
  5573. foreach ($scripts as $name => $script) {
  5574. $description = '';
  5575. try {
  5576. $cmd = $this->getApplication()->find($name);
  5577. if ($cmd instanceof ScriptAliasCommand) {
  5578. $description = $cmd->getDescription();
  5579. }
  5580. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  5581. }
  5582. $table[] = array(' '.$name, $description);
  5583. }
  5584. $this->renderTable($table, $output);
  5585. return 0;
  5586. }
  5587. }
  5588. <?php
  5589. namespace Composer\Command;
  5590. use Symfony\Component\Console\Input\InputInterface;
  5591. use Symfony\Component\Console\Input\InputOption;
  5592. use Symfony\Component\Console\Input\InputArgument;
  5593. use Symfony\Component\Console\Output\OutputInterface;
  5594. class ScriptAliasCommand extends BaseCommand
  5595. {
  5596. private $script;
  5597. private $description;
  5598. public function __construct($script, $description)
  5599. {
  5600. $this->script = $script;
  5601. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  5602. parent::__construct();
  5603. }
  5604. protected function configure()
  5605. {
  5606. $this
  5607. ->setName($this->script)
  5608. ->setDescription($this->description)
  5609. ->setDefinition(array(
  5610. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5611. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5612. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5613. ))
  5614. ->setHelp(
  5615. <<<EOT
  5616. The <info>run-script</info> command runs scripts defined in composer.json:
  5617. <info>php composer.phar run-script post-update-cmd</info>
  5618. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5619. EOT
  5620. )
  5621. ;
  5622. }
  5623. protected function execute(InputInterface $input, OutputInterface $output)
  5624. {
  5625. $composer = $this->getComposer();
  5626. $args = $input->getArguments();
  5627. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  5628. }
  5629. }
  5630. <?php
  5631. namespace Composer\Command;
  5632. use Composer\Factory;
  5633. use Symfony\Component\Console\Input\InputInterface;
  5634. use Symfony\Component\Console\Input\InputArgument;
  5635. use Symfony\Component\Console\Input\InputOption;
  5636. use Symfony\Component\Console\Output\OutputInterface;
  5637. use Composer\Repository\CompositeRepository;
  5638. use Composer\Repository\PlatformRepository;
  5639. use Composer\Repository\RepositoryInterface;
  5640. use Composer\Plugin\CommandEvent;
  5641. use Composer\Plugin\PluginEvents;
  5642. class SearchCommand extends BaseCommand
  5643. {
  5644. protected $matches;
  5645. protected $lowMatches = array();
  5646. protected $tokens;
  5647. protected $output;
  5648. protected $onlyName;
  5649. protected function configure()
  5650. {
  5651. $this
  5652. ->setName('search')
  5653. ->setDescription('Searches for packages.')
  5654. ->setDefinition(array(
  5655. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in name'),
  5656. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  5657. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  5658. ))
  5659. ->setHelp(
  5660. <<<EOT
  5661. The search command searches for packages by its name
  5662. <info>php composer.phar search symfony composer</info>
  5663. Read more at https://getcomposer.org/doc/03-cli.md#search
  5664. EOT
  5665. )
  5666. ;
  5667. }
  5668. protected function execute(InputInterface $input, OutputInterface $output)
  5669. {
  5670. $platformRepo = new PlatformRepository;
  5671. $io = $this->getIO();
  5672. if (!($composer = $this->getComposer(false))) {
  5673. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  5674. }
  5675. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5676. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  5677. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  5678. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  5679. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5680. $onlyName = $input->getOption('only-name');
  5681. $type = $input->getOption('type') ?: null;
  5682. $flags = $onlyName ? RepositoryInterface::SEARCH_NAME : RepositoryInterface::SEARCH_FULLTEXT;
  5683. $results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags, $type);
  5684. foreach ($results as $result) {
  5685. $io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
  5686. }
  5687. return 0;
  5688. }
  5689. }
  5690. <?php
  5691. namespace Composer\Command;
  5692. use Composer\Composer;
  5693. use Composer\Factory;
  5694. use Composer\Config;
  5695. use Composer\Util\Filesystem;
  5696. use Composer\Util\Platform;
  5697. use Composer\SelfUpdate\Keys;
  5698. use Composer\SelfUpdate\Versions;
  5699. use Composer\IO\IOInterface;
  5700. use Composer\Downloader\FilesystemException;
  5701. use Composer\Downloader\TransportException;
  5702. use Symfony\Component\Console\Input\InputInterface;
  5703. use Symfony\Component\Console\Input\InputOption;
  5704. use Symfony\Component\Console\Input\InputArgument;
  5705. use Symfony\Component\Console\Output\OutputInterface;
  5706. use Symfony\Component\Finder\Finder;
  5707. class SelfUpdateCommand extends BaseCommand
  5708. {
  5709. const HOMEPAGE = 'getcomposer.org';
  5710. const OLD_INSTALL_EXT = '-old.phar';
  5711. protected function configure()
  5712. {
  5713. $this
  5714. ->setName('self-update')
  5715. ->setAliases(array('selfupdate'))
  5716. ->setDescription('Updates composer.phar to the latest version.')
  5717. ->setDefinition(array(
  5718. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  5719. new InputOption('clean-backups', null, InputOption::VALUE_NONE, 'Delete old backups during an update. This makes the current version of composer the only backup available after the update'),
  5720. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  5721. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5722. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  5723. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  5724. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  5725. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  5726. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  5727. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  5728. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  5729. ))
  5730. ->setHelp(
  5731. <<<EOT
  5732. The <info>self-update</info> command checks getcomposer.org for newer
  5733. versions of composer and if found, installs the latest.
  5734. <info>php composer.phar self-update</info>
  5735. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  5736. EOT
  5737. )
  5738. ;
  5739. }
  5740. protected function execute(InputInterface $input, OutputInterface $output)
  5741. {
  5742. $config = Factory::createConfig();
  5743. if ($config->get('disable-tls') === true) {
  5744. $baseUrl = 'http://' . self::HOMEPAGE;
  5745. } else {
  5746. $baseUrl = 'https://' . self::HOMEPAGE;
  5747. }
  5748. $io = $this->getIO();
  5749. $httpDownloader = Factory::createHttpDownloader($io, $config);
  5750. $versionsUtil = new Versions($config, $httpDownloader);
  5751. $requestedChannel = null;
  5752. foreach (Versions::$channels as $channel) {
  5753. if ($input->getOption($channel)) {
  5754. $requestedChannel = $channel;
  5755. $versionsUtil->setChannel($channel);
  5756. break;
  5757. }
  5758. }
  5759. if ($input->getOption('set-channel-only')) {
  5760. return 0;
  5761. }
  5762. $cacheDir = $config->get('cache-dir');
  5763. $rollbackDir = $config->get('data-dir');
  5764. $home = $config->get('home');
  5765. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  5766. if ($input->getOption('update-keys')) {
  5767. return $this->fetchKeys($io, $config);
  5768. }
  5769. if (!file_exists($localFilename)) {
  5770. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  5771. }
  5772. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  5773. if (!is_writable($tmpDir)) {
  5774. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  5775. }
  5776. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  5777. $composeUser = posix_getpwuid(posix_geteuid());
  5778. $homeOwner = posix_getpwuid(fileowner($home));
  5779. if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  5780. $io->writeError('<warning>You are running Composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  5781. }
  5782. }
  5783. if ($input->getOption('rollback')) {
  5784. return $this->rollback($output, $rollbackDir, $localFilename);
  5785. }
  5786. $latest = $versionsUtil->getLatest();
  5787. $latestStable = $versionsUtil->getLatest('stable');
  5788. try {
  5789. $latestPreview = $versionsUtil->getLatest('preview');
  5790. } catch (\UnexpectedValueException $e) {
  5791. $latestPreview = $latestStable;
  5792. }
  5793. $latestVersion = $latest['version'];
  5794. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  5795. $currentMajorVersion = preg_replace('{^(\d+).*}', '$1', Composer::getVersion());
  5796. $updateMajorVersion = preg_replace('{^(\d+).*}', '$1', $updateVersion);
  5797. $previewMajorVersion = preg_replace('{^(\d+).*}', '$1', $latestPreview['version']);
  5798. if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
  5799. if ($currentMajorVersion < $updateMajorVersion) {
  5800. $skippedVersion = $updateVersion;
  5801. $versionsUtil->setChannel($currentMajorVersion);
  5802. $latest = $versionsUtil->getLatest();
  5803. $latestStable = $versionsUtil->getLatest('stable');
  5804. $latestVersion = $latest['version'];
  5805. $updateVersion = $latestVersion;
  5806. $io->writeError('<warning>A new stable major version of Composer is available ('.$skippedVersion.'), run "composer self-update --'.$updateMajorVersion.'" to update to it. See also https://getcomposer.org/'.$updateMajorVersion.'</warning>');
  5807. } elseif ($currentMajorVersion < $previewMajorVersion) {
  5808. $io->writeError('<warning>A preview release of the next major version of Composer is available ('.$latestPreview['version'].'), run "composer self-update --preview" to give it a try. See also https://github.com/composer/composer/releases for changelogs.</warning>');
  5809. }
  5810. }
  5811. if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
  5812. $io->writeError('<warning>Warning: You forced the install of '.$latestVersion.' via --'.$requestedChannel.', but '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.</warning>');
  5813. }
  5814. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  5815. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  5816. return 1;
  5817. }
  5818. $channelString = $versionsUtil->getChannel();
  5819. if (is_numeric($channelString)) {
  5820. $channelString .= '.x';
  5821. }
  5822. if (Composer::VERSION === $updateVersion) {
  5823. $io->writeError(
  5824. sprintf(
  5825. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  5826. $updateVersion,
  5827. $channelString
  5828. )
  5829. );
  5830. if ($input->getOption('clean-backups')) {
  5831. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  5832. }
  5833. return 0;
  5834. }
  5835. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp.phar';
  5836. $backupFile = sprintf(
  5837. '%s/%s-%s%s',
  5838. $rollbackDir,
  5839. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  5840. preg_replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  5841. self::OLD_INSTALL_EXT
  5842. );
  5843. $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion);
  5844. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  5845. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  5846. try {
  5847. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  5848. } catch (TransportException $e) {
  5849. if ($e->getStatusCode() === 404) {
  5850. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  5851. }
  5852. throw $e;
  5853. }
  5854. $io->writeError(' ', false);
  5855. $httpDownloader->copy($remoteFilename, $tempFilename);
  5856. $io->writeError('');
  5857. if (!file_exists($tempFilename) || !$signature) {
  5858. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  5859. return 1;
  5860. }
  5861. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  5862. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  5863. } else {
  5864. if (!extension_loaded('openssl')) {
  5865. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  5866. . 'If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the \'disable-tls\' option to true.');
  5867. }
  5868. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  5869. if (!file_exists($sigFile)) {
  5870. file_put_contents(
  5871. $home.'/keys.dev.pub',
  5872. <<<DEVPUBKEY
  5873. -----BEGIN PUBLIC KEY-----
  5874. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  5875. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  5876. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  5877. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  5878. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  5879. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  5880. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  5881. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  5882. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  5883. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  5884. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  5885. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  5886. -----END PUBLIC KEY-----
  5887. DEVPUBKEY
  5888. );
  5889. file_put_contents(
  5890. $home.'/keys.tags.pub',
  5891. <<<TAGSPUBKEY
  5892. -----BEGIN PUBLIC KEY-----
  5893. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  5894. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  5895. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  5896. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  5897. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  5898. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  5899. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  5900. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  5901. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  5902. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  5903. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  5904. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  5905. -----END PUBLIC KEY-----
  5906. TAGSPUBKEY
  5907. );
  5908. }
  5909. $pubkeyid = openssl_pkey_get_public($sigFile);
  5910. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  5911. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  5912. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  5913. }
  5914. $signature = json_decode($signature, true);
  5915. $signature = base64_decode($signature['sha384']);
  5916. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  5917. if (PHP_VERSION_ID < 80000) {
  5918. openssl_free_key($pubkeyid);
  5919. }
  5920. if (!$verified) {
  5921. throw new \RuntimeException('The phar signature did not match the file you downloaded, this means your public keys are outdated or that the phar file is corrupt/has been modified');
  5922. }
  5923. }
  5924. if ($input->getOption('clean-backups')) {
  5925. $this->cleanBackups($rollbackDir);
  5926. }
  5927. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  5928. @unlink($tempFilename);
  5929. return 1;
  5930. }
  5931. if (file_exists($backupFile)) {
  5932. $io->writeError(sprintf(
  5933. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  5934. Composer::VERSION
  5935. ));
  5936. } else {
  5937. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  5938. }
  5939. return 0;
  5940. }
  5941. protected function fetchKeys(IOInterface $io, Config $config)
  5942. {
  5943. if (!$io->isInteractive()) {
  5944. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  5945. }
  5946. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  5947. $validator = function ($value) {
  5948. if (!preg_match('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  5949. throw new \UnexpectedValueException('Invalid input');
  5950. }
  5951. return trim($value)."\n";
  5952. };
  5953. $devKey = '';
  5954. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  5955. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  5956. while ($line = $io->ask('')) {
  5957. $devKey .= trim($line)."\n";
  5958. if (trim($line) === '-----END PUBLIC KEY-----') {
  5959. break;
  5960. }
  5961. }
  5962. }
  5963. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  5964. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5965. $tagsKey = '';
  5966. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  5967. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  5968. while ($line = $io->ask('')) {
  5969. $tagsKey .= trim($line)."\n";
  5970. if (trim($line) === '-----END PUBLIC KEY-----') {
  5971. break;
  5972. }
  5973. }
  5974. }
  5975. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  5976. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5977. $io->write('Public keys stored in '.$config->get('home'));
  5978. }
  5979. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  5980. {
  5981. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  5982. if (!$rollbackVersion) {
  5983. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  5984. }
  5985. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  5986. if (!is_file($oldFile)) {
  5987. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  5988. }
  5989. if (!is_readable($oldFile)) {
  5990. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  5991. }
  5992. $io = $this->getIO();
  5993. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  5994. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  5995. return 1;
  5996. }
  5997. return 0;
  5998. }
  5999. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  6000. {
  6001. $io = $this->getIO();
  6002. @chmod($newFilename, fileperms($localFilename));
  6003. if (!$this->validatePhar($newFilename, $error)) {
  6004. $io->writeError('<error>The '.($backupTarget ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  6005. if ($backupTarget) {
  6006. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  6007. }
  6008. return false;
  6009. }
  6010. if ($backupTarget) {
  6011. @copy($localFilename, $backupTarget);
  6012. }
  6013. try {
  6014. if (Platform::isWindows()) {
  6015. copy($newFilename, $localFilename);
  6016. @unlink($newFilename);
  6017. } else {
  6018. rename($newFilename, $localFilename);
  6019. }
  6020. return true;
  6021. } catch (\Exception $e) {
  6022. if (!is_writable(dirname($localFilename))
  6023. && $io->isInteractive()
  6024. && $this->isWindowsNonAdminUser()) {
  6025. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  6026. }
  6027. $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
  6028. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  6029. }
  6030. }
  6031. protected function cleanBackups($rollbackDir, $except = null)
  6032. {
  6033. $finder = $this->getOldInstallationFinder($rollbackDir);
  6034. $io = $this->getIO();
  6035. $fs = new Filesystem;
  6036. foreach ($finder as $file) {
  6037. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  6038. continue;
  6039. }
  6040. $file = (string) $file;
  6041. $io->writeError('<info>Removing: '.$file.'</info>');
  6042. $fs->remove($file);
  6043. }
  6044. }
  6045. protected function getLastBackupVersion($rollbackDir)
  6046. {
  6047. $finder = $this->getOldInstallationFinder($rollbackDir);
  6048. $finder->sortByName();
  6049. $files = iterator_to_array($finder);
  6050. if (count($files)) {
  6051. return basename(end($files), self::OLD_INSTALL_EXT);
  6052. }
  6053. return false;
  6054. }
  6055. protected function getOldInstallationFinder($rollbackDir)
  6056. {
  6057. return Finder::create()
  6058. ->depth(0)
  6059. ->files()
  6060. ->name('*' . self::OLD_INSTALL_EXT)
  6061. ->in($rollbackDir);
  6062. }
  6063. protected function validatePhar($pharFile, &$error)
  6064. {
  6065. if (ini_get('phar.readonly')) {
  6066. return true;
  6067. }
  6068. try {
  6069. $phar = new \Phar($pharFile);
  6070. unset($phar);
  6071. $result = true;
  6072. } catch (\Exception $e) {
  6073. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  6074. throw $e;
  6075. }
  6076. $error = $e->getMessage();
  6077. $result = false;
  6078. }
  6079. return $result;
  6080. }
  6081. protected function isWindowsNonAdminUser()
  6082. {
  6083. if (!Platform::isWindows()) {
  6084. return false;
  6085. }
  6086. exec('fltmc.exe filters', $output, $exitCode);
  6087. return $exitCode !== 0;
  6088. }
  6089. protected function tryAsWindowsAdmin($localFilename, $newFilename)
  6090. {
  6091. $io = $this->getIO();
  6092. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6093. $helpMessage = 'Please run the self-update command as an Administrator.';
  6094. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6095. if (!$io->askConfirmation($question, false)) {
  6096. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6097. return false;
  6098. }
  6099. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6100. $script = $tmpFile.'.vbs';
  6101. rename($tmpFile, $script);
  6102. $checksum = hash_file('sha256', $newFilename);
  6103. $source = str_replace('/', '\\', $newFilename);
  6104. $destination = str_replace('/', '\\', $localFilename);
  6105. $vbs = <<<EOT
  6106. Set UAC = CreateObject("Shell.Application")
  6107. UAC.ShellExecute "cmd.exe", "/c copy /b /y ""$source"" ""$destination""", "", "runas", 0
  6108. Wscript.Sleep(300)
  6109. EOT;
  6110. file_put_contents($script, $vbs);
  6111. exec('"'.$script.'"');
  6112. @unlink($script);
  6113. if ($result = is_readable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
  6114. $io->writeError('<info>Operation succeeded.</info>');
  6115. @unlink($newFilename);
  6116. } else {
  6117. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  6118. }
  6119. return $result;
  6120. }
  6121. }
  6122. <?php
  6123. namespace Composer\Command;
  6124. use Composer\Composer;
  6125. use Composer\DependencyResolver\DefaultPolicy;
  6126. use Composer\Json\JsonFile;
  6127. use Composer\Package\BasePackage;
  6128. use Composer\Package\CompletePackageInterface;
  6129. use Composer\Package\Link;
  6130. use Composer\Package\AliasPackage;
  6131. use Composer\Package\PackageInterface;
  6132. use Composer\Package\Version\VersionParser;
  6133. use Composer\Package\Version\VersionSelector;
  6134. use Composer\Plugin\CommandEvent;
  6135. use Composer\Plugin\PluginEvents;
  6136. use Composer\Repository\InstalledArrayRepository;
  6137. use Composer\Repository\ComposerRepository;
  6138. use Composer\Repository\CompositeRepository;
  6139. use Composer\Repository\PlatformRepository;
  6140. use Composer\Repository\RepositoryFactory;
  6141. use Composer\Repository\InstalledRepository;
  6142. use Composer\Repository\RepositoryInterface;
  6143. use Composer\Repository\RepositorySet;
  6144. use Composer\Repository\RootPackageRepository;
  6145. use Composer\Semver\Constraint\ConstraintInterface;
  6146. use Composer\Semver\Semver;
  6147. use Composer\Spdx\SpdxLicenses;
  6148. use Composer\Util\Platform;
  6149. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  6150. use Symfony\Component\Console\Input\InputArgument;
  6151. use Symfony\Component\Console\Input\InputInterface;
  6152. use Symfony\Component\Console\Input\InputOption;
  6153. use Symfony\Component\Console\Output\OutputInterface;
  6154. use Symfony\Component\Console\Terminal;
  6155. class ShowCommand extends BaseCommand
  6156. {
  6157. protected $versionParser;
  6158. protected $colors;
  6159. private $repositorySet;
  6160. protected function configure()
  6161. {
  6162. $this
  6163. ->setName('show')
  6164. ->setAliases(array('info'))
  6165. ->setDescription('Shows information about packages.')
  6166. ->setDefinition(array(
  6167. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  6168. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  6169. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  6170. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  6171. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  6172. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  6173. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  6174. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  6175. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  6176. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  6177. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  6178. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  6179. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  6180. new InputOption('ignore', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore specified package(s). Use it with the --outdated option if you don\'t want to be informed about new versions of some packages.'),
  6181. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  6182. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6183. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6184. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6185. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6186. ))
  6187. ->setHelp(
  6188. <<<EOT
  6189. The show command displays detailed information about a package, or
  6190. lists all packages available.
  6191. Read more at https://getcomposer.org/doc/03-cli.md#show
  6192. EOT
  6193. )
  6194. ;
  6195. }
  6196. protected function execute(InputInterface $input, OutputInterface $output)
  6197. {
  6198. $this->versionParser = new VersionParser;
  6199. if ($input->getOption('tree')) {
  6200. $this->initStyles($output);
  6201. }
  6202. $composer = $this->getComposer(false);
  6203. $io = $this->getIO();
  6204. if ($input->getOption('installed')) {
  6205. $io->writeError('<warning>You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages.</warning>');
  6206. }
  6207. if ($input->getOption('outdated')) {
  6208. $input->setOption('latest', true);
  6209. } elseif ($input->getOption('ignore')) {
  6210. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  6211. }
  6212. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  6213. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  6214. return 1;
  6215. }
  6216. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  6217. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  6218. return 1;
  6219. }
  6220. if ($input->getOption('tree') && $input->getOption('latest')) {
  6221. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  6222. return 1;
  6223. }
  6224. if ($input->getOption('tree') && $input->getOption('path')) {
  6225. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  6226. return 1;
  6227. }
  6228. $format = $input->getOption('format');
  6229. if (!in_array($format, array('text', 'json'))) {
  6230. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6231. return 1;
  6232. }
  6233. $platformOverrides = array();
  6234. if ($composer) {
  6235. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  6236. }
  6237. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  6238. $lockedRepo = null;
  6239. if ($input->getOption('self')) {
  6240. $package = $this->getComposer()->getPackage();
  6241. if ($input->getOption('name-only')) {
  6242. $io->write($package->getName());
  6243. return 0;
  6244. }
  6245. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  6246. } elseif ($input->getOption('platform')) {
  6247. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  6248. } elseif ($input->getOption('available')) {
  6249. $installedRepo = new InstalledRepository(array($platformRepo));
  6250. if ($composer) {
  6251. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  6252. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  6253. } else {
  6254. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6255. $repos = new CompositeRepository($defaultRepos);
  6256. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6257. }
  6258. } elseif ($input->getOption('all') && $composer) {
  6259. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6260. $locker = $composer->getLocker();
  6261. if ($locker->isLocked()) {
  6262. $lockedRepo = $locker->getLockedRepository(true);
  6263. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  6264. } else {
  6265. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  6266. }
  6267. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6268. } elseif ($input->getOption('all')) {
  6269. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6270. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6271. $installedRepo = new InstalledRepository(array($platformRepo));
  6272. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  6273. } elseif ($input->getOption('locked')) {
  6274. if (!$composer || !$composer->getLocker()->isLocked()) {
  6275. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  6276. }
  6277. $locker = $composer->getLocker();
  6278. $lockedRepo = $locker->getLockedRepository(true);
  6279. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  6280. } else {
  6281. if (!$composer) {
  6282. $composer = $this->getComposer();
  6283. }
  6284. $rootPkg = $composer->getPackage();
  6285. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  6286. if ($input->getOption('no-dev')) {
  6287. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  6288. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) {
  6289. return clone $pkg;
  6290. }, $packages))));
  6291. }
  6292. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  6293. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  6294. }
  6295. }
  6296. if ($composer) {
  6297. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  6298. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6299. }
  6300. if ($input->getOption('latest') && null === $composer) {
  6301. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  6302. $input->setOption('latest', false);
  6303. }
  6304. $packageFilter = $input->getArgument('package');
  6305. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  6306. if (empty($package)) {
  6307. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  6308. if (empty($package)) {
  6309. $options = $input->getOptions();
  6310. if (!isset($options['working-dir']) || !file_exists('composer.json')) {
  6311. if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
  6312. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
  6313. }
  6314. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
  6315. }
  6316. $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
  6317. return 1;
  6318. }
  6319. } else {
  6320. $versions = array($package->getPrettyVersion() => $package->getVersion());
  6321. }
  6322. $exitCode = 0;
  6323. if ($input->getOption('tree')) {
  6324. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  6325. if ('json' === $format) {
  6326. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  6327. } else {
  6328. $this->displayPackageTree(array($arrayTree));
  6329. }
  6330. } else {
  6331. $latestPackage = null;
  6332. if ($input->getOption('latest')) {
  6333. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'));
  6334. }
  6335. if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) {
  6336. $exitCode = 1;
  6337. }
  6338. if ($input->getOption('path')) {
  6339. $io->write($package->getName(), false);
  6340. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  6341. return $exitCode;
  6342. }
  6343. if ('json' === $format) {
  6344. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  6345. } else {
  6346. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  6347. }
  6348. }
  6349. return $exitCode;
  6350. }
  6351. if ($input->getOption('tree')) {
  6352. $rootRequires = $this->getRootRequires();
  6353. $packages = $installedRepo->getPackages();
  6354. usort($packages, 'strcmp');
  6355. $arrayTree = array();
  6356. foreach ($packages as $package) {
  6357. if (in_array($package->getName(), $rootRequires, true)) {
  6358. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  6359. }
  6360. }
  6361. if ('json' === $format) {
  6362. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  6363. } else {
  6364. $this->displayPackageTree($arrayTree);
  6365. }
  6366. return 0;
  6367. }
  6368. if ($repos instanceof CompositeRepository) {
  6369. $repos = $repos->getRepositories();
  6370. } elseif (!is_array($repos)) {
  6371. $repos = array($repos);
  6372. }
  6373. $packages = array();
  6374. $packageFilterRegex = null;
  6375. if (null !== $packageFilter) {
  6376. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  6377. }
  6378. $packageListFilter = array();
  6379. if ($input->getOption('direct')) {
  6380. $packageListFilter = $this->getRootRequires();
  6381. }
  6382. if (class_exists('Symfony\Component\Console\Terminal')) {
  6383. $terminal = new Terminal();
  6384. $width = $terminal->getWidth();
  6385. } else {
  6386. list($width) = $this->getApplication()->getTerminalDimensions();
  6387. }
  6388. if (null === $width) {
  6389. $width = PHP_INT_MAX;
  6390. }
  6391. if (Platform::isWindows()) {
  6392. $width--;
  6393. } else {
  6394. $width = max(80, $width);
  6395. }
  6396. if ($input->getOption('path') && null === $composer) {
  6397. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  6398. $input->setOption('path', false);
  6399. }
  6400. foreach ($repos as $repo) {
  6401. if ($repo === $platformRepo) {
  6402. $type = 'platform';
  6403. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  6404. $type = 'locked';
  6405. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  6406. $type = 'installed';
  6407. } else {
  6408. $type = 'available';
  6409. }
  6410. if ($repo instanceof ComposerRepository) {
  6411. foreach ($repo->getPackageNames($packageFilter) as $name) {
  6412. $packages[$type][$name] = $name;
  6413. }
  6414. } else {
  6415. foreach ($repo->getPackages() as $package) {
  6416. if (!isset($packages[$type][$package->getName()])
  6417. || !is_object($packages[$type][$package->getName()])
  6418. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  6419. ) {
  6420. while ($package instanceof AliasPackage) {
  6421. $package = $package->getAliasOf();
  6422. }
  6423. if (!$packageFilterRegex || preg_match($packageFilterRegex, $package->getName())) {
  6424. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  6425. $packages[$type][$package->getName()] = $package;
  6426. }
  6427. }
  6428. }
  6429. }
  6430. }
  6431. }
  6432. $showAllTypes = $input->getOption('all');
  6433. $showLatest = $input->getOption('latest');
  6434. $showMinorOnly = $input->getOption('minor-only');
  6435. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  6436. $indent = $showAllTypes ? ' ' : '';
  6437. $latestPackages = array();
  6438. $exitCode = 0;
  6439. $viewData = array();
  6440. $viewMetaData = array();
  6441. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  6442. if (isset($packages[$type])) {
  6443. ksort($packages[$type]);
  6444. $nameLength = $versionLength = $latestLength = 0;
  6445. if ($showLatest && $showVersion) {
  6446. foreach ($packages[$type] as $package) {
  6447. if (is_object($package)) {
  6448. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly);
  6449. if ($latestPackage === false) {
  6450. continue;
  6451. }
  6452. $latestPackages[$package->getPrettyName()] = $latestPackage;
  6453. }
  6454. }
  6455. }
  6456. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  6457. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  6458. $writeLatest = $writeVersion && $showLatest;
  6459. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  6460. $hasOutdatedPackages = false;
  6461. $viewData[$type] = array();
  6462. foreach ($packages[$type] as $package) {
  6463. $packageViewData = array();
  6464. if (is_object($package)) {
  6465. $latestPackage = null;
  6466. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  6467. $latestPackage = $latestPackages[$package->getPrettyName()];
  6468. }
  6469. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackage->isAbandoned();
  6470. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  6471. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  6472. continue;
  6473. }
  6474. if ($input->getOption('outdated') || $input->getOption('strict')) {
  6475. $hasOutdatedPackages = true;
  6476. }
  6477. $packageViewData['name'] = $package->getPrettyName();
  6478. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  6479. if ($writeVersion) {
  6480. $packageViewData['version'] = $package->getFullPrettyVersion();
  6481. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  6482. }
  6483. if ($writeLatest && $latestPackage) {
  6484. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  6485. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  6486. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  6487. }
  6488. if ($writeDescription) {
  6489. $packageViewData['description'] = $package->getDescription();
  6490. }
  6491. if ($writePath) {
  6492. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  6493. }
  6494. if ($latestPackage && $latestPackage->isAbandoned()) {
  6495. $replacement = is_string($latestPackage->getReplacementPackage())
  6496. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  6497. : 'No replacement was suggested';
  6498. $packageWarning = sprintf(
  6499. 'Package %s is abandoned, you should avoid using it. %s.',
  6500. $package->getPrettyName(),
  6501. $replacement
  6502. );
  6503. $packageViewData['warning'] = $packageWarning;
  6504. }
  6505. } else {
  6506. $packageViewData['name'] = $package;
  6507. $nameLength = max($nameLength, strlen($package));
  6508. }
  6509. $viewData[$type][] = $packageViewData;
  6510. }
  6511. $viewMetaData[$type] = array(
  6512. 'nameLength' => $nameLength,
  6513. 'versionLength' => $versionLength,
  6514. 'latestLength' => $latestLength,
  6515. );
  6516. if ($input->getOption('strict') && $hasOutdatedPackages) {
  6517. $exitCode = 1;
  6518. break;
  6519. }
  6520. }
  6521. }
  6522. if ('json' === $format) {
  6523. $io->write(JsonFile::encode($viewData));
  6524. } else {
  6525. foreach ($viewData as $type => $packages) {
  6526. $nameLength = $viewMetaData[$type]['nameLength'];
  6527. $versionLength = $viewMetaData[$type]['versionLength'];
  6528. $latestLength = $viewMetaData[$type]['latestLength'];
  6529. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  6530. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  6531. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  6532. if ($writeLatest && !$io->isDecorated()) {
  6533. $latestLength += 2;
  6534. }
  6535. if ($showAllTypes) {
  6536. if ('available' === $type) {
  6537. $io->write('<comment>' . $type . '</comment>:');
  6538. } else {
  6539. $io->write('<info>' . $type . '</info>:');
  6540. }
  6541. }
  6542. foreach ($packages as $package) {
  6543. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  6544. if (isset($package['version']) && $writeVersion) {
  6545. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  6546. }
  6547. if (isset($package['latest']) && $writeLatest) {
  6548. $latestVersion = $package['latest'];
  6549. $updateStatus = $package['latest-status'];
  6550. $style = $this->updateStatusToVersionStyle($updateStatus);
  6551. if (!$io->isDecorated()) {
  6552. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  6553. }
  6554. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  6555. }
  6556. if (isset($package['description']) && $writeDescription) {
  6557. $description = strtok($package['description'], "\r\n");
  6558. $remaining = $width - $nameLength - $versionLength - 4;
  6559. if ($writeLatest) {
  6560. $remaining -= $latestLength;
  6561. }
  6562. if (strlen($description) > $remaining) {
  6563. $description = substr($description, 0, $remaining - 3) . '...';
  6564. }
  6565. $io->write(' ' . $description, false);
  6566. }
  6567. if (isset($package['path'])) {
  6568. $io->write(' ' . $package['path'], false);
  6569. }
  6570. $io->write('');
  6571. if (isset($package['warning'])) {
  6572. $io->write('<warning>' . $package['warning'] . '</warning>');
  6573. }
  6574. }
  6575. if ($showAllTypes) {
  6576. $io->write('');
  6577. }
  6578. }
  6579. }
  6580. return $exitCode;
  6581. }
  6582. protected function getRootRequires()
  6583. {
  6584. $rootPackage = $this->getComposer()->getPackage();
  6585. return array_map(
  6586. 'strtolower',
  6587. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  6588. );
  6589. }
  6590. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  6591. {
  6592. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  6593. }
  6594. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
  6595. {
  6596. $name = strtolower($name);
  6597. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  6598. $policy = new DefaultPolicy();
  6599. $repositorySet = new RepositorySet('dev');
  6600. $repositorySet->allowInstalledRepositories();
  6601. $repositorySet->addRepository($repos);
  6602. $matchedPackage = null;
  6603. $versions = array();
  6604. if (PlatformRepository::isPlatformPackage($name)) {
  6605. $pool = $repositorySet->createPoolWithAllPackages();
  6606. } else {
  6607. $pool = $repositorySet->createPoolForPackage($name);
  6608. }
  6609. $matches = $pool->whatProvides($name, $constraint);
  6610. foreach ($matches as $index => $package) {
  6611. if (null === $version && $installedRepo->hasPackage($package)) {
  6612. $matchedPackage = $package;
  6613. }
  6614. $versions[$package->getPrettyVersion()] = $package->getVersion();
  6615. $matches[$index] = $package->getId();
  6616. }
  6617. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  6618. $matchedPackage = $pool->literalToPackage($preferred[0]);
  6619. }
  6620. return array($matchedPackage, $versions);
  6621. }
  6622. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6623. {
  6624. $io = $this->getIO();
  6625. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  6626. $this->printLinks($package, Link::TYPE_REQUIRE);
  6627. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  6628. if ($package->getSuggests()) {
  6629. $io->write("\n<info>suggests</info>");
  6630. foreach ($package->getSuggests() as $suggested => $reason) {
  6631. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  6632. }
  6633. }
  6634. $this->printLinks($package, Link::TYPE_PROVIDE);
  6635. $this->printLinks($package, Link::TYPE_CONFLICT);
  6636. $this->printLinks($package, Link::TYPE_REPLACE);
  6637. }
  6638. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6639. {
  6640. $io = $this->getIO();
  6641. $io->write('<info>name</info> : ' . $package->getPrettyName());
  6642. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  6643. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  6644. $this->printVersions($package, $versions, $installedRepo);
  6645. if ($latestPackage) {
  6646. $style = $this->getVersionStyle($latestPackage, $package);
  6647. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  6648. } else {
  6649. $latestPackage = $package;
  6650. }
  6651. $io->write('<info>type</info> : ' . $package->getType());
  6652. $this->printLicenses($package);
  6653. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  6654. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  6655. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  6656. if ($installedRepo->hasPackage($package)) {
  6657. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  6658. }
  6659. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  6660. if ($latestPackage->isAbandoned()) {
  6661. $replacement = ($latestPackage->getReplacementPackage() !== null)
  6662. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  6663. : null;
  6664. $io->writeError(
  6665. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  6666. );
  6667. }
  6668. if ($package->getSupport()) {
  6669. $io->write("\n<info>support</info>");
  6670. foreach ($package->getSupport() as $type => $value) {
  6671. $io->write('<comment>' . $type . '</comment> : '.$value);
  6672. }
  6673. }
  6674. if ($package->getAutoload()) {
  6675. $io->write("\n<info>autoload</info>");
  6676. foreach ($package->getAutoload() as $type => $autoloads) {
  6677. $io->write('<comment>' . $type . '</comment>');
  6678. if ($type === 'psr-0' || $type === 'psr-4') {
  6679. foreach ($autoloads as $name => $path) {
  6680. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  6681. }
  6682. } elseif ($type === 'classmap') {
  6683. $io->write(implode(', ', $autoloads));
  6684. }
  6685. }
  6686. if ($package->getIncludePaths()) {
  6687. $io->write('<comment>include-path</comment>');
  6688. $io->write(implode(', ', $package->getIncludePaths()));
  6689. }
  6690. }
  6691. }
  6692. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
  6693. {
  6694. $versions = array_keys($versions);
  6695. $versions = Semver::rsort($versions);
  6696. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  6697. foreach ($installedPackages as $installedPackage) {
  6698. $installedVersion = $installedPackage->getPrettyVersion();
  6699. $key = array_search($installedVersion, $versions);
  6700. if (false !== $key) {
  6701. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  6702. }
  6703. }
  6704. }
  6705. $versions = implode(', ', $versions);
  6706. $this->getIO()->write('<info>versions</info> : ' . $versions);
  6707. }
  6708. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  6709. {
  6710. $title = $title ?: $linkType;
  6711. $io = $this->getIO();
  6712. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  6713. $io->write("\n<info>" . $title . "</info>");
  6714. foreach ($links as $link) {
  6715. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  6716. }
  6717. }
  6718. }
  6719. protected function printLicenses(CompletePackageInterface $package)
  6720. {
  6721. $spdxLicenses = new SpdxLicenses();
  6722. $licenses = $package->getLicense();
  6723. $io = $this->getIO();
  6724. foreach ($licenses as $licenseId) {
  6725. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6726. if (!$license) {
  6727. $out = $licenseId;
  6728. } else {
  6729. if ($license[1] === true) {
  6730. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  6731. } else {
  6732. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  6733. }
  6734. }
  6735. $io->write('<info>license</info> : ' . $out);
  6736. }
  6737. }
  6738. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6739. {
  6740. $json = array(
  6741. 'name' => $package->getPrettyName(),
  6742. 'description' => $package->getDescription(),
  6743. 'keywords' => $package->getKeywords() ?: array(),
  6744. 'type' => $package->getType(),
  6745. 'homepage' => $package->getHomepage(),
  6746. 'names' => $package->getNames(),
  6747. );
  6748. $json = $this->appendVersions($json, $versions);
  6749. $json = $this->appendLicenses($json, $package);
  6750. if ($latestPackage) {
  6751. $json['latest'] = $latestPackage->getPrettyVersion();
  6752. } else {
  6753. $latestPackage = $package;
  6754. }
  6755. if ($package->getSourceType()) {
  6756. $json['source'] = array(
  6757. 'type' => $package->getSourceType(),
  6758. 'url' => $package->getSourceUrl(),
  6759. 'reference' => $package->getSourceReference(),
  6760. );
  6761. }
  6762. if ($package->getDistType()) {
  6763. $json['dist'] = array(
  6764. 'type' => $package->getDistType(),
  6765. 'url' => $package->getDistUrl(),
  6766. 'reference' => $package->getDistReference(),
  6767. );
  6768. }
  6769. if ($installedRepo->hasPackage($package)) {
  6770. $json['path'] = realpath($this->getComposer()->getInstallationManager()->getInstallPath($package));
  6771. if ($json['path'] === false) {
  6772. unset($json['path']);
  6773. }
  6774. }
  6775. if ($latestPackage->isAbandoned()) {
  6776. $json['replacement'] = $latestPackage->getReplacementPackage();
  6777. }
  6778. if ($package->getSuggests()) {
  6779. $json['suggests'] = $package->getSuggests();
  6780. }
  6781. if ($package->getSupport()) {
  6782. $json['support'] = $package->getSupport();
  6783. }
  6784. $json = $this->appendAutoload($json, $package);
  6785. if ($package->getIncludePaths()) {
  6786. $json['include_path'] = $package->getIncludePaths();
  6787. }
  6788. $json = $this->appendLinks($json, $package);
  6789. $this->getIO()->write(JsonFile::encode($json));
  6790. }
  6791. private function appendVersions($json, array $versions)
  6792. {
  6793. uasort($versions, 'version_compare');
  6794. $versions = array_keys(array_reverse($versions));
  6795. $json['versions'] = $versions;
  6796. return $json;
  6797. }
  6798. private function appendLicenses($json, CompletePackageInterface $package)
  6799. {
  6800. if ($licenses = $package->getLicense()) {
  6801. $spdxLicenses = new SpdxLicenses();
  6802. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  6803. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6804. if (!$license) {
  6805. return $licenseId;
  6806. }
  6807. return array(
  6808. 'name' => $license[0],
  6809. 'osi' => $licenseId,
  6810. 'url' => $license[2],
  6811. );
  6812. }, $licenses);
  6813. }
  6814. return $json;
  6815. }
  6816. private function appendAutoload($json, CompletePackageInterface $package)
  6817. {
  6818. if ($package->getAutoload()) {
  6819. $autoload = array();
  6820. foreach ($package->getAutoload() as $type => $autoloads) {
  6821. if ($type === 'psr-0' || $type === 'psr-4') {
  6822. $psr = array();
  6823. foreach ($autoloads as $name => $path) {
  6824. if (!$path) {
  6825. $path = '.';
  6826. }
  6827. $psr[$name ?: '*'] = $path;
  6828. }
  6829. $autoload[$type] = $psr;
  6830. } elseif ($type === 'classmap') {
  6831. $autoload['classmap'] = $autoloads;
  6832. }
  6833. }
  6834. $json['autoload'] = $autoload;
  6835. }
  6836. return $json;
  6837. }
  6838. private function appendLinks($json, CompletePackageInterface $package)
  6839. {
  6840. foreach (Link::$TYPES as $linkType) {
  6841. $json = $this->appendLink($json, $package, $linkType);
  6842. }
  6843. return $json;
  6844. }
  6845. private function appendLink($json, CompletePackageInterface $package, $linkType)
  6846. {
  6847. $links = $package->{'get' . ucfirst($linkType)}();
  6848. if ($links) {
  6849. $json[$linkType] = array();
  6850. foreach ($links as $link) {
  6851. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  6852. }
  6853. }
  6854. return $json;
  6855. }
  6856. protected function initStyles(OutputInterface $output)
  6857. {
  6858. $this->colors = array(
  6859. 'green',
  6860. 'yellow',
  6861. 'cyan',
  6862. 'magenta',
  6863. 'blue',
  6864. );
  6865. foreach ($this->colors as $color) {
  6866. $style = new OutputFormatterStyle($color);
  6867. $output->getFormatter()->setStyle($color, $style);
  6868. }
  6869. }
  6870. protected function displayPackageTree(array $arrayTree)
  6871. {
  6872. $io = $this->getIO();
  6873. foreach ($arrayTree as $package) {
  6874. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  6875. $io->write(' ' . $package['version'], false);
  6876. $io->write(' ' . strtok($package['description'], "\r\n"));
  6877. if (isset($package['requires'])) {
  6878. $requires = $package['requires'];
  6879. $treeBar = '├';
  6880. $j = 0;
  6881. $total = count($requires);
  6882. foreach ($requires as $require) {
  6883. $requireName = $require['name'];
  6884. $j++;
  6885. if ($j === $total) {
  6886. $treeBar = 'â””';
  6887. }
  6888. $level = 1;
  6889. $color = $this->colors[$level];
  6890. $info = sprintf(
  6891. '%s──<%s>%s</%s> %s',
  6892. $treeBar,
  6893. $color,
  6894. $requireName,
  6895. $color,
  6896. $require['version']
  6897. );
  6898. $this->writeTreeLine($info);
  6899. $treeBar = str_replace('â””', ' ', $treeBar);
  6900. $packagesInTree = array($package['name'], $requireName);
  6901. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  6902. }
  6903. }
  6904. }
  6905. }
  6906. protected function generatePackageTree(
  6907. PackageInterface $package,
  6908. InstalledRepository $installedRepo,
  6909. RepositoryInterface $remoteRepos
  6910. ) {
  6911. $requires = $package->getRequires();
  6912. ksort($requires);
  6913. $children = array();
  6914. foreach ($requires as $requireName => $require) {
  6915. $packagesInTree = array($package->getName(), $requireName);
  6916. $treeChildDesc = array(
  6917. 'name' => $requireName,
  6918. 'version' => $require->getPrettyConstraint(),
  6919. );
  6920. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  6921. if ($deepChildren) {
  6922. $treeChildDesc['requires'] = $deepChildren;
  6923. }
  6924. $children[] = $treeChildDesc;
  6925. }
  6926. $tree = array(
  6927. 'name' => $package->getPrettyName(),
  6928. 'version' => $package->getPrettyVersion(),
  6929. 'description' => $package->getDescription(),
  6930. );
  6931. if ($children) {
  6932. $tree['requires'] = $children;
  6933. }
  6934. return $tree;
  6935. }
  6936. protected function displayTree(
  6937. $package,
  6938. array $packagesInTree,
  6939. $previousTreeBar = '├',
  6940. $level = 1
  6941. ) {
  6942. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  6943. if (is_array($package) && isset($package['requires'])) {
  6944. $requires = $package['requires'];
  6945. $treeBar = $previousTreeBar . ' ├';
  6946. $i = 0;
  6947. $total = count($requires);
  6948. foreach ($requires as $require) {
  6949. $currentTree = $packagesInTree;
  6950. $i++;
  6951. if ($i === $total) {
  6952. $treeBar = $previousTreeBar . ' â””';
  6953. }
  6954. $colorIdent = $level % count($this->colors);
  6955. $color = $this->colors[$colorIdent];
  6956. $circularWarn = in_array(
  6957. $require['name'],
  6958. $currentTree,
  6959. true
  6960. ) ? '(circular dependency aborted here)' : '';
  6961. $info = rtrim(sprintf(
  6962. '%s──<%s>%s</%s> %s %s',
  6963. $treeBar,
  6964. $color,
  6965. $require['name'],
  6966. $color,
  6967. $require['version'],
  6968. $circularWarn
  6969. ));
  6970. $this->writeTreeLine($info);
  6971. $treeBar = str_replace('â””', ' ', $treeBar);
  6972. $currentTree[] = $require['name'];
  6973. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  6974. }
  6975. }
  6976. }
  6977. protected function addTree(
  6978. $name,
  6979. $package,
  6980. InstalledRepository $installedRepo,
  6981. RepositoryInterface $remoteRepos,
  6982. array $packagesInTree
  6983. ) {
  6984. $children = array();
  6985. list($package) = $this->getPackage(
  6986. $installedRepo,
  6987. $remoteRepos,
  6988. $name,
  6989. $package->getPrettyConstraint() === 'self.version' ? $package->getConstraint() : $package->getPrettyConstraint()
  6990. );
  6991. if (is_object($package)) {
  6992. $requires = $package->getRequires();
  6993. ksort($requires);
  6994. foreach ($requires as $requireName => $require) {
  6995. $currentTree = $packagesInTree;
  6996. $treeChildDesc = array(
  6997. 'name' => $requireName,
  6998. 'version' => $require->getPrettyConstraint(),
  6999. );
  7000. if (!in_array($requireName, $currentTree, true)) {
  7001. $currentTree[] = $requireName;
  7002. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  7003. if ($deepChildren) {
  7004. $treeChildDesc['requires'] = $deepChildren;
  7005. }
  7006. }
  7007. $children[] = $treeChildDesc;
  7008. }
  7009. }
  7010. return $children;
  7011. }
  7012. private function updateStatusToVersionStyle($updateStatus)
  7013. {
  7014. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  7015. }
  7016. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  7017. {
  7018. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  7019. return 'up-to-date';
  7020. }
  7021. $constraint = $package->getVersion();
  7022. if (0 !== strpos($constraint, 'dev-')) {
  7023. $constraint = '^'.$constraint;
  7024. }
  7025. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  7026. return 'semver-safe-update';
  7027. }
  7028. return 'update-possible';
  7029. }
  7030. private function writeTreeLine($line)
  7031. {
  7032. $io = $this->getIO();
  7033. if (!$io->isDecorated()) {
  7034. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  7035. }
  7036. $io->write($line);
  7037. }
  7038. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, $minorOnly = false)
  7039. {
  7040. $name = $package->getName();
  7041. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  7042. $stability = $composer->getPackage()->getMinimumStability();
  7043. $flags = $composer->getPackage()->getStabilityFlags();
  7044. if (isset($flags[$name])) {
  7045. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  7046. }
  7047. $bestStability = $stability;
  7048. if ($composer->getPackage()->getPreferStable()) {
  7049. $bestStability = $package->getStability();
  7050. }
  7051. $targetVersion = null;
  7052. if (0 === strpos($package->getVersion(), 'dev-')) {
  7053. $targetVersion = $package->getVersion();
  7054. }
  7055. if ($targetVersion === null && $minorOnly) {
  7056. $targetVersion = '^' . $package->getVersion();
  7057. }
  7058. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability);
  7059. while ($candidate instanceof AliasPackage) {
  7060. $candidate = $candidate->getAliasOf();
  7061. }
  7062. return $candidate;
  7063. }
  7064. private function getRepositorySet(Composer $composer)
  7065. {
  7066. if (!$this->repositorySet) {
  7067. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  7068. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  7069. }
  7070. return $this->repositorySet;
  7071. }
  7072. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  7073. {
  7074. $requires = $package->getRequires();
  7075. foreach ($repo->getPackages() as $candidate) {
  7076. foreach ($candidate->getNames() as $name) {
  7077. if (isset($requires[$name])) {
  7078. if (!in_array($candidate, $bucket, true)) {
  7079. $bucket[] = $candidate;
  7080. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  7081. }
  7082. break;
  7083. }
  7084. }
  7085. }
  7086. return $bucket;
  7087. }
  7088. }
  7089. <?php
  7090. namespace Composer\Command;
  7091. use Symfony\Component\Console\Input\InputInterface;
  7092. use Symfony\Component\Console\Input\InputOption;
  7093. use Symfony\Component\Console\Output\OutputInterface;
  7094. use Composer\Downloader\ChangeReportInterface;
  7095. use Composer\Downloader\DvcsDownloaderInterface;
  7096. use Composer\Downloader\VcsCapableDownloaderInterface;
  7097. use Composer\Package\Dumper\ArrayDumper;
  7098. use Composer\Package\Version\VersionGuesser;
  7099. use Composer\Package\Version\VersionParser;
  7100. use Composer\Plugin\CommandEvent;
  7101. use Composer\Plugin\PluginEvents;
  7102. use Composer\Script\ScriptEvents;
  7103. use Composer\Util\ProcessExecutor;
  7104. class StatusCommand extends BaseCommand
  7105. {
  7106. const EXIT_CODE_ERRORS = 1;
  7107. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  7108. const EXIT_CODE_VERSION_CHANGES = 4;
  7109. protected function configure()
  7110. {
  7111. $this
  7112. ->setName('status')
  7113. ->setDescription('Shows a list of locally modified packages.')
  7114. ->setDefinition(array(
  7115. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  7116. ))
  7117. ->setHelp(
  7118. <<<EOT
  7119. The status command displays a list of dependencies that have
  7120. been modified locally.
  7121. Read more at https://getcomposer.org/doc/03-cli.md#status
  7122. EOT
  7123. )
  7124. ;
  7125. }
  7126. protected function execute(InputInterface $input, OutputInterface $output)
  7127. {
  7128. $composer = $this->getComposer();
  7129. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  7130. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7131. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  7132. $exitCode = $this->doExecute($input);
  7133. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  7134. return $exitCode;
  7135. }
  7136. private function doExecute(InputInterface $input)
  7137. {
  7138. $composer = $this->getComposer();
  7139. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  7140. $dm = $composer->getDownloadManager();
  7141. $im = $composer->getInstallationManager();
  7142. $errors = array();
  7143. $io = $this->getIO();
  7144. $unpushedChanges = array();
  7145. $vcsVersionChanges = array();
  7146. $parser = new VersionParser;
  7147. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  7148. $dumper = new ArrayDumper;
  7149. foreach ($installedRepo->getCanonicalPackages() as $package) {
  7150. $downloader = $dm->getDownloaderForPackage($package);
  7151. $targetDir = $im->getInstallPath($package);
  7152. if ($downloader instanceof ChangeReportInterface) {
  7153. if (is_link($targetDir)) {
  7154. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  7155. }
  7156. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  7157. $errors[$targetDir] = $changes;
  7158. }
  7159. }
  7160. if ($downloader instanceof VcsCapableDownloaderInterface) {
  7161. if ($downloader->getVcsReference($package, $targetDir)) {
  7162. switch ($package->getInstallationSource()) {
  7163. case 'source':
  7164. $previousRef = $package->getSourceReference();
  7165. break;
  7166. case 'dist':
  7167. $previousRef = $package->getDistReference();
  7168. break;
  7169. default:
  7170. $previousRef = null;
  7171. }
  7172. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  7173. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  7174. $vcsVersionChanges[$targetDir] = array(
  7175. 'previous' => array(
  7176. 'version' => $package->getPrettyVersion(),
  7177. 'ref' => $previousRef,
  7178. ),
  7179. 'current' => array(
  7180. 'version' => $currentVersion['pretty_version'],
  7181. 'ref' => $currentVersion['commit'],
  7182. ),
  7183. );
  7184. }
  7185. }
  7186. }
  7187. if ($downloader instanceof DvcsDownloaderInterface) {
  7188. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  7189. $unpushedChanges[$targetDir] = $unpushed;
  7190. }
  7191. }
  7192. }
  7193. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  7194. $io->writeError('<info>No local changes</info>');
  7195. return 0;
  7196. }
  7197. if ($errors) {
  7198. $io->writeError('<error>You have changes in the following dependencies:</error>');
  7199. foreach ($errors as $path => $changes) {
  7200. if ($input->getOption('verbose')) {
  7201. $indentedChanges = implode("\n", array_map(function ($line) {
  7202. return ' ' . ltrim($line);
  7203. }, explode("\n", $changes)));
  7204. $io->write('<info>'.$path.'</info>:');
  7205. $io->write($indentedChanges);
  7206. } else {
  7207. $io->write($path);
  7208. }
  7209. }
  7210. }
  7211. if ($unpushedChanges) {
  7212. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  7213. foreach ($unpushedChanges as $path => $changes) {
  7214. if ($input->getOption('verbose')) {
  7215. $indentedChanges = implode("\n", array_map(function ($line) {
  7216. return ' ' . ltrim($line);
  7217. }, explode("\n", $changes)));
  7218. $io->write('<info>'.$path.'</info>:');
  7219. $io->write($indentedChanges);
  7220. } else {
  7221. $io->write($path);
  7222. }
  7223. }
  7224. }
  7225. if ($vcsVersionChanges) {
  7226. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  7227. foreach ($vcsVersionChanges as $path => $changes) {
  7228. if ($input->getOption('verbose')) {
  7229. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  7230. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  7231. if ($io->isVeryVerbose()) {
  7232. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  7233. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  7234. }
  7235. $io->write('<info>'.$path.'</info>:');
  7236. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  7237. } else {
  7238. $io->write($path);
  7239. }
  7240. }
  7241. }
  7242. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  7243. $io->writeError('Use --verbose (-v) to see a list of files');
  7244. }
  7245. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  7246. }
  7247. }
  7248. <?php
  7249. namespace Composer\Command;
  7250. use Composer\Repository\PlatformRepository;
  7251. use Composer\Repository\RootPackageRepository;
  7252. use Composer\Repository\InstalledRepository;
  7253. use Composer\Installer\SuggestedPackagesReporter;
  7254. use Symfony\Component\Console\Input\InputArgument;
  7255. use Symfony\Component\Console\Input\InputInterface;
  7256. use Symfony\Component\Console\Input\InputOption;
  7257. use Symfony\Component\Console\Output\OutputInterface;
  7258. class SuggestsCommand extends BaseCommand
  7259. {
  7260. protected function configure()
  7261. {
  7262. $this
  7263. ->setName('suggests')
  7264. ->setDescription('Shows package suggestions.')
  7265. ->setDefinition(array(
  7266. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  7267. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  7268. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  7269. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  7270. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  7271. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  7272. ))
  7273. ->setHelp(
  7274. <<<EOT
  7275. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  7276. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  7277. EOT
  7278. )
  7279. ;
  7280. }
  7281. protected function execute(InputInterface $input, OutputInterface $output)
  7282. {
  7283. $composer = $this->getComposer();
  7284. $installedRepos = array(
  7285. new RootPackageRepository(clone $composer->getPackage()),
  7286. );
  7287. $locker = $composer->getLocker();
  7288. if ($locker->isLocked()) {
  7289. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  7290. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7291. } else {
  7292. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  7293. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  7294. }
  7295. $installedRepo = new InstalledRepository($installedRepos);
  7296. $reporter = new SuggestedPackagesReporter($this->getIO());
  7297. $filter = $input->getArgument('packages');
  7298. $packages = $installedRepo->getPackages();
  7299. $packages[] = $composer->getPackage();
  7300. foreach ($packages as $package) {
  7301. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  7302. continue;
  7303. }
  7304. $reporter->addSuggestionsFromPackage($package);
  7305. }
  7306. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7307. if ($input->getOption('by-suggestion')) {
  7308. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  7309. }
  7310. if ($input->getOption('by-package')) {
  7311. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7312. }
  7313. if ($input->getOption('list')) {
  7314. $mode = SuggestedPackagesReporter::MODE_LIST;
  7315. }
  7316. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  7317. return 0;
  7318. }
  7319. }
  7320. <?php
  7321. namespace Composer\Command;
  7322. use Composer\Composer;
  7323. use Composer\DependencyResolver\Request;
  7324. use Composer\Installer;
  7325. use Composer\IO\IOInterface;
  7326. use Composer\Plugin\CommandEvent;
  7327. use Composer\Plugin\PluginEvents;
  7328. use Composer\Package\Version\VersionParser;
  7329. use Composer\Util\HttpDownloader;
  7330. use Composer\Semver\Constraint\MultiConstraint;
  7331. use Composer\Package\Link;
  7332. use Symfony\Component\Console\Helper\Table;
  7333. use Symfony\Component\Console\Input\InputInterface;
  7334. use Symfony\Component\Console\Input\InputOption;
  7335. use Symfony\Component\Console\Input\InputArgument;
  7336. use Symfony\Component\Console\Output\OutputInterface;
  7337. use Symfony\Component\Console\Question\Question;
  7338. class UpdateCommand extends BaseCommand
  7339. {
  7340. protected function configure()
  7341. {
  7342. $this
  7343. ->setName('update')
  7344. ->setAliases(array('u', 'upgrade'))
  7345. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  7346. ->setDefinition(array(
  7347. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  7348. new InputOption('with', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Temporary version constraint to add, e.g. foo/bar:1.0.0 or foo/bar=1.0.0'),
  7349. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  7350. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  7351. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  7352. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  7353. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  7354. new InputOption('lock', null, InputOption::VALUE_NONE, 'Overwrites the lock file hash to suppress warning about the lock file being out of date without updating package versions. Package metadata like mirrors and URLs are updated if they changed.'),
  7355. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  7356. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  7357. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  7358. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  7359. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7360. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  7361. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  7362. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  7363. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  7364. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  7365. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  7366. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  7367. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  7368. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  7369. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  7370. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  7371. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  7372. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  7373. ))
  7374. ->setHelp(
  7375. <<<EOT
  7376. The <info>update</info> command reads the composer.json file from the
  7377. current directory, processes it, and updates, removes or installs all the
  7378. dependencies.
  7379. <info>php composer.phar update</info>
  7380. To limit the update operation to a few packages, you can list the package(s)
  7381. you want to update as such:
  7382. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  7383. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  7384. from a specific vendor:
  7385. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  7386. To run an update with more restrictive constraints you can use:
  7387. <info>php composer.phar update --with vendor/package:1.0.*</info>
  7388. To run a partial update with more restrictive constraints you can use the shorthand:
  7389. <info>php composer.phar update vendor/package:1.0.*</info>
  7390. To select packages names interactively with auto-completion use <info>-i</info>.
  7391. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  7392. EOT
  7393. )
  7394. ;
  7395. }
  7396. protected function execute(InputInterface $input, OutputInterface $output)
  7397. {
  7398. $io = $this->getIO();
  7399. if ($input->getOption('dev')) {
  7400. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  7401. }
  7402. if ($input->getOption('no-suggest')) {
  7403. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  7404. }
  7405. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  7406. if (!HttpDownloader::isCurlEnabled()) {
  7407. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  7408. }
  7409. $packages = $input->getArgument('packages');
  7410. $reqs = $this->formatRequirements($input->getOption('with'));
  7411. if ($packages) {
  7412. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg) {
  7413. return preg_match('{\S+[ =:]\S+}', $pkg) > 0;
  7414. });
  7415. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  7416. $reqs[$package] = $constraint;
  7417. }
  7418. foreach ($allowlistPackagesWithRequirements as $package) {
  7419. $packageName = preg_replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  7420. $index = array_search($package, $packages);
  7421. $packages[$index] = $packageName;
  7422. }
  7423. }
  7424. $rootRequires = $composer->getPackage()->getRequires();
  7425. $rootDevRequires = $composer->getPackage()->getDevRequires();
  7426. foreach ($reqs as $package => $constraint) {
  7427. if (isset($rootRequires[$package])) {
  7428. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  7429. } elseif (isset($rootDevRequires[$package])) {
  7430. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  7431. } else {
  7432. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  7433. }
  7434. }
  7435. $composer->getPackage()->setRequires($rootRequires);
  7436. $composer->getPackage()->setDevRequires($rootDevRequires);
  7437. if ($input->getOption('interactive')) {
  7438. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  7439. }
  7440. if ($input->getOption('root-reqs')) {
  7441. $requires = array_keys($rootRequires);
  7442. if (!$input->getOption('no-dev')) {
  7443. $requires = array_merge($requires, array_keys($rootDevRequires));
  7444. }
  7445. if (!empty($packages)) {
  7446. $packages = array_intersect($packages, $requires);
  7447. } else {
  7448. $packages = $requires;
  7449. }
  7450. }
  7451. $filteredPackages = array_filter($packages, function ($package) {
  7452. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  7453. });
  7454. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  7455. $packages = $filteredPackages;
  7456. if ($updateMirrors && !empty($packages)) {
  7457. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  7458. return -1;
  7459. }
  7460. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  7461. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7462. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7463. $install = Installer::create($io, $composer);
  7464. $config = $composer->getConfig();
  7465. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  7466. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  7467. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  7468. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7469. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  7470. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7471. if ($input->getOption('with-all-dependencies')) {
  7472. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7473. } elseif ($input->getOption('with-dependencies')) {
  7474. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7475. }
  7476. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  7477. $install
  7478. ->setDryRun($input->getOption('dry-run'))
  7479. ->setVerbose($input->getOption('verbose'))
  7480. ->setPreferSource($preferSource)
  7481. ->setPreferDist($preferDist)
  7482. ->setDevMode(!$input->getOption('no-dev'))
  7483. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  7484. ->setRunScripts(!$input->getOption('no-scripts'))
  7485. ->setOptimizeAutoloader($optimize)
  7486. ->setClassMapAuthoritative($authoritative)
  7487. ->setApcuAutoloader($apcu, $apcuPrefix)
  7488. ->setUpdate(true)
  7489. ->setInstall(!$input->getOption('no-install'))
  7490. ->setUpdateMirrors($updateMirrors)
  7491. ->setUpdateAllowList($packages)
  7492. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7493. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  7494. ->setPreferStable($input->getOption('prefer-stable'))
  7495. ->setPreferLowest($input->getOption('prefer-lowest'))
  7496. ;
  7497. if ($input->getOption('no-plugins')) {
  7498. $install->disablePlugins();
  7499. }
  7500. return $install->run();
  7501. }
  7502. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  7503. {
  7504. if (!$input->isInteractive()) {
  7505. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  7506. }
  7507. $requires = array_merge(
  7508. $composer->getPackage()->getRequires(),
  7509. $composer->getPackage()->getDevRequires()
  7510. );
  7511. $autocompleterValues = array();
  7512. foreach ($requires as $require) {
  7513. $target = $require->getTarget();
  7514. $autocompleterValues[strtolower($target)] = $target;
  7515. }
  7516. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  7517. foreach ($installedPackages as $package) {
  7518. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  7519. }
  7520. $helper = $this->getHelper('question');
  7521. $question = new Question('<comment>Enter package name: </comment>', null);
  7522. $io->writeError('<info>Press enter without value to end submission</info>');
  7523. do {
  7524. $autocompleterValues = array_diff($autocompleterValues, $packages);
  7525. $question->setAutocompleterValues($autocompleterValues);
  7526. $addedPackage = $helper->ask($input, $output, $question);
  7527. if (!is_string($addedPackage) || empty($addedPackage)) {
  7528. break;
  7529. }
  7530. $addedPackage = strtolower($addedPackage);
  7531. if (!in_array($addedPackage, $packages)) {
  7532. $packages[] = $addedPackage;
  7533. }
  7534. } while (true);
  7535. $packages = array_filter($packages);
  7536. if (!$packages) {
  7537. throw new \InvalidArgumentException('You must enter minimum one package.');
  7538. }
  7539. $table = new Table($output);
  7540. $table->setHeaders(array('Selected packages'));
  7541. foreach ($packages as $package) {
  7542. $table->addRow(array($package));
  7543. }
  7544. $table->render();
  7545. if ($io->askConfirmation(sprintf(
  7546. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  7547. 1 === count($packages) ? '' : 's'
  7548. ))) {
  7549. return $packages;
  7550. }
  7551. throw new \RuntimeException('Installation aborted.');
  7552. }
  7553. private function appendConstraintToLink(Link $link, $constraint)
  7554. {
  7555. $parser = new VersionParser;
  7556. $oldPrettyString = $link->getConstraint()->getPrettyString();
  7557. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  7558. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  7559. return new Link(
  7560. $link->getSource(),
  7561. $link->getTarget(),
  7562. $newConstraint,
  7563. $link->getDescription(),
  7564. $link->getPrettyConstraint() . ', ' . $constraint
  7565. );
  7566. }
  7567. }
  7568. <?php
  7569. namespace Composer\Command;
  7570. use Composer\Factory;
  7571. use Composer\Package\Loader\ValidatingArrayLoader;
  7572. use Composer\Plugin\CommandEvent;
  7573. use Composer\Plugin\PluginEvents;
  7574. use Composer\Util\ConfigValidator;
  7575. use Symfony\Component\Console\Input\InputArgument;
  7576. use Symfony\Component\Console\Input\InputInterface;
  7577. use Symfony\Component\Console\Input\InputOption;
  7578. use Symfony\Component\Console\Output\OutputInterface;
  7579. class ValidateCommand extends BaseCommand
  7580. {
  7581. protected function configure()
  7582. {
  7583. $this
  7584. ->setName('validate')
  7585. ->setDescription('Validates a composer.json and composer.lock.')
  7586. ->setDefinition(array(
  7587. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  7588. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  7589. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  7590. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  7591. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  7592. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  7593. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  7594. ))
  7595. ->setHelp(
  7596. <<<EOT
  7597. The validate command validates a given composer.json and composer.lock
  7598. Exit codes in case of errors are:
  7599. 1 validation warning(s), only when --strict is given
  7600. 2 validation error(s)
  7601. 3 file unreadable or missing
  7602. Read more at https://getcomposer.org/doc/03-cli.md#validate
  7603. EOT
  7604. );
  7605. }
  7606. protected function execute(InputInterface $input, OutputInterface $output)
  7607. {
  7608. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  7609. $io = $this->getIO();
  7610. if (!file_exists($file)) {
  7611. $io->writeError('<error>' . $file . ' not found.</error>');
  7612. return 3;
  7613. }
  7614. if (!is_readable($file)) {
  7615. $io->writeError('<error>' . $file . ' is not readable.</error>');
  7616. return 3;
  7617. }
  7618. $validator = new ConfigValidator($io);
  7619. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  7620. $checkPublish = !$input->getOption('no-check-publish');
  7621. $checkLock = !$input->getOption('no-check-lock');
  7622. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  7623. $isStrict = $input->getOption('strict');
  7624. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7625. $lockErrors = array();
  7626. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  7627. $locker = $composer->getLocker();
  7628. if ($locker->isLocked() && !$locker->isFresh()) {
  7629. $lockErrors[] = 'The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update` or `composer update <package name>`.';
  7630. }
  7631. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  7632. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7633. if ($input->getOption('with-dependencies')) {
  7634. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7635. foreach ($localRepo->getPackages() as $package) {
  7636. $path = $composer->getInstallationManager()->getInstallPath($package);
  7637. $file = $path . '/composer.json';
  7638. if (is_dir($path) && file_exists($file)) {
  7639. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7640. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  7641. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7642. $exitCode = max($depCode, $exitCode);
  7643. }
  7644. }
  7645. }
  7646. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  7647. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7648. return max($eventCode, $exitCode);
  7649. }
  7650. private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false)
  7651. {
  7652. $doPrintSchemaUrl = false;
  7653. if ($errors) {
  7654. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  7655. } elseif ($publishErrors) {
  7656. $io->writeError('<info>' . $name . ' is valid for simple usage with composer but has</info>');
  7657. $io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
  7658. $doPrintSchemaUrl = $printSchemaUrl;
  7659. } elseif ($warnings) {
  7660. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  7661. $doPrintSchemaUrl = $printSchemaUrl;
  7662. } else {
  7663. $io->write('<info>' . $name . ' is valid</info>');
  7664. }
  7665. if ($doPrintSchemaUrl) {
  7666. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  7667. }
  7668. $extraWarnings = array();
  7669. if ($checkPublish) {
  7670. $errors = array_merge($errors, $publishErrors);
  7671. } else {
  7672. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  7673. }
  7674. if ($checkLock) {
  7675. $errors = array_merge($errors, $lockErrors);
  7676. } else {
  7677. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  7678. }
  7679. $messages = array(
  7680. 'error' => $errors,
  7681. 'warning' => array_merge($warnings, $extraWarnings),
  7682. );
  7683. foreach ($messages as $style => $msgs) {
  7684. foreach ($msgs as $msg) {
  7685. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  7686. }
  7687. }
  7688. }
  7689. }
  7690. <?php
  7691. namespace Composer;
  7692. use Composer\Package\RootPackageInterface;
  7693. use Composer\Package\Locker;
  7694. use Composer\Util\Loop;
  7695. use Composer\Repository\RepositoryManager;
  7696. use Composer\Installer\InstallationManager;
  7697. use Composer\Plugin\PluginManager;
  7698. use Composer\Downloader\DownloadManager;
  7699. use Composer\EventDispatcher\EventDispatcher;
  7700. use Composer\Autoload\AutoloadGenerator;
  7701. use Composer\Package\Archiver\ArchiveManager;
  7702. class Composer
  7703. {
  7704. const VERSION = '2.0.12';
  7705. const BRANCH_ALIAS_VERSION = '';
  7706. const RELEASE_DATE = '2021-04-01 10:14:59';
  7707. const SOURCE_VERSION = '';
  7708. const RUNTIME_API_VERSION = '2.0.0';
  7709. public static function getVersion()
  7710. {
  7711. if (self::VERSION === '@package_version'.'@') {
  7712. return self::SOURCE_VERSION;
  7713. }
  7714. if (self::BRANCH_ALIAS_VERSION !== '' && preg_match('{^[a-f0-9]{40}$}', self::VERSION)) {
  7715. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  7716. }
  7717. return self::VERSION;
  7718. }
  7719. private $package;
  7720. private $locker;
  7721. private $loop;
  7722. private $repositoryManager;
  7723. private $downloadManager;
  7724. private $installationManager;
  7725. private $pluginManager;
  7726. private $config;
  7727. private $eventDispatcher;
  7728. private $autoloadGenerator;
  7729. private $archiveManager;
  7730. public function setPackage(RootPackageInterface $package)
  7731. {
  7732. $this->package = $package;
  7733. }
  7734. public function getPackage()
  7735. {
  7736. return $this->package;
  7737. }
  7738. public function setConfig(Config $config)
  7739. {
  7740. $this->config = $config;
  7741. }
  7742. public function getConfig()
  7743. {
  7744. return $this->config;
  7745. }
  7746. public function setLocker(Locker $locker)
  7747. {
  7748. $this->locker = $locker;
  7749. }
  7750. public function getLocker()
  7751. {
  7752. return $this->locker;
  7753. }
  7754. public function setLoop(Loop $loop)
  7755. {
  7756. $this->loop = $loop;
  7757. }
  7758. public function getLoop()
  7759. {
  7760. return $this->loop;
  7761. }
  7762. public function setRepositoryManager(RepositoryManager $manager)
  7763. {
  7764. $this->repositoryManager = $manager;
  7765. }
  7766. public function getRepositoryManager()
  7767. {
  7768. return $this->repositoryManager;
  7769. }
  7770. public function setDownloadManager(DownloadManager $manager)
  7771. {
  7772. $this->downloadManager = $manager;
  7773. }
  7774. public function getDownloadManager()
  7775. {
  7776. return $this->downloadManager;
  7777. }
  7778. public function setArchiveManager(ArchiveManager $manager)
  7779. {
  7780. $this->archiveManager = $manager;
  7781. }
  7782. public function getArchiveManager()
  7783. {
  7784. return $this->archiveManager;
  7785. }
  7786. public function setInstallationManager(InstallationManager $manager)
  7787. {
  7788. $this->installationManager = $manager;
  7789. }
  7790. public function getInstallationManager()
  7791. {
  7792. return $this->installationManager;
  7793. }
  7794. public function setPluginManager(PluginManager $manager)
  7795. {
  7796. $this->pluginManager = $manager;
  7797. }
  7798. public function getPluginManager()
  7799. {
  7800. return $this->pluginManager;
  7801. }
  7802. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  7803. {
  7804. $this->eventDispatcher = $eventDispatcher;
  7805. }
  7806. public function getEventDispatcher()
  7807. {
  7808. return $this->eventDispatcher;
  7809. }
  7810. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  7811. {
  7812. $this->autoloadGenerator = $autoloadGenerator;
  7813. }
  7814. public function getAutoloadGenerator()
  7815. {
  7816. return $this->autoloadGenerator;
  7817. }
  7818. }
  7819. <?php
  7820. namespace Composer;
  7821. use Composer\Config\ConfigSourceInterface;
  7822. use Composer\Downloader\TransportException;
  7823. use Composer\IO\IOInterface;
  7824. use Composer\Util\Platform;
  7825. use Composer\Util\ProcessExecutor;
  7826. class Config
  7827. {
  7828. const RELATIVE_PATHS = 1;
  7829. public static $defaultConfig = array(
  7830. 'process-timeout' => 300,
  7831. 'use-include-path' => false,
  7832. 'preferred-install' => 'auto',
  7833. 'notify-on-install' => true,
  7834. 'github-protocols' => array('https', 'ssh', 'git'),
  7835. 'vendor-dir' => 'vendor',
  7836. 'bin-dir' => '{$vendor-dir}/bin',
  7837. 'cache-dir' => '{$home}/cache',
  7838. 'data-dir' => '{$home}',
  7839. 'cache-files-dir' => '{$cache-dir}/files',
  7840. 'cache-repo-dir' => '{$cache-dir}/repo',
  7841. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  7842. 'cache-ttl' => 15552000,
  7843. 'cache-files-ttl' => null,
  7844. 'cache-files-maxsize' => '300MiB',
  7845. 'cache-read-only' => false,
  7846. 'bin-compat' => 'auto',
  7847. 'discard-changes' => false,
  7848. 'autoloader-suffix' => null,
  7849. 'sort-packages' => false,
  7850. 'optimize-autoloader' => false,
  7851. 'classmap-authoritative' => false,
  7852. 'apcu-autoloader' => false,
  7853. 'prepend-autoloader' => true,
  7854. 'github-domains' => array('github.com'),
  7855. 'bitbucket-expose-hostname' => true,
  7856. 'disable-tls' => false,
  7857. 'secure-http' => true,
  7858. 'cafile' => null,
  7859. 'capath' => null,
  7860. 'github-expose-hostname' => true,
  7861. 'gitlab-domains' => array('gitlab.com'),
  7862. 'store-auths' => 'prompt',
  7863. 'platform' => array(),
  7864. 'archive-format' => 'tar',
  7865. 'archive-dir' => '.',
  7866. 'htaccess-protect' => true,
  7867. 'use-github-api' => true,
  7868. 'lock' => true,
  7869. 'platform-check' => 'php-only',
  7870. );
  7871. public static $defaultRepositories = array(
  7872. 'packagist.org' => array(
  7873. 'type' => 'composer',
  7874. 'url' => 'https://repo.packagist.org',
  7875. ),
  7876. );
  7877. private $config;
  7878. private $baseDir;
  7879. private $repositories;
  7880. private $configSource;
  7881. private $authConfigSource;
  7882. private $useEnvironment;
  7883. private $warnedHosts = array();
  7884. public function __construct($useEnvironment = true, $baseDir = null)
  7885. {
  7886. $this->config = static::$defaultConfig;
  7887. $this->repositories = static::$defaultRepositories;
  7888. $this->useEnvironment = (bool) $useEnvironment;
  7889. $this->baseDir = $baseDir;
  7890. }
  7891. public function setConfigSource(ConfigSourceInterface $source)
  7892. {
  7893. $this->configSource = $source;
  7894. }
  7895. public function getConfigSource()
  7896. {
  7897. return $this->configSource;
  7898. }
  7899. public function setAuthConfigSource(ConfigSourceInterface $source)
  7900. {
  7901. $this->authConfigSource = $source;
  7902. }
  7903. public function getAuthConfigSource()
  7904. {
  7905. return $this->authConfigSource;
  7906. }
  7907. public function merge($config)
  7908. {
  7909. if (!empty($config['config']) && is_array($config['config'])) {
  7910. foreach ($config['config'] as $key => $val) {
  7911. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer')) && isset($this->config[$key])) {
  7912. $this->config[$key] = array_merge($this->config[$key], $val);
  7913. } elseif (in_array($key, array('gitlab-domains', 'github-domains')) && isset($this->config[$key])) {
  7914. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  7915. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  7916. if (is_array($val) || is_array($this->config[$key])) {
  7917. if (is_string($val)) {
  7918. $val = array('*' => $val);
  7919. }
  7920. if (is_string($this->config[$key])) {
  7921. $this->config[$key] = array('*' => $this->config[$key]);
  7922. }
  7923. $this->config[$key] = array_merge($this->config[$key], $val);
  7924. if (isset($this->config[$key]['*'])) {
  7925. $wildcard = $this->config[$key]['*'];
  7926. unset($this->config[$key]['*']);
  7927. $this->config[$key]['*'] = $wildcard;
  7928. }
  7929. } else {
  7930. $this->config[$key] = $val;
  7931. }
  7932. } else {
  7933. $this->config[$key] = $val;
  7934. }
  7935. }
  7936. }
  7937. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  7938. $this->repositories = array_reverse($this->repositories, true);
  7939. $newRepos = array_reverse($config['repositories'], true);
  7940. foreach ($newRepos as $name => $repository) {
  7941. if (false === $repository) {
  7942. $this->disableRepoByName($name);
  7943. continue;
  7944. }
  7945. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  7946. $this->disableRepoByName(key($repository));
  7947. continue;
  7948. }
  7949. if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && preg_match('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
  7950. $this->disableRepoByName('packagist.org');
  7951. }
  7952. if (is_int($name)) {
  7953. $this->repositories[] = $repository;
  7954. } else {
  7955. if ($name === 'packagist') {
  7956. $this->repositories[$name . '.org'] = $repository;
  7957. } else {
  7958. $this->repositories[$name] = $repository;
  7959. }
  7960. }
  7961. }
  7962. $this->repositories = array_reverse($this->repositories, true);
  7963. }
  7964. }
  7965. public function getRepositories()
  7966. {
  7967. return $this->repositories;
  7968. }
  7969. public function get($key, $flags = 0)
  7970. {
  7971. switch ($key) {
  7972. case 'vendor-dir':
  7973. case 'bin-dir':
  7974. case 'process-timeout':
  7975. case 'data-dir':
  7976. case 'cache-dir':
  7977. case 'cache-files-dir':
  7978. case 'cache-repo-dir':
  7979. case 'cache-vcs-dir':
  7980. case 'cafile':
  7981. case 'capath':
  7982. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7983. $val = $this->getComposerEnv($env);
  7984. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  7985. $val = Platform::expandPath($val);
  7986. if (substr($key, -4) !== '-dir') {
  7987. return $val;
  7988. }
  7989. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  7990. case 'cache-read-only':
  7991. case 'htaccess-protect':
  7992. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7993. $val = $this->getComposerEnv($env);
  7994. if (false === $val) {
  7995. $val = $this->config[$key];
  7996. }
  7997. return $val !== 'false' && (bool) $val;
  7998. case 'disable-tls':
  7999. case 'secure-http':
  8000. case 'use-github-api':
  8001. case 'lock':
  8002. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  8003. return false;
  8004. }
  8005. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  8006. case 'cache-ttl':
  8007. return (int) $this->config[$key];
  8008. case 'cache-files-maxsize':
  8009. if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  8010. throw new \RuntimeException(
  8011. "Could not parse the value of '$key': {$this->config[$key]}"
  8012. );
  8013. }
  8014. $size = $matches[1];
  8015. if (isset($matches[2])) {
  8016. switch (strtolower($matches[2])) {
  8017. case 'g':
  8018. $size *= 1024;
  8019. case 'm':
  8020. $size *= 1024;
  8021. case 'k':
  8022. $size *= 1024;
  8023. break;
  8024. }
  8025. }
  8026. return $size;
  8027. case 'cache-files-ttl':
  8028. if (isset($this->config[$key])) {
  8029. return (int) $this->config[$key];
  8030. }
  8031. return (int) $this->config['cache-ttl'];
  8032. case 'home':
  8033. $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  8034. return rtrim($this->process($val, $flags), '/\\');
  8035. case 'bin-compat':
  8036. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  8037. if (!in_array($value, array('auto', 'full'))) {
  8038. throw new \RuntimeException(
  8039. "Invalid value for 'bin-compat': {$value}. Expected auto, full"
  8040. );
  8041. }
  8042. return $value;
  8043. case 'discard-changes':
  8044. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  8045. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  8046. throw new \RuntimeException(
  8047. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  8048. );
  8049. }
  8050. if ('stash' === $env) {
  8051. return 'stash';
  8052. }
  8053. return $env !== 'false' && (bool) $env;
  8054. }
  8055. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  8056. throw new \RuntimeException(
  8057. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  8058. );
  8059. }
  8060. return $this->config[$key];
  8061. case 'github-protocols':
  8062. $protos = $this->config['github-protocols'];
  8063. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  8064. unset($protos[$index]);
  8065. }
  8066. if (reset($protos) === 'http') {
  8067. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  8068. }
  8069. return $protos;
  8070. default:
  8071. if (!isset($this->config[$key])) {
  8072. return null;
  8073. }
  8074. return $this->process($this->config[$key], $flags);
  8075. }
  8076. }
  8077. public function all($flags = 0)
  8078. {
  8079. $all = array(
  8080. 'repositories' => $this->getRepositories(),
  8081. );
  8082. foreach (array_keys($this->config) as $key) {
  8083. $all['config'][$key] = $this->get($key, $flags);
  8084. }
  8085. return $all;
  8086. }
  8087. public function raw()
  8088. {
  8089. return array(
  8090. 'repositories' => $this->getRepositories(),
  8091. 'config' => $this->config,
  8092. );
  8093. }
  8094. public function has($key)
  8095. {
  8096. return array_key_exists($key, $this->config);
  8097. }
  8098. private function process($value, $flags)
  8099. {
  8100. $config = $this;
  8101. if (!is_string($value)) {
  8102. return $value;
  8103. }
  8104. return preg_replace_callback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  8105. return $config->get($match[1], $flags);
  8106. }, $value);
  8107. }
  8108. private function realpath($path)
  8109. {
  8110. if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  8111. return $path;
  8112. }
  8113. return $this->baseDir . '/' . $path;
  8114. }
  8115. private function getComposerEnv($var)
  8116. {
  8117. if ($this->useEnvironment) {
  8118. return getenv($var);
  8119. }
  8120. return false;
  8121. }
  8122. private function disableRepoByName($name)
  8123. {
  8124. if (isset($this->repositories[$name])) {
  8125. unset($this->repositories[$name]);
  8126. } elseif ($name === 'packagist') {
  8127. unset($this->repositories['packagist.org']);
  8128. }
  8129. }
  8130. public function prohibitUrlByConfig($url, IOInterface $io = null)
  8131. {
  8132. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  8133. return;
  8134. }
  8135. $scheme = parse_url($url, PHP_URL_SCHEME);
  8136. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  8137. if ($this->get('secure-http')) {
  8138. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  8139. }
  8140. if ($io) {
  8141. $host = parse_url($url, PHP_URL_HOST);
  8142. if (!isset($this->warnedHosts[$host])) {
  8143. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  8144. }
  8145. $this->warnedHosts[$host] = true;
  8146. }
  8147. }
  8148. }
  8149. public static function disableProcessTimeout()
  8150. {
  8151. ProcessExecutor::setTimeout(0);
  8152. }
  8153. }
  8154. <?php
  8155. namespace Composer\Config;
  8156. interface ConfigSourceInterface
  8157. {
  8158. public function addRepository($name, $config, $append = true);
  8159. public function removeRepository($name);
  8160. public function addConfigSetting($name, $value);
  8161. public function removeConfigSetting($name);
  8162. public function addProperty($name, $value);
  8163. public function removeProperty($name);
  8164. public function addLink($type, $name, $value);
  8165. public function removeLink($type, $name);
  8166. public function getName();
  8167. }
  8168. <?php
  8169. namespace Composer\Config;
  8170. use Composer\Json\JsonFile;
  8171. use Composer\Json\JsonManipulator;
  8172. use Composer\Json\JsonValidationException;
  8173. use Composer\Util\Silencer;
  8174. class JsonConfigSource implements ConfigSourceInterface
  8175. {
  8176. private $file;
  8177. private $authConfig;
  8178. public function __construct(JsonFile $file, $authConfig = false)
  8179. {
  8180. $this->file = $file;
  8181. $this->authConfig = $authConfig;
  8182. }
  8183. public function getName()
  8184. {
  8185. return $this->file->getPath();
  8186. }
  8187. public function addRepository($name, $config, $append = true)
  8188. {
  8189. $this->manipulateJson('addRepository', $name, $config, $append, function (&$config, $repo, $repoConfig) use ($append) {
  8190. if (isset($config['repositories'])) {
  8191. foreach ($config['repositories'] as $index => $val) {
  8192. if ($index === $repo) {
  8193. continue;
  8194. }
  8195. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  8196. unset($config['repositories'][$index]);
  8197. $config['repositories']['packagist.org'] = false;
  8198. break;
  8199. }
  8200. }
  8201. }
  8202. if ($append) {
  8203. $config['repositories'][$repo] = $repoConfig;
  8204. } else {
  8205. $config['repositories'] = array($repo => $repoConfig) + $config['repositories'];
  8206. }
  8207. });
  8208. }
  8209. public function removeRepository($name)
  8210. {
  8211. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  8212. unset($config['repositories'][$repo]);
  8213. });
  8214. }
  8215. public function addConfigSetting($name, $value)
  8216. {
  8217. $authConfig = $this->authConfig;
  8218. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  8219. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8220. list($key, $host) = explode('.', $key, 2);
  8221. if ($authConfig) {
  8222. $config[$key][$host] = $val;
  8223. } else {
  8224. $config['config'][$key][$host] = $val;
  8225. }
  8226. } else {
  8227. $config['config'][$key] = $val;
  8228. }
  8229. });
  8230. }
  8231. public function removeConfigSetting($name)
  8232. {
  8233. $authConfig = $this->authConfig;
  8234. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  8235. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8236. list($key, $host) = explode('.', $key, 2);
  8237. if ($authConfig) {
  8238. unset($config[$key][$host]);
  8239. } else {
  8240. unset($config['config'][$key][$host]);
  8241. }
  8242. } else {
  8243. unset($config['config'][$key]);
  8244. }
  8245. });
  8246. }
  8247. public function addProperty($name, $value)
  8248. {
  8249. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  8250. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8251. $bits = explode('.', $key);
  8252. $last = array_pop($bits);
  8253. $arr = &$config[reset($bits)];
  8254. foreach ($bits as $bit) {
  8255. if (!isset($arr[$bit])) {
  8256. $arr[$bit] = array();
  8257. }
  8258. $arr = &$arr[$bit];
  8259. }
  8260. $arr[$last] = $val;
  8261. } else {
  8262. $config[$key] = $val;
  8263. }
  8264. });
  8265. }
  8266. public function removeProperty($name)
  8267. {
  8268. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  8269. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8270. $bits = explode('.', $key);
  8271. $last = array_pop($bits);
  8272. $arr = &$config[reset($bits)];
  8273. foreach ($bits as $bit) {
  8274. if (!isset($arr[$bit])) {
  8275. return;
  8276. }
  8277. $arr = &$arr[$bit];
  8278. }
  8279. unset($arr[$last]);
  8280. } else {
  8281. unset($config[$key]);
  8282. }
  8283. });
  8284. }
  8285. public function addLink($type, $name, $value)
  8286. {
  8287. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  8288. $config[$type][$name] = $value;
  8289. });
  8290. }
  8291. public function removeLink($type, $name)
  8292. {
  8293. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  8294. unset($config[$type][$name]);
  8295. });
  8296. $this->manipulateJson('removeMainKeyIfEmpty', $type, function (&$config, $type) {
  8297. if (0 === count($config[$type])) {
  8298. unset($config[$type]);
  8299. }
  8300. });
  8301. }
  8302. protected function manipulateJson($method, $args, $fallback)
  8303. {
  8304. $args = func_get_args();
  8305. array_shift($args);
  8306. $fallback = array_pop($args);
  8307. if ($this->file->exists()) {
  8308. if (!is_writable($this->file->getPath())) {
  8309. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  8310. }
  8311. if (!is_readable($this->file->getPath())) {
  8312. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  8313. }
  8314. $contents = file_get_contents($this->file->getPath());
  8315. } elseif ($this->authConfig) {
  8316. $contents = "{\n}\n";
  8317. } else {
  8318. $contents = "{\n \"config\": {\n }\n}\n";
  8319. }
  8320. $manipulator = new JsonManipulator($contents);
  8321. $newFile = !$this->file->exists();
  8322. if ($this->authConfig && $method === 'addConfigSetting') {
  8323. $method = 'addSubNode';
  8324. list($mainNode, $name) = explode('.', $args[0], 2);
  8325. $args = array($mainNode, $name, $args[1]);
  8326. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  8327. $method = 'removeSubNode';
  8328. list($mainNode, $name) = explode('.', $args[0], 2);
  8329. $args = array($mainNode, $name);
  8330. }
  8331. if (call_user_func_array(array($manipulator, $method), $args)) {
  8332. file_put_contents($this->file->getPath(), $manipulator->getContents());
  8333. } else {
  8334. $config = $this->file->read();
  8335. $this->arrayUnshiftRef($args, $config);
  8336. call_user_func_array($fallback, $args);
  8337. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support') as $prop) {
  8338. if (isset($config[$prop]) && $config[$prop] === array()) {
  8339. $config[$prop] = new \stdClass;
  8340. }
  8341. }
  8342. foreach (array('psr-0', 'psr-4') as $prop) {
  8343. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === array()) {
  8344. $config['autoload'][$prop] = new \stdClass;
  8345. }
  8346. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === array()) {
  8347. $config['autoload-dev'][$prop] = new \stdClass;
  8348. }
  8349. }
  8350. foreach (array('platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install') as $prop) {
  8351. if (isset($config['config'][$prop]) && $config['config'][$prop] === array()) {
  8352. $config['config'][$prop] = new \stdClass;
  8353. }
  8354. }
  8355. $this->file->write($config);
  8356. }
  8357. try {
  8358. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  8359. } catch (JsonValidationException $e) {
  8360. file_put_contents($this->file->getPath(), $contents);
  8361. throw new \RuntimeException('Failed to update composer.json with a valid format, reverting to the original content. Please report an issue to us with details (command you run and a copy of your composer.json).', 0, $e);
  8362. }
  8363. if ($newFile) {
  8364. Silencer::call('chmod', $this->file->getPath(), 0600);
  8365. }
  8366. }
  8367. private function arrayUnshiftRef(&$array, &$value)
  8368. {
  8369. $return = array_unshift($array, '');
  8370. $array[0] = &$value;
  8371. return $return;
  8372. }
  8373. }
  8374. <?php
  8375. namespace Composer\Console;
  8376. use Composer\IO\NullIO;
  8377. use Composer\Util\Platform;
  8378. use Composer\Util\Silencer;
  8379. use Symfony\Component\Console\Application as BaseApplication;
  8380. use Symfony\Component\Console\Exception\CommandNotFoundException;
  8381. use Symfony\Component\Console\Helper\HelperSet;
  8382. use Symfony\Component\Console\Helper\QuestionHelper;
  8383. use Symfony\Component\Console\Input\InputInterface;
  8384. use Symfony\Component\Console\Input\InputOption;
  8385. use Symfony\Component\Console\Output\OutputInterface;
  8386. use Seld\JsonLint\ParsingException;
  8387. use Composer\Command;
  8388. use Composer\Composer;
  8389. use Composer\Factory;
  8390. use Composer\IO\IOInterface;
  8391. use Composer\IO\ConsoleIO;
  8392. use Composer\Json\JsonValidationException;
  8393. use Composer\Util\ErrorHandler;
  8394. use Composer\Util\HttpDownloader;
  8395. use Composer\EventDispatcher\ScriptExecutionException;
  8396. use Composer\Exception\NoSslException;
  8397. class Application extends BaseApplication
  8398. {
  8399. protected $composer;
  8400. protected $io;
  8401. private static $logo = ' ______
  8402. / ____/___ ____ ___ ____ ____ ________ _____
  8403. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  8404. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  8405. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  8406. /_/
  8407. ';
  8408. private $hasPluginCommands = false;
  8409. private $disablePluginsByDefault = false;
  8410. private $initialWorkingDirectory;
  8411. public function __construct()
  8412. {
  8413. static $shutdownRegistered = false;
  8414. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  8415. ini_set('xdebug.show_exception_trace', false);
  8416. ini_set('xdebug.scream', false);
  8417. }
  8418. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  8419. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  8420. }
  8421. if (!$shutdownRegistered) {
  8422. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  8423. pcntl_async_signals(true);
  8424. pcntl_signal(SIGINT, function ($sig) {
  8425. exit(130);
  8426. });
  8427. }
  8428. $shutdownRegistered = true;
  8429. register_shutdown_function(function () {
  8430. $lastError = error_get_last();
  8431. if ($lastError && $lastError['message'] &&
  8432. (strpos($lastError['message'], 'Allowed memory') !== false ||
  8433. strpos($lastError['message'], 'exceeded memory') !== false )) {
  8434. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  8435. }
  8436. });
  8437. }
  8438. $this->io = new NullIO();
  8439. $this->initialWorkingDirectory = getcwd();
  8440. parent::__construct('Composer', Composer::getVersion());
  8441. }
  8442. public function run(InputInterface $input = null, OutputInterface $output = null)
  8443. {
  8444. if (null === $output) {
  8445. $output = Factory::createOutput();
  8446. }
  8447. return parent::run($input, $output);
  8448. }
  8449. public function doRun(InputInterface $input, OutputInterface $output)
  8450. {
  8451. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  8452. if (getenv('COMPOSER_NO_INTERACTION') || !Platform::isTty(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'))) {
  8453. $input->setInteractive(false);
  8454. }
  8455. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  8456. new QuestionHelper(),
  8457. )));
  8458. ErrorHandler::register($io);
  8459. if ($input->hasParameterOption('--no-cache')) {
  8460. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  8461. $_SERVER['COMPOSER_CACHE_DIR'] = Platform::isWindows() ? 'nul' : '/dev/null';
  8462. putenv('COMPOSER_CACHE_DIR='.$_SERVER['COMPOSER_CACHE_DIR']);
  8463. }
  8464. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  8465. $oldWorkingDir = getcwd();
  8466. chdir($newWorkDir);
  8467. $this->initialWorkingDirectory = $newWorkDir;
  8468. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  8469. }
  8470. $commandName = '';
  8471. if ($name = $this->getCommandName($input)) {
  8472. try {
  8473. $commandName = $this->find($name)->getName();
  8474. } catch (CommandNotFoundException $e) {
  8475. $commandName = false;
  8476. } catch (\InvalidArgumentException $e) {
  8477. }
  8478. }
  8479. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile())) {
  8480. $dir = dirname(getcwd());
  8481. $home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
  8482. while (dirname($dir) !== $dir && $dir !== $home) {
  8483. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  8484. if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  8485. $oldWorkingDir = getcwd();
  8486. chdir($dir);
  8487. }
  8488. break;
  8489. }
  8490. $dir = dirname($dir);
  8491. }
  8492. }
  8493. if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) {
  8494. try {
  8495. foreach ($this->getPluginCommands() as $command) {
  8496. if ($this->has($command->getName())) {
  8497. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  8498. } else {
  8499. $this->add($command);
  8500. }
  8501. }
  8502. } catch (NoSslException $e) {
  8503. } catch (ParsingException $e) {
  8504. $details = $e->getDetails();
  8505. $file = realpath(Factory::getComposerFile());
  8506. $line = null;
  8507. if ($details && isset($details['line'])) {
  8508. $line = $details['line'];
  8509. }
  8510. $ghe = new GithubActionError($this->io);
  8511. $ghe->emit($e->getMessage(), $file, $line);
  8512. throw $e;
  8513. }
  8514. $this->hasPluginCommands = true;
  8515. }
  8516. $isProxyCommand = false;
  8517. if ($name = $this->getCommandName($input)) {
  8518. try {
  8519. $command = $this->find($name);
  8520. $commandName = $command->getName();
  8521. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  8522. } catch (\InvalidArgumentException $e) {
  8523. }
  8524. }
  8525. if (!$isProxyCommand) {
  8526. $io->writeError(sprintf(
  8527. 'Running %s (%s) with %s on %s',
  8528. Composer::getVersion(),
  8529. Composer::RELEASE_DATE,
  8530. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  8531. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  8532. ), true, IOInterface::DEBUG);
  8533. if (PHP_VERSION_ID < 50302) {
  8534. $io->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
  8535. }
  8536. if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  8537. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  8538. }
  8539. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  8540. $io->writeError(sprintf('<warning>Warning: This development build of Composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
  8541. }
  8542. if (
  8543. !Platform::isWindows()
  8544. && function_exists('exec')
  8545. && !getenv('COMPOSER_ALLOW_SUPERUSER')
  8546. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  8547. ) {
  8548. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  8549. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  8550. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  8551. if ($io->isInteractive()) {
  8552. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  8553. return 1;
  8554. }
  8555. }
  8556. }
  8557. if ($uid = (int) getenv('SUDO_UID')) {
  8558. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  8559. }
  8560. }
  8561. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  8562. }
  8563. Silencer::call(function () use ($io) {
  8564. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  8565. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  8566. $io->writeError(sprintf('<error>PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini</error>', sys_get_temp_dir()));
  8567. }
  8568. });
  8569. $file = Factory::getComposerFile();
  8570. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  8571. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  8572. foreach ($composer['scripts'] as $script => $dummy) {
  8573. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  8574. if ($this->has($script)) {
  8575. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  8576. } else {
  8577. $description = null;
  8578. if (isset($composer['scripts-descriptions'][$script])) {
  8579. $description = $composer['scripts-descriptions'][$script];
  8580. }
  8581. $this->add(new Command\ScriptAliasCommand($script, $description));
  8582. }
  8583. }
  8584. }
  8585. }
  8586. }
  8587. }
  8588. try {
  8589. if ($input->hasParameterOption('--profile')) {
  8590. $startTime = microtime(true);
  8591. $this->io->enableDebugging($startTime);
  8592. }
  8593. $result = parent::doRun($input, $output);
  8594. if (isset($oldWorkingDir)) {
  8595. Silencer::call('chdir', $oldWorkingDir);
  8596. }
  8597. if (isset($startTime)) {
  8598. $io->writeError('<info>Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MiB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MiB), time: '.round(microtime(true) - $startTime, 2).'s');
  8599. }
  8600. restore_error_handler();
  8601. return $result;
  8602. } catch (ScriptExecutionException $e) {
  8603. return (int) $e->getCode();
  8604. } catch (\Exception $e) {
  8605. $ghe = new GithubActionError($this->io);
  8606. $ghe->emit($e->getMessage());
  8607. $this->hintCommonErrors($e);
  8608. restore_error_handler();
  8609. throw $e;
  8610. }
  8611. }
  8612. private function getNewWorkingDir(InputInterface $input)
  8613. {
  8614. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  8615. if (false !== $workingDir && !is_dir($workingDir)) {
  8616. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  8617. }
  8618. return $workingDir;
  8619. }
  8620. private function hintCommonErrors($exception)
  8621. {
  8622. $io = $this->getIO();
  8623. Silencer::suppress();
  8624. try {
  8625. $composer = $this->getComposer(false, true);
  8626. if ($composer) {
  8627. $config = $composer->getConfig();
  8628. $minSpaceFree = 1024 * 1024;
  8629. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  8630. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  8631. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  8632. ) {
  8633. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  8634. }
  8635. }
  8636. } catch (\Exception $e) {
  8637. }
  8638. Silencer::restore();
  8639. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  8640. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  8641. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>', true, IOInterface::QUIET);
  8642. }
  8643. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  8644. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  8645. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  8646. }
  8647. if ($hints = HttpDownloader::getExceptionHints($exception)) {
  8648. foreach ($hints as $hint) {
  8649. $io->writeError($hint, true, IOInterface::QUIET);
  8650. }
  8651. }
  8652. }
  8653. public function getComposer($required = true, $disablePlugins = null)
  8654. {
  8655. if (null === $disablePlugins) {
  8656. $disablePlugins = $this->disablePluginsByDefault;
  8657. }
  8658. if (null === $this->composer) {
  8659. try {
  8660. $this->composer = Factory::create($this->io, null, $disablePlugins);
  8661. } catch (\InvalidArgumentException $e) {
  8662. if ($required) {
  8663. $this->io->writeError($e->getMessage());
  8664. exit(1);
  8665. }
  8666. } catch (JsonValidationException $e) {
  8667. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  8668. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  8669. throw new JsonValidationException($message);
  8670. }
  8671. }
  8672. return $this->composer;
  8673. }
  8674. public function resetComposer()
  8675. {
  8676. $this->composer = null;
  8677. if ($this->getIO() && method_exists($this->getIO(), 'resetAuthentications')) {
  8678. $this->getIO()->resetAuthentications();
  8679. }
  8680. }
  8681. public function getIO()
  8682. {
  8683. return $this->io;
  8684. }
  8685. public function getHelp()
  8686. {
  8687. return self::$logo . parent::getHelp();
  8688. }
  8689. protected function getDefaultCommands()
  8690. {
  8691. $commands = array_merge(parent::getDefaultCommands(), array(
  8692. new Command\AboutCommand(),
  8693. new Command\ConfigCommand(),
  8694. new Command\DependsCommand(),
  8695. new Command\ProhibitsCommand(),
  8696. new Command\InitCommand(),
  8697. new Command\InstallCommand(),
  8698. new Command\CreateProjectCommand(),
  8699. new Command\UpdateCommand(),
  8700. new Command\SearchCommand(),
  8701. new Command\ValidateCommand(),
  8702. new Command\ShowCommand(),
  8703. new Command\SuggestsCommand(),
  8704. new Command\RequireCommand(),
  8705. new Command\DumpAutoloadCommand(),
  8706. new Command\StatusCommand(),
  8707. new Command\ArchiveCommand(),
  8708. new Command\DiagnoseCommand(),
  8709. new Command\RunScriptCommand(),
  8710. new Command\LicensesCommand(),
  8711. new Command\GlobalCommand(),
  8712. new Command\ClearCacheCommand(),
  8713. new Command\RemoveCommand(),
  8714. new Command\HomeCommand(),
  8715. new Command\ExecCommand(),
  8716. new Command\OutdatedCommand(),
  8717. new Command\CheckPlatformReqsCommand(),
  8718. new Command\FundCommand(),
  8719. ));
  8720. if (strpos(__FILE__, 'phar:') === 0) {
  8721. $commands[] = new Command\SelfUpdateCommand();
  8722. }
  8723. return $commands;
  8724. }
  8725. public function getLongVersion()
  8726. {
  8727. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  8728. return sprintf(
  8729. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  8730. $this->getName(),
  8731. Composer::BRANCH_ALIAS_VERSION,
  8732. $this->getVersion(),
  8733. Composer::RELEASE_DATE
  8734. );
  8735. }
  8736. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  8737. }
  8738. protected function getDefaultInputDefinition()
  8739. {
  8740. $definition = parent::getDefaultInputDefinition();
  8741. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  8742. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  8743. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  8744. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  8745. return $definition;
  8746. }
  8747. private function getPluginCommands()
  8748. {
  8749. $commands = array();
  8750. $composer = $this->getComposer(false, false);
  8751. if (null === $composer) {
  8752. $composer = Factory::createGlobal($this->io);
  8753. }
  8754. if (null !== $composer) {
  8755. $pm = $composer->getPluginManager();
  8756. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  8757. $newCommands = $capability->getCommands();
  8758. if (!is_array($newCommands)) {
  8759. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  8760. }
  8761. foreach ($newCommands as $command) {
  8762. if (!$command instanceof Command\BaseCommand) {
  8763. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  8764. }
  8765. }
  8766. $commands = array_merge($commands, $newCommands);
  8767. }
  8768. }
  8769. return $commands;
  8770. }
  8771. public function getInitialWorkingDirectory()
  8772. {
  8773. return $this->initialWorkingDirectory;
  8774. }
  8775. }
  8776. <?php
  8777. namespace Composer\Console;
  8778. use Composer\IO\IOInterface;
  8779. final class GithubActionError
  8780. {
  8781. protected $io;
  8782. public function __construct(IOInterface $io)
  8783. {
  8784. $this->io = $io;
  8785. }
  8786. public function emit($message, $file = null, $line = null)
  8787. {
  8788. if (getenv('GITHUB_ACTIONS') && !getenv('COMPOSER_TESTS_ARE_RUNNING')) {
  8789. $message = str_replace("\n", '%0A', $message);
  8790. if ($file && $line) {
  8791. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  8792. } elseif ($file) {
  8793. $this->io->write("::error file=". $file ."::". $message);
  8794. } else {
  8795. $this->io->write("::error ::". $message);
  8796. }
  8797. }
  8798. }
  8799. }
  8800. <?php
  8801. namespace Composer\Console;
  8802. use Symfony\Component\Console\Formatter\OutputFormatter;
  8803. class HtmlOutputFormatter extends OutputFormatter
  8804. {
  8805. private static $availableForegroundColors = array(
  8806. 30 => 'black',
  8807. 31 => 'red',
  8808. 32 => 'green',
  8809. 33 => 'yellow',
  8810. 34 => 'blue',
  8811. 35 => 'magenta',
  8812. 36 => 'cyan',
  8813. 37 => 'white',
  8814. );
  8815. private static $availableBackgroundColors = array(
  8816. 40 => 'black',
  8817. 41 => 'red',
  8818. 42 => 'green',
  8819. 43 => 'yellow',
  8820. 44 => 'blue',
  8821. 45 => 'magenta',
  8822. 46 => 'cyan',
  8823. 47 => 'white',
  8824. );
  8825. private static $availableOptions = array(
  8826. 1 => 'bold',
  8827. 4 => 'underscore',
  8828. );
  8829. public function __construct(array $styles = array())
  8830. {
  8831. parent::__construct(true, $styles);
  8832. }
  8833. public function format($message)
  8834. {
  8835. $formatted = parent::format($message);
  8836. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  8837. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  8838. }
  8839. private function formatHtml($matches)
  8840. {
  8841. $out = '<span style="';
  8842. foreach (explode(';', $matches[1]) as $code) {
  8843. if (isset(self::$availableForegroundColors[$code])) {
  8844. $out .= 'color:'.self::$availableForegroundColors[$code].';';
  8845. } elseif (isset(self::$availableBackgroundColors[$code])) {
  8846. $out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
  8847. } elseif (isset(self::$availableOptions[$code])) {
  8848. switch (self::$availableOptions[$code]) {
  8849. case 'bold':
  8850. $out .= 'font-weight:bold;';
  8851. break;
  8852. case 'underscore':
  8853. $out .= 'text-decoration:underline;';
  8854. break;
  8855. }
  8856. }
  8857. }
  8858. return $out.'">'.$matches[2].'</span>';
  8859. }
  8860. }
  8861. <?php
  8862. namespace Composer\DependencyResolver;
  8863. class Decisions implements \Iterator, \Countable
  8864. {
  8865. const DECISION_LITERAL = 0;
  8866. const DECISION_REASON = 1;
  8867. protected $pool;
  8868. protected $decisionMap;
  8869. protected $decisionQueue = array();
  8870. public function __construct($pool)
  8871. {
  8872. $this->pool = $pool;
  8873. $this->decisionMap = array();
  8874. }
  8875. public function decide($literal, $level, $why)
  8876. {
  8877. $this->addDecision($literal, $level);
  8878. $this->decisionQueue[] = array(
  8879. self::DECISION_LITERAL => $literal,
  8880. self::DECISION_REASON => $why,
  8881. );
  8882. }
  8883. public function satisfy($literal)
  8884. {
  8885. $packageId = abs($literal);
  8886. return (
  8887. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  8888. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  8889. );
  8890. }
  8891. public function conflict($literal)
  8892. {
  8893. $packageId = abs($literal);
  8894. return (
  8895. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  8896. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  8897. );
  8898. }
  8899. public function decided($literalOrPackageId)
  8900. {
  8901. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  8902. }
  8903. public function undecided($literalOrPackageId)
  8904. {
  8905. return empty($this->decisionMap[abs($literalOrPackageId)]);
  8906. }
  8907. public function decidedInstall($literalOrPackageId)
  8908. {
  8909. $packageId = abs($literalOrPackageId);
  8910. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  8911. }
  8912. public function decisionLevel($literalOrPackageId)
  8913. {
  8914. $packageId = abs($literalOrPackageId);
  8915. if (isset($this->decisionMap[$packageId])) {
  8916. return abs($this->decisionMap[$packageId]);
  8917. }
  8918. return 0;
  8919. }
  8920. public function decisionRule($literalOrPackageId)
  8921. {
  8922. $packageId = abs($literalOrPackageId);
  8923. foreach ($this->decisionQueue as $i => $decision) {
  8924. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  8925. return $decision[self::DECISION_REASON];
  8926. }
  8927. }
  8928. return null;
  8929. }
  8930. public function atOffset($queueOffset)
  8931. {
  8932. return $this->decisionQueue[$queueOffset];
  8933. }
  8934. public function validOffset($queueOffset)
  8935. {
  8936. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  8937. }
  8938. public function lastReason()
  8939. {
  8940. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  8941. }
  8942. public function lastLiteral()
  8943. {
  8944. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  8945. }
  8946. public function reset()
  8947. {
  8948. while ($decision = array_pop($this->decisionQueue)) {
  8949. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8950. }
  8951. }
  8952. public function resetToOffset($offset)
  8953. {
  8954. while (\count($this->decisionQueue) > $offset + 1) {
  8955. $decision = array_pop($this->decisionQueue);
  8956. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8957. }
  8958. }
  8959. public function revertLast()
  8960. {
  8961. $this->decisionMap[abs($this->lastLiteral())] = 0;
  8962. array_pop($this->decisionQueue);
  8963. }
  8964. public function count()
  8965. {
  8966. return \count($this->decisionQueue);
  8967. }
  8968. public function rewind()
  8969. {
  8970. end($this->decisionQueue);
  8971. }
  8972. public function current()
  8973. {
  8974. return current($this->decisionQueue);
  8975. }
  8976. public function key()
  8977. {
  8978. return key($this->decisionQueue);
  8979. }
  8980. public function next()
  8981. {
  8982. return prev($this->decisionQueue);
  8983. }
  8984. public function valid()
  8985. {
  8986. return false !== current($this->decisionQueue);
  8987. }
  8988. public function isEmpty()
  8989. {
  8990. return \count($this->decisionQueue) === 0;
  8991. }
  8992. protected function addDecision($literal, $level)
  8993. {
  8994. $packageId = abs($literal);
  8995. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  8996. if ($previousDecision != 0) {
  8997. $literalString = $this->pool->literalToPrettyString($literal, array());
  8998. $package = $this->pool->literalToPackage($literal);
  8999. throw new SolverBugException(
  9000. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  9001. );
  9002. }
  9003. if ($literal > 0) {
  9004. $this->decisionMap[$packageId] = $level;
  9005. } else {
  9006. $this->decisionMap[$packageId] = -$level;
  9007. }
  9008. }
  9009. public function toString(Pool $pool = null)
  9010. {
  9011. $decisionMap = $this->decisionMap;
  9012. ksort($decisionMap);
  9013. $str = '[';
  9014. foreach ($decisionMap as $packageId => $level) {
  9015. $str .= (($pool) ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  9016. }
  9017. $str .= ']';
  9018. return $str;
  9019. }
  9020. public function __toString()
  9021. {
  9022. return $this->toString();
  9023. }
  9024. }
  9025. <?php
  9026. namespace Composer\DependencyResolver;
  9027. use Composer\Package\PackageInterface;
  9028. use Composer\Package\AliasPackage;
  9029. use Composer\Package\BasePackage;
  9030. use Composer\Semver\Constraint\Constraint;
  9031. class DefaultPolicy implements PolicyInterface
  9032. {
  9033. private $preferStable;
  9034. private $preferLowest;
  9035. public function __construct($preferStable = false, $preferLowest = false)
  9036. {
  9037. $this->preferStable = $preferStable;
  9038. $this->preferLowest = $preferLowest;
  9039. }
  9040. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  9041. {
  9042. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  9043. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  9044. }
  9045. $constraint = new Constraint($operator, $b->getVersion());
  9046. $version = new Constraint('==', $a->getVersion());
  9047. return $constraint->matchSpecific($version, true);
  9048. }
  9049. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
  9050. {
  9051. $packages = $this->groupLiteralsByName($pool, $literals);
  9052. $policy = $this;
  9053. foreach ($packages as &$nameLiterals) {
  9054. usort($nameLiterals, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9055. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  9056. });
  9057. }
  9058. foreach ($packages as &$sortedLiterals) {
  9059. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  9060. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  9061. }
  9062. $selected = \call_user_func_array('array_merge', array_values($packages));
  9063. usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9064. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  9065. });
  9066. return $selected;
  9067. }
  9068. protected function groupLiteralsByName(Pool $pool, $literals)
  9069. {
  9070. $packages = array();
  9071. foreach ($literals as $literal) {
  9072. $packageName = $pool->literalToPackage($literal)->getName();
  9073. if (!isset($packages[$packageName])) {
  9074. $packages[$packageName] = array();
  9075. }
  9076. $packages[$packageName][] = $literal;
  9077. }
  9078. return $packages;
  9079. }
  9080. public function compareByPriority(Pool $pool, PackageInterface $a, PackageInterface $b, $requiredPackage = null, $ignoreReplace = false)
  9081. {
  9082. if ($a->getName() === $b->getName()) {
  9083. $aAliased = $a instanceof AliasPackage;
  9084. $bAliased = $b instanceof AliasPackage;
  9085. if ($aAliased && !$bAliased) {
  9086. return -1;
  9087. }
  9088. if (!$aAliased && $bAliased) {
  9089. return 1;
  9090. }
  9091. }
  9092. if (!$ignoreReplace) {
  9093. if ($this->replaces($a, $b)) {
  9094. return 1;
  9095. }
  9096. if ($this->replaces($b, $a)) {
  9097. return -1;
  9098. }
  9099. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  9100. $requiredVendor = substr($requiredPackage, 0, $pos);
  9101. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  9102. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  9103. if ($bIsSameVendor !== $aIsSameVendor) {
  9104. return $aIsSameVendor ? -1 : 1;
  9105. }
  9106. }
  9107. }
  9108. if ($a->id === $b->id) {
  9109. return 0;
  9110. }
  9111. return ($a->id < $b->id) ? -1 : 1;
  9112. }
  9113. protected function replaces(PackageInterface $source, PackageInterface $target)
  9114. {
  9115. foreach ($source->getReplaces() as $link) {
  9116. if ($link->getTarget() === $target->getName()
  9117. ) {
  9118. return true;
  9119. }
  9120. }
  9121. return false;
  9122. }
  9123. protected function pruneToBestVersion(Pool $pool, $literals)
  9124. {
  9125. $operator = $this->preferLowest ? '<' : '>';
  9126. $bestLiterals = array($literals[0]);
  9127. $bestPackage = $pool->literalToPackage($literals[0]);
  9128. foreach ($literals as $i => $literal) {
  9129. if (0 === $i) {
  9130. continue;
  9131. }
  9132. $package = $pool->literalToPackage($literal);
  9133. if ($this->versionCompare($package, $bestPackage, $operator)) {
  9134. $bestPackage = $package;
  9135. $bestLiterals = array($literal);
  9136. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  9137. $bestLiterals[] = $literal;
  9138. }
  9139. }
  9140. return $bestLiterals;
  9141. }
  9142. protected function pruneRemoteAliases(Pool $pool, array $literals)
  9143. {
  9144. $hasLocalAlias = false;
  9145. foreach ($literals as $literal) {
  9146. $package = $pool->literalToPackage($literal);
  9147. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9148. $hasLocalAlias = true;
  9149. break;
  9150. }
  9151. }
  9152. if (!$hasLocalAlias) {
  9153. return $literals;
  9154. }
  9155. $selected = array();
  9156. foreach ($literals as $literal) {
  9157. $package = $pool->literalToPackage($literal);
  9158. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9159. $selected[] = $literal;
  9160. }
  9161. }
  9162. return $selected;
  9163. }
  9164. }
  9165. <?php
  9166. namespace Composer\DependencyResolver;
  9167. use Composer\Package\PackageInterface;
  9168. use Composer\Package\Link;
  9169. class GenericRule extends Rule
  9170. {
  9171. protected $literals;
  9172. public function __construct(array $literals, $reason, $reasonData)
  9173. {
  9174. parent::__construct($reason, $reasonData);
  9175. sort($literals);
  9176. $this->literals = $literals;
  9177. }
  9178. public function getLiterals()
  9179. {
  9180. return $this->literals;
  9181. }
  9182. public function getHash()
  9183. {
  9184. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  9185. return $data['hash'];
  9186. }
  9187. public function equals(Rule $rule)
  9188. {
  9189. return $this->literals === $rule->getLiterals();
  9190. }
  9191. public function isAssertion()
  9192. {
  9193. return 1 === \count($this->literals);
  9194. }
  9195. public function __toString()
  9196. {
  9197. $result = $this->isDisabled() ? 'disabled(' : '(';
  9198. foreach ($this->literals as $i => $literal) {
  9199. if ($i != 0) {
  9200. $result .= '|';
  9201. }
  9202. $result .= $literal;
  9203. }
  9204. $result .= ')';
  9205. return $result;
  9206. }
  9207. }
  9208. <?php
  9209. namespace Composer\DependencyResolver;
  9210. use Composer\Repository\RepositoryInterface;
  9211. class LocalRepoTransaction extends Transaction
  9212. {
  9213. public function __construct(RepositoryInterface $lockedRepository, $localRepository)
  9214. {
  9215. parent::__construct(
  9216. $localRepository->getPackages(),
  9217. $lockedRepository->getPackages()
  9218. );
  9219. }
  9220. }
  9221. <?php
  9222. namespace Composer\DependencyResolver;
  9223. use Composer\Package\AliasPackage;
  9224. use Composer\Package\RootAliasPackage;
  9225. class LockTransaction extends Transaction
  9226. {
  9227. protected $presentMap;
  9228. protected $unlockableMap;
  9229. protected $resultPackages;
  9230. public function __construct(Pool $pool, $presentMap, $unlockableMap, $decisions)
  9231. {
  9232. $this->presentMap = $presentMap;
  9233. $this->unlockableMap = $unlockableMap;
  9234. $this->setResultPackages($pool, $decisions);
  9235. parent::__construct($this->presentMap, $this->resultPackages['all']);
  9236. }
  9237. public function setResultPackages(Pool $pool, Decisions $decisions)
  9238. {
  9239. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  9240. foreach ($decisions as $i => $decision) {
  9241. $literal = $decision[Decisions::DECISION_LITERAL];
  9242. if ($literal > 0) {
  9243. $package = $pool->literalToPackage($literal);
  9244. $this->resultPackages['all'][] = $package;
  9245. if (!isset($this->unlockableMap[$package->id])) {
  9246. $this->resultPackages['non-dev'][] = $package;
  9247. }
  9248. }
  9249. }
  9250. }
  9251. public function setNonDevPackages(LockTransaction $extractionResult)
  9252. {
  9253. $packages = $extractionResult->getNewLockPackages(false);
  9254. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  9255. $this->resultPackages['non-dev'] = array();
  9256. foreach ($packages as $package) {
  9257. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  9258. if ($package->getName() == $resultPackage->getName()) {
  9259. $this->resultPackages['non-dev'][] = $resultPackage;
  9260. unset($this->resultPackages['dev'][$i]);
  9261. }
  9262. }
  9263. }
  9264. }
  9265. public function getNewLockPackages($devMode, $updateMirrors = false)
  9266. {
  9267. $packages = array();
  9268. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  9269. if (!($package instanceof AliasPackage) && !($package instanceof RootAliasPackage)) {
  9270. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  9271. foreach ($this->presentMap as $presentPackage) {
  9272. if ($package->getName() == $presentPackage->getName() &&
  9273. $package->getVersion() == $presentPackage->getVersion() &&
  9274. $presentPackage->getSourceReference() &&
  9275. $presentPackage->getSourceType() === $package->getSourceType()
  9276. ) {
  9277. $package->setSourceDistReferences($presentPackage->getSourceReference());
  9278. }
  9279. }
  9280. }
  9281. $packages[] = $package;
  9282. }
  9283. }
  9284. return $packages;
  9285. }
  9286. public function getAliases($aliases)
  9287. {
  9288. $usedAliases = array();
  9289. foreach ($this->resultPackages['all'] as $package) {
  9290. if ($package instanceof AliasPackage) {
  9291. foreach ($aliases as $index => $alias) {
  9292. if ($alias['package'] === $package->getName()) {
  9293. $usedAliases[] = $alias;
  9294. unset($aliases[$index]);
  9295. }
  9296. }
  9297. }
  9298. }
  9299. usort($usedAliases, function ($a, $b) {
  9300. return strcmp($a['package'], $b['package']);
  9301. });
  9302. return $usedAliases;
  9303. }
  9304. }
  9305. <?php
  9306. namespace Composer\DependencyResolver;
  9307. use Composer\Package\PackageInterface;
  9308. use Composer\Package\Link;
  9309. class MultiConflictRule extends Rule
  9310. {
  9311. protected $literals;
  9312. public function __construct(array $literals, $reason, $reasonData)
  9313. {
  9314. parent::__construct($reason, $reasonData);
  9315. if (\count($literals) < 3) {
  9316. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  9317. }
  9318. sort($literals);
  9319. $this->literals = $literals;
  9320. }
  9321. public function getLiterals()
  9322. {
  9323. return $this->literals;
  9324. }
  9325. public function getHash()
  9326. {
  9327. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  9328. return $data['hash'];
  9329. }
  9330. public function equals(Rule $rule)
  9331. {
  9332. if ($rule instanceof MultiConflictRule) {
  9333. return $this->literals === $rule->getLiterals();
  9334. }
  9335. return false;
  9336. }
  9337. public function isAssertion()
  9338. {
  9339. return false;
  9340. }
  9341. public function disable()
  9342. {
  9343. throw new \RuntimeException("Disabling multi conflict rules is not possible. Please contact composer at https://github.com/composer/composer to let us debug what lead to this situation.");
  9344. }
  9345. public function __toString()
  9346. {
  9347. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  9348. foreach ($this->literals as $i => $literal) {
  9349. if ($i != 0) {
  9350. $result .= '|';
  9351. }
  9352. $result .= $literal;
  9353. }
  9354. $result .= '))';
  9355. return $result;
  9356. }
  9357. }
  9358. <?php
  9359. namespace Composer\DependencyResolver\Operation;
  9360. use Composer\Package\PackageInterface;
  9361. class InstallOperation extends SolverOperation implements OperationInterface
  9362. {
  9363. const TYPE = 'install';
  9364. protected $package;
  9365. public function __construct(PackageInterface $package)
  9366. {
  9367. $this->package = $package;
  9368. }
  9369. public function getPackage()
  9370. {
  9371. return $this->package;
  9372. }
  9373. public function show($lock)
  9374. {
  9375. return self::format($this->package, $lock);
  9376. }
  9377. public static function format(PackageInterface $package, $lock = false)
  9378. {
  9379. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9380. }
  9381. }
  9382. <?php
  9383. namespace Composer\DependencyResolver\Operation;
  9384. use Composer\Package\AliasPackage;
  9385. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  9386. {
  9387. const TYPE = 'markAliasInstalled';
  9388. protected $package;
  9389. public function __construct(AliasPackage $package)
  9390. {
  9391. $this->package = $package;
  9392. }
  9393. public function getPackage()
  9394. {
  9395. return $this->package;
  9396. }
  9397. public function show($lock)
  9398. {
  9399. return 'Marking <info>'.$this->package->getPrettyName().'</info> (<comment>'.$this->package->getFullPrettyVersion().'</comment>) as installed, alias of <info>'.$this->package->getAliasOf()->getPrettyName().'</info> (<comment>'.$this->package->getAliasOf()->getFullPrettyVersion().'</comment>)';
  9400. }
  9401. }
  9402. <?php
  9403. namespace Composer\DependencyResolver\Operation;
  9404. use Composer\Package\AliasPackage;
  9405. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  9406. {
  9407. const TYPE = 'markAliasUninstalled';
  9408. protected $package;
  9409. public function __construct(AliasPackage $package)
  9410. {
  9411. $this->package = $package;
  9412. }
  9413. public function getPackage()
  9414. {
  9415. return $this->package;
  9416. }
  9417. public function show($lock)
  9418. {
  9419. return 'Marking <info>'.$this->package->getPrettyName().'</info> (<comment>'.$this->package->getFullPrettyVersion().'</comment>) as uninstalled, alias of <info>'.$this->package->getAliasOf()->getPrettyName().'</info> (<comment>'.$this->package->getAliasOf()->getFullPrettyVersion().'</comment>)';
  9420. }
  9421. }
  9422. <?php
  9423. namespace Composer\DependencyResolver\Operation;
  9424. interface OperationInterface
  9425. {
  9426. public function getOperationType();
  9427. public function show($lock);
  9428. public function __toString();
  9429. }
  9430. <?php
  9431. namespace Composer\DependencyResolver\Operation;
  9432. abstract class SolverOperation implements OperationInterface
  9433. {
  9434. const TYPE = null;
  9435. public function getOperationType()
  9436. {
  9437. return static::TYPE;
  9438. }
  9439. public function __toString()
  9440. {
  9441. return $this->show(false);
  9442. }
  9443. }
  9444. <?php
  9445. namespace Composer\DependencyResolver\Operation;
  9446. use Composer\Package\PackageInterface;
  9447. class UninstallOperation extends SolverOperation implements OperationInterface
  9448. {
  9449. const TYPE = 'uninstall';
  9450. protected $package;
  9451. public function __construct(PackageInterface $package)
  9452. {
  9453. $this->package = $package;
  9454. }
  9455. public function getPackage()
  9456. {
  9457. return $this->package;
  9458. }
  9459. public function show($lock)
  9460. {
  9461. return self::format($this->package, $lock);
  9462. }
  9463. public static function format(PackageInterface $package, $lock = false)
  9464. {
  9465. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9466. }
  9467. }
  9468. <?php
  9469. namespace Composer\DependencyResolver\Operation;
  9470. use Composer\Package\PackageInterface;
  9471. use Composer\Package\Version\VersionParser;
  9472. class UpdateOperation extends SolverOperation implements OperationInterface
  9473. {
  9474. const TYPE = 'update';
  9475. protected $initialPackage;
  9476. protected $targetPackage;
  9477. public function __construct(PackageInterface $initial, PackageInterface $target)
  9478. {
  9479. $this->initialPackage = $initial;
  9480. $this->targetPackage = $target;
  9481. }
  9482. public function getInitialPackage()
  9483. {
  9484. return $this->initialPackage;
  9485. }
  9486. public function getTargetPackage()
  9487. {
  9488. return $this->targetPackage;
  9489. }
  9490. public function show($lock)
  9491. {
  9492. return self::format($this->initialPackage, $this->targetPackage, $lock);
  9493. }
  9494. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
  9495. {
  9496. $fromVersion = $initialPackage->getFullPrettyVersion();
  9497. $toVersion = $targetPackage->getFullPrettyVersion();
  9498. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  9499. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9500. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9501. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  9502. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9503. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9504. }
  9505. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  9506. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  9507. }
  9508. }
  9509. <?php
  9510. namespace Composer\DependencyResolver;
  9511. use Composer\Package\PackageInterface;
  9512. interface PolicyInterface
  9513. {
  9514. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  9515. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
  9516. }
  9517. <?php
  9518. namespace Composer\DependencyResolver;
  9519. use Composer\Package\Version\VersionParser;
  9520. use Composer\Semver\CompilingMatcher;
  9521. use Composer\Semver\Constraint\ConstraintInterface;
  9522. use Composer\Semver\Constraint\Constraint;
  9523. use Composer\Package\PackageInterface;
  9524. class Pool implements \Countable
  9525. {
  9526. protected $packages = array();
  9527. protected $packageByName = array();
  9528. protected $versionParser;
  9529. protected $providerCache = array();
  9530. protected $unacceptableFixedOrLockedPackages;
  9531. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array())
  9532. {
  9533. $this->versionParser = new VersionParser;
  9534. $this->setPackages($packages);
  9535. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  9536. }
  9537. private function setPackages(array $packages)
  9538. {
  9539. $id = 1;
  9540. foreach ($packages as $package) {
  9541. $this->packages[] = $package;
  9542. $package->id = $id++;
  9543. foreach ($package->getNames() as $provided) {
  9544. $this->packageByName[$provided][] = $package;
  9545. }
  9546. }
  9547. }
  9548. public function getPackages()
  9549. {
  9550. return $this->packages;
  9551. }
  9552. public function packageById($id)
  9553. {
  9554. return $this->packages[$id - 1];
  9555. }
  9556. public function count()
  9557. {
  9558. return \count($this->packages);
  9559. }
  9560. public function whatProvides($name, ConstraintInterface $constraint = null)
  9561. {
  9562. $key = (string) $constraint;
  9563. if (isset($this->providerCache[$name][$key])) {
  9564. return $this->providerCache[$name][$key];
  9565. }
  9566. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  9567. }
  9568. private function computeWhatProvides($name, $constraint)
  9569. {
  9570. if (!isset($this->packageByName[$name])) {
  9571. return array();
  9572. }
  9573. $matches = array();
  9574. foreach ($this->packageByName[$name] as $candidate) {
  9575. if ($this->match($candidate, $name, $constraint)) {
  9576. $matches[] = $candidate;
  9577. }
  9578. }
  9579. return $matches;
  9580. }
  9581. public function literalToPackage($literal)
  9582. {
  9583. $packageId = abs($literal);
  9584. return $this->packageById($packageId);
  9585. }
  9586. public function literalToPrettyString($literal, $installedMap)
  9587. {
  9588. $package = $this->literalToPackage($literal);
  9589. if (isset($installedMap[$package->id])) {
  9590. $prefix = ($literal > 0 ? 'keep' : 'remove');
  9591. } else {
  9592. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  9593. }
  9594. return $prefix.' '.$package->getPrettyString();
  9595. }
  9596. public function match($candidate, $name, ConstraintInterface $constraint = null)
  9597. {
  9598. $candidateName = $candidate->getName();
  9599. $candidateVersion = $candidate->getVersion();
  9600. if ($candidateName === $name) {
  9601. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  9602. }
  9603. $provides = $candidate->getProvides();
  9604. $replaces = $candidate->getReplaces();
  9605. if (isset($replaces[0]) || isset($provides[0])) {
  9606. foreach ($provides as $link) {
  9607. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9608. return true;
  9609. }
  9610. }
  9611. foreach ($replaces as $link) {
  9612. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9613. return true;
  9614. }
  9615. }
  9616. return false;
  9617. }
  9618. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  9619. return true;
  9620. }
  9621. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  9622. return true;
  9623. }
  9624. return false;
  9625. }
  9626. public function isUnacceptableFixedOrLockedPackage(PackageInterface $package)
  9627. {
  9628. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  9629. }
  9630. public function __toString()
  9631. {
  9632. $str = "Pool:\n";
  9633. foreach ($this->packages as $package) {
  9634. $str .= '- '.str_pad($package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  9635. }
  9636. return $str;
  9637. }
  9638. }
  9639. <?php
  9640. namespace Composer\DependencyResolver;
  9641. use Composer\EventDispatcher\EventDispatcher;
  9642. use Composer\IO\IOInterface;
  9643. use Composer\Package\AliasPackage;
  9644. use Composer\Package\BasePackage;
  9645. use Composer\Package\PackageInterface;
  9646. use Composer\Package\Version\StabilityFilter;
  9647. use Composer\Plugin\PluginEvents;
  9648. use Composer\Plugin\PrePoolCreateEvent;
  9649. use Composer\Repository\PlatformRepository;
  9650. use Composer\Repository\RootPackageRepository;
  9651. use Composer\Semver\CompilingMatcher;
  9652. use Composer\Semver\Constraint\Constraint;
  9653. use Composer\Semver\Constraint\ConstraintInterface;
  9654. use Composer\Semver\Constraint\MatchAllConstraint;
  9655. use Composer\Semver\Constraint\MultiConstraint;
  9656. use Composer\Semver\Intervals;
  9657. class PoolBuilder
  9658. {
  9659. private $acceptableStabilities;
  9660. private $stabilityFlags;
  9661. private $rootAliases;
  9662. private $rootReferences;
  9663. private $eventDispatcher;
  9664. private $io;
  9665. private $aliasMap = array();
  9666. private $packagesToLoad = array();
  9667. private $loadedPackages = array();
  9668. private $loadedPerRepo = array();
  9669. private $packages = array();
  9670. private $unacceptableFixedOrLockedPackages = array();
  9671. private $updateAllowList = array();
  9672. private $skippedLoad = array();
  9673. private $maxExtendedReqs = array();
  9674. private $updateAllowWarned = array();
  9675. private $indexCounter = 0;
  9676. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null)
  9677. {
  9678. $this->acceptableStabilities = $acceptableStabilities;
  9679. $this->stabilityFlags = $stabilityFlags;
  9680. $this->rootAliases = $rootAliases;
  9681. $this->rootReferences = $rootReferences;
  9682. $this->eventDispatcher = $eventDispatcher;
  9683. $this->io = $io;
  9684. }
  9685. public function buildPool(array $repositories, Request $request)
  9686. {
  9687. if ($request->getUpdateAllowList()) {
  9688. $this->updateAllowList = $request->getUpdateAllowList();
  9689. $this->warnAboutNonMatchingUpdateAllowList($request);
  9690. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  9691. if (!$this->isUpdateAllowed($lockedPackage)) {
  9692. $request->lockPackage($lockedPackage);
  9693. $lockedName = $lockedPackage->getName();
  9694. $this->skippedLoad[$lockedName] = $lockedName;
  9695. foreach ($lockedPackage->getReplaces() as $link) {
  9696. $this->skippedLoad[$link->getTarget()] = $lockedName;
  9697. }
  9698. }
  9699. }
  9700. }
  9701. foreach ($request->getFixedOrLockedPackages() as $package) {
  9702. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  9703. foreach ($package->getReplaces() as $link) {
  9704. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  9705. }
  9706. if (
  9707. $package->getRepository() instanceof RootPackageRepository
  9708. || $package->getRepository() instanceof PlatformRepository
  9709. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  9710. ) {
  9711. $this->loadPackage($request, $package, false);
  9712. } else {
  9713. $this->unacceptableFixedOrLockedPackages[] = $package;
  9714. }
  9715. }
  9716. foreach ($request->getRequires() as $packageName => $constraint) {
  9717. if (isset($this->loadedPackages[$packageName])) {
  9718. continue;
  9719. }
  9720. $this->packagesToLoad[$packageName] = $constraint;
  9721. $this->maxExtendedReqs[$packageName] = true;
  9722. }
  9723. foreach ($this->packagesToLoad as $name => $constraint) {
  9724. if (isset($this->loadedPackages[$name])) {
  9725. unset($this->packagesToLoad[$name]);
  9726. }
  9727. }
  9728. while (!empty($this->packagesToLoad)) {
  9729. $this->loadPackagesMarkedForLoading($request, $repositories);
  9730. }
  9731. foreach ($this->packages as $i => $package) {
  9732. if (!$package instanceof AliasPackage) {
  9733. $constraint = new Constraint('==', $package->getVersion());
  9734. $aliasedPackages = array($i => $package);
  9735. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9736. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  9737. }
  9738. $found = false;
  9739. foreach ($aliasedPackages as $packageOrAlias) {
  9740. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  9741. $found = true;
  9742. }
  9743. }
  9744. if (!$found) {
  9745. foreach ($aliasedPackages as $index => $packageOrAlias) {
  9746. unset($this->packages[$index]);
  9747. }
  9748. }
  9749. }
  9750. }
  9751. if ($this->eventDispatcher) {
  9752. $prePoolCreateEvent = new PrePoolCreateEvent(
  9753. PluginEvents::PRE_POOL_CREATE,
  9754. $repositories,
  9755. $request,
  9756. $this->acceptableStabilities,
  9757. $this->stabilityFlags,
  9758. $this->rootAliases,
  9759. $this->rootReferences,
  9760. $this->packages,
  9761. $this->unacceptableFixedOrLockedPackages
  9762. );
  9763. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  9764. $this->packages = $prePoolCreateEvent->getPackages();
  9765. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  9766. }
  9767. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  9768. $this->aliasMap = array();
  9769. $this->packagesToLoad = array();
  9770. $this->loadedPackages = array();
  9771. $this->loadedPerRepo = array();
  9772. $this->packages = array();
  9773. $this->unacceptableFixedOrLockedPackages = array();
  9774. $this->maxExtendedReqs = array();
  9775. $this->skippedLoad = array();
  9776. $this->indexCounter = 0;
  9777. Intervals::clear();
  9778. return $pool;
  9779. }
  9780. private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
  9781. {
  9782. if (PlatformRepository::isPlatformPackage($name)) {
  9783. return;
  9784. }
  9785. if (isset($this->maxExtendedReqs[$name])) {
  9786. return;
  9787. }
  9788. $rootRequires = $request->getRequires();
  9789. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  9790. $constraint = $rootRequires[$name];
  9791. }
  9792. if (!isset($this->loadedPackages[$name])) {
  9793. if (isset($this->packagesToLoad[$name])) {
  9794. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  9795. return;
  9796. }
  9797. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  9798. }
  9799. $this->packagesToLoad[$name] = $constraint;
  9800. return;
  9801. }
  9802. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  9803. return;
  9804. }
  9805. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  9806. unset($this->loadedPackages[$name]);
  9807. }
  9808. private function loadPackagesMarkedForLoading(Request $request, $repositories)
  9809. {
  9810. foreach ($this->packagesToLoad as $name => $constraint) {
  9811. $this->loadedPackages[$name] = $constraint;
  9812. }
  9813. $packageBatch = $this->packagesToLoad;
  9814. $this->packagesToLoad = array();
  9815. foreach ($repositories as $repoIndex => $repository) {
  9816. if (empty($packageBatch)) {
  9817. break;
  9818. }
  9819. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  9820. continue;
  9821. }
  9822. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
  9823. foreach ($result['namesFound'] as $name) {
  9824. unset($packageBatch[$name]);
  9825. }
  9826. foreach ($result['packages'] as $package) {
  9827. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  9828. $this->loadPackage($request, $package);
  9829. }
  9830. }
  9831. }
  9832. private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true)
  9833. {
  9834. $index = $this->indexCounter++;
  9835. $this->packages[$index] = $package;
  9836. if ($package instanceof AliasPackage) {
  9837. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  9838. }
  9839. $name = $package->getName();
  9840. if (isset($this->rootReferences[$name])) {
  9841. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  9842. $package->setSourceDistReferences($this->rootReferences[$name]);
  9843. }
  9844. }
  9845. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  9846. $alias = $this->rootAliases[$name][$package->getVersion()];
  9847. if ($package instanceof AliasPackage) {
  9848. $basePackage = $package->getAliasOf();
  9849. } else {
  9850. $basePackage = $package;
  9851. }
  9852. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  9853. $aliasPackage->setRootPackageAlias(true);
  9854. $newIndex = $this->indexCounter++;
  9855. $this->packages[$newIndex] = $aliasPackage;
  9856. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  9857. }
  9858. foreach ($package->getRequires() as $link) {
  9859. $require = $link->getTarget();
  9860. $linkConstraint = $link->getConstraint();
  9861. if (isset($this->skippedLoad[$require])) {
  9862. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9863. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$require])) {
  9864. $this->unlockPackage($request, $require);
  9865. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9866. } elseif (!isset($this->updateAllowWarned[$this->skippedLoad[$require]])) {
  9867. $this->updateAllowWarned[$this->skippedLoad[$require]] = true;
  9868. $this->io->writeError('<warning>Dependency "'.$this->skippedLoad[$require].'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
  9869. }
  9870. }
  9871. } else {
  9872. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9873. }
  9874. }
  9875. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9876. foreach ($package->getReplaces() as $link) {
  9877. $replace = $link->getTarget();
  9878. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  9879. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
  9880. $this->unlockPackage($request, $replace);
  9881. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  9882. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
  9883. $this->updateAllowWarned[$replace] = true;
  9884. $this->io->writeError('<warning>Dependency "'.$replace.'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
  9885. }
  9886. }
  9887. }
  9888. }
  9889. }
  9890. private function isRootRequire(Request $request, $name)
  9891. {
  9892. $rootRequires = $request->getRequires();
  9893. return isset($rootRequires[$name]);
  9894. }
  9895. private function isUpdateAllowed(PackageInterface $package)
  9896. {
  9897. foreach ($this->updateAllowList as $pattern => $void) {
  9898. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9899. if (preg_match($patternRegexp, $package->getName())) {
  9900. return true;
  9901. }
  9902. }
  9903. return false;
  9904. }
  9905. private function warnAboutNonMatchingUpdateAllowList(Request $request)
  9906. {
  9907. foreach ($this->updateAllowList as $pattern => $void) {
  9908. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9909. foreach ($request->getLockedRepository()->getPackages() as $package) {
  9910. if (preg_match($patternRegexp, $package->getName())) {
  9911. continue 2;
  9912. }
  9913. }
  9914. foreach ($request->getRequires() as $packageName => $constraint) {
  9915. if (preg_match($patternRegexp, $packageName)) {
  9916. continue 2;
  9917. }
  9918. }
  9919. if (strpos($pattern, '*') !== false) {
  9920. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  9921. } else {
  9922. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  9923. }
  9924. }
  9925. }
  9926. private function unlockPackage(Request $request, $name)
  9927. {
  9928. if (
  9929. $this->skippedLoad[$name] !== $name
  9930. && isset($this->skippedLoad[$this->skippedLoad[$name]])
  9931. ) {
  9932. $this->unlockPackage($request, $this->skippedLoad[$name]);
  9933. }
  9934. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name]);
  9935. foreach ($request->getLockedPackages() as $lockedPackage) {
  9936. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  9937. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  9938. $request->unlockPackage($lockedPackage);
  9939. $this->removeLoadedPackage($request, $lockedPackage, $index);
  9940. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  9941. if ($fixedOrLockedPackage !== $lockedPackage && isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  9942. foreach ($fixedOrLockedPackage->getRequires() as $requireLink) {
  9943. if ($requireLink->getTarget() === $lockedPackage->getName()) {
  9944. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requireLink->getConstraint());
  9945. }
  9946. }
  9947. }
  9948. }
  9949. }
  9950. }
  9951. }
  9952. }
  9953. private function removeLoadedPackage(Request $request, PackageInterface $package, $index)
  9954. {
  9955. unset($this->packages[$index]);
  9956. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9957. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  9958. $request->unlockPackage($aliasPackage);
  9959. unset($this->packages[$aliasIndex]);
  9960. }
  9961. unset($this->aliasMap[spl_object_hash($package)]);
  9962. }
  9963. }
  9964. }
  9965. <?php
  9966. namespace Composer\DependencyResolver;
  9967. use Composer\Package\CompletePackageInterface;
  9968. use Composer\Package\AliasPackage;
  9969. use Composer\Repository\RepositorySet;
  9970. use Composer\Repository\LockArrayRepository;
  9971. use Composer\Semver\Constraint\Constraint;
  9972. use Composer\Package\Version\VersionParser;
  9973. class Problem
  9974. {
  9975. protected $reasonSeen;
  9976. protected $reasons = array();
  9977. protected $section = 0;
  9978. public function addRule(Rule $rule)
  9979. {
  9980. $this->addReason(spl_object_hash($rule), $rule);
  9981. }
  9982. public function getReasons()
  9983. {
  9984. return $this->reasons;
  9985. }
  9986. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  9987. {
  9988. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  9989. if (count($reasons) === 1) {
  9990. reset($reasons);
  9991. $rule = current($reasons);
  9992. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  9993. throw new \LogicException("Single reason problems must contain a request rule.");
  9994. }
  9995. $reasonData = $rule->getReasonData();
  9996. $packageName = $reasonData['packageName'];
  9997. $constraint = $reasonData['constraint'];
  9998. if (isset($constraint)) {
  9999. $packages = $pool->whatProvides($packageName, $constraint);
  10000. } else {
  10001. $packages = array();
  10002. }
  10003. if (empty($packages)) {
  10004. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  10005. }
  10006. }
  10007. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10008. }
  10009. public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10010. {
  10011. $messages = array();
  10012. $templates = array();
  10013. $parser = new VersionParser;
  10014. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  10015. foreach ($rules as $rule) {
  10016. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10017. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && preg_match('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  10018. $template = preg_replace('{^\S+ \S+ }', '%s%s ', $message);
  10019. $messages[] = $template;
  10020. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  10021. } elseif ($message !== '') {
  10022. $messages[] = $message;
  10023. }
  10024. }
  10025. $result = array();
  10026. foreach (array_unique($messages) as $message) {
  10027. if (isset($templates[$message])) {
  10028. foreach ($templates[$message] as $package => $versions) {
  10029. uksort($versions, 'version_compare');
  10030. if (!$isVerbose) {
  10031. $versions = self::condenseVersionList($versions, 1);
  10032. }
  10033. if (count($versions) > 1) {
  10034. $message = preg_replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  10035. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  10036. } else {
  10037. $result[] = sprintf($message, $package, ' '.reset($versions));
  10038. }
  10039. }
  10040. } else {
  10041. $result[] = $message;
  10042. }
  10043. }
  10044. return "\n$indent- ".implode("\n$indent- ", $result);
  10045. }
  10046. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10047. {
  10048. foreach ($this->reasons as $sectionRules) {
  10049. foreach ($sectionRules as $rule) {
  10050. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  10051. return true;
  10052. }
  10053. }
  10054. }
  10055. }
  10056. protected function addReason($id, Rule $reason)
  10057. {
  10058. if (!isset($this->reasonSeen[$id])) {
  10059. $this->reasonSeen[$id] = true;
  10060. $this->reasons[$this->section][] = $reason;
  10061. }
  10062. }
  10063. public function nextSection()
  10064. {
  10065. $this->section++;
  10066. }
  10067. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, $constraint = null)
  10068. {
  10069. if ($packageName === 'php' || $packageName === 'php-64bit' || $packageName === 'hhvm') {
  10070. $version = phpversion();
  10071. $available = $pool->whatProvides($packageName);
  10072. if (count($available)) {
  10073. $firstAvailable = reset($available);
  10074. $version = $firstAvailable->getPrettyVersion();
  10075. $extra = $firstAvailable->getExtra();
  10076. if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  10077. $version .= '; ' . str_replace('Package ', '', $firstAvailable->getDescription());
  10078. }
  10079. }
  10080. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  10081. if (defined('HHVM_VERSION') || (count($available) && $packageName === 'hhvm')) {
  10082. return array($msg, 'your HHVM version does not satisfy that requirement.');
  10083. }
  10084. if ($packageName === 'hhvm') {
  10085. return array($msg, 'you are running this with PHP and not HHVM.');
  10086. }
  10087. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  10088. }
  10089. if (0 === stripos($packageName, 'ext-')) {
  10090. if (false !== strpos($packageName, ' ')) {
  10091. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  10092. }
  10093. $ext = substr($packageName, 4);
  10094. $error = extension_loaded($ext) ? 'it has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'it is missing from your system';
  10095. return array("- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ', $error.'. Install or enable PHP\'s '.$ext.' extension.');
  10096. }
  10097. if (0 === stripos($packageName, 'lib-')) {
  10098. if (strtolower($packageName) === 'lib-icu') {
  10099. $error = extension_loaded('intl') ? 'it has the wrong version installed, try upgrading the intl extension.' : 'it is missing from your system, make sure the intl extension is loaded.';
  10100. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  10101. }
  10102. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', 'it has the wrong version installed or is missing from your system, make sure to load the extension providing it.');
  10103. }
  10104. $lockedPackage = null;
  10105. foreach ($request->getLockedPackages() as $package) {
  10106. if ($package->getName() === $packageName) {
  10107. $lockedPackage = $package;
  10108. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10109. return array("- ", $package->getPrettyName().' is fixed to '.$package->getPrettyVersion().' (lock file version) by a partial update but that version is rejected by your minimum-stability. Make sure you list it as an argument for the update command.');
  10110. }
  10111. break;
  10112. }
  10113. }
  10114. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  10115. $rootReqs = $repositorySet->getRootRequires();
  10116. if (isset($rootReqs[$packageName])) {
  10117. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName) {
  10118. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  10119. });
  10120. if (0 === count($filtered)) {
  10121. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these conflict' : 'it conflicts').' with your root composer.json require ('.$rootReqs[$packageName]->getPrettyString().').');
  10122. }
  10123. }
  10124. if ($lockedPackage) {
  10125. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  10126. $filtered = array_filter($packages, function ($p) use ($fixedConstraint) {
  10127. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  10128. });
  10129. if (0 === count($filtered)) {
  10130. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but the package is fixed to '.$lockedPackage->getPrettyVersion().' (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.');
  10131. }
  10132. }
  10133. $nonLockedPackages = array_filter($packages, function ($p) {
  10134. return !$p->getRepository() instanceof LockArrayRepository;
  10135. });
  10136. if (!$nonLockedPackages) {
  10137. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.');
  10138. }
  10139. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but these were not loaded, likely because '.(self::hasMultipleNames($packages) ? 'they conflict' : 'it conflicts').' with another require.');
  10140. }
  10141. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10142. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10143. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'minimum-stability');
  10144. }
  10145. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match your minimum-stability.');
  10146. }
  10147. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10148. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10149. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'constraint');
  10150. }
  10151. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match the constraint.');
  10152. }
  10153. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  10154. $illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  10155. return array("- Root composer.json requires $packageName, it ", 'could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.');
  10156. }
  10157. if ($providers = $repositorySet->getProviders($packageName)) {
  10158. $maxProviders = 20;
  10159. $providersStr = implode(array_map(function ($p) {
  10160. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  10161. return " - ${p['name']}".$description."\n";
  10162. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  10163. if (count($providers) > $maxProviders + 1) {
  10164. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  10165. }
  10166. return array("- Root composer.json requires $packageName".self::constraintToText($constraint).", it ", "could not be found in any version, but the following packages provide it:\n".$providersStr." Consider requiring one of these to satisfy the $packageName requirement.");
  10167. }
  10168. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  10169. }
  10170. public static function getPackageList(array $packages, $isVerbose)
  10171. {
  10172. $prepared = array();
  10173. $hasDefaultBranch = array();
  10174. foreach ($packages as $package) {
  10175. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  10176. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  10177. if ($package->isDefaultBranch()) {
  10178. $hasDefaultBranch[$package->getName()] = true;
  10179. }
  10180. }
  10181. foreach ($prepared as $name => $package) {
  10182. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  10183. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  10184. }
  10185. uksort($package['versions'], 'version_compare');
  10186. if (!$isVerbose) {
  10187. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  10188. }
  10189. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  10190. }
  10191. return implode(', ', $prepared);
  10192. }
  10193. private static function condenseVersionList(array $versions, $max)
  10194. {
  10195. if (count($versions) <= $max) {
  10196. return $versions;
  10197. }
  10198. $filtered = array();
  10199. $byMajor = array();
  10200. foreach ($versions as $version => $pretty) {
  10201. $byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  10202. }
  10203. foreach ($byMajor as $versionsForMajor) {
  10204. if (count($versionsForMajor) > $max) {
  10205. $filtered[] = $versionsForMajor[0];
  10206. $filtered[] = '...';
  10207. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  10208. } else {
  10209. $filtered = array_merge($filtered, $versionsForMajor);
  10210. }
  10211. }
  10212. return $filtered;
  10213. }
  10214. private static function hasMultipleNames(array $packages)
  10215. {
  10216. $name = null;
  10217. foreach ($packages as $package) {
  10218. if ($name === null || $name === $package->getName()) {
  10219. $name = $package->getName();
  10220. } else {
  10221. return true;
  10222. }
  10223. }
  10224. return false;
  10225. }
  10226. private static function computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, array $higherRepoPackages, array $allReposPackages, $reason)
  10227. {
  10228. $nextRepoPackages = array();
  10229. $nextRepo = null;
  10230. foreach ($allReposPackages as $package) {
  10231. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  10232. $nextRepoPackages[] = $package;
  10233. $nextRepo = $package->getRepository();
  10234. } else {
  10235. break;
  10236. }
  10237. }
  10238. if ($nextRepo instanceof LockArrayRepository) {
  10239. $singular = count($higherRepoPackages) === 1;
  10240. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ',
  10241. 'found '.self::getPackageList($nextRepoPackages, $isVerbose).' in the lock file and '.self::getPackageList($higherRepoPackages, $isVerbose).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. Make sure you either fix the '.$reason.' or avoid updating this package to keep the one from the lock file.');
  10242. }
  10243. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages with higher priority do not match your '.$reason.' and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.');
  10244. }
  10245. protected static function constraintToText($constraint)
  10246. {
  10247. return $constraint ? ' '.$constraint->getPrettyString() : '';
  10248. }
  10249. }
  10250. <?php
  10251. namespace Composer\DependencyResolver;
  10252. use Composer\Package\Package;
  10253. use Composer\Package\PackageInterface;
  10254. use Composer\Repository\LockArrayRepository;
  10255. use Composer\Semver\Constraint\ConstraintInterface;
  10256. use Composer\Semver\Constraint\MatchAllConstraint;
  10257. class Request
  10258. {
  10259. const UPDATE_ONLY_LISTED = 0;
  10260. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  10261. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  10262. protected $lockedRepository;
  10263. protected $requires = array();
  10264. protected $fixedPackages = array();
  10265. protected $lockedPackages = array();
  10266. protected $fixedLockedPackages = array();
  10267. protected $updateAllowList = array();
  10268. protected $updateAllowTransitiveDependencies = false;
  10269. public function __construct(LockArrayRepository $lockedRepository = null)
  10270. {
  10271. $this->lockedRepository = $lockedRepository;
  10272. }
  10273. public function requireName($packageName, ConstraintInterface $constraint = null)
  10274. {
  10275. $packageName = strtolower($packageName);
  10276. if ($constraint === null) {
  10277. $constraint = new MatchAllConstraint();
  10278. }
  10279. if (isset($this->requires[$packageName])) {
  10280. throw new \LogicException('Overwriting requires seems like a bug ('.$packageName.' '.$this->requires[$packageName]->getPrettyString().' => '.$constraint->getPrettyString().', check why it is happening, might be a root alias');
  10281. }
  10282. $this->requires[$packageName] = $constraint;
  10283. }
  10284. public function fixPackage(PackageInterface $package)
  10285. {
  10286. $this->fixedPackages[spl_object_hash($package)] = $package;
  10287. }
  10288. public function lockPackage(PackageInterface $package)
  10289. {
  10290. $this->lockedPackages[spl_object_hash($package)] = $package;
  10291. }
  10292. public function fixLockedPackage(PackageInterface $package)
  10293. {
  10294. $this->fixedPackages[spl_object_hash($package)] = $package;
  10295. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  10296. }
  10297. public function unlockPackage(PackageInterface $package)
  10298. {
  10299. unset($this->lockedPackages[spl_object_hash($package)]);
  10300. }
  10301. public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)
  10302. {
  10303. $this->updateAllowList = $updateAllowList;
  10304. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  10305. }
  10306. public function getUpdateAllowList()
  10307. {
  10308. return $this->updateAllowList;
  10309. }
  10310. public function getUpdateAllowTransitiveDependencies()
  10311. {
  10312. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  10313. }
  10314. public function getUpdateAllowTransitiveRootDependencies()
  10315. {
  10316. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  10317. }
  10318. public function getRequires()
  10319. {
  10320. return $this->requires;
  10321. }
  10322. public function getFixedPackages()
  10323. {
  10324. return $this->fixedPackages;
  10325. }
  10326. public function isFixedPackage(PackageInterface $package)
  10327. {
  10328. return isset($this->fixedPackages[spl_object_hash($package)]);
  10329. }
  10330. public function getLockedPackages()
  10331. {
  10332. return $this->lockedPackages;
  10333. }
  10334. public function isLockedPackage(PackageInterface $package)
  10335. {
  10336. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  10337. }
  10338. public function getFixedOrLockedPackages()
  10339. {
  10340. return array_merge($this->fixedPackages, $this->lockedPackages);
  10341. }
  10342. public function getPresentMap($packageIds = false)
  10343. {
  10344. $presentMap = array();
  10345. if ($this->lockedRepository) {
  10346. foreach ($this->lockedRepository->getPackages() as $package) {
  10347. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10348. }
  10349. }
  10350. foreach ($this->fixedPackages as $package) {
  10351. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10352. }
  10353. return $presentMap;
  10354. }
  10355. public function getFixedPackagesMap()
  10356. {
  10357. $fixedPackagesMap = array();
  10358. foreach ($this->fixedPackages as $package) {
  10359. $fixedPackagesMap[$package->id] = $package;
  10360. }
  10361. return $fixedPackagesMap;
  10362. }
  10363. public function getLockedRepository()
  10364. {
  10365. return $this->lockedRepository;
  10366. }
  10367. }
  10368. <?php
  10369. namespace Composer\DependencyResolver;
  10370. use Composer\Package\Link;
  10371. use Composer\Package\PackageInterface;
  10372. use Composer\Package\AliasPackage;
  10373. use Composer\Repository\RepositorySet;
  10374. use Composer\Repository\PlatformRepository;
  10375. use Composer\Package\Version\VersionParser;
  10376. use Composer\Semver\Constraint\Constraint;
  10377. abstract class Rule
  10378. {
  10379. const RULE_ROOT_REQUIRE = 2;
  10380. const RULE_FIXED = 3;
  10381. const RULE_PACKAGE_CONFLICT = 6;
  10382. const RULE_PACKAGE_REQUIRES = 7;
  10383. const RULE_PACKAGE_SAME_NAME = 10;
  10384. const RULE_LEARNED = 12;
  10385. const RULE_PACKAGE_ALIAS = 13;
  10386. const RULE_PACKAGE_INVERSE_ALIAS = 14;
  10387. const BITFIELD_TYPE = 0;
  10388. const BITFIELD_REASON = 8;
  10389. const BITFIELD_DISABLED = 16;
  10390. protected $bitfield;
  10391. protected $request;
  10392. protected $reasonData;
  10393. public function __construct($reason, $reasonData)
  10394. {
  10395. $this->reasonData = $reasonData;
  10396. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  10397. ($reason << self::BITFIELD_REASON) |
  10398. (255 << self::BITFIELD_TYPE);
  10399. }
  10400. abstract public function getLiterals();
  10401. abstract public function getHash();
  10402. abstract public function equals(Rule $rule);
  10403. public function getReason()
  10404. {
  10405. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  10406. }
  10407. public function getReasonData()
  10408. {
  10409. return $this->reasonData;
  10410. }
  10411. public function getRequiredPackage()
  10412. {
  10413. $reason = $this->getReason();
  10414. if ($reason === self::RULE_ROOT_REQUIRE) {
  10415. return $this->reasonData['packageName'];
  10416. }
  10417. if ($reason === self::RULE_FIXED) {
  10418. return $this->reasonData['package']->getName();
  10419. }
  10420. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  10421. return $this->reasonData->getTarget();
  10422. }
  10423. }
  10424. public function setType($type)
  10425. {
  10426. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  10427. }
  10428. public function getType()
  10429. {
  10430. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  10431. }
  10432. public function disable()
  10433. {
  10434. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  10435. }
  10436. public function enable()
  10437. {
  10438. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  10439. }
  10440. public function isDisabled()
  10441. {
  10442. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10443. }
  10444. public function isEnabled()
  10445. {
  10446. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10447. }
  10448. abstract public function isAssertion();
  10449. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10450. {
  10451. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  10452. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  10453. return false;
  10454. }
  10455. if ($request->getLockedRepository()) {
  10456. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10457. if ($package->getName() === $this->reasonData->getTarget()) {
  10458. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10459. return true;
  10460. }
  10461. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  10462. return true;
  10463. }
  10464. if (!$request->isLockedPackage($package)) {
  10465. return true;
  10466. }
  10467. break;
  10468. }
  10469. }
  10470. }
  10471. }
  10472. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  10473. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  10474. return false;
  10475. }
  10476. if ($request->getLockedRepository()) {
  10477. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10478. if ($package->getName() === $this->reasonData['packageName']) {
  10479. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10480. return true;
  10481. }
  10482. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  10483. return true;
  10484. }
  10485. break;
  10486. }
  10487. }
  10488. }
  10489. }
  10490. return false;
  10491. }
  10492. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10493. {
  10494. $literals = $this->getLiterals();
  10495. switch ($this->getReason()) {
  10496. case self::RULE_ROOT_REQUIRE:
  10497. $packageName = $this->reasonData['packageName'];
  10498. $constraint = $this->reasonData['constraint'];
  10499. $packages = $pool->whatProvides($packageName, $constraint);
  10500. if (!$packages) {
  10501. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  10502. }
  10503. $packagesNonAlias = array_values(array_filter($packages, function ($p) {
  10504. return !($p instanceof AliasPackage);
  10505. }));
  10506. if (count($packagesNonAlias) === 1) {
  10507. $package = $packagesNonAlias[0];
  10508. if ($request->isLockedPackage($package)) {
  10509. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  10510. }
  10511. }
  10512. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose).'.';
  10513. case self::RULE_FIXED:
  10514. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  10515. if ($request->isLockedPackage($package)) {
  10516. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  10517. }
  10518. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  10519. case self::RULE_PACKAGE_CONFLICT:
  10520. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10521. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10522. return $package2->getPrettyString().' conflicts with '.$package1->getPrettyString().'.';
  10523. case self::RULE_PACKAGE_REQUIRES:
  10524. $sourceLiteral = array_shift($literals);
  10525. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  10526. $requires = array();
  10527. foreach ($literals as $literal) {
  10528. $requires[] = $pool->literalToPackage($literal);
  10529. }
  10530. $text = $this->reasonData->getPrettyString($sourcePackage);
  10531. if ($requires) {
  10532. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose) . '.';
  10533. } else {
  10534. $targetName = $this->reasonData->getTarget();
  10535. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  10536. return $text . ' -> ' . $reason[1];
  10537. }
  10538. return $text;
  10539. case self::RULE_PACKAGE_SAME_NAME:
  10540. $packageNames = array();
  10541. foreach ($literals as $literal) {
  10542. $package = $pool->literalToPackage($literal);
  10543. $packageNames[$package->getName()] = true;
  10544. }
  10545. $replacedName = $this->reasonData;
  10546. if (count($packageNames) > 1) {
  10547. $reason = null;
  10548. if (!isset($packageNames[$replacedName])) {
  10549. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  10550. } else {
  10551. $replacerNames = $packageNames;
  10552. unset($replacerNames[$replacedName]);
  10553. $replacerNames = array_keys($replacerNames);
  10554. if (count($replacerNames) == 1) {
  10555. $reason = $replacerNames[0] . ' replaces ';
  10556. } else {
  10557. $reason = '['.implode(', ', $replacerNames).'] replace ';
  10558. }
  10559. $reason .= $replacedName.' and thus cannot coexist with it.';
  10560. }
  10561. $installedPackages = array();
  10562. $removablePackages = array();
  10563. foreach ($literals as $literal) {
  10564. if (isset($installedMap[abs($literal)])) {
  10565. $installedPackages[] = $pool->literalToPackage($literal);
  10566. } else {
  10567. $removablePackages[] = $pool->literalToPackage($literal);
  10568. }
  10569. }
  10570. if ($installedPackages && $removablePackages) {
  10571. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose).'. '.$reason;
  10572. }
  10573. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose).'. '.$reason;
  10574. }
  10575. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.';
  10576. case self::RULE_LEARNED:
  10577. $learnedString = ' (conflict analysis result)';
  10578. if (count($literals) === 1) {
  10579. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  10580. } else {
  10581. $groups = array();
  10582. foreach ($literals as $literal) {
  10583. $package = $pool->literalToPackage($literal);
  10584. if (isset($installedMap[$package->id])) {
  10585. $group = $literal > 0 ? 'keep' : 'remove';
  10586. } else {
  10587. $group = $literal > 0 ? 'install' : 'don\'t install';
  10588. }
  10589. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  10590. }
  10591. $ruleTexts = array();
  10592. foreach ($groups as $group => $packages) {
  10593. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  10594. }
  10595. $ruleText = implode(' | ', $ruleTexts);
  10596. }
  10597. return 'Conclusion: '.$ruleText.$learnedString;
  10598. case self::RULE_PACKAGE_ALIAS:
  10599. $aliasPackage = $pool->literalToPackage($literals[0]);
  10600. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10601. return '';
  10602. }
  10603. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10604. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  10605. case self::RULE_PACKAGE_INVERSE_ALIAS:
  10606. $aliasPackage = $pool->literalToPackage($literals[1]);
  10607. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10608. return '';
  10609. }
  10610. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10611. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  10612. default:
  10613. $ruleText = '';
  10614. foreach ($literals as $i => $literal) {
  10615. if ($i != 0) {
  10616. $ruleText .= '|';
  10617. }
  10618. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  10619. }
  10620. return '('.$ruleText.')';
  10621. }
  10622. }
  10623. protected function formatPackagesUnique($pool, array $packages, $isVerbose)
  10624. {
  10625. foreach ($packages as $index => $package) {
  10626. if (!\is_object($package)) {
  10627. $packages[$index] = $pool->literalToPackage($package);
  10628. }
  10629. }
  10630. return Problem::getPackageList($packages, $isVerbose);
  10631. }
  10632. private function deduplicateDefaultBranchAlias(PackageInterface $package)
  10633. {
  10634. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10635. $package = $package->getAliasOf();
  10636. }
  10637. return $package;
  10638. }
  10639. }
  10640. <?php
  10641. namespace Composer\DependencyResolver;
  10642. use Composer\Package\PackageInterface;
  10643. use Composer\Package\Link;
  10644. class Rule2Literals extends Rule
  10645. {
  10646. protected $literal1;
  10647. protected $literal2;
  10648. public function __construct($literal1, $literal2, $reason, $reasonData)
  10649. {
  10650. parent::__construct($reason, $reasonData);
  10651. if ($literal1 < $literal2) {
  10652. $this->literal1 = $literal1;
  10653. $this->literal2 = $literal2;
  10654. } else {
  10655. $this->literal1 = $literal2;
  10656. $this->literal2 = $literal1;
  10657. }
  10658. }
  10659. public function getLiterals()
  10660. {
  10661. return array($this->literal1, $this->literal2);
  10662. }
  10663. public function getHash()
  10664. {
  10665. return $this->literal1.','.$this->literal2;
  10666. }
  10667. public function equals(Rule $rule)
  10668. {
  10669. if ($rule instanceof self) {
  10670. if ($this->literal1 !== $rule->literal1) {
  10671. return false;
  10672. }
  10673. if ($this->literal2 !== $rule->literal2) {
  10674. return false;
  10675. }
  10676. return true;
  10677. }
  10678. $literals = $rule->getLiterals();
  10679. if (2 != \count($literals)) {
  10680. return false;
  10681. }
  10682. if ($this->literal1 !== $literals[0]) {
  10683. return false;
  10684. }
  10685. if ($this->literal2 !== $literals[1]) {
  10686. return false;
  10687. }
  10688. return true;
  10689. }
  10690. public function isAssertion()
  10691. {
  10692. return false;
  10693. }
  10694. public function __toString()
  10695. {
  10696. $result = $this->isDisabled() ? 'disabled(' : '(';
  10697. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  10698. return $result;
  10699. }
  10700. }
  10701. <?php
  10702. namespace Composer\DependencyResolver;
  10703. use Composer\Repository\RepositorySet;
  10704. class RuleSet implements \IteratorAggregate, \Countable
  10705. {
  10706. const TYPE_PACKAGE = 0;
  10707. const TYPE_REQUEST = 1;
  10708. const TYPE_LEARNED = 4;
  10709. public $ruleById;
  10710. protected static $types = array(
  10711. 255 => 'UNKNOWN',
  10712. self::TYPE_PACKAGE => 'PACKAGE',
  10713. self::TYPE_REQUEST => 'REQUEST',
  10714. self::TYPE_LEARNED => 'LEARNED',
  10715. );
  10716. protected $rules;
  10717. protected $nextRuleId;
  10718. protected $rulesByHash;
  10719. public function __construct()
  10720. {
  10721. $this->nextRuleId = 0;
  10722. foreach ($this->getTypes() as $type) {
  10723. $this->rules[$type] = array();
  10724. }
  10725. $this->rulesByHash = array();
  10726. }
  10727. public function add(Rule $rule, $type)
  10728. {
  10729. if (!isset(self::$types[$type])) {
  10730. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  10731. }
  10732. $hash = $rule->getHash();
  10733. if (isset($this->rulesByHash[$hash])) {
  10734. $potentialDuplicates = $this->rulesByHash[$hash];
  10735. if (\is_array($potentialDuplicates)) {
  10736. foreach ($potentialDuplicates as $potentialDuplicate) {
  10737. if ($rule->equals($potentialDuplicate)) {
  10738. return;
  10739. }
  10740. }
  10741. } else {
  10742. if ($rule->equals($potentialDuplicates)) {
  10743. return;
  10744. }
  10745. }
  10746. }
  10747. if (!isset($this->rules[$type])) {
  10748. $this->rules[$type] = array();
  10749. }
  10750. $this->rules[$type][] = $rule;
  10751. $this->ruleById[$this->nextRuleId] = $rule;
  10752. $rule->setType($type);
  10753. $this->nextRuleId++;
  10754. if (!isset($this->rulesByHash[$hash])) {
  10755. $this->rulesByHash[$hash] = $rule;
  10756. } elseif (\is_array($this->rulesByHash[$hash])) {
  10757. $this->rulesByHash[$hash][] = $rule;
  10758. } else {
  10759. $originalRule = $this->rulesByHash[$hash];
  10760. $this->rulesByHash[$hash] = array($originalRule, $rule);
  10761. }
  10762. }
  10763. public function count()
  10764. {
  10765. return $this->nextRuleId;
  10766. }
  10767. public function ruleById($id)
  10768. {
  10769. return $this->ruleById[$id];
  10770. }
  10771. public function getRules()
  10772. {
  10773. return $this->rules;
  10774. }
  10775. public function getIterator()
  10776. {
  10777. return new RuleSetIterator($this->getRules());
  10778. }
  10779. public function getIteratorFor($types)
  10780. {
  10781. if (!\is_array($types)) {
  10782. $types = array($types);
  10783. }
  10784. $allRules = $this->getRules();
  10785. $rules = array();
  10786. foreach ($types as $type) {
  10787. $rules[$type] = $allRules[$type];
  10788. }
  10789. return new RuleSetIterator($rules);
  10790. }
  10791. public function getIteratorWithout($types)
  10792. {
  10793. if (!\is_array($types)) {
  10794. $types = array($types);
  10795. }
  10796. $rules = $this->getRules();
  10797. foreach ($types as $type) {
  10798. unset($rules[$type]);
  10799. }
  10800. return new RuleSetIterator($rules);
  10801. }
  10802. public function getTypes()
  10803. {
  10804. $types = self::$types;
  10805. unset($types[255]);
  10806. return array_keys($types);
  10807. }
  10808. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
  10809. {
  10810. $string = "\n";
  10811. foreach ($this->rules as $type => $rules) {
  10812. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  10813. foreach ($rules as $rule) {
  10814. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  10815. }
  10816. $string .= "\n\n";
  10817. }
  10818. return $string;
  10819. }
  10820. public function __toString()
  10821. {
  10822. return $this->getPrettyString();
  10823. }
  10824. }
  10825. <?php
  10826. namespace Composer\DependencyResolver;
  10827. use Composer\Package\PackageInterface;
  10828. use Composer\Package\AliasPackage;
  10829. use Composer\Repository\PlatformRepository;
  10830. class RuleSetGenerator
  10831. {
  10832. protected $policy;
  10833. protected $pool;
  10834. protected $rules;
  10835. protected $addedMap;
  10836. protected $conflictAddedMap;
  10837. protected $addedPackagesByNames;
  10838. protected $conflictsForName;
  10839. public function __construct(PolicyInterface $policy, Pool $pool)
  10840. {
  10841. $this->policy = $policy;
  10842. $this->pool = $pool;
  10843. }
  10844. protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
  10845. {
  10846. $literals = array(-$package->id);
  10847. foreach ($providers as $provider) {
  10848. if ($provider === $package) {
  10849. return null;
  10850. }
  10851. $literals[] = $provider->id;
  10852. }
  10853. return new GenericRule($literals, $reason, $reasonData);
  10854. }
  10855. protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
  10856. {
  10857. $literals = array();
  10858. foreach ($packages as $package) {
  10859. $literals[] = $package->id;
  10860. }
  10861. return new GenericRule($literals, $reason, $reasonData);
  10862. }
  10863. protected function createRule2Literals(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
  10864. {
  10865. if ($issuer === $provider) {
  10866. return null;
  10867. }
  10868. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  10869. }
  10870. protected function createMultiConflictRule(array $packages, $reason, $reasonData = null)
  10871. {
  10872. $literals = array();
  10873. foreach ($packages as $package) {
  10874. $literals[] = -$package->id;
  10875. }
  10876. if (\count($literals) == 2) {
  10877. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  10878. }
  10879. return new MultiConflictRule($literals, $reason, $reasonData);
  10880. }
  10881. private function addRule($type, Rule $newRule = null)
  10882. {
  10883. if (!$newRule) {
  10884. return;
  10885. }
  10886. $this->rules->add($newRule, $type);
  10887. }
  10888. protected function addRulesForPackage(PackageInterface $package, $ignorePlatformReqs)
  10889. {
  10890. $workQueue = new \SplQueue;
  10891. $workQueue->enqueue($package);
  10892. while (!$workQueue->isEmpty()) {
  10893. $package = $workQueue->dequeue();
  10894. if (isset($this->addedMap[$package->id])) {
  10895. continue;
  10896. }
  10897. $this->addedMap[$package->id] = $package;
  10898. if (!$package instanceof AliasPackage) {
  10899. foreach ($package->getNames(false) as $name) {
  10900. $this->addedPackagesByNames[$name][] = $package;
  10901. }
  10902. } else {
  10903. $workQueue->enqueue($package->getAliasOf());
  10904. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  10905. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), array($package), Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  10906. if (!$package->hasSelfVersionRequires()) {
  10907. continue;
  10908. }
  10909. }
  10910. foreach ($package->getRequires() as $link) {
  10911. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10912. continue;
  10913. }
  10914. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10915. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  10916. foreach ($possibleRequires as $require) {
  10917. $workQueue->enqueue($require);
  10918. }
  10919. }
  10920. }
  10921. }
  10922. protected function addConflictRules($ignorePlatformReqs = false)
  10923. {
  10924. foreach ($this->addedMap as $package) {
  10925. foreach ($package->getConflicts() as $link) {
  10926. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  10927. continue;
  10928. }
  10929. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10930. continue;
  10931. }
  10932. $conflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10933. foreach ($conflicts as $conflict) {
  10934. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  10935. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  10936. }
  10937. }
  10938. }
  10939. }
  10940. foreach ($this->addedPackagesByNames as $name => $packages) {
  10941. if (\count($packages) > 1) {
  10942. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  10943. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  10944. }
  10945. }
  10946. }
  10947. protected function addRulesForRequest(Request $request, $ignorePlatformReqs)
  10948. {
  10949. foreach ($request->getFixedPackages() as $package) {
  10950. if ($package->id == -1) {
  10951. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  10952. continue;
  10953. }
  10954. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  10955. }
  10956. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10957. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  10958. 'package' => $package,
  10959. ));
  10960. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10961. }
  10962. foreach ($request->getRequires() as $packageName => $constraint) {
  10963. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  10964. continue;
  10965. }
  10966. $packages = $this->pool->whatProvides($packageName, $constraint);
  10967. if ($packages) {
  10968. foreach ($packages as $package) {
  10969. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10970. }
  10971. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  10972. 'packageName' => $packageName,
  10973. 'constraint' => $constraint,
  10974. ));
  10975. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10976. }
  10977. }
  10978. }
  10979. protected function addRulesForRootAliases($ignorePlatformReqs)
  10980. {
  10981. foreach ($this->pool->getPackages() as $package) {
  10982. if (!isset($this->addedMap[$package->id]) &&
  10983. $package instanceof AliasPackage &&
  10984. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  10985. ) {
  10986. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10987. }
  10988. }
  10989. }
  10990. public function getRulesFor(Request $request, $ignorePlatformReqs = false)
  10991. {
  10992. $this->rules = new RuleSet;
  10993. $this->addedMap = array();
  10994. $this->conflictAddedMap = array();
  10995. $this->addedPackagesByNames = array();
  10996. $this->conflictsForName = array();
  10997. $this->addRulesForRequest($request, $ignorePlatformReqs);
  10998. $this->addRulesForRootAliases($ignorePlatformReqs);
  10999. $this->addConflictRules($ignorePlatformReqs);
  11000. $this->addedMap = $this->addedPackagesByNames = null;
  11001. return $this->rules;
  11002. }
  11003. }
  11004. <?php
  11005. namespace Composer\DependencyResolver;
  11006. class RuleSetIterator implements \Iterator
  11007. {
  11008. protected $rules;
  11009. protected $types;
  11010. protected $currentOffset;
  11011. protected $currentType;
  11012. protected $currentTypeOffset;
  11013. public function __construct(array $rules)
  11014. {
  11015. $this->rules = $rules;
  11016. $this->types = array_keys($rules);
  11017. sort($this->types);
  11018. $this->rewind();
  11019. }
  11020. public function current()
  11021. {
  11022. return $this->rules[$this->currentType][$this->currentOffset];
  11023. }
  11024. public function key()
  11025. {
  11026. return $this->currentType;
  11027. }
  11028. public function next()
  11029. {
  11030. $this->currentOffset++;
  11031. if (!isset($this->rules[$this->currentType])) {
  11032. return;
  11033. }
  11034. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  11035. $this->currentOffset = 0;
  11036. do {
  11037. $this->currentTypeOffset++;
  11038. if (!isset($this->types[$this->currentTypeOffset])) {
  11039. $this->currentType = -1;
  11040. break;
  11041. }
  11042. $this->currentType = $this->types[$this->currentTypeOffset];
  11043. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11044. }
  11045. }
  11046. public function rewind()
  11047. {
  11048. $this->currentOffset = 0;
  11049. $this->currentTypeOffset = -1;
  11050. $this->currentType = -1;
  11051. do {
  11052. $this->currentTypeOffset++;
  11053. if (!isset($this->types[$this->currentTypeOffset])) {
  11054. $this->currentType = -1;
  11055. break;
  11056. }
  11057. $this->currentType = $this->types[$this->currentTypeOffset];
  11058. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11059. }
  11060. public function valid()
  11061. {
  11062. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  11063. }
  11064. }
  11065. <?php
  11066. namespace Composer\DependencyResolver;
  11067. class RuleWatchChain extends \SplDoublyLinkedList
  11068. {
  11069. protected $offset = 0;
  11070. public function seek($offset)
  11071. {
  11072. $this->rewind();
  11073. for ($i = 0; $i < $offset; $i++, $this->next());
  11074. }
  11075. public function remove()
  11076. {
  11077. $offset = $this->key();
  11078. $this->offsetUnset($offset);
  11079. $this->seek($offset);
  11080. }
  11081. }
  11082. <?php
  11083. namespace Composer\DependencyResolver;
  11084. class RuleWatchGraph
  11085. {
  11086. protected $watchChains = array();
  11087. public function insert(RuleWatchNode $node)
  11088. {
  11089. if ($node->getRule()->isAssertion()) {
  11090. return;
  11091. }
  11092. if (!$node->getRule() instanceof MultiConflictRule) {
  11093. foreach (array($node->watch1, $node->watch2) as $literal) {
  11094. if (!isset($this->watchChains[$literal])) {
  11095. $this->watchChains[$literal] = new RuleWatchChain;
  11096. }
  11097. $this->watchChains[$literal]->unshift($node);
  11098. }
  11099. } else {
  11100. foreach ($node->getRule()->getLiterals() as $literal) {
  11101. if (!isset($this->watchChains[$literal])) {
  11102. $this->watchChains[$literal] = new RuleWatchChain;
  11103. }
  11104. $this->watchChains[$literal]->unshift($node);
  11105. }
  11106. }
  11107. }
  11108. public function propagateLiteral($decidedLiteral, $level, $decisions)
  11109. {
  11110. $literal = -$decidedLiteral;
  11111. if (!isset($this->watchChains[$literal])) {
  11112. return null;
  11113. }
  11114. $chain = $this->watchChains[$literal];
  11115. $chain->rewind();
  11116. while ($chain->valid()) {
  11117. $node = $chain->current();
  11118. if (!$node->getRule() instanceof MultiConflictRule) {
  11119. $otherWatch = $node->getOtherWatch($literal);
  11120. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  11121. $ruleLiterals = $node->getRule()->getLiterals();
  11122. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  11123. return $literal !== $ruleLiteral &&
  11124. $otherWatch !== $ruleLiteral &&
  11125. !$decisions->conflict($ruleLiteral);
  11126. });
  11127. if ($alternativeLiterals) {
  11128. reset($alternativeLiterals);
  11129. $this->moveWatch($literal, current($alternativeLiterals), $node);
  11130. continue;
  11131. }
  11132. if ($decisions->conflict($otherWatch)) {
  11133. return $node->getRule();
  11134. }
  11135. $decisions->decide($otherWatch, $level, $node->getRule());
  11136. }
  11137. } else {
  11138. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  11139. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  11140. if ($decisions->conflict($otherLiteral)) {
  11141. return $node->getRule();
  11142. }
  11143. $decisions->decide($otherLiteral, $level, $node->getRule());
  11144. }
  11145. }
  11146. }
  11147. $chain->next();
  11148. }
  11149. return null;
  11150. }
  11151. protected function moveWatch($fromLiteral, $toLiteral, $node)
  11152. {
  11153. if (!isset($this->watchChains[$toLiteral])) {
  11154. $this->watchChains[$toLiteral] = new RuleWatchChain;
  11155. }
  11156. $node->moveWatch($fromLiteral, $toLiteral);
  11157. $this->watchChains[$fromLiteral]->remove();
  11158. $this->watchChains[$toLiteral]->unshift($node);
  11159. }
  11160. }
  11161. <?php
  11162. namespace Composer\DependencyResolver;
  11163. class RuleWatchNode
  11164. {
  11165. public $watch1;
  11166. public $watch2;
  11167. protected $rule;
  11168. public function __construct($rule)
  11169. {
  11170. $this->rule = $rule;
  11171. $literals = $rule->getLiterals();
  11172. $literalCount = \count($literals);
  11173. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  11174. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  11175. }
  11176. public function watch2OnHighest(Decisions $decisions)
  11177. {
  11178. $literals = $this->rule->getLiterals();
  11179. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  11180. return;
  11181. }
  11182. $watchLevel = 0;
  11183. foreach ($literals as $literal) {
  11184. $level = $decisions->decisionLevel($literal);
  11185. if ($level > $watchLevel) {
  11186. $this->watch2 = $literal;
  11187. $watchLevel = $level;
  11188. }
  11189. }
  11190. }
  11191. public function getRule()
  11192. {
  11193. return $this->rule;
  11194. }
  11195. public function getOtherWatch($literal)
  11196. {
  11197. if ($this->watch1 == $literal) {
  11198. return $this->watch2;
  11199. }
  11200. return $this->watch1;
  11201. }
  11202. public function moveWatch($from, $to)
  11203. {
  11204. if ($this->watch1 == $from) {
  11205. $this->watch1 = $to;
  11206. } else {
  11207. $this->watch2 = $to;
  11208. }
  11209. }
  11210. }
  11211. <?php
  11212. namespace Composer\DependencyResolver;
  11213. use Composer\IO\IOInterface;
  11214. use Composer\Package\PackageInterface;
  11215. use Composer\Repository\PlatformRepository;
  11216. class Solver
  11217. {
  11218. const BRANCH_LITERALS = 0;
  11219. const BRANCH_LEVEL = 1;
  11220. protected $policy;
  11221. protected $pool;
  11222. protected $rules;
  11223. protected $watchGraph;
  11224. protected $decisions;
  11225. protected $fixedMap;
  11226. protected $propagateIndex;
  11227. protected $branches = array();
  11228. protected $problems = array();
  11229. protected $learnedPool = array();
  11230. protected $learnedWhy = array();
  11231. public $testFlagLearnedPositiveLiteral = false;
  11232. protected $io;
  11233. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  11234. {
  11235. $this->io = $io;
  11236. $this->policy = $policy;
  11237. $this->pool = $pool;
  11238. }
  11239. public function getRuleSetSize()
  11240. {
  11241. return \count($this->rules);
  11242. }
  11243. public function getPool()
  11244. {
  11245. return $this->pool;
  11246. }
  11247. private function makeAssertionRuleDecisions()
  11248. {
  11249. $decisionStart = \count($this->decisions) - 1;
  11250. $rulesCount = \count($this->rules);
  11251. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  11252. $rule = $this->rules->ruleById[$ruleIndex];
  11253. if (!$rule->isAssertion() || $rule->isDisabled()) {
  11254. continue;
  11255. }
  11256. $literals = $rule->getLiterals();
  11257. $literal = $literals[0];
  11258. if (!$this->decisions->decided($literal)) {
  11259. $this->decisions->decide($literal, 1, $rule);
  11260. continue;
  11261. }
  11262. if ($this->decisions->satisfy($literal)) {
  11263. continue;
  11264. }
  11265. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  11266. $rule->disable();
  11267. continue;
  11268. }
  11269. $conflict = $this->decisions->decisionRule($literal);
  11270. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  11271. $problem = new Problem();
  11272. $problem->addRule($rule);
  11273. $problem->addRule($conflict);
  11274. $rule->disable();
  11275. $this->problems[] = $problem;
  11276. continue;
  11277. }
  11278. $problem = new Problem();
  11279. $problem->addRule($rule);
  11280. $problem->addRule($conflict);
  11281. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  11282. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  11283. continue;
  11284. }
  11285. $assertRuleLiterals = $assertRule->getLiterals();
  11286. $assertRuleLiteral = $assertRuleLiterals[0];
  11287. if (abs($literal) !== abs($assertRuleLiteral)) {
  11288. continue;
  11289. }
  11290. $problem->addRule($assertRule);
  11291. $assertRule->disable();
  11292. }
  11293. $this->problems[] = $problem;
  11294. $this->decisions->resetToOffset($decisionStart);
  11295. $ruleIndex = -1;
  11296. }
  11297. }
  11298. protected function setupFixedMap(Request $request)
  11299. {
  11300. $this->fixedMap = array();
  11301. foreach ($request->getFixedPackages() as $package) {
  11302. $this->fixedMap[$package->id] = $package;
  11303. }
  11304. }
  11305. protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
  11306. {
  11307. foreach ($request->getRequires() as $packageName => $constraint) {
  11308. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  11309. continue;
  11310. }
  11311. if (!$this->pool->whatProvides($packageName, $constraint)) {
  11312. $problem = new Problem();
  11313. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  11314. $this->problems[] = $problem;
  11315. }
  11316. }
  11317. }
  11318. public function solve(Request $request, $ignorePlatformReqs = false)
  11319. {
  11320. $this->setupFixedMap($request);
  11321. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  11322. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  11323. $this->rules = $ruleSetGenerator->getRulesFor($request, $ignorePlatformReqs);
  11324. unset($ruleSetGenerator);
  11325. $this->checkForRootRequireProblems($request, $ignorePlatformReqs);
  11326. $this->decisions = new Decisions($this->pool);
  11327. $this->watchGraph = new RuleWatchGraph;
  11328. foreach ($this->rules as $rule) {
  11329. $this->watchGraph->insert(new RuleWatchNode($rule));
  11330. }
  11331. $this->makeAssertionRuleDecisions();
  11332. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  11333. $before = microtime(true);
  11334. $this->runSat();
  11335. $this->io->writeError('', true, IOInterface::DEBUG);
  11336. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  11337. if ($this->problems) {
  11338. throw new SolverProblemsException($this->problems, $this->learnedPool);
  11339. }
  11340. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  11341. }
  11342. protected function propagate($level)
  11343. {
  11344. while ($this->decisions->validOffset($this->propagateIndex)) {
  11345. $decision = $this->decisions->atOffset($this->propagateIndex);
  11346. $conflict = $this->watchGraph->propagateLiteral(
  11347. $decision[Decisions::DECISION_LITERAL],
  11348. $level,
  11349. $this->decisions
  11350. );
  11351. $this->propagateIndex++;
  11352. if ($conflict) {
  11353. return $conflict;
  11354. }
  11355. }
  11356. return null;
  11357. }
  11358. private function revert($level)
  11359. {
  11360. while (!$this->decisions->isEmpty()) {
  11361. $literal = $this->decisions->lastLiteral();
  11362. if ($this->decisions->undecided($literal)) {
  11363. break;
  11364. }
  11365. $decisionLevel = $this->decisions->decisionLevel($literal);
  11366. if ($decisionLevel <= $level) {
  11367. break;
  11368. }
  11369. $this->decisions->revertLast();
  11370. $this->propagateIndex = \count($this->decisions);
  11371. }
  11372. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  11373. array_pop($this->branches);
  11374. }
  11375. }
  11376. private function setPropagateLearn($level, $literal, Rule $rule)
  11377. {
  11378. $level++;
  11379. $this->decisions->decide($literal, $level, $rule);
  11380. while (true) {
  11381. $rule = $this->propagate($level);
  11382. if (!$rule) {
  11383. break;
  11384. }
  11385. if ($level == 1) {
  11386. return $this->analyzeUnsolvable($rule);
  11387. }
  11388. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  11389. if ($newLevel <= 0 || $newLevel >= $level) {
  11390. throw new SolverBugException(
  11391. "Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
  11392. );
  11393. }
  11394. if (!$newRule) {
  11395. throw new SolverBugException(
  11396. "No rule was learned from analyzing $rule at level $level."
  11397. );
  11398. }
  11399. $level = $newLevel;
  11400. $this->revert($level);
  11401. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  11402. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  11403. $ruleNode = new RuleWatchNode($newRule);
  11404. $ruleNode->watch2OnHighest($this->decisions);
  11405. $this->watchGraph->insert($ruleNode);
  11406. $this->decisions->decide($learnLiteral, $level, $newRule);
  11407. }
  11408. return $level;
  11409. }
  11410. private function selectAndInstall($level, array $decisionQueue, Rule $rule)
  11411. {
  11412. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  11413. $selectedLiteral = array_shift($literals);
  11414. if (\count($literals)) {
  11415. $this->branches[] = array($literals, $level);
  11416. }
  11417. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  11418. }
  11419. protected function analyze($level, Rule $rule)
  11420. {
  11421. $analyzedRule = $rule;
  11422. $ruleLevel = 1;
  11423. $num = 0;
  11424. $l1num = 0;
  11425. $seen = array();
  11426. $learnedLiterals = array(null);
  11427. $decisionId = \count($this->decisions);
  11428. $this->learnedPool[] = array();
  11429. while (true) {
  11430. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11431. foreach ($rule->getLiterals() as $literal) {
  11432. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  11433. continue;
  11434. }
  11435. if ($this->decisions->satisfy($literal)) {
  11436. continue;
  11437. }
  11438. if (isset($seen[abs($literal)])) {
  11439. continue;
  11440. }
  11441. $seen[abs($literal)] = true;
  11442. $l = $this->decisions->decisionLevel($literal);
  11443. if (1 === $l) {
  11444. $l1num++;
  11445. } elseif ($level === $l) {
  11446. $num++;
  11447. } else {
  11448. $learnedLiterals[] = $literal;
  11449. if ($l > $ruleLevel) {
  11450. $ruleLevel = $l;
  11451. }
  11452. }
  11453. }
  11454. unset($literal);
  11455. $l1retry = true;
  11456. while ($l1retry) {
  11457. $l1retry = false;
  11458. if (!$num && !--$l1num) {
  11459. break 2;
  11460. }
  11461. while (true) {
  11462. if ($decisionId <= 0) {
  11463. throw new SolverBugException(
  11464. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  11465. );
  11466. }
  11467. $decisionId--;
  11468. $decision = $this->decisions->atOffset($decisionId);
  11469. $literal = $decision[Decisions::DECISION_LITERAL];
  11470. if (isset($seen[abs($literal)])) {
  11471. break;
  11472. }
  11473. }
  11474. unset($seen[abs($literal)]);
  11475. if ($num && 0 === --$num) {
  11476. if ($literal < 0) {
  11477. $this->testFlagLearnedPositiveLiteral = true;
  11478. }
  11479. $learnedLiterals[0] = -$literal;
  11480. if (!$l1num) {
  11481. break 2;
  11482. }
  11483. foreach ($learnedLiterals as $i => $learnedLiteral) {
  11484. if ($i !== 0) {
  11485. unset($seen[abs($learnedLiteral)]);
  11486. }
  11487. }
  11488. $l1num++;
  11489. $l1retry = true;
  11490. } else {
  11491. $decision = $this->decisions->atOffset($decisionId);
  11492. $rule = $decision[Decisions::DECISION_REASON];
  11493. if ($rule instanceof MultiConflictRule) {
  11494. foreach ($rule->getLiterals() as $literal) {
  11495. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  11496. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11497. $l = $this->decisions->decisionLevel($literal);
  11498. if (1 === $l) {
  11499. $l1num++;
  11500. } elseif ($level === $l) {
  11501. $num++;
  11502. } else {
  11503. $learnedLiterals[] = $literal;
  11504. if ($l > $ruleLevel) {
  11505. $ruleLevel = $l;
  11506. }
  11507. }
  11508. $seen[abs($literal)] = true;
  11509. break;
  11510. }
  11511. }
  11512. $l1retry = true;
  11513. }
  11514. }
  11515. }
  11516. $decision = $this->decisions->atOffset($decisionId);
  11517. $rule = $decision[Decisions::DECISION_REASON];
  11518. }
  11519. $why = \count($this->learnedPool) - 1;
  11520. if (!$learnedLiterals[0]) {
  11521. throw new SolverBugException(
  11522. "Did not find a learnable literal in analyzed rule $analyzedRule."
  11523. );
  11524. }
  11525. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  11526. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  11527. }
  11528. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen)
  11529. {
  11530. $why = spl_object_hash($conflictRule);
  11531. $ruleSeen[$why] = true;
  11532. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  11533. $learnedWhy = $this->learnedWhy[$why];
  11534. $problemRules = $this->learnedPool[$learnedWhy];
  11535. foreach ($problemRules as $problemRule) {
  11536. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  11537. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  11538. }
  11539. }
  11540. return;
  11541. }
  11542. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  11543. return;
  11544. }
  11545. $problem->nextSection();
  11546. $problem->addRule($conflictRule);
  11547. }
  11548. private function analyzeUnsolvable(Rule $conflictRule)
  11549. {
  11550. $problem = new Problem();
  11551. $problem->addRule($conflictRule);
  11552. $ruleSeen = array();
  11553. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  11554. $this->problems[] = $problem;
  11555. $seen = array();
  11556. $literals = $conflictRule->getLiterals();
  11557. foreach ($literals as $literal) {
  11558. if ($this->decisions->satisfy($literal)) {
  11559. continue;
  11560. }
  11561. $seen[abs($literal)] = true;
  11562. }
  11563. foreach ($this->decisions as $decision) {
  11564. $literal = $decision[Decisions::DECISION_LITERAL];
  11565. if (!isset($seen[abs($literal)])) {
  11566. continue;
  11567. }
  11568. $why = $decision[Decisions::DECISION_REASON];
  11569. $problem->addRule($why);
  11570. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  11571. $literals = $why->getLiterals();
  11572. foreach ($literals as $literal) {
  11573. if ($this->decisions->satisfy($literal)) {
  11574. continue;
  11575. }
  11576. $seen[abs($literal)] = true;
  11577. }
  11578. }
  11579. return 0;
  11580. }
  11581. private function enableDisableLearnedRules()
  11582. {
  11583. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  11584. $why = $this->learnedWhy[spl_object_hash($rule)];
  11585. $problemRules = $this->learnedPool[$why];
  11586. $foundDisabled = false;
  11587. foreach ($problemRules as $problemRule) {
  11588. if ($problemRule->isDisabled()) {
  11589. $foundDisabled = true;
  11590. break;
  11591. }
  11592. }
  11593. if ($foundDisabled && $rule->isEnabled()) {
  11594. $rule->disable();
  11595. } elseif (!$foundDisabled && $rule->isDisabled()) {
  11596. $rule->enable();
  11597. }
  11598. }
  11599. }
  11600. private function runSat()
  11601. {
  11602. $this->propagateIndex = 0;
  11603. $level = 1;
  11604. $systemLevel = $level + 1;
  11605. while (true) {
  11606. if (1 === $level) {
  11607. $conflictRule = $this->propagate($level);
  11608. if (null !== $conflictRule) {
  11609. if ($this->analyzeUnsolvable($conflictRule)) {
  11610. continue;
  11611. }
  11612. return;
  11613. }
  11614. }
  11615. if ($level < $systemLevel) {
  11616. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  11617. foreach ($iterator as $rule) {
  11618. if ($rule->isEnabled()) {
  11619. $decisionQueue = array();
  11620. $noneSatisfied = true;
  11621. foreach ($rule->getLiterals() as $literal) {
  11622. if ($this->decisions->satisfy($literal)) {
  11623. $noneSatisfied = false;
  11624. break;
  11625. }
  11626. if ($literal > 0 && $this->decisions->undecided($literal)) {
  11627. $decisionQueue[] = $literal;
  11628. }
  11629. }
  11630. if ($noneSatisfied && \count($decisionQueue)) {
  11631. $prunedQueue = array();
  11632. foreach ($decisionQueue as $literal) {
  11633. if (isset($this->fixedMap[abs($literal)])) {
  11634. $prunedQueue[] = $literal;
  11635. }
  11636. }
  11637. if (!empty($prunedQueue)) {
  11638. $decisionQueue = $prunedQueue;
  11639. }
  11640. }
  11641. if ($noneSatisfied && \count($decisionQueue)) {
  11642. $oLevel = $level;
  11643. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11644. if (0 === $level) {
  11645. return;
  11646. }
  11647. if ($level <= $oLevel) {
  11648. break;
  11649. }
  11650. }
  11651. }
  11652. }
  11653. $systemLevel = $level + 1;
  11654. $iterator->next();
  11655. if ($iterator->valid()) {
  11656. continue;
  11657. }
  11658. }
  11659. if ($level < $systemLevel) {
  11660. $systemLevel = $level;
  11661. }
  11662. $rulesCount = \count($this->rules);
  11663. $pass = 1;
  11664. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  11665. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  11666. if ($i == $rulesCount) {
  11667. if (1 === $pass) {
  11668. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  11669. } else {
  11670. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  11671. }
  11672. $i = 0;
  11673. $pass++;
  11674. }
  11675. $rule = $this->rules->ruleById[$i];
  11676. $literals = $rule->getLiterals();
  11677. if ($rule->isDisabled()) {
  11678. continue;
  11679. }
  11680. $decisionQueue = array();
  11681. foreach ($literals as $literal) {
  11682. if ($literal <= 0) {
  11683. if (!$this->decisions->decidedInstall($literal)) {
  11684. continue 2;
  11685. }
  11686. } else {
  11687. if ($this->decisions->decidedInstall($literal)) {
  11688. continue 2;
  11689. }
  11690. if ($this->decisions->undecided($literal)) {
  11691. $decisionQueue[] = $literal;
  11692. }
  11693. }
  11694. }
  11695. if (\count($decisionQueue) < 2) {
  11696. continue;
  11697. }
  11698. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11699. if (0 === $level) {
  11700. return;
  11701. }
  11702. $rulesCount = \count($this->rules);
  11703. $n = -1;
  11704. }
  11705. if ($level < $systemLevel) {
  11706. continue;
  11707. }
  11708. if (\count($this->branches)) {
  11709. $lastLiteral = null;
  11710. $lastLevel = null;
  11711. $lastBranchIndex = 0;
  11712. $lastBranchOffset = 0;
  11713. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  11714. list($literals, $l) = $this->branches[$i];
  11715. foreach ($literals as $offset => $literal) {
  11716. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  11717. $lastLiteral = $literal;
  11718. $lastBranchIndex = $i;
  11719. $lastBranchOffset = $offset;
  11720. $lastLevel = $l;
  11721. }
  11722. }
  11723. }
  11724. if ($lastLiteral) {
  11725. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  11726. $level = $lastLevel;
  11727. $this->revert($level);
  11728. $why = $this->decisions->lastReason();
  11729. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  11730. if ($level == 0) {
  11731. return;
  11732. }
  11733. continue;
  11734. }
  11735. }
  11736. break;
  11737. }
  11738. }
  11739. }
  11740. <?php
  11741. namespace Composer\DependencyResolver;
  11742. class SolverBugException extends \RuntimeException
  11743. {
  11744. public function __construct($message)
  11745. {
  11746. parent::__construct(
  11747. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  11748. "Please report the command you ran, the exact error you received, and your composer.json on https://github.com/composer/composer/issues - thank you!\n"
  11749. );
  11750. }
  11751. }
  11752. <?php
  11753. namespace Composer\DependencyResolver;
  11754. use Composer\Util\IniHelper;
  11755. use Composer\Repository\RepositorySet;
  11756. class SolverProblemsException extends \RuntimeException
  11757. {
  11758. protected $problems;
  11759. protected $learnedPool;
  11760. public function __construct(array $problems, array $learnedPool)
  11761. {
  11762. $this->problems = $problems;
  11763. $this->learnedPool = $learnedPool;
  11764. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', 2);
  11765. }
  11766. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
  11767. {
  11768. $installedMap = $request->getPresentMap(true);
  11769. $hasExtensionProblems = false;
  11770. $isCausedByLock = false;
  11771. $problems = array();
  11772. foreach ($this->problems as $problem) {
  11773. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  11774. if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
  11775. $hasExtensionProblems = true;
  11776. }
  11777. $isCausedByLock |= $problem->isCausedByLock($repositorySet, $request, $pool);
  11778. }
  11779. $i = 1;
  11780. $text = "\n";
  11781. foreach (array_unique($problems) as $problem) {
  11782. $text .= " Problem ".($i++).$problem;
  11783. }
  11784. $hints = array();
  11785. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  11786. $hints[] = "Potential causes:\n - A typo in the package name\n - The package is not available in a stable-enough version according to your minimum-stability setting\n see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.\n - It's a private package and you forgot to add a custom repository to find it\n\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
  11787. }
  11788. if ($hasExtensionProblems) {
  11789. $hints[] = $this->createExtensionHint();
  11790. }
  11791. if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
  11792. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  11793. }
  11794. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  11795. $hints[] = "<warning>ocramius/package-versions only provides support for Composer 2 in 1.8+, which requires PHP 7.4.</warning>\nIf you can not upgrade PHP you can require <info>composer/package-versions-deprecated</info> to resolve this with PHP 7.0+.";
  11796. }
  11797. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  11798. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  11799. $hints[] = "You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.";
  11800. }
  11801. }
  11802. if ($hints) {
  11803. $text .= "\n" . implode("\n\n", $hints);
  11804. }
  11805. return $text;
  11806. }
  11807. public function getProblems()
  11808. {
  11809. return $this->problems;
  11810. }
  11811. private function createExtensionHint()
  11812. {
  11813. $paths = IniHelper::getAll();
  11814. if (count($paths) === 1 && empty($paths[0])) {
  11815. return '';
  11816. }
  11817. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  11818. $text .= implode("\n - ", $paths);
  11819. $text .= "\nYou can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
  11820. return $text;
  11821. }
  11822. private function hasExtensionProblems(array $reasonSets)
  11823. {
  11824. foreach ($reasonSets as $reasonSet) {
  11825. foreach ($reasonSet as $rule) {
  11826. if (0 === strpos($rule->getRequiredPackage(), 'ext-')) {
  11827. return true;
  11828. }
  11829. }
  11830. }
  11831. return false;
  11832. }
  11833. }
  11834. <?php
  11835. namespace Composer\DependencyResolver;
  11836. use Composer\Package\AliasPackage;
  11837. use Composer\Package\Link;
  11838. use Composer\Package\PackageInterface;
  11839. use Composer\Repository\PlatformRepository;
  11840. class Transaction
  11841. {
  11842. protected $operations;
  11843. protected $presentPackages;
  11844. protected $resultPackageMap;
  11845. protected $resultPackagesByName = array();
  11846. public function __construct($presentPackages, $resultPackages)
  11847. {
  11848. $this->presentPackages = $presentPackages;
  11849. $this->setResultPackageMaps($resultPackages);
  11850. $this->operations = $this->calculateOperations();
  11851. }
  11852. public function getOperations()
  11853. {
  11854. return $this->operations;
  11855. }
  11856. private function setResultPackageMaps($resultPackages)
  11857. {
  11858. $packageSort = function (PackageInterface $a, PackageInterface $b) {
  11859. if ($a->getName() == $b->getName()) {
  11860. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  11861. return $a instanceof AliasPackage ? -1 : 1;
  11862. }
  11863. return strcmp($b->getVersion(), $a->getVersion());
  11864. }
  11865. return strcmp($b->getName(), $a->getName());
  11866. };
  11867. $this->resultPackageMap = array();
  11868. foreach ($resultPackages as $package) {
  11869. $this->resultPackageMap[spl_object_hash($package)] = $package;
  11870. foreach ($package->getNames() as $name) {
  11871. $this->resultPackagesByName[$name][] = $package;
  11872. }
  11873. }
  11874. uasort($this->resultPackageMap, $packageSort);
  11875. foreach ($this->resultPackagesByName as $name => $packages) {
  11876. uasort($this->resultPackagesByName[$name], $packageSort);
  11877. }
  11878. }
  11879. protected function calculateOperations()
  11880. {
  11881. $operations = array();
  11882. $presentPackageMap = array();
  11883. $removeMap = array();
  11884. $presentAliasMap = array();
  11885. $removeAliasMap = array();
  11886. foreach ($this->presentPackages as $package) {
  11887. if ($package instanceof AliasPackage) {
  11888. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11889. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11890. } else {
  11891. $presentPackageMap[$package->getName()] = $package;
  11892. $removeMap[$package->getName()] = $package;
  11893. }
  11894. }
  11895. $stack = $this->getRootPackages();
  11896. $visited = array();
  11897. $processed = array();
  11898. while (!empty($stack)) {
  11899. $package = array_pop($stack);
  11900. if (isset($processed[spl_object_hash($package)])) {
  11901. continue;
  11902. }
  11903. if (!isset($visited[spl_object_hash($package)])) {
  11904. $visited[spl_object_hash($package)] = true;
  11905. $stack[] = $package;
  11906. if ($package instanceof AliasPackage) {
  11907. $stack[] = $package->getAliasOf();
  11908. } else {
  11909. foreach ($package->getRequires() as $link) {
  11910. $possibleRequires = $this->getProvidersInResult($link);
  11911. foreach ($possibleRequires as $require) {
  11912. $stack[] = $require;
  11913. }
  11914. }
  11915. }
  11916. } elseif (!isset($processed[spl_object_hash($package)])) {
  11917. $processed[spl_object_hash($package)] = true;
  11918. if ($package instanceof AliasPackage) {
  11919. $aliasKey = $package->getName().'::'.$package->getVersion();
  11920. if (isset($presentAliasMap[$aliasKey])) {
  11921. unset($removeAliasMap[$aliasKey]);
  11922. } else {
  11923. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  11924. }
  11925. } else {
  11926. if (isset($presentPackageMap[$package->getName()])) {
  11927. $source = $presentPackageMap[$package->getName()];
  11928. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  11929. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  11930. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  11931. ) {
  11932. $operations[] = new Operation\UpdateOperation($source, $package);
  11933. }
  11934. unset($removeMap[$package->getName()]);
  11935. } else {
  11936. $operations[] = new Operation\InstallOperation($package);
  11937. unset($removeMap[$package->getName()]);
  11938. }
  11939. }
  11940. }
  11941. }
  11942. foreach ($removeMap as $name => $package) {
  11943. array_unshift($operations, new Operation\UninstallOperation($package));
  11944. }
  11945. foreach ($removeAliasMap as $nameVersion => $package) {
  11946. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  11947. }
  11948. $operations = $this->movePluginsToFront($operations);
  11949. $operations = $this->moveUninstallsToFront($operations);
  11950. return $this->operations = $operations;
  11951. }
  11952. protected function getRootPackages()
  11953. {
  11954. $roots = $this->resultPackageMap;
  11955. foreach ($this->resultPackageMap as $packageHash => $package) {
  11956. if (!isset($roots[$packageHash])) {
  11957. continue;
  11958. }
  11959. foreach ($package->getRequires() as $link) {
  11960. $possibleRequires = $this->getProvidersInResult($link);
  11961. foreach ($possibleRequires as $require) {
  11962. if ($require !== $package) {
  11963. unset($roots[spl_object_hash($require)]);
  11964. }
  11965. }
  11966. }
  11967. }
  11968. return $roots;
  11969. }
  11970. protected function getProvidersInResult(Link $link)
  11971. {
  11972. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  11973. return array();
  11974. }
  11975. return $this->resultPackagesByName[$link->getTarget()];
  11976. }
  11977. private function movePluginsToFront(array $operations)
  11978. {
  11979. $dlModifyingPluginsNoDeps = array();
  11980. $dlModifyingPluginsWithDeps = array();
  11981. $dlModifyingPluginRequires = array();
  11982. $pluginsNoDeps = array();
  11983. $pluginsWithDeps = array();
  11984. $pluginRequires = array();
  11985. foreach (array_reverse($operations, true) as $idx => $op) {
  11986. if ($op instanceof Operation\InstallOperation) {
  11987. $package = $op->getPackage();
  11988. } elseif ($op instanceof Operation\UpdateOperation) {
  11989. $package = $op->getTargetPackage();
  11990. } else {
  11991. continue;
  11992. }
  11993. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  11994. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  11995. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  11996. return !PlatformRepository::isPlatformPackage($req);
  11997. });
  11998. if ($isDownloadsModifyingPlugin && !count($requires)) {
  11999. array_unshift($dlModifyingPluginsNoDeps, $op);
  12000. } else {
  12001. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  12002. array_unshift($dlModifyingPluginsWithDeps, $op);
  12003. }
  12004. unset($operations[$idx]);
  12005. continue;
  12006. }
  12007. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  12008. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  12009. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  12010. return !PlatformRepository::isPlatformPackage($req);
  12011. });
  12012. if ($isPlugin && !count($requires)) {
  12013. array_unshift($pluginsNoDeps, $op);
  12014. } else {
  12015. $pluginRequires = array_merge($pluginRequires, $requires);
  12016. array_unshift($pluginsWithDeps, $op);
  12017. }
  12018. unset($operations[$idx]);
  12019. }
  12020. }
  12021. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  12022. }
  12023. private function moveUninstallsToFront(array $operations)
  12024. {
  12025. $uninstOps = array();
  12026. foreach ($operations as $idx => $op) {
  12027. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  12028. $uninstOps[] = $op;
  12029. unset($operations[$idx]);
  12030. }
  12031. }
  12032. return array_merge($uninstOps, $operations);
  12033. }
  12034. }
  12035. <?php
  12036. namespace Composer\Downloader;
  12037. use Composer\Package\PackageInterface;
  12038. use Symfony\Component\Finder\Finder;
  12039. use React\Promise\PromiseInterface;
  12040. use Composer\DependencyResolver\Operation\InstallOperation;
  12041. abstract class ArchiveDownloader extends FileDownloader
  12042. {
  12043. public function install(PackageInterface $package, $path, $output = true)
  12044. {
  12045. if ($output) {
  12046. $this->io->writeError(" - " . InstallOperation::format($package).": Extracting archive");
  12047. } else {
  12048. $this->io->writeError('Extracting archive', false);
  12049. }
  12050. $vendorDir = $this->config->get('vendor-dir');
  12051. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  12052. $this->filesystem->emptyDirectory($path);
  12053. }
  12054. do {
  12055. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  12056. } while (is_dir($temporaryDir));
  12057. $this->addCleanupPath($package, $temporaryDir);
  12058. if (!is_dir($path) || realpath($path) !== getcwd()) {
  12059. $this->addCleanupPath($package, $path);
  12060. }
  12061. $this->filesystem->ensureDirectoryExists($temporaryDir);
  12062. $fileName = $this->getFileName($package, $path);
  12063. $filesystem = $this->filesystem;
  12064. $self = $this;
  12065. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package, $self) {
  12066. $self->clearLastCacheWrite($package);
  12067. $filesystem->removeDirectory($temporaryDir);
  12068. if (is_dir($path) && realpath($path) !== getcwd()) {
  12069. $filesystem->removeDirectory($path);
  12070. }
  12071. $self->removeCleanupPath($package, $temporaryDir);
  12072. $self->removeCleanupPath($package, realpath($path));
  12073. };
  12074. $promise = null;
  12075. try {
  12076. $promise = $this->extract($package, $fileName, $temporaryDir);
  12077. } catch (\Exception $e) {
  12078. $cleanup();
  12079. throw $e;
  12080. }
  12081. if (!$promise instanceof PromiseInterface) {
  12082. $promise = \React\Promise\resolve();
  12083. }
  12084. return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) {
  12085. $filesystem->unlink($fileName);
  12086. $getFolderContent = function ($dir) {
  12087. $finder = Finder::create()
  12088. ->ignoreVCS(false)
  12089. ->ignoreDotFiles(false)
  12090. ->notName('.DS_Store')
  12091. ->depth(0)
  12092. ->in($dir);
  12093. return iterator_to_array($finder);
  12094. };
  12095. $renameRecursively = null;
  12096. $renameRecursively = function ($from, $to) use ($filesystem, $getFolderContent, $package, &$renameRecursively) {
  12097. $contentDir = $getFolderContent($from);
  12098. foreach ($contentDir as $file) {
  12099. $file = (string) $file;
  12100. if (is_dir($to . '/' . basename($file))) {
  12101. if (!is_dir($file)) {
  12102. throw new \RuntimeException('Installing '.$package.' would lead to overwriting the '.$to.'/'.basename($file).' directory with a file from the package, invalid operation.');
  12103. }
  12104. $renameRecursively($file, $to . '/' . basename($file));
  12105. } else {
  12106. $filesystem->rename($file, $to . '/' . basename($file));
  12107. }
  12108. }
  12109. };
  12110. $renameAsOne = false;
  12111. if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectory($path))) {
  12112. $renameAsOne = true;
  12113. }
  12114. $contentDir = $getFolderContent($temporaryDir);
  12115. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));
  12116. if ($renameAsOne) {
  12117. if ($singleDirAtTopLevel) {
  12118. $extractedDir = (string) reset($contentDir);
  12119. } else {
  12120. $extractedDir = $temporaryDir;
  12121. }
  12122. $filesystem->rename($extractedDir, $path);
  12123. } else {
  12124. $from = $temporaryDir;
  12125. if ($singleDirAtTopLevel) {
  12126. $from = (string) reset($contentDir);
  12127. }
  12128. $renameRecursively($from, $path);
  12129. }
  12130. $filesystem->removeDirectory($temporaryDir);
  12131. $self->removeCleanupPath($package, $temporaryDir);
  12132. $self->removeCleanupPath($package, $path);
  12133. }, function ($e) use ($cleanup) {
  12134. $cleanup();
  12135. throw $e;
  12136. });
  12137. }
  12138. abstract protected function extract(PackageInterface $package, $file, $path);
  12139. }
  12140. <?php
  12141. namespace Composer\Downloader;
  12142. use Composer\Package\PackageInterface;
  12143. interface ChangeReportInterface
  12144. {
  12145. public function getLocalChanges(PackageInterface $package, $path);
  12146. }
  12147. <?php
  12148. namespace Composer\Downloader;
  12149. use Composer\Package\PackageInterface;
  12150. use Composer\IO\IOInterface;
  12151. use Composer\Util\Filesystem;
  12152. use Composer\Exception\IrrecoverableDownloadException;
  12153. use React\Promise\PromiseInterface;
  12154. class DownloadManager
  12155. {
  12156. private $io;
  12157. private $preferDist = false;
  12158. private $preferSource;
  12159. private $packagePreferences = array();
  12160. private $filesystem;
  12161. private $downloaders = array();
  12162. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  12163. {
  12164. $this->io = $io;
  12165. $this->preferSource = $preferSource;
  12166. $this->filesystem = $filesystem ?: new Filesystem();
  12167. }
  12168. public function setPreferSource($preferSource)
  12169. {
  12170. $this->preferSource = $preferSource;
  12171. return $this;
  12172. }
  12173. public function setPreferDist($preferDist)
  12174. {
  12175. $this->preferDist = $preferDist;
  12176. return $this;
  12177. }
  12178. public function setPreferences(array $preferences)
  12179. {
  12180. $this->packagePreferences = $preferences;
  12181. return $this;
  12182. }
  12183. public function setDownloader($type, DownloaderInterface $downloader)
  12184. {
  12185. $type = strtolower($type);
  12186. $this->downloaders[$type] = $downloader;
  12187. return $this;
  12188. }
  12189. public function getDownloader($type)
  12190. {
  12191. $type = strtolower($type);
  12192. if (!isset($this->downloaders[$type])) {
  12193. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  12194. }
  12195. return $this->downloaders[$type];
  12196. }
  12197. public function getDownloaderForPackage(PackageInterface $package)
  12198. {
  12199. $installationSource = $package->getInstallationSource();
  12200. if ('metapackage' === $package->getType()) {
  12201. return;
  12202. }
  12203. if ('dist' === $installationSource) {
  12204. $downloader = $this->getDownloader($package->getDistType());
  12205. } elseif ('source' === $installationSource) {
  12206. $downloader = $this->getDownloader($package->getSourceType());
  12207. } else {
  12208. throw new \InvalidArgumentException(
  12209. 'Package '.$package.' does not have an installation source set'
  12210. );
  12211. }
  12212. if ($installationSource !== $downloader->getInstallationSource()) {
  12213. throw new \LogicException(sprintf(
  12214. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  12215. get_class($downloader),
  12216. $downloader->getInstallationSource(),
  12217. $installationSource,
  12218. $package
  12219. ));
  12220. }
  12221. return $downloader;
  12222. }
  12223. public function getDownloaderType(DownloaderInterface $downloader)
  12224. {
  12225. return array_search($downloader, $this->downloaders);
  12226. }
  12227. public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12228. {
  12229. $targetDir = $this->normalizeTargetDir($targetDir);
  12230. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  12231. $sources = $this->getAvailableSources($package, $prevPackage);
  12232. $io = $this->io;
  12233. $self = $this;
  12234. $download = function ($retry = false) use (&$sources, $io, $package, $self, $targetDir, &$download, $prevPackage) {
  12235. $source = array_shift($sources);
  12236. if ($retry) {
  12237. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  12238. }
  12239. $package->setInstallationSource($source);
  12240. $downloader = $self->getDownloaderForPackage($package);
  12241. if (!$downloader) {
  12242. return \React\Promise\resolve();
  12243. }
  12244. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  12245. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  12246. if (!$sources) {
  12247. throw $e;
  12248. }
  12249. $io->writeError(
  12250. ' <warning>Failed to download '.
  12251. $package->getPrettyName().
  12252. ' from ' . $source . ': '.
  12253. $e->getMessage().'</warning>'
  12254. );
  12255. return $download(true);
  12256. }
  12257. throw $e;
  12258. };
  12259. try {
  12260. $result = $downloader->download($package, $targetDir, $prevPackage);
  12261. } catch (\Exception $e) {
  12262. return $handleError($e);
  12263. }
  12264. if (!$result instanceof PromiseInterface) {
  12265. return \React\Promise\resolve($result);
  12266. }
  12267. $res = $result->then(function ($res) {
  12268. return $res;
  12269. }, $handleError);
  12270. return $res;
  12271. };
  12272. return $download();
  12273. }
  12274. public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12275. {
  12276. $targetDir = $this->normalizeTargetDir($targetDir);
  12277. $downloader = $this->getDownloaderForPackage($package);
  12278. if ($downloader) {
  12279. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  12280. }
  12281. }
  12282. public function install(PackageInterface $package, $targetDir)
  12283. {
  12284. $targetDir = $this->normalizeTargetDir($targetDir);
  12285. $downloader = $this->getDownloaderForPackage($package);
  12286. if ($downloader) {
  12287. return $downloader->install($package, $targetDir);
  12288. }
  12289. }
  12290. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  12291. {
  12292. $targetDir = $this->normalizeTargetDir($targetDir);
  12293. $downloader = $this->getDownloaderForPackage($target);
  12294. $initialDownloader = $this->getDownloaderForPackage($initial);
  12295. if (!$initialDownloader && !$downloader) {
  12296. return;
  12297. }
  12298. if (!$downloader) {
  12299. return $initialDownloader->remove($initial, $targetDir);
  12300. }
  12301. $initialType = $this->getDownloaderType($initialDownloader);
  12302. $targetType = $this->getDownloaderType($downloader);
  12303. if ($initialType === $targetType) {
  12304. try {
  12305. return $downloader->update($initial, $target, $targetDir);
  12306. } catch (\RuntimeException $e) {
  12307. if (!$this->io->isInteractive()) {
  12308. throw $e;
  12309. }
  12310. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  12311. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  12312. throw $e;
  12313. }
  12314. }
  12315. }
  12316. $promise = $initialDownloader->remove($initial, $targetDir);
  12317. if ($promise) {
  12318. $self = $this;
  12319. return $promise->then(function ($res) use ($self, $target, $targetDir) {
  12320. return $self->install($target, $targetDir);
  12321. });
  12322. }
  12323. return $this->install($target, $targetDir);
  12324. }
  12325. public function remove(PackageInterface $package, $targetDir)
  12326. {
  12327. $targetDir = $this->normalizeTargetDir($targetDir);
  12328. $downloader = $this->getDownloaderForPackage($package);
  12329. if ($downloader) {
  12330. return $downloader->remove($package, $targetDir);
  12331. }
  12332. }
  12333. public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12334. {
  12335. $targetDir = $this->normalizeTargetDir($targetDir);
  12336. $downloader = $this->getDownloaderForPackage($package);
  12337. if ($downloader) {
  12338. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  12339. }
  12340. }
  12341. protected function resolvePackageInstallPreference(PackageInterface $package)
  12342. {
  12343. foreach ($this->packagePreferences as $pattern => $preference) {
  12344. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  12345. if (preg_match($pattern, $package->getName())) {
  12346. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  12347. return 'dist';
  12348. }
  12349. return 'source';
  12350. }
  12351. }
  12352. return $package->isDev() ? 'source' : 'dist';
  12353. }
  12354. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
  12355. {
  12356. $sourceType = $package->getSourceType();
  12357. $distType = $package->getDistType();
  12358. $sources = array();
  12359. if ($sourceType) {
  12360. $sources[] = 'source';
  12361. }
  12362. if ($distType) {
  12363. $sources[] = 'dist';
  12364. }
  12365. if (empty($sources)) {
  12366. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  12367. }
  12368. if (
  12369. $prevPackage
  12370. && in_array($prevPackage->getInstallationSource(), $sources, true)
  12371. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  12372. ) {
  12373. $prevSource = $prevPackage->getInstallationSource();
  12374. usort($sources, function ($a, $b) use ($prevSource) {
  12375. return $a === $prevSource ? -1 : 1;
  12376. });
  12377. return $sources;
  12378. }
  12379. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  12380. $sources = array_reverse($sources);
  12381. }
  12382. return $sources;
  12383. }
  12384. private function normalizeTargetDir($dir)
  12385. {
  12386. if ($dir === '\\' || $dir === '/') {
  12387. return $dir;
  12388. }
  12389. return rtrim($dir, '\\/');
  12390. }
  12391. }
  12392. <?php
  12393. namespace Composer\Downloader;
  12394. use Composer\Package\PackageInterface;
  12395. use React\Promise\PromiseInterface;
  12396. interface DownloaderInterface
  12397. {
  12398. public function getInstallationSource();
  12399. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12400. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12401. public function install(PackageInterface $package, $path);
  12402. public function update(PackageInterface $initial, PackageInterface $target, $path);
  12403. public function remove(PackageInterface $package, $path);
  12404. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12405. }
  12406. <?php
  12407. namespace Composer\Downloader;
  12408. use Composer\Package\PackageInterface;
  12409. interface DvcsDownloaderInterface
  12410. {
  12411. public function getUnpushedChanges(PackageInterface $package, $path);
  12412. }
  12413. <?php
  12414. namespace Composer\Downloader;
  12415. use Composer\Config;
  12416. use Composer\Cache;
  12417. use Composer\IO\IOInterface;
  12418. use Composer\IO\NullIO;
  12419. use Composer\Exception\IrrecoverableDownloadException;
  12420. use Composer\Package\Comparer\Comparer;
  12421. use Composer\DependencyResolver\Operation\UpdateOperation;
  12422. use Composer\DependencyResolver\Operation\InstallOperation;
  12423. use Composer\DependencyResolver\Operation\UninstallOperation;
  12424. use Composer\Package\PackageInterface;
  12425. use Composer\Plugin\PluginEvents;
  12426. use Composer\Plugin\PostFileDownloadEvent;
  12427. use Composer\Plugin\PreFileDownloadEvent;
  12428. use Composer\EventDispatcher\EventDispatcher;
  12429. use Composer\Util\Filesystem;
  12430. use Composer\Util\Silencer;
  12431. use Composer\Util\HttpDownloader;
  12432. use Composer\Util\Url as UrlUtil;
  12433. use Composer\Util\ProcessExecutor;
  12434. use React\Promise\PromiseInterface;
  12435. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  12436. {
  12437. protected $io;
  12438. protected $config;
  12439. protected $httpDownloader;
  12440. protected $filesystem;
  12441. protected $cache;
  12442. protected $eventDispatcher;
  12443. protected $process;
  12444. public $lastCacheWrites = array();
  12445. private $additionalCleanupPaths = array();
  12446. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  12447. {
  12448. $this->io = $io;
  12449. $this->config = $config;
  12450. $this->eventDispatcher = $eventDispatcher;
  12451. $this->httpDownloader = $httpDownloader;
  12452. $this->cache = $cache;
  12453. $this->process = $process ?: new ProcessExecutor($io);
  12454. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  12455. if ($this->cache && $this->cache->gcIsNecessary()) {
  12456. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  12457. }
  12458. }
  12459. public function getInstallationSource()
  12460. {
  12461. return 'dist';
  12462. }
  12463. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  12464. {
  12465. if (!$package->getDistUrl()) {
  12466. throw new \InvalidArgumentException('The given package is missing url information');
  12467. }
  12468. $cacheKeyGenerator = function (PackageInterface $package, $key) {
  12469. $cacheKey = sha1($key);
  12470. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  12471. };
  12472. $retries = 3;
  12473. $urls = $package->getDistUrls();
  12474. foreach ($urls as $index => $url) {
  12475. $processedUrl = $this->processUrl($package, $url);
  12476. $urls[$index] = array(
  12477. 'base' => $url,
  12478. 'processed' => $processedUrl,
  12479. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  12480. );
  12481. }
  12482. $fileName = $this->getFileName($package, $path);
  12483. $this->filesystem->ensureDirectoryExists($path);
  12484. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  12485. $io = $this->io;
  12486. $cache = $this->cache;
  12487. $httpDownloader = $this->httpDownloader;
  12488. $eventDispatcher = $this->eventDispatcher;
  12489. $filesystem = $this->filesystem;
  12490. $self = $this;
  12491. $accept = null;
  12492. $reject = null;
  12493. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject) {
  12494. $url = reset($urls);
  12495. $index = key($urls);
  12496. if ($eventDispatcher) {
  12497. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  12498. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  12499. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  12500. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  12501. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  12502. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  12503. }
  12504. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  12505. }
  12506. $urls[$index] = $url;
  12507. $checksum = $package->getDistSha1Checksum();
  12508. $cacheKey = $url['cacheKey'];
  12509. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  12510. if ($output) {
  12511. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  12512. }
  12513. $result = \React\Promise\resolve($fileName);
  12514. } else {
  12515. if ($output) {
  12516. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  12517. }
  12518. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  12519. ->then($accept, $reject);
  12520. }
  12521. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher) {
  12522. if (null === $result) {
  12523. return $fileName;
  12524. }
  12525. if (!file_exists($fileName)) {
  12526. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  12527. .' directory is writable and you have internet connectivity');
  12528. }
  12529. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  12530. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  12531. }
  12532. if ($eventDispatcher) {
  12533. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], $package);
  12534. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  12535. }
  12536. return $fileName;
  12537. });
  12538. };
  12539. $accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
  12540. $url = reset($urls);
  12541. $cacheKey = $url['cacheKey'];
  12542. if ($cache && !$cache->isReadOnly()) {
  12543. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  12544. $cache->copyFrom($cacheKey, $fileName);
  12545. }
  12546. $response->collect();
  12547. return $fileName;
  12548. };
  12549. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem, $self) {
  12550. if (file_exists($fileName)) {
  12551. $filesystem->unlink($fileName);
  12552. }
  12553. $self->clearLastCacheWrite($package);
  12554. if ($e instanceof IrrecoverableDownloadException) {
  12555. throw $e;
  12556. }
  12557. if ($e instanceof MaxFileSizeExceededException) {
  12558. throw $e;
  12559. }
  12560. if ($e instanceof TransportException) {
  12561. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  12562. $retries = 0;
  12563. }
  12564. }
  12565. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  12566. $retries = 0;
  12567. $urls = array();
  12568. }
  12569. if ($retries) {
  12570. usleep(500000);
  12571. $retries--;
  12572. return $download();
  12573. }
  12574. array_shift($urls);
  12575. if ($urls) {
  12576. if ($io->isDebug()) {
  12577. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  12578. $io->writeError(' Trying the next URL for '.$package->getName());
  12579. } else {
  12580. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  12581. }
  12582. $retries = 3;
  12583. usleep(100000);
  12584. return $download();
  12585. }
  12586. throw $e;
  12587. };
  12588. return $download();
  12589. }
  12590. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12591. {
  12592. }
  12593. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12594. {
  12595. $fileName = $this->getFileName($package, $path);
  12596. if (file_exists($fileName)) {
  12597. $this->filesystem->unlink($fileName);
  12598. }
  12599. $dirsToCleanUp = array(
  12600. $this->config->get('vendor-dir').'/composer/',
  12601. $this->config->get('vendor-dir'),
  12602. $path,
  12603. );
  12604. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12605. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  12606. $this->filesystem->remove($path);
  12607. }
  12608. }
  12609. foreach ($dirsToCleanUp as $dir) {
  12610. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
  12611. $this->filesystem->removeDirectory($dir);
  12612. }
  12613. }
  12614. }
  12615. public function install(PackageInterface $package, $path, $output = true)
  12616. {
  12617. if ($output) {
  12618. $this->io->writeError(" - " . InstallOperation::format($package));
  12619. }
  12620. $this->filesystem->emptyDirectory($path);
  12621. $this->filesystem->ensureDirectoryExists($path);
  12622. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
  12623. if ($package->getBinaries()) {
  12624. foreach ($package->getBinaries() as $bin) {
  12625. if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
  12626. Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
  12627. }
  12628. }
  12629. }
  12630. }
  12631. public function clearLastCacheWrite(PackageInterface $package)
  12632. {
  12633. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  12634. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  12635. unset($this->lastCacheWrites[$package->getName()]);
  12636. }
  12637. }
  12638. public function addCleanupPath(PackageInterface $package, $path)
  12639. {
  12640. $this->additionalCleanupPaths[$package->getName()][] = $path;
  12641. }
  12642. public function removeCleanupPath(PackageInterface $package, $path)
  12643. {
  12644. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12645. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  12646. if (false !== $idx) {
  12647. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  12648. }
  12649. }
  12650. }
  12651. public function update(PackageInterface $initial, PackageInterface $target, $path)
  12652. {
  12653. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . ": ", false);
  12654. $promise = $this->remove($initial, $path, false);
  12655. if ($promise === null || !$promise instanceof PromiseInterface) {
  12656. $promise = \React\Promise\resolve();
  12657. }
  12658. $self = $this;
  12659. $io = $this->io;
  12660. return $promise->then(function () use ($self, $target, $path, $io) {
  12661. $promise = $self->install($target, $path, false);
  12662. $io->writeError('');
  12663. return $promise;
  12664. });
  12665. }
  12666. public function remove(PackageInterface $package, $path, $output = true)
  12667. {
  12668. if ($output) {
  12669. $this->io->writeError(" - " . UninstallOperation::format($package));
  12670. }
  12671. if (!$this->filesystem->removeDirectory($path)) {
  12672. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  12673. }
  12674. }
  12675. protected function getFileName(PackageInterface $package, $path)
  12676. {
  12677. return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
  12678. }
  12679. protected function processUrl(PackageInterface $package, $url)
  12680. {
  12681. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  12682. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  12683. }
  12684. if ($package->getDistReference()) {
  12685. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  12686. }
  12687. return $url;
  12688. }
  12689. public function getLocalChanges(PackageInterface $package, $targetDir)
  12690. {
  12691. $prevIO = $this->io;
  12692. $this->io = new NullIO;
  12693. $this->io->loadConfiguration($this->config);
  12694. $e = null;
  12695. $output = '';
  12696. $targetDir = Filesystem::trimTrailingSlash($targetDir);
  12697. try {
  12698. if (is_dir($targetDir.'_compare')) {
  12699. $this->filesystem->removeDirectory($targetDir.'_compare');
  12700. }
  12701. $this->download($package, $targetDir.'_compare', null, false);
  12702. $this->httpDownloader->wait();
  12703. $this->install($package, $targetDir.'_compare', false);
  12704. $this->process->wait();
  12705. $comparer = new Comparer();
  12706. $comparer->setSource($targetDir.'_compare');
  12707. $comparer->setUpdate($targetDir);
  12708. $comparer->doCompare();
  12709. $output = $comparer->getChanged(true, true);
  12710. $this->filesystem->removeDirectory($targetDir.'_compare');
  12711. } catch (\Exception $e) {
  12712. }
  12713. $this->io = $prevIO;
  12714. if ($e) {
  12715. throw $e;
  12716. }
  12717. return trim($output);
  12718. }
  12719. }
  12720. <?php
  12721. namespace Composer\Downloader;
  12722. class FilesystemException extends \Exception
  12723. {
  12724. public function __construct($message = '', $code = 0, \Exception $previous = null)
  12725. {
  12726. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  12727. }
  12728. }
  12729. <?php
  12730. namespace Composer\Downloader;
  12731. use Composer\Package\PackageInterface;
  12732. use Composer\Util\ProcessExecutor;
  12733. class FossilDownloader extends VcsDownloader
  12734. {
  12735. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12736. {
  12737. }
  12738. protected function doInstall(PackageInterface $package, $path, $url)
  12739. {
  12740. $this->config->prohibitUrlByConfig($url, $this->io);
  12741. $url = ProcessExecutor::escape($url);
  12742. $ref = ProcessExecutor::escape($package->getSourceReference());
  12743. $repoFile = $path . '.fossil';
  12744. $this->io->writeError("Cloning ".$package->getSourceReference());
  12745. $command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape($repoFile));
  12746. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  12747. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12748. }
  12749. $command = sprintf('fossil open %s --nested', ProcessExecutor::escape($repoFile));
  12750. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12751. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12752. }
  12753. $command = sprintf('fossil update %s', $ref);
  12754. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12755. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12756. }
  12757. }
  12758. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12759. {
  12760. $this->config->prohibitUrlByConfig($url, $this->io);
  12761. $ref = ProcessExecutor::escape($target->getSourceReference());
  12762. $this->io->writeError(" Updating to ".$target->getSourceReference());
  12763. if (!$this->hasMetadataRepository($path)) {
  12764. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12765. }
  12766. $command = sprintf('fossil pull && fossil up %s', $ref);
  12767. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12768. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12769. }
  12770. }
  12771. public function getLocalChanges(PackageInterface $package, $path)
  12772. {
  12773. if (!$this->hasMetadataRepository($path)) {
  12774. return null;
  12775. }
  12776. $this->process->execute('fossil changes', $output, realpath($path));
  12777. return trim($output) ?: null;
  12778. }
  12779. protected function getCommitLogs($fromReference, $toReference, $path)
  12780. {
  12781. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  12782. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  12783. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12784. }
  12785. $log = '';
  12786. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  12787. foreach ($this->process->splitLines($output) as $line) {
  12788. if (preg_match($match, $line)) {
  12789. break;
  12790. }
  12791. $log .= $line;
  12792. }
  12793. return $log;
  12794. }
  12795. protected function hasMetadataRepository($path)
  12796. {
  12797. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  12798. }
  12799. }
  12800. <?php
  12801. namespace Composer\Downloader;
  12802. use Composer\Config;
  12803. use Composer\IO\IOInterface;
  12804. use Composer\Package\PackageInterface;
  12805. use Composer\Util\Filesystem;
  12806. use Composer\Util\Git as GitUtil;
  12807. use Composer\Util\Url;
  12808. use Composer\Util\Platform;
  12809. use Composer\Util\ProcessExecutor;
  12810. use Composer\Cache;
  12811. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  12812. {
  12813. private $hasStashedChanges = array();
  12814. private $hasDiscardedChanges = array();
  12815. private $gitUtil;
  12816. private $cachedPackages = array();
  12817. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  12818. {
  12819. parent::__construct($io, $config, $process, $fs);
  12820. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  12821. }
  12822. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12823. {
  12824. GitUtil::cleanEnv();
  12825. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12826. $gitVersion = GitUtil::getVersion($this->process);
  12827. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  12828. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  12829. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  12830. $ref = $package->getSourceReference();
  12831. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  12832. $this->cachedPackages[$package->getId()][$ref] = true;
  12833. }
  12834. } elseif (null === $gitVersion) {
  12835. throw new \RuntimeException('git was not found in your PATH, skipping source download');
  12836. }
  12837. }
  12838. protected function doInstall(PackageInterface $package, $path, $url)
  12839. {
  12840. GitUtil::cleanEnv();
  12841. $path = $this->normalizePath($path);
  12842. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12843. $ref = $package->getSourceReference();
  12844. $flag = Platform::isWindows() ? '/D ' : '';
  12845. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  12846. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  12847. $command =
  12848. 'git clone --no-checkout %cachePath% %path% --dissociate --reference %cachePath% '
  12849. . '&& cd '.$flag.'%path% '
  12850. . '&& git remote set-url origin %sanitizedUrl% && git remote add composer %sanitizedUrl%';
  12851. } else {
  12852. $msg = "Cloning ".$this->getShortHash($ref);
  12853. $command = 'git clone --no-checkout %url% %path% && cd '.$flag.'%path% && git remote add composer %url% && git fetch composer && git remote set-url origin %sanitizedUrl% && git remote set-url composer %sanitizedUrl%';
  12854. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12855. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  12856. }
  12857. }
  12858. $this->io->writeError($msg);
  12859. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  12860. return str_replace(
  12861. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  12862. array(
  12863. ProcessExecutor::escape($url),
  12864. ProcessExecutor::escape($path),
  12865. ProcessExecutor::escape($cachePath),
  12866. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12867. ),
  12868. $command
  12869. );
  12870. };
  12871. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  12872. if ($url !== $package->getSourceUrl()) {
  12873. $this->updateOriginUrl($path, $package->getSourceUrl());
  12874. } else {
  12875. $this->setPushUrl($path, $url);
  12876. }
  12877. if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
  12878. if ($package->getDistReference() === $package->getSourceReference()) {
  12879. $package->setDistReference($newRef);
  12880. }
  12881. $package->setSourceReference($newRef);
  12882. }
  12883. }
  12884. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12885. {
  12886. GitUtil::cleanEnv();
  12887. $path = $this->normalizePath($path);
  12888. if (!$this->hasMetadataRepository($path)) {
  12889. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12890. }
  12891. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12892. $ref = $target->getSourceReference();
  12893. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  12894. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  12895. $command = '(git rev-parse --quiet --verify %ref% || (git remote set-url composer %cachePath% && git fetch composer && git fetch --tags composer)) && git remote set-url composer %sanitizedUrl%';
  12896. } else {
  12897. $msg = "Checking out ".$this->getShortHash($ref);
  12898. $command = '(git remote set-url composer %url% && git rev-parse --quiet --verify %ref% || (git fetch composer && git fetch --tags composer)) && git remote set-url composer %sanitizedUrl%';
  12899. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12900. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  12901. }
  12902. }
  12903. $this->io->writeError($msg);
  12904. $commandCallable = function ($url) use ($ref, $command, $cachePath) {
  12905. return str_replace(
  12906. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  12907. array(
  12908. ProcessExecutor::escape($url),
  12909. ProcessExecutor::escape($ref.'^{commit}'),
  12910. ProcessExecutor::escape($cachePath),
  12911. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12912. ),
  12913. $command
  12914. );
  12915. };
  12916. $this->gitUtil->runCommand($commandCallable, $url, $path);
  12917. if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
  12918. if ($target->getDistReference() === $target->getSourceReference()) {
  12919. $target->setDistReference($newRef);
  12920. }
  12921. $target->setSourceReference($newRef);
  12922. }
  12923. $updateOriginUrl = false;
  12924. if (
  12925. 0 === $this->process->execute('git remote -v', $output, $path)
  12926. && preg_match('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  12927. && preg_match('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  12928. ) {
  12929. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  12930. $updateOriginUrl = true;
  12931. }
  12932. }
  12933. if ($updateOriginUrl) {
  12934. $this->updateOriginUrl($path, $target->getSourceUrl());
  12935. }
  12936. }
  12937. public function getLocalChanges(PackageInterface $package, $path)
  12938. {
  12939. GitUtil::cleanEnv();
  12940. if (!$this->hasMetadataRepository($path)) {
  12941. return;
  12942. }
  12943. $command = 'git status --porcelain --untracked-files=no';
  12944. if (0 !== $this->process->execute($command, $output, $path)) {
  12945. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12946. }
  12947. return trim($output) ?: null;
  12948. }
  12949. public function getUnpushedChanges(PackageInterface $package, $path)
  12950. {
  12951. GitUtil::cleanEnv();
  12952. $path = $this->normalizePath($path);
  12953. if (!$this->hasMetadataRepository($path)) {
  12954. return;
  12955. }
  12956. $command = 'git show-ref --head -d';
  12957. if (0 !== $this->process->execute($command, $output, $path)) {
  12958. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12959. }
  12960. $refs = trim($output);
  12961. if (!preg_match('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  12962. return;
  12963. }
  12964. $headRef = $match[1];
  12965. if (!preg_match_all('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  12966. return;
  12967. }
  12968. $candidateBranches = $matches[1];
  12969. $branch = $candidateBranches[0];
  12970. $unpushedChanges = null;
  12971. $branchNotFoundError = false;
  12972. for ($i = 0; $i <= 1; $i++) {
  12973. $remoteBranches = array();
  12974. foreach ($candidateBranches as $candidate) {
  12975. if (preg_match_all('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  12976. foreach ($matches[1] as $match) {
  12977. $branch = $candidate;
  12978. $remoteBranches[] = $match;
  12979. }
  12980. break;
  12981. }
  12982. }
  12983. if (!$remoteBranches) {
  12984. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  12985. $branchNotFoundError = true;
  12986. } else {
  12987. if ($branchNotFoundError) {
  12988. $unpushedChanges = null;
  12989. }
  12990. foreach ($remoteBranches as $remoteBranch) {
  12991. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  12992. if (0 !== $this->process->execute($command, $output, $path)) {
  12993. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12994. }
  12995. $output = trim($output);
  12996. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  12997. $unpushedChanges = $output;
  12998. }
  12999. }
  13000. }
  13001. if ($unpushedChanges && $i === 0) {
  13002. $this->process->execute('git fetch --all', $output, $path);
  13003. $command = 'git show-ref --head -d';
  13004. if (0 !== $this->process->execute($command, $output, $path)) {
  13005. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13006. }
  13007. $refs = trim($output);
  13008. }
  13009. if (!$unpushedChanges) {
  13010. break;
  13011. }
  13012. }
  13013. return $unpushedChanges;
  13014. }
  13015. protected function cleanChanges(PackageInterface $package, $path, $update)
  13016. {
  13017. GitUtil::cleanEnv();
  13018. $path = $this->normalizePath($path);
  13019. $unpushed = $this->getUnpushedChanges($package, $path);
  13020. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  13021. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  13022. }
  13023. if (!$changes = $this->getLocalChanges($package, $path)) {
  13024. return;
  13025. }
  13026. if (!$this->io->isInteractive()) {
  13027. $discardChanges = $this->config->get('discard-changes');
  13028. if (true === $discardChanges) {
  13029. return $this->discardChanges($path);
  13030. }
  13031. if ('stash' === $discardChanges) {
  13032. if (!$update) {
  13033. return parent::cleanChanges($package, $path, $update);
  13034. }
  13035. return $this->stashChanges($path);
  13036. }
  13037. return parent::cleanChanges($package, $path, $update);
  13038. }
  13039. $changes = array_map(function ($elem) {
  13040. return ' '.$elem;
  13041. }, preg_split('{\s*\r?\n\s*}', $changes));
  13042. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  13043. $this->io->writeError(array_slice($changes, 0, 10));
  13044. if (count($changes) > 10) {
  13045. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  13046. }
  13047. while (true) {
  13048. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  13049. case 'y':
  13050. $this->discardChanges($path);
  13051. break 2;
  13052. case 's':
  13053. if (!$update) {
  13054. goto help;
  13055. }
  13056. $this->stashChanges($path);
  13057. break 2;
  13058. case 'n':
  13059. throw new \RuntimeException('Update aborted');
  13060. case 'v':
  13061. $this->io->writeError($changes);
  13062. break;
  13063. case 'd':
  13064. $this->viewDiff($path);
  13065. break;
  13066. case '?':
  13067. default:
  13068. help:
  13069. $this->io->writeError(array(
  13070. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13071. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13072. ' v - view modified files',
  13073. ' d - view local modifications (diff)',
  13074. ));
  13075. if ($update) {
  13076. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  13077. }
  13078. $this->io->writeError(' ? - print help');
  13079. break;
  13080. }
  13081. }
  13082. }
  13083. protected function reapplyChanges($path)
  13084. {
  13085. $path = $this->normalizePath($path);
  13086. if (!empty($this->hasStashedChanges[$path])) {
  13087. unset($this->hasStashedChanges[$path]);
  13088. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  13089. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  13090. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  13091. }
  13092. }
  13093. unset($this->hasDiscardedChanges[$path]);
  13094. }
  13095. protected function updateToCommit($path, $reference, $branch, $date)
  13096. {
  13097. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  13098. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  13099. $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
  13100. $branches = null;
  13101. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  13102. $branches = $output;
  13103. }
  13104. $gitRef = $reference;
  13105. if (!preg_match('{^[a-f0-9]{40}$}', $reference)
  13106. && $branches
  13107. && preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  13108. ) {
  13109. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  13110. if (0 === $this->process->execute($command, $output, $path)) {
  13111. return null;
  13112. }
  13113. }
  13114. if (preg_match('{^[a-f0-9]{40}$}', $reference)) {
  13115. if (!preg_match('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && preg_match('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  13116. $branch = 'v' . $branch;
  13117. }
  13118. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  13119. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  13120. $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  13121. if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
  13122. return null;
  13123. }
  13124. }
  13125. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  13126. if (0 === $this->process->execute($command, $output, $path)) {
  13127. return null;
  13128. }
  13129. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  13130. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  13131. }
  13132. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
  13133. }
  13134. protected function updateOriginUrl($path, $url)
  13135. {
  13136. $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
  13137. $this->setPushUrl($path, $url);
  13138. }
  13139. protected function setPushUrl($path, $url)
  13140. {
  13141. if (preg_match('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  13142. $protocols = $this->config->get('github-protocols');
  13143. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  13144. if (!in_array('ssh', $protocols, true)) {
  13145. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  13146. }
  13147. $cmd = sprintf('git remote set-url --push origin %s', ProcessExecutor::escape($pushUrl));
  13148. $this->process->execute($cmd, $ignoredOutput, $path);
  13149. }
  13150. }
  13151. protected function getCommitLogs($fromReference, $toReference, $path)
  13152. {
  13153. $path = $this->normalizePath($path);
  13154. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13155. if (0 !== $this->process->execute($command, $output, $path)) {
  13156. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13157. }
  13158. return $output;
  13159. }
  13160. protected function discardChanges($path)
  13161. {
  13162. $path = $this->normalizePath($path);
  13163. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  13164. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  13165. }
  13166. $this->hasDiscardedChanges[$path] = true;
  13167. }
  13168. protected function stashChanges($path)
  13169. {
  13170. $path = $this->normalizePath($path);
  13171. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  13172. throw new \RuntimeException("Could not stash changes\n\n:".$output);
  13173. }
  13174. $this->hasStashedChanges[$path] = true;
  13175. }
  13176. protected function viewDiff($path)
  13177. {
  13178. $path = $this->normalizePath($path);
  13179. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  13180. throw new \RuntimeException("Could not view diff\n\n:".$output);
  13181. }
  13182. $this->io->writeError($output);
  13183. }
  13184. protected function normalizePath($path)
  13185. {
  13186. if (Platform::isWindows() && strlen($path) > 0) {
  13187. $basePath = $path;
  13188. $removed = array();
  13189. while (!is_dir($basePath) && $basePath !== '\\') {
  13190. array_unshift($removed, basename($basePath));
  13191. $basePath = dirname($basePath);
  13192. }
  13193. if ($basePath === '\\') {
  13194. return $path;
  13195. }
  13196. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  13197. }
  13198. return $path;
  13199. }
  13200. protected function hasMetadataRepository($path)
  13201. {
  13202. $path = $this->normalizePath($path);
  13203. return is_dir($path.'/.git');
  13204. }
  13205. protected function getShortHash($reference)
  13206. {
  13207. if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {
  13208. return substr($reference, 0, 10);
  13209. }
  13210. return $reference;
  13211. }
  13212. }
  13213. <?php
  13214. namespace Composer\Downloader;
  13215. use Composer\Package\PackageInterface;
  13216. use Composer\Util\Platform;
  13217. use Composer\Util\ProcessExecutor;
  13218. class GzipDownloader extends ArchiveDownloader
  13219. {
  13220. protected function extract(PackageInterface $package, $file, $path)
  13221. {
  13222. $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
  13223. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  13224. if (!Platform::isWindows()) {
  13225. $command = 'gzip -cd ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  13226. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13227. return;
  13228. }
  13229. if (extension_loaded('zlib')) {
  13230. $this->extractUsingExt($file, $targetFilepath);
  13231. return;
  13232. }
  13233. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13234. throw new \RuntimeException($processError);
  13235. }
  13236. $this->extractUsingExt($file, $targetFilepath);
  13237. }
  13238. private function extractUsingExt($file, $targetFilepath)
  13239. {
  13240. $archiveFile = gzopen($file, 'rb');
  13241. $targetFile = fopen($targetFilepath, 'wb');
  13242. while ($string = gzread($archiveFile, 4096)) {
  13243. fwrite($targetFile, $string, Platform::strlen($string));
  13244. }
  13245. gzclose($archiveFile);
  13246. fclose($targetFile);
  13247. }
  13248. }
  13249. <?php
  13250. namespace Composer\Downloader;
  13251. use Composer\Package\PackageInterface;
  13252. use Composer\Util\ProcessExecutor;
  13253. use Composer\Util\Hg as HgUtils;
  13254. class HgDownloader extends VcsDownloader
  13255. {
  13256. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13257. {
  13258. if (null === HgUtils::getVersion($this->process)) {
  13259. throw new \RuntimeException('hg was not found in your PATH, skipping source download');
  13260. }
  13261. }
  13262. protected function doInstall(PackageInterface $package, $path, $url)
  13263. {
  13264. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13265. $cloneCommand = function ($url) use ($path) {
  13266. return sprintf('hg clone %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  13267. };
  13268. $hgUtils->runCommand($cloneCommand, $url, $path);
  13269. $ref = ProcessExecutor::escape($package->getSourceReference());
  13270. $command = sprintf('hg up %s', $ref);
  13271. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13272. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13273. }
  13274. }
  13275. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13276. {
  13277. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13278. $ref = $target->getSourceReference();
  13279. $this->io->writeError(" Updating to ".$target->getSourceReference());
  13280. if (!$this->hasMetadataRepository($path)) {
  13281. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13282. }
  13283. $command = function ($url) use ($ref) {
  13284. return sprintf('hg pull %s && hg up %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  13285. };
  13286. $hgUtils->runCommand($command, $url, $path);
  13287. }
  13288. public function getLocalChanges(PackageInterface $package, $path)
  13289. {
  13290. if (!is_dir($path.'/.hg')) {
  13291. return null;
  13292. }
  13293. $this->process->execute('hg st', $output, realpath($path));
  13294. return trim($output) ?: null;
  13295. }
  13296. protected function getCommitLogs($fromReference, $toReference, $path)
  13297. {
  13298. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13299. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  13300. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13301. }
  13302. return $output;
  13303. }
  13304. protected function hasMetadataRepository($path)
  13305. {
  13306. return is_dir($path . '/.hg');
  13307. }
  13308. }
  13309. <?php
  13310. namespace Composer\Downloader;
  13311. class MaxFileSizeExceededException extends TransportException
  13312. {
  13313. }
  13314. <?php
  13315. namespace Composer\Downloader;
  13316. use Composer\Package\Archiver\ArchivableFilesFinder;
  13317. use Composer\Package\Dumper\ArrayDumper;
  13318. use Composer\Package\PackageInterface;
  13319. use Composer\Package\Version\VersionGuesser;
  13320. use Composer\Package\Version\VersionParser;
  13321. use Composer\Util\Platform;
  13322. use Composer\Util\Filesystem;
  13323. use Symfony\Component\Filesystem\Exception\IOException;
  13324. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  13325. use Composer\DependencyResolver\Operation\InstallOperation;
  13326. use Composer\DependencyResolver\Operation\UninstallOperation;
  13327. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  13328. {
  13329. const STRATEGY_SYMLINK = 10;
  13330. const STRATEGY_MIRROR = 20;
  13331. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13332. {
  13333. $path = Filesystem::trimTrailingSlash($path);
  13334. $url = $package->getDistUrl();
  13335. $realUrl = realpath($url);
  13336. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  13337. throw new \RuntimeException(sprintf(
  13338. 'Source path "%s" is not found for package %s',
  13339. $url,
  13340. $package->getName()
  13341. ));
  13342. }
  13343. if (realpath($path) === $realUrl) {
  13344. return;
  13345. }
  13346. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  13347. throw new \RuntimeException(sprintf(
  13348. 'Package %s cannot install to "%s" inside its source at "%s"',
  13349. $package->getName(),
  13350. realpath($path),
  13351. $realUrl
  13352. ));
  13353. }
  13354. }
  13355. public function install(PackageInterface $package, $path, $output = true)
  13356. {
  13357. $path = Filesystem::trimTrailingSlash($path);
  13358. $url = $package->getDistUrl();
  13359. $realUrl = realpath($url);
  13360. if (realpath($path) === $realUrl) {
  13361. if ($output) {
  13362. $this->io->writeError(" - " . InstallOperation::format($package).': Source already present');
  13363. } else {
  13364. $this->io->writeError('Source already present', false);
  13365. }
  13366. return;
  13367. }
  13368. $transportOptions = $package->getTransportOptions() + array('symlink' => null, 'relative' => true);
  13369. $currentStrategy = self::STRATEGY_SYMLINK;
  13370. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  13371. $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS');
  13372. if ($mirrorPathRepos) {
  13373. $currentStrategy = self::STRATEGY_MIRROR;
  13374. }
  13375. if (true === $transportOptions['symlink']) {
  13376. $currentStrategy = self::STRATEGY_SYMLINK;
  13377. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  13378. } elseif (false === $transportOptions['symlink']) {
  13379. $currentStrategy = self::STRATEGY_MIRROR;
  13380. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13381. }
  13382. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  13383. $currentStrategy = self::STRATEGY_MIRROR;
  13384. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13385. }
  13386. $symfonyFilesystem = new SymfonyFilesystem();
  13387. $this->filesystem->removeDirectory($path);
  13388. if ($output) {
  13389. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13390. }
  13391. $isFallback = false;
  13392. if (self::STRATEGY_SYMLINK == $currentStrategy) {
  13393. try {
  13394. if (Platform::isWindows()) {
  13395. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  13396. $this->filesystem->junction($realUrl, $path);
  13397. } else {
  13398. $absolutePath = $path;
  13399. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  13400. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  13401. }
  13402. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  13403. $path = rtrim($path, "/");
  13404. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  13405. if ($transportOptions['relative']) {
  13406. $symfonyFilesystem->symlink($shortestPath, $path);
  13407. } else {
  13408. $symfonyFilesystem->symlink($realUrl, $path);
  13409. }
  13410. }
  13411. } catch (IOException $e) {
  13412. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
  13413. $this->io->writeError('');
  13414. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  13415. $currentStrategy = self::STRATEGY_MIRROR;
  13416. $isFallback = true;
  13417. } else {
  13418. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  13419. }
  13420. }
  13421. }
  13422. if (self::STRATEGY_MIRROR == $currentStrategy) {
  13423. $realUrl = $this->filesystem->normalizePath($realUrl);
  13424. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  13425. $iterator = new ArchivableFilesFinder($realUrl, array());
  13426. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  13427. }
  13428. if ($output) {
  13429. $this->io->writeError('');
  13430. }
  13431. }
  13432. public function remove(PackageInterface $package, $path, $output = true)
  13433. {
  13434. $path = Filesystem::trimTrailingSlash($path);
  13435. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  13436. if ($output) {
  13437. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13438. }
  13439. if (!$this->filesystem->removeJunction($path)) {
  13440. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  13441. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  13442. }
  13443. } elseif (realpath($path) === realpath($package->getDistUrl())) {
  13444. if ($output) {
  13445. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13446. }
  13447. } else {
  13448. parent::remove($package, $path, $output);
  13449. }
  13450. }
  13451. public function getVcsReference(PackageInterface $package, $path)
  13452. {
  13453. $path = Filesystem::trimTrailingSlash($path);
  13454. $parser = new VersionParser;
  13455. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13456. $dumper = new ArrayDumper;
  13457. $packageConfig = $dumper->dump($package);
  13458. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13459. return $packageVersion['commit'];
  13460. }
  13461. }
  13462. private function safeJunctions()
  13463. {
  13464. return function_exists('proc_open') &&
  13465. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  13466. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  13467. }
  13468. }
  13469. <?php
  13470. namespace Composer\Downloader;
  13471. use Composer\Package\PackageInterface;
  13472. use Composer\Repository\VcsRepository;
  13473. use Composer\Util\Perforce;
  13474. class PerforceDownloader extends VcsDownloader
  13475. {
  13476. protected $perforce;
  13477. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13478. {
  13479. }
  13480. public function doInstall(PackageInterface $package, $path, $url)
  13481. {
  13482. $ref = $package->getSourceReference();
  13483. $label = $this->getLabelFromSourceReference($ref);
  13484. $this->io->writeError('Cloning ' . $ref);
  13485. $this->initPerforce($package, $path, $url);
  13486. $this->perforce->setStream($ref);
  13487. $this->perforce->p4Login();
  13488. $this->perforce->writeP4ClientSpec();
  13489. $this->perforce->connectClient();
  13490. $this->perforce->syncCodeBase($label);
  13491. $this->perforce->cleanupClientSpec();
  13492. }
  13493. private function getLabelFromSourceReference($ref)
  13494. {
  13495. $pos = strpos($ref, '@');
  13496. if (false !== $pos) {
  13497. return substr($ref, $pos + 1);
  13498. }
  13499. return null;
  13500. }
  13501. public function initPerforce(PackageInterface $package, $path, $url)
  13502. {
  13503. if (!empty($this->perforce)) {
  13504. $this->perforce->initializePath($path);
  13505. return;
  13506. }
  13507. $repository = $package->getRepository();
  13508. $repoConfig = null;
  13509. if ($repository instanceof VcsRepository) {
  13510. $repoConfig = $this->getRepoConfig($repository);
  13511. }
  13512. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  13513. }
  13514. private function getRepoConfig(VcsRepository $repository)
  13515. {
  13516. return $repository->getRepoConfig();
  13517. }
  13518. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13519. {
  13520. $this->doInstall($target, $path, $url);
  13521. }
  13522. public function getLocalChanges(PackageInterface $package, $path)
  13523. {
  13524. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  13525. }
  13526. protected function getCommitLogs($fromReference, $toReference, $path)
  13527. {
  13528. return $this->perforce->getCommitLogs($fromReference, $toReference);
  13529. }
  13530. public function setPerforce($perforce)
  13531. {
  13532. $this->perforce = $perforce;
  13533. }
  13534. protected function hasMetadataRepository($path)
  13535. {
  13536. return true;
  13537. }
  13538. }
  13539. <?php
  13540. namespace Composer\Downloader;
  13541. use Composer\Package\PackageInterface;
  13542. class PharDownloader extends ArchiveDownloader
  13543. {
  13544. protected function extract(PackageInterface $package, $file, $path)
  13545. {
  13546. $archive = new \Phar($file);
  13547. $archive->extractTo($path, null, true);
  13548. }
  13549. }
  13550. <?php
  13551. namespace Composer\Downloader;
  13552. use Composer\Util\IniHelper;
  13553. use Composer\Util\Platform;
  13554. use Composer\Util\ProcessExecutor;
  13555. use Composer\Package\PackageInterface;
  13556. use RarArchive;
  13557. class RarDownloader extends ArchiveDownloader
  13558. {
  13559. protected function extract(PackageInterface $package, $file, $path)
  13560. {
  13561. $processError = null;
  13562. if (!Platform::isWindows()) {
  13563. $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  13564. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13565. return;
  13566. }
  13567. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13568. }
  13569. if (!class_exists('RarArchive')) {
  13570. $iniMessage = IniHelper::getMessage();
  13571. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  13572. . $iniMessage . "\n" . $processError;
  13573. if (!Platform::isWindows()) {
  13574. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  13575. }
  13576. throw new \RuntimeException($error);
  13577. }
  13578. $rarArchive = RarArchive::open($file);
  13579. if (false === $rarArchive) {
  13580. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  13581. }
  13582. $entries = $rarArchive->getEntries();
  13583. if (false === $entries) {
  13584. throw new \RuntimeException('Could not retrieve RAR archive entries');
  13585. }
  13586. foreach ($entries as $entry) {
  13587. if (false === $entry->extract($path)) {
  13588. throw new \RuntimeException('Could not extract entry');
  13589. }
  13590. }
  13591. $rarArchive->close();
  13592. }
  13593. }
  13594. <?php
  13595. namespace Composer\Downloader;
  13596. use Composer\Package\PackageInterface;
  13597. use Composer\Util\Svn as SvnUtil;
  13598. use Composer\Repository\VcsRepository;
  13599. use Composer\Util\ProcessExecutor;
  13600. class SvnDownloader extends VcsDownloader
  13601. {
  13602. protected $cacheCredentials = true;
  13603. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13604. {
  13605. SvnUtil::cleanEnv();
  13606. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  13607. if (null === $util->binaryVersion()) {
  13608. throw new \RuntimeException('svn was not found in your PATH, skipping source download');
  13609. }
  13610. }
  13611. protected function doInstall(PackageInterface $package, $path, $url)
  13612. {
  13613. SvnUtil::cleanEnv();
  13614. $ref = $package->getSourceReference();
  13615. $repo = $package->getRepository();
  13616. if ($repo instanceof VcsRepository) {
  13617. $repoConfig = $repo->getRepoConfig();
  13618. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  13619. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  13620. }
  13621. }
  13622. $this->io->writeError(" Checking out ".$package->getSourceReference());
  13623. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  13624. }
  13625. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13626. {
  13627. SvnUtil::cleanEnv();
  13628. $ref = $target->getSourceReference();
  13629. if (!$this->hasMetadataRepository($path)) {
  13630. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13631. }
  13632. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  13633. $flags = "";
  13634. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  13635. $flags .= ' --ignore-ancestry';
  13636. }
  13637. $this->io->writeError(" Checking out " . $ref);
  13638. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  13639. }
  13640. public function getLocalChanges(PackageInterface $package, $path)
  13641. {
  13642. if (!$this->hasMetadataRepository($path)) {
  13643. return null;
  13644. }
  13645. $this->process->execute('svn status --ignore-externals', $output, $path);
  13646. return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
  13647. }
  13648. protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
  13649. {
  13650. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13651. $util->setCacheCredentials($this->cacheCredentials);
  13652. try {
  13653. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  13654. } catch (\RuntimeException $e) {
  13655. throw new \RuntimeException(
  13656. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  13657. );
  13658. }
  13659. }
  13660. protected function cleanChanges(PackageInterface $package, $path, $update)
  13661. {
  13662. if (!$changes = $this->getLocalChanges($package, $path)) {
  13663. return;
  13664. }
  13665. if (!$this->io->isInteractive()) {
  13666. if (true === $this->config->get('discard-changes')) {
  13667. return $this->discardChanges($path);
  13668. }
  13669. return parent::cleanChanges($package, $path, $update);
  13670. }
  13671. $changes = array_map(function ($elem) {
  13672. return ' '.$elem;
  13673. }, preg_split('{\s*\r?\n\s*}', $changes));
  13674. $countChanges = count($changes);
  13675. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  13676. $this->io->writeError(array_slice($changes, 0, 10));
  13677. if ($countChanges > 10) {
  13678. $remainingChanges = $countChanges - 10;
  13679. $this->io->writeError(
  13680. sprintf(
  13681. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  13682. $remainingChanges === 1 ? '' : 's'
  13683. )
  13684. );
  13685. }
  13686. while (true) {
  13687. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  13688. case 'y':
  13689. $this->discardChanges($path);
  13690. break 2;
  13691. case 'n':
  13692. throw new \RuntimeException('Update aborted');
  13693. case 'v':
  13694. $this->io->writeError($changes);
  13695. break;
  13696. case '?':
  13697. default:
  13698. $this->io->writeError(array(
  13699. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13700. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13701. ' v - view modified files',
  13702. ' ? - print help',
  13703. ));
  13704. break;
  13705. }
  13706. }
  13707. }
  13708. protected function getCommitLogs($fromReference, $toReference, $path)
  13709. {
  13710. if (preg_match('{@(\d+)$}', $fromReference) && preg_match('{@(\d+)$}', $toReference)) {
  13711. $command = sprintf('svn info --non-interactive --xml %s', ProcessExecutor::escape($path));
  13712. if (0 !== $this->process->execute($command, $output, $path)) {
  13713. throw new \RuntimeException(
  13714. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  13715. );
  13716. }
  13717. $urlPattern = '#<url>(.*)</url>#';
  13718. if (preg_match($urlPattern, $output, $matches)) {
  13719. $baseUrl = $matches[1];
  13720. } else {
  13721. throw new \RuntimeException(
  13722. 'Unable to determine svn url for path '. $path
  13723. );
  13724. }
  13725. $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
  13726. $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
  13727. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  13728. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13729. $util->setCacheCredentials($this->cacheCredentials);
  13730. try {
  13731. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  13732. } catch (\RuntimeException $e) {
  13733. throw new \RuntimeException(
  13734. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  13735. );
  13736. }
  13737. }
  13738. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  13739. }
  13740. protected function discardChanges($path)
  13741. {
  13742. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  13743. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  13744. }
  13745. }
  13746. protected function hasMetadataRepository($path)
  13747. {
  13748. return is_dir($path.'/.svn');
  13749. }
  13750. }
  13751. <?php
  13752. namespace Composer\Downloader;
  13753. use Composer\Package\PackageInterface;
  13754. class TarDownloader extends ArchiveDownloader
  13755. {
  13756. protected function extract(PackageInterface $package, $file, $path)
  13757. {
  13758. $archive = new \PharData($file);
  13759. $archive->extractTo($path, null, true);
  13760. }
  13761. }
  13762. <?php
  13763. namespace Composer\Downloader;
  13764. class TransportException extends \RuntimeException
  13765. {
  13766. protected $headers;
  13767. protected $response;
  13768. protected $statusCode;
  13769. protected $responseInfo = array();
  13770. public function setHeaders($headers)
  13771. {
  13772. $this->headers = $headers;
  13773. }
  13774. public function getHeaders()
  13775. {
  13776. return $this->headers;
  13777. }
  13778. public function setResponse($response)
  13779. {
  13780. $this->response = $response;
  13781. }
  13782. public function getResponse()
  13783. {
  13784. return $this->response;
  13785. }
  13786. public function setStatusCode($statusCode)
  13787. {
  13788. $this->statusCode = $statusCode;
  13789. }
  13790. public function getStatusCode()
  13791. {
  13792. return $this->statusCode;
  13793. }
  13794. public function getResponseInfo()
  13795. {
  13796. return $this->responseInfo;
  13797. }
  13798. public function setResponseInfo(array $responseInfo)
  13799. {
  13800. $this->responseInfo = $responseInfo;
  13801. }
  13802. }
  13803. <?php
  13804. namespace Composer\Downloader;
  13805. use Composer\Package\PackageInterface;
  13806. interface VcsCapableDownloaderInterface
  13807. {
  13808. public function getVcsReference(PackageInterface $package, $path);
  13809. }
  13810. <?php
  13811. namespace Composer\Downloader;
  13812. use Composer\Config;
  13813. use Composer\Package\Dumper\ArrayDumper;
  13814. use Composer\Package\PackageInterface;
  13815. use Composer\Package\Version\VersionGuesser;
  13816. use Composer\Package\Version\VersionParser;
  13817. use Composer\Util\ProcessExecutor;
  13818. use Composer\IO\IOInterface;
  13819. use Composer\Util\Filesystem;
  13820. use React\Promise\PromiseInterface;
  13821. use Composer\DependencyResolver\Operation\UpdateOperation;
  13822. use Composer\DependencyResolver\Operation\InstallOperation;
  13823. use Composer\DependencyResolver\Operation\UninstallOperation;
  13824. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  13825. {
  13826. protected $io;
  13827. protected $config;
  13828. protected $process;
  13829. protected $filesystem;
  13830. protected $hasCleanedChanges = array();
  13831. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  13832. {
  13833. $this->io = $io;
  13834. $this->config = $config;
  13835. $this->process = $process ?: new ProcessExecutor($io);
  13836. $this->filesystem = $fs ?: new Filesystem($this->process);
  13837. }
  13838. public function getInstallationSource()
  13839. {
  13840. return 'source';
  13841. }
  13842. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13843. {
  13844. if (!$package->getSourceReference()) {
  13845. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13846. }
  13847. $urls = $this->prepareUrls($package->getSourceUrls());
  13848. while ($url = array_shift($urls)) {
  13849. try {
  13850. return $this->doDownload($package, $path, $url, $prevPackage);
  13851. } catch (\Exception $e) {
  13852. if ($e instanceof \PHPUnit\Framework\Exception) {
  13853. throw $e;
  13854. }
  13855. if ($this->io->isDebug()) {
  13856. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13857. } elseif (count($urls)) {
  13858. $this->io->writeError(' Failed, trying the next URL');
  13859. }
  13860. if (!count($urls)) {
  13861. throw $e;
  13862. }
  13863. }
  13864. }
  13865. }
  13866. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13867. {
  13868. if ($type === 'update') {
  13869. $this->cleanChanges($prevPackage, $path, true);
  13870. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  13871. } elseif ($type === 'install') {
  13872. $this->filesystem->emptyDirectory($path);
  13873. } elseif ($type === 'uninstall') {
  13874. $this->cleanChanges($package, $path, false);
  13875. }
  13876. }
  13877. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13878. {
  13879. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  13880. $this->reapplyChanges($path);
  13881. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  13882. }
  13883. }
  13884. public function install(PackageInterface $package, $path)
  13885. {
  13886. if (!$package->getSourceReference()) {
  13887. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13888. }
  13889. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13890. $urls = $this->prepareUrls($package->getSourceUrls());
  13891. while ($url = array_shift($urls)) {
  13892. try {
  13893. $this->doInstall($package, $path, $url);
  13894. break;
  13895. } catch (\Exception $e) {
  13896. if ($e instanceof \PHPUnit\Framework\Exception) {
  13897. throw $e;
  13898. }
  13899. if ($this->io->isDebug()) {
  13900. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13901. } elseif (count($urls)) {
  13902. $this->io->writeError(' Failed, trying the next URL');
  13903. }
  13904. if (!count($urls)) {
  13905. throw $e;
  13906. }
  13907. }
  13908. }
  13909. }
  13910. public function update(PackageInterface $initial, PackageInterface $target, $path)
  13911. {
  13912. if (!$target->getSourceReference()) {
  13913. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  13914. }
  13915. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  13916. $urls = $this->prepareUrls($target->getSourceUrls());
  13917. $exception = null;
  13918. while ($url = array_shift($urls)) {
  13919. try {
  13920. $this->doUpdate($initial, $target, $path, $url);
  13921. $exception = null;
  13922. break;
  13923. } catch (\Exception $exception) {
  13924. if ($exception instanceof \PHPUnit\Framework\Exception) {
  13925. throw $exception;
  13926. }
  13927. if ($this->io->isDebug()) {
  13928. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  13929. } elseif (count($urls)) {
  13930. $this->io->writeError(' Failed, trying the next URL');
  13931. }
  13932. }
  13933. }
  13934. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  13935. $message = 'Pulling in changes:';
  13936. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  13937. if (!trim($logs)) {
  13938. $message = 'Rolling back changes:';
  13939. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  13940. }
  13941. if (trim($logs)) {
  13942. $logs = implode("\n", array_map(function ($line) {
  13943. return ' ' . $line;
  13944. }, explode("\n", $logs)));
  13945. $logs = str_replace('<', '\<', $logs);
  13946. $this->io->writeError(' '.$message);
  13947. $this->io->writeError($logs);
  13948. }
  13949. }
  13950. if (!$urls && $exception) {
  13951. throw $exception;
  13952. }
  13953. }
  13954. public function remove(PackageInterface $package, $path)
  13955. {
  13956. $this->io->writeError(" - " . UninstallOperation::format($package));
  13957. if (!$this->filesystem->removeDirectory($path)) {
  13958. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  13959. }
  13960. }
  13961. public function getVcsReference(PackageInterface $package, $path)
  13962. {
  13963. $parser = new VersionParser;
  13964. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13965. $dumper = new ArrayDumper;
  13966. $packageConfig = $dumper->dump($package);
  13967. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13968. return $packageVersion['commit'];
  13969. }
  13970. }
  13971. protected function cleanChanges(PackageInterface $package, $path, $update)
  13972. {
  13973. if (null !== $this->getLocalChanges($package, $path)) {
  13974. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  13975. }
  13976. }
  13977. protected function reapplyChanges($path)
  13978. {
  13979. }
  13980. abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
  13981. abstract protected function doInstall(PackageInterface $package, $path, $url);
  13982. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  13983. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  13984. abstract protected function hasMetadataRepository($path);
  13985. private function prepareUrls(array $urls)
  13986. {
  13987. foreach ($urls as $index => $url) {
  13988. if (Filesystem::isLocalPath($url)) {
  13989. $fileProtocol = 'file://';
  13990. $isFileProtocol = false;
  13991. if (0 === strpos($url, $fileProtocol)) {
  13992. $url = substr($url, strlen($fileProtocol));
  13993. $isFileProtocol = true;
  13994. }
  13995. if (false !== strpos($url, '%')) {
  13996. $url = rawurldecode($url);
  13997. }
  13998. $urls[$index] = realpath($url);
  13999. if ($isFileProtocol) {
  14000. $urls[$index] = $fileProtocol . $urls[$index];
  14001. }
  14002. }
  14003. }
  14004. return $urls;
  14005. }
  14006. }
  14007. <?php
  14008. namespace Composer\Downloader;
  14009. use Composer\Package\PackageInterface;
  14010. use Composer\Util\ProcessExecutor;
  14011. class XzDownloader extends ArchiveDownloader
  14012. {
  14013. protected function extract(PackageInterface $package, $file, $path)
  14014. {
  14015. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  14016. if (0 === $this->process->execute($command, $ignoredOutput)) {
  14017. return;
  14018. }
  14019. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  14020. throw new \RuntimeException($processError);
  14021. }
  14022. }
  14023. <?php
  14024. namespace Composer\Downloader;
  14025. use Composer\Package\PackageInterface;
  14026. use Composer\Util\IniHelper;
  14027. use Composer\Util\Platform;
  14028. use Composer\Util\ProcessExecutor;
  14029. use Symfony\Component\Process\ExecutableFinder;
  14030. use ZipArchive;
  14031. class ZipDownloader extends ArchiveDownloader
  14032. {
  14033. protected static $hasSystemUnzip;
  14034. private static $hasZipArchive;
  14035. private static $isWindows;
  14036. private $zipArchiveObject;
  14037. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  14038. {
  14039. if (null === self::$hasSystemUnzip) {
  14040. $finder = new ExecutableFinder;
  14041. self::$hasSystemUnzip = (bool) $finder->find('unzip');
  14042. }
  14043. if (null === self::$hasZipArchive) {
  14044. self::$hasZipArchive = class_exists('ZipArchive');
  14045. }
  14046. if (!self::$hasZipArchive && !self::$hasSystemUnzip) {
  14047. $iniMessage = IniHelper::getMessage();
  14048. $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
  14049. throw new \RuntimeException($error);
  14050. }
  14051. if (null === self::$isWindows) {
  14052. self::$isWindows = Platform::isWindows();
  14053. if (!self::$isWindows && !self::$hasSystemUnzip) {
  14054. $this->io->writeError("<warning>As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  14055. $this->io->writeError("<warning>This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.</warning>");
  14056. $this->io->writeError("<warning>Installing 'unzip' may remediate them.</warning>");
  14057. }
  14058. }
  14059. return parent::download($package, $path, $prevPackage, $output);
  14060. }
  14061. private function extractWithSystemUnzip(PackageInterface $package, $file, $path, $isLastChance, $async = false)
  14062. {
  14063. if (!self::$hasZipArchive) {
  14064. $isLastChance = true;
  14065. }
  14066. if (!self::$hasSystemUnzip && !$isLastChance) {
  14067. return $this->extractWithZipArchive($package, $file, $path, true);
  14068. }
  14069. $overwrite = $isLastChance ? '-o' : '';
  14070. $command = 'unzip -qq '.$overwrite.' '.ProcessExecutor::escape($file).' -d '.ProcessExecutor::escape($path);
  14071. if ($async) {
  14072. $self = $this;
  14073. $io = $this->io;
  14074. $tryFallback = function ($processError) use ($isLastChance, $io, $self, $file, $path, $package) {
  14075. if ($isLastChance) {
  14076. throw $processError;
  14077. }
  14078. if (!is_file($file)) {
  14079. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14080. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  14081. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  14082. } else {
  14083. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14084. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  14085. $io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  14086. }
  14087. return $self->extractWithZipArchive($package, $file, $path, true);
  14088. };
  14089. try {
  14090. $promise = $this->process->executeAsync($command);
  14091. return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) {
  14092. if (!$process->isSuccessful()) {
  14093. $output = $process->getErrorOutput();
  14094. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  14095. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  14096. }
  14097. });
  14098. } catch (\Exception $e) {
  14099. return $tryFallback($e);
  14100. } catch (\Throwable $e) {
  14101. return $tryFallback($e);
  14102. }
  14103. }
  14104. $processError = null;
  14105. try {
  14106. if (0 === $exitCode = $this->process->execute($command, $ignoredOutput)) {
  14107. return \React\Promise\resolve();
  14108. }
  14109. $processError = new \RuntimeException('Failed to execute ('.$exitCode.') '.$command."\n\n".$this->process->getErrorOutput());
  14110. } catch (\Exception $e) {
  14111. $processError = $e;
  14112. }
  14113. if ($isLastChance) {
  14114. throw $processError;
  14115. }
  14116. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14117. $this->io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  14118. $this->io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  14119. return $this->extractWithZipArchive($package, $file, $path, true);
  14120. }
  14121. public function extractWithZipArchive(PackageInterface $package, $file, $path, $isLastChance)
  14122. {
  14123. if (!self::$hasSystemUnzip) {
  14124. $isLastChance = true;
  14125. }
  14126. if (!self::$hasZipArchive && !$isLastChance) {
  14127. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14128. }
  14129. $processError = null;
  14130. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  14131. try {
  14132. if (true === ($retval = $zipArchive->open($file))) {
  14133. $extractResult = $zipArchive->extractTo($path);
  14134. if (true === $extractResult) {
  14135. $zipArchive->close();
  14136. return \React\Promise\resolve();
  14137. }
  14138. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  14139. } else {
  14140. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  14141. }
  14142. } catch (\ErrorException $e) {
  14143. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  14144. } catch (\Exception $e) {
  14145. $processError = $e;
  14146. } catch (\Throwable $e) {
  14147. $processError = $e;
  14148. }
  14149. if ($isLastChance) {
  14150. throw $processError;
  14151. }
  14152. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14153. $this->io->writeError(' Unzip with ZipArchive class failed, falling back to unzip command');
  14154. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14155. }
  14156. public function extract(PackageInterface $package, $file, $path)
  14157. {
  14158. if (self::$isWindows) {
  14159. return $this->extractWithZipArchive($package, $file, $path, false);
  14160. }
  14161. return $this->extractWithSystemUnzip($package, $file, $path, false, true);
  14162. }
  14163. protected function getErrorMessage($retval, $file)
  14164. {
  14165. switch ($retval) {
  14166. case ZipArchive::ER_EXISTS:
  14167. return sprintf("File '%s' already exists.", $file);
  14168. case ZipArchive::ER_INCONS:
  14169. return sprintf("Zip archive '%s' is inconsistent.", $file);
  14170. case ZipArchive::ER_INVAL:
  14171. return sprintf("Invalid argument (%s)", $file);
  14172. case ZipArchive::ER_MEMORY:
  14173. return sprintf("Malloc failure (%s)", $file);
  14174. case ZipArchive::ER_NOENT:
  14175. return sprintf("No such zip file: '%s'", $file);
  14176. case ZipArchive::ER_NOZIP:
  14177. return sprintf("'%s' is not a zip archive.", $file);
  14178. case ZipArchive::ER_OPEN:
  14179. return sprintf("Can't open zip file: %s", $file);
  14180. case ZipArchive::ER_READ:
  14181. return sprintf("Zip read error (%s)", $file);
  14182. case ZipArchive::ER_SEEK:
  14183. return sprintf("Zip seek error (%s)", $file);
  14184. default:
  14185. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  14186. }
  14187. }
  14188. }
  14189. <?php
  14190. namespace Composer\EventDispatcher;
  14191. class Event
  14192. {
  14193. protected $name;
  14194. protected $args;
  14195. protected $flags;
  14196. private $propagationStopped = false;
  14197. public function __construct($name, array $args = array(), array $flags = array())
  14198. {
  14199. $this->name = $name;
  14200. $this->args = $args;
  14201. $this->flags = $flags;
  14202. }
  14203. public function getName()
  14204. {
  14205. return $this->name;
  14206. }
  14207. public function getArguments()
  14208. {
  14209. return $this->args;
  14210. }
  14211. public function getFlags()
  14212. {
  14213. return $this->flags;
  14214. }
  14215. public function isPropagationStopped()
  14216. {
  14217. return $this->propagationStopped;
  14218. }
  14219. public function stopPropagation()
  14220. {
  14221. $this->propagationStopped = true;
  14222. }
  14223. }
  14224. <?php
  14225. namespace Composer\EventDispatcher;
  14226. use Composer\DependencyResolver\Transaction;
  14227. use Composer\Installer\InstallerEvent;
  14228. use Composer\IO\IOInterface;
  14229. use Composer\Composer;
  14230. use Composer\Util\Platform;
  14231. use Composer\DependencyResolver\Operation\OperationInterface;
  14232. use Composer\Repository\RepositoryInterface;
  14233. use Composer\Script;
  14234. use Composer\Installer\PackageEvent;
  14235. use Composer\Installer\BinaryInstaller;
  14236. use Composer\Util\ProcessExecutor;
  14237. use Composer\Script\Event as ScriptEvent;
  14238. use Composer\ClassLoader;
  14239. use Symfony\Component\Process\PhpExecutableFinder;
  14240. class EventDispatcher
  14241. {
  14242. protected $composer;
  14243. protected $io;
  14244. protected $loader;
  14245. protected $process;
  14246. protected $listeners = array();
  14247. private $eventStack;
  14248. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14249. {
  14250. $this->composer = $composer;
  14251. $this->io = $io;
  14252. $this->process = $process ?: new ProcessExecutor($io);
  14253. $this->eventStack = array();
  14254. }
  14255. public function dispatch($eventName, Event $event = null)
  14256. {
  14257. if (null === $event) {
  14258. $event = new Event($eventName);
  14259. }
  14260. return $this->doDispatch($event);
  14261. }
  14262. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  14263. {
  14264. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  14265. }
  14266. public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  14267. {
  14268. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  14269. }
  14270. public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
  14271. {
  14272. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  14273. }
  14274. protected function doDispatch(Event $event)
  14275. {
  14276. if (getenv('COMPOSER_DEBUG_EVENTS')) {
  14277. $details = null;
  14278. if ($event instanceof PackageEvent) {
  14279. $details = (string) $event->getOperation();
  14280. }
  14281. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  14282. }
  14283. $listeners = $this->getListeners($event);
  14284. $this->pushEvent($event);
  14285. $returnMax = 0;
  14286. foreach ($listeners as $callable) {
  14287. $return = 0;
  14288. $this->ensureBinDirIsInPath();
  14289. if (!is_string($callable)) {
  14290. if (!is_callable($callable)) {
  14291. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  14292. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  14293. }
  14294. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  14295. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  14296. }
  14297. $return = false === call_user_func($callable, $event) ? 1 : 0;
  14298. } elseif ($this->isComposerScript($callable)) {
  14299. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  14300. $script = explode(' ', substr($callable, 1));
  14301. $scriptName = $script[0];
  14302. unset($script[0]);
  14303. $args = array_merge($script, $event->getArguments());
  14304. $flags = $event->getFlags();
  14305. if (strpos($callable, '@composer ') === 0) {
  14306. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  14307. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14308. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14309. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14310. }
  14311. } else {
  14312. if (!$this->getListeners(new Event($scriptName))) {
  14313. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  14314. }
  14315. try {
  14316. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  14317. $scriptEvent->setOriginatingEvent($event);
  14318. $return = $this->dispatch($scriptName, $scriptEvent);
  14319. } catch (ScriptExecutionException $e) {
  14320. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14321. throw $e;
  14322. }
  14323. }
  14324. } elseif ($this->isPhpScript($callable)) {
  14325. $className = substr($callable, 0, strpos($callable, '::'));
  14326. $methodName = substr($callable, strpos($callable, '::') + 2);
  14327. if (!class_exists($className)) {
  14328. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14329. continue;
  14330. }
  14331. if (!is_callable($callable)) {
  14332. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14333. continue;
  14334. }
  14335. try {
  14336. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  14337. } catch (\Exception $e) {
  14338. $message = "Script %s handling the %s event terminated with an exception";
  14339. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  14340. throw $e;
  14341. }
  14342. } else {
  14343. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  14344. $exec = $callable . ($args === '' ? '' : ' '.$args);
  14345. if ($this->io->isVerbose()) {
  14346. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  14347. } elseif ($event->getName() !== '__exec_command') {
  14348. $this->io->writeError(sprintf('> %s', $exec));
  14349. }
  14350. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  14351. if ($possibleLocalBinaries) {
  14352. foreach ($possibleLocalBinaries as $localExec) {
  14353. if (preg_match('{\b'.preg_quote($callable).'$}', $localExec)) {
  14354. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  14355. $exec = preg_replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  14356. break;
  14357. }
  14358. }
  14359. }
  14360. if (strpos($exec, '@putenv ') === 0) {
  14361. putenv(substr($exec, 8));
  14362. list($var, $value) = explode('=', substr($exec, 8), 2);
  14363. $_SERVER[$var] = $value;
  14364. continue;
  14365. }
  14366. if (strpos($exec, '@php ') === 0) {
  14367. $pathAndArgs = substr($exec, 5);
  14368. if (Platform::isWindows()) {
  14369. $pathAndArgs = preg_replace_callback('{^\S+}', function ($path) {
  14370. return str_replace('/', '\\', $path[0]);
  14371. }, $pathAndArgs);
  14372. }
  14373. $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
  14374. } else {
  14375. $finder = new PhpExecutableFinder();
  14376. $phpPath = $finder->find(false);
  14377. if ($phpPath) {
  14378. $_SERVER['PHP_BINARY'] = $phpPath;
  14379. putenv('PHP_BINARY=' . $_SERVER['PHP_BINARY']);
  14380. }
  14381. if (Platform::isWindows()) {
  14382. $exec = preg_replace_callback('{^\S+}', function ($path) {
  14383. return str_replace('/', '\\', $path[0]);
  14384. }, $exec);
  14385. }
  14386. }
  14387. if (strpos($exec, 'composer ') === 0) {
  14388. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8);
  14389. }
  14390. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14391. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14392. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14393. }
  14394. }
  14395. $returnMax = max($returnMax, $return);
  14396. if ($event->isPropagationStopped()) {
  14397. break;
  14398. }
  14399. }
  14400. $this->popEvent();
  14401. return $returnMax;
  14402. }
  14403. protected function executeTty($exec)
  14404. {
  14405. if ($this->io->isInteractive()) {
  14406. return $this->process->executeTty($exec);
  14407. }
  14408. return $this->process->execute($exec);
  14409. }
  14410. protected function getPhpExecCommand()
  14411. {
  14412. $finder = new PhpExecutableFinder();
  14413. $phpPath = $finder->find(false);
  14414. if (!$phpPath) {
  14415. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  14416. }
  14417. $phpArgs = $finder->findArguments();
  14418. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  14419. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  14420. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  14421. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  14422. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  14423. }
  14424. protected function executeEventPhpScript($className, $methodName, Event $event)
  14425. {
  14426. if ($this->io->isVerbose()) {
  14427. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  14428. } else {
  14429. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  14430. }
  14431. return $className::$methodName($event);
  14432. }
  14433. public function addListener($eventName, $listener, $priority = 0)
  14434. {
  14435. $this->listeners[$eventName][$priority][] = $listener;
  14436. }
  14437. public function removeListener($listener)
  14438. {
  14439. foreach ($this->listeners as $eventName => $priorities) {
  14440. foreach ($priorities as $priority => $listeners) {
  14441. foreach ($listeners as $index => $candidate) {
  14442. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  14443. unset($this->listeners[$eventName][$priority][$index]);
  14444. }
  14445. }
  14446. }
  14447. }
  14448. }
  14449. public function addSubscriber(EventSubscriberInterface $subscriber)
  14450. {
  14451. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  14452. if (is_string($params)) {
  14453. $this->addListener($eventName, array($subscriber, $params));
  14454. } elseif (is_string($params[0])) {
  14455. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  14456. } else {
  14457. foreach ($params as $listener) {
  14458. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  14459. }
  14460. }
  14461. }
  14462. }
  14463. protected function getListeners(Event $event)
  14464. {
  14465. $scriptListeners = $this->getScriptListeners($event);
  14466. if (!isset($this->listeners[$event->getName()][0])) {
  14467. $this->listeners[$event->getName()][0] = array();
  14468. }
  14469. krsort($this->listeners[$event->getName()]);
  14470. $listeners = $this->listeners;
  14471. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  14472. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  14473. }
  14474. public function hasEventListeners(Event $event)
  14475. {
  14476. $listeners = $this->getListeners($event);
  14477. return count($listeners) > 0;
  14478. }
  14479. protected function getScriptListeners(Event $event)
  14480. {
  14481. $package = $this->composer->getPackage();
  14482. $scripts = $package->getScripts();
  14483. if (empty($scripts[$event->getName()])) {
  14484. return array();
  14485. }
  14486. if ($this->loader) {
  14487. $this->loader->unregister();
  14488. }
  14489. $generator = $this->composer->getAutoloadGenerator();
  14490. if ($event instanceof ScriptEvent) {
  14491. $generator->setDevMode($event->isDevMode());
  14492. }
  14493. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  14494. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  14495. $map = $generator->parseAutoloads($packageMap, $package);
  14496. $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  14497. $this->loader->register(false);
  14498. return $scripts[$event->getName()];
  14499. }
  14500. protected function isPhpScript($callable)
  14501. {
  14502. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  14503. }
  14504. protected function isComposerScript($callable)
  14505. {
  14506. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  14507. }
  14508. protected function pushEvent(Event $event)
  14509. {
  14510. $eventName = $event->getName();
  14511. if (in_array($eventName, $this->eventStack)) {
  14512. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  14513. }
  14514. return array_push($this->eventStack, $eventName);
  14515. }
  14516. protected function popEvent()
  14517. {
  14518. return array_pop($this->eventStack);
  14519. }
  14520. private function ensureBinDirIsInPath()
  14521. {
  14522. $pathStr = 'PATH';
  14523. if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
  14524. $pathStr = 'Path';
  14525. }
  14526. $binDir = $this->composer->getConfig()->get('bin-dir');
  14527. if (is_dir($binDir)) {
  14528. $binDir = realpath($binDir);
  14529. if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) {
  14530. $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
  14531. putenv($pathStr.'='.$_SERVER[$pathStr]);
  14532. }
  14533. }
  14534. }
  14535. }
  14536. <?php
  14537. namespace Composer\EventDispatcher;
  14538. interface EventSubscriberInterface
  14539. {
  14540. public static function getSubscribedEvents();
  14541. }
  14542. <?php
  14543. namespace Composer\EventDispatcher;
  14544. class ScriptExecutionException extends \RuntimeException
  14545. {
  14546. }
  14547. <?php
  14548. namespace Composer\Exception;
  14549. class IrrecoverableDownloadException extends \RuntimeException
  14550. {
  14551. }
  14552. <?php
  14553. namespace Composer\Exception;
  14554. class NoSslException extends \RuntimeException
  14555. {
  14556. }
  14557. <?php
  14558. namespace Composer;
  14559. use Composer\Config\JsonConfigSource;
  14560. use Composer\Json\JsonFile;
  14561. use Composer\IO\IOInterface;
  14562. use Composer\Package\Archiver;
  14563. use Composer\Package\Version\VersionGuesser;
  14564. use Composer\Package\RootPackageInterface;
  14565. use Composer\Repository\RepositoryManager;
  14566. use Composer\Repository\RepositoryFactory;
  14567. use Composer\Repository\WritableRepositoryInterface;
  14568. use Composer\Util\Filesystem;
  14569. use Composer\Util\Platform;
  14570. use Composer\Util\ProcessExecutor;
  14571. use Composer\Util\HttpDownloader;
  14572. use Composer\Util\Loop;
  14573. use Composer\Util\Silencer;
  14574. use Composer\Plugin\PluginEvents;
  14575. use Composer\EventDispatcher\Event;
  14576. use Seld\JsonLint\DuplicateKeyException;
  14577. use Symfony\Component\Console\Formatter\OutputFormatter;
  14578. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  14579. use Symfony\Component\Console\Output\ConsoleOutput;
  14580. use Composer\EventDispatcher\EventDispatcher;
  14581. use Composer\Autoload\AutoloadGenerator;
  14582. use Composer\Package\Version\VersionParser;
  14583. use Composer\Downloader\TransportException;
  14584. use Seld\JsonLint\JsonParser;
  14585. class Factory
  14586. {
  14587. protected static function getHomeDir()
  14588. {
  14589. $home = getenv('COMPOSER_HOME');
  14590. if ($home) {
  14591. return $home;
  14592. }
  14593. if (Platform::isWindows()) {
  14594. if (!getenv('APPDATA')) {
  14595. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14596. }
  14597. return rtrim(strtr(getenv('APPDATA'), '\\', '/'), '/') . '/Composer';
  14598. }
  14599. $userDir = self::getUserDir();
  14600. $dirs = array();
  14601. if (self::useXdg()) {
  14602. $xdgConfig = getenv('XDG_CONFIG_HOME');
  14603. if (!$xdgConfig) {
  14604. $xdgConfig = $userDir . '/.config';
  14605. }
  14606. $dirs[] = $xdgConfig . '/composer';
  14607. }
  14608. $dirs[] = $userDir . '/.composer';
  14609. foreach ($dirs as $dir) {
  14610. if (Silencer::call('is_dir', $dir)) {
  14611. return $dir;
  14612. }
  14613. }
  14614. return $dirs[0];
  14615. }
  14616. protected static function getCacheDir($home)
  14617. {
  14618. $cacheDir = getenv('COMPOSER_CACHE_DIR');
  14619. if ($cacheDir) {
  14620. return $cacheDir;
  14621. }
  14622. $homeEnv = getenv('COMPOSER_HOME');
  14623. if ($homeEnv) {
  14624. return $homeEnv . '/cache';
  14625. }
  14626. if (Platform::isWindows()) {
  14627. if ($cacheDir = getenv('LOCALAPPDATA')) {
  14628. $cacheDir .= '/Composer';
  14629. } else {
  14630. $cacheDir = $home . '/cache';
  14631. }
  14632. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  14633. }
  14634. $userDir = self::getUserDir();
  14635. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  14636. return $home . '/cache';
  14637. }
  14638. if (self::useXdg()) {
  14639. $xdgCache = getenv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  14640. return $xdgCache . '/composer';
  14641. }
  14642. return $home . '/cache';
  14643. }
  14644. protected static function getDataDir($home)
  14645. {
  14646. $homeEnv = getenv('COMPOSER_HOME');
  14647. if ($homeEnv) {
  14648. return $homeEnv;
  14649. }
  14650. if (Platform::isWindows()) {
  14651. return strtr($home, '\\', '/');
  14652. }
  14653. $userDir = self::getUserDir();
  14654. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  14655. $xdgData = getenv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  14656. return $xdgData . '/composer';
  14657. }
  14658. return $home;
  14659. }
  14660. public static function createConfig(IOInterface $io = null, $cwd = null)
  14661. {
  14662. $cwd = $cwd ?: getcwd();
  14663. $config = new Config(true, $cwd);
  14664. $home = self::getHomeDir();
  14665. $config->merge(array('config' => array(
  14666. 'home' => $home,
  14667. 'cache-dir' => self::getCacheDir($home),
  14668. 'data-dir' => self::getDataDir($home),
  14669. )));
  14670. $file = new JsonFile($config->get('home').'/config.json');
  14671. if ($file->exists()) {
  14672. if ($io && $io->isDebug()) {
  14673. $io->writeError('Loading config file ' . $file->getPath());
  14674. }
  14675. $config->merge($file->read());
  14676. }
  14677. $config->setConfigSource(new JsonConfigSource($file));
  14678. $htaccessProtect = (bool) $config->get('htaccess-protect');
  14679. if ($htaccessProtect) {
  14680. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  14681. foreach ($dirs as $dir) {
  14682. if (!file_exists($dir . '/.htaccess')) {
  14683. if (!is_dir($dir)) {
  14684. Silencer::call('mkdir', $dir, 0777, true);
  14685. }
  14686. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  14687. }
  14688. }
  14689. }
  14690. $file = new JsonFile($config->get('home').'/auth.json');
  14691. if ($file->exists()) {
  14692. if ($io && $io->isDebug()) {
  14693. $io->writeError('Loading config file ' . $file->getPath());
  14694. }
  14695. $config->merge(array('config' => $file->read()));
  14696. }
  14697. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  14698. if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
  14699. $authData = json_decode($composerAuthEnv, true);
  14700. if (null === $authData) {
  14701. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  14702. }
  14703. if ($io && $io->isDebug()) {
  14704. $io->writeError('Loading auth config from COMPOSER_AUTH');
  14705. }
  14706. $config->merge(array('config' => $authData));
  14707. }
  14708. return $config;
  14709. }
  14710. public static function getComposerFile()
  14711. {
  14712. return trim(getenv('COMPOSER')) ?: './composer.json';
  14713. }
  14714. public static function getLockFile($composerFile)
  14715. {
  14716. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  14717. ? substr($composerFile, 0, -4).'lock'
  14718. : $composerFile . '.lock';
  14719. }
  14720. public static function createAdditionalStyles()
  14721. {
  14722. return array(
  14723. 'highlight' => new OutputFormatterStyle('red'),
  14724. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  14725. );
  14726. }
  14727. public static function createOutput()
  14728. {
  14729. $styles = self::createAdditionalStyles();
  14730. $formatter = new OutputFormatter(false, $styles);
  14731. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  14732. }
  14733. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
  14734. {
  14735. $cwd = $cwd ?: getcwd();
  14736. if (null === $localConfig) {
  14737. $localConfig = static::getComposerFile();
  14738. }
  14739. if (is_string($localConfig)) {
  14740. $composerFile = $localConfig;
  14741. $file = new JsonFile($localConfig, null, $io);
  14742. if (!$file->exists()) {
  14743. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  14744. $message = 'Composer could not find a composer.json file in '.$cwd;
  14745. } else {
  14746. $message = 'Composer could not find the config file: '.$localConfig;
  14747. }
  14748. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section' : '';
  14749. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  14750. }
  14751. $file->validateSchema(JsonFile::LAX_SCHEMA);
  14752. $jsonParser = new JsonParser;
  14753. try {
  14754. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  14755. } catch (DuplicateKeyException $e) {
  14756. $details = $e->getDetails();
  14757. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  14758. }
  14759. $localConfig = $file->read();
  14760. }
  14761. $config = static::createConfig($io, $cwd);
  14762. $config->merge($localConfig);
  14763. if (isset($composerFile)) {
  14764. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  14765. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  14766. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  14767. if ($localAuthFile->exists()) {
  14768. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  14769. $config->merge(array('config' => $localAuthFile->read()));
  14770. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  14771. }
  14772. }
  14773. $vendorDir = $config->get('vendor-dir');
  14774. $composer = new Composer();
  14775. $composer->setConfig($config);
  14776. if ($fullLoad) {
  14777. $io->loadConfiguration($config);
  14778. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  14779. include $installedVersionsPath;
  14780. }
  14781. }
  14782. $httpDownloader = self::createHttpDownloader($io, $config);
  14783. $process = new ProcessExecutor($io);
  14784. $loop = new Loop($httpDownloader, $process);
  14785. $composer->setLoop($loop);
  14786. $dispatcher = new EventDispatcher($composer, $io, $process);
  14787. $composer->setEventDispatcher($dispatcher);
  14788. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  14789. $composer->setRepositoryManager($rm);
  14790. if (!$fullLoad && !isset($localConfig['version'])) {
  14791. $localConfig['version'] = '1.0.0';
  14792. }
  14793. $parser = new VersionParser;
  14794. $guesser = new VersionGuesser($config, $process, $parser);
  14795. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  14796. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  14797. $composer->setPackage($package);
  14798. $this->addLocalRepository($io, $rm, $vendorDir, $package);
  14799. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  14800. $composer->setInstallationManager($im);
  14801. if ($fullLoad) {
  14802. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  14803. $composer->setDownloadManager($dm);
  14804. $generator = new AutoloadGenerator($dispatcher, $io);
  14805. $composer->setAutoloadGenerator($generator);
  14806. $am = $this->createArchiveManager($config, $dm, $loop);
  14807. $composer->setArchiveManager($am);
  14808. }
  14809. $this->createDefaultInstallers($im, $composer, $io, $process);
  14810. if ($fullLoad) {
  14811. $globalComposer = null;
  14812. if (realpath($config->get('home')) !== $cwd) {
  14813. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
  14814. }
  14815. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  14816. $composer->setPluginManager($pm);
  14817. $pm->loadInstalledPlugins();
  14818. }
  14819. if ($fullLoad && isset($composerFile)) {
  14820. $lockFile = self::getLockFile($composerFile);
  14821. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
  14822. $composer->setLocker($locker);
  14823. }
  14824. if ($fullLoad) {
  14825. $initEvent = new Event(PluginEvents::INIT);
  14826. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  14827. if ($rm->getLocalRepository()) {
  14828. $this->purgePackages($rm->getLocalRepository(), $im);
  14829. }
  14830. }
  14831. return $composer;
  14832. }
  14833. public static function createGlobal(IOInterface $io, $disablePlugins = false)
  14834. {
  14835. $factory = new static();
  14836. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, true);
  14837. }
  14838. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage)
  14839. {
  14840. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage));
  14841. }
  14842. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
  14843. {
  14844. $composer = null;
  14845. try {
  14846. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad);
  14847. } catch (\Exception $e) {
  14848. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  14849. }
  14850. return $composer;
  14851. }
  14852. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null)
  14853. {
  14854. $cache = null;
  14855. if ($config->get('cache-files-ttl') > 0) {
  14856. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  14857. $cache->setReadOnly($config->get('cache-read-only'));
  14858. }
  14859. $fs = new Filesystem($process);
  14860. $dm = new Downloader\DownloadManager($io, false, $fs);
  14861. switch ($preferred = $config->get('preferred-install')) {
  14862. case 'dist':
  14863. $dm->setPreferDist(true);
  14864. break;
  14865. case 'source':
  14866. $dm->setPreferSource(true);
  14867. break;
  14868. case 'auto':
  14869. default:
  14870. break;
  14871. }
  14872. if (is_array($preferred)) {
  14873. $dm->setPreferences($preferred);
  14874. }
  14875. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  14876. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  14877. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  14878. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  14879. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  14880. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14881. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14882. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14883. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14884. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14885. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14886. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14887. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14888. return $dm;
  14889. }
  14890. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  14891. {
  14892. $am = new Archiver\ArchiveManager($dm, $loop);
  14893. $am->addArchiver(new Archiver\ZipArchiver);
  14894. $am->addArchiver(new Archiver\PharArchiver);
  14895. return $am;
  14896. }
  14897. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  14898. {
  14899. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  14900. }
  14901. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  14902. {
  14903. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  14904. }
  14905. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14906. {
  14907. $fs = new Filesystem($process);
  14908. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs);
  14909. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  14910. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  14911. $im->addInstaller(new Installer\MetapackageInstaller($io));
  14912. }
  14913. protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
  14914. {
  14915. foreach ($repo->getPackages() as $package) {
  14916. if (!$im->isPackageInstalled($repo, $package)) {
  14917. $repo->removePackage($package);
  14918. }
  14919. }
  14920. }
  14921. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
  14922. {
  14923. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  14924. }
  14925. public static function create(IOInterface $io, $config = null, $disablePlugins = false)
  14926. {
  14927. $factory = new static();
  14928. return $factory->createComposer($io, $config, $disablePlugins);
  14929. }
  14930. public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())
  14931. {
  14932. static $warned = false;
  14933. $disableTls = false;
  14934. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  14935. $warned = true;
  14936. $disableTls = !extension_loaded('openssl');
  14937. } elseif ($config && $config->get('disable-tls') === true) {
  14938. if (!$warned) {
  14939. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  14940. }
  14941. $warned = true;
  14942. $disableTls = true;
  14943. } elseif (!extension_loaded('openssl')) {
  14944. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  14945. . 'If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the \'disable-tls\' option to true.');
  14946. }
  14947. $httpDownloaderOptions = array();
  14948. if ($disableTls === false) {
  14949. if ($config && $config->get('cafile')) {
  14950. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  14951. }
  14952. if ($config && $config->get('capath')) {
  14953. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  14954. }
  14955. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  14956. }
  14957. try {
  14958. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  14959. } catch (TransportException $e) {
  14960. if (false !== strpos($e->getMessage(), 'cafile')) {
  14961. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  14962. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  14963. if (PHP_VERSION_ID < 50600) {
  14964. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  14965. }
  14966. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  14967. }
  14968. throw $e;
  14969. }
  14970. return $httpDownloader;
  14971. }
  14972. private static function useXdg()
  14973. {
  14974. foreach (array_keys($_SERVER) as $key) {
  14975. if (strpos($key, 'XDG_') === 0) {
  14976. return true;
  14977. }
  14978. }
  14979. if (Silencer::call('is_dir', '/etc/xdg')) {
  14980. return true;
  14981. }
  14982. return false;
  14983. }
  14984. private static function getUserDir()
  14985. {
  14986. $home = getenv('HOME');
  14987. if (!$home) {
  14988. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14989. }
  14990. return rtrim(strtr($home, '\\', '/'), '/');
  14991. }
  14992. }
  14993. <?php
  14994. namespace Composer\IO;
  14995. use Composer\Config;
  14996. use Composer\Util\ProcessExecutor;
  14997. use Psr\Log\LogLevel;
  14998. abstract class BaseIO implements IOInterface
  14999. {
  15000. protected $authentications = array();
  15001. public function getAuthentications()
  15002. {
  15003. return $this->authentications;
  15004. }
  15005. public function resetAuthentications()
  15006. {
  15007. $this->authentications = array();
  15008. }
  15009. public function hasAuthentication($repositoryName)
  15010. {
  15011. return isset($this->authentications[$repositoryName]);
  15012. }
  15013. public function getAuthentication($repositoryName)
  15014. {
  15015. if (isset($this->authentications[$repositoryName])) {
  15016. return $this->authentications[$repositoryName];
  15017. }
  15018. return array('username' => null, 'password' => null);
  15019. }
  15020. public function setAuthentication($repositoryName, $username, $password = null)
  15021. {
  15022. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  15023. }
  15024. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15025. {
  15026. $this->write($messages, $newline, $verbosity);
  15027. }
  15028. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15029. {
  15030. $this->writeError($messages, $newline, $verbosity);
  15031. }
  15032. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  15033. {
  15034. if ($this->hasAuthentication($repositoryName)) {
  15035. $auth = $this->getAuthentication($repositoryName);
  15036. if ($auth['username'] === $username && $auth['password'] === $password) {
  15037. return;
  15038. }
  15039. $this->writeError(
  15040. sprintf(
  15041. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  15042. $repositoryName
  15043. )
  15044. );
  15045. }
  15046. $this->setAuthentication($repositoryName, $username, $password);
  15047. }
  15048. public function loadConfiguration(Config $config)
  15049. {
  15050. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  15051. $githubOauth = $config->get('github-oauth') ?: array();
  15052. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  15053. $gitlabToken = $config->get('gitlab-token') ?: array();
  15054. $httpBasic = $config->get('http-basic') ?: array();
  15055. $bearerToken = $config->get('bearer') ?: array();
  15056. foreach ($bitbucketOauth as $domain => $cred) {
  15057. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  15058. }
  15059. foreach ($githubOauth as $domain => $token) {
  15060. if (!preg_match('{^[.A-Za-z0-9_]+$}', $token)) {
  15061. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  15062. }
  15063. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  15064. }
  15065. foreach ($gitlabOauth as $domain => $token) {
  15066. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  15067. }
  15068. foreach ($gitlabToken as $domain => $token) {
  15069. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  15070. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  15071. $this->checkAndSetAuthentication($domain, $username, $password);
  15072. }
  15073. foreach ($httpBasic as $domain => $cred) {
  15074. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  15075. }
  15076. foreach ($bearerToken as $domain => $token) {
  15077. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  15078. }
  15079. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  15080. }
  15081. public function emergency($message, array $context = array())
  15082. {
  15083. return $this->log(LogLevel::EMERGENCY, $message, $context);
  15084. }
  15085. public function alert($message, array $context = array())
  15086. {
  15087. return $this->log(LogLevel::ALERT, $message, $context);
  15088. }
  15089. public function critical($message, array $context = array())
  15090. {
  15091. return $this->log(LogLevel::CRITICAL, $message, $context);
  15092. }
  15093. public function error($message, array $context = array())
  15094. {
  15095. return $this->log(LogLevel::ERROR, $message, $context);
  15096. }
  15097. public function warning($message, array $context = array())
  15098. {
  15099. return $this->log(LogLevel::WARNING, $message, $context);
  15100. }
  15101. public function notice($message, array $context = array())
  15102. {
  15103. return $this->log(LogLevel::NOTICE, $message, $context);
  15104. }
  15105. public function info($message, array $context = array())
  15106. {
  15107. return $this->log(LogLevel::INFO, $message, $context);
  15108. }
  15109. public function debug($message, array $context = array())
  15110. {
  15111. return $this->log(LogLevel::DEBUG, $message, $context);
  15112. }
  15113. public function log($level, $message, array $context = array())
  15114. {
  15115. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  15116. $this->writeError('<error>'.$message.'</error>');
  15117. } elseif ($level === LogLevel::WARNING) {
  15118. $this->writeError('<warning>'.$message.'</warning>');
  15119. } elseif ($level === LogLevel::NOTICE) {
  15120. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  15121. } elseif ($level === LogLevel::INFO) {
  15122. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  15123. } else {
  15124. $this->writeError($message, true, self::DEBUG);
  15125. }
  15126. }
  15127. }
  15128. <?php
  15129. namespace Composer\IO;
  15130. use Symfony\Component\Console\Helper\QuestionHelper;
  15131. use Symfony\Component\Console\Output\StreamOutput;
  15132. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  15133. use Symfony\Component\Console\Input\StreamableInputInterface;
  15134. use Symfony\Component\Console\Input\StringInput;
  15135. use Symfony\Component\Console\Helper\HelperSet;
  15136. class BufferIO extends ConsoleIO
  15137. {
  15138. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  15139. {
  15140. $input = new StringInput($input);
  15141. $input->setInteractive(false);
  15142. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  15143. parent::__construct($input, $output, new HelperSet(array(
  15144. new QuestionHelper(),
  15145. )));
  15146. }
  15147. public function getOutput()
  15148. {
  15149. fseek($this->output->getStream(), 0);
  15150. $output = stream_get_contents($this->output->getStream());
  15151. $output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  15152. $pre = strip_tags($matches[1]);
  15153. if (strlen($pre) === strlen($matches[2])) {
  15154. return '';
  15155. }
  15156. return rtrim($matches[1])."\n";
  15157. }, $output);
  15158. return $output;
  15159. }
  15160. public function setUserInputs(array $inputs)
  15161. {
  15162. if (!$this->input instanceof StreamableInputInterface) {
  15163. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  15164. }
  15165. $this->input->setStream($this->createStream($inputs));
  15166. $this->input->setInteractive(true);
  15167. }
  15168. private function createStream(array $inputs)
  15169. {
  15170. $stream = fopen('php://memory', 'r+');
  15171. foreach ($inputs as $input) {
  15172. fwrite($stream, $input.PHP_EOL);
  15173. }
  15174. rewind($stream);
  15175. return $stream;
  15176. }
  15177. }
  15178. <?php
  15179. namespace Composer\IO;
  15180. use Composer\Question\StrictConfirmationQuestion;
  15181. use Symfony\Component\Console\Helper\HelperSet;
  15182. use Symfony\Component\Console\Helper\ProgressBar;
  15183. use Symfony\Component\Console\Input\InputInterface;
  15184. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  15185. use Symfony\Component\Console\Output\OutputInterface;
  15186. use Symfony\Component\Console\Question\ChoiceQuestion;
  15187. use Symfony\Component\Console\Question\Question;
  15188. class ConsoleIO extends BaseIO
  15189. {
  15190. protected $input;
  15191. protected $output;
  15192. protected $helperSet;
  15193. protected $lastMessage;
  15194. protected $lastMessageErr;
  15195. private $startTime;
  15196. private $verbosityMap;
  15197. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  15198. {
  15199. $this->input = $input;
  15200. $this->output = $output;
  15201. $this->helperSet = $helperSet;
  15202. $this->verbosityMap = array(
  15203. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  15204. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  15205. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  15206. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  15207. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  15208. );
  15209. }
  15210. public function enableDebugging($startTime)
  15211. {
  15212. $this->startTime = $startTime;
  15213. }
  15214. public function isInteractive()
  15215. {
  15216. return $this->input->isInteractive();
  15217. }
  15218. public function isDecorated()
  15219. {
  15220. return $this->output->isDecorated();
  15221. }
  15222. public function isVerbose()
  15223. {
  15224. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  15225. }
  15226. public function isVeryVerbose()
  15227. {
  15228. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  15229. }
  15230. public function isDebug()
  15231. {
  15232. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  15233. }
  15234. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15235. {
  15236. $this->doWrite($messages, $newline, false, $verbosity);
  15237. }
  15238. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15239. {
  15240. $this->doWrite($messages, $newline, true, $verbosity);
  15241. }
  15242. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15243. {
  15244. $this->doWrite($messages, $newline, false, $verbosity, true);
  15245. }
  15246. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15247. {
  15248. $this->doWrite($messages, $newline, true, $verbosity, true);
  15249. }
  15250. private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
  15251. {
  15252. $sfVerbosity = $this->verbosityMap[$verbosity];
  15253. if ($sfVerbosity > $this->output->getVerbosity()) {
  15254. return;
  15255. }
  15256. if (OutputInterface::VERBOSITY_QUIET === 0) {
  15257. $sfVerbosity = OutputInterface::OUTPUT_NORMAL;
  15258. }
  15259. if ($raw) {
  15260. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  15261. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  15262. } else {
  15263. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  15264. }
  15265. }
  15266. if (null !== $this->startTime) {
  15267. $memoryUsage = memory_get_usage() / 1024 / 1024;
  15268. $timeSpent = microtime(true) - $this->startTime;
  15269. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  15270. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  15271. }, (array) $messages);
  15272. }
  15273. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  15274. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  15275. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  15276. return;
  15277. }
  15278. $this->output->write($messages, $newline, $sfVerbosity);
  15279. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  15280. }
  15281. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15282. {
  15283. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  15284. }
  15285. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15286. {
  15287. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  15288. }
  15289. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  15290. {
  15291. $messages = implode($newline ? "\n" : '', (array) $messages);
  15292. if (!isset($size)) {
  15293. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  15294. }
  15295. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  15296. $this->doWrite($messages, false, $stderr, $verbosity);
  15297. $fill = $size - strlen(strip_tags($messages));
  15298. if ($fill > 0) {
  15299. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  15300. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  15301. }
  15302. if ($newline) {
  15303. $this->doWrite('', true, $stderr, $verbosity);
  15304. }
  15305. if ($stderr) {
  15306. $this->lastMessageErr = $messages;
  15307. } else {
  15308. $this->lastMessage = $messages;
  15309. }
  15310. }
  15311. public function getProgressBar($max = 0)
  15312. {
  15313. return new ProgressBar($this->getErrorOutput(), $max);
  15314. }
  15315. public function ask($question, $default = null)
  15316. {
  15317. $helper = $this->helperSet->get('question');
  15318. $question = new Question($question, $default);
  15319. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15320. }
  15321. public function askConfirmation($question, $default = true)
  15322. {
  15323. $helper = $this->helperSet->get('question');
  15324. $question = new StrictConfirmationQuestion($question, $default);
  15325. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15326. }
  15327. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  15328. {
  15329. $helper = $this->helperSet->get('question');
  15330. $question = new Question($question, $default);
  15331. $question->setValidator($validator);
  15332. $question->setMaxAttempts($attempts);
  15333. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15334. }
  15335. public function askAndHideAnswer($question)
  15336. {
  15337. $helper = $this->helperSet->get('question');
  15338. $question = new Question($question);
  15339. $question->setHidden(true);
  15340. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15341. }
  15342. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15343. {
  15344. $helper = $this->helperSet->get('question');
  15345. $question = new ChoiceQuestion($question, $choices, $default);
  15346. $question->setMaxAttempts($attempts ?: null);
  15347. $question->setErrorMessage($errorMessage);
  15348. $question->setMultiselect($multiselect);
  15349. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  15350. if (!is_array($result)) {
  15351. return (string) array_search($result, $choices, true);
  15352. }
  15353. $results = array();
  15354. foreach ($choices as $index => $choice) {
  15355. if (in_array($choice, $result, true)) {
  15356. $results[] = (string) $index;
  15357. }
  15358. }
  15359. return $results;
  15360. }
  15361. private function getErrorOutput()
  15362. {
  15363. if ($this->output instanceof ConsoleOutputInterface) {
  15364. return $this->output->getErrorOutput();
  15365. }
  15366. return $this->output;
  15367. }
  15368. }
  15369. <?php
  15370. namespace Composer\IO;
  15371. use Composer\Config;
  15372. use Psr\Log\LoggerInterface;
  15373. interface IOInterface extends LoggerInterface
  15374. {
  15375. const QUIET = 1;
  15376. const NORMAL = 2;
  15377. const VERBOSE = 4;
  15378. const VERY_VERBOSE = 8;
  15379. const DEBUG = 16;
  15380. public function isInteractive();
  15381. public function isVerbose();
  15382. public function isVeryVerbose();
  15383. public function isDebug();
  15384. public function isDecorated();
  15385. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  15386. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  15387. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15388. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15389. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15390. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15391. public function ask($question, $default = null);
  15392. public function askConfirmation($question, $default = true);
  15393. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  15394. public function askAndHideAnswer($question);
  15395. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  15396. public function getAuthentications();
  15397. public function hasAuthentication($repositoryName);
  15398. public function getAuthentication($repositoryName);
  15399. public function setAuthentication($repositoryName, $username, $password = null);
  15400. public function loadConfiguration(Config $config);
  15401. }
  15402. <?php
  15403. namespace Composer\IO;
  15404. class NullIO extends BaseIO
  15405. {
  15406. public function isInteractive()
  15407. {
  15408. return false;
  15409. }
  15410. public function isVerbose()
  15411. {
  15412. return false;
  15413. }
  15414. public function isVeryVerbose()
  15415. {
  15416. return false;
  15417. }
  15418. public function isDebug()
  15419. {
  15420. return false;
  15421. }
  15422. public function isDecorated()
  15423. {
  15424. return false;
  15425. }
  15426. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15427. {
  15428. }
  15429. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15430. {
  15431. }
  15432. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15433. {
  15434. }
  15435. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15436. {
  15437. }
  15438. public function ask($question, $default = null)
  15439. {
  15440. return $default;
  15441. }
  15442. public function askConfirmation($question, $default = true)
  15443. {
  15444. return $default;
  15445. }
  15446. public function askAndValidate($question, $validator, $attempts = false, $default = null)
  15447. {
  15448. return $default;
  15449. }
  15450. public function askAndHideAnswer($question)
  15451. {
  15452. return null;
  15453. }
  15454. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15455. {
  15456. return $default;
  15457. }
  15458. }
  15459. <?php
  15460. namespace Composer;
  15461. use Composer\Autoload\ClassLoader;
  15462. use Composer\Semver\VersionParser;
  15463. class InstalledVersions
  15464. {
  15465. private static $installed;
  15466. private static $canGetVendors;
  15467. private static $installedByVendor = array();
  15468. public static function getInstalledPackages()
  15469. {
  15470. $packages = array();
  15471. foreach (self::getInstalled() as $installed) {
  15472. $packages[] = array_keys($installed['versions']);
  15473. }
  15474. if (1 === \count($packages)) {
  15475. return $packages[0];
  15476. }
  15477. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  15478. }
  15479. public static function isInstalled($packageName)
  15480. {
  15481. foreach (self::getInstalled() as $installed) {
  15482. if (isset($installed['versions'][$packageName])) {
  15483. return true;
  15484. }
  15485. }
  15486. return false;
  15487. }
  15488. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  15489. {
  15490. $constraint = $parser->parseConstraints($constraint);
  15491. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  15492. return $provided->matches($constraint);
  15493. }
  15494. public static function getVersionRanges($packageName)
  15495. {
  15496. foreach (self::getInstalled() as $installed) {
  15497. if (!isset($installed['versions'][$packageName])) {
  15498. continue;
  15499. }
  15500. $ranges = array();
  15501. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  15502. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  15503. }
  15504. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  15505. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  15506. }
  15507. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  15508. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  15509. }
  15510. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  15511. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  15512. }
  15513. return implode(' || ', $ranges);
  15514. }
  15515. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15516. }
  15517. public static function getVersion($packageName)
  15518. {
  15519. foreach (self::getInstalled() as $installed) {
  15520. if (!isset($installed['versions'][$packageName])) {
  15521. continue;
  15522. }
  15523. if (!isset($installed['versions'][$packageName]['version'])) {
  15524. return null;
  15525. }
  15526. return $installed['versions'][$packageName]['version'];
  15527. }
  15528. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15529. }
  15530. public static function getPrettyVersion($packageName)
  15531. {
  15532. foreach (self::getInstalled() as $installed) {
  15533. if (!isset($installed['versions'][$packageName])) {
  15534. continue;
  15535. }
  15536. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  15537. return null;
  15538. }
  15539. return $installed['versions'][$packageName]['pretty_version'];
  15540. }
  15541. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15542. }
  15543. public static function getReference($packageName)
  15544. {
  15545. foreach (self::getInstalled() as $installed) {
  15546. if (!isset($installed['versions'][$packageName])) {
  15547. continue;
  15548. }
  15549. if (!isset($installed['versions'][$packageName]['reference'])) {
  15550. return null;
  15551. }
  15552. return $installed['versions'][$packageName]['reference'];
  15553. }
  15554. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15555. }
  15556. public static function getRootPackage()
  15557. {
  15558. $installed = self::getInstalled();
  15559. return $installed[0]['root'];
  15560. }
  15561. public static function getRawData()
  15562. {
  15563. return self::$installed;
  15564. }
  15565. public static function reload($data)
  15566. {
  15567. self::$installed = $data;
  15568. self::$installedByVendor = array();
  15569. }
  15570. private static function getInstalled()
  15571. {
  15572. if (null === self::$canGetVendors) {
  15573. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  15574. }
  15575. $installed = array();
  15576. if (self::$canGetVendors) {
  15577. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  15578. if (isset(self::$installedByVendor[$vendorDir])) {
  15579. $installed[] = self::$installedByVendor[$vendorDir];
  15580. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  15581. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  15582. }
  15583. }
  15584. }
  15585. $installed[] = self::$installed;
  15586. return $installed;
  15587. }
  15588. }
  15589. <?php
  15590. namespace Composer;
  15591. use Composer\Autoload\AutoloadGenerator;
  15592. use Composer\Console\GithubActionError;
  15593. use Composer\DependencyResolver\DefaultPolicy;
  15594. use Composer\DependencyResolver\LocalRepoTransaction;
  15595. use Composer\DependencyResolver\LockTransaction;
  15596. use Composer\DependencyResolver\Operation\UpdateOperation;
  15597. use Composer\DependencyResolver\Operation\InstallOperation;
  15598. use Composer\DependencyResolver\Operation\UninstallOperation;
  15599. use Composer\DependencyResolver\Pool;
  15600. use Composer\DependencyResolver\Request;
  15601. use Composer\DependencyResolver\Solver;
  15602. use Composer\DependencyResolver\SolverProblemsException;
  15603. use Composer\DependencyResolver\PolicyInterface;
  15604. use Composer\Downloader\DownloadManager;
  15605. use Composer\EventDispatcher\EventDispatcher;
  15606. use Composer\Installer\InstallationManager;
  15607. use Composer\Installer\InstallerEvents;
  15608. use Composer\Installer\SuggestedPackagesReporter;
  15609. use Composer\IO\IOInterface;
  15610. use Composer\Package\AliasPackage;
  15611. use Composer\Package\RootAliasPackage;
  15612. use Composer\Package\BasePackage;
  15613. use Composer\Package\CompletePackage;
  15614. use Composer\Package\CompletePackageInterface;
  15615. use Composer\Package\Link;
  15616. use Composer\Package\Loader\ArrayLoader;
  15617. use Composer\Package\Dumper\ArrayDumper;
  15618. use Composer\Package\Version\VersionParser;
  15619. use Composer\Package\Package;
  15620. use Composer\Repository\ArrayRepository;
  15621. use Composer\Repository\RepositorySet;
  15622. use Composer\Repository\CompositeRepository;
  15623. use Composer\Semver\Constraint\Constraint;
  15624. use Composer\Package\Locker;
  15625. use Composer\Package\RootPackageInterface;
  15626. use Composer\Repository\InstalledArrayRepository;
  15627. use Composer\Repository\InstalledRepositoryInterface;
  15628. use Composer\Repository\InstalledRepository;
  15629. use Composer\Repository\FilterRepository;
  15630. use Composer\Repository\RootPackageRepository;
  15631. use Composer\Repository\PlatformRepository;
  15632. use Composer\Repository\RepositoryInterface;
  15633. use Composer\Repository\RepositoryManager;
  15634. use Composer\Repository\LockArrayRepository;
  15635. use Composer\Script\ScriptEvents;
  15636. class Installer
  15637. {
  15638. protected $io;
  15639. protected $config;
  15640. protected $package;
  15641. protected $fixedRootPackage;
  15642. protected $downloadManager;
  15643. protected $repositoryManager;
  15644. protected $locker;
  15645. protected $installationManager;
  15646. protected $eventDispatcher;
  15647. protected $autoloadGenerator;
  15648. protected $preferSource = false;
  15649. protected $preferDist = false;
  15650. protected $optimizeAutoloader = false;
  15651. protected $classMapAuthoritative = false;
  15652. protected $apcuAutoloader = false;
  15653. protected $apcuAutoloaderPrefix;
  15654. protected $devMode = false;
  15655. protected $dryRun = false;
  15656. protected $verbose = false;
  15657. protected $update = false;
  15658. protected $install = true;
  15659. protected $dumpAutoloader = true;
  15660. protected $runScripts = true;
  15661. protected $ignorePlatformReqs = false;
  15662. protected $preferStable = false;
  15663. protected $preferLowest = false;
  15664. protected $writeLock;
  15665. protected $executeOperations = true;
  15666. protected $updateMirrors = false;
  15667. protected $updateAllowList;
  15668. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  15669. protected $suggestedPackagesReporter;
  15670. protected $additionalFixedRepository;
  15671. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  15672. {
  15673. $this->io = $io;
  15674. $this->config = $config;
  15675. $this->package = $package;
  15676. $this->downloadManager = $downloadManager;
  15677. $this->repositoryManager = $repositoryManager;
  15678. $this->locker = $locker;
  15679. $this->installationManager = $installationManager;
  15680. $this->eventDispatcher = $eventDispatcher;
  15681. $this->autoloadGenerator = $autoloadGenerator;
  15682. $this->writeLock = $config->get('lock');
  15683. }
  15684. public function run()
  15685. {
  15686. gc_collect_cycles();
  15687. gc_disable();
  15688. if ($this->updateAllowList && $this->updateMirrors) {
  15689. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  15690. }
  15691. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  15692. if (!$this->update && !$this->locker->isLocked()) {
  15693. $this->io->writeError('<warning>No lock file found. Updating dependencies instead of installing from lock file. Use composer update over composer install if you do not have a lock file.</warning>');
  15694. $this->update = true;
  15695. }
  15696. if ($this->dryRun) {
  15697. $this->verbose = true;
  15698. $this->runScripts = false;
  15699. $this->executeOperations = false;
  15700. $this->writeLock = false;
  15701. $this->dumpAutoloader = false;
  15702. $this->mockLocalRepositories($this->repositoryManager);
  15703. }
  15704. if ($this->update && !$this->install) {
  15705. $this->dumpAutoloader = false;
  15706. }
  15707. if ($this->runScripts) {
  15708. $_SERVER['COMPOSER_DEV_MODE'] = $this->devMode ? '1' : '0';
  15709. putenv('COMPOSER_DEV_MODE='.$_SERVER['COMPOSER_DEV_MODE']);
  15710. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  15711. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15712. }
  15713. $this->downloadManager->setPreferSource($this->preferSource);
  15714. $this->downloadManager->setPreferDist($this->preferDist);
  15715. $localRepo = $this->repositoryManager->getLocalRepository();
  15716. if (!$this->suggestedPackagesReporter) {
  15717. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  15718. }
  15719. try {
  15720. if ($this->update) {
  15721. $res = $this->doUpdate($localRepo, $this->install);
  15722. } else {
  15723. $res = $this->doInstall($localRepo);
  15724. }
  15725. if ($res !== 0) {
  15726. return $res;
  15727. }
  15728. } catch (\Exception $e) {
  15729. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15730. $this->installationManager->notifyInstalls($this->io);
  15731. }
  15732. throw $e;
  15733. }
  15734. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15735. $this->installationManager->notifyInstalls($this->io);
  15736. }
  15737. if ($this->update) {
  15738. $installedRepo = new InstalledRepository(array(
  15739. $this->locker->getLockedRepository($this->devMode),
  15740. $this->createPlatformRepo(false),
  15741. new RootPackageRepository(clone $this->package),
  15742. ));
  15743. if ($isFreshInstall) {
  15744. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  15745. }
  15746. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  15747. }
  15748. $lockedRepository = $this->locker->getLockedRepository(true);
  15749. foreach ($lockedRepository->getPackages() as $package) {
  15750. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  15751. continue;
  15752. }
  15753. $replacement = is_string($package->getReplacementPackage())
  15754. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  15755. : 'No replacement was suggested';
  15756. $this->io->writeError(
  15757. sprintf(
  15758. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  15759. $package->getPrettyName(),
  15760. $replacement
  15761. )
  15762. );
  15763. }
  15764. if ($this->dumpAutoloader) {
  15765. if ($this->optimizeAutoloader) {
  15766. $this->io->writeError('<info>Generating optimized autoload files</info>');
  15767. } else {
  15768. $this->io->writeError('<info>Generating autoload files</info>');
  15769. }
  15770. $this->autoloadGenerator->setDevMode($this->devMode);
  15771. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  15772. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  15773. $this->autoloadGenerator->setRunScripts($this->runScripts);
  15774. $this->autoloadGenerator->setIgnorePlatformRequirements($this->ignorePlatformReqs);
  15775. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  15776. }
  15777. if ($this->install && $this->executeOperations) {
  15778. foreach ($localRepo->getPackages() as $package) {
  15779. $this->installationManager->ensureBinariesPresence($package);
  15780. }
  15781. }
  15782. $fundingCount = 0;
  15783. foreach ($localRepo->getPackages() as $package) {
  15784. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  15785. $fundingCount++;
  15786. }
  15787. }
  15788. if ($fundingCount) {
  15789. $this->io->writeError(array(
  15790. sprintf(
  15791. "<info>%d package%s you are using %s looking for funding.</info>",
  15792. $fundingCount,
  15793. 1 === $fundingCount ? '' : 's',
  15794. 1 === $fundingCount ? 'is' : 'are'
  15795. ),
  15796. '<info>Use the `composer fund` command to find out more!</info>',
  15797. ));
  15798. }
  15799. if ($this->runScripts) {
  15800. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  15801. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15802. }
  15803. if (!defined('HHVM_VERSION')) {
  15804. gc_enable();
  15805. }
  15806. return 0;
  15807. }
  15808. protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
  15809. {
  15810. $platformRepo = $this->createPlatformRepo(true);
  15811. $aliases = $this->getRootAliases(true);
  15812. $lockedRepository = null;
  15813. try {
  15814. if ($this->locker->isLocked()) {
  15815. $lockedRepository = $this->locker->getLockedRepository(true);
  15816. }
  15817. } catch (\Seld\JsonLint\ParsingException $e) {
  15818. if ($this->updateAllowList || $this->updateMirrors) {
  15819. throw $e;
  15820. }
  15821. }
  15822. if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
  15823. $this->io->writeError('<error>Cannot update ' . ($this->updateMirrors ? 'lock file information' : 'only a partial set of packages') . ' without a lock file present. Run `composer update` to generate a lock file.</error>', true, IOInterface::QUIET);
  15824. return 1;
  15825. }
  15826. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  15827. $policy = $this->createPolicy(true);
  15828. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15829. $repositories = $this->repositoryManager->getRepositories();
  15830. foreach ($repositories as $repository) {
  15831. $repositorySet->addRepository($repository);
  15832. }
  15833. if ($lockedRepository) {
  15834. $repositorySet->addRepository($lockedRepository);
  15835. }
  15836. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15837. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  15838. if ($this->updateAllowList) {
  15839. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  15840. }
  15841. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15842. $this->io->writeError('<info>Updating dependencies</info>');
  15843. $solver = new Solver($policy, $pool, $this->io);
  15844. try {
  15845. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15846. $ruleSetSize = $solver->getRuleSetSize();
  15847. $solver = null;
  15848. } catch (SolverProblemsException $e) {
  15849. $err = 'Your requirements could not be resolved to an installable set of packages.';
  15850. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15851. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15852. $this->io->writeError($prettyProblem);
  15853. if (!$this->devMode) {
  15854. $this->io->writeError('<warning>Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.</warning>', true, IOInterface::QUIET);
  15855. }
  15856. $ghe = new GithubActionError($this->io);
  15857. $ghe->emit($err."\n".$prettyProblem);
  15858. return max(1, $e->getCode());
  15859. }
  15860. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  15861. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  15862. if (!$lockTransaction->getOperations()) {
  15863. $this->io->writeError('Nothing to modify in lock file');
  15864. }
  15865. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  15866. if ($exitCode !== 0) {
  15867. return $exitCode;
  15868. }
  15869. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  15870. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  15871. $installsUpdates = $uninstalls = array();
  15872. if ($lockTransaction->getOperations()) {
  15873. $installNames = $updateNames = $uninstallNames = array();
  15874. foreach ($lockTransaction->getOperations() as $operation) {
  15875. if ($operation instanceof InstallOperation) {
  15876. $installsUpdates[] = $operation;
  15877. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15878. } elseif ($operation instanceof UpdateOperation) {
  15879. $installsUpdates[] = $operation;
  15880. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15881. } elseif ($operation instanceof UninstallOperation) {
  15882. $uninstalls[] = $operation;
  15883. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  15884. }
  15885. }
  15886. $this->io->writeError(sprintf(
  15887. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  15888. count($installNames),
  15889. 1 === count($installNames) ? '' : 's',
  15890. count($updateNames),
  15891. 1 === count($updateNames) ? '' : 's',
  15892. count($uninstalls),
  15893. 1 === count($uninstalls) ? '' : 's'
  15894. ));
  15895. if ($installNames) {
  15896. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  15897. }
  15898. if ($updateNames) {
  15899. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  15900. }
  15901. if ($uninstalls) {
  15902. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  15903. }
  15904. }
  15905. $sortByName = function ($a, $b) {
  15906. if ($a instanceof UpdateOperation) {
  15907. $a = $a->getTargetPackage()->getName();
  15908. } else {
  15909. $a = $a->getPackage()->getName();
  15910. }
  15911. if ($b instanceof UpdateOperation) {
  15912. $b = $b->getTargetPackage()->getName();
  15913. } else {
  15914. $b = $b->getPackage()->getName();
  15915. }
  15916. return strcmp($a, $b);
  15917. };
  15918. usort($uninstalls, $sortByName);
  15919. usort($installsUpdates, $sortByName);
  15920. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  15921. if ($operation instanceof InstallOperation) {
  15922. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  15923. }
  15924. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  15925. $this->io->writeError(' - ' . $operation->show(true));
  15926. }
  15927. }
  15928. $updatedLock = $this->locker->setLockData(
  15929. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  15930. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  15931. $platformReqs,
  15932. $platformDevReqs,
  15933. $lockTransaction->getAliases($aliases),
  15934. $this->package->getMinimumStability(),
  15935. $this->package->getStabilityFlags(),
  15936. $this->preferStable || $this->package->getPreferStable(),
  15937. $this->preferLowest,
  15938. $this->config->get('platform') ?: array(),
  15939. $this->writeLock && $this->executeOperations
  15940. );
  15941. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  15942. $this->io->writeError('<info>Writing lock file</info>');
  15943. }
  15944. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  15945. $vendorDir = $this->config->get('vendor-dir');
  15946. if (is_dir($vendorDir)) {
  15947. @touch($vendorDir);
  15948. }
  15949. }
  15950. if ($doInstall) {
  15951. return $this->doInstall($localRepo, true);
  15952. }
  15953. return 0;
  15954. }
  15955. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null)
  15956. {
  15957. if (!$this->package->getDevRequires()) {
  15958. return 0;
  15959. }
  15960. $resultRepo = new ArrayRepository(array());
  15961. $loader = new ArrayLoader(null, true);
  15962. $dumper = new ArrayDumper();
  15963. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  15964. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  15965. }
  15966. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15967. $repositorySet->addRepository($resultRepo);
  15968. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  15969. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  15970. $pool = $repositorySet->createPoolWithAllPackages();
  15971. $solver = new Solver($policy, $pool, $this->io);
  15972. try {
  15973. $nonDevLockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15974. $solver = null;
  15975. } catch (SolverProblemsException $e) {
  15976. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  15977. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  15978. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15979. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  15980. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  15981. $this->io->writeError($prettyProblem);
  15982. $ghe = new GithubActionError($this->io);
  15983. $ghe->emit($err."\n".$prettyProblem);
  15984. return max(1, $e->getCode());
  15985. }
  15986. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  15987. return 0;
  15988. }
  15989. protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false)
  15990. {
  15991. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  15992. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  15993. if (!$alreadySolved) {
  15994. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  15995. $platformRepo = $this->createPlatformRepo(false);
  15996. $policy = $this->createPolicy(false);
  15997. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  15998. $repositorySet->addRepository($lockedRepository);
  15999. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  16000. if (!$this->locker->isFresh()) {
  16001. $this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.</warning>', true, IOInterface::QUIET);
  16002. }
  16003. foreach ($lockedRepository->getPackages() as $package) {
  16004. $request->fixLockedPackage($package);
  16005. }
  16006. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  16007. $request->requireName($link->getTarget(), $link->getConstraint());
  16008. }
  16009. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  16010. $solver = new Solver($policy, $pool, $this->io);
  16011. try {
  16012. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  16013. $solver = null;
  16014. if (0 !== count($lockTransaction->getOperations())) {
  16015. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  16016. return 1;
  16017. }
  16018. } catch (SolverProblemsException $e) {
  16019. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  16020. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  16021. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  16022. $this->io->writeError($prettyProblem);
  16023. $ghe = new GithubActionError($this->io);
  16024. $ghe->emit($err."\n".$prettyProblem);
  16025. return max(1, $e->getCode());
  16026. }
  16027. }
  16028. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  16029. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  16030. if (!$localRepoTransaction->getOperations()) {
  16031. $this->io->writeError('Nothing to install, update or remove');
  16032. }
  16033. if ($localRepoTransaction->getOperations()) {
  16034. $installs = $updates = $uninstalls = array();
  16035. foreach ($localRepoTransaction->getOperations() as $operation) {
  16036. if ($operation instanceof InstallOperation) {
  16037. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  16038. } elseif ($operation instanceof UpdateOperation) {
  16039. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  16040. } elseif ($operation instanceof UninstallOperation) {
  16041. $uninstalls[] = $operation->getPackage()->getPrettyName();
  16042. }
  16043. }
  16044. $this->io->writeError(sprintf(
  16045. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  16046. count($installs),
  16047. 1 === count($installs) ? '' : 's',
  16048. count($updates),
  16049. 1 === count($updates) ? '' : 's',
  16050. count($uninstalls),
  16051. 1 === count($uninstalls) ? '' : 's'
  16052. ));
  16053. if ($installs) {
  16054. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  16055. }
  16056. if ($updates) {
  16057. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  16058. }
  16059. if ($uninstalls) {
  16060. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  16061. }
  16062. }
  16063. if ($this->executeOperations) {
  16064. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  16065. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  16066. } else {
  16067. foreach ($localRepoTransaction->getOperations() as $operation) {
  16068. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  16069. $this->io->writeError(' - ' . $operation->show(false));
  16070. }
  16071. }
  16072. }
  16073. return 0;
  16074. }
  16075. protected function createPlatformRepo($forUpdate)
  16076. {
  16077. if ($forUpdate) {
  16078. $platformOverrides = $this->config->get('platform') ?: array();
  16079. } else {
  16080. $platformOverrides = $this->locker->getPlatformOverrides();
  16081. }
  16082. return new PlatformRepository(array(), $platformOverrides);
  16083. }
  16084. private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
  16085. {
  16086. if ($forUpdate) {
  16087. $minimumStability = $this->package->getMinimumStability();
  16088. $stabilityFlags = $this->package->getStabilityFlags();
  16089. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  16090. } else {
  16091. $minimumStability = $this->locker->getMinimumStability();
  16092. $stabilityFlags = $this->locker->getStabilityFlags();
  16093. $requires = array();
  16094. foreach ($lockedRepository->getPackages() as $package) {
  16095. $constraint = new Constraint('=', $package->getVersion());
  16096. $constraint->setPrettyString($package->getPrettyVersion());
  16097. $requires[$package->getName()] = $constraint;
  16098. }
  16099. }
  16100. $rootRequires = array();
  16101. foreach ($requires as $req => $constraint) {
  16102. if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($req)) {
  16103. continue;
  16104. }
  16105. if ($constraint instanceof Link) {
  16106. $rootRequires[$req] = $constraint->getConstraint();
  16107. } else {
  16108. $rootRequires[$req] = $constraint;
  16109. }
  16110. }
  16111. $this->fixedRootPackage = clone $this->package;
  16112. $this->fixedRootPackage->setRequires(array());
  16113. $this->fixedRootPackage->setDevRequires(array());
  16114. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  16115. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  16116. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  16117. $repositorySet->addRepository($platformRepo);
  16118. if ($this->additionalFixedRepository) {
  16119. $additionalFixedRepositories = $this->additionalFixedRepository;
  16120. if ($additionalFixedRepositories instanceof CompositeRepository) {
  16121. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  16122. } else {
  16123. $additionalFixedRepositories = array($additionalFixedRepositories);
  16124. }
  16125. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  16126. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  16127. $repositorySet->allowInstalledRepositories();
  16128. break;
  16129. }
  16130. }
  16131. $repositorySet->addRepository($this->additionalFixedRepository);
  16132. }
  16133. return $repositorySet;
  16134. }
  16135. private function createPolicy($forUpdate)
  16136. {
  16137. $preferStable = null;
  16138. $preferLowest = null;
  16139. if (!$forUpdate) {
  16140. $preferStable = $this->locker->getPreferStable();
  16141. $preferLowest = $this->locker->getPreferLowest();
  16142. }
  16143. if (null === $preferStable) {
  16144. $preferStable = $this->preferStable || $this->package->getPreferStable();
  16145. }
  16146. if (null === $preferLowest) {
  16147. $preferLowest = $this->preferLowest;
  16148. }
  16149. return new DefaultPolicy($preferStable, $preferLowest);
  16150. }
  16151. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null)
  16152. {
  16153. $request = new Request($lockedRepository);
  16154. $request->fixPackage($rootPackage);
  16155. if ($rootPackage instanceof RootAliasPackage) {
  16156. $request->fixPackage($rootPackage->getAliasOf());
  16157. }
  16158. $fixedPackages = $platformRepo->getPackages();
  16159. if ($this->additionalFixedRepository) {
  16160. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  16161. }
  16162. $provided = $rootPackage->getProvides();
  16163. foreach ($fixedPackages as $package) {
  16164. if ($package->getRepository() !== $platformRepo
  16165. || !isset($provided[$package->getName()])
  16166. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  16167. ) {
  16168. $request->fixPackage($package);
  16169. }
  16170. }
  16171. return $request;
  16172. }
  16173. private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true)
  16174. {
  16175. if ($this->updateMirrors) {
  16176. $excludedPackages = array();
  16177. if (!$includeDevRequires) {
  16178. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  16179. }
  16180. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  16181. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  16182. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  16183. }
  16184. }
  16185. } else {
  16186. $links = $this->package->getRequires();
  16187. if ($includeDevRequires) {
  16188. $links = array_merge($links, $this->package->getDevRequires());
  16189. }
  16190. foreach ($links as $link) {
  16191. $request->requireName($link->getTarget(), $link->getConstraint());
  16192. }
  16193. }
  16194. }
  16195. private function getRootAliases($forUpdate)
  16196. {
  16197. if ($forUpdate) {
  16198. $aliases = $this->package->getAliases();
  16199. } else {
  16200. $aliases = $this->locker->getAliases();
  16201. }
  16202. return $aliases;
  16203. }
  16204. private function extractPlatformRequirements(array $links)
  16205. {
  16206. $platformReqs = array();
  16207. foreach ($links as $link) {
  16208. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  16209. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  16210. }
  16211. }
  16212. return $platformReqs;
  16213. }
  16214. private function mockLocalRepositories(RepositoryManager $rm)
  16215. {
  16216. $packages = array();
  16217. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  16218. $packages[(string) $package] = clone $package;
  16219. }
  16220. foreach ($packages as $key => $package) {
  16221. if ($package instanceof AliasPackage) {
  16222. $alias = (string) $package->getAliasOf();
  16223. $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  16224. }
  16225. }
  16226. $rm->setLocalRepository(
  16227. new InstalledArrayRepository($packages)
  16228. );
  16229. }
  16230. public static function create(IOInterface $io, Composer $composer)
  16231. {
  16232. return new static(
  16233. $io,
  16234. $composer->getConfig(),
  16235. $composer->getPackage(),
  16236. $composer->getDownloadManager(),
  16237. $composer->getRepositoryManager(),
  16238. $composer->getLocker(),
  16239. $composer->getInstallationManager(),
  16240. $composer->getEventDispatcher(),
  16241. $composer->getAutoloadGenerator()
  16242. );
  16243. }
  16244. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository)
  16245. {
  16246. $this->additionalFixedRepository = $additionalFixedRepository;
  16247. return $this;
  16248. }
  16249. public function setDryRun($dryRun = true)
  16250. {
  16251. $this->dryRun = (bool) $dryRun;
  16252. return $this;
  16253. }
  16254. public function isDryRun()
  16255. {
  16256. return $this->dryRun;
  16257. }
  16258. public function setPreferSource($preferSource = true)
  16259. {
  16260. $this->preferSource = (bool) $preferSource;
  16261. return $this;
  16262. }
  16263. public function setPreferDist($preferDist = true)
  16264. {
  16265. $this->preferDist = (bool) $preferDist;
  16266. return $this;
  16267. }
  16268. public function setOptimizeAutoloader($optimizeAutoloader)
  16269. {
  16270. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  16271. if (!$this->optimizeAutoloader) {
  16272. $this->setClassMapAuthoritative(false);
  16273. }
  16274. return $this;
  16275. }
  16276. public function setClassMapAuthoritative($classMapAuthoritative)
  16277. {
  16278. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  16279. if ($this->classMapAuthoritative) {
  16280. $this->setOptimizeAutoloader(true);
  16281. }
  16282. return $this;
  16283. }
  16284. public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
  16285. {
  16286. $this->apcuAutoloader = $apcuAutoloader;
  16287. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  16288. return $this;
  16289. }
  16290. public function setUpdate($update)
  16291. {
  16292. $this->update = (bool) $update;
  16293. return $this;
  16294. }
  16295. public function setInstall($install)
  16296. {
  16297. $this->install = (bool) $install;
  16298. return $this;
  16299. }
  16300. public function setDevMode($devMode = true)
  16301. {
  16302. $this->devMode = (bool) $devMode;
  16303. return $this;
  16304. }
  16305. public function setDumpAutoloader($dumpAutoloader = true)
  16306. {
  16307. $this->dumpAutoloader = (bool) $dumpAutoloader;
  16308. return $this;
  16309. }
  16310. public function setRunScripts($runScripts = true)
  16311. {
  16312. $this->runScripts = (bool) $runScripts;
  16313. return $this;
  16314. }
  16315. public function setConfig(Config $config)
  16316. {
  16317. $this->config = $config;
  16318. return $this;
  16319. }
  16320. public function setVerbose($verbose = true)
  16321. {
  16322. $this->verbose = (bool) $verbose;
  16323. return $this;
  16324. }
  16325. public function isVerbose()
  16326. {
  16327. return $this->verbose;
  16328. }
  16329. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  16330. {
  16331. if (is_array($ignorePlatformReqs)) {
  16332. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  16333. return PlatformRepository::isPlatformPackage($req);
  16334. });
  16335. } else {
  16336. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  16337. }
  16338. return $this;
  16339. }
  16340. public function setUpdateMirrors($updateMirrors)
  16341. {
  16342. $this->updateMirrors = $updateMirrors;
  16343. return $this;
  16344. }
  16345. public function setUpdateAllowList(array $packages)
  16346. {
  16347. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  16348. return $this;
  16349. }
  16350. public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  16351. {
  16352. if (!in_array($updateAllowTransitiveDependencies, array(Request::UPDATE_ONLY_LISTED, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS), true)) {
  16353. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  16354. }
  16355. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  16356. return $this;
  16357. }
  16358. public function setPreferStable($preferStable = true)
  16359. {
  16360. $this->preferStable = (bool) $preferStable;
  16361. return $this;
  16362. }
  16363. public function setPreferLowest($preferLowest = true)
  16364. {
  16365. $this->preferLowest = (bool) $preferLowest;
  16366. return $this;
  16367. }
  16368. public function setWriteLock($writeLock = true)
  16369. {
  16370. $this->writeLock = (bool) $writeLock;
  16371. return $this;
  16372. }
  16373. public function setExecuteOperations($executeOperations = true)
  16374. {
  16375. $this->executeOperations = (bool) $executeOperations;
  16376. return $this;
  16377. }
  16378. public function disablePlugins()
  16379. {
  16380. $this->installationManager->disablePlugins();
  16381. return $this;
  16382. }
  16383. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  16384. {
  16385. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  16386. return $this;
  16387. }
  16388. }
  16389. <?php
  16390. namespace Composer\Installer;
  16391. use Composer\IO\IOInterface;
  16392. use Composer\Package\PackageInterface;
  16393. use Composer\Util\Filesystem;
  16394. use Composer\Util\Platform;
  16395. use Composer\Util\ProcessExecutor;
  16396. use Composer\Util\Silencer;
  16397. class BinaryInstaller
  16398. {
  16399. protected $binDir;
  16400. protected $binCompat;
  16401. protected $io;
  16402. protected $filesystem;
  16403. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
  16404. {
  16405. $this->binDir = $binDir;
  16406. $this->binCompat = $binCompat;
  16407. $this->io = $io;
  16408. $this->filesystem = $filesystem ?: new Filesystem();
  16409. }
  16410. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  16411. {
  16412. $binaries = $this->getBinaries($package);
  16413. if (!$binaries) {
  16414. return;
  16415. }
  16416. foreach ($binaries as $bin) {
  16417. $binPath = $installPath.'/'.$bin;
  16418. if (!file_exists($binPath)) {
  16419. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  16420. continue;
  16421. }
  16422. $binPath = realpath($binPath);
  16423. $this->initializeBinDir();
  16424. $link = $this->binDir.'/'.basename($bin);
  16425. if (file_exists($link)) {
  16426. if (is_link($link)) {
  16427. Silencer::call('chmod', $link, 0777 & ~umask());
  16428. }
  16429. if ($warnOnOverwrite) {
  16430. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  16431. }
  16432. continue;
  16433. }
  16434. if ($this->binCompat === "auto") {
  16435. if (Platform::isWindows()) {
  16436. $this->installFullBinaries($binPath, $link, $bin, $package);
  16437. } else {
  16438. $this->installSymlinkBinaries($binPath, $link);
  16439. }
  16440. } elseif ($this->binCompat === "full") {
  16441. $this->installFullBinaries($binPath, $link, $bin, $package);
  16442. }
  16443. Silencer::call('chmod', $link, 0777 & ~umask());
  16444. }
  16445. }
  16446. public function removeBinaries(PackageInterface $package)
  16447. {
  16448. $this->initializeBinDir();
  16449. $binaries = $this->getBinaries($package);
  16450. if (!$binaries) {
  16451. return;
  16452. }
  16453. foreach ($binaries as $bin) {
  16454. $link = $this->binDir.'/'.basename($bin);
  16455. if (is_link($link) || file_exists($link)) {
  16456. $this->filesystem->unlink($link);
  16457. }
  16458. if (file_exists($link.'.bat')) {
  16459. $this->filesystem->unlink($link.'.bat');
  16460. }
  16461. }
  16462. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  16463. Silencer::call('rmdir', $this->binDir);
  16464. }
  16465. }
  16466. public static function determineBinaryCaller($bin)
  16467. {
  16468. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  16469. return 'call';
  16470. }
  16471. $handle = fopen($bin, 'r');
  16472. $line = fgets($handle);
  16473. fclose($handle);
  16474. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  16475. return trim($match[1]);
  16476. }
  16477. return 'php';
  16478. }
  16479. protected function getBinaries(PackageInterface $package)
  16480. {
  16481. return $package->getBinaries();
  16482. }
  16483. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  16484. {
  16485. if ('.bat' !== substr($binPath, -4)) {
  16486. $this->installUnixyProxyBinaries($binPath, $link);
  16487. @chmod($link, 0777 & ~umask());
  16488. $link .= '.bat';
  16489. if (file_exists($link)) {
  16490. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  16491. }
  16492. }
  16493. if (!file_exists($link)) {
  16494. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  16495. }
  16496. }
  16497. protected function installSymlinkBinaries($binPath, $link)
  16498. {
  16499. if (!$this->filesystem->relativeSymlink($binPath, $link)) {
  16500. $this->installUnixyProxyBinaries($binPath, $link);
  16501. }
  16502. }
  16503. protected function installUnixyProxyBinaries($binPath, $link)
  16504. {
  16505. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  16506. }
  16507. protected function initializeBinDir()
  16508. {
  16509. $this->filesystem->ensureDirectoryExists($this->binDir);
  16510. $this->binDir = realpath($this->binDir);
  16511. }
  16512. protected function generateWindowsProxyCode($bin, $link)
  16513. {
  16514. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16515. $caller = self::determineBinaryCaller($bin);
  16516. return "@ECHO OFF\r\n".
  16517. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  16518. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  16519. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  16520. }
  16521. protected function generateUnixyProxyCode($bin, $link)
  16522. {
  16523. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16524. $binDir = ProcessExecutor::escape(dirname($binPath));
  16525. $binFile = basename($binPath);
  16526. $binContents = file_get_contents($bin);
  16527. if (preg_match('{^(?:#!(?:/usr)?/bin/env php|#!(?:/usr)?/bin/php|<?php)\r?\n}', $binContents, $match)) {
  16528. if (false === ($pos = strpos($binContents, '__HALT_COMPILER')) || false === strpos(substr($binContents, 0, $pos), 'Phar::mapPhar')) {
  16529. $proxyCode = trim($match[0]);
  16530. if ($proxyCode === "<?php") {
  16531. $proxyCode = "#!/usr/bin/env php";
  16532. }
  16533. $binPathExported = var_export($binPath, true);
  16534. return $proxyCode . "\n" . <<<PROXY
  16535. <?php
  16536. /**
  16537. * Proxy PHP file generated by Composer
  16538. *
  16539. * This file includes the referenced bin path ($binPath) using eval to remove the shebang if present
  16540. *
  16541. * @generated
  16542. */
  16543. \$binPath = realpath(__DIR__ . "/" . $binPathExported);
  16544. \$contents = file_get_contents(\$binPath);
  16545. \$contents = preg_replace('{^#!/.+\\r?\\n<\\?(php)?}', '', \$contents, 1, \$replaced);
  16546. if (\$replaced) {
  16547. \$contents = strtr(\$contents, array(
  16548. '__FILE__' => var_export(\$binPath, true),
  16549. '__DIR__' => var_export(dirname(\$binPath), true),
  16550. ));
  16551. eval(\$contents);
  16552. exit(0);
  16553. }
  16554. include \$binPath;
  16555. PROXY;
  16556. }
  16557. }
  16558. $proxyCode = <<<PROXY
  16559. #!/usr/bin/env sh
  16560. dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  16561. if [ -d /proc/cygdrive ]; then
  16562. case \$(which php) in
  16563. \$(readlink -n /proc/cygdrive)/*)
  16564. # We are in Cygwin using Windows php, so the path must be translated
  16565. dir=\$(cygpath -m "\$dir");
  16566. ;;
  16567. esac
  16568. fi
  16569. "\${dir}/$binFile" "\$@"
  16570. PROXY;
  16571. return $proxyCode;
  16572. }
  16573. }
  16574. <?php
  16575. namespace Composer\Installer;
  16576. use Composer\Package\PackageInterface;
  16577. interface BinaryPresenceInterface
  16578. {
  16579. public function ensureBinariesPresence(PackageInterface $package);
  16580. }
  16581. <?php
  16582. namespace Composer\Installer;
  16583. use Composer\IO\IOInterface;
  16584. use Composer\IO\ConsoleIO;
  16585. use Composer\Package\PackageInterface;
  16586. use Composer\Package\AliasPackage;
  16587. use Composer\Repository\RepositoryInterface;
  16588. use Composer\Repository\InstalledRepositoryInterface;
  16589. use Composer\DependencyResolver\Operation\OperationInterface;
  16590. use Composer\DependencyResolver\Operation\InstallOperation;
  16591. use Composer\DependencyResolver\Operation\UpdateOperation;
  16592. use Composer\DependencyResolver\Operation\UninstallOperation;
  16593. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  16594. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  16595. use Composer\EventDispatcher\EventDispatcher;
  16596. use Composer\Util\Loop;
  16597. use Composer\Util\Platform;
  16598. use React\Promise\PromiseInterface;
  16599. class InstallationManager
  16600. {
  16601. private $installers = array();
  16602. private $cache = array();
  16603. private $notifiablePackages = array();
  16604. private $loop;
  16605. private $io;
  16606. private $eventDispatcher;
  16607. private $outputProgress;
  16608. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  16609. {
  16610. $this->loop = $loop;
  16611. $this->io = $io;
  16612. $this->eventDispatcher = $eventDispatcher;
  16613. }
  16614. public function reset()
  16615. {
  16616. $this->notifiablePackages = array();
  16617. }
  16618. public function addInstaller(InstallerInterface $installer)
  16619. {
  16620. array_unshift($this->installers, $installer);
  16621. $this->cache = array();
  16622. }
  16623. public function removeInstaller(InstallerInterface $installer)
  16624. {
  16625. if (false !== ($key = array_search($installer, $this->installers, true))) {
  16626. array_splice($this->installers, $key, 1);
  16627. $this->cache = array();
  16628. }
  16629. }
  16630. public function disablePlugins()
  16631. {
  16632. foreach ($this->installers as $i => $installer) {
  16633. if (!$installer instanceof PluginInstaller) {
  16634. continue;
  16635. }
  16636. unset($this->installers[$i]);
  16637. }
  16638. }
  16639. public function getInstaller($type)
  16640. {
  16641. $type = strtolower($type);
  16642. if (isset($this->cache[$type])) {
  16643. return $this->cache[$type];
  16644. }
  16645. foreach ($this->installers as $installer) {
  16646. if ($installer->supports($type)) {
  16647. return $this->cache[$type] = $installer;
  16648. }
  16649. }
  16650. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  16651. }
  16652. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16653. {
  16654. if ($package instanceof AliasPackage) {
  16655. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  16656. }
  16657. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  16658. }
  16659. public function ensureBinariesPresence(PackageInterface $package)
  16660. {
  16661. try {
  16662. $installer = $this->getInstaller($package->getType());
  16663. } catch (\InvalidArgumentException $e) {
  16664. return;
  16665. }
  16666. if ($installer instanceof BinaryPresenceInterface) {
  16667. $installer->ensureBinariesPresence($package);
  16668. }
  16669. }
  16670. public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
  16671. {
  16672. $cleanupPromises = array();
  16673. $loop = $this->loop;
  16674. $io = $this->io;
  16675. $runCleanup = function () use (&$cleanupPromises, $loop) {
  16676. $promises = array();
  16677. $loop->abortJobs();
  16678. foreach ($cleanupPromises as $cleanup) {
  16679. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup) {
  16680. $promise = $cleanup();
  16681. if (!$promise instanceof PromiseInterface) {
  16682. $resolve();
  16683. } else {
  16684. $promise->then(function () use ($resolve) {
  16685. $resolve();
  16686. });
  16687. }
  16688. });
  16689. }
  16690. if (!empty($promises)) {
  16691. $loop->wait($promises);
  16692. }
  16693. };
  16694. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  16695. $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli';
  16696. $prevHandler = null;
  16697. $windowsHandler = null;
  16698. if ($handleInterruptsUnix) {
  16699. pcntl_async_signals(true);
  16700. $prevHandler = pcntl_signal_get_handler(SIGINT);
  16701. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io) {
  16702. $io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);
  16703. $runCleanup();
  16704. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  16705. call_user_func($prevHandler, $sig);
  16706. }
  16707. exit(130);
  16708. });
  16709. }
  16710. if ($handleInterruptsWindows) {
  16711. $windowsHandler = function ($event) use ($runCleanup, $io) {
  16712. if ($event !== PHP_WINDOWS_EVENT_CTRL_C) {
  16713. return;
  16714. }
  16715. $io->writeError('Received CTRL+C, aborting', true, IOInterface::DEBUG);
  16716. $runCleanup();
  16717. exit(130);
  16718. };
  16719. sapi_windows_set_ctrl_handler($windowsHandler);
  16720. }
  16721. try {
  16722. $batches = array();
  16723. $batch = array();
  16724. foreach ($operations as $index => $operation) {
  16725. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16726. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16727. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  16728. if ($batch) {
  16729. $batches[] = $batch;
  16730. }
  16731. $batches[] = array($index => $operation);
  16732. $batch = array();
  16733. continue;
  16734. }
  16735. }
  16736. $batch[$index] = $operation;
  16737. }
  16738. if ($batch) {
  16739. $batches[] = $batch;
  16740. }
  16741. foreach ($batches as $batch) {
  16742. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  16743. }
  16744. } catch (\Exception $e) {
  16745. $runCleanup();
  16746. if ($handleInterruptsUnix) {
  16747. pcntl_signal(SIGINT, $prevHandler);
  16748. }
  16749. if ($handleInterruptsWindows) {
  16750. sapi_windows_set_ctrl_handler($prevHandler, false);
  16751. }
  16752. throw $e;
  16753. }
  16754. if ($handleInterruptsUnix) {
  16755. pcntl_signal(SIGINT, $prevHandler);
  16756. }
  16757. if ($handleInterruptsWindows) {
  16758. sapi_windows_set_ctrl_handler($prevHandler, false);
  16759. }
  16760. $repo->write($devMode, $this);
  16761. }
  16762. private function downloadAndExecuteBatch(RepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
  16763. {
  16764. $promises = array();
  16765. foreach ($operations as $index => $operation) {
  16766. $opType = $operation->getOperationType();
  16767. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16768. continue;
  16769. }
  16770. if ($opType === 'update') {
  16771. $package = $operation->getTargetPackage();
  16772. $initialPackage = $operation->getInitialPackage();
  16773. } else {
  16774. $package = $operation->getPackage();
  16775. $initialPackage = null;
  16776. }
  16777. $installer = $this->getInstaller($package->getType());
  16778. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  16779. if (!$package->getInstallationSource()) {
  16780. return;
  16781. }
  16782. return $installer->cleanup($opType, $package, $initialPackage);
  16783. };
  16784. if ($opType !== 'uninstall') {
  16785. $promise = $installer->download($package, $initialPackage);
  16786. if ($promise) {
  16787. $promises[] = $promise;
  16788. }
  16789. }
  16790. }
  16791. if (count($promises)) {
  16792. $this->waitOnPromises($promises);
  16793. }
  16794. $batches = array();
  16795. $batch = array();
  16796. foreach ($operations as $index => $operation) {
  16797. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16798. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16799. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  16800. if ($batch) {
  16801. $batches[] = $batch;
  16802. }
  16803. $batches[] = array($index => $operation);
  16804. $batch = array();
  16805. continue;
  16806. }
  16807. }
  16808. $batch[$index] = $operation;
  16809. }
  16810. if ($batch) {
  16811. $batches[] = $batch;
  16812. }
  16813. foreach ($batches as $batch) {
  16814. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  16815. }
  16816. }
  16817. private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
  16818. {
  16819. $promises = array();
  16820. $postExecCallbacks = array();
  16821. foreach ($operations as $index => $operation) {
  16822. $opType = $operation->getOperationType();
  16823. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16824. if ($this->io->isDebug()) {
  16825. $this->io->writeError(' - ' . $operation->show(false));
  16826. }
  16827. $this->$opType($repo, $operation);
  16828. continue;
  16829. }
  16830. if ($opType === 'update') {
  16831. $package = $operation->getTargetPackage();
  16832. $initialPackage = $operation->getInitialPackage();
  16833. } else {
  16834. $package = $operation->getPackage();
  16835. $initialPackage = null;
  16836. }
  16837. $installer = $this->getInstaller($package->getType());
  16838. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  16839. if (defined($event) && $runScripts && $this->eventDispatcher) {
  16840. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16841. }
  16842. $dispatcher = $this->eventDispatcher;
  16843. $installManager = $this;
  16844. $io = $this->io;
  16845. $promise = $installer->prepare($opType, $package, $initialPackage);
  16846. if (!$promise instanceof PromiseInterface) {
  16847. $promise = \React\Promise\resolve();
  16848. }
  16849. $promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
  16850. return $installManager->$opType($repo, $operation);
  16851. })->then($cleanupPromises[$index])
  16852. ->then(function () use ($installManager, $devMode, $repo) {
  16853. $repo->write($devMode, $installManager);
  16854. }, function ($e) use ($opType, $package, $io) {
  16855. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  16856. throw $e;
  16857. });
  16858. $postExecCallbacks[] = function () use ($opType, $runScripts, $dispatcher, $devMode, $repo, $allOperations, $operation) {
  16859. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  16860. if (defined($event) && $runScripts && $dispatcher) {
  16861. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16862. }
  16863. };
  16864. $promises[] = $promise;
  16865. }
  16866. if (count($promises)) {
  16867. $this->waitOnPromises($promises);
  16868. }
  16869. Platform::workaroundFilesystemIssues();
  16870. foreach ($postExecCallbacks as $cb) {
  16871. $cb();
  16872. }
  16873. }
  16874. private function waitOnPromises(array $promises)
  16875. {
  16876. $progress = null;
  16877. if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
  16878. $progress = $this->io->getProgressBar();
  16879. }
  16880. $this->loop->wait($promises, $progress);
  16881. if ($progress) {
  16882. $progress->clear();
  16883. }
  16884. }
  16885. public function install(RepositoryInterface $repo, InstallOperation $operation)
  16886. {
  16887. $package = $operation->getPackage();
  16888. $installer = $this->getInstaller($package->getType());
  16889. $promise = $installer->install($repo, $package);
  16890. $this->markForNotification($package);
  16891. return $promise;
  16892. }
  16893. public function update(RepositoryInterface $repo, UpdateOperation $operation)
  16894. {
  16895. $initial = $operation->getInitialPackage();
  16896. $target = $operation->getTargetPackage();
  16897. $initialType = $initial->getType();
  16898. $targetType = $target->getType();
  16899. if ($initialType === $targetType) {
  16900. $installer = $this->getInstaller($initialType);
  16901. $promise = $installer->update($repo, $initial, $target);
  16902. $this->markForNotification($target);
  16903. } else {
  16904. $promise = $this->getInstaller($initialType)->uninstall($repo, $initial);
  16905. if (!$promise instanceof PromiseInterface) {
  16906. $promise = \React\Promise\resolve();
  16907. }
  16908. $installer = $this->getInstaller($targetType);
  16909. $promise->then(function () use ($installer, $repo, $target) {
  16910. return $installer->install($repo, $target);
  16911. });
  16912. }
  16913. return $promise;
  16914. }
  16915. public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
  16916. {
  16917. $package = $operation->getPackage();
  16918. $installer = $this->getInstaller($package->getType());
  16919. return $installer->uninstall($repo, $package);
  16920. }
  16921. public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  16922. {
  16923. $package = $operation->getPackage();
  16924. if (!$repo->hasPackage($package)) {
  16925. $repo->addPackage(clone $package);
  16926. }
  16927. }
  16928. public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  16929. {
  16930. $package = $operation->getPackage();
  16931. $repo->removePackage($package);
  16932. }
  16933. public function getInstallPath(PackageInterface $package)
  16934. {
  16935. $installer = $this->getInstaller($package->getType());
  16936. return $installer->getInstallPath($package);
  16937. }
  16938. public function setOutputProgress($outputProgress)
  16939. {
  16940. $this->outputProgress = $outputProgress;
  16941. }
  16942. public function notifyInstalls(IOInterface $io)
  16943. {
  16944. $promises = array();
  16945. try {
  16946. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  16947. if (strpos($repoUrl, '%package%')) {
  16948. foreach ($packages as $package) {
  16949. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  16950. $params = array(
  16951. 'version' => $package->getPrettyVersion(),
  16952. 'version_normalized' => $package->getVersion(),
  16953. );
  16954. $opts = array(
  16955. 'retry-auth-failure' => false,
  16956. 'http' => array(
  16957. 'method' => 'POST',
  16958. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  16959. 'content' => http_build_query($params, '', '&'),
  16960. 'timeout' => 3,
  16961. ),
  16962. );
  16963. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  16964. }
  16965. continue;
  16966. }
  16967. $postData = array('downloads' => array());
  16968. foreach ($packages as $package) {
  16969. $postData['downloads'][] = array(
  16970. 'name' => $package->getPrettyName(),
  16971. 'version' => $package->getVersion(),
  16972. );
  16973. }
  16974. $opts = array(
  16975. 'retry-auth-failure' => false,
  16976. 'http' => array(
  16977. 'method' => 'POST',
  16978. 'header' => array('Content-Type: application/json'),
  16979. 'content' => json_encode($postData),
  16980. 'timeout' => 6,
  16981. ),
  16982. );
  16983. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  16984. }
  16985. $this->loop->wait($promises);
  16986. } catch (\Exception $e) {
  16987. }
  16988. $this->reset();
  16989. }
  16990. private function markForNotification(PackageInterface $package)
  16991. {
  16992. if ($package->getNotificationUrl()) {
  16993. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  16994. }
  16995. }
  16996. }
  16997. <?php
  16998. namespace Composer\Installer;
  16999. use Composer\Composer;
  17000. use Composer\DependencyResolver\Transaction;
  17001. use Composer\EventDispatcher\Event;
  17002. use Composer\IO\IOInterface;
  17003. class InstallerEvent extends Event
  17004. {
  17005. private $composer;
  17006. private $io;
  17007. private $devMode;
  17008. private $executeOperations;
  17009. private $transaction;
  17010. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
  17011. {
  17012. parent::__construct($eventName);
  17013. $this->composer = $composer;
  17014. $this->io = $io;
  17015. $this->devMode = $devMode;
  17016. $this->executeOperations = $executeOperations;
  17017. $this->transaction = $transaction;
  17018. }
  17019. public function getComposer()
  17020. {
  17021. return $this->composer;
  17022. }
  17023. public function getIO()
  17024. {
  17025. return $this->io;
  17026. }
  17027. public function isDevMode()
  17028. {
  17029. return $this->devMode;
  17030. }
  17031. public function isExecutingOperations()
  17032. {
  17033. return $this->executeOperations;
  17034. }
  17035. public function getTransaction()
  17036. {
  17037. return $this->transaction;
  17038. }
  17039. }
  17040. <?php
  17041. namespace Composer\Installer;
  17042. class InstallerEvents
  17043. {
  17044. const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  17045. }
  17046. <?php
  17047. namespace Composer\Installer;
  17048. use Composer\Package\PackageInterface;
  17049. use Composer\Repository\InstalledRepositoryInterface;
  17050. use InvalidArgumentException;
  17051. use React\Promise\PromiseInterface;
  17052. interface InstallerInterface
  17053. {
  17054. public function supports($packageType);
  17055. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  17056. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  17057. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
  17058. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  17059. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  17060. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  17061. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
  17062. public function getInstallPath(PackageInterface $package);
  17063. }
  17064. <?php
  17065. namespace Composer\Installer;
  17066. use Composer\Composer;
  17067. use Composer\IO\IOInterface;
  17068. use Composer\Repository\InstalledRepositoryInterface;
  17069. use Composer\Package\PackageInterface;
  17070. use Composer\Util\Filesystem;
  17071. use Composer\Util\Silencer;
  17072. use Composer\Util\Platform;
  17073. use React\Promise\PromiseInterface;
  17074. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  17075. {
  17076. protected $composer;
  17077. protected $vendorDir;
  17078. protected $binDir;
  17079. protected $downloadManager;
  17080. protected $io;
  17081. protected $type;
  17082. protected $filesystem;
  17083. protected $binCompat;
  17084. protected $binaryInstaller;
  17085. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  17086. {
  17087. $this->composer = $composer;
  17088. $this->downloadManager = $composer->getDownloadManager();
  17089. $this->io = $io;
  17090. $this->type = $type;
  17091. $this->filesystem = $filesystem ?: new Filesystem();
  17092. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  17093. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
  17094. }
  17095. public function supports($packageType)
  17096. {
  17097. return $packageType === $this->type || null === $this->type;
  17098. }
  17099. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17100. {
  17101. if (!$repo->hasPackage($package)) {
  17102. return false;
  17103. }
  17104. $installPath = $this->getInstallPath($package);
  17105. if (is_readable($installPath)) {
  17106. return true;
  17107. }
  17108. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  17109. }
  17110. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17111. {
  17112. $this->initializeVendorDir();
  17113. $downloadPath = $this->getInstallPath($package);
  17114. return $this->downloadManager->download($package, $downloadPath, $prevPackage);
  17115. }
  17116. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17117. {
  17118. $this->initializeVendorDir();
  17119. $downloadPath = $this->getInstallPath($package);
  17120. return $this->downloadManager->prepare($type, $package, $downloadPath, $prevPackage);
  17121. }
  17122. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17123. {
  17124. $this->initializeVendorDir();
  17125. $downloadPath = $this->getInstallPath($package);
  17126. return $this->downloadManager->cleanup($type, $package, $downloadPath, $prevPackage);
  17127. }
  17128. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17129. {
  17130. $this->initializeVendorDir();
  17131. $downloadPath = $this->getInstallPath($package);
  17132. if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
  17133. $this->binaryInstaller->removeBinaries($package);
  17134. }
  17135. $promise = $this->installCode($package);
  17136. if (!$promise instanceof PromiseInterface) {
  17137. $promise = \React\Promise\resolve();
  17138. }
  17139. $binaryInstaller = $this->binaryInstaller;
  17140. $installPath = $this->getInstallPath($package);
  17141. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
  17142. $binaryInstaller->installBinaries($package, $installPath);
  17143. if (!$repo->hasPackage($package)) {
  17144. $repo->addPackage(clone $package);
  17145. }
  17146. });
  17147. }
  17148. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17149. {
  17150. if (!$repo->hasPackage($initial)) {
  17151. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17152. }
  17153. $this->initializeVendorDir();
  17154. $this->binaryInstaller->removeBinaries($initial);
  17155. $promise = $this->updateCode($initial, $target);
  17156. if (!$promise instanceof PromiseInterface) {
  17157. $promise = \React\Promise\resolve();
  17158. }
  17159. $binaryInstaller = $this->binaryInstaller;
  17160. $installPath = $this->getInstallPath($target);
  17161. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
  17162. $binaryInstaller->installBinaries($target, $installPath);
  17163. $repo->removePackage($initial);
  17164. if (!$repo->hasPackage($target)) {
  17165. $repo->addPackage(clone $target);
  17166. }
  17167. });
  17168. }
  17169. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17170. {
  17171. if (!$repo->hasPackage($package)) {
  17172. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17173. }
  17174. $promise = $this->removeCode($package);
  17175. if (!$promise instanceof PromiseInterface) {
  17176. $promise = \React\Promise\resolve();
  17177. }
  17178. $binaryInstaller = $this->binaryInstaller;
  17179. $downloadPath = $this->getPackageBasePath($package);
  17180. $filesystem = $this->filesystem;
  17181. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
  17182. $binaryInstaller->removeBinaries($package);
  17183. $repo->removePackage($package);
  17184. if (strpos($package->getName(), '/')) {
  17185. $packageVendorDir = dirname($downloadPath);
  17186. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  17187. Silencer::call('rmdir', $packageVendorDir);
  17188. }
  17189. }
  17190. });
  17191. }
  17192. public function getInstallPath(PackageInterface $package)
  17193. {
  17194. $this->initializeVendorDir();
  17195. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  17196. $targetDir = $package->getTargetDir();
  17197. return $basePath . ($targetDir ? '/'.$targetDir : '');
  17198. }
  17199. public function ensureBinariesPresence(PackageInterface $package)
  17200. {
  17201. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  17202. }
  17203. protected function getPackageBasePath(PackageInterface $package)
  17204. {
  17205. $installPath = $this->getInstallPath($package);
  17206. $targetDir = $package->getTargetDir();
  17207. if ($targetDir) {
  17208. return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  17209. }
  17210. return $installPath;
  17211. }
  17212. protected function installCode(PackageInterface $package)
  17213. {
  17214. $downloadPath = $this->getInstallPath($package);
  17215. return $this->downloadManager->install($package, $downloadPath);
  17216. }
  17217. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  17218. {
  17219. $initialDownloadPath = $this->getInstallPath($initial);
  17220. $targetDownloadPath = $this->getInstallPath($target);
  17221. if ($targetDownloadPath !== $initialDownloadPath) {
  17222. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  17223. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  17224. ) {
  17225. $promise = $this->removeCode($initial);
  17226. if (!$promise instanceof PromiseInterface) {
  17227. $promise = \React\Promise\resolve();
  17228. }
  17229. $self = $this;
  17230. return $promise->then(function () use ($self, $target) {
  17231. $reflMethod = new \ReflectionMethod($self, 'installCode');
  17232. $reflMethod->setAccessible(true);
  17233. return $reflMethod->invoke($self, $target);
  17234. });
  17235. }
  17236. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  17237. }
  17238. return $this->downloadManager->update($initial, $target, $targetDownloadPath);
  17239. }
  17240. protected function removeCode(PackageInterface $package)
  17241. {
  17242. $downloadPath = $this->getPackageBasePath($package);
  17243. return $this->downloadManager->remove($package, $downloadPath);
  17244. }
  17245. protected function initializeVendorDir()
  17246. {
  17247. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  17248. $this->vendorDir = realpath($this->vendorDir);
  17249. }
  17250. }
  17251. <?php
  17252. namespace Composer\Installer;
  17253. use Composer\Repository\InstalledRepositoryInterface;
  17254. use Composer\Package\PackageInterface;
  17255. use Composer\IO\IOInterface;
  17256. use Composer\DependencyResolver\Operation\UpdateOperation;
  17257. use Composer\DependencyResolver\Operation\InstallOperation;
  17258. use Composer\DependencyResolver\Operation\UninstallOperation;
  17259. class MetapackageInstaller implements InstallerInterface
  17260. {
  17261. private $io;
  17262. public function __construct(IOInterface $io)
  17263. {
  17264. $this->io = $io;
  17265. }
  17266. public function supports($packageType)
  17267. {
  17268. return $packageType === 'metapackage';
  17269. }
  17270. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17271. {
  17272. return $repo->hasPackage($package);
  17273. }
  17274. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17275. {
  17276. }
  17277. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17278. {
  17279. }
  17280. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17281. {
  17282. }
  17283. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17284. {
  17285. $this->io->writeError(" - " . InstallOperation::format($package));
  17286. $repo->addPackage(clone $package);
  17287. }
  17288. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17289. {
  17290. if (!$repo->hasPackage($initial)) {
  17291. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17292. }
  17293. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  17294. $repo->removePackage($initial);
  17295. $repo->addPackage(clone $target);
  17296. }
  17297. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17298. {
  17299. if (!$repo->hasPackage($package)) {
  17300. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17301. }
  17302. $this->io->writeError(" - " . UninstallOperation::format($package));
  17303. $repo->removePackage($package);
  17304. }
  17305. public function getInstallPath(PackageInterface $package)
  17306. {
  17307. return '';
  17308. }
  17309. }
  17310. <?php
  17311. namespace Composer\Installer;
  17312. use Composer\Repository\InstalledRepositoryInterface;
  17313. use Composer\Package\PackageInterface;
  17314. class NoopInstaller implements InstallerInterface
  17315. {
  17316. public function supports($packageType)
  17317. {
  17318. return true;
  17319. }
  17320. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17321. {
  17322. return $repo->hasPackage($package);
  17323. }
  17324. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17325. {
  17326. }
  17327. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17328. {
  17329. }
  17330. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17331. {
  17332. }
  17333. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17334. {
  17335. if (!$repo->hasPackage($package)) {
  17336. $repo->addPackage(clone $package);
  17337. }
  17338. }
  17339. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17340. {
  17341. if (!$repo->hasPackage($initial)) {
  17342. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17343. }
  17344. $repo->removePackage($initial);
  17345. if (!$repo->hasPackage($target)) {
  17346. $repo->addPackage(clone $target);
  17347. }
  17348. }
  17349. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17350. {
  17351. if (!$repo->hasPackage($package)) {
  17352. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17353. }
  17354. $repo->removePackage($package);
  17355. }
  17356. public function getInstallPath(PackageInterface $package)
  17357. {
  17358. $targetDir = $package->getTargetDir();
  17359. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  17360. }
  17361. }
  17362. <?php
  17363. namespace Composer\Installer;
  17364. use Composer\Composer;
  17365. use Composer\IO\IOInterface;
  17366. use Composer\DependencyResolver\Operation\OperationInterface;
  17367. use Composer\Repository\RepositoryInterface;
  17368. use Composer\EventDispatcher\Event;
  17369. class PackageEvent extends Event
  17370. {
  17371. private $composer;
  17372. private $io;
  17373. private $devMode;
  17374. private $localRepo;
  17375. private $operations;
  17376. private $operation;
  17377. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  17378. {
  17379. parent::__construct($eventName);
  17380. $this->composer = $composer;
  17381. $this->io = $io;
  17382. $this->devMode = $devMode;
  17383. $this->localRepo = $localRepo;
  17384. $this->operations = $operations;
  17385. $this->operation = $operation;
  17386. }
  17387. public function getComposer()
  17388. {
  17389. return $this->composer;
  17390. }
  17391. public function getIO()
  17392. {
  17393. return $this->io;
  17394. }
  17395. public function isDevMode()
  17396. {
  17397. return $this->devMode;
  17398. }
  17399. public function getLocalRepo()
  17400. {
  17401. return $this->localRepo;
  17402. }
  17403. public function getOperations()
  17404. {
  17405. return $this->operations;
  17406. }
  17407. public function getOperation()
  17408. {
  17409. return $this->operation;
  17410. }
  17411. }
  17412. <?php
  17413. namespace Composer\Installer;
  17414. class PackageEvents
  17415. {
  17416. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  17417. const POST_PACKAGE_INSTALL = 'post-package-install';
  17418. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  17419. const POST_PACKAGE_UPDATE = 'post-package-update';
  17420. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  17421. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  17422. }
  17423. <?php
  17424. namespace Composer\Installer;
  17425. use Composer\Composer;
  17426. use Composer\IO\IOInterface;
  17427. use Composer\Repository\InstalledRepositoryInterface;
  17428. use Composer\Package\PackageInterface;
  17429. use Composer\Util\Filesystem;
  17430. use Composer\Installer\InstallationManager;
  17431. use Composer\Util\Platform;
  17432. use React\Promise\PromiseInterface;
  17433. class PluginInstaller extends LibraryInstaller
  17434. {
  17435. public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  17436. {
  17437. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  17438. }
  17439. public function supports($packageType)
  17440. {
  17441. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  17442. }
  17443. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17444. {
  17445. $extra = $package->getExtra();
  17446. if (empty($extra['class'])) {
  17447. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  17448. }
  17449. return parent::download($package, $prevPackage);
  17450. }
  17451. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17452. {
  17453. $promise = parent::install($repo, $package);
  17454. if (!$promise instanceof PromiseInterface) {
  17455. $promise = \React\Promise\resolve();
  17456. }
  17457. $pluginManager = $this->composer->getPluginManager();
  17458. $self = $this;
  17459. return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
  17460. try {
  17461. Platform::workaroundFilesystemIssues();
  17462. $pluginManager->registerPackage($package, true);
  17463. } catch (\Exception $e) {
  17464. $self->rollbackInstall($e, $repo, $package);
  17465. }
  17466. });
  17467. }
  17468. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17469. {
  17470. $promise = parent::update($repo, $initial, $target);
  17471. if (!$promise instanceof PromiseInterface) {
  17472. $promise = \React\Promise\resolve();
  17473. }
  17474. $pluginManager = $this->composer->getPluginManager();
  17475. $self = $this;
  17476. return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
  17477. try {
  17478. Platform::workaroundFilesystemIssues();
  17479. $pluginManager->deactivatePackage($initial, true);
  17480. $pluginManager->registerPackage($target, true);
  17481. } catch (\Exception $e) {
  17482. $self->rollbackInstall($e, $repo, $target);
  17483. }
  17484. });
  17485. }
  17486. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17487. {
  17488. $this->composer->getPluginManager()->uninstallPackage($package, true);
  17489. return parent::uninstall($repo, $package);
  17490. }
  17491. public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
  17492. {
  17493. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  17494. parent::uninstall($repo, $package);
  17495. throw $e;
  17496. }
  17497. }
  17498. <?php
  17499. namespace Composer\Installer;
  17500. use Composer\Package\PackageInterface;
  17501. use Composer\Downloader\DownloadManager;
  17502. use Composer\Repository\InstalledRepositoryInterface;
  17503. use Composer\Util\Filesystem;
  17504. class ProjectInstaller implements InstallerInterface
  17505. {
  17506. private $installPath;
  17507. private $downloadManager;
  17508. private $filesystem;
  17509. public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
  17510. {
  17511. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  17512. $this->downloadManager = $dm;
  17513. $this->filesystem = $fs;
  17514. }
  17515. public function supports($packageType)
  17516. {
  17517. return true;
  17518. }
  17519. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17520. {
  17521. return false;
  17522. }
  17523. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17524. {
  17525. $installPath = $this->installPath;
  17526. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  17527. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  17528. }
  17529. if (!is_dir($installPath)) {
  17530. mkdir($installPath, 0777, true);
  17531. }
  17532. return $this->downloadManager->download($package, $installPath, $prevPackage);
  17533. }
  17534. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17535. {
  17536. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  17537. }
  17538. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17539. {
  17540. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  17541. }
  17542. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17543. {
  17544. return $this->downloadManager->install($package, $this->installPath);
  17545. }
  17546. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17547. {
  17548. throw new \InvalidArgumentException("not supported");
  17549. }
  17550. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17551. {
  17552. throw new \InvalidArgumentException("not supported");
  17553. }
  17554. public function getInstallPath(PackageInterface $package)
  17555. {
  17556. return $this->installPath;
  17557. }
  17558. }
  17559. <?php
  17560. namespace Composer\Installer;
  17561. use Composer\IO\IOInterface;
  17562. use Composer\Package\PackageInterface;
  17563. use Composer\Repository\InstalledRepository;
  17564. use Symfony\Component\Console\Formatter\OutputFormatter;
  17565. class SuggestedPackagesReporter
  17566. {
  17567. const MODE_LIST = 1;
  17568. const MODE_BY_PACKAGE = 2;
  17569. const MODE_BY_SUGGESTION = 4;
  17570. protected $suggestedPackages = array();
  17571. private $io;
  17572. public function __construct(IOInterface $io)
  17573. {
  17574. $this->io = $io;
  17575. }
  17576. public function getPackages()
  17577. {
  17578. return $this->suggestedPackages;
  17579. }
  17580. public function addPackage($source, $target, $reason)
  17581. {
  17582. $this->suggestedPackages[] = array(
  17583. 'source' => $source,
  17584. 'target' => $target,
  17585. 'reason' => $reason,
  17586. );
  17587. return $this;
  17588. }
  17589. public function addSuggestionsFromPackage(PackageInterface $package)
  17590. {
  17591. $source = $package->getPrettyName();
  17592. foreach ($package->getSuggests() as $target => $reason) {
  17593. $this->addPackage(
  17594. $source,
  17595. $target,
  17596. $reason
  17597. );
  17598. }
  17599. return $this;
  17600. }
  17601. public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17602. {
  17603. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17604. $suggesters = array();
  17605. $suggested = array();
  17606. foreach ($suggestedPackages as $suggestion) {
  17607. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  17608. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  17609. }
  17610. ksort($suggesters);
  17611. ksort($suggested);
  17612. if ($mode & self::MODE_LIST) {
  17613. foreach (array_keys($suggested) as $name) {
  17614. $this->io->write(sprintf('<info>%s</info>', $name));
  17615. }
  17616. return 0;
  17617. }
  17618. if ($mode & self::MODE_BY_PACKAGE) {
  17619. foreach ($suggesters as $suggester => $suggestions) {
  17620. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  17621. foreach ($suggestions as $suggestion => $reason) {
  17622. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  17623. }
  17624. $this->io->write('');
  17625. }
  17626. }
  17627. if ($mode & self::MODE_BY_SUGGESTION) {
  17628. if ($mode & self::MODE_BY_PACKAGE) {
  17629. $this->io->write(str_repeat('-', 78));
  17630. }
  17631. foreach ($suggested as $suggestion => $suggesters) {
  17632. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  17633. foreach ($suggesters as $suggester => $reason) {
  17634. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  17635. }
  17636. $this->io->write('');
  17637. }
  17638. }
  17639. if ($onlyDependentsOf) {
  17640. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  17641. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  17642. if ($diff) {
  17643. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  17644. }
  17645. }
  17646. return $this;
  17647. }
  17648. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17649. {
  17650. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17651. if ($suggestedPackages) {
  17652. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  17653. }
  17654. return $this;
  17655. }
  17656. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17657. {
  17658. $suggestedPackages = $this->getPackages();
  17659. $installedNames = array();
  17660. if (null !== $installedRepo && !empty($suggestedPackages)) {
  17661. foreach ($installedRepo->getPackages() as $package) {
  17662. $installedNames = array_merge(
  17663. $installedNames,
  17664. $package->getNames()
  17665. );
  17666. }
  17667. }
  17668. $sourceFilter = array();
  17669. if ($onlyDependentsOf) {
  17670. $sourceFilter = array_map(function ($link) {
  17671. return $link->getTarget();
  17672. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  17673. $sourceFilter[] = $onlyDependentsOf->getName();
  17674. }
  17675. $suggestions = array();
  17676. foreach ($suggestedPackages as $suggestion) {
  17677. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  17678. continue;
  17679. }
  17680. $suggestions[] = $suggestion;
  17681. }
  17682. return $suggestions;
  17683. }
  17684. private function escapeOutput($string)
  17685. {
  17686. return OutputFormatter::escape(
  17687. $this->removeControlCharacters($string)
  17688. );
  17689. }
  17690. private function removeControlCharacters($string)
  17691. {
  17692. return preg_replace(
  17693. '/[[:cntrl:]]/',
  17694. '',
  17695. str_replace("\n", ' ', $string)
  17696. );
  17697. }
  17698. }
  17699. <?php
  17700. namespace Composer\Json;
  17701. use JsonSchema\Validator;
  17702. use Seld\JsonLint\JsonParser;
  17703. use Seld\JsonLint\ParsingException;
  17704. use Composer\Util\HttpDownloader;
  17705. use Composer\IO\IOInterface;
  17706. use Composer\Downloader\TransportException;
  17707. class JsonFile
  17708. {
  17709. const LAX_SCHEMA = 1;
  17710. const STRICT_SCHEMA = 2;
  17711. const JSON_UNESCAPED_SLASHES = 64;
  17712. const JSON_PRETTY_PRINT = 128;
  17713. const JSON_UNESCAPED_UNICODE = 256;
  17714. const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
  17715. private $path;
  17716. private $httpDownloader;
  17717. private $io;
  17718. public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  17719. {
  17720. $this->path = $path;
  17721. if (null === $httpDownloader && preg_match('{^https?://}i', $path)) {
  17722. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  17723. }
  17724. $this->httpDownloader = $httpDownloader;
  17725. $this->io = $io;
  17726. }
  17727. public function getPath()
  17728. {
  17729. return $this->path;
  17730. }
  17731. public function exists()
  17732. {
  17733. return is_file($this->path);
  17734. }
  17735. public function read()
  17736. {
  17737. try {
  17738. if ($this->httpDownloader) {
  17739. $json = $this->httpDownloader->get($this->path)->getBody();
  17740. } else {
  17741. if ($this->io && $this->io->isDebug()) {
  17742. $realpathInfo = '';
  17743. $realpath = realpath($this->path);
  17744. if (false !== $realpath && $realpath !== $this->path) {
  17745. $realpathInfo = ' (' . $realpath . ')';
  17746. }
  17747. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  17748. }
  17749. $json = file_get_contents($this->path);
  17750. }
  17751. } catch (TransportException $e) {
  17752. throw new \RuntimeException($e->getMessage(), 0, $e);
  17753. } catch (\Exception $e) {
  17754. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  17755. }
  17756. return static::parseJson($json, $this->path);
  17757. }
  17758. public function write(array $hash, $options = 448)
  17759. {
  17760. if ($this->path === 'php://memory') {
  17761. file_put_contents($this->path, static::encode($hash, $options));
  17762. return;
  17763. }
  17764. $dir = dirname($this->path);
  17765. if (!is_dir($dir)) {
  17766. if (file_exists($dir)) {
  17767. throw new \UnexpectedValueException(
  17768. realpath($dir).' exists and is not a directory.'
  17769. );
  17770. }
  17771. if (!@mkdir($dir, 0777, true)) {
  17772. throw new \UnexpectedValueException(
  17773. $dir.' does not exist and could not be created.'
  17774. );
  17775. }
  17776. }
  17777. $retries = 3;
  17778. while ($retries--) {
  17779. try {
  17780. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  17781. break;
  17782. } catch (\Exception $e) {
  17783. if ($retries) {
  17784. usleep(500000);
  17785. continue;
  17786. }
  17787. throw $e;
  17788. }
  17789. }
  17790. }
  17791. private function filePutContentsIfModified($path, $content)
  17792. {
  17793. $currentContent = @file_get_contents($path);
  17794. if (!$currentContent || ($currentContent != $content)) {
  17795. return file_put_contents($path, $content);
  17796. }
  17797. return 0;
  17798. }
  17799. public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
  17800. {
  17801. $content = file_get_contents($this->path);
  17802. $data = json_decode($content);
  17803. if (null === $data && 'null' !== $content) {
  17804. self::validateSyntax($content, $this->path);
  17805. }
  17806. if (null === $schemaFile) {
  17807. $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
  17808. }
  17809. if (false === strpos($schemaFile, '://')) {
  17810. $schemaFile = 'file://' . $schemaFile;
  17811. }
  17812. $schemaData = (object) array('$ref' => $schemaFile);
  17813. if ($schema === self::LAX_SCHEMA) {
  17814. $schemaData->additionalProperties = true;
  17815. $schemaData->required = array();
  17816. }
  17817. $validator = new Validator();
  17818. $validator->check($data, $schemaData);
  17819. if (!$validator->isValid()) {
  17820. $errors = array();
  17821. foreach ((array) $validator->getErrors() as $error) {
  17822. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  17823. }
  17824. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  17825. }
  17826. return true;
  17827. }
  17828. public static function encode($data, $options = 448)
  17829. {
  17830. if (PHP_VERSION_ID >= 50400) {
  17831. $json = json_encode($data, $options);
  17832. if (false === $json) {
  17833. self::throwEncodeError(json_last_error());
  17834. }
  17835. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  17836. $json = preg_replace('/\[\s+\]/', '[]', $json);
  17837. $json = preg_replace('/\{\s+\}/', '{}', $json);
  17838. }
  17839. return $json;
  17840. }
  17841. $json = json_encode($data);
  17842. if (false === $json) {
  17843. self::throwEncodeError(json_last_error());
  17844. }
  17845. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  17846. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  17847. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  17848. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  17849. return $json;
  17850. }
  17851. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  17852. }
  17853. private static function throwEncodeError($code)
  17854. {
  17855. switch ($code) {
  17856. case JSON_ERROR_DEPTH:
  17857. $msg = 'Maximum stack depth exceeded';
  17858. break;
  17859. case JSON_ERROR_STATE_MISMATCH:
  17860. $msg = 'Underflow or the modes mismatch';
  17861. break;
  17862. case JSON_ERROR_CTRL_CHAR:
  17863. $msg = 'Unexpected control character found';
  17864. break;
  17865. case JSON_ERROR_UTF8:
  17866. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  17867. break;
  17868. default:
  17869. $msg = 'Unknown error';
  17870. }
  17871. throw new \RuntimeException('JSON encoding failed: '.$msg);
  17872. }
  17873. public static function parseJson($json, $file = null)
  17874. {
  17875. if (null === $json) {
  17876. return;
  17877. }
  17878. $data = json_decode($json, true);
  17879. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  17880. self::validateSyntax($json, $file);
  17881. }
  17882. return $data;
  17883. }
  17884. protected static function validateSyntax($json, $file = null)
  17885. {
  17886. $parser = new JsonParser();
  17887. $result = $parser->lint($json);
  17888. if (null === $result) {
  17889. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  17890. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  17891. }
  17892. return true;
  17893. }
  17894. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  17895. }
  17896. }
  17897. <?php
  17898. namespace Composer\Json;
  17899. class JsonFormatter
  17900. {
  17901. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  17902. {
  17903. $result = '';
  17904. $pos = 0;
  17905. $strLen = strlen($json);
  17906. $indentStr = ' ';
  17907. $newLine = "\n";
  17908. $outOfQuotes = true;
  17909. $buffer = '';
  17910. $noescape = true;
  17911. for ($i = 0; $i < $strLen; $i++) {
  17912. $char = substr($json, $i, 1);
  17913. if ('"' === $char && $noescape) {
  17914. $outOfQuotes = !$outOfQuotes;
  17915. }
  17916. if (!$outOfQuotes) {
  17917. $buffer .= $char;
  17918. $noescape = '\\' === $char ? !$noescape : true;
  17919. continue;
  17920. }
  17921. if ('' !== $buffer) {
  17922. if ($unescapeSlashes) {
  17923. $buffer = str_replace('\\/', '/', $buffer);
  17924. }
  17925. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  17926. $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  17927. $l = strlen($match[1]);
  17928. if ($l % 2) {
  17929. $code = hexdec($match[2]);
  17930. if (0xD800 <= $code && 0xDFFF >= $code) {
  17931. return $match[0];
  17932. }
  17933. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  17934. pack('H*', $match[2]),
  17935. 'UTF-8',
  17936. 'UCS-2BE'
  17937. );
  17938. }
  17939. return $match[0];
  17940. }, $buffer);
  17941. }
  17942. $result .= $buffer.$char;
  17943. $buffer = '';
  17944. continue;
  17945. }
  17946. if (':' === $char) {
  17947. $char .= ' ';
  17948. } elseif ('}' === $char || ']' === $char) {
  17949. $pos--;
  17950. $prevChar = substr($json, $i - 1, 1);
  17951. if ('{' !== $prevChar && '[' !== $prevChar) {
  17952. $result .= $newLine;
  17953. for ($j = 0; $j < $pos; $j++) {
  17954. $result .= $indentStr;
  17955. }
  17956. } else {
  17957. $result = rtrim($result);
  17958. }
  17959. }
  17960. $result .= $char;
  17961. if (',' === $char || '{' === $char || '[' === $char) {
  17962. $result .= $newLine;
  17963. if ('{' === $char || '[' === $char) {
  17964. $pos++;
  17965. }
  17966. for ($j = 0; $j < $pos; $j++) {
  17967. $result .= $indentStr;
  17968. }
  17969. }
  17970. }
  17971. return $result;
  17972. }
  17973. }
  17974. <?php
  17975. namespace Composer\Json;
  17976. use Composer\Repository\PlatformRepository;
  17977. class JsonManipulator
  17978. {
  17979. private static $DEFINES = '(?(DEFINE)
  17980. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? )
  17981. (?<boolean> true | false | null )
  17982. (?<string> " ([^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  17983. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  17984. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  17985. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  17986. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  17987. )';
  17988. private $contents;
  17989. private $newline;
  17990. private $indent;
  17991. public function __construct($contents)
  17992. {
  17993. $contents = trim($contents);
  17994. if ($contents === '') {
  17995. $contents = '{}';
  17996. }
  17997. if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
  17998. throw new \InvalidArgumentException('The json file must be an object ({})');
  17999. }
  18000. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  18001. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  18002. $this->detectIndenting();
  18003. }
  18004. public function getContents()
  18005. {
  18006. return $this->contents . $this->newline;
  18007. }
  18008. public function addLink($type, $package, $constraint, $sortPackages = false)
  18009. {
  18010. $decoded = JsonFile::parseJson($this->contents);
  18011. if (!isset($decoded[$type])) {
  18012. return $this->addMainKey($type, array($package => $constraint));
  18013. }
  18014. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18015. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  18016. if (!$this->pregMatch($regex, $this->contents, $matches)) {
  18017. return false;
  18018. }
  18019. $links = $matches['value'];
  18020. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  18021. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  18022. if ($this->pregMatch($regex, $links, $packageMatches)) {
  18023. $existingPackage = $packageMatches['package'];
  18024. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  18025. $links = preg_replace_callback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  18026. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  18027. }, $links);
  18028. } else {
  18029. if ($this->pregMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  18030. $links = preg_replace(
  18031. '{'.preg_quote($match[1]).'$}',
  18032. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  18033. $links
  18034. );
  18035. } else {
  18036. $links = '{' . $this->newline .
  18037. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  18038. $this->indent . '}';
  18039. }
  18040. }
  18041. if (true === $sortPackages) {
  18042. $requirements = json_decode($links, true);
  18043. $this->sortPackages($requirements);
  18044. $links = $this->format($requirements);
  18045. }
  18046. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  18047. return true;
  18048. }
  18049. private function sortPackages(array &$packages = array())
  18050. {
  18051. $prefix = function ($requirement) {
  18052. if (PlatformRepository::isPlatformPackage($requirement)) {
  18053. return preg_replace(
  18054. array(
  18055. '/^php/',
  18056. '/^hhvm/',
  18057. '/^ext/',
  18058. '/^lib/',
  18059. '/^\D/',
  18060. ),
  18061. array(
  18062. '0-$0',
  18063. '1-$0',
  18064. '2-$0',
  18065. '3-$0',
  18066. '4-$0',
  18067. ),
  18068. $requirement
  18069. );
  18070. }
  18071. return '5-'.$requirement;
  18072. };
  18073. uksort($packages, function ($a, $b) use ($prefix) {
  18074. return strnatcmp($prefix($a), $prefix($b));
  18075. });
  18076. }
  18077. public function addRepository($name, $config, $append = true)
  18078. {
  18079. return $this->addSubNode('repositories', $name, $config, $append);
  18080. }
  18081. public function removeRepository($name)
  18082. {
  18083. return $this->removeSubNode('repositories', $name);
  18084. }
  18085. public function addConfigSetting($name, $value)
  18086. {
  18087. return $this->addSubNode('config', $name, $value);
  18088. }
  18089. public function removeConfigSetting($name)
  18090. {
  18091. return $this->removeSubNode('config', $name);
  18092. }
  18093. public function addProperty($name, $value)
  18094. {
  18095. if (strpos($name, 'suggest.') === 0) {
  18096. return $this->addSubNode('suggest', substr($name, 8), $value);
  18097. }
  18098. if (strpos($name, 'extra.') === 0) {
  18099. return $this->addSubNode('extra', substr($name, 6), $value);
  18100. }
  18101. if (strpos($name, 'scripts.') === 0) {
  18102. return $this->addSubNode('scripts', substr($name, 8), $value);
  18103. }
  18104. return $this->addMainKey($name, $value);
  18105. }
  18106. public function removeProperty($name)
  18107. {
  18108. if (strpos($name, 'suggest.') === 0) {
  18109. return $this->removeSubNode('suggest', substr($name, 8));
  18110. }
  18111. if (strpos($name, 'extra.') === 0) {
  18112. return $this->removeSubNode('extra', substr($name, 6));
  18113. }
  18114. if (strpos($name, 'scripts.') === 0) {
  18115. return $this->removeSubNode('scripts', substr($name, 8));
  18116. }
  18117. return $this->removeMainKey($name);
  18118. }
  18119. public function addSubNode($mainNode, $name, $value, $append = true)
  18120. {
  18121. $decoded = JsonFile::parseJson($this->contents);
  18122. $subName = null;
  18123. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  18124. list($name, $subName) = explode('.', $name, 2);
  18125. }
  18126. if (!isset($decoded[$mainNode])) {
  18127. if ($subName !== null) {
  18128. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  18129. } else {
  18130. $this->addMainKey($mainNode, array($name => $value));
  18131. }
  18132. return true;
  18133. }
  18134. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  18135. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  18136. try {
  18137. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  18138. return false;
  18139. }
  18140. } catch (\RuntimeException $e) {
  18141. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  18142. return false;
  18143. }
  18144. throw $e;
  18145. }
  18146. $children = $match['content'];
  18147. if (!@json_decode($children)) {
  18148. return false;
  18149. }
  18150. $that = $this;
  18151. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  18152. if ($this->pregMatch($childRegex, $children, $matches)) {
  18153. $children = preg_replace_callback($childRegex, function ($matches) use ($subName, $value, $that) {
  18154. if ($subName !== null) {
  18155. $curVal = json_decode($matches['content'], true);
  18156. if (!is_array($curVal)) {
  18157. $curVal = array();
  18158. }
  18159. $curVal[$subName] = $value;
  18160. $value = $curVal;
  18161. }
  18162. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  18163. }, $children);
  18164. } else {
  18165. $this->pregMatch('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  18166. $whitespace = '';
  18167. if (!empty($match['trailingspace'])) {
  18168. $whitespace = $match['trailingspace'];
  18169. }
  18170. if (!empty($match['content'])) {
  18171. if ($subName !== null) {
  18172. $value = array($subName => $value);
  18173. }
  18174. if ($append) {
  18175. $children = preg_replace(
  18176. '#'.$whitespace.'}$#',
  18177. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  18178. $children
  18179. );
  18180. } else {
  18181. $whitespace = '';
  18182. if (!empty($match['leadingspace'])) {
  18183. $whitespace = $match['leadingspace'];
  18184. }
  18185. $children = preg_replace(
  18186. '#^{'.$whitespace.'#',
  18187. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  18188. $children
  18189. );
  18190. }
  18191. } else {
  18192. if ($subName !== null) {
  18193. $value = array($subName => $value);
  18194. }
  18195. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  18196. }
  18197. }
  18198. $this->contents = preg_replace_callback($nodeRegex, function ($m) use ($children) {
  18199. return $m['start'] . $children . $m['end'];
  18200. }, $this->contents);
  18201. return true;
  18202. }
  18203. public function removeSubNode($mainNode, $name)
  18204. {
  18205. $decoded = JsonFile::parseJson($this->contents);
  18206. if (empty($decoded[$mainNode])) {
  18207. return true;
  18208. }
  18209. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  18210. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  18211. try {
  18212. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  18213. return false;
  18214. }
  18215. } catch (\RuntimeException $e) {
  18216. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  18217. return false;
  18218. }
  18219. throw $e;
  18220. }
  18221. $children = $match['content'];
  18222. if (!@json_decode($children, true)) {
  18223. return false;
  18224. }
  18225. $subName = null;
  18226. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  18227. list($name, $subName) = explode('.', $name, 2);
  18228. }
  18229. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  18230. return true;
  18231. }
  18232. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  18233. if ($this->pregMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  18234. if (preg_match_all('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  18235. $bestMatch = '';
  18236. foreach ($matches[0] as $match) {
  18237. if (strlen($bestMatch) < strlen($match)) {
  18238. $bestMatch = $match;
  18239. }
  18240. }
  18241. $childrenClean = preg_replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  18242. if (1 !== $count) {
  18243. $childrenClean = preg_replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  18244. if (1 !== $count) {
  18245. return false;
  18246. }
  18247. }
  18248. }
  18249. } else {
  18250. $childrenClean = $children;
  18251. }
  18252. if (!isset($childrenClean)) {
  18253. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  18254. }
  18255. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  18256. if (empty($match['content'])) {
  18257. $newline = $this->newline;
  18258. $indent = $this->indent;
  18259. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($indent, $newline) {
  18260. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  18261. }, $this->contents);
  18262. if ($subName !== null) {
  18263. $curVal = json_decode($children, true);
  18264. unset($curVal[$name][$subName]);
  18265. $this->addSubNode($mainNode, $name, $curVal[$name]);
  18266. }
  18267. return true;
  18268. }
  18269. $that = $this;
  18270. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  18271. if ($subName !== null) {
  18272. $curVal = json_decode($matches['content'], true);
  18273. unset($curVal[$name][$subName]);
  18274. $childrenClean = $that->format($curVal);
  18275. }
  18276. return $matches['start'] . $childrenClean . $matches['end'];
  18277. }, $this->contents);
  18278. return true;
  18279. }
  18280. public function addMainKey($key, $content)
  18281. {
  18282. $decoded = JsonFile::parseJson($this->contents);
  18283. $content = $this->format($content);
  18284. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18285. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  18286. if (isset($decoded[$key]) && $this->pregMatch($regex, $this->contents, $matches)) {
  18287. if (!@json_decode('{'.$matches['key'].'}')) {
  18288. return false;
  18289. }
  18290. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  18291. return true;
  18292. }
  18293. if ($this->pregMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  18294. $this->contents = preg_replace(
  18295. '#'.$match[1].'\}$#',
  18296. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  18297. $this->contents
  18298. );
  18299. return true;
  18300. }
  18301. $this->contents = preg_replace(
  18302. '#\}$#',
  18303. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  18304. $this->contents
  18305. );
  18306. return true;
  18307. }
  18308. public function removeMainKey($key)
  18309. {
  18310. $decoded = JsonFile::parseJson($this->contents);
  18311. if (!array_key_exists($key, $decoded)) {
  18312. return true;
  18313. }
  18314. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18315. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  18316. if ($this->pregMatch($regex, $this->contents, $matches)) {
  18317. if (!@json_decode('{'.$matches['removal'].'}')) {
  18318. return false;
  18319. }
  18320. if (preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
  18321. $matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  18322. }
  18323. $this->contents = $matches['start'] . $matches['end'];
  18324. if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
  18325. $this->contents = "{\n}";
  18326. }
  18327. return true;
  18328. }
  18329. return false;
  18330. }
  18331. public function removeMainKeyIfEmpty($key)
  18332. {
  18333. $decoded = JsonFile::parseJson($this->contents);
  18334. if (!array_key_exists($key, $decoded)) {
  18335. return true;
  18336. }
  18337. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  18338. return $this->removeMainKey($key);
  18339. }
  18340. return true;
  18341. }
  18342. public function format($data, $depth = 0)
  18343. {
  18344. if (is_array($data)) {
  18345. reset($data);
  18346. if (is_numeric(key($data))) {
  18347. foreach ($data as $key => $val) {
  18348. $data[$key] = $this->format($val, $depth + 1);
  18349. }
  18350. return '['.implode(', ', $data).']';
  18351. }
  18352. $out = '{' . $this->newline;
  18353. $elems = array();
  18354. foreach ($data as $key => $val) {
  18355. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  18356. }
  18357. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  18358. }
  18359. return JsonFile::encode($data);
  18360. }
  18361. protected function detectIndenting()
  18362. {
  18363. if ($this->pregMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  18364. $this->indent = $match[1];
  18365. } else {
  18366. $this->indent = ' ';
  18367. }
  18368. }
  18369. protected function pregMatch($re, $str, &$matches = array())
  18370. {
  18371. $count = preg_match($re, $str, $matches);
  18372. if ($count === false) {
  18373. switch (preg_last_error()) {
  18374. case PREG_NO_ERROR:
  18375. throw new \RuntimeException('Failed to execute regex: PREG_NO_ERROR', PREG_NO_ERROR);
  18376. case PREG_INTERNAL_ERROR:
  18377. throw new \RuntimeException('Failed to execute regex: PREG_INTERNAL_ERROR', PREG_INTERNAL_ERROR);
  18378. case PREG_BACKTRACK_LIMIT_ERROR:
  18379. throw new \RuntimeException('Failed to execute regex: PREG_BACKTRACK_LIMIT_ERROR', PREG_BACKTRACK_LIMIT_ERROR);
  18380. case PREG_RECURSION_LIMIT_ERROR:
  18381. throw new \RuntimeException('Failed to execute regex: PREG_RECURSION_LIMIT_ERROR', PREG_RECURSION_LIMIT_ERROR);
  18382. case PREG_BAD_UTF8_ERROR:
  18383. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_ERROR);
  18384. case PREG_BAD_UTF8_OFFSET_ERROR:
  18385. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_OFFSET_ERROR', PREG_BAD_UTF8_OFFSET_ERROR);
  18386. case 6:
  18387. if (PHP_VERSION_ID > 70000) {
  18388. throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6);
  18389. }
  18390. default:
  18391. throw new \RuntimeException('Failed to execute regex: Unknown error');
  18392. }
  18393. }
  18394. return $count;
  18395. }
  18396. }
  18397. <?php
  18398. namespace Composer\Json;
  18399. use Exception;
  18400. class JsonValidationException extends Exception
  18401. {
  18402. protected $errors;
  18403. public function __construct($message, $errors = array(), Exception $previous = null)
  18404. {
  18405. $this->errors = $errors;
  18406. parent::__construct($message, 0, $previous);
  18407. }
  18408. public function getErrors()
  18409. {
  18410. return $this->errors;
  18411. }
  18412. }
  18413. <?php
  18414. namespace Composer\Package;
  18415. use Composer\Semver\Constraint\Constraint;
  18416. use Composer\Package\Version\VersionParser;
  18417. class AliasPackage extends BasePackage implements CompletePackageInterface
  18418. {
  18419. protected $version;
  18420. protected $prettyVersion;
  18421. protected $dev;
  18422. protected $rootPackageAlias = false;
  18423. protected $stability;
  18424. protected $hasSelfVersionRequires = false;
  18425. protected $aliasOf;
  18426. protected $requires;
  18427. protected $devRequires;
  18428. protected $conflicts;
  18429. protected $provides;
  18430. protected $replaces;
  18431. public function __construct(PackageInterface $aliasOf, $version, $prettyVersion)
  18432. {
  18433. parent::__construct($aliasOf->getName());
  18434. $this->version = $version;
  18435. $this->prettyVersion = $prettyVersion;
  18436. $this->aliasOf = $aliasOf;
  18437. $this->stability = VersionParser::parseStability($version);
  18438. $this->dev = $this->stability === 'dev';
  18439. foreach (Link::$TYPES as $type) {
  18440. $links = $aliasOf->{'get' . ucfirst($type)}();
  18441. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  18442. }
  18443. }
  18444. public function getAliasOf()
  18445. {
  18446. return $this->aliasOf;
  18447. }
  18448. public function getVersion()
  18449. {
  18450. return $this->version;
  18451. }
  18452. public function getStability()
  18453. {
  18454. return $this->stability;
  18455. }
  18456. public function getPrettyVersion()
  18457. {
  18458. return $this->prettyVersion;
  18459. }
  18460. public function isDev()
  18461. {
  18462. return $this->dev;
  18463. }
  18464. public function getRequires()
  18465. {
  18466. return $this->requires;
  18467. }
  18468. public function getConflicts()
  18469. {
  18470. return $this->conflicts;
  18471. }
  18472. public function getProvides()
  18473. {
  18474. return $this->provides;
  18475. }
  18476. public function getReplaces()
  18477. {
  18478. return $this->replaces;
  18479. }
  18480. public function getDevRequires()
  18481. {
  18482. return $this->devRequires;
  18483. }
  18484. public function setRootPackageAlias($value)
  18485. {
  18486. return $this->rootPackageAlias = $value;
  18487. }
  18488. public function isRootPackageAlias()
  18489. {
  18490. return $this->rootPackageAlias;
  18491. }
  18492. protected function replaceSelfVersionDependencies(array $links, $linkType)
  18493. {
  18494. $prettyVersion = $this->prettyVersion;
  18495. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  18496. $prettyVersion = $this->aliasOf->getPrettyVersion();
  18497. }
  18498. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  18499. $newLinks = array();
  18500. foreach ($links as $link) {
  18501. if ('self.version' === $link->getPrettyConstraint()) {
  18502. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18503. $constraint->setPrettyString($prettyVersion);
  18504. }
  18505. }
  18506. $links = array_merge($links, $newLinks);
  18507. } else {
  18508. foreach ($links as $index => $link) {
  18509. if ('self.version' === $link->getPrettyConstraint()) {
  18510. if ($linkType === Link::TYPE_REQUIRE) {
  18511. $this->hasSelfVersionRequires = true;
  18512. }
  18513. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18514. $constraint->setPrettyString($prettyVersion);
  18515. }
  18516. }
  18517. }
  18518. return $links;
  18519. }
  18520. public function hasSelfVersionRequires()
  18521. {
  18522. return $this->hasSelfVersionRequires;
  18523. }
  18524. public function getType()
  18525. {
  18526. return $this->aliasOf->getType();
  18527. }
  18528. public function getTargetDir()
  18529. {
  18530. return $this->aliasOf->getTargetDir();
  18531. }
  18532. public function getExtra()
  18533. {
  18534. return $this->aliasOf->getExtra();
  18535. }
  18536. public function setInstallationSource($type)
  18537. {
  18538. $this->aliasOf->setInstallationSource($type);
  18539. }
  18540. public function getInstallationSource()
  18541. {
  18542. return $this->aliasOf->getInstallationSource();
  18543. }
  18544. public function getSourceType()
  18545. {
  18546. return $this->aliasOf->getSourceType();
  18547. }
  18548. public function getSourceUrl()
  18549. {
  18550. return $this->aliasOf->getSourceUrl();
  18551. }
  18552. public function getSourceUrls()
  18553. {
  18554. return $this->aliasOf->getSourceUrls();
  18555. }
  18556. public function getSourceReference()
  18557. {
  18558. return $this->aliasOf->getSourceReference();
  18559. }
  18560. public function setSourceReference($reference)
  18561. {
  18562. return $this->aliasOf->setSourceReference($reference);
  18563. }
  18564. public function setSourceMirrors($mirrors)
  18565. {
  18566. return $this->aliasOf->setSourceMirrors($mirrors);
  18567. }
  18568. public function getSourceMirrors()
  18569. {
  18570. return $this->aliasOf->getSourceMirrors();
  18571. }
  18572. public function getDistType()
  18573. {
  18574. return $this->aliasOf->getDistType();
  18575. }
  18576. public function getDistUrl()
  18577. {
  18578. return $this->aliasOf->getDistUrl();
  18579. }
  18580. public function getDistUrls()
  18581. {
  18582. return $this->aliasOf->getDistUrls();
  18583. }
  18584. public function getDistReference()
  18585. {
  18586. return $this->aliasOf->getDistReference();
  18587. }
  18588. public function setDistReference($reference)
  18589. {
  18590. return $this->aliasOf->setDistReference($reference);
  18591. }
  18592. public function getDistSha1Checksum()
  18593. {
  18594. return $this->aliasOf->getDistSha1Checksum();
  18595. }
  18596. public function setTransportOptions(array $options)
  18597. {
  18598. return $this->aliasOf->setTransportOptions($options);
  18599. }
  18600. public function getTransportOptions()
  18601. {
  18602. return $this->aliasOf->getTransportOptions();
  18603. }
  18604. public function setDistMirrors($mirrors)
  18605. {
  18606. return $this->aliasOf->setDistMirrors($mirrors);
  18607. }
  18608. public function getDistMirrors()
  18609. {
  18610. return $this->aliasOf->getDistMirrors();
  18611. }
  18612. public function getScripts()
  18613. {
  18614. return $this->aliasOf->getScripts();
  18615. }
  18616. public function getLicense()
  18617. {
  18618. return $this->aliasOf->getLicense();
  18619. }
  18620. public function getAutoload()
  18621. {
  18622. return $this->aliasOf->getAutoload();
  18623. }
  18624. public function getDevAutoload()
  18625. {
  18626. return $this->aliasOf->getDevAutoload();
  18627. }
  18628. public function getIncludePaths()
  18629. {
  18630. return $this->aliasOf->getIncludePaths();
  18631. }
  18632. public function getRepositories()
  18633. {
  18634. return $this->aliasOf->getRepositories();
  18635. }
  18636. public function getReleaseDate()
  18637. {
  18638. return $this->aliasOf->getReleaseDate();
  18639. }
  18640. public function getBinaries()
  18641. {
  18642. return $this->aliasOf->getBinaries();
  18643. }
  18644. public function getKeywords()
  18645. {
  18646. return $this->aliasOf->getKeywords();
  18647. }
  18648. public function getDescription()
  18649. {
  18650. return $this->aliasOf->getDescription();
  18651. }
  18652. public function getHomepage()
  18653. {
  18654. return $this->aliasOf->getHomepage();
  18655. }
  18656. public function getSuggests()
  18657. {
  18658. return $this->aliasOf->getSuggests();
  18659. }
  18660. public function getAuthors()
  18661. {
  18662. return $this->aliasOf->getAuthors();
  18663. }
  18664. public function getSupport()
  18665. {
  18666. return $this->aliasOf->getSupport();
  18667. }
  18668. public function getFunding()
  18669. {
  18670. return $this->aliasOf->getFunding();
  18671. }
  18672. public function getNotificationUrl()
  18673. {
  18674. return $this->aliasOf->getNotificationUrl();
  18675. }
  18676. public function getArchiveName()
  18677. {
  18678. return $this->aliasOf->getArchiveName();
  18679. }
  18680. public function getArchiveExcludes()
  18681. {
  18682. return $this->aliasOf->getArchiveExcludes();
  18683. }
  18684. public function isDefaultBranch()
  18685. {
  18686. return $this->aliasOf->isDefaultBranch();
  18687. }
  18688. public function isAbandoned()
  18689. {
  18690. return $this->aliasOf->isAbandoned();
  18691. }
  18692. public function getReplacementPackage()
  18693. {
  18694. return $this->aliasOf->getReplacementPackage();
  18695. }
  18696. public function __toString()
  18697. {
  18698. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  18699. }
  18700. public function setDistUrl($url)
  18701. {
  18702. return $this->aliasOf->setDistUrl($url);
  18703. }
  18704. public function setDistType($type)
  18705. {
  18706. return $this->aliasOf->setDistType($type);
  18707. }
  18708. public function setSourceDistReferences($reference)
  18709. {
  18710. return $this->aliasOf->setSourceDistReferences($reference);
  18711. }
  18712. }
  18713. <?php
  18714. namespace Composer\Package\Archiver;
  18715. use FilterIterator;
  18716. use PharData;
  18717. class ArchivableFilesFilter extends FilterIterator
  18718. {
  18719. private $dirs = array();
  18720. public function accept()
  18721. {
  18722. $file = $this->getInnerIterator()->current();
  18723. if ($file->isDir()) {
  18724. $this->dirs[] = (string) $file;
  18725. return false;
  18726. }
  18727. return true;
  18728. }
  18729. public function addEmptyDir(PharData $phar, $sources)
  18730. {
  18731. foreach ($this->dirs as $filepath) {
  18732. $localname = str_replace($sources . "/", '', $filepath);
  18733. $phar->addEmptyDir($localname);
  18734. }
  18735. }
  18736. }
  18737. <?php
  18738. namespace Composer\Package\Archiver;
  18739. use Composer\Util\Filesystem;
  18740. use FilesystemIterator;
  18741. use Symfony\Component\Finder\Finder;
  18742. use Symfony\Component\Finder\SplFileInfo;
  18743. class ArchivableFilesFinder extends \FilterIterator
  18744. {
  18745. protected $finder;
  18746. public function __construct($sources, array $excludes, $ignoreFilters = false)
  18747. {
  18748. $fs = new Filesystem();
  18749. $sources = $fs->normalizePath(realpath($sources));
  18750. if ($ignoreFilters) {
  18751. $filters = array();
  18752. } else {
  18753. $filters = array(
  18754. new HgExcludeFilter($sources),
  18755. new GitExcludeFilter($sources),
  18756. new ComposerExcludeFilter($sources, $excludes),
  18757. );
  18758. }
  18759. $this->finder = new Finder();
  18760. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  18761. if ($file->isLink() && strpos($file->getRealPath(), $sources) !== 0) {
  18762. return false;
  18763. }
  18764. $relativePath = preg_replace(
  18765. '#^'.preg_quote($sources, '#').'#',
  18766. '',
  18767. $fs->normalizePath($file->getRealPath())
  18768. );
  18769. $exclude = false;
  18770. foreach ($filters as $filter) {
  18771. $exclude = $filter->filter($relativePath, $exclude);
  18772. }
  18773. return !$exclude;
  18774. };
  18775. if (method_exists($filter, 'bindTo')) {
  18776. $filter = $filter->bindTo(null);
  18777. }
  18778. $this->finder
  18779. ->in($sources)
  18780. ->filter($filter)
  18781. ->ignoreVCS(true)
  18782. ->ignoreDotFiles(false);
  18783. parent::__construct($this->finder->getIterator());
  18784. }
  18785. public function accept()
  18786. {
  18787. $current = $this->getInnerIterator()->current();
  18788. if (!$current->isDir()) {
  18789. return true;
  18790. }
  18791. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  18792. return !$iterator->valid();
  18793. }
  18794. }
  18795. <?php
  18796. namespace Composer\Package\Archiver;
  18797. use Composer\Downloader\DownloadManager;
  18798. use Composer\Package\PackageInterface;
  18799. use Composer\Package\RootPackageInterface;
  18800. use Composer\Util\Filesystem;
  18801. use Composer\Util\Loop;
  18802. use Composer\Json\JsonFile;
  18803. class ArchiveManager
  18804. {
  18805. protected $downloadManager;
  18806. protected $loop;
  18807. protected $archivers = array();
  18808. protected $overwriteFiles = true;
  18809. public function __construct(DownloadManager $downloadManager, Loop $loop)
  18810. {
  18811. $this->downloadManager = $downloadManager;
  18812. $this->loop = $loop;
  18813. }
  18814. public function addArchiver(ArchiverInterface $archiver)
  18815. {
  18816. $this->archivers[] = $archiver;
  18817. }
  18818. public function setOverwriteFiles($overwriteFiles)
  18819. {
  18820. $this->overwriteFiles = $overwriteFiles;
  18821. return $this;
  18822. }
  18823. public function getPackageFilename(PackageInterface $package)
  18824. {
  18825. if ($package->getArchiveName()) {
  18826. $baseName = $package->getArchiveName();
  18827. } else {
  18828. $baseName = preg_replace('#[^a-z0-9-_]#i', '-', $package->getName());
  18829. }
  18830. $nameParts = array($baseName);
  18831. if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  18832. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  18833. } else {
  18834. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  18835. }
  18836. if ($package->getSourceReference()) {
  18837. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  18838. }
  18839. $name = implode('-', array_filter($nameParts, function ($p) {
  18840. return !empty($p);
  18841. }));
  18842. return str_replace('/', '-', $name);
  18843. }
  18844. public function archive(PackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  18845. {
  18846. if (empty($format)) {
  18847. throw new \InvalidArgumentException('Format must be specified');
  18848. }
  18849. $usableArchiver = null;
  18850. foreach ($this->archivers as $archiver) {
  18851. if ($archiver->supports($format, $package->getSourceType())) {
  18852. $usableArchiver = $archiver;
  18853. break;
  18854. }
  18855. }
  18856. if (null === $usableArchiver) {
  18857. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  18858. }
  18859. $filesystem = new Filesystem();
  18860. if ($package instanceof RootPackageInterface) {
  18861. $sourcePath = realpath('.');
  18862. } else {
  18863. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  18864. $filesystem->ensureDirectoryExists($sourcePath);
  18865. try {
  18866. $promise = $this->downloadManager->download($package, $sourcePath);
  18867. $this->loop->wait(array($promise));
  18868. $this->downloadManager->install($package, $sourcePath);
  18869. } catch (\Exception $e) {
  18870. $filesystem->removeDirectory($sourcePath);
  18871. throw $e;
  18872. }
  18873. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  18874. $jsonFile = new JsonFile($composerJsonPath);
  18875. $jsonData = $jsonFile->read();
  18876. if (!empty($jsonData['archive']['name'])) {
  18877. $package->setArchiveName($jsonData['archive']['name']);
  18878. }
  18879. if (!empty($jsonData['archive']['exclude'])) {
  18880. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  18881. }
  18882. }
  18883. }
  18884. if (null === $fileName) {
  18885. $packageName = $this->getPackageFilename($package);
  18886. } else {
  18887. $packageName = $fileName;
  18888. }
  18889. $filesystem->ensureDirectoryExists($targetDir);
  18890. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  18891. $filesystem->ensureDirectoryExists(dirname($target));
  18892. if (!$this->overwriteFiles && file_exists($target)) {
  18893. return $target;
  18894. }
  18895. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  18896. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  18897. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  18898. $filesystem->rename($archivePath, $target);
  18899. if (!$package instanceof RootPackageInterface) {
  18900. $filesystem->removeDirectory($sourcePath);
  18901. }
  18902. $filesystem->remove($tempTarget);
  18903. return $target;
  18904. }
  18905. }
  18906. <?php
  18907. namespace Composer\Package\Archiver;
  18908. interface ArchiverInterface
  18909. {
  18910. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  18911. public function supports($format, $sourceType);
  18912. }
  18913. <?php
  18914. namespace Composer\Package\Archiver;
  18915. use Symfony\Component\Finder;
  18916. abstract class BaseExcludeFilter
  18917. {
  18918. protected $sourcePath;
  18919. protected $excludePatterns;
  18920. public function __construct($sourcePath)
  18921. {
  18922. $this->sourcePath = $sourcePath;
  18923. $this->excludePatterns = array();
  18924. }
  18925. public function filter($relativePath, $exclude)
  18926. {
  18927. foreach ($this->excludePatterns as $patternData) {
  18928. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  18929. if ($stripLeadingSlash) {
  18930. $path = substr($relativePath, 1);
  18931. } else {
  18932. $path = $relativePath;
  18933. }
  18934. if (@preg_match($pattern, $path)) {
  18935. $exclude = !$negate;
  18936. }
  18937. }
  18938. return $exclude;
  18939. }
  18940. protected function parseLines(array $lines, $lineParser)
  18941. {
  18942. return array_filter(
  18943. array_map(
  18944. function ($line) use ($lineParser) {
  18945. $line = trim($line);
  18946. if (!$line || 0 === strpos($line, '#')) {
  18947. return null;
  18948. }
  18949. return call_user_func($lineParser, $line);
  18950. },
  18951. $lines
  18952. ),
  18953. function ($pattern) {
  18954. return $pattern !== null;
  18955. }
  18956. );
  18957. }
  18958. protected function generatePatterns($rules)
  18959. {
  18960. $patterns = array();
  18961. foreach ($rules as $rule) {
  18962. $patterns[] = $this->generatePattern($rule);
  18963. }
  18964. return $patterns;
  18965. }
  18966. protected function generatePattern($rule)
  18967. {
  18968. $negate = false;
  18969. $pattern = '';
  18970. if ($rule !== '' && $rule[0] === '!') {
  18971. $negate = true;
  18972. $rule = ltrim($rule, '!');
  18973. }
  18974. $firstSlashPosition = strpos($rule, '/');
  18975. if (0 === $firstSlashPosition) {
  18976. $pattern = '^/';
  18977. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  18978. $pattern = '/';
  18979. }
  18980. $rule = trim($rule, '/');
  18981. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  18982. return array('{'.$pattern.$rule.'(?=$|/)}', $negate, false);
  18983. }
  18984. }
  18985. <?php
  18986. namespace Composer\Package\Archiver;
  18987. class ComposerExcludeFilter extends BaseExcludeFilter
  18988. {
  18989. public function __construct($sourcePath, array $excludeRules)
  18990. {
  18991. parent::__construct($sourcePath);
  18992. $this->excludePatterns = $this->generatePatterns($excludeRules);
  18993. }
  18994. }
  18995. <?php
  18996. namespace Composer\Package\Archiver;
  18997. class GitExcludeFilter extends BaseExcludeFilter
  18998. {
  18999. public function __construct($sourcePath)
  19000. {
  19001. parent::__construct($sourcePath);
  19002. if (file_exists($sourcePath.'/.gitignore')) {
  19003. $this->excludePatterns = $this->parseLines(
  19004. file($sourcePath.'/.gitignore'),
  19005. array($this, 'parseGitIgnoreLine')
  19006. );
  19007. }
  19008. if (file_exists($sourcePath.'/.gitattributes')) {
  19009. $this->excludePatterns = array_merge(
  19010. $this->excludePatterns,
  19011. $this->parseLines(
  19012. file($sourcePath.'/.gitattributes'),
  19013. array($this, 'parseGitAttributesLine')
  19014. )
  19015. );
  19016. }
  19017. }
  19018. public function parseGitIgnoreLine($line)
  19019. {
  19020. return $this->generatePattern($line);
  19021. }
  19022. public function parseGitAttributesLine($line)
  19023. {
  19024. $parts = preg_split('#\s+#', $line);
  19025. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  19026. return $this->generatePattern($parts[0]);
  19027. }
  19028. return null;
  19029. }
  19030. }
  19031. <?php
  19032. namespace Composer\Package\Archiver;
  19033. use Symfony\Component\Finder;
  19034. class HgExcludeFilter extends BaseExcludeFilter
  19035. {
  19036. const HG_IGNORE_REGEX = 1;
  19037. const HG_IGNORE_GLOB = 2;
  19038. protected $patternMode;
  19039. public function __construct($sourcePath)
  19040. {
  19041. parent::__construct($sourcePath);
  19042. $this->patternMode = self::HG_IGNORE_REGEX;
  19043. if (file_exists($sourcePath.'/.hgignore')) {
  19044. $this->excludePatterns = $this->parseLines(
  19045. file($sourcePath.'/.hgignore'),
  19046. array($this, 'parseHgIgnoreLine')
  19047. );
  19048. }
  19049. }
  19050. public function parseHgIgnoreLine($line)
  19051. {
  19052. if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)) {
  19053. if ($matches[1] === 'glob') {
  19054. $this->patternMode = self::HG_IGNORE_GLOB;
  19055. } else {
  19056. $this->patternMode = self::HG_IGNORE_REGEX;
  19057. }
  19058. return null;
  19059. }
  19060. if ($this->patternMode == self::HG_IGNORE_GLOB) {
  19061. return $this->patternFromGlob($line);
  19062. }
  19063. return $this->patternFromRegex($line);
  19064. }
  19065. protected function patternFromGlob($line)
  19066. {
  19067. $pattern = '#'.substr(Finder\Glob::toRegex($line), 2, -1).'#';
  19068. $pattern = str_replace('[^/]*', '.*', $pattern);
  19069. return array($pattern, false, true);
  19070. }
  19071. public function patternFromRegex($line)
  19072. {
  19073. $pattern = '#'.preg_replace('/((?:\\\\\\\\)*)(\\\\?)#/', '\1\2\2\\#', $line).'#';
  19074. return array($pattern, false, true);
  19075. }
  19076. }
  19077. <?php
  19078. namespace Composer\Package\Archiver;
  19079. class PharArchiver implements ArchiverInterface
  19080. {
  19081. protected static $formats = array(
  19082. 'zip' => \Phar::ZIP,
  19083. 'tar' => \Phar::TAR,
  19084. 'tar.gz' => \Phar::TAR,
  19085. 'tar.bz2' => \Phar::TAR,
  19086. );
  19087. protected static $compressFormats = array(
  19088. 'tar.gz' => \Phar::GZ,
  19089. 'tar.bz2' => \Phar::BZ2,
  19090. );
  19091. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  19092. {
  19093. $sources = realpath($sources);
  19094. if (file_exists($target)) {
  19095. unlink($target);
  19096. }
  19097. try {
  19098. $filename = substr($target, 0, strrpos($target, $format) - 1);
  19099. if (isset(static::$compressFormats[$format])) {
  19100. $target = $filename . '.tar';
  19101. }
  19102. $phar = new \PharData($target, null, null, static::$formats[$format]);
  19103. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  19104. $filesOnly = new ArchivableFilesFilter($files);
  19105. $phar->buildFromIterator($filesOnly, $sources);
  19106. $filesOnly->addEmptyDir($phar, $sources);
  19107. if (isset(static::$compressFormats[$format])) {
  19108. if (!$phar->canCompress(static::$compressFormats[$format])) {
  19109. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  19110. }
  19111. unlink($target);
  19112. $phar->compress(static::$compressFormats[$format]);
  19113. $target = $filename . '.' . $format;
  19114. }
  19115. return $target;
  19116. } catch (\UnexpectedValueException $e) {
  19117. $message = sprintf(
  19118. "Could not create archive '%s' from '%s': %s",
  19119. $target,
  19120. $sources,
  19121. $e->getMessage()
  19122. );
  19123. throw new \RuntimeException($message, $e->getCode(), $e);
  19124. }
  19125. }
  19126. public function supports($format, $sourceType)
  19127. {
  19128. return isset(static::$formats[$format]);
  19129. }
  19130. }
  19131. <?php
  19132. namespace Composer\Package\Archiver;
  19133. use ZipArchive;
  19134. use Composer\Util\Filesystem;
  19135. class ZipArchiver implements ArchiverInterface
  19136. {
  19137. protected static $formats = array(
  19138. 'zip' => 1,
  19139. );
  19140. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  19141. {
  19142. $fs = new Filesystem();
  19143. $sources = $fs->normalizePath($sources);
  19144. $zip = new ZipArchive();
  19145. $res = $zip->open($target, ZipArchive::CREATE);
  19146. if ($res === true) {
  19147. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  19148. foreach ($files as $file) {
  19149. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  19150. $localname = $filepath;
  19151. if (strpos($localname, $sources . '/') === 0) {
  19152. $localname = substr($localname, strlen($sources . '/'));
  19153. }
  19154. if ($file->isDir()) {
  19155. $zip->addEmptyDir($localname);
  19156. } else {
  19157. $zip->addFile($filepath, $localname);
  19158. }
  19159. if (PHP_VERSION_ID >= 50600) {
  19160. $perms = fileperms($filepath);
  19161. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  19162. }
  19163. }
  19164. if ($zip->close()) {
  19165. return $target;
  19166. }
  19167. }
  19168. $message = sprintf(
  19169. "Could not create archive '%s' from '%s': %s",
  19170. $target,
  19171. $sources,
  19172. $zip->getStatusString()
  19173. );
  19174. throw new \RuntimeException($message);
  19175. }
  19176. public function supports($format, $sourceType)
  19177. {
  19178. return isset(static::$formats[$format]) && $this->compressionAvailable();
  19179. }
  19180. private function compressionAvailable()
  19181. {
  19182. return class_exists('ZipArchive');
  19183. }
  19184. }
  19185. <?php
  19186. namespace Composer\Package;
  19187. use Composer\Repository\RepositoryInterface;
  19188. use Composer\Repository\PlatformRepository;
  19189. abstract class BasePackage implements PackageInterface
  19190. {
  19191. public static $supportedLinkTypes = array(
  19192. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  19193. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  19194. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  19195. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  19196. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  19197. );
  19198. const STABILITY_STABLE = 0;
  19199. const STABILITY_RC = 5;
  19200. const STABILITY_BETA = 10;
  19201. const STABILITY_ALPHA = 15;
  19202. const STABILITY_DEV = 20;
  19203. public static $stabilities = array(
  19204. 'stable' => self::STABILITY_STABLE,
  19205. 'RC' => self::STABILITY_RC,
  19206. 'beta' => self::STABILITY_BETA,
  19207. 'alpha' => self::STABILITY_ALPHA,
  19208. 'dev' => self::STABILITY_DEV,
  19209. );
  19210. public $id;
  19211. protected $name;
  19212. protected $prettyName;
  19213. protected $repository;
  19214. protected $transportOptions = array();
  19215. public function __construct($name)
  19216. {
  19217. $this->prettyName = $name;
  19218. $this->name = strtolower($name);
  19219. $this->id = -1;
  19220. }
  19221. public function getName()
  19222. {
  19223. return $this->name;
  19224. }
  19225. public function getPrettyName()
  19226. {
  19227. return $this->prettyName;
  19228. }
  19229. public function getNames($provides = true)
  19230. {
  19231. $names = array(
  19232. $this->getName() => true,
  19233. );
  19234. if ($provides) {
  19235. foreach ($this->getProvides() as $link) {
  19236. $names[$link->getTarget()] = true;
  19237. }
  19238. }
  19239. foreach ($this->getReplaces() as $link) {
  19240. $names[$link->getTarget()] = true;
  19241. }
  19242. return array_keys($names);
  19243. }
  19244. public function setId($id)
  19245. {
  19246. $this->id = $id;
  19247. }
  19248. public function getId()
  19249. {
  19250. return $this->id;
  19251. }
  19252. public function setRepository(RepositoryInterface $repository)
  19253. {
  19254. if ($this->repository && $repository !== $this->repository) {
  19255. throw new \LogicException('A package can only be added to one repository');
  19256. }
  19257. $this->repository = $repository;
  19258. }
  19259. public function getRepository()
  19260. {
  19261. return $this->repository;
  19262. }
  19263. public function getTransportOptions()
  19264. {
  19265. return $this->transportOptions;
  19266. }
  19267. public function setTransportOptions(array $options)
  19268. {
  19269. $this->transportOptions = $options;
  19270. }
  19271. public function isPlatform()
  19272. {
  19273. return $this->getRepository() instanceof PlatformRepository;
  19274. }
  19275. public function getUniqueName()
  19276. {
  19277. return $this->getName().'-'.$this->getVersion();
  19278. }
  19279. public function equals(PackageInterface $package)
  19280. {
  19281. $self = $this;
  19282. if ($this instanceof AliasPackage) {
  19283. $self = $this->getAliasOf();
  19284. }
  19285. if ($package instanceof AliasPackage) {
  19286. $package = $package->getAliasOf();
  19287. }
  19288. return $package === $self;
  19289. }
  19290. public function __toString()
  19291. {
  19292. return $this->getUniqueName();
  19293. }
  19294. public function getPrettyString()
  19295. {
  19296. return $this->getPrettyName().' '.$this->getPrettyVersion();
  19297. }
  19298. public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
  19299. {
  19300. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  19301. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  19302. ) {
  19303. return $this->getPrettyVersion();
  19304. }
  19305. switch ($displayMode) {
  19306. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  19307. case PackageInterface::DISPLAY_SOURCE_REF:
  19308. $reference = $this->getSourceReference();
  19309. break;
  19310. case PackageInterface::DISPLAY_DIST_REF:
  19311. $reference = $this->getDistReference();
  19312. break;
  19313. default:
  19314. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  19315. }
  19316. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  19317. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  19318. }
  19319. return $this->getPrettyVersion() . ' ' . $reference;
  19320. }
  19321. public function getStabilityPriority()
  19322. {
  19323. return self::$stabilities[$this->getStability()];
  19324. }
  19325. public function __clone()
  19326. {
  19327. $this->repository = null;
  19328. $this->id = -1;
  19329. }
  19330. public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
  19331. {
  19332. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  19333. return sprintf($wrap, $cleanedAllowPattern);
  19334. }
  19335. }
  19336. <?php
  19337. namespace Composer\Package\Comparer;
  19338. class Comparer
  19339. {
  19340. private $source;
  19341. private $update;
  19342. private $changed;
  19343. public function setSource($source)
  19344. {
  19345. $this->source = $source;
  19346. }
  19347. public function setUpdate($update)
  19348. {
  19349. $this->update = $update;
  19350. }
  19351. public function getChanged($toString = false, $explicated = false)
  19352. {
  19353. $changed = $this->changed;
  19354. if (!count($changed)) {
  19355. return false;
  19356. }
  19357. if ($explicated) {
  19358. foreach ($changed as $sectionKey => $itemSection) {
  19359. foreach ($itemSection as $itemKey => $item) {
  19360. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  19361. }
  19362. }
  19363. }
  19364. if ($toString) {
  19365. foreach ($changed as $sectionKey => $itemSection) {
  19366. foreach ($itemSection as $itemKey => $item) {
  19367. $changed['string'][] = $item."\r\n";
  19368. }
  19369. }
  19370. $changed = implode("\r\n", $changed['string']);
  19371. }
  19372. return $changed;
  19373. }
  19374. public function doCompare()
  19375. {
  19376. $source = array();
  19377. $destination = array();
  19378. $this->changed = array();
  19379. $currentDirectory = getcwd();
  19380. chdir($this->source);
  19381. $source = $this->doTree('.', $source);
  19382. if (!is_array($source)) {
  19383. return;
  19384. }
  19385. chdir($currentDirectory);
  19386. chdir($this->update);
  19387. $destination = $this->doTree('.', $destination);
  19388. if (!is_array($destination)) {
  19389. exit;
  19390. }
  19391. chdir($currentDirectory);
  19392. foreach ($source as $dir => $value) {
  19393. foreach ($value as $file => $hash) {
  19394. if (isset($destination[$dir][$file])) {
  19395. if ($hash !== $destination[$dir][$file]) {
  19396. $this->changed['changed'][] = $dir.'/'.$file;
  19397. }
  19398. } else {
  19399. $this->changed['removed'][] = $dir.'/'.$file;
  19400. }
  19401. }
  19402. }
  19403. foreach ($destination as $dir => $value) {
  19404. foreach ($value as $file => $hash) {
  19405. if (!isset($source[$dir][$file])) {
  19406. $this->changed['added'][] = $dir.'/'.$file;
  19407. }
  19408. }
  19409. }
  19410. }
  19411. private function doTree($dir, &$array)
  19412. {
  19413. if ($dh = opendir($dir)) {
  19414. while ($file = readdir($dh)) {
  19415. if ($file !== '.' && $file !== '..') {
  19416. if (is_link($dir.'/'.$file)) {
  19417. $array[$dir][$file] = readlink($dir.'/'.$file);
  19418. } elseif (is_dir($dir.'/'.$file)) {
  19419. if (!count($array)) {
  19420. $array[0] = 'Temp';
  19421. }
  19422. if (!$this->doTree($dir.'/'.$file, $array)) {
  19423. return false;
  19424. }
  19425. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  19426. $array[$dir][$file] = md5_file($dir.'/'.$file);
  19427. }
  19428. }
  19429. }
  19430. if (count($array) > 1 && isset($array['0'])) {
  19431. unset($array['0']);
  19432. }
  19433. return $array;
  19434. }
  19435. return false;
  19436. }
  19437. }
  19438. <?php
  19439. namespace Composer\Package;
  19440. class CompletePackage extends Package implements CompletePackageInterface
  19441. {
  19442. protected $repositories;
  19443. protected $license = array();
  19444. protected $keywords;
  19445. protected $authors;
  19446. protected $description;
  19447. protected $homepage;
  19448. protected $scripts = array();
  19449. protected $support = array();
  19450. protected $funding = array();
  19451. protected $abandoned = false;
  19452. public function setScripts(array $scripts)
  19453. {
  19454. $this->scripts = $scripts;
  19455. }
  19456. public function getScripts()
  19457. {
  19458. return $this->scripts;
  19459. }
  19460. public function setRepositories($repositories)
  19461. {
  19462. $this->repositories = $repositories;
  19463. }
  19464. public function getRepositories()
  19465. {
  19466. return $this->repositories;
  19467. }
  19468. public function setLicense(array $license)
  19469. {
  19470. $this->license = $license;
  19471. }
  19472. public function getLicense()
  19473. {
  19474. return $this->license;
  19475. }
  19476. public function setKeywords(array $keywords)
  19477. {
  19478. $this->keywords = $keywords;
  19479. }
  19480. public function getKeywords()
  19481. {
  19482. return $this->keywords;
  19483. }
  19484. public function setAuthors(array $authors)
  19485. {
  19486. $this->authors = $authors;
  19487. }
  19488. public function getAuthors()
  19489. {
  19490. return $this->authors;
  19491. }
  19492. public function setDescription($description)
  19493. {
  19494. $this->description = $description;
  19495. }
  19496. public function getDescription()
  19497. {
  19498. return $this->description;
  19499. }
  19500. public function setHomepage($homepage)
  19501. {
  19502. $this->homepage = $homepage;
  19503. }
  19504. public function getHomepage()
  19505. {
  19506. return $this->homepage;
  19507. }
  19508. public function setSupport(array $support)
  19509. {
  19510. $this->support = $support;
  19511. }
  19512. public function getSupport()
  19513. {
  19514. return $this->support;
  19515. }
  19516. public function setFunding(array $funding)
  19517. {
  19518. $this->funding = $funding;
  19519. }
  19520. public function getFunding()
  19521. {
  19522. return $this->funding;
  19523. }
  19524. public function isAbandoned()
  19525. {
  19526. return (bool) $this->abandoned;
  19527. }
  19528. public function setAbandoned($abandoned)
  19529. {
  19530. $this->abandoned = $abandoned;
  19531. }
  19532. public function getReplacementPackage()
  19533. {
  19534. return \is_string($this->abandoned) ? $this->abandoned : null;
  19535. }
  19536. }
  19537. <?php
  19538. namespace Composer\Package;
  19539. interface CompletePackageInterface extends PackageInterface
  19540. {
  19541. public function getScripts();
  19542. public function getRepositories();
  19543. public function getLicense();
  19544. public function getKeywords();
  19545. public function getDescription();
  19546. public function getHomepage();
  19547. public function getAuthors();
  19548. public function getSupport();
  19549. public function getFunding();
  19550. public function isAbandoned();
  19551. public function getReplacementPackage();
  19552. }
  19553. <?php
  19554. namespace Composer\Package\Dumper;
  19555. use Composer\Package\BasePackage;
  19556. use Composer\Package\PackageInterface;
  19557. use Composer\Package\CompletePackageInterface;
  19558. use Composer\Package\RootPackageInterface;
  19559. class ArrayDumper
  19560. {
  19561. public function dump(PackageInterface $package)
  19562. {
  19563. $keys = array(
  19564. 'binaries' => 'bin',
  19565. 'type',
  19566. 'extra',
  19567. 'installationSource' => 'installation-source',
  19568. 'autoload',
  19569. 'devAutoload' => 'autoload-dev',
  19570. 'notificationUrl' => 'notification-url',
  19571. 'includePaths' => 'include-path',
  19572. );
  19573. $data = array();
  19574. $data['name'] = $package->getPrettyName();
  19575. $data['version'] = $package->getPrettyVersion();
  19576. $data['version_normalized'] = $package->getVersion();
  19577. if ($package->getTargetDir()) {
  19578. $data['target-dir'] = $package->getTargetDir();
  19579. }
  19580. if ($package->getSourceType()) {
  19581. $data['source']['type'] = $package->getSourceType();
  19582. $data['source']['url'] = $package->getSourceUrl();
  19583. if (null !== ($value = $package->getSourceReference())) {
  19584. $data['source']['reference'] = $value;
  19585. }
  19586. if ($mirrors = $package->getSourceMirrors()) {
  19587. $data['source']['mirrors'] = $mirrors;
  19588. }
  19589. }
  19590. if ($package->getDistType()) {
  19591. $data['dist']['type'] = $package->getDistType();
  19592. $data['dist']['url'] = $package->getDistUrl();
  19593. if (null !== ($value = $package->getDistReference())) {
  19594. $data['dist']['reference'] = $value;
  19595. }
  19596. if (null !== ($value = $package->getDistSha1Checksum())) {
  19597. $data['dist']['shasum'] = $value;
  19598. }
  19599. if ($mirrors = $package->getDistMirrors()) {
  19600. $data['dist']['mirrors'] = $mirrors;
  19601. }
  19602. }
  19603. if ($package->getArchiveName()) {
  19604. $data['archive']['name'] = $package->getArchiveName();
  19605. }
  19606. if ($package->getArchiveExcludes()) {
  19607. $data['archive']['exclude'] = $package->getArchiveExcludes();
  19608. }
  19609. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  19610. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  19611. foreach ($links as $link) {
  19612. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  19613. }
  19614. ksort($data[$type]);
  19615. }
  19616. }
  19617. if ($packages = $package->getSuggests()) {
  19618. ksort($packages);
  19619. $data['suggest'] = $packages;
  19620. }
  19621. if ($package->getReleaseDate()) {
  19622. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  19623. }
  19624. if ($package->isDefaultBranch()) {
  19625. $data['default-branch'] = true;
  19626. }
  19627. $data = $this->dumpValues($package, $keys, $data);
  19628. if ($package instanceof CompletePackageInterface) {
  19629. $keys = array(
  19630. 'scripts',
  19631. 'license',
  19632. 'authors',
  19633. 'description',
  19634. 'homepage',
  19635. 'keywords',
  19636. 'repositories',
  19637. 'support',
  19638. 'funding',
  19639. );
  19640. $data = $this->dumpValues($package, $keys, $data);
  19641. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  19642. sort($data['keywords']);
  19643. }
  19644. if ($package->isAbandoned()) {
  19645. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  19646. }
  19647. }
  19648. if ($package instanceof RootPackageInterface) {
  19649. $minimumStability = $package->getMinimumStability();
  19650. if ($minimumStability) {
  19651. $data['minimum-stability'] = $minimumStability;
  19652. }
  19653. }
  19654. if (\count($package->getTransportOptions()) > 0) {
  19655. $data['transport-options'] = $package->getTransportOptions();
  19656. }
  19657. return $data;
  19658. }
  19659. private function dumpValues(PackageInterface $package, array $keys, array $data)
  19660. {
  19661. foreach ($keys as $method => $key) {
  19662. if (is_numeric($method)) {
  19663. $method = $key;
  19664. }
  19665. $getter = 'get'.ucfirst($method);
  19666. $value = $package->$getter();
  19667. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  19668. $data[$key] = $value;
  19669. }
  19670. }
  19671. return $data;
  19672. }
  19673. }
  19674. <?php
  19675. namespace Composer\Package;
  19676. use Composer\Semver\Constraint\ConstraintInterface;
  19677. class Link
  19678. {
  19679. const TYPE_REQUIRE = 'requires';
  19680. const TYPE_DEV_REQUIRE = 'devRequires';
  19681. const TYPE_PROVIDE = 'provides';
  19682. const TYPE_CONFLICT = 'conflicts';
  19683. const TYPE_REPLACE = 'replaces';
  19684. public static $TYPES = array(
  19685. self::TYPE_REQUIRE,
  19686. self::TYPE_DEV_REQUIRE,
  19687. self::TYPE_PROVIDE,
  19688. self::TYPE_CONFLICT,
  19689. self::TYPE_REPLACE,
  19690. );
  19691. protected $source;
  19692. protected $target;
  19693. protected $constraint;
  19694. protected $description;
  19695. protected $prettyConstraint;
  19696. public function __construct(
  19697. $source,
  19698. $target,
  19699. ConstraintInterface $constraint,
  19700. $description = 'relates to',
  19701. $prettyConstraint = null
  19702. ) {
  19703. $this->source = strtolower($source);
  19704. $this->target = strtolower($target);
  19705. $this->constraint = $constraint;
  19706. $this->description = $description;
  19707. $this->prettyConstraint = $prettyConstraint;
  19708. }
  19709. public function getDescription()
  19710. {
  19711. return $this->description;
  19712. }
  19713. public function getSource()
  19714. {
  19715. return $this->source;
  19716. }
  19717. public function getTarget()
  19718. {
  19719. return $this->target;
  19720. }
  19721. public function getConstraint()
  19722. {
  19723. return $this->constraint;
  19724. }
  19725. public function getPrettyConstraint()
  19726. {
  19727. if (null === $this->prettyConstraint) {
  19728. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  19729. }
  19730. return $this->prettyConstraint;
  19731. }
  19732. public function __toString()
  19733. {
  19734. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  19735. }
  19736. public function getPrettyString(PackageInterface $sourcePackage)
  19737. {
  19738. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.($this->constraint ? ' '.$this->constraint->getPrettyString() : '');
  19739. }
  19740. }
  19741. <?php
  19742. namespace Composer\Package\Loader;
  19743. use Composer\Package;
  19744. use Composer\Package\AliasPackage;
  19745. use Composer\Package\Link;
  19746. use Composer\Package\RootAliasPackage;
  19747. use Composer\Package\RootPackageInterface;
  19748. use Composer\Package\Version\VersionParser;
  19749. class ArrayLoader implements LoaderInterface
  19750. {
  19751. protected $versionParser;
  19752. protected $loadOptions;
  19753. public function __construct(VersionParser $parser = null, $loadOptions = false)
  19754. {
  19755. if (!$parser) {
  19756. $parser = new VersionParser;
  19757. }
  19758. $this->versionParser = $parser;
  19759. $this->loadOptions = $loadOptions;
  19760. }
  19761. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  19762. {
  19763. $package = $this->createObject($config, $class);
  19764. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19765. if (isset($config[$type])) {
  19766. $method = 'set'.ucfirst($opts['method']);
  19767. $package->{$method}(
  19768. $this->parseLinks(
  19769. $package->getName(),
  19770. $package->getPrettyVersion(),
  19771. $opts['description'],
  19772. $config[$type]
  19773. )
  19774. );
  19775. }
  19776. }
  19777. $package = $this->configureObject($package, $config);
  19778. return $package;
  19779. }
  19780. public function loadPackages(array $versions, $class)
  19781. {
  19782. $packages = array();
  19783. $linkCache = array();
  19784. foreach ($versions as $version) {
  19785. $package = $this->createObject($version, $class);
  19786. $this->configureCachedLinks($linkCache, $package, $version);
  19787. $package = $this->configureObject($package, $version);
  19788. $packages[] = $package;
  19789. }
  19790. return $packages;
  19791. }
  19792. private function createObject(array $config, $class)
  19793. {
  19794. if (!isset($config['name'])) {
  19795. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  19796. }
  19797. if (!isset($config['version'])) {
  19798. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  19799. }
  19800. if (isset($config['version_normalized'])) {
  19801. $version = $config['version_normalized'];
  19802. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  19803. $version = $this->versionParser->normalize($config['version']);
  19804. }
  19805. } else {
  19806. $version = $this->versionParser->normalize($config['version']);
  19807. }
  19808. return new $class($config['name'], $version, $config['version']);
  19809. }
  19810. private function configureObject($package, array $config)
  19811. {
  19812. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  19813. if (isset($config['target-dir'])) {
  19814. $package->setTargetDir($config['target-dir']);
  19815. }
  19816. if (isset($config['extra']) && \is_array($config['extra'])) {
  19817. $package->setExtra($config['extra']);
  19818. }
  19819. if (isset($config['bin'])) {
  19820. if (!\is_array($config['bin'])) {
  19821. $config['bin'] = array($config['bin']);
  19822. }
  19823. foreach ($config['bin'] as $key => $bin) {
  19824. $config['bin'][$key] = ltrim($bin, '/');
  19825. }
  19826. $package->setBinaries($config['bin']);
  19827. }
  19828. if (isset($config['installation-source'])) {
  19829. $package->setInstallationSource($config['installation-source']);
  19830. }
  19831. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19832. $package->setIsDefaultBranch(true);
  19833. }
  19834. if (isset($config['source'])) {
  19835. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  19836. throw new \UnexpectedValueException(sprintf(
  19837. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  19838. $config['name'],
  19839. json_encode($config['source'])
  19840. ));
  19841. }
  19842. $package->setSourceType($config['source']['type']);
  19843. $package->setSourceUrl($config['source']['url']);
  19844. $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
  19845. if (isset($config['source']['mirrors'])) {
  19846. $package->setSourceMirrors($config['source']['mirrors']);
  19847. }
  19848. }
  19849. if (isset($config['dist'])) {
  19850. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  19851. throw new \UnexpectedValueException(sprintf(
  19852. "Package %s's dist key should be specified as ".
  19853. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  19854. $config['name'],
  19855. json_encode($config['dist'])
  19856. ));
  19857. }
  19858. $package->setDistType($config['dist']['type']);
  19859. $package->setDistUrl($config['dist']['url']);
  19860. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  19861. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  19862. if (isset($config['dist']['mirrors'])) {
  19863. $package->setDistMirrors($config['dist']['mirrors']);
  19864. }
  19865. }
  19866. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  19867. foreach ($config['suggest'] as $target => $reason) {
  19868. if ('self.version' === trim($reason)) {
  19869. $config['suggest'][$target] = $package->getPrettyVersion();
  19870. }
  19871. }
  19872. $package->setSuggests($config['suggest']);
  19873. }
  19874. if (isset($config['autoload'])) {
  19875. $package->setAutoload($config['autoload']);
  19876. }
  19877. if (isset($config['autoload-dev'])) {
  19878. $package->setDevAutoload($config['autoload-dev']);
  19879. }
  19880. if (isset($config['include-path'])) {
  19881. $package->setIncludePaths($config['include-path']);
  19882. }
  19883. if (!empty($config['time'])) {
  19884. $time = preg_match('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  19885. try {
  19886. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  19887. $package->setReleaseDate($date);
  19888. } catch (\Exception $e) {
  19889. }
  19890. }
  19891. if (!empty($config['notification-url'])) {
  19892. $package->setNotificationUrl($config['notification-url']);
  19893. }
  19894. if (!empty($config['archive']['name'])) {
  19895. $package->setArchiveName($config['archive']['name']);
  19896. }
  19897. if (!empty($config['archive']['exclude'])) {
  19898. $package->setArchiveExcludes($config['archive']['exclude']);
  19899. }
  19900. if ($package instanceof Package\CompletePackageInterface) {
  19901. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  19902. foreach ($config['scripts'] as $event => $listeners) {
  19903. $config['scripts'][$event] = (array) $listeners;
  19904. }
  19905. if (isset($config['scripts']['composer'])) {
  19906. trigger_error('The `composer` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  19907. }
  19908. $package->setScripts($config['scripts']);
  19909. }
  19910. if (!empty($config['description']) && \is_string($config['description'])) {
  19911. $package->setDescription($config['description']);
  19912. }
  19913. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  19914. $package->setHomepage($config['homepage']);
  19915. }
  19916. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  19917. $package->setKeywords($config['keywords']);
  19918. }
  19919. if (!empty($config['license'])) {
  19920. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  19921. }
  19922. if (!empty($config['authors']) && \is_array($config['authors'])) {
  19923. $package->setAuthors($config['authors']);
  19924. }
  19925. if (isset($config['support'])) {
  19926. $package->setSupport($config['support']);
  19927. }
  19928. if (!empty($config['funding']) && \is_array($config['funding'])) {
  19929. $package->setFunding($config['funding']);
  19930. }
  19931. if (isset($config['abandoned'])) {
  19932. $package->setAbandoned($config['abandoned']);
  19933. }
  19934. }
  19935. if ($this->loadOptions && isset($config['transport-options'])) {
  19936. $package->setTransportOptions($config['transport-options']);
  19937. }
  19938. if ($aliasNormalized = $this->getBranchAlias($config)) {
  19939. $prettyAlias = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
  19940. if ($package instanceof RootPackageInterface) {
  19941. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  19942. }
  19943. return new AliasPackage($package, $aliasNormalized, $prettyAlias);
  19944. }
  19945. return $package;
  19946. }
  19947. private function configureCachedLinks(&$linkCache, $package, array $config)
  19948. {
  19949. $name = $package->getName();
  19950. $prettyVersion = $package->getPrettyVersion();
  19951. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19952. if (isset($config[$type])) {
  19953. $method = 'set'.ucfirst($opts['method']);
  19954. $links = array();
  19955. foreach ($config[$type] as $prettyTarget => $constraint) {
  19956. $target = strtolower($prettyTarget);
  19957. if ($constraint === 'self.version') {
  19958. $links[$target] = $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint);
  19959. } else {
  19960. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  19961. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint));
  19962. }
  19963. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  19964. $links[$target] = $link;
  19965. }
  19966. }
  19967. $package->{$method}($links);
  19968. }
  19969. }
  19970. }
  19971. public function parseLinks($source, $sourceVersion, $description, $links)
  19972. {
  19973. $res = array();
  19974. foreach ($links as $target => $constraint) {
  19975. $res[strtolower($target)] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  19976. }
  19977. return $res;
  19978. }
  19979. private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
  19980. {
  19981. if (!\is_string($prettyConstraint)) {
  19982. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  19983. }
  19984. if ('self.version' === $prettyConstraint) {
  19985. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  19986. } else {
  19987. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  19988. }
  19989. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  19990. }
  19991. public function getBranchAlias(array $config)
  19992. {
  19993. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  19994. return;
  19995. }
  19996. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  19997. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  19998. if ('-dev' !== substr($targetBranch, -4)) {
  19999. continue;
  20000. }
  20001. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  20002. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  20003. } else {
  20004. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  20005. }
  20006. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  20007. continue;
  20008. }
  20009. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  20010. continue;
  20011. }
  20012. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  20013. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  20014. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  20015. ) {
  20016. continue;
  20017. }
  20018. return $validatedTargetBranch;
  20019. }
  20020. }
  20021. if (
  20022. isset($config['default-branch'])
  20023. && $config['default-branch'] === true
  20024. && false === $this->versionParser->parseNumericAliasPrefix($config['version'])
  20025. ) {
  20026. return VersionParser::DEFAULT_BRANCH_ALIAS;
  20027. }
  20028. }
  20029. }
  20030. <?php
  20031. namespace Composer\Package\Loader;
  20032. class InvalidPackageException extends \Exception
  20033. {
  20034. private $errors;
  20035. private $warnings;
  20036. private $data;
  20037. public function __construct(array $errors, array $warnings, array $data)
  20038. {
  20039. $this->errors = $errors;
  20040. $this->warnings = $warnings;
  20041. $this->data = $data;
  20042. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  20043. }
  20044. public function getData()
  20045. {
  20046. return $this->data;
  20047. }
  20048. public function getErrors()
  20049. {
  20050. return $this->errors;
  20051. }
  20052. public function getWarnings()
  20053. {
  20054. return $this->warnings;
  20055. }
  20056. }
  20057. <?php
  20058. namespace Composer\Package\Loader;
  20059. use Composer\Json\JsonFile;
  20060. class JsonLoader
  20061. {
  20062. private $loader;
  20063. public function __construct(LoaderInterface $loader)
  20064. {
  20065. $this->loader = $loader;
  20066. }
  20067. public function load($json)
  20068. {
  20069. if ($json instanceof JsonFile) {
  20070. $config = $json->read();
  20071. } elseif (file_exists($json)) {
  20072. $config = JsonFile::parseJson(file_get_contents($json), $json);
  20073. } elseif (is_string($json)) {
  20074. $config = JsonFile::parseJson($json);
  20075. } else {
  20076. throw new \InvalidArgumentException(sprintf(
  20077. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  20078. gettype($json)
  20079. ));
  20080. }
  20081. return $this->loader->load($config);
  20082. }
  20083. }
  20084. <?php
  20085. namespace Composer\Package\Loader;
  20086. interface LoaderInterface
  20087. {
  20088. public function load(array $package, $class = 'Composer\Package\CompletePackage');
  20089. }
  20090. <?php
  20091. namespace Composer\Package\Loader;
  20092. use Composer\Package\BasePackage;
  20093. use Composer\Package\AliasPackage;
  20094. use Composer\Config;
  20095. use Composer\IO\IOInterface;
  20096. use Composer\Package\RootPackageInterface;
  20097. use Composer\Repository\RepositoryFactory;
  20098. use Composer\Package\Version\VersionGuesser;
  20099. use Composer\Package\Version\VersionParser;
  20100. use Composer\Package\RootPackage;
  20101. use Composer\Repository\RepositoryManager;
  20102. use Composer\Util\ProcessExecutor;
  20103. class RootPackageLoader extends ArrayLoader
  20104. {
  20105. private $manager;
  20106. private $config;
  20107. private $versionGuesser;
  20108. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  20109. {
  20110. parent::__construct($parser);
  20111. $this->manager = $manager;
  20112. $this->config = $config;
  20113. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  20114. }
  20115. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  20116. {
  20117. if (!isset($config['name'])) {
  20118. $config['name'] = '__root__';
  20119. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  20120. throw new \RuntimeException('Your package name '.$err);
  20121. }
  20122. $autoVersioned = false;
  20123. if (!isset($config['version'])) {
  20124. $commit = null;
  20125. if (getenv('COMPOSER_ROOT_VERSION')) {
  20126. $config['version'] = getenv('COMPOSER_ROOT_VERSION');
  20127. } else {
  20128. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  20129. if ($versionData) {
  20130. $config['version'] = $versionData['pretty_version'];
  20131. $config['version_normalized'] = $versionData['version'];
  20132. $commit = $versionData['commit'];
  20133. }
  20134. }
  20135. if (!isset($config['version'])) {
  20136. $config['version'] = '1.0.0';
  20137. $autoVersioned = true;
  20138. }
  20139. if ($commit) {
  20140. $config['source'] = array(
  20141. 'type' => '',
  20142. 'url' => '',
  20143. 'reference' => $commit,
  20144. );
  20145. $config['dist'] = array(
  20146. 'type' => '',
  20147. 'url' => '',
  20148. 'reference' => $commit,
  20149. );
  20150. }
  20151. }
  20152. $realPackage = $package = parent::load($config, $class);
  20153. if ($realPackage instanceof AliasPackage) {
  20154. $realPackage = $package->getAliasOf();
  20155. }
  20156. if ($autoVersioned) {
  20157. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  20158. }
  20159. if (isset($config['minimum-stability'])) {
  20160. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  20161. }
  20162. $aliases = array();
  20163. $stabilityFlags = array();
  20164. $references = array();
  20165. foreach (array('require', 'require-dev') as $linkType) {
  20166. if (isset($config[$linkType])) {
  20167. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  20168. $method = 'get'.ucfirst($linkInfo['method']);
  20169. $links = array();
  20170. foreach ($realPackage->$method() as $link) {
  20171. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  20172. }
  20173. $aliases = $this->extractAliases($links, $aliases);
  20174. $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
  20175. $references = $this->extractReferences($links, $references);
  20176. if (isset($links[$config['name']])) {
  20177. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  20178. 'Did you accidentally name your root package after an external package?', $config['name']));
  20179. }
  20180. }
  20181. }
  20182. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20183. if (isset($config[$linkType])) {
  20184. foreach ($config[$linkType] as $linkName => $constraint) {
  20185. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  20186. throw new \RuntimeException($linkType.'.'.$err);
  20187. }
  20188. }
  20189. }
  20190. }
  20191. $realPackage->setAliases($aliases);
  20192. $realPackage->setStabilityFlags($stabilityFlags);
  20193. $realPackage->setReferences($references);
  20194. if (isset($config['prefer-stable'])) {
  20195. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  20196. }
  20197. if (isset($config['config'])) {
  20198. $realPackage->setConfig($config['config']);
  20199. }
  20200. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  20201. foreach ($repos as $repo) {
  20202. $this->manager->addRepository($repo);
  20203. }
  20204. $realPackage->setRepositories($this->config->getRepositories());
  20205. return $package;
  20206. }
  20207. private function extractAliases(array $requires, array $aliases)
  20208. {
  20209. foreach ($requires as $reqName => $reqVersion) {
  20210. if (preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  20211. $aliases[] = array(
  20212. 'package' => strtolower($reqName),
  20213. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  20214. 'alias' => $match[2],
  20215. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  20216. );
  20217. } elseif (strpos($reqVersion, ' as ') !== false) {
  20218. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  20219. }
  20220. }
  20221. return $aliases;
  20222. }
  20223. private function extractStabilityFlags(array $requires, array $stabilityFlags, $minimumStability)
  20224. {
  20225. $stabilities = BasePackage::$stabilities;
  20226. $minimumStability = $stabilities[$minimumStability];
  20227. foreach ($requires as $reqName => $reqVersion) {
  20228. $constraints = array();
  20229. $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
  20230. foreach ($orSplit as $orConstraint) {
  20231. $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  20232. foreach ($andSplit as $andConstraint) {
  20233. $constraints[] = $andConstraint;
  20234. }
  20235. }
  20236. $match = false;
  20237. foreach ($constraints as $constraint) {
  20238. if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  20239. $name = strtolower($reqName);
  20240. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  20241. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  20242. continue;
  20243. }
  20244. $stabilityFlags[$name] = $stability;
  20245. $match = true;
  20246. }
  20247. }
  20248. if ($match) {
  20249. continue;
  20250. }
  20251. foreach ($constraints as $constraint) {
  20252. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  20253. if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  20254. $name = strtolower($reqName);
  20255. $stability = $stabilities[$stabilityName];
  20256. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  20257. continue;
  20258. }
  20259. $stabilityFlags[$name] = $stability;
  20260. }
  20261. }
  20262. }
  20263. return $stabilityFlags;
  20264. }
  20265. private function extractReferences(array $requires, array $references)
  20266. {
  20267. foreach ($requires as $reqName => $reqVersion) {
  20268. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  20269. if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  20270. $name = strtolower($reqName);
  20271. $references[$name] = $match[1];
  20272. }
  20273. }
  20274. return $references;
  20275. }
  20276. }
  20277. <?php
  20278. namespace Composer\Package\Loader;
  20279. use Composer\Package\BasePackage;
  20280. use Composer\Semver\Constraint\Constraint;
  20281. use Composer\Package\Version\VersionParser;
  20282. use Composer\Repository\PlatformRepository;
  20283. use Composer\Spdx\SpdxLicenses;
  20284. class ValidatingArrayLoader implements LoaderInterface
  20285. {
  20286. const CHECK_ALL = 3;
  20287. const CHECK_UNBOUND_CONSTRAINTS = 1;
  20288. const CHECK_STRICT_CONSTRAINTS = 2;
  20289. private $loader;
  20290. private $versionParser;
  20291. private $errors;
  20292. private $warnings;
  20293. private $config;
  20294. private $strictName;
  20295. private $flags;
  20296. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  20297. {
  20298. $this->loader = $loader;
  20299. $this->versionParser = $parser ?: new VersionParser();
  20300. $this->strictName = $strictName;
  20301. $this->flags = $flags;
  20302. }
  20303. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  20304. {
  20305. $this->errors = array();
  20306. $this->warnings = array();
  20307. $this->config = $config;
  20308. if ($err = self::hasPackageNamingError($config['name'])) {
  20309. $this->warnings[] = 'Deprecation warning: Your package name '.$err.' Make sure you fix this as Composer 2.0 will error.';
  20310. }
  20311. if ($this->strictName) {
  20312. $this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
  20313. } else {
  20314. $this->validateString('name', true);
  20315. }
  20316. if (!empty($this->config['version'])) {
  20317. try {
  20318. $this->versionParser->normalize($this->config['version']);
  20319. } catch (\Exception $e) {
  20320. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  20321. unset($this->config['version']);
  20322. }
  20323. }
  20324. if (!empty($this->config['config']['platform'])) {
  20325. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  20326. try {
  20327. $this->versionParser->normalize($platform);
  20328. } catch (\Exception $e) {
  20329. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  20330. }
  20331. }
  20332. }
  20333. $this->validateRegex('type', '[A-Za-z0-9-]+');
  20334. $this->validateString('target-dir');
  20335. $this->validateArray('extra');
  20336. if (isset($this->config['bin'])) {
  20337. if (is_string($this->config['bin'])) {
  20338. $this->validateString('bin');
  20339. } else {
  20340. $this->validateFlatArray('bin');
  20341. }
  20342. }
  20343. $this->validateArray('scripts');
  20344. $this->validateString('description');
  20345. $this->validateUrl('homepage');
  20346. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  20347. $releaseDate = null;
  20348. $this->validateString('time');
  20349. if (!empty($this->config['time'])) {
  20350. try {
  20351. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  20352. } catch (\Exception $e) {
  20353. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  20354. unset($this->config['time']);
  20355. }
  20356. }
  20357. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  20358. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  20359. $licenses = (array) $this->config['license'];
  20360. $licenseValidator = new SpdxLicenses();
  20361. foreach ($licenses as $license) {
  20362. if ('proprietary' === $license) {
  20363. continue;
  20364. }
  20365. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  20366. if (!$licenseValidator->validate($licenseToValidate)) {
  20367. if ($licenseValidator->validate(trim($licenseToValidate))) {
  20368. $this->warnings[] = sprintf(
  20369. 'License %s must not contain extra spaces, make sure to trim it.',
  20370. json_encode($license)
  20371. );
  20372. } else {
  20373. $this->warnings[] = sprintf(
  20374. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  20375. 'If the software is closed-source, you may use "proprietary" as license.',
  20376. json_encode($license)
  20377. );
  20378. }
  20379. }
  20380. }
  20381. }
  20382. }
  20383. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  20384. foreach ($this->config['authors'] as $key => $author) {
  20385. if (!is_array($author)) {
  20386. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  20387. unset($this->config['authors'][$key]);
  20388. continue;
  20389. }
  20390. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  20391. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  20392. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  20393. unset($this->config['authors'][$key][$authorData]);
  20394. }
  20395. }
  20396. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  20397. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  20398. unset($this->config['authors'][$key]['homepage']);
  20399. }
  20400. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  20401. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  20402. unset($this->config['authors'][$key]['email']);
  20403. }
  20404. if (empty($this->config['authors'][$key])) {
  20405. unset($this->config['authors'][$key]);
  20406. }
  20407. }
  20408. if (empty($this->config['authors'])) {
  20409. unset($this->config['authors']);
  20410. }
  20411. }
  20412. if ($this->validateArray('support') && !empty($this->config['support'])) {
  20413. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  20414. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  20415. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  20416. unset($this->config['support'][$key]);
  20417. }
  20418. }
  20419. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  20420. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  20421. unset($this->config['support']['email']);
  20422. }
  20423. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc'))) {
  20424. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> URL';
  20425. unset($this->config['support']['irc']);
  20426. }
  20427. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  20428. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  20429. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  20430. unset($this->config['support'][$key]);
  20431. }
  20432. }
  20433. if (empty($this->config['support'])) {
  20434. unset($this->config['support']);
  20435. }
  20436. }
  20437. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  20438. foreach ($this->config['funding'] as $key => $fundingOption) {
  20439. if (!is_array($fundingOption)) {
  20440. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  20441. unset($this->config['funding'][$key]);
  20442. continue;
  20443. }
  20444. foreach (array('type', 'url') as $fundingData) {
  20445. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  20446. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  20447. unset($this->config['funding'][$key][$fundingData]);
  20448. }
  20449. }
  20450. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  20451. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  20452. unset($this->config['funding'][$key]['url']);
  20453. }
  20454. if (empty($this->config['funding'][$key])) {
  20455. unset($this->config['funding'][$key]);
  20456. }
  20457. }
  20458. if (empty($this->config['funding'])) {
  20459. unset($this->config['funding']);
  20460. }
  20461. }
  20462. $unboundConstraint = new Constraint('=', '10000000-dev');
  20463. $stableConstraint = new Constraint('=', '1.0.0');
  20464. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20465. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  20466. foreach ($this->config[$linkType] as $package => $constraint) {
  20467. if ($err = self::hasPackageNamingError($package, true)) {
  20468. $this->warnings[] = 'Deprecation warning: '.$linkType.'.'.$err.' Make sure you fix this as Composer 2.0 will error.';
  20469. } elseif (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
  20470. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  20471. }
  20472. if (!is_string($constraint)) {
  20473. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  20474. unset($this->config[$linkType][$package]);
  20475. } elseif ('self.version' !== $constraint) {
  20476. try {
  20477. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  20478. } catch (\Exception $e) {
  20479. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  20480. unset($this->config[$linkType][$package]);
  20481. continue;
  20482. }
  20483. if (
  20484. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  20485. && 'require' === $linkType
  20486. && $linkConstraint->matches($unboundConstraint)
  20487. && !PlatformRepository::isPlatformPackage($package)
  20488. ) {
  20489. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  20490. } elseif (
  20491. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  20492. && 'require' === $linkType
  20493. && strpos($linkConstraint, '=') === 0
  20494. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  20495. ) {
  20496. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  20497. }
  20498. }
  20499. }
  20500. }
  20501. }
  20502. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  20503. foreach ($this->config['suggest'] as $package => $description) {
  20504. if (!is_string($description)) {
  20505. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  20506. unset($this->config['suggest'][$package]);
  20507. }
  20508. }
  20509. }
  20510. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  20511. if (!isset(BasePackage::$stabilities[$this->config['minimum-stability']])) {
  20512. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  20513. unset($this->config['minimum-stability']);
  20514. }
  20515. }
  20516. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  20517. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  20518. foreach ($this->config['autoload'] as $type => $typeConfig) {
  20519. if (!in_array($type, $types)) {
  20520. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  20521. unset($this->config['autoload'][$type]);
  20522. }
  20523. if ($type === 'psr-4') {
  20524. foreach ($typeConfig as $namespace => $dirs) {
  20525. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  20526. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  20527. }
  20528. }
  20529. }
  20530. }
  20531. }
  20532. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  20533. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  20534. unset($this->config['autoload']['psr-4']);
  20535. }
  20536. $this->validateFlatArray('include-path');
  20537. $this->validateArray('transport-options');
  20538. if (isset($this->config['extra']['branch-alias'])) {
  20539. if (!is_array($this->config['extra']['branch-alias'])) {
  20540. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  20541. } else {
  20542. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  20543. if ('-dev' !== substr($targetBranch, -4)) {
  20544. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  20545. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20546. continue;
  20547. }
  20548. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  20549. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  20550. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  20551. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20552. continue;
  20553. }
  20554. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  20555. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  20556. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  20557. ) {
  20558. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  20559. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20560. }
  20561. }
  20562. }
  20563. }
  20564. if ($this->errors) {
  20565. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  20566. }
  20567. $package = $this->loader->load($this->config, $class);
  20568. $this->config = null;
  20569. return $package;
  20570. }
  20571. public function getWarnings()
  20572. {
  20573. return $this->warnings;
  20574. }
  20575. public function getErrors()
  20576. {
  20577. return $this->errors;
  20578. }
  20579. public static function hasPackageNamingError($name, $isLink = false)
  20580. {
  20581. if (PlatformRepository::isPlatformPackage($name)) {
  20582. return;
  20583. }
  20584. if (!preg_match('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  20585. return $name.' is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$".';
  20586. }
  20587. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  20588. $bits = explode('/', strtolower($name));
  20589. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  20590. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  20591. }
  20592. if (preg_match('{\.json$}', $name)) {
  20593. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  20594. }
  20595. if (preg_match('{[A-Z]}', $name)) {
  20596. if ($isLink) {
  20597. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  20598. }
  20599. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  20600. $suggestName = strtolower($suggestName);
  20601. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  20602. }
  20603. }
  20604. private function validateRegex($property, $regex, $mandatory = false)
  20605. {
  20606. if (!$this->validateString($property, $mandatory)) {
  20607. return false;
  20608. }
  20609. if (!preg_match('{^'.$regex.'$}u', $this->config[$property])) {
  20610. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  20611. if ($mandatory) {
  20612. $this->errors[] = $message;
  20613. } else {
  20614. $this->warnings[] = $message;
  20615. }
  20616. unset($this->config[$property]);
  20617. return false;
  20618. }
  20619. return true;
  20620. }
  20621. private function validateString($property, $mandatory = false)
  20622. {
  20623. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  20624. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  20625. unset($this->config[$property]);
  20626. return false;
  20627. }
  20628. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  20629. if ($mandatory) {
  20630. $this->errors[] = $property.' : must be present';
  20631. }
  20632. unset($this->config[$property]);
  20633. return false;
  20634. }
  20635. return true;
  20636. }
  20637. private function validateArray($property, $mandatory = false)
  20638. {
  20639. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  20640. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  20641. unset($this->config[$property]);
  20642. return false;
  20643. }
  20644. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  20645. if ($mandatory) {
  20646. $this->errors[] = $property.' : must be present and contain at least one element';
  20647. }
  20648. unset($this->config[$property]);
  20649. return false;
  20650. }
  20651. return true;
  20652. }
  20653. private function validateFlatArray($property, $regex = null, $mandatory = false)
  20654. {
  20655. if (!$this->validateArray($property, $mandatory)) {
  20656. return false;
  20657. }
  20658. $pass = true;
  20659. foreach ($this->config[$property] as $key => $value) {
  20660. if (!is_string($value) && !is_numeric($value)) {
  20661. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  20662. unset($this->config[$property][$key]);
  20663. $pass = false;
  20664. continue;
  20665. }
  20666. if ($regex && !preg_match('{^'.$regex.'$}u', $value)) {
  20667. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  20668. unset($this->config[$property][$key]);
  20669. $pass = false;
  20670. }
  20671. }
  20672. return $pass;
  20673. }
  20674. private function validateUrl($property, $mandatory = false)
  20675. {
  20676. if (!$this->validateString($property, $mandatory)) {
  20677. return false;
  20678. }
  20679. if (!$this->filterUrl($this->config[$property])) {
  20680. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  20681. unset($this->config[$property]);
  20682. return false;
  20683. }
  20684. return true;
  20685. }
  20686. private function filterUrl($value, array $schemes = array('http', 'https'))
  20687. {
  20688. if ($value === '') {
  20689. return true;
  20690. }
  20691. $bits = parse_url($value);
  20692. if (empty($bits['scheme']) || empty($bits['host'])) {
  20693. return false;
  20694. }
  20695. if (!in_array($bits['scheme'], $schemes, true)) {
  20696. return false;
  20697. }
  20698. return true;
  20699. }
  20700. }
  20701. <?php
  20702. namespace Composer\Package;
  20703. use Composer\Json\JsonFile;
  20704. use Composer\Installer\InstallationManager;
  20705. use Composer\Repository\LockArrayRepository;
  20706. use Composer\Util\ProcessExecutor;
  20707. use Composer\Package\Dumper\ArrayDumper;
  20708. use Composer\Package\Loader\ArrayLoader;
  20709. use Composer\Package\Version\VersionParser;
  20710. use Composer\Plugin\PluginInterface;
  20711. use Composer\Util\Git as GitUtil;
  20712. use Composer\IO\IOInterface;
  20713. use Seld\JsonLint\ParsingException;
  20714. class Locker
  20715. {
  20716. private $lockFile;
  20717. private $installationManager;
  20718. private $hash;
  20719. private $contentHash;
  20720. private $loader;
  20721. private $dumper;
  20722. private $process;
  20723. private $lockDataCache;
  20724. private $virtualFileWritten;
  20725. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents, ProcessExecutor $process = null)
  20726. {
  20727. $this->lockFile = $lockFile;
  20728. $this->installationManager = $installationManager;
  20729. $this->hash = md5($composerFileContents);
  20730. $this->contentHash = self::getContentHash($composerFileContents);
  20731. $this->loader = new ArrayLoader(null, true);
  20732. $this->dumper = new ArrayDumper();
  20733. $this->process = $process ?: new ProcessExecutor($io);
  20734. }
  20735. public static function getContentHash($composerFileContents)
  20736. {
  20737. $content = json_decode($composerFileContents, true);
  20738. $relevantKeys = array(
  20739. 'name',
  20740. 'version',
  20741. 'require',
  20742. 'require-dev',
  20743. 'conflict',
  20744. 'replace',
  20745. 'provide',
  20746. 'minimum-stability',
  20747. 'prefer-stable',
  20748. 'repositories',
  20749. 'extra',
  20750. );
  20751. $relevantContent = array();
  20752. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  20753. $relevantContent[$key] = $content[$key];
  20754. }
  20755. if (isset($content['config']['platform'])) {
  20756. $relevantContent['config']['platform'] = $content['config']['platform'];
  20757. }
  20758. ksort($relevantContent);
  20759. return md5(json_encode($relevantContent));
  20760. }
  20761. public function isLocked()
  20762. {
  20763. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  20764. return false;
  20765. }
  20766. $data = $this->getLockData();
  20767. return isset($data['packages']);
  20768. }
  20769. public function isFresh()
  20770. {
  20771. $lock = $this->lockFile->read();
  20772. if (!empty($lock['content-hash'])) {
  20773. return $this->contentHash === $lock['content-hash'];
  20774. }
  20775. if (!empty($lock['hash'])) {
  20776. return $this->hash === $lock['hash'];
  20777. }
  20778. return false;
  20779. }
  20780. public function getLockedRepository($withDevReqs = false)
  20781. {
  20782. $lockData = $this->getLockData();
  20783. $packages = new LockArrayRepository();
  20784. $lockedPackages = $lockData['packages'];
  20785. if ($withDevReqs) {
  20786. if (isset($lockData['packages-dev'])) {
  20787. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  20788. } else {
  20789. throw new \RuntimeException('The lock file does not contain require-dev information, run install with the --no-dev option or delete it and run composer update to generate a new lock file.');
  20790. }
  20791. }
  20792. if (empty($lockedPackages)) {
  20793. return $packages;
  20794. }
  20795. if (isset($lockedPackages[0]['name'])) {
  20796. $packageByName = array();
  20797. foreach ($lockedPackages as $info) {
  20798. $package = $this->loader->load($info);
  20799. $packages->addPackage($package);
  20800. $packageByName[$package->getName()] = $package;
  20801. if ($package instanceof AliasPackage) {
  20802. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  20803. }
  20804. }
  20805. if (isset($lockData['aliases'])) {
  20806. foreach ($lockData['aliases'] as $alias) {
  20807. if (isset($packageByName[$alias['package']])) {
  20808. $aliasPkg = new AliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  20809. $aliasPkg->setRootPackageAlias(true);
  20810. $packages->addPackage($aliasPkg);
  20811. }
  20812. }
  20813. }
  20814. return $packages;
  20815. }
  20816. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  20817. }
  20818. public function getDevPackageNames()
  20819. {
  20820. $names = array();
  20821. $lockData = $this->getLockData();
  20822. if (isset($lockData['packages-dev'])) {
  20823. foreach ($lockData['packages-dev'] as $package) {
  20824. $names[] = strtolower($package['name']);
  20825. }
  20826. }
  20827. return $names;
  20828. }
  20829. public function getPlatformRequirements($withDevReqs = false)
  20830. {
  20831. $lockData = $this->getLockData();
  20832. $requirements = array();
  20833. if (!empty($lockData['platform'])) {
  20834. $requirements = $this->loader->parseLinks(
  20835. '__root__',
  20836. '1.0.0',
  20837. Link::TYPE_REQUIRE,
  20838. isset($lockData['platform']) ? $lockData['platform'] : array()
  20839. );
  20840. }
  20841. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  20842. $devRequirements = $this->loader->parseLinks(
  20843. '__root__',
  20844. '1.0.0',
  20845. Link::TYPE_REQUIRE,
  20846. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  20847. );
  20848. $requirements = array_merge($requirements, $devRequirements);
  20849. }
  20850. return $requirements;
  20851. }
  20852. public function getMinimumStability()
  20853. {
  20854. $lockData = $this->getLockData();
  20855. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  20856. }
  20857. public function getStabilityFlags()
  20858. {
  20859. $lockData = $this->getLockData();
  20860. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  20861. }
  20862. public function getPreferStable()
  20863. {
  20864. $lockData = $this->getLockData();
  20865. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  20866. }
  20867. public function getPreferLowest()
  20868. {
  20869. $lockData = $this->getLockData();
  20870. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  20871. }
  20872. public function getPlatformOverrides()
  20873. {
  20874. $lockData = $this->getLockData();
  20875. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  20876. }
  20877. public function getAliases()
  20878. {
  20879. $lockData = $this->getLockData();
  20880. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  20881. }
  20882. public function getLockData()
  20883. {
  20884. if (null !== $this->lockDataCache) {
  20885. return $this->lockDataCache;
  20886. }
  20887. if (!$this->lockFile->exists()) {
  20888. throw new \LogicException('No lockfile found. Unable to read locked packages');
  20889. }
  20890. return $this->lockDataCache = $this->lockFile->read();
  20891. }
  20892. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
  20893. {
  20894. $aliases = array_map(function ($alias) {
  20895. if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  20896. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  20897. }
  20898. return $alias;
  20899. }, $aliases);
  20900. $lock = array(
  20901. '_readme' => array('This file locks the dependencies of your project to a known state',
  20902. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  20903. 'This file is @gener'.'ated automatically', ),
  20904. 'content-hash' => $this->contentHash,
  20905. 'packages' => null,
  20906. 'packages-dev' => null,
  20907. 'aliases' => $aliases,
  20908. 'minimum-stability' => $minimumStability,
  20909. 'stability-flags' => $stabilityFlags,
  20910. 'prefer-stable' => $preferStable,
  20911. 'prefer-lowest' => $preferLowest,
  20912. );
  20913. $lock['packages'] = $this->lockPackages($packages);
  20914. if (null !== $devPackages) {
  20915. $lock['packages-dev'] = $this->lockPackages($devPackages);
  20916. }
  20917. $lock['platform'] = $platformReqs;
  20918. $lock['platform-dev'] = $platformDevReqs;
  20919. if ($platformOverrides) {
  20920. $lock['platform-overrides'] = $platformOverrides;
  20921. }
  20922. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  20923. try {
  20924. $isLocked = $this->isLocked();
  20925. } catch (ParsingException $e) {
  20926. $isLocked = false;
  20927. }
  20928. if (!$isLocked || $lock !== $this->getLockData()) {
  20929. if ($write) {
  20930. $this->lockFile->write($lock);
  20931. $this->lockDataCache = null;
  20932. $this->virtualFileWritten = false;
  20933. } else {
  20934. $this->virtualFileWritten = true;
  20935. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT));
  20936. }
  20937. return true;
  20938. }
  20939. return false;
  20940. }
  20941. private function lockPackages(array $packages)
  20942. {
  20943. $locked = array();
  20944. foreach ($packages as $package) {
  20945. if ($package instanceof AliasPackage) {
  20946. continue;
  20947. }
  20948. $name = $package->getPrettyName();
  20949. $version = $package->getPrettyVersion();
  20950. if (!$name || !$version) {
  20951. throw new \LogicException(sprintf(
  20952. 'Package "%s" has no version or name and can not be locked',
  20953. $package
  20954. ));
  20955. }
  20956. $spec = $this->dumper->dump($package);
  20957. unset($spec['version_normalized']);
  20958. $time = isset($spec['time']) ? $spec['time'] : null;
  20959. unset($spec['time']);
  20960. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  20961. $time = $this->getPackageTime($package) ?: $time;
  20962. }
  20963. if (null !== $time) {
  20964. $spec['time'] = $time;
  20965. }
  20966. unset($spec['installation-source']);
  20967. $locked[] = $spec;
  20968. }
  20969. usort($locked, function ($a, $b) {
  20970. $comparison = strcmp($a['name'], $b['name']);
  20971. if (0 !== $comparison) {
  20972. return $comparison;
  20973. }
  20974. return strcmp($a['version'], $b['version']);
  20975. });
  20976. return $locked;
  20977. }
  20978. private function getPackageTime(PackageInterface $package)
  20979. {
  20980. if (!function_exists('proc_open')) {
  20981. return null;
  20982. }
  20983. $path = realpath($this->installationManager->getInstallPath($package));
  20984. $sourceType = $package->getSourceType();
  20985. $datetime = null;
  20986. if ($path && in_array($sourceType, array('git', 'hg'))) {
  20987. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  20988. switch ($sourceType) {
  20989. case 'git':
  20990. GitUtil::cleanEnv();
  20991. if (0 === $this->process->execute('git log -n1 --pretty=%ct '.ProcessExecutor::escape($sourceRef).GitUtil::getNoShowSignatureFlag($this->process), $output, $path) && preg_match('{^\s*\d+\s*$}', $output)) {
  20992. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  20993. }
  20994. break;
  20995. case 'hg':
  20996. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) {
  20997. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  20998. }
  20999. break;
  21000. }
  21001. }
  21002. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  21003. }
  21004. }
  21005. <?php
  21006. namespace Composer\Package;
  21007. use Composer\Package\Version\VersionParser;
  21008. use Composer\Util\ComposerMirror;
  21009. class Package extends BasePackage
  21010. {
  21011. protected $type;
  21012. protected $targetDir;
  21013. protected $installationSource;
  21014. protected $sourceType;
  21015. protected $sourceUrl;
  21016. protected $sourceReference;
  21017. protected $sourceMirrors;
  21018. protected $distType;
  21019. protected $distUrl;
  21020. protected $distReference;
  21021. protected $distSha1Checksum;
  21022. protected $distMirrors;
  21023. protected $version;
  21024. protected $prettyVersion;
  21025. protected $releaseDate;
  21026. protected $extra = array();
  21027. protected $binaries = array();
  21028. protected $dev;
  21029. protected $stability;
  21030. protected $notificationUrl;
  21031. protected $requires = array();
  21032. protected $conflicts = array();
  21033. protected $provides = array();
  21034. protected $replaces = array();
  21035. protected $devRequires = array();
  21036. protected $suggests = array();
  21037. protected $autoload = array();
  21038. protected $devAutoload = array();
  21039. protected $includePaths = array();
  21040. protected $archiveName;
  21041. protected $archiveExcludes = array();
  21042. protected $isDefaultBranch = false;
  21043. public function __construct($name, $version, $prettyVersion)
  21044. {
  21045. parent::__construct($name);
  21046. $this->version = $version;
  21047. $this->prettyVersion = $prettyVersion;
  21048. $this->stability = VersionParser::parseStability($version);
  21049. $this->dev = $this->stability === 'dev';
  21050. }
  21051. public function isDev()
  21052. {
  21053. return $this->dev;
  21054. }
  21055. public function setType($type)
  21056. {
  21057. $this->type = $type;
  21058. }
  21059. public function getType()
  21060. {
  21061. return $this->type ?: 'library';
  21062. }
  21063. public function getStability()
  21064. {
  21065. return $this->stability;
  21066. }
  21067. public function setTargetDir($targetDir)
  21068. {
  21069. $this->targetDir = $targetDir;
  21070. }
  21071. public function getTargetDir()
  21072. {
  21073. if (null === $this->targetDir) {
  21074. return;
  21075. }
  21076. return ltrim(preg_replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  21077. }
  21078. public function setExtra(array $extra)
  21079. {
  21080. $this->extra = $extra;
  21081. }
  21082. public function getExtra()
  21083. {
  21084. return $this->extra;
  21085. }
  21086. public function setBinaries(array $binaries)
  21087. {
  21088. $this->binaries = $binaries;
  21089. }
  21090. public function getBinaries()
  21091. {
  21092. return $this->binaries;
  21093. }
  21094. public function setInstallationSource($type)
  21095. {
  21096. $this->installationSource = $type;
  21097. }
  21098. public function getInstallationSource()
  21099. {
  21100. return $this->installationSource;
  21101. }
  21102. public function setSourceType($type)
  21103. {
  21104. $this->sourceType = $type;
  21105. }
  21106. public function getSourceType()
  21107. {
  21108. return $this->sourceType;
  21109. }
  21110. public function setSourceUrl($url)
  21111. {
  21112. $this->sourceUrl = $url;
  21113. }
  21114. public function getSourceUrl()
  21115. {
  21116. return $this->sourceUrl;
  21117. }
  21118. public function setSourceReference($reference)
  21119. {
  21120. $this->sourceReference = $reference;
  21121. }
  21122. public function getSourceReference()
  21123. {
  21124. return $this->sourceReference;
  21125. }
  21126. public function setSourceMirrors($mirrors)
  21127. {
  21128. $this->sourceMirrors = $mirrors;
  21129. }
  21130. public function getSourceMirrors()
  21131. {
  21132. return $this->sourceMirrors;
  21133. }
  21134. public function getSourceUrls()
  21135. {
  21136. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  21137. }
  21138. public function setDistType($type)
  21139. {
  21140. $this->distType = $type;
  21141. }
  21142. public function getDistType()
  21143. {
  21144. return $this->distType;
  21145. }
  21146. public function setDistUrl($url)
  21147. {
  21148. $this->distUrl = $url;
  21149. }
  21150. public function getDistUrl()
  21151. {
  21152. return $this->distUrl;
  21153. }
  21154. public function setDistReference($reference)
  21155. {
  21156. $this->distReference = $reference;
  21157. }
  21158. public function getDistReference()
  21159. {
  21160. return $this->distReference;
  21161. }
  21162. public function setDistSha1Checksum($sha1checksum)
  21163. {
  21164. $this->distSha1Checksum = $sha1checksum;
  21165. }
  21166. public function getDistSha1Checksum()
  21167. {
  21168. return $this->distSha1Checksum;
  21169. }
  21170. public function setDistMirrors($mirrors)
  21171. {
  21172. $this->distMirrors = $mirrors;
  21173. }
  21174. public function getDistMirrors()
  21175. {
  21176. return $this->distMirrors;
  21177. }
  21178. public function getDistUrls()
  21179. {
  21180. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  21181. }
  21182. public function getVersion()
  21183. {
  21184. return $this->version;
  21185. }
  21186. public function getPrettyVersion()
  21187. {
  21188. return $this->prettyVersion;
  21189. }
  21190. public function setReleaseDate(\DateTime $releaseDate)
  21191. {
  21192. $this->releaseDate = $releaseDate;
  21193. }
  21194. public function getReleaseDate()
  21195. {
  21196. return $this->releaseDate;
  21197. }
  21198. public function setRequires(array $requires)
  21199. {
  21200. $this->requires = $requires;
  21201. }
  21202. public function getRequires()
  21203. {
  21204. return $this->requires;
  21205. }
  21206. public function setConflicts(array $conflicts)
  21207. {
  21208. $this->conflicts = $conflicts;
  21209. }
  21210. public function getConflicts()
  21211. {
  21212. return $this->conflicts;
  21213. }
  21214. public function setProvides(array $provides)
  21215. {
  21216. $this->provides = $provides;
  21217. }
  21218. public function getProvides()
  21219. {
  21220. return $this->provides;
  21221. }
  21222. public function setReplaces(array $replaces)
  21223. {
  21224. $this->replaces = $replaces;
  21225. }
  21226. public function getReplaces()
  21227. {
  21228. return $this->replaces;
  21229. }
  21230. public function setDevRequires(array $devRequires)
  21231. {
  21232. $this->devRequires = $devRequires;
  21233. }
  21234. public function getDevRequires()
  21235. {
  21236. return $this->devRequires;
  21237. }
  21238. public function setSuggests(array $suggests)
  21239. {
  21240. $this->suggests = $suggests;
  21241. }
  21242. public function getSuggests()
  21243. {
  21244. return $this->suggests;
  21245. }
  21246. public function setAutoload(array $autoload)
  21247. {
  21248. $this->autoload = $autoload;
  21249. }
  21250. public function getAutoload()
  21251. {
  21252. return $this->autoload;
  21253. }
  21254. public function setDevAutoload(array $devAutoload)
  21255. {
  21256. $this->devAutoload = $devAutoload;
  21257. }
  21258. public function getDevAutoload()
  21259. {
  21260. return $this->devAutoload;
  21261. }
  21262. public function setIncludePaths(array $includePaths)
  21263. {
  21264. $this->includePaths = $includePaths;
  21265. }
  21266. public function getIncludePaths()
  21267. {
  21268. return $this->includePaths;
  21269. }
  21270. public function setNotificationUrl($notificationUrl)
  21271. {
  21272. $this->notificationUrl = $notificationUrl;
  21273. }
  21274. public function getNotificationUrl()
  21275. {
  21276. return $this->notificationUrl;
  21277. }
  21278. public function setArchiveName($name)
  21279. {
  21280. $this->archiveName = $name;
  21281. }
  21282. public function getArchiveName()
  21283. {
  21284. return $this->archiveName;
  21285. }
  21286. public function setArchiveExcludes(array $excludes)
  21287. {
  21288. $this->archiveExcludes = $excludes;
  21289. }
  21290. public function getArchiveExcludes()
  21291. {
  21292. return $this->archiveExcludes;
  21293. }
  21294. public function setIsDefaultBranch($defaultBranch)
  21295. {
  21296. $this->isDefaultBranch = $defaultBranch;
  21297. }
  21298. public function isDefaultBranch()
  21299. {
  21300. return $this->isDefaultBranch;
  21301. }
  21302. public function setSourceDistReferences($reference)
  21303. {
  21304. $this->setSourceReference($reference);
  21305. if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())) {
  21306. $this->setDistReference($reference);
  21307. $this->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  21308. } elseif ($this->getDistReference()) {
  21309. $this->setDistReference($reference);
  21310. }
  21311. }
  21312. public function replaceVersion($version, $prettyVersion)
  21313. {
  21314. $this->version = $version;
  21315. $this->prettyVersion = $prettyVersion;
  21316. $this->stability = VersionParser::parseStability($version);
  21317. $this->dev = $this->stability === 'dev';
  21318. }
  21319. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  21320. {
  21321. if (!$url) {
  21322. return array();
  21323. }
  21324. $urls = array($url);
  21325. if ($mirrors) {
  21326. foreach ($mirrors as $mirror) {
  21327. if ($urlType === 'dist') {
  21328. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
  21329. } elseif ($urlType === 'source' && $type === 'git') {
  21330. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  21331. } elseif ($urlType === 'source' && $type === 'hg') {
  21332. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  21333. } else {
  21334. continue;
  21335. }
  21336. if (!\in_array($mirrorUrl, $urls)) {
  21337. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  21338. $func($urls, $mirrorUrl);
  21339. }
  21340. }
  21341. }
  21342. return $urls;
  21343. }
  21344. }
  21345. <?php
  21346. namespace Composer\Package;
  21347. use Composer\Repository\RepositoryInterface;
  21348. interface PackageInterface
  21349. {
  21350. const DISPLAY_SOURCE_REF_IF_DEV = 0;
  21351. const DISPLAY_SOURCE_REF = 1;
  21352. const DISPLAY_DIST_REF = 2;
  21353. public function getName();
  21354. public function getPrettyName();
  21355. public function getNames($provides = true);
  21356. public function setId($id);
  21357. public function getId();
  21358. public function isDev();
  21359. public function getType();
  21360. public function getTargetDir();
  21361. public function getExtra();
  21362. public function setInstallationSource($type);
  21363. public function getInstallationSource();
  21364. public function getSourceType();
  21365. public function getSourceUrl();
  21366. public function getSourceUrls();
  21367. public function getSourceReference();
  21368. public function getSourceMirrors();
  21369. public function getDistType();
  21370. public function getDistUrl();
  21371. public function getDistUrls();
  21372. public function getDistReference();
  21373. public function getDistSha1Checksum();
  21374. public function getDistMirrors();
  21375. public function getVersion();
  21376. public function getPrettyVersion();
  21377. public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
  21378. public function getReleaseDate();
  21379. public function getStability();
  21380. public function getRequires();
  21381. public function getConflicts();
  21382. public function getProvides();
  21383. public function getReplaces();
  21384. public function getDevRequires();
  21385. public function getSuggests();
  21386. public function getAutoload();
  21387. public function getDevAutoload();
  21388. public function getIncludePaths();
  21389. public function setRepository(RepositoryInterface $repository);
  21390. public function getRepository();
  21391. public function getBinaries();
  21392. public function getUniqueName();
  21393. public function getNotificationUrl();
  21394. public function __toString();
  21395. public function getPrettyString();
  21396. public function getArchiveName();
  21397. public function getArchiveExcludes();
  21398. public function isDefaultBranch();
  21399. public function getTransportOptions();
  21400. public function setSourceReference($reference);
  21401. public function setDistUrl($url);
  21402. public function setDistType($type);
  21403. public function setDistReference($reference);
  21404. public function setSourceDistReferences($reference);
  21405. }
  21406. <?php
  21407. namespace Composer\Package;
  21408. class RootAliasPackage extends AliasPackage implements RootPackageInterface
  21409. {
  21410. public function __construct(RootPackageInterface $aliasOf, $version, $prettyVersion)
  21411. {
  21412. parent::__construct($aliasOf, $version, $prettyVersion);
  21413. }
  21414. public function getAliases()
  21415. {
  21416. return $this->aliasOf->getAliases();
  21417. }
  21418. public function getMinimumStability()
  21419. {
  21420. return $this->aliasOf->getMinimumStability();
  21421. }
  21422. public function getStabilityFlags()
  21423. {
  21424. return $this->aliasOf->getStabilityFlags();
  21425. }
  21426. public function getReferences()
  21427. {
  21428. return $this->aliasOf->getReferences();
  21429. }
  21430. public function getPreferStable()
  21431. {
  21432. return $this->aliasOf->getPreferStable();
  21433. }
  21434. public function getConfig()
  21435. {
  21436. return $this->aliasOf->getConfig();
  21437. }
  21438. public function setRequires(array $require)
  21439. {
  21440. $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
  21441. $this->aliasOf->setRequires($require);
  21442. }
  21443. public function setDevRequires(array $devRequire)
  21444. {
  21445. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
  21446. $this->aliasOf->setDevRequires($devRequire);
  21447. }
  21448. public function setConflicts(array $conflicts)
  21449. {
  21450. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  21451. $this->aliasOf->setConflicts($conflicts);
  21452. }
  21453. public function setProvides(array $provides)
  21454. {
  21455. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  21456. $this->aliasOf->setProvides($provides);
  21457. }
  21458. public function setReplaces(array $replaces)
  21459. {
  21460. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  21461. $this->aliasOf->setReplaces($replaces);
  21462. }
  21463. public function setRepositories($repositories)
  21464. {
  21465. $this->aliasOf->setRepositories($repositories);
  21466. }
  21467. public function setAutoload(array $autoload)
  21468. {
  21469. $this->aliasOf->setAutoload($autoload);
  21470. }
  21471. public function setDevAutoload(array $devAutoload)
  21472. {
  21473. $this->aliasOf->setDevAutoload($devAutoload);
  21474. }
  21475. public function setStabilityFlags(array $stabilityFlags)
  21476. {
  21477. $this->aliasOf->setStabilityFlags($stabilityFlags);
  21478. }
  21479. public function setSuggests(array $suggests)
  21480. {
  21481. $this->aliasOf->setSuggests($suggests);
  21482. }
  21483. public function setExtra(array $extra)
  21484. {
  21485. $this->aliasOf->setExtra($extra);
  21486. }
  21487. public function __clone()
  21488. {
  21489. parent::__clone();
  21490. $this->aliasOf = clone $this->aliasOf;
  21491. }
  21492. }
  21493. <?php
  21494. namespace Composer\Package;
  21495. class RootPackage extends CompletePackage implements RootPackageInterface
  21496. {
  21497. const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  21498. protected $minimumStability = 'stable';
  21499. protected $preferStable = false;
  21500. protected $stabilityFlags = array();
  21501. protected $config = array();
  21502. protected $references = array();
  21503. protected $aliases = array();
  21504. public function setMinimumStability($minimumStability)
  21505. {
  21506. $this->minimumStability = $minimumStability;
  21507. }
  21508. public function getMinimumStability()
  21509. {
  21510. return $this->minimumStability;
  21511. }
  21512. public function setStabilityFlags(array $stabilityFlags)
  21513. {
  21514. $this->stabilityFlags = $stabilityFlags;
  21515. }
  21516. public function getStabilityFlags()
  21517. {
  21518. return $this->stabilityFlags;
  21519. }
  21520. public function setPreferStable($preferStable)
  21521. {
  21522. $this->preferStable = $preferStable;
  21523. }
  21524. public function getPreferStable()
  21525. {
  21526. return $this->preferStable;
  21527. }
  21528. public function setConfig(array $config)
  21529. {
  21530. $this->config = $config;
  21531. }
  21532. public function getConfig()
  21533. {
  21534. return $this->config;
  21535. }
  21536. public function setReferences(array $references)
  21537. {
  21538. $this->references = $references;
  21539. }
  21540. public function getReferences()
  21541. {
  21542. return $this->references;
  21543. }
  21544. public function setAliases(array $aliases)
  21545. {
  21546. $this->aliases = $aliases;
  21547. }
  21548. public function getAliases()
  21549. {
  21550. return $this->aliases;
  21551. }
  21552. }
  21553. <?php
  21554. namespace Composer\Package;
  21555. interface RootPackageInterface extends CompletePackageInterface
  21556. {
  21557. public function getAliases();
  21558. public function getMinimumStability();
  21559. public function getStabilityFlags();
  21560. public function getReferences();
  21561. public function getPreferStable();
  21562. public function getConfig();
  21563. public function setRequires(array $requires);
  21564. public function setDevRequires(array $devRequires);
  21565. public function setConflicts(array $conflicts);
  21566. public function setProvides(array $provides);
  21567. public function setReplaces(array $replaces);
  21568. public function setRepositories($repositories);
  21569. public function setAutoload(array $autoload);
  21570. public function setDevAutoload(array $devAutoload);
  21571. public function setStabilityFlags(array $stabilityFlags);
  21572. public function setSuggests(array $suggests);
  21573. public function setExtra(array $extra);
  21574. }
  21575. <?php
  21576. namespace Composer\Package\Version;
  21577. use Composer\Package\BasePackage;
  21578. class StabilityFilter
  21579. {
  21580. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, $names, $stability)
  21581. {
  21582. foreach ($names as $name) {
  21583. if (isset($stabilityFlags[$name])) {
  21584. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  21585. return true;
  21586. }
  21587. } elseif (isset($acceptableStabilities[$stability])) {
  21588. return true;
  21589. }
  21590. }
  21591. return false;
  21592. }
  21593. }
  21594. <?php
  21595. namespace Composer\Package\Version;
  21596. use Composer\Config;
  21597. use Composer\Repository\Vcs\HgDriver;
  21598. use Composer\IO\NullIO;
  21599. use Composer\Semver\VersionParser as SemverVersionParser;
  21600. use Composer\Util\Git as GitUtil;
  21601. use Composer\Util\HttpDownloader;
  21602. use Composer\Util\ProcessExecutor;
  21603. use Composer\Util\Svn as SvnUtil;
  21604. class VersionGuesser
  21605. {
  21606. private $config;
  21607. private $process;
  21608. private $versionParser;
  21609. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  21610. {
  21611. $this->config = $config;
  21612. $this->process = $process;
  21613. $this->versionParser = $versionParser;
  21614. }
  21615. public function guessVersion(array $packageConfig, $path)
  21616. {
  21617. if (!function_exists('proc_open')) {
  21618. return null;
  21619. }
  21620. $versionData = $this->guessGitVersion($packageConfig, $path);
  21621. if (null !== $versionData && null !== $versionData['version']) {
  21622. return $this->postprocess($versionData);
  21623. }
  21624. $versionData = $this->guessHgVersion($packageConfig, $path);
  21625. if (null !== $versionData && null !== $versionData['version']) {
  21626. return $this->postprocess($versionData);
  21627. }
  21628. $versionData = $this->guessFossilVersion($path);
  21629. if (null !== $versionData && null !== $versionData['version']) {
  21630. return $this->postprocess($versionData);
  21631. }
  21632. $versionData = $this->guessSvnVersion($packageConfig, $path);
  21633. if (null !== $versionData && null !== $versionData['version']) {
  21634. return $this->postprocess($versionData);
  21635. }
  21636. return null;
  21637. }
  21638. private function postprocess(array $versionData)
  21639. {
  21640. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  21641. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  21642. }
  21643. if ('-dev' === substr($versionData['version'], -4) && preg_match('{\.9{7}}', $versionData['version'])) {
  21644. $versionData['pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['version']);
  21645. }
  21646. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && preg_match('{\.9{7}}', $versionData['feature_version'])) {
  21647. $versionData['feature_pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  21648. }
  21649. return $versionData;
  21650. }
  21651. private function guessGitVersion(array $packageConfig, $path)
  21652. {
  21653. GitUtil::cleanEnv();
  21654. $commit = null;
  21655. $version = null;
  21656. $prettyVersion = null;
  21657. $featureVersion = null;
  21658. $featurePrettyVersion = null;
  21659. $isDetached = false;
  21660. if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
  21661. $branches = array();
  21662. $isFeatureBranch = false;
  21663. foreach ($this->process->splitLines($output) as $branch) {
  21664. if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21665. if (
  21666. $match[1] === '(no branch)'
  21667. || strpos($match[1], '(detached ') === 0
  21668. || strpos($match[1], '(HEAD detached at') === 0
  21669. ) {
  21670. $version = 'dev-' . $match[2];
  21671. $prettyVersion = $version;
  21672. $isFeatureBranch = true;
  21673. $isDetached = true;
  21674. } else {
  21675. $version = $this->versionParser->normalizeBranch($match[1]);
  21676. $prettyVersion = 'dev-' . $match[1];
  21677. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  21678. }
  21679. if ($match[2]) {
  21680. $commit = $match[2];
  21681. }
  21682. }
  21683. if ($branch && !preg_match('{^ *.+/HEAD }', $branch)) {
  21684. if (preg_match('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21685. $branches[] = $match[1];
  21686. }
  21687. }
  21688. }
  21689. if ($isFeatureBranch) {
  21690. $featureVersion = $version;
  21691. $featurePrettyVersion = $prettyVersion;
  21692. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  21693. $version = $result['version'];
  21694. $prettyVersion = $result['pretty_version'];
  21695. }
  21696. }
  21697. if (!$version || $isDetached) {
  21698. $result = $this->versionFromGitTags($path);
  21699. if ($result) {
  21700. $version = $result['version'];
  21701. $prettyVersion = $result['pretty_version'];
  21702. $featureVersion = null;
  21703. $featurePrettyVersion = null;
  21704. }
  21705. }
  21706. if (!$commit) {
  21707. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  21708. if (0 === $this->process->execute($command, $output, $path)) {
  21709. $commit = trim($output) ?: null;
  21710. }
  21711. }
  21712. if ($featureVersion) {
  21713. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  21714. }
  21715. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  21716. }
  21717. private function versionFromGitTags($path)
  21718. {
  21719. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  21720. try {
  21721. $version = $this->versionParser->normalize(trim($output));
  21722. return array('version' => $version, 'pretty_version' => trim($output));
  21723. } catch (\Exception $e) {
  21724. }
  21725. }
  21726. return null;
  21727. }
  21728. private function guessHgVersion(array $packageConfig, $path)
  21729. {
  21730. if (0 === $this->process->execute('hg branch', $output, $path)) {
  21731. $branch = trim($output);
  21732. $version = $this->versionParser->normalizeBranch($branch);
  21733. $isFeatureBranch = 0 === strpos($version, 'dev-');
  21734. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  21735. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  21736. }
  21737. if (!$isFeatureBranch) {
  21738. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  21739. }
  21740. $io = new NullIO();
  21741. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  21742. $branches = array_keys($driver->getBranches());
  21743. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  21744. $result['commit'] = '';
  21745. $result['feature_version'] = $version;
  21746. $result['feature_pretty_version'] = $version;
  21747. return $result;
  21748. }
  21749. }
  21750. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  21751. {
  21752. $prettyVersion = $version;
  21753. if (!isset($packageConfig['extra']['branch-alias'][$version])
  21754. || strpos(json_encode($packageConfig), '"self.version"')
  21755. ) {
  21756. $branch = preg_replace('{^dev-}', '', $version);
  21757. $length = PHP_INT_MAX;
  21758. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  21759. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21760. }
  21761. usort($branches, function ($a, $b) {
  21762. $aRemote = 0 === strpos($a, 'remotes/');
  21763. $bRemote = 0 === strpos($b, 'remotes/');
  21764. if ($aRemote !== $bRemote) {
  21765. return $aRemote ? 1 : -1;
  21766. }
  21767. return strnatcasecmp($b, $a);
  21768. });
  21769. foreach ($branches as $candidate) {
  21770. $candidateVersion = preg_replace('{^remotes/\S+/}', '', $candidate);
  21771. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  21772. continue;
  21773. }
  21774. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  21775. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  21776. continue;
  21777. }
  21778. if (strlen($output) < $length) {
  21779. $length = strlen($output);
  21780. $version = $this->versionParser->normalizeBranch($candidateVersion);
  21781. $prettyVersion = 'dev-' . $candidateVersion;
  21782. if ($length === 0) {
  21783. break;
  21784. }
  21785. }
  21786. }
  21787. }
  21788. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21789. }
  21790. private function isFeatureBranch(array $packageConfig, $branchName)
  21791. {
  21792. $nonFeatureBranches = '';
  21793. if (!empty($packageConfig['non-feature-branches'])) {
  21794. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  21795. }
  21796. return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  21797. }
  21798. private function guessFossilVersion($path)
  21799. {
  21800. $version = null;
  21801. $prettyVersion = null;
  21802. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  21803. $branch = trim($output);
  21804. $version = $this->versionParser->normalizeBranch($branch);
  21805. $prettyVersion = 'dev-' . $branch;
  21806. }
  21807. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  21808. try {
  21809. $version = $this->versionParser->normalize(trim($output));
  21810. $prettyVersion = trim($output);
  21811. } catch (\Exception $e) {
  21812. }
  21813. }
  21814. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21815. }
  21816. private function guessSvnVersion(array $packageConfig, $path)
  21817. {
  21818. SvnUtil::cleanEnv();
  21819. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  21820. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  21821. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  21822. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  21823. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  21824. if (preg_match($urlPattern, $output, $matches)) {
  21825. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  21826. $version = $this->versionParser->normalizeBranch($matches[3]);
  21827. $prettyVersion = 'dev-' . $matches[3];
  21828. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21829. }
  21830. $prettyVersion = trim($matches[1]);
  21831. if ($prettyVersion === 'trunk') {
  21832. $version = 'dev-trunk';
  21833. } else {
  21834. $version = $this->versionParser->normalize($prettyVersion);
  21835. }
  21836. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21837. }
  21838. }
  21839. }
  21840. }
  21841. <?php
  21842. namespace Composer\Package\Version;
  21843. use Composer\Repository\PlatformRepository;
  21844. use Composer\Semver\VersionParser as SemverVersionParser;
  21845. use Composer\Semver\Semver;
  21846. class VersionParser extends SemverVersionParser
  21847. {
  21848. const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  21849. private static $constraints = array();
  21850. public function parseConstraints($constraints)
  21851. {
  21852. if (!isset(self::$constraints[$constraints])) {
  21853. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  21854. }
  21855. return self::$constraints[$constraints];
  21856. }
  21857. public function parseNameVersionPairs(array $pairs)
  21858. {
  21859. $pairs = array_values($pairs);
  21860. $result = array();
  21861. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  21862. $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  21863. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  21864. $pair .= ' '.$pairs[$i + 1];
  21865. $i++;
  21866. }
  21867. if (strpos($pair, ' ')) {
  21868. list($name, $version) = explode(' ', $pair, 2);
  21869. $result[] = array('name' => $name, 'version' => $version);
  21870. } else {
  21871. $result[] = array('name' => $pair);
  21872. }
  21873. }
  21874. return $result;
  21875. }
  21876. public static function isUpgrade($normalizedFrom, $normalizedTo)
  21877. {
  21878. if ($normalizedFrom === $normalizedTo) {
  21879. return true;
  21880. }
  21881. if (in_array($normalizedFrom, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  21882. $normalizedFrom = VersionParser::DEFAULT_BRANCH_ALIAS;
  21883. }
  21884. if (in_array($normalizedTo, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  21885. $normalizedTo = VersionParser::DEFAULT_BRANCH_ALIAS;
  21886. }
  21887. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  21888. return true;
  21889. }
  21890. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  21891. return $sorted[0] === $normalizedFrom;
  21892. }
  21893. }
  21894. <?php
  21895. namespace Composer\Package\Version;
  21896. use Composer\Package\BasePackage;
  21897. use Composer\Package\AliasPackage;
  21898. use Composer\Package\PackageInterface;
  21899. use Composer\Composer;
  21900. use Composer\Package\Loader\ArrayLoader;
  21901. use Composer\Package\Dumper\ArrayDumper;
  21902. use Composer\Repository\RepositorySet;
  21903. use Composer\Repository\PlatformRepository;
  21904. use Composer\Semver\Constraint\Constraint;
  21905. class VersionSelector
  21906. {
  21907. private $repositorySet;
  21908. private $platformConstraints = array();
  21909. private $parser;
  21910. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  21911. {
  21912. $this->repositorySet = $repositorySet;
  21913. if ($platformRepo) {
  21914. foreach ($platformRepo->getPackages() as $package) {
  21915. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  21916. }
  21917. }
  21918. }
  21919. public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $ignorePlatformReqs = false, $repoSetFlags = 0)
  21920. {
  21921. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  21922. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  21923. }
  21924. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  21925. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  21926. if ($this->platformConstraints && true !== $ignorePlatformReqs) {
  21927. $platformConstraints = $this->platformConstraints;
  21928. $ignorePlatformReqs = $ignorePlatformReqs ?: array();
  21929. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $ignorePlatformReqs) {
  21930. $reqs = $pkg->getRequires();
  21931. foreach ($reqs as $name => $link) {
  21932. if (!in_array($name, $ignorePlatformReqs, true) && isset($platformConstraints[$name])) {
  21933. foreach ($platformConstraints[$name] as $constraint) {
  21934. if ($link->getConstraint()->matches($constraint)) {
  21935. continue 2;
  21936. }
  21937. }
  21938. return false;
  21939. }
  21940. }
  21941. return true;
  21942. });
  21943. }
  21944. if (!$candidates) {
  21945. return false;
  21946. }
  21947. $package = reset($candidates);
  21948. $minPriority = BasePackage::$stabilities[$preferredStability];
  21949. foreach ($candidates as $candidate) {
  21950. $candidatePriority = $candidate->getStabilityPriority();
  21951. $currentPriority = $package->getStabilityPriority();
  21952. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  21953. continue;
  21954. }
  21955. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  21956. $package = $candidate;
  21957. continue;
  21958. }
  21959. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  21960. $package = $candidate;
  21961. continue;
  21962. }
  21963. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  21964. $package = $candidate;
  21965. }
  21966. }
  21967. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  21968. $package = $package->getAliasOf();
  21969. }
  21970. return $package;
  21971. }
  21972. public function findRecommendedRequireVersion(PackageInterface $package)
  21973. {
  21974. $version = $package->getVersion();
  21975. if (!$package->isDev()) {
  21976. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  21977. }
  21978. $loader = new ArrayLoader($this->getParser());
  21979. $dumper = new ArrayDumper();
  21980. $extra = $loader->getBranchAlias($dumper->dump($package));
  21981. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  21982. $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  21983. if ($count) {
  21984. $extra = str_replace('.9999999', '.0', $extra);
  21985. return $this->transformVersion($extra, $extra, 'dev');
  21986. }
  21987. }
  21988. return $package->getPrettyVersion();
  21989. }
  21990. private function transformVersion($version, $prettyVersion, $stability)
  21991. {
  21992. $semanticVersionParts = explode('.', $version);
  21993. if (count($semanticVersionParts) == 4 && preg_match('{^0\D?}', $semanticVersionParts[3])) {
  21994. if ($semanticVersionParts[0] === '0') {
  21995. unset($semanticVersionParts[3]);
  21996. } else {
  21997. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  21998. }
  21999. $version = implode('.', $semanticVersionParts);
  22000. } else {
  22001. return $prettyVersion;
  22002. }
  22003. if ($stability != 'stable') {
  22004. $version .= '@'.$stability;
  22005. }
  22006. return '^' . $version;
  22007. }
  22008. private function getParser()
  22009. {
  22010. if ($this->parser === null) {
  22011. $this->parser = new VersionParser();
  22012. }
  22013. return $this->parser;
  22014. }
  22015. }
  22016. <?php
  22017. namespace Composer\Platform;
  22018. use Composer\Util\Platform;
  22019. use Composer\Util\ProcessExecutor;
  22020. use Symfony\Component\Process\ExecutableFinder;
  22021. class HhvmDetector
  22022. {
  22023. private static $hhvmVersion;
  22024. private $executableFinder;
  22025. private $processExecutor;
  22026. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  22027. {
  22028. $this->executableFinder = $executableFinder;
  22029. $this->processExecutor = $processExecutor;
  22030. }
  22031. public function reset()
  22032. {
  22033. self::$hhvmVersion = null;
  22034. }
  22035. public function getVersion()
  22036. {
  22037. if (null !== self::$hhvmVersion) {
  22038. return self::$hhvmVersion ?: null;
  22039. }
  22040. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  22041. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  22042. self::$hhvmVersion = false;
  22043. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  22044. $hhvmPath = $this->executableFinder->find('hhvm');
  22045. if ($hhvmPath !== null) {
  22046. $this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
  22047. $exitCode = $this->processExecutor->execute(
  22048. ProcessExecutor::escape($hhvmPath).
  22049. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  22050. self::$hhvmVersion
  22051. );
  22052. if ($exitCode !== 0) {
  22053. self::$hhvmVersion = false;
  22054. }
  22055. }
  22056. }
  22057. return self::$hhvmVersion;
  22058. }
  22059. }
  22060. <?php
  22061. namespace Composer\Platform;
  22062. class Runtime
  22063. {
  22064. public function hasConstant($constant, $class = null)
  22065. {
  22066. return defined(ltrim($class.'::'.$constant, ':'));
  22067. }
  22068. public function getConstant($constant, $class = null)
  22069. {
  22070. return constant(ltrim($class.'::'.$constant, ':'));
  22071. }
  22072. public function hasFunction($fn)
  22073. {
  22074. return function_exists($fn);
  22075. }
  22076. public function invoke($callable, array $arguments = array())
  22077. {
  22078. return call_user_func_array($callable, $arguments);
  22079. }
  22080. public function hasClass($class)
  22081. {
  22082. return class_exists($class, false);
  22083. }
  22084. public function construct($class, array $arguments = array())
  22085. {
  22086. if (empty($arguments)) {
  22087. return new $class;
  22088. }
  22089. $refl = new \ReflectionClass($class);
  22090. return $refl->newInstanceArgs($arguments);
  22091. }
  22092. public function getExtensions()
  22093. {
  22094. return get_loaded_extensions();
  22095. }
  22096. public function getExtensionVersion($extension)
  22097. {
  22098. return phpversion($extension);
  22099. }
  22100. public function getExtensionInfo($extension)
  22101. {
  22102. $reflector = new \ReflectionExtension($extension);
  22103. ob_start();
  22104. $reflector->info();
  22105. return ob_get_clean();
  22106. }
  22107. }
  22108. <?php
  22109. namespace Composer\Platform;
  22110. class Version
  22111. {
  22112. public static function parseOpenssl($opensslVersion, &$isFips)
  22113. {
  22114. $isFips = false;
  22115. if (!preg_match('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?$/', $opensslVersion, $matches)) {
  22116. return null;
  22117. }
  22118. $isFips = strpos($matches['suffix'], 'fips') !== false;
  22119. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  22120. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  22121. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  22122. }
  22123. public static function parseLibjpeg($libjpegVersion)
  22124. {
  22125. if (!preg_match('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  22126. return null;
  22127. }
  22128. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  22129. }
  22130. public static function parseZoneinfoVersion($zoneinfoVersion)
  22131. {
  22132. if (!preg_match('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  22133. return null;
  22134. }
  22135. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  22136. }
  22137. private static function convertAlphaVersionToIntVersion($alpha)
  22138. {
  22139. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  22140. }
  22141. public static function convertLibxpmVersionId($versionId)
  22142. {
  22143. return self::convertVersionId($versionId, 100);
  22144. }
  22145. public static function convertOpenldapVersionId($versionId)
  22146. {
  22147. return self::convertVersionId($versionId, 100);
  22148. }
  22149. private static function convertVersionId($versionId, $base)
  22150. {
  22151. return sprintf(
  22152. '%d.%d.%d',
  22153. $versionId / ($base * $base),
  22154. ($versionId / $base) % $base,
  22155. $versionId % $base
  22156. );
  22157. }
  22158. }
  22159. <?php
  22160. namespace Composer\Plugin\Capability;
  22161. interface Capability
  22162. {
  22163. }
  22164. <?php
  22165. namespace Composer\Plugin\Capability;
  22166. interface CommandProvider extends Capability
  22167. {
  22168. public function getCommands();
  22169. }
  22170. <?php
  22171. namespace Composer\Plugin;
  22172. interface Capable
  22173. {
  22174. public function getCapabilities();
  22175. }
  22176. <?php
  22177. namespace Composer\Plugin;
  22178. use Composer\EventDispatcher\Event;
  22179. use Symfony\Component\Console\Input\InputInterface;
  22180. use Symfony\Component\Console\Output\OutputInterface;
  22181. class CommandEvent extends Event
  22182. {
  22183. private $commandName;
  22184. private $input;
  22185. private $output;
  22186. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  22187. {
  22188. parent::__construct($name, $args, $flags);
  22189. $this->commandName = $commandName;
  22190. $this->input = $input;
  22191. $this->output = $output;
  22192. }
  22193. public function getInput()
  22194. {
  22195. return $this->input;
  22196. }
  22197. public function getOutput()
  22198. {
  22199. return $this->output;
  22200. }
  22201. public function getCommandName()
  22202. {
  22203. return $this->commandName;
  22204. }
  22205. }
  22206. <?php
  22207. namespace Composer\Plugin;
  22208. class PluginEvents
  22209. {
  22210. const INIT = 'init';
  22211. const COMMAND = 'command';
  22212. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  22213. const POST_FILE_DOWNLOAD = 'post-file-download';
  22214. const PRE_COMMAND_RUN = 'pre-command-run';
  22215. const PRE_POOL_CREATE = 'pre-pool-create';
  22216. }
  22217. <?php
  22218. namespace Composer\Plugin;
  22219. use Composer\Composer;
  22220. use Composer\IO\IOInterface;
  22221. interface PluginInterface
  22222. {
  22223. const PLUGIN_API_VERSION = '2.0.0';
  22224. public function activate(Composer $composer, IOInterface $io);
  22225. public function deactivate(Composer $composer, IOInterface $io);
  22226. public function uninstall(Composer $composer, IOInterface $io);
  22227. }
  22228. <?php
  22229. namespace Composer\Plugin;
  22230. use Composer\Composer;
  22231. use Composer\EventDispatcher\EventSubscriberInterface;
  22232. use Composer\IO\IOInterface;
  22233. use Composer\Package\CompletePackage;
  22234. use Composer\Package\Package;
  22235. use Composer\Package\RootPackage;
  22236. use Composer\Package\Version\VersionParser;
  22237. use Composer\Repository\RepositoryInterface;
  22238. use Composer\Repository\InstalledRepository;
  22239. use Composer\Repository\RootPackageRepository;
  22240. use Composer\Package\PackageInterface;
  22241. use Composer\Package\RootPackageInterface;
  22242. use Composer\Package\Link;
  22243. use Composer\Semver\Constraint\Constraint;
  22244. use Composer\Plugin\Capability\Capability;
  22245. use Composer\Util\PackageSorter;
  22246. class PluginManager
  22247. {
  22248. protected $composer;
  22249. protected $io;
  22250. protected $globalComposer;
  22251. protected $versionParser;
  22252. protected $disablePlugins = false;
  22253. protected $plugins = array();
  22254. protected $registeredPlugins = array();
  22255. private static $classCounter = 0;
  22256. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  22257. {
  22258. $this->io = $io;
  22259. $this->composer = $composer;
  22260. $this->globalComposer = $globalComposer;
  22261. $this->versionParser = new VersionParser();
  22262. $this->disablePlugins = $disablePlugins;
  22263. }
  22264. public function loadInstalledPlugins()
  22265. {
  22266. if ($this->disablePlugins) {
  22267. return;
  22268. }
  22269. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  22270. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22271. if ($repo) {
  22272. $this->loadRepository($repo, false);
  22273. }
  22274. if ($globalRepo) {
  22275. $this->loadRepository($globalRepo, true);
  22276. }
  22277. }
  22278. public function getPlugins()
  22279. {
  22280. return $this->plugins;
  22281. }
  22282. public function getGlobalComposer()
  22283. {
  22284. return $this->globalComposer;
  22285. }
  22286. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false, $isGlobalPlugin = false)
  22287. {
  22288. if ($this->disablePlugins) {
  22289. return;
  22290. }
  22291. if ($package->getType() === 'composer-plugin') {
  22292. $requiresComposer = null;
  22293. foreach ($package->getRequires() as $link) {
  22294. if ('composer-plugin-api' === $link->getTarget()) {
  22295. $requiresComposer = $link->getConstraint();
  22296. break;
  22297. }
  22298. }
  22299. if (!$requiresComposer) {
  22300. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  22301. }
  22302. $currentPluginApiVersion = $this->getPluginApiVersion();
  22303. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  22304. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  22305. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin requires composer-plugin-api '.$this->getPluginApiVersion().', this *WILL* break in the future and it should be fixed ASAP (require ^'.$this->getPluginApiVersion().' instead for example).</warning>');
  22306. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  22307. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin ? '(installed globally) ' : '').'was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
  22308. return;
  22309. }
  22310. if ($package->getName() === 'symfony/flex' && preg_match('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  22311. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin ? '(installed globally) ' : '').'was skipped because it is not compatible with Composer 2+. Make sure to update it to version 1.9.8 or greater.</warning>');
  22312. return;
  22313. }
  22314. }
  22315. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22316. if (isset($this->registeredPlugins[$package->getName()])) {
  22317. return;
  22318. }
  22319. $extra = $package->getExtra();
  22320. if (empty($extra['class'])) {
  22321. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  22322. }
  22323. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  22324. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  22325. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22326. $rootPackage = clone $this->composer->getPackage();
  22327. $rootPackageRepo = new RootPackageRepository($rootPackage);
  22328. $installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo));
  22329. if ($globalRepo) {
  22330. $installedRepo->addRepository($globalRepo);
  22331. }
  22332. $autoloadPackages = array($package->getName() => $package);
  22333. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  22334. $generator = $this->composer->getAutoloadGenerator();
  22335. $autoloads = array(array($rootPackage, ''));
  22336. foreach ($autoloadPackages as $autoloadPackage) {
  22337. if ($autoloadPackage === $rootPackage) {
  22338. continue;
  22339. }
  22340. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  22341. $autoloads[] = array($autoloadPackage, $downloadPath);
  22342. }
  22343. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  22344. $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  22345. $classLoader->register(false);
  22346. foreach ($classes as $class) {
  22347. if (class_exists($class, false)) {
  22348. $class = trim($class, '\\');
  22349. $path = $classLoader->findFile($class);
  22350. $code = file_get_contents($path);
  22351. $separatorPos = strrpos($class, '\\');
  22352. $className = $class;
  22353. if ($separatorPos) {
  22354. $className = substr($class, $separatorPos + 1);
  22355. }
  22356. $code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  22357. $code = strtr($code, array(
  22358. '__FILE__' => var_export($path, true),
  22359. '__DIR__' => var_export(dirname($path), true),
  22360. '__CLASS__' => var_export($class, true),
  22361. ));
  22362. $code = preg_replace('/^\s*<\?(php)?/i', '', $code, 1);
  22363. eval($code);
  22364. $class .= '_composer_tmp'.self::$classCounter;
  22365. self::$classCounter++;
  22366. }
  22367. if ($oldInstallerPlugin) {
  22368. $installer = new $class($this->io, $this->composer);
  22369. $this->composer->getInstallationManager()->addInstaller($installer);
  22370. $this->registeredPlugins[$package->getName()] = $installer;
  22371. } elseif (class_exists($class)) {
  22372. $plugin = new $class();
  22373. $this->addPlugin($plugin, $isGlobalPlugin, $package);
  22374. $this->registeredPlugins[$package->getName()] = $plugin;
  22375. } elseif ($failOnMissingClasses) {
  22376. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  22377. }
  22378. }
  22379. }
  22380. public function deactivatePackage(PackageInterface $package)
  22381. {
  22382. if ($this->disablePlugins) {
  22383. return;
  22384. }
  22385. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22386. if (!isset($this->registeredPlugins[$package->getName()])) {
  22387. return;
  22388. }
  22389. if ($oldInstallerPlugin) {
  22390. $installer = $this->registeredPlugins[$package->getName()];
  22391. unset($this->registeredPlugins[$package->getName()]);
  22392. $this->composer->getInstallationManager()->removeInstaller($installer);
  22393. } else {
  22394. $plugin = $this->registeredPlugins[$package->getName()];
  22395. unset($this->registeredPlugins[$package->getName()]);
  22396. $this->removePlugin($plugin);
  22397. }
  22398. }
  22399. public function uninstallPackage(PackageInterface $package)
  22400. {
  22401. if ($this->disablePlugins) {
  22402. return;
  22403. }
  22404. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22405. if (!isset($this->registeredPlugins[$package->getName()])) {
  22406. return;
  22407. }
  22408. if ($oldInstallerPlugin) {
  22409. $this->deactivatePackage($package);
  22410. } else {
  22411. $plugin = $this->registeredPlugins[$package->getName()];
  22412. unset($this->registeredPlugins[$package->getName()]);
  22413. $this->removePlugin($plugin);
  22414. $this->uninstallPlugin($plugin);
  22415. }
  22416. }
  22417. protected function getPluginApiVersion()
  22418. {
  22419. return PluginInterface::PLUGIN_API_VERSION;
  22420. }
  22421. public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false, PackageInterface $sourcePackage = null)
  22422. {
  22423. $details = array();
  22424. if ($sourcePackage) {
  22425. $details[] = 'from '.$sourcePackage->getName();
  22426. }
  22427. if ($isGlobalPlugin) {
  22428. $details[] = 'installed globally';
  22429. }
  22430. $this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
  22431. $this->plugins[] = $plugin;
  22432. $plugin->activate($this->composer, $this->io);
  22433. if ($plugin instanceof EventSubscriberInterface) {
  22434. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  22435. }
  22436. }
  22437. public function removePlugin(PluginInterface $plugin)
  22438. {
  22439. $index = array_search($plugin, $this->plugins, true);
  22440. if ($index === false) {
  22441. return;
  22442. }
  22443. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22444. unset($this->plugins[$index]);
  22445. $plugin->deactivate($this->composer, $this->io);
  22446. $this->composer->getEventDispatcher()->removeListener($plugin);
  22447. }
  22448. public function uninstallPlugin(PluginInterface $plugin)
  22449. {
  22450. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22451. $plugin->uninstall($this->composer, $this->io);
  22452. }
  22453. private function loadRepository(RepositoryInterface $repo, $isGlobalRepo)
  22454. {
  22455. $packages = $repo->getPackages();
  22456. $sortedPackages = PackageSorter::sortPackages($packages);
  22457. foreach ($sortedPackages as $package) {
  22458. if (!($package instanceof CompletePackage)) {
  22459. continue;
  22460. }
  22461. if ('composer-plugin' === $package->getType()) {
  22462. $this->registerPackage($package, false, $isGlobalRepo);
  22463. } elseif ('composer-installer' === $package->getType()) {
  22464. $this->registerPackage($package, false, $isGlobalRepo);
  22465. }
  22466. }
  22467. }
  22468. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
  22469. {
  22470. foreach ($package->getRequires() as $requireLink) {
  22471. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  22472. if (!isset($collected[$requiredPackage->getName()])) {
  22473. $collected[$requiredPackage->getName()] = $requiredPackage;
  22474. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  22475. }
  22476. }
  22477. }
  22478. return $collected;
  22479. }
  22480. private function getInstallPath(PackageInterface $package, $global = false)
  22481. {
  22482. if (!$global) {
  22483. return $this->composer->getInstallationManager()->getInstallPath($package);
  22484. }
  22485. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  22486. }
  22487. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  22488. {
  22489. if (!($plugin instanceof Capable)) {
  22490. return null;
  22491. }
  22492. $capabilities = (array) $plugin->getCapabilities();
  22493. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  22494. return trim($capabilities[$capability]);
  22495. }
  22496. if (
  22497. array_key_exists($capability, $capabilities)
  22498. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  22499. ) {
  22500. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], 1));
  22501. }
  22502. }
  22503. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  22504. {
  22505. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  22506. if (!class_exists($capabilityClass)) {
  22507. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  22508. }
  22509. $ctorArgs['plugin'] = $plugin;
  22510. $capabilityObj = new $capabilityClass($ctorArgs);
  22511. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  22512. throw new \RuntimeException(
  22513. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  22514. );
  22515. }
  22516. return $capabilityObj;
  22517. }
  22518. }
  22519. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  22520. {
  22521. $capabilities = array();
  22522. foreach ($this->getPlugins() as $plugin) {
  22523. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  22524. $capabilities[] = $capability;
  22525. }
  22526. }
  22527. return $capabilities;
  22528. }
  22529. }
  22530. <?php
  22531. namespace Composer\Plugin;
  22532. use Composer\EventDispatcher\Event;
  22533. use Composer\Package\PackageInterface;
  22534. class PostFileDownloadEvent extends Event
  22535. {
  22536. private $fileName;
  22537. private $checksum;
  22538. private $url;
  22539. private $package;
  22540. public function __construct($name, $fileName, $checksum, $url, PackageInterface $package)
  22541. {
  22542. parent::__construct($name);
  22543. $this->fileName = $fileName;
  22544. $this->checksum = $checksum;
  22545. $this->url = $url;
  22546. $this->package = $package;
  22547. }
  22548. public function getFileName()
  22549. {
  22550. return $this->fileName;
  22551. }
  22552. public function getChecksum()
  22553. {
  22554. return $this->checksum;
  22555. }
  22556. public function getUrl()
  22557. {
  22558. return $this->url;
  22559. }
  22560. public function getPackage()
  22561. {
  22562. return $this->package;
  22563. }
  22564. }
  22565. <?php
  22566. namespace Composer\Plugin;
  22567. use Composer\EventDispatcher\Event;
  22568. use Symfony\Component\Console\Input\InputInterface;
  22569. class PreCommandRunEvent extends Event
  22570. {
  22571. private $input;
  22572. private $command;
  22573. public function __construct($name, InputInterface $input, $command)
  22574. {
  22575. parent::__construct($name);
  22576. $this->input = $input;
  22577. $this->command = $command;
  22578. }
  22579. public function getInput()
  22580. {
  22581. return $this->input;
  22582. }
  22583. public function getCommand()
  22584. {
  22585. return $this->command;
  22586. }
  22587. }
  22588. <?php
  22589. namespace Composer\Plugin;
  22590. use Composer\EventDispatcher\Event;
  22591. use Composer\Util\HttpDownloader;
  22592. class PreFileDownloadEvent extends Event
  22593. {
  22594. private $httpDownloader;
  22595. private $processedUrl;
  22596. private $customCacheKey;
  22597. private $type;
  22598. private $context;
  22599. public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null)
  22600. {
  22601. parent::__construct($name);
  22602. $this->httpDownloader = $httpDownloader;
  22603. $this->processedUrl = $processedUrl;
  22604. $this->type = $type;
  22605. $this->context = $context;
  22606. }
  22607. public function getHttpDownloader()
  22608. {
  22609. return $this->httpDownloader;
  22610. }
  22611. public function getProcessedUrl()
  22612. {
  22613. return $this->processedUrl;
  22614. }
  22615. public function setProcessedUrl($processedUrl)
  22616. {
  22617. $this->processedUrl = $processedUrl;
  22618. }
  22619. public function getCustomCacheKey()
  22620. {
  22621. return $this->customCacheKey;
  22622. }
  22623. public function setCustomCacheKey($customCacheKey)
  22624. {
  22625. $this->customCacheKey = $customCacheKey;
  22626. }
  22627. public function getType()
  22628. {
  22629. return $this->type;
  22630. }
  22631. public function getContext()
  22632. {
  22633. return $this->context;
  22634. }
  22635. }
  22636. <?php
  22637. namespace Composer\Plugin;
  22638. use Composer\EventDispatcher\Event;
  22639. use Composer\Repository\RepositoryInterface;
  22640. use Composer\DependencyResolver\Request;
  22641. use Composer\Package\PackageInterface;
  22642. class PrePoolCreateEvent extends Event
  22643. {
  22644. private $repositories;
  22645. private $request;
  22646. private $acceptableStabilities;
  22647. private $stabilityFlags;
  22648. private $rootAliases;
  22649. private $rootReferences;
  22650. private $packages;
  22651. private $unacceptableFixedPackages;
  22652. public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  22653. {
  22654. parent::__construct($name);
  22655. $this->repositories = $repositories;
  22656. $this->request = $request;
  22657. $this->acceptableStabilities = $acceptableStabilities;
  22658. $this->stabilityFlags = $stabilityFlags;
  22659. $this->rootAliases = $rootAliases;
  22660. $this->rootReferences = $rootReferences;
  22661. $this->packages = $packages;
  22662. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  22663. }
  22664. public function getRepositories()
  22665. {
  22666. return $this->repositories;
  22667. }
  22668. public function getRequest()
  22669. {
  22670. return $this->request;
  22671. }
  22672. public function getAcceptableStabilities()
  22673. {
  22674. return $this->acceptableStabilities;
  22675. }
  22676. public function getStabilityFlags()
  22677. {
  22678. return $this->stabilityFlags;
  22679. }
  22680. public function getRootAliases()
  22681. {
  22682. return $this->rootAliases;
  22683. }
  22684. public function getRootReferences()
  22685. {
  22686. return $this->rootReferences;
  22687. }
  22688. public function getPackages()
  22689. {
  22690. return $this->packages;
  22691. }
  22692. public function getUnacceptableFixedPackages()
  22693. {
  22694. return $this->unacceptableFixedPackages;
  22695. }
  22696. public function setPackages(array $packages)
  22697. {
  22698. $this->packages = $packages;
  22699. }
  22700. public function setUnacceptableFixedPackages(array $packages)
  22701. {
  22702. $this->unacceptableFixedPackages = $packages;
  22703. }
  22704. }
  22705. <?php
  22706. namespace Composer\Question;
  22707. use Symfony\Component\Console\Exception\InvalidArgumentException;
  22708. use Symfony\Component\Console\Question\Question;
  22709. class StrictConfirmationQuestion extends Question
  22710. {
  22711. private $trueAnswerRegex;
  22712. private $falseAnswerRegex;
  22713. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  22714. {
  22715. parent::__construct($question, (bool) $default);
  22716. $this->trueAnswerRegex = $trueAnswerRegex;
  22717. $this->falseAnswerRegex = $falseAnswerRegex;
  22718. $this->setNormalizer($this->getDefaultNormalizer());
  22719. $this->setValidator($this->getDefaultValidator());
  22720. }
  22721. private function getDefaultNormalizer()
  22722. {
  22723. $default = $this->getDefault();
  22724. $trueRegex = $this->trueAnswerRegex;
  22725. $falseRegex = $this->falseAnswerRegex;
  22726. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  22727. if (is_bool($answer)) {
  22728. return $answer;
  22729. }
  22730. if (empty($answer) && !empty($default)) {
  22731. return $default;
  22732. }
  22733. if (preg_match($trueRegex, $answer)) {
  22734. return true;
  22735. }
  22736. if (preg_match($falseRegex, $answer)) {
  22737. return false;
  22738. }
  22739. return null;
  22740. };
  22741. }
  22742. private function getDefaultValidator()
  22743. {
  22744. return function ($answer) {
  22745. if (!is_bool($answer)) {
  22746. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  22747. }
  22748. return $answer;
  22749. };
  22750. }
  22751. }
  22752. <?php
  22753. namespace Composer\Repository;
  22754. use Composer\Package\AliasPackage;
  22755. use Composer\Package\PackageInterface;
  22756. use Composer\Package\CompletePackageInterface;
  22757. use Composer\Package\Version\VersionParser;
  22758. use Composer\Package\Version\StabilityFilter;
  22759. use Composer\Semver\Constraint\ConstraintInterface;
  22760. use Composer\Semver\Constraint\Constraint;
  22761. class ArrayRepository implements RepositoryInterface
  22762. {
  22763. protected $packages;
  22764. protected $packageMap;
  22765. public function __construct(array $packages = array())
  22766. {
  22767. foreach ($packages as $package) {
  22768. $this->addPackage($package);
  22769. }
  22770. }
  22771. public function getRepoName()
  22772. {
  22773. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  22774. }
  22775. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  22776. {
  22777. $packages = $this->getPackages();
  22778. $result = array();
  22779. $namesFound = array();
  22780. foreach ($packages as $package) {
  22781. if (array_key_exists($package->getName(), $packageMap)) {
  22782. if (
  22783. (!$packageMap[$package->getName()] || $packageMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  22784. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  22785. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  22786. ) {
  22787. $result[spl_object_hash($package)] = $package;
  22788. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  22789. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  22790. }
  22791. }
  22792. $namesFound[$package->getName()] = true;
  22793. }
  22794. }
  22795. foreach ($packages as $package) {
  22796. if ($package instanceof AliasPackage) {
  22797. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  22798. $result[spl_object_hash($package)] = $package;
  22799. }
  22800. }
  22801. }
  22802. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  22803. }
  22804. public function findPackage($name, $constraint)
  22805. {
  22806. $name = strtolower($name);
  22807. if (!$constraint instanceof ConstraintInterface) {
  22808. $versionParser = new VersionParser();
  22809. $constraint = $versionParser->parseConstraints($constraint);
  22810. }
  22811. foreach ($this->getPackages() as $package) {
  22812. if ($name === $package->getName()) {
  22813. $pkgConstraint = new Constraint('==', $package->getVersion());
  22814. if ($constraint->matches($pkgConstraint)) {
  22815. return $package;
  22816. }
  22817. }
  22818. }
  22819. return null;
  22820. }
  22821. public function findPackages($name, $constraint = null)
  22822. {
  22823. $name = strtolower($name);
  22824. $packages = array();
  22825. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  22826. $versionParser = new VersionParser();
  22827. $constraint = $versionParser->parseConstraints($constraint);
  22828. }
  22829. foreach ($this->getPackages() as $package) {
  22830. if ($name === $package->getName()) {
  22831. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  22832. $packages[] = $package;
  22833. }
  22834. }
  22835. }
  22836. return $packages;
  22837. }
  22838. public function search($query, $mode = 0, $type = null)
  22839. {
  22840. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  22841. $matches = array();
  22842. foreach ($this->getPackages() as $package) {
  22843. $name = $package->getName();
  22844. if (isset($matches[$name])) {
  22845. continue;
  22846. }
  22847. if (preg_match($regex, $name)
  22848. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  22849. ) {
  22850. if (null !== $type && $package->getType() !== $type) {
  22851. continue;
  22852. }
  22853. $matches[$name] = array(
  22854. 'name' => $package->getPrettyName(),
  22855. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  22856. );
  22857. }
  22858. }
  22859. return array_values($matches);
  22860. }
  22861. public function hasPackage(PackageInterface $package)
  22862. {
  22863. if ($this->packageMap === null) {
  22864. $this->packageMap = array();
  22865. foreach ($this->getPackages() as $repoPackage) {
  22866. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  22867. }
  22868. }
  22869. return isset($this->packageMap[$package->getUniqueName()]);
  22870. }
  22871. public function addPackage(PackageInterface $package)
  22872. {
  22873. if (null === $this->packages) {
  22874. $this->initialize();
  22875. }
  22876. $package->setRepository($this);
  22877. $this->packages[] = $package;
  22878. if ($package instanceof AliasPackage) {
  22879. $aliasedPackage = $package->getAliasOf();
  22880. if (null === $aliasedPackage->getRepository()) {
  22881. $this->addPackage($aliasedPackage);
  22882. }
  22883. }
  22884. $this->packageMap = null;
  22885. }
  22886. public function getProviders($packageName)
  22887. {
  22888. $result = array();
  22889. foreach ($this->getPackages() as $candidate) {
  22890. if (isset($result[$candidate->getName()])) {
  22891. continue;
  22892. }
  22893. foreach ($candidate->getProvides() as $link) {
  22894. if ($packageName === $link->getTarget()) {
  22895. $result[$candidate->getName()] = array(
  22896. 'name' => $candidate->getName(),
  22897. 'description' => $candidate->getDescription(),
  22898. 'type' => $candidate->getType(),
  22899. );
  22900. continue 2;
  22901. }
  22902. }
  22903. }
  22904. return $result;
  22905. }
  22906. protected function createAliasPackage(PackageInterface $package, $alias, $prettyAlias)
  22907. {
  22908. return new AliasPackage($package instanceof AliasPackage ? $package->getAliasOf() : $package, $alias, $prettyAlias);
  22909. }
  22910. public function removePackage(PackageInterface $package)
  22911. {
  22912. $packageId = $package->getUniqueName();
  22913. foreach ($this->getPackages() as $key => $repoPackage) {
  22914. if ($packageId === $repoPackage->getUniqueName()) {
  22915. array_splice($this->packages, $key, 1);
  22916. $this->packageMap = null;
  22917. return;
  22918. }
  22919. }
  22920. }
  22921. public function getPackages()
  22922. {
  22923. if (null === $this->packages) {
  22924. $this->initialize();
  22925. }
  22926. return $this->packages;
  22927. }
  22928. public function count()
  22929. {
  22930. if (null === $this->packages) {
  22931. $this->initialize();
  22932. }
  22933. return count($this->packages);
  22934. }
  22935. protected function initialize()
  22936. {
  22937. $this->packages = array();
  22938. }
  22939. }
  22940. <?php
  22941. namespace Composer\Repository;
  22942. use Composer\IO\IOInterface;
  22943. use Composer\Json\JsonFile;
  22944. use Composer\Package\Loader\ArrayLoader;
  22945. use Composer\Package\Loader\LoaderInterface;
  22946. use Composer\Util\Tar;
  22947. use Composer\Util\Zip;
  22948. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22949. {
  22950. protected $loader;
  22951. protected $lookup;
  22952. protected $repoConfig;
  22953. private $io;
  22954. public function __construct(array $repoConfig, IOInterface $io)
  22955. {
  22956. parent::__construct();
  22957. if (!extension_loaded('zip')) {
  22958. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  22959. }
  22960. $this->loader = new ArrayLoader();
  22961. $this->lookup = $repoConfig['url'];
  22962. $this->io = $io;
  22963. $this->repoConfig = $repoConfig;
  22964. }
  22965. public function getRepoName()
  22966. {
  22967. return 'artifact repo ('.$this->lookup.')';
  22968. }
  22969. public function getRepoConfig()
  22970. {
  22971. return $this->repoConfig;
  22972. }
  22973. protected function initialize()
  22974. {
  22975. parent::initialize();
  22976. $this->scanDirectory($this->lookup);
  22977. }
  22978. private function scanDirectory($path)
  22979. {
  22980. $io = $this->io;
  22981. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  22982. $iterator = new \RecursiveIteratorIterator($directory);
  22983. $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar|tar|gz|tgz)$/i');
  22984. foreach ($regex as $file) {
  22985. if (!$file->isFile()) {
  22986. continue;
  22987. }
  22988. $package = $this->getComposerInformation($file);
  22989. if (!$package) {
  22990. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  22991. continue;
  22992. }
  22993. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  22994. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  22995. $this->addPackage($package);
  22996. }
  22997. }
  22998. private function getComposerInformation(\SplFileInfo $file)
  22999. {
  23000. $json = null;
  23001. $fileType = null;
  23002. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  23003. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  23004. $fileType = 'tar';
  23005. } elseif ($fileExtension === 'zip') {
  23006. $fileType = 'zip';
  23007. } else {
  23008. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  23009. }
  23010. try {
  23011. if ($fileType === 'tar') {
  23012. $json = Tar::getComposerJson($file->getPathname());
  23013. } else {
  23014. $json = Zip::getComposerJson($file->getPathname());
  23015. }
  23016. } catch (\Exception $exception) {
  23017. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  23018. }
  23019. if (null === $json) {
  23020. return false;
  23021. }
  23022. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  23023. $package['dist'] = array(
  23024. 'type' => $fileType,
  23025. 'url' => strtr($file->getPathname(), '\\', '/'),
  23026. 'shasum' => sha1_file($file->getRealPath()),
  23027. );
  23028. try {
  23029. $package = $this->loader->load($package);
  23030. } catch (\UnexpectedValueException $e) {
  23031. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  23032. }
  23033. return $package;
  23034. }
  23035. }
  23036. <?php
  23037. namespace Composer\Repository;
  23038. use Composer\Package\BasePackage;
  23039. use Composer\Package\Loader\ArrayLoader;
  23040. use Composer\Package\PackageInterface;
  23041. use Composer\Package\AliasPackage;
  23042. use Composer\Package\Version\VersionParser;
  23043. use Composer\Package\Version\StabilityFilter;
  23044. use Composer\Json\JsonFile;
  23045. use Composer\Cache;
  23046. use Composer\Config;
  23047. use Composer\IO\IOInterface;
  23048. use Composer\Semver\CompilingMatcher;
  23049. use Composer\Util\HttpDownloader;
  23050. use Composer\Util\Loop;
  23051. use Composer\Plugin\PluginEvents;
  23052. use Composer\Plugin\PreFileDownloadEvent;
  23053. use Composer\EventDispatcher\EventDispatcher;
  23054. use Composer\Downloader\TransportException;
  23055. use Composer\Semver\Constraint\ConstraintInterface;
  23056. use Composer\Semver\Constraint\Constraint;
  23057. use Composer\Semver\Constraint\MatchAllConstraint;
  23058. use Composer\Util\Http\Response;
  23059. use Composer\Util\MetadataMinifier;
  23060. use Composer\Util\Url;
  23061. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  23062. {
  23063. private $repoConfig;
  23064. private $options;
  23065. private $url;
  23066. private $baseUrl;
  23067. private $io;
  23068. private $httpDownloader;
  23069. private $loop;
  23070. protected $cache;
  23071. protected $notifyUrl;
  23072. protected $searchUrl;
  23073. protected $providersApiUrl;
  23074. protected $hasProviders = false;
  23075. protected $providersUrl;
  23076. protected $listUrl;
  23077. protected $hasAvailablePackageList = false;
  23078. protected $availablePackages;
  23079. protected $availablePackagePatterns;
  23080. protected $lazyProvidersUrl;
  23081. protected $providerListing;
  23082. protected $loader;
  23083. private $allowSslDowngrade = false;
  23084. private $eventDispatcher;
  23085. private $sourceMirrors;
  23086. private $distMirrors;
  23087. private $degradedMode = false;
  23088. private $rootData;
  23089. private $hasPartialPackages;
  23090. private $partialPackagesByName;
  23091. public $freshMetadataUrls = array();
  23092. public $packagesNotFoundCache = array();
  23093. public $versionParser;
  23094. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  23095. {
  23096. parent::__construct();
  23097. if (!preg_match('{^[\w.]+\??://}', $repoConfig['url'])) {
  23098. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  23099. }
  23100. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  23101. if (strpos($repoConfig['url'], 'https?') === 0) {
  23102. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  23103. }
  23104. $urlBits = parse_url($repoConfig['url']);
  23105. if ($urlBits === false || empty($urlBits['scheme'])) {
  23106. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  23107. }
  23108. if (!isset($repoConfig['options'])) {
  23109. $repoConfig['options'] = array();
  23110. }
  23111. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  23112. $this->allowSslDowngrade = true;
  23113. }
  23114. $this->options = $repoConfig['options'];
  23115. $this->url = $repoConfig['url'];
  23116. if (preg_match('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  23117. $this->url = $match['proto'].'://repo.packagist.org';
  23118. }
  23119. $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  23120. $this->io = $io;
  23121. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  23122. $this->cache->setReadOnly($config->get('cache-read-only'));
  23123. $this->versionParser = new VersionParser();
  23124. $this->loader = new ArrayLoader($this->versionParser);
  23125. $this->httpDownloader = $httpDownloader;
  23126. $this->eventDispatcher = $eventDispatcher;
  23127. $this->repoConfig = $repoConfig;
  23128. $this->loop = new Loop($this->httpDownloader);
  23129. }
  23130. public function getRepoName()
  23131. {
  23132. return 'composer repo ('.Url::sanitize($this->url).')';
  23133. }
  23134. public function getRepoConfig()
  23135. {
  23136. return $this->repoConfig;
  23137. }
  23138. public function findPackage($name, $constraint)
  23139. {
  23140. $hasProviders = $this->hasProviders();
  23141. $name = strtolower($name);
  23142. if (!$constraint instanceof ConstraintInterface) {
  23143. $constraint = $this->versionParser->parseConstraints($constraint);
  23144. }
  23145. if ($this->lazyProvidersUrl) {
  23146. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  23147. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  23148. }
  23149. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  23150. return;
  23151. }
  23152. $packages = $this->loadAsyncPackages(array($name => $constraint));
  23153. return reset($packages['packages']);
  23154. }
  23155. if ($hasProviders) {
  23156. foreach ($this->getProviderNames() as $providerName) {
  23157. if ($name === $providerName) {
  23158. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  23159. }
  23160. }
  23161. return;
  23162. }
  23163. return parent::findPackage($name, $constraint);
  23164. }
  23165. public function findPackages($name, $constraint = null)
  23166. {
  23167. $hasProviders = $this->hasProviders();
  23168. $name = strtolower($name);
  23169. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  23170. $constraint = $this->versionParser->parseConstraints($constraint);
  23171. }
  23172. if ($this->lazyProvidersUrl) {
  23173. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  23174. return $this->filterPackages($this->whatProvides($name), $constraint);
  23175. }
  23176. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  23177. return array();
  23178. }
  23179. $result = $this->loadAsyncPackages(array($name => $constraint));
  23180. return $result['packages'];
  23181. }
  23182. if ($hasProviders) {
  23183. foreach ($this->getProviderNames() as $providerName) {
  23184. if ($name === $providerName) {
  23185. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  23186. }
  23187. }
  23188. return array();
  23189. }
  23190. return parent::findPackages($name, $constraint);
  23191. }
  23192. private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
  23193. {
  23194. if (null === $constraint) {
  23195. if ($returnFirstMatch) {
  23196. return reset($packages);
  23197. }
  23198. return $packages;
  23199. }
  23200. $filteredPackages = array();
  23201. foreach ($packages as $package) {
  23202. $pkgConstraint = new Constraint('==', $package->getVersion());
  23203. if ($constraint->matches($pkgConstraint)) {
  23204. if ($returnFirstMatch) {
  23205. return $package;
  23206. }
  23207. $filteredPackages[] = $package;
  23208. }
  23209. }
  23210. if ($returnFirstMatch) {
  23211. return null;
  23212. }
  23213. return $filteredPackages;
  23214. }
  23215. public function getPackages()
  23216. {
  23217. $hasProviders = $this->hasProviders();
  23218. if ($this->lazyProvidersUrl) {
  23219. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  23220. $packageMap = array();
  23221. foreach ($this->availablePackages as $name) {
  23222. $packageMap[$name] = new MatchAllConstraint();
  23223. }
  23224. $result = $this->loadAsyncPackages($packageMap);
  23225. return array_values($result['packages']);
  23226. }
  23227. if ($this->hasPartialPackages()) {
  23228. return array_values($this->partialPackagesByName);
  23229. }
  23230. throw new \LogicException('Composer repositories that have lazy providers and no available-packages list can not load the complete list of packages, use getPackageNames instead.');
  23231. }
  23232. if ($hasProviders) {
  23233. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  23234. }
  23235. return parent::getPackages();
  23236. }
  23237. public function getPackageNames($packageFilter = null)
  23238. {
  23239. $hasProviders = $this->hasProviders();
  23240. $packageFilterCb = function ($name) {
  23241. return true;
  23242. };
  23243. if (null !== $packageFilter) {
  23244. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  23245. $packageFilterCb = function ($name) use ($packageFilterRegex) {
  23246. return (bool) preg_match($packageFilterRegex, $name);
  23247. };
  23248. }
  23249. if ($this->lazyProvidersUrl) {
  23250. if (is_array($this->availablePackages)) {
  23251. return array_filter(array_keys($this->availablePackages), $packageFilterCb);
  23252. }
  23253. if ($this->listUrl) {
  23254. $url = $this->listUrl;
  23255. if ($packageFilter) {
  23256. $url .= '?filter='.urlencode($packageFilter);
  23257. }
  23258. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23259. return $result['packageNames'];
  23260. }
  23261. if ($this->hasPartialPackages()) {
  23262. return array_filter(array_keys($this->partialPackagesByName), $packageFilterCb);
  23263. }
  23264. return array();
  23265. }
  23266. if ($hasProviders) {
  23267. return array_filter($this->getProviderNames(), $packageFilterCb);
  23268. }
  23269. $names = array();
  23270. foreach ($this->getPackages() as $package) {
  23271. if ($packageFilterCb($package->getName())) {
  23272. $names[] = $package->getPrettyName();
  23273. }
  23274. }
  23275. return $names;
  23276. }
  23277. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23278. {
  23279. $hasProviders = $this->hasProviders();
  23280. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  23281. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23282. }
  23283. $packages = array();
  23284. $namesFound = array();
  23285. if ($hasProviders || $this->hasPartialPackages()) {
  23286. foreach ($packageNameMap as $name => $constraint) {
  23287. $matches = array();
  23288. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  23289. continue;
  23290. }
  23291. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23292. foreach ($candidates as $candidate) {
  23293. if ($candidate->getName() !== $name) {
  23294. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  23295. }
  23296. $namesFound[$name] = true;
  23297. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  23298. $matches[spl_object_hash($candidate)] = $candidate;
  23299. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23300. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  23301. }
  23302. }
  23303. }
  23304. foreach ($candidates as $candidate) {
  23305. if ($candidate instanceof AliasPackage) {
  23306. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23307. $matches[spl_object_hash($candidate)] = $candidate;
  23308. }
  23309. }
  23310. }
  23311. $packages = array_merge($packages, $matches);
  23312. unset($packageNameMap[$name]);
  23313. }
  23314. }
  23315. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  23316. if ($this->hasAvailablePackageList) {
  23317. foreach ($packageNameMap as $name => $constraint) {
  23318. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  23319. unset($packageNameMap[$name]);
  23320. }
  23321. }
  23322. }
  23323. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23324. $packages = array_merge($packages, $result['packages']);
  23325. $namesFound = array_merge($namesFound, $result['namesFound']);
  23326. }
  23327. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  23328. }
  23329. public function search($query, $mode = 0, $type = null)
  23330. {
  23331. $this->loadRootServerFile();
  23332. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  23333. $url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
  23334. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23335. if (empty($search['results'])) {
  23336. return array();
  23337. }
  23338. $results = array();
  23339. foreach ($search['results'] as $result) {
  23340. if (empty($result['virtual'])) {
  23341. $results[] = $result;
  23342. }
  23343. }
  23344. return $results;
  23345. }
  23346. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  23347. $results = array();
  23348. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  23349. foreach ($this->getPackageNames() as $name) {
  23350. if (preg_match($regex, $name)) {
  23351. $results[] = array('name' => $name);
  23352. }
  23353. }
  23354. return $results;
  23355. }
  23356. return parent::search($query, $mode);
  23357. }
  23358. public function getProviders($packageName)
  23359. {
  23360. $this->loadRootServerFile();
  23361. $result = array();
  23362. if ($this->providersApiUrl) {
  23363. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  23364. foreach ($apiResult['providers'] as $provider) {
  23365. $result[$provider['name']] = $provider;
  23366. }
  23367. return $result;
  23368. }
  23369. if ($this->hasPartialPackages()) {
  23370. foreach ($this->partialPackagesByName as $versions) {
  23371. foreach ($versions as $candidate) {
  23372. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  23373. continue;
  23374. }
  23375. $result[$candidate['name']] = array(
  23376. 'name' => $candidate['name'],
  23377. 'description' => isset($candidate['description']) ? $candidate['description'] : '',
  23378. 'type' => isset($candidate['type']) ? $candidate['type'] : '',
  23379. );
  23380. }
  23381. }
  23382. }
  23383. if ($this->packages) {
  23384. $result = array_merge($result, parent::getProviders($packageName));
  23385. }
  23386. return $result;
  23387. }
  23388. private function getProviderNames()
  23389. {
  23390. $this->loadRootServerFile();
  23391. if (null === $this->providerListing) {
  23392. $this->loadProviderListings($this->loadRootServerFile());
  23393. }
  23394. if ($this->lazyProvidersUrl) {
  23395. return array();
  23396. }
  23397. if ($this->providersUrl) {
  23398. return array_keys($this->providerListing);
  23399. }
  23400. return array();
  23401. }
  23402. private function configurePackageTransportOptions(PackageInterface $package)
  23403. {
  23404. foreach ($package->getDistUrls() as $url) {
  23405. if (strpos($url, $this->baseUrl) === 0) {
  23406. $package->setTransportOptions($this->options);
  23407. return;
  23408. }
  23409. }
  23410. }
  23411. private function hasProviders()
  23412. {
  23413. $this->loadRootServerFile();
  23414. return $this->hasProviders;
  23415. }
  23416. private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23417. {
  23418. $packagesSource = null;
  23419. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  23420. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  23421. return array();
  23422. }
  23423. if (null === $this->providerListing) {
  23424. $this->loadProviderListings($this->loadRootServerFile());
  23425. }
  23426. $useLastModifiedCheck = false;
  23427. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  23428. $hash = null;
  23429. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23430. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23431. $useLastModifiedCheck = true;
  23432. } elseif ($this->providersUrl) {
  23433. if (!isset($this->providerListing[$name])) {
  23434. return array();
  23435. }
  23436. $hash = $this->providerListing[$name]['sha256'];
  23437. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  23438. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23439. } else {
  23440. return array();
  23441. }
  23442. $packages = null;
  23443. if ($cacheKey) {
  23444. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  23445. $packages = json_decode($this->cache->read($cacheKey), true);
  23446. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  23447. } elseif ($useLastModifiedCheck) {
  23448. if ($contents = $this->cache->read($cacheKey)) {
  23449. $contents = json_decode($contents, true);
  23450. if (isset($alreadyLoaded[$name])) {
  23451. $packages = $contents;
  23452. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  23453. } elseif (isset($contents['last-modified'])) {
  23454. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  23455. $packages = true === $response ? $contents : $response;
  23456. $packagesSource = true === $response ? 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')' : 'downloaded file ('.Url::sanitize($url).')';
  23457. }
  23458. }
  23459. }
  23460. }
  23461. if (!$packages) {
  23462. try {
  23463. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  23464. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  23465. } catch (TransportException $e) {
  23466. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  23467. $packages = array('packages' => array());
  23468. $packagesSource = 'not-found file ('.Url::sanitize($url).')';
  23469. if ($e->getStatusCode() === 499) {
  23470. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  23471. }
  23472. } else {
  23473. throw $e;
  23474. }
  23475. }
  23476. }
  23477. $loadingPartialPackage = false;
  23478. } else {
  23479. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  23480. $packagesSource = 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')';
  23481. $loadingPartialPackage = true;
  23482. }
  23483. $result = array();
  23484. $versionsToLoad = array();
  23485. foreach ($packages['packages'] as $versions) {
  23486. foreach ($versions as $version) {
  23487. $normalizedName = strtolower($version['name']);
  23488. if ($normalizedName !== $name) {
  23489. continue;
  23490. }
  23491. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  23492. continue;
  23493. }
  23494. if (!isset($versionsToLoad[$version['uid']])) {
  23495. if (!isset($version['version_normalized'])) {
  23496. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23497. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23498. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23499. }
  23500. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  23501. continue;
  23502. }
  23503. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  23504. $versionsToLoad[$version['uid']] = $version;
  23505. }
  23506. }
  23507. }
  23508. }
  23509. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  23510. $uids = array_keys($versionsToLoad);
  23511. foreach ($loadedPackages as $index => $package) {
  23512. $package->setRepository($this);
  23513. $uid = $uids[$index];
  23514. if ($package instanceof AliasPackage) {
  23515. $aliased = $package->getAliasOf();
  23516. $aliased->setRepository($this);
  23517. $result[$uid] = $aliased;
  23518. $result[$uid.'-alias'] = $package;
  23519. } else {
  23520. $result[$uid] = $package;
  23521. }
  23522. }
  23523. return $result;
  23524. }
  23525. protected function initialize()
  23526. {
  23527. parent::initialize();
  23528. $repoData = $this->loadDataFromServer();
  23529. foreach ($this->createPackages($repoData, 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')') as $package) {
  23530. $this->addPackage($package);
  23531. }
  23532. }
  23533. public function addPackage(PackageInterface $package)
  23534. {
  23535. parent::addPackage($package);
  23536. $this->configurePackageTransportOptions($package);
  23537. }
  23538. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23539. {
  23540. $this->loadRootServerFile();
  23541. $packages = array();
  23542. $namesFound = array();
  23543. $promises = array();
  23544. $repo = $this;
  23545. if (!$this->lazyProvidersUrl) {
  23546. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  23547. }
  23548. foreach ($packageNames as $name => $constraint) {
  23549. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  23550. $packageNames[$name.'~dev'] = $constraint;
  23551. }
  23552. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  23553. unset($packageNames[$name]);
  23554. }
  23555. }
  23556. foreach ($packageNames as $name => $constraint) {
  23557. $name = strtolower($name);
  23558. $realName = preg_replace('{~dev$}', '', $name);
  23559. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  23560. continue;
  23561. }
  23562. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23563. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  23564. $lastModified = null;
  23565. if ($contents = $this->cache->read($cacheKey)) {
  23566. $contents = json_decode($contents, true);
  23567. $lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
  23568. }
  23569. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  23570. ->then(function ($response) use (&$packages, &$namesFound, $url, $cacheKey, $contents, $realName, $constraint, $repo, $acceptableStabilities, $stabilityFlags, $alreadyLoaded) {
  23571. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  23572. if (true === $response) {
  23573. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  23574. $response = $contents;
  23575. }
  23576. if (!isset($response['packages'][$realName])) {
  23577. return;
  23578. }
  23579. $versions = $response['packages'][$realName];
  23580. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  23581. $versions = MetadataMinifier::expand($versions);
  23582. }
  23583. $namesFound[$realName] = true;
  23584. $versionsToLoad = array();
  23585. foreach ($versions as $version) {
  23586. if (!isset($version['version_normalized'])) {
  23587. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23588. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23589. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23590. }
  23591. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  23592. continue;
  23593. }
  23594. if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  23595. $versionsToLoad[] = $version;
  23596. }
  23597. }
  23598. $loadedPackages = $repo->createPackages($versionsToLoad, $packagesSource);
  23599. foreach ($loadedPackages as $package) {
  23600. $package->setRepository($repo);
  23601. $packages[spl_object_hash($package)] = $package;
  23602. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  23603. $package->getAliasOf()->setRepository($repo);
  23604. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  23605. }
  23606. }
  23607. });
  23608. }
  23609. $this->loop->wait($promises);
  23610. return array('namesFound' => $namesFound, 'packages' => $packages);
  23611. }
  23612. public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
  23613. {
  23614. $versions = array($versionData['version_normalized']);
  23615. if ($alias = $this->loader->getBranchAlias($versionData)) {
  23616. $versions[] = $alias;
  23617. }
  23618. foreach ($versions as $version) {
  23619. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  23620. continue;
  23621. }
  23622. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  23623. continue;
  23624. }
  23625. return true;
  23626. }
  23627. return false;
  23628. }
  23629. private function getPackagesJsonUrl()
  23630. {
  23631. $jsonUrlParts = parse_url($this->url);
  23632. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  23633. return $this->url;
  23634. }
  23635. return $this->url . '/packages.json';
  23636. }
  23637. protected function loadRootServerFile()
  23638. {
  23639. if (null !== $this->rootData) {
  23640. return $this->rootData;
  23641. }
  23642. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  23643. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  23644. }
  23645. $data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json');
  23646. if (!empty($data['notify-batch'])) {
  23647. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  23648. } elseif (!empty($data['notify'])) {
  23649. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  23650. }
  23651. if (!empty($data['search'])) {
  23652. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  23653. }
  23654. if (!empty($data['mirrors'])) {
  23655. foreach ($data['mirrors'] as $mirror) {
  23656. if (!empty($mirror['git-url'])) {
  23657. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  23658. }
  23659. if (!empty($mirror['hg-url'])) {
  23660. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  23661. }
  23662. if (!empty($mirror['dist-url'])) {
  23663. $this->distMirrors[] = array(
  23664. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  23665. 'preferred' => !empty($mirror['preferred']),
  23666. );
  23667. }
  23668. }
  23669. }
  23670. if (!empty($data['providers-lazy-url'])) {
  23671. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  23672. $this->hasProviders = true;
  23673. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23674. }
  23675. if (!empty($data['metadata-url']) && !empty($data['list']) && $data['metadata-url'] === '/p/%package%.json' && $data['list'] === 'https://packagist.org/packages/list.json') {
  23676. $this->io->writeError('<warning>Composer 2 repository support for '.$this->url.' has been disabled due to what seems like a misconfiguration. If this is a packagist.org mirror we recommend removing it as Composer 2 handles network operations much faster and should work fine without.</warning>');
  23677. unset($data['metadata-url']);
  23678. }
  23679. if (!empty($data['metadata-url'])) {
  23680. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  23681. $this->providersUrl = null;
  23682. $this->hasProviders = false;
  23683. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23684. $this->allowSslDowngrade = false;
  23685. if (!empty($data['available-packages'])) {
  23686. $availPackages = array_map('strtolower', $data['available-packages']);
  23687. $this->availablePackages = array_combine($availPackages, $availPackages);
  23688. $this->hasAvailablePackageList = true;
  23689. }
  23690. if (!empty($data['available-package-patterns'])) {
  23691. $this->availablePackagePatterns = array_map(function ($pattern) {
  23692. return BasePackage::packageNameToRegexp($pattern);
  23693. }, $data['available-package-patterns']);
  23694. $this->hasAvailablePackageList = true;
  23695. }
  23696. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  23697. }
  23698. if ($this->allowSslDowngrade) {
  23699. $this->url = str_replace('https://', 'http://', $this->url);
  23700. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  23701. }
  23702. if (!empty($data['providers-url'])) {
  23703. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  23704. $this->hasProviders = true;
  23705. }
  23706. if (!empty($data['list'])) {
  23707. $this->listUrl = $this->canonicalizeUrl($data['list']);
  23708. }
  23709. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  23710. $this->hasProviders = true;
  23711. }
  23712. if (!empty($data['providers-api'])) {
  23713. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  23714. }
  23715. return $this->rootData = $data;
  23716. }
  23717. private function canonicalizeUrl($url)
  23718. {
  23719. if ('/' === $url[0]) {
  23720. if (preg_match('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  23721. return $matches[0] . $url;
  23722. }
  23723. return $this->url;
  23724. }
  23725. return $url;
  23726. }
  23727. private function loadDataFromServer()
  23728. {
  23729. $data = $this->loadRootServerFile();
  23730. return $this->loadIncludes($data);
  23731. }
  23732. private function hasPartialPackages()
  23733. {
  23734. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  23735. $this->initializePartialPackages();
  23736. }
  23737. return $this->hasPartialPackages;
  23738. }
  23739. private function loadProviderListings($data)
  23740. {
  23741. if (isset($data['providers'])) {
  23742. if (!is_array($this->providerListing)) {
  23743. $this->providerListing = array();
  23744. }
  23745. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  23746. }
  23747. if ($this->providersUrl && isset($data['provider-includes'])) {
  23748. $includes = $data['provider-includes'];
  23749. foreach ($includes as $include => $metadata) {
  23750. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  23751. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  23752. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  23753. $includedData = json_decode($this->cache->read($cacheKey), true);
  23754. } else {
  23755. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  23756. }
  23757. $this->loadProviderListings($includedData);
  23758. }
  23759. }
  23760. }
  23761. private function loadIncludes($data)
  23762. {
  23763. $packages = array();
  23764. if (!isset($data['packages']) && !isset($data['includes'])) {
  23765. foreach ($data as $pkg) {
  23766. foreach ($pkg['versions'] as $metadata) {
  23767. $packages[] = $metadata;
  23768. }
  23769. }
  23770. return $packages;
  23771. }
  23772. if (isset($data['packages'])) {
  23773. foreach ($data['packages'] as $package => $versions) {
  23774. foreach ($versions as $version => $metadata) {
  23775. $packages[] = $metadata;
  23776. }
  23777. }
  23778. }
  23779. if (isset($data['includes'])) {
  23780. foreach ($data['includes'] as $include => $metadata) {
  23781. if (isset($metadata['sha1']) && $this->cache->sha1($include) === $metadata['sha1']) {
  23782. $includedData = json_decode($this->cache->read($include), true);
  23783. } else {
  23784. $includedData = $this->fetchFile($include);
  23785. }
  23786. $packages = array_merge($packages, $this->loadIncludes($includedData));
  23787. }
  23788. }
  23789. return $packages;
  23790. }
  23791. public function createPackages(array $packages, $source = null)
  23792. {
  23793. if (!$packages) {
  23794. return array();
  23795. }
  23796. try {
  23797. foreach ($packages as &$data) {
  23798. if (!isset($data['notification-url'])) {
  23799. $data['notification-url'] = $this->notifyUrl;
  23800. }
  23801. }
  23802. $packageInstances = $this->loader->loadPackages($packages, 'Composer\Package\CompletePackage');
  23803. foreach ($packageInstances as $package) {
  23804. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  23805. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  23806. }
  23807. $package->setDistMirrors($this->distMirrors);
  23808. $this->configurePackageTransportOptions($package);
  23809. }
  23810. return $packageInstances;
  23811. } catch (\Exception $e) {
  23812. throw new \RuntimeException('Could not load packages '.(isset($packages[0]['name']) ? $packages[0]['name'] : json_encode($packages)).' in '.$this->getRepoName().($source ? ' from '.$source : '').': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
  23813. }
  23814. }
  23815. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  23816. {
  23817. if (null === $cacheKey) {
  23818. $cacheKey = $filename;
  23819. $filename = $this->baseUrl.'/'.$filename;
  23820. }
  23821. if (($pos = strpos($filename, '$')) && preg_match('{^https?://}i', $filename)) {
  23822. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  23823. }
  23824. $retries = 3;
  23825. while ($retries--) {
  23826. try {
  23827. if ($this->eventDispatcher) {
  23828. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23829. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23830. $filename = $preFileDownloadEvent->getProcessedUrl();
  23831. }
  23832. $response = $this->httpDownloader->get($filename, $this->options);
  23833. $json = $response->getBody();
  23834. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  23835. if ($this->allowSslDowngrade) {
  23836. $this->url = str_replace('http://', 'https://', $this->url);
  23837. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  23838. $filename = str_replace('http://', 'https://', $filename);
  23839. }
  23840. if ($retries) {
  23841. usleep(100000);
  23842. continue;
  23843. }
  23844. throw new RepositorySecurityException('The contents of '.$filename.' do not match its signature. This could indicate a man-in-the-middle attack or e.g. antivirus software corrupting files. Try running composer again and report this if you think it is a mistake.');
  23845. }
  23846. $data = $response->decodeJson();
  23847. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23848. if ($cacheKey && !$this->cache->isReadOnly()) {
  23849. if ($storeLastModifiedTime) {
  23850. $lastModifiedDate = $response->getHeader('last-modified');
  23851. if ($lastModifiedDate) {
  23852. $data['last-modified'] = $lastModifiedDate;
  23853. $json = json_encode($data);
  23854. }
  23855. }
  23856. $this->cache->write($cacheKey, $json);
  23857. }
  23858. $response->collect();
  23859. break;
  23860. } catch (\Exception $e) {
  23861. if ($e instanceof \LogicException) {
  23862. throw $e;
  23863. }
  23864. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23865. throw $e;
  23866. }
  23867. if ($retries) {
  23868. usleep(100000);
  23869. continue;
  23870. }
  23871. if ($e instanceof RepositorySecurityException) {
  23872. throw $e;
  23873. }
  23874. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  23875. if (!$this->degradedMode) {
  23876. $this->io->writeError('<warning>'.$this->url.' could not be fully loaded ('.$e->getMessage().'), package information was loaded from the local cache and may be out of date</warning>');
  23877. }
  23878. $this->degradedMode = true;
  23879. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  23880. break;
  23881. }
  23882. throw $e;
  23883. }
  23884. }
  23885. if (!isset($data)) {
  23886. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  23887. }
  23888. return $data;
  23889. }
  23890. private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  23891. {
  23892. $retries = 3;
  23893. while ($retries--) {
  23894. try {
  23895. if ($this->eventDispatcher) {
  23896. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23897. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23898. $filename = $preFileDownloadEvent->getProcessedUrl();
  23899. }
  23900. $options = $this->options;
  23901. if (isset($options['http']['header'])) {
  23902. $options['http']['header'] = (array) $options['http']['header'];
  23903. }
  23904. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23905. $response = $this->httpDownloader->get($filename, $options);
  23906. $json = $response->getBody();
  23907. if ($json === '' && $response->getStatusCode() === 304) {
  23908. return true;
  23909. }
  23910. $data = $response->decodeJson();
  23911. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23912. $lastModifiedDate = $response->getHeader('last-modified');
  23913. $response->collect();
  23914. if ($lastModifiedDate) {
  23915. $data['last-modified'] = $lastModifiedDate;
  23916. $json = json_encode($data);
  23917. }
  23918. if (!$this->cache->isReadOnly()) {
  23919. $this->cache->write($cacheKey, $json);
  23920. }
  23921. return $data;
  23922. } catch (\Exception $e) {
  23923. if ($e instanceof \LogicException) {
  23924. throw $e;
  23925. }
  23926. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23927. throw $e;
  23928. }
  23929. if ($retries) {
  23930. usleep(100000);
  23931. continue;
  23932. }
  23933. if (!$this->degradedMode) {
  23934. $this->io->writeError('<warning>'.$this->url.' could not be fully loaded ('.$e->getMessage().'), package information was loaded from the local cache and may be out of date</warning>');
  23935. }
  23936. $this->degradedMode = true;
  23937. return true;
  23938. }
  23939. }
  23940. }
  23941. private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
  23942. {
  23943. $retries = 3;
  23944. if (isset($this->packagesNotFoundCache[$filename])) {
  23945. return \React\Promise\resolve(array('packages' => array()));
  23946. }
  23947. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  23948. return \React\Promise\resolve(true);
  23949. }
  23950. $httpDownloader = $this->httpDownloader;
  23951. if ($this->eventDispatcher) {
  23952. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23953. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23954. $filename = $preFileDownloadEvent->getProcessedUrl();
  23955. }
  23956. $options = $this->options;
  23957. if ($lastModifiedTime) {
  23958. if (isset($options['http']['header'])) {
  23959. $options['http']['header'] = (array) $options['http']['header'];
  23960. }
  23961. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23962. }
  23963. $io = $this->io;
  23964. $url = $this->url;
  23965. $cache = $this->cache;
  23966. $degradedMode = &$this->degradedMode;
  23967. $repo = $this;
  23968. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) {
  23969. if ($response->getStatusCode() === 404) {
  23970. $repo->packagesNotFoundCache[$filename] = true;
  23971. return array('packages' => array());
  23972. }
  23973. $json = $response->getBody();
  23974. if ($json === '' && $response->getStatusCode() === 304) {
  23975. $repo->freshMetadataUrls[$filename] = true;
  23976. return true;
  23977. }
  23978. $data = $response->decodeJson();
  23979. HttpDownloader::outputWarnings($io, $url, $data);
  23980. $lastModifiedDate = $response->getHeader('last-modified');
  23981. $response->collect();
  23982. if ($lastModifiedDate) {
  23983. $data['last-modified'] = $lastModifiedDate;
  23984. $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE);
  23985. }
  23986. if (!$cache->isReadOnly()) {
  23987. $cache->write($cacheKey, $json);
  23988. }
  23989. $repo->freshMetadataUrls[$filename] = true;
  23990. return $data;
  23991. };
  23992. $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) {
  23993. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23994. $repo->packagesNotFoundCache[$filename] = true;
  23995. return false;
  23996. }
  23997. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  23998. $retries = 0;
  23999. }
  24000. if (--$retries > 0) {
  24001. usleep(100000);
  24002. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  24003. }
  24004. if (!$degradedMode) {
  24005. $io->writeError('<warning>'.$url.' could not be fully loaded ('.$e->getMessage().'), package information was loaded from the local cache and may be out of date</warning>');
  24006. }
  24007. $degradedMode = true;
  24008. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  24009. return $accept(new Response(array('url' => $url), 404, array(), ''));
  24010. }
  24011. throw $e;
  24012. };
  24013. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  24014. }
  24015. private function initializePartialPackages()
  24016. {
  24017. $rootData = $this->loadRootServerFile();
  24018. $this->partialPackagesByName = array();
  24019. foreach ($rootData['packages'] as $package => $versions) {
  24020. foreach ($versions as $version) {
  24021. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  24022. }
  24023. }
  24024. $this->rootData = true;
  24025. }
  24026. protected function lazyProvidersRepoContains($name)
  24027. {
  24028. if (!$this->hasAvailablePackageList) {
  24029. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  24030. }
  24031. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  24032. return true;
  24033. }
  24034. if (is_array($this->availablePackagePatterns)) {
  24035. foreach ($this->availablePackagePatterns as $providerRegex) {
  24036. if (preg_match($providerRegex, $name)) {
  24037. return true;
  24038. }
  24039. }
  24040. }
  24041. return false;
  24042. }
  24043. }
  24044. <?php
  24045. namespace Composer\Repository;
  24046. use Composer\Package\PackageInterface;
  24047. class CompositeRepository implements RepositoryInterface
  24048. {
  24049. private $repositories;
  24050. public function __construct(array $repositories)
  24051. {
  24052. $this->repositories = array();
  24053. foreach ($repositories as $repo) {
  24054. $this->addRepository($repo);
  24055. }
  24056. }
  24057. public function getRepoName()
  24058. {
  24059. return 'composite repo ('.implode(', ', array_map(function ($repo) {
  24060. return $repo->getRepoName();
  24061. }, $this->repositories)).')';
  24062. }
  24063. public function getRepositories()
  24064. {
  24065. return $this->repositories;
  24066. }
  24067. public function hasPackage(PackageInterface $package)
  24068. {
  24069. foreach ($this->repositories as $repository) {
  24070. if ($repository->hasPackage($package)) {
  24071. return true;
  24072. }
  24073. }
  24074. return false;
  24075. }
  24076. public function findPackage($name, $constraint)
  24077. {
  24078. foreach ($this->repositories as $repository) {
  24079. $package = $repository->findPackage($name, $constraint);
  24080. if (null !== $package) {
  24081. return $package;
  24082. }
  24083. }
  24084. return null;
  24085. }
  24086. public function findPackages($name, $constraint = null)
  24087. {
  24088. $packages = array();
  24089. foreach ($this->repositories as $repository) {
  24090. $packages[] = $repository->findPackages($name, $constraint);
  24091. }
  24092. return $packages ? call_user_func_array('array_merge', $packages) : array();
  24093. }
  24094. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  24095. {
  24096. $packages = array();
  24097. $namesFound = array();
  24098. foreach ($this->repositories as $repository) {
  24099. $result = $repository->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24100. $packages[] = $result['packages'];
  24101. $namesFound[] = $result['namesFound'];
  24102. }
  24103. return array(
  24104. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  24105. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  24106. );
  24107. }
  24108. public function search($query, $mode = 0, $type = null)
  24109. {
  24110. $matches = array();
  24111. foreach ($this->repositories as $repository) {
  24112. $matches[] = $repository->search($query, $mode, $type);
  24113. }
  24114. return $matches ? call_user_func_array('array_merge', $matches) : array();
  24115. }
  24116. public function getPackages()
  24117. {
  24118. $packages = array();
  24119. foreach ($this->repositories as $repository) {
  24120. $packages[] = $repository->getPackages();
  24121. }
  24122. return $packages ? call_user_func_array('array_merge', $packages) : array();
  24123. }
  24124. public function getProviders($packageName)
  24125. {
  24126. $results = array();
  24127. foreach ($this->repositories as $repository) {
  24128. $results[] = $repository->getProviders($packageName);
  24129. }
  24130. return $results ? call_user_func_array('array_merge', $results) : array();
  24131. }
  24132. public function removePackage(PackageInterface $package)
  24133. {
  24134. foreach ($this->repositories as $repository) {
  24135. $repository->removePackage($package);
  24136. }
  24137. }
  24138. public function count()
  24139. {
  24140. $total = 0;
  24141. foreach ($this->repositories as $repository) {
  24142. $total += $repository->count();
  24143. }
  24144. return $total;
  24145. }
  24146. public function addRepository(RepositoryInterface $repository)
  24147. {
  24148. if ($repository instanceof self) {
  24149. foreach ($repository->getRepositories() as $repo) {
  24150. $this->addRepository($repo);
  24151. }
  24152. } else {
  24153. $this->repositories[] = $repository;
  24154. }
  24155. }
  24156. }
  24157. <?php
  24158. namespace Composer\Repository;
  24159. interface ConfigurableRepositoryInterface
  24160. {
  24161. public function getRepoConfig();
  24162. }
  24163. <?php
  24164. namespace Composer\Repository;
  24165. use Composer\Json\JsonFile;
  24166. use Composer\Package\Loader\ArrayLoader;
  24167. use Composer\Package\RootPackageInterface;
  24168. use Composer\Package\AliasPackage;
  24169. use Composer\Package\Dumper\ArrayDumper;
  24170. use Composer\Installer\InstallationManager;
  24171. use Composer\Util\Filesystem;
  24172. class FilesystemRepository extends WritableArrayRepository
  24173. {
  24174. protected $file;
  24175. private $dumpVersions;
  24176. private $rootPackage;
  24177. public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null)
  24178. {
  24179. parent::__construct();
  24180. $this->file = $repositoryFile;
  24181. $this->dumpVersions = $dumpVersions;
  24182. $this->rootPackage = $rootPackage;
  24183. if ($dumpVersions && !$rootPackage) {
  24184. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  24185. }
  24186. }
  24187. protected function initialize()
  24188. {
  24189. parent::initialize();
  24190. if (!$this->file->exists()) {
  24191. return;
  24192. }
  24193. try {
  24194. $data = $this->file->read();
  24195. if (isset($data['packages'])) {
  24196. $packages = $data['packages'];
  24197. } else {
  24198. $packages = $data;
  24199. }
  24200. if (isset($data['dev-package-names'])) {
  24201. $this->setDevPackageNames($data['dev-package-names']);
  24202. }
  24203. if (!is_array($packages)) {
  24204. throw new \UnexpectedValueException('Could not parse package list from the repository');
  24205. }
  24206. } catch (\Exception $e) {
  24207. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  24208. }
  24209. $loader = new ArrayLoader(null, true);
  24210. foreach ($packages as $packageData) {
  24211. $package = $loader->load($packageData);
  24212. $this->addPackage($package);
  24213. }
  24214. }
  24215. public function reload()
  24216. {
  24217. $this->packages = null;
  24218. $this->initialize();
  24219. }
  24220. public function write($devMode, InstallationManager $installationManager)
  24221. {
  24222. $data = array('packages' => array(), 'dev' => $devMode, 'dev-package-names' => array());
  24223. $dumper = new ArrayDumper();
  24224. $fs = new Filesystem();
  24225. $repoDir = dirname($fs->normalizePath($this->file->getPath()));
  24226. foreach ($this->getCanonicalPackages() as $package) {
  24227. $pkgArray = $dumper->dump($package);
  24228. $path = $installationManager->getInstallPath($package);
  24229. $pkgArray['install-path'] = ('' !== $path && null !== $path) ? $fs->findShortestPath($repoDir, $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path, true) : null;
  24230. $data['packages'][] = $pkgArray;
  24231. if (in_array($package->getName(), $this->devPackageNames, true)) {
  24232. $data['dev-package-names'][] = $package->getName();
  24233. }
  24234. }
  24235. sort($data['dev-package-names']);
  24236. usort($data['packages'], function ($a, $b) {
  24237. return strcmp($a['name'], $b['name']);
  24238. });
  24239. $this->file->write($data);
  24240. if ($this->dumpVersions) {
  24241. $versions = $this->generateInstalledVersions($installationManager);
  24242. $fs->filePutContentsIfModified($repoDir.'/installed.php', '<?php return '.var_export($versions, true).';'."\n");
  24243. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  24244. $installedVersionsClass = str_replace('private static $installed;', 'private static $installed = '.var_export($versions, true).';', $installedVersionsClass);
  24245. $fs->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  24246. \Composer\InstalledVersions::reload($versions);
  24247. }
  24248. }
  24249. private function generateInstalledVersions(InstallationManager $installationManager)
  24250. {
  24251. if (!$this->dumpVersions) {
  24252. return null;
  24253. }
  24254. $versions = array('versions' => array());
  24255. $packages = $this->getPackages();
  24256. $packages[] = $rootPackage = $this->rootPackage;
  24257. while ($rootPackage instanceof AliasPackage) {
  24258. $rootPackage = $rootPackage->getAliasOf();
  24259. $packages[] = $rootPackage;
  24260. }
  24261. foreach ($packages as $package) {
  24262. if ($package instanceof AliasPackage) {
  24263. continue;
  24264. }
  24265. $reference = null;
  24266. if ($package->getInstallationSource()) {
  24267. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  24268. }
  24269. if (null === $reference) {
  24270. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  24271. }
  24272. $versions['versions'][$package->getName()] = array(
  24273. 'pretty_version' => $package->getPrettyVersion(),
  24274. 'version' => $package->getVersion(),
  24275. 'aliases' => array(),
  24276. 'reference' => $reference,
  24277. );
  24278. if ($package instanceof RootPackageInterface) {
  24279. $versions['root'] = $versions['versions'][$package->getName()];
  24280. $versions['root']['name'] = $package->getName();
  24281. }
  24282. }
  24283. foreach ($packages as $package) {
  24284. foreach ($package->getReplaces() as $replace) {
  24285. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  24286. continue;
  24287. }
  24288. $replaced = $replace->getPrettyConstraint();
  24289. if ($replaced === 'self.version') {
  24290. $replaced = $package->getPrettyVersion();
  24291. }
  24292. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  24293. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  24294. }
  24295. }
  24296. foreach ($package->getProvides() as $provide) {
  24297. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  24298. continue;
  24299. }
  24300. $provided = $provide->getPrettyConstraint();
  24301. if ($provided === 'self.version') {
  24302. $provided = $package->getPrettyVersion();
  24303. }
  24304. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  24305. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  24306. }
  24307. }
  24308. }
  24309. foreach ($packages as $package) {
  24310. if (!$package instanceof AliasPackage) {
  24311. continue;
  24312. }
  24313. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  24314. if ($package instanceof RootPackageInterface) {
  24315. $versions['root']['aliases'][] = $package->getPrettyVersion();
  24316. }
  24317. }
  24318. ksort($versions['versions']);
  24319. ksort($versions);
  24320. return $versions;
  24321. }
  24322. }
  24323. <?php
  24324. namespace Composer\Repository;
  24325. use Composer\Package\PackageInterface;
  24326. use Composer\Package\BasePackage;
  24327. class FilterRepository implements RepositoryInterface
  24328. {
  24329. private $only = array();
  24330. private $exclude = array();
  24331. private $canonical = true;
  24332. private $repo;
  24333. public function __construct(RepositoryInterface $repo, array $options)
  24334. {
  24335. if (isset($options['only'])) {
  24336. if (!is_array($options['only'])) {
  24337. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  24338. }
  24339. $this->only = '{^'.implode('|', array_map(function ($val) {
  24340. return BasePackage::packageNameToRegexp($val, '%s');
  24341. }, $options['only'])) .'$}iD';
  24342. }
  24343. if (isset($options['exclude'])) {
  24344. if (!is_array($options['exclude'])) {
  24345. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  24346. }
  24347. $this->exclude = '{^'.implode('|', array_map(function ($val) {
  24348. return BasePackage::packageNameToRegexp($val, '%s');
  24349. }, $options['exclude'])) .'$}iD';
  24350. }
  24351. if ($this->exclude && $this->only) {
  24352. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  24353. }
  24354. if (isset($options['canonical'])) {
  24355. if (!is_bool($options['canonical'])) {
  24356. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  24357. }
  24358. $this->canonical = $options['canonical'];
  24359. }
  24360. $this->repo = $repo;
  24361. }
  24362. public function getRepoName()
  24363. {
  24364. return $this->repo->getRepoName();
  24365. }
  24366. public function getRepository()
  24367. {
  24368. return $this->repo;
  24369. }
  24370. public function hasPackage(PackageInterface $package)
  24371. {
  24372. return $this->repo->hasPackage($package);
  24373. }
  24374. public function findPackage($name, $constraint)
  24375. {
  24376. if (!$this->isAllowed($name)) {
  24377. return null;
  24378. }
  24379. return $this->repo->findPackage($name, $constraint);
  24380. }
  24381. public function findPackages($name, $constraint = null)
  24382. {
  24383. if (!$this->isAllowed($name)) {
  24384. return array();
  24385. }
  24386. return $this->repo->findPackages($name, $constraint);
  24387. }
  24388. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  24389. {
  24390. foreach ($packageMap as $name => $constraint) {
  24391. if (!$this->isAllowed($name)) {
  24392. unset($packageMap[$name]);
  24393. }
  24394. }
  24395. if (!$packageMap) {
  24396. return array('namesFound' => array(), 'packages' => array());
  24397. }
  24398. $result = $this->repo->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24399. if (!$this->canonical) {
  24400. $result['namesFound'] = array();
  24401. }
  24402. return $result;
  24403. }
  24404. public function search($query, $mode = 0, $type = null)
  24405. {
  24406. $result = array();
  24407. foreach ($this->repo->search($query, $mode, $type) as $package) {
  24408. if ($this->isAllowed($package['name'])) {
  24409. $result[] = $package;
  24410. }
  24411. }
  24412. return $result;
  24413. }
  24414. public function getPackages()
  24415. {
  24416. $result = array();
  24417. foreach ($this->repo->getPackages() as $package) {
  24418. if ($this->isAllowed($package->getName())) {
  24419. $result[] = $package;
  24420. }
  24421. }
  24422. return $result;
  24423. }
  24424. public function getProviders($packageName)
  24425. {
  24426. $result = array();
  24427. foreach ($this->repo->getProviders($packageName) as $provider) {
  24428. if ($this->isAllowed($provider['name'])) {
  24429. $result[] = $provider;
  24430. }
  24431. }
  24432. return $result;
  24433. }
  24434. public function removePackage(PackageInterface $package)
  24435. {
  24436. return $this->repo->removePackage($package);
  24437. }
  24438. public function count()
  24439. {
  24440. if ($this->repo->count() > 0) {
  24441. return count($this->getPackages());
  24442. }
  24443. return 0;
  24444. }
  24445. private function isAllowed($name)
  24446. {
  24447. if (!$this->only && !$this->exclude) {
  24448. return true;
  24449. }
  24450. if ($this->only) {
  24451. return (bool) preg_match($this->only, $name);
  24452. }
  24453. return !preg_match($this->exclude, $name);
  24454. }
  24455. }
  24456. <?php
  24457. namespace Composer\Repository;
  24458. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  24459. {
  24460. public function getRepoName()
  24461. {
  24462. return 'installed '.parent::getRepoName();
  24463. }
  24464. public function isFresh()
  24465. {
  24466. return $this->count() === 0;
  24467. }
  24468. }
  24469. <?php
  24470. namespace Composer\Repository;
  24471. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  24472. {
  24473. public function getRepoName()
  24474. {
  24475. return 'installed '.parent::getRepoName();
  24476. }
  24477. public function isFresh()
  24478. {
  24479. return !$this->file->exists();
  24480. }
  24481. }
  24482. <?php
  24483. namespace Composer\Repository;
  24484. use Composer\Package\Version\VersionParser;
  24485. use Composer\Semver\Constraint\ConstraintInterface;
  24486. use Composer\Semver\Constraint\Constraint;
  24487. use Composer\Semver\Constraint\MatchAllConstraint;
  24488. use Composer\Package\RootPackageInterface;
  24489. use Composer\Package\Link;
  24490. class InstalledRepository extends CompositeRepository
  24491. {
  24492. public function findPackagesWithReplacersAndProviders($name, $constraint = null)
  24493. {
  24494. $name = strtolower($name);
  24495. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  24496. $versionParser = new VersionParser();
  24497. $constraint = $versionParser->parseConstraints($constraint);
  24498. }
  24499. $matches = array();
  24500. foreach ($this->getRepositories() as $repo) {
  24501. foreach ($repo->getPackages() as $candidate) {
  24502. if ($name === $candidate->getName()) {
  24503. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  24504. $matches[] = $candidate;
  24505. }
  24506. continue;
  24507. }
  24508. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  24509. if (
  24510. $name === $link->getTarget()
  24511. && ($constraint === null || $link->getConstraint() === null || $constraint->matches($link->getConstraint()))
  24512. ) {
  24513. $matches[] = $candidate;
  24514. continue 2;
  24515. }
  24516. }
  24517. }
  24518. }
  24519. return $matches;
  24520. }
  24521. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  24522. {
  24523. $needles = array_map('strtolower', (array) $needle);
  24524. $results = array();
  24525. if (null === $packagesFound) {
  24526. $packagesFound = $needles;
  24527. }
  24528. $rootPackage = null;
  24529. foreach ($this->getPackages() as $package) {
  24530. if ($package instanceof RootPackageInterface) {
  24531. $rootPackage = $package;
  24532. break;
  24533. }
  24534. }
  24535. foreach ($this->getPackages() as $package) {
  24536. $links = $package->getRequires();
  24537. $packagesInTree = $packagesFound;
  24538. if (!$invert) {
  24539. $links += $package->getReplaces();
  24540. foreach ($package->getReplaces() as $link) {
  24541. foreach ($needles as $needle) {
  24542. if ($link->getSource() === $needle) {
  24543. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24544. if (in_array($link->getTarget(), $packagesInTree)) {
  24545. $results[] = array($package, $link, false);
  24546. continue;
  24547. }
  24548. $packagesInTree[] = $link->getTarget();
  24549. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  24550. $results[] = array($package, $link, $dependents);
  24551. $needles[] = $link->getTarget();
  24552. }
  24553. }
  24554. }
  24555. }
  24556. }
  24557. if ($package instanceof RootPackageInterface) {
  24558. $links += $package->getDevRequires();
  24559. }
  24560. foreach ($links as $link) {
  24561. foreach ($needles as $needle) {
  24562. if ($link->getTarget() === $needle) {
  24563. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24564. if (in_array($link->getSource(), $packagesInTree)) {
  24565. $results[] = array($package, $link, false);
  24566. continue;
  24567. }
  24568. $packagesInTree[] = $link->getSource();
  24569. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  24570. $results[] = array($package, $link, $dependents);
  24571. }
  24572. }
  24573. }
  24574. }
  24575. if ($invert && in_array($package->getName(), $needles)) {
  24576. foreach ($package->getConflicts() as $link) {
  24577. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  24578. $version = new Constraint('=', $pkg->getVersion());
  24579. if ($link->getConstraint()->matches($version) === $invert) {
  24580. $results[] = array($package, $link, false);
  24581. }
  24582. }
  24583. }
  24584. }
  24585. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  24586. foreach ($package->getRequires() as $link) {
  24587. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  24588. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  24589. continue;
  24590. }
  24591. $platformPkg = $this->findPackage($link->getTarget(), '*');
  24592. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  24593. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  24594. continue;
  24595. }
  24596. foreach ($this->getPackages() as $pkg) {
  24597. if (!in_array($link->getTarget(), $pkg->getNames())) {
  24598. continue;
  24599. }
  24600. $version = new Constraint('=', $pkg->getVersion());
  24601. if ($link->getTarget() !== $pkg->getName()) {
  24602. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  24603. if ($link->getTarget() === $prov->getTarget()) {
  24604. $version = $prov->getConstraint();
  24605. break;
  24606. }
  24607. }
  24608. }
  24609. if (!$link->getConstraint()->matches($version)) {
  24610. if ($rootPackage) {
  24611. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  24612. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  24613. $results[] = array($package, $link, false);
  24614. $results[] = array($rootPackage, $rootReq, false);
  24615. continue 3;
  24616. }
  24617. }
  24618. $results[] = array($package, $link, false);
  24619. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, 'does not require', 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  24620. } else {
  24621. $results[] = array($package, $link, false);
  24622. }
  24623. }
  24624. continue 2;
  24625. }
  24626. }
  24627. }
  24628. }
  24629. ksort($results);
  24630. return $results;
  24631. }
  24632. public function getRepoName()
  24633. {
  24634. return 'installed repo ('.implode(', ', array_map(function ($repo) {
  24635. return $repo->getRepoName();
  24636. }, $this->getRepositories())).')';
  24637. }
  24638. public function addRepository(RepositoryInterface $repository)
  24639. {
  24640. if (
  24641. $repository instanceof LockArrayRepository
  24642. || $repository instanceof InstalledRepositoryInterface
  24643. || $repository instanceof RootPackageRepository
  24644. || $repository instanceof PlatformRepository
  24645. ) {
  24646. return parent::addRepository($repository);
  24647. }
  24648. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  24649. }
  24650. }
  24651. <?php
  24652. namespace Composer\Repository;
  24653. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  24654. {
  24655. public function isFresh();
  24656. }
  24657. <?php
  24658. namespace Composer\Repository;
  24659. class InvalidRepositoryException extends \Exception
  24660. {
  24661. }
  24662. <?php
  24663. namespace Composer\Repository;
  24664. class LockArrayRepository extends ArrayRepository
  24665. {
  24666. public function getRepoName()
  24667. {
  24668. return 'lock repo';
  24669. }
  24670. }
  24671. <?php
  24672. namespace Composer\Repository;
  24673. use Composer\Package\Loader\ArrayLoader;
  24674. use Composer\Package\Loader\ValidatingArrayLoader;
  24675. class PackageRepository extends ArrayRepository
  24676. {
  24677. private $config;
  24678. public function __construct(array $config)
  24679. {
  24680. parent::__construct();
  24681. $this->config = $config['package'];
  24682. if (!is_numeric(key($this->config))) {
  24683. $this->config = array($this->config);
  24684. }
  24685. }
  24686. protected function initialize()
  24687. {
  24688. parent::initialize();
  24689. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
  24690. foreach ($this->config as $package) {
  24691. try {
  24692. $package = $loader->load($package);
  24693. } catch (\Exception $e) {
  24694. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  24695. }
  24696. $this->addPackage($package);
  24697. }
  24698. }
  24699. public function getRepoName()
  24700. {
  24701. return preg_replace('{^array }', 'package ', parent::getRepoName());
  24702. }
  24703. }
  24704. <?php
  24705. namespace Composer\Repository;
  24706. use Composer\Config;
  24707. use Composer\IO\IOInterface;
  24708. use Composer\Json\JsonFile;
  24709. use Composer\Package\Loader\ArrayLoader;
  24710. use Composer\Package\Version\VersionGuesser;
  24711. use Composer\Package\Version\VersionParser;
  24712. use Composer\Util\Platform;
  24713. use Composer\Util\ProcessExecutor;
  24714. use Composer\Util\Filesystem;
  24715. use Composer\Util\Url;
  24716. use Composer\Util\Git as GitUtil;
  24717. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  24718. {
  24719. private $loader;
  24720. private $versionGuesser;
  24721. private $url;
  24722. private $repoConfig;
  24723. private $process;
  24724. private $options;
  24725. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  24726. {
  24727. if (!isset($repoConfig['url'])) {
  24728. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  24729. }
  24730. $this->loader = new ArrayLoader(null, true);
  24731. $this->url = Platform::expandPath($repoConfig['url']);
  24732. $this->process = new ProcessExecutor($io);
  24733. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  24734. $this->repoConfig = $repoConfig;
  24735. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  24736. if (!isset($this->options['relative'])) {
  24737. $filesystem = new Filesystem();
  24738. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  24739. }
  24740. parent::__construct();
  24741. }
  24742. public function getRepoName()
  24743. {
  24744. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  24745. }
  24746. public function getRepoConfig()
  24747. {
  24748. return $this->repoConfig;
  24749. }
  24750. protected function initialize()
  24751. {
  24752. parent::initialize();
  24753. $urlMatches = $this->getUrlMatches();
  24754. if (empty($urlMatches)) {
  24755. if (preg_match('{[*{}]}', $this->url)) {
  24756. $url = $this->url;
  24757. while (preg_match('{[*{}]}', $url)) {
  24758. $url = dirname($url);
  24759. }
  24760. if (is_dir($url)) {
  24761. return;
  24762. }
  24763. }
  24764. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  24765. }
  24766. foreach ($urlMatches as $url) {
  24767. $path = realpath($url) . DIRECTORY_SEPARATOR;
  24768. $composerFilePath = $path.'composer.json';
  24769. if (!file_exists($composerFilePath)) {
  24770. continue;
  24771. }
  24772. $json = file_get_contents($composerFilePath);
  24773. $package = JsonFile::parseJson($json, $composerFilePath);
  24774. $package['dist'] = array(
  24775. 'type' => 'path',
  24776. 'url' => $url,
  24777. 'reference' => sha1($json . serialize($this->options)),
  24778. );
  24779. $package['transport-options'] = $this->options;
  24780. unset($package['transport-options']['versions']);
  24781. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  24782. $package['version'] = $this->options['versions'][$package['name']];
  24783. }
  24784. if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
  24785. if (
  24786. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  24787. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  24788. && $ref1 === $ref2
  24789. ) {
  24790. $package['version'] = $rootVersion;
  24791. }
  24792. }
  24793. $output = '';
  24794. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  24795. $package['dist']['reference'] = trim($output);
  24796. }
  24797. if (!isset($package['version'])) {
  24798. $versionData = $this->versionGuesser->guessVersion($package, $path);
  24799. if (is_array($versionData) && $versionData['pretty_version']) {
  24800. if (!empty($versionData['feature_pretty_version'])) {
  24801. $package['version'] = $versionData['feature_pretty_version'];
  24802. $this->addPackage($this->loader->load($package));
  24803. }
  24804. $package['version'] = $versionData['pretty_version'];
  24805. } else {
  24806. $package['version'] = 'dev-master';
  24807. }
  24808. }
  24809. $package = $this->loader->load($package);
  24810. $this->addPackage($package);
  24811. }
  24812. }
  24813. private function getUrlMatches()
  24814. {
  24815. $flags = GLOB_MARK | GLOB_ONLYDIR;
  24816. if (defined('GLOB_BRACE')) {
  24817. $flags |= GLOB_BRACE;
  24818. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  24819. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  24820. }
  24821. return array_map(function ($val) {
  24822. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  24823. }, glob($this->url, $flags));
  24824. }
  24825. }
  24826. <?php
  24827. namespace Composer\Repository;
  24828. class PearRepository extends ArrayRepository
  24829. {
  24830. public function __construct()
  24831. {
  24832. throw new \RuntimeException('The PEAR repository has been removed from Composer 2.0');
  24833. }
  24834. }
  24835. <?php
  24836. namespace Composer\Repository;
  24837. use Composer\Composer;
  24838. use Composer\Package\CompletePackage;
  24839. use Composer\Package\Link;
  24840. use Composer\Package\PackageInterface;
  24841. use Composer\Package\Version\VersionParser;
  24842. use Composer\Platform\HhvmDetector;
  24843. use Composer\Platform\Runtime;
  24844. use Composer\Platform\Version;
  24845. use Composer\Plugin\PluginInterface;
  24846. use Composer\Semver\Constraint\Constraint;
  24847. use Composer\Util\Silencer;
  24848. use Composer\XdebugHandler\XdebugHandler;
  24849. class PlatformRepository extends ArrayRepository
  24850. {
  24851. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
  24852. private $versionParser;
  24853. private $overrides = array();
  24854. private $runtime;
  24855. private $hhvmDetector;
  24856. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  24857. {
  24858. $this->runtime = $runtime ?: new Runtime();
  24859. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  24860. foreach ($overrides as $name => $version) {
  24861. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  24862. }
  24863. parent::__construct($packages);
  24864. }
  24865. public function getRepoName()
  24866. {
  24867. return 'platform repo';
  24868. }
  24869. protected function initialize()
  24870. {
  24871. parent::initialize();
  24872. $this->versionParser = new VersionParser();
  24873. foreach ($this->overrides as $override) {
  24874. if (!self::isPlatformPackage($override['name'])) {
  24875. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  24876. }
  24877. $this->addOverriddenPackage($override);
  24878. }
  24879. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  24880. $version = $this->versionParser->normalize($prettyVersion);
  24881. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  24882. $composerPluginApi->setDescription('The Composer Plugin API');
  24883. $this->addPackage($composerPluginApi);
  24884. $prettyVersion = Composer::RUNTIME_API_VERSION;
  24885. $version = $this->versionParser->normalize($prettyVersion);
  24886. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  24887. $composerRuntimeApi->setDescription('The Composer Runtime API');
  24888. $this->addPackage($composerRuntimeApi);
  24889. try {
  24890. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  24891. $version = $this->versionParser->normalize($prettyVersion);
  24892. } catch (\UnexpectedValueException $e) {
  24893. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  24894. $version = $this->versionParser->normalize($prettyVersion);
  24895. }
  24896. $php = new CompletePackage('php', $version, $prettyVersion);
  24897. $php->setDescription('The PHP interpreter');
  24898. $this->addPackage($php);
  24899. if ($this->runtime->getConstant('PHP_DEBUG')) {
  24900. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  24901. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  24902. $this->addPackage($phpdebug);
  24903. }
  24904. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  24905. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  24906. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  24907. $this->addPackage($phpzts);
  24908. }
  24909. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  24910. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  24911. $php64->setDescription('The PHP interpreter, 64bit');
  24912. $this->addPackage($php64);
  24913. }
  24914. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  24915. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  24916. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  24917. $this->addPackage($phpIpv6);
  24918. }
  24919. $loadedExtensions = $this->runtime->getExtensions();
  24920. foreach ($loadedExtensions as $name) {
  24921. if (in_array($name, array('standard', 'Core'))) {
  24922. continue;
  24923. }
  24924. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  24925. }
  24926. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  24927. $this->addExtension('xdebug', $prettyVersion);
  24928. }
  24929. foreach ($loadedExtensions as $name) {
  24930. switch ($name) {
  24931. case 'amqp':
  24932. $info = $this->runtime->getExtensionInfo($name);
  24933. if (preg_match('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  24934. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  24935. }
  24936. if (preg_match('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  24937. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  24938. }
  24939. break;
  24940. case 'bz2':
  24941. $info = $this->runtime->getExtensionInfo($name);
  24942. if (preg_match('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  24943. $this->addLibrary($name, $matches['version']);
  24944. }
  24945. break;
  24946. case 'curl':
  24947. $curlVersion = $this->runtime->invoke('curl_version');
  24948. $this->addLibrary($name, $curlVersion['version']);
  24949. $info = $this->runtime->getExtensionInfo($name);
  24950. if (preg_match('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  24951. $library = strtolower($sslMatches['library']);
  24952. if ($library === 'openssl') {
  24953. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  24954. $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl') : array());
  24955. } else {
  24956. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  24957. }
  24958. }
  24959. if (preg_match('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  24960. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  24961. }
  24962. if (preg_match('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  24963. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  24964. }
  24965. break;
  24966. case 'date':
  24967. $info = $this->runtime->getExtensionInfo($name);
  24968. if (preg_match('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  24969. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  24970. }
  24971. if (preg_match('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  24972. $external = $zoneinfoSourceMatches['source'] === 'external';
  24973. if (preg_match('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  24974. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  24975. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  24976. } else {
  24977. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  24978. }
  24979. }
  24980. }
  24981. break;
  24982. case 'fileinfo':
  24983. $info = $this->runtime->getExtensionInfo($name);
  24984. if (preg_match('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  24985. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  24986. }
  24987. break;
  24988. case 'gd':
  24989. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  24990. $info = $this->runtime->getExtensionInfo($name);
  24991. if (preg_match('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  24992. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  24993. }
  24994. if (preg_match('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  24995. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  24996. }
  24997. if (preg_match('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  24998. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  24999. }
  25000. if (preg_match('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  25001. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId($libxpmMatches['versionId']), 'libxpm version for gd');
  25002. }
  25003. break;
  25004. case 'gmp':
  25005. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  25006. break;
  25007. case 'iconv':
  25008. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  25009. break;
  25010. case 'intl':
  25011. $info = $this->runtime->getExtensionInfo($name);
  25012. $description = 'The ICU unicode and globalization support library';
  25013. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  25014. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  25015. } elseif (preg_match('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  25016. $this->addLibrary('icu', $matches['version'], $description);
  25017. }
  25018. if (preg_match('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches)) {
  25019. $this->addLibrary('icu-zoneinfo', Version::parseZoneinfoVersion($zoneinfoMatches['version']), 'zoneinfo ("Olson") database for icu');
  25020. }
  25021. if ($this->runtime->hasClass('ResourceBundle')) {
  25022. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  25023. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  25024. }
  25025. if ($this->runtime->hasClass('IntlChar')) {
  25026. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  25027. }
  25028. break;
  25029. case 'imagick':
  25030. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  25031. preg_match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  25032. $version = $matches['version'];
  25033. if (isset($matches['patch'])) {
  25034. $version .= '.'.$matches['patch'];
  25035. }
  25036. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  25037. break;
  25038. case 'ldap':
  25039. $info = $this->runtime->getExtensionInfo($name);
  25040. if (preg_match('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && preg_match('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  25041. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId($matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  25042. }
  25043. break;
  25044. case 'libxml':
  25045. $libxmlProvides = array_map(function ($extension) {
  25046. return $extension . '-libxml';
  25047. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  25048. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  25049. break;
  25050. case 'mbstring':
  25051. $info = $this->runtime->getExtensionInfo($name);
  25052. if (preg_match('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  25053. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  25054. }
  25055. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  25056. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  25057. } elseif (preg_match('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  25058. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  25059. }
  25060. break;
  25061. case 'memcached':
  25062. $info = $this->runtime->getExtensionInfo($name);
  25063. if (preg_match('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  25064. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  25065. }
  25066. break;
  25067. case 'openssl':
  25068. if (preg_match('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  25069. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  25070. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  25071. }
  25072. break;
  25073. case 'pcre':
  25074. $this->addLibrary($name, preg_replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  25075. $info = $this->runtime->getExtensionInfo($name);
  25076. if (preg_match('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  25077. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  25078. }
  25079. break;
  25080. case 'mysqlnd':
  25081. case 'pdo_mysql':
  25082. $info = $this->runtime->getExtensionInfo($name);
  25083. if (preg_match('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  25084. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  25085. }
  25086. break;
  25087. case 'mongodb':
  25088. $info = $this->runtime->getExtensionInfo($name);
  25089. if (preg_match('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  25090. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  25091. }
  25092. if (preg_match('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  25093. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  25094. }
  25095. break;
  25096. case 'pgsql':
  25097. case 'pdo_pgsql':
  25098. $info = $this->runtime->getExtensionInfo($name);
  25099. if (preg_match('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  25100. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  25101. }
  25102. break;
  25103. case 'libsodium':
  25104. case 'sodium':
  25105. if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) {
  25106. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  25107. }
  25108. break;
  25109. case 'sqlite3':
  25110. case 'pdo_sqlite':
  25111. $info = $this->runtime->getExtensionInfo($name);
  25112. if (preg_match('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  25113. $this->addLibrary($name.'-sqlite', $matches['version']);
  25114. }
  25115. break;
  25116. case 'ssh2':
  25117. $info = $this->runtime->getExtensionInfo($name);
  25118. if (preg_match('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  25119. $this->addLibrary($name.'-libssh2', $matches['version']);
  25120. }
  25121. break;
  25122. case 'xsl':
  25123. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  25124. $info = $this->runtime->getExtensionInfo('xsl');
  25125. if (preg_match('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  25126. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  25127. }
  25128. break;
  25129. case 'yaml':
  25130. $info = $this->runtime->getExtensionInfo('yaml');
  25131. if (preg_match('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  25132. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  25133. }
  25134. break;
  25135. case 'zip':
  25136. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  25137. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, array('zip'));
  25138. }
  25139. break;
  25140. case 'zlib':
  25141. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  25142. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  25143. } elseif (preg_match('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  25144. $this->addLibrary($name, $matches['version']);
  25145. }
  25146. break;
  25147. default:
  25148. break;
  25149. }
  25150. }
  25151. $hhvmVersion = $this->hhvmDetector->getVersion();
  25152. if ($hhvmVersion) {
  25153. try {
  25154. $prettyVersion = $hhvmVersion;
  25155. $version = $this->versionParser->normalize($prettyVersion);
  25156. } catch (\UnexpectedValueException $e) {
  25157. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  25158. $version = $this->versionParser->normalize($prettyVersion);
  25159. }
  25160. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  25161. $hhvm->setDescription('The HHVM Runtime (64bit)');
  25162. $this->addPackage($hhvm);
  25163. }
  25164. }
  25165. public function addPackage(PackageInterface $package)
  25166. {
  25167. if (isset($this->overrides[$package->getName()])) {
  25168. $overrider = $this->findPackage($package->getName(), '*');
  25169. if ($package->getVersion() === $overrider->getVersion()) {
  25170. $actualText = 'same as actual';
  25171. } else {
  25172. $actualText = 'actual: '.$package->getPrettyVersion();
  25173. }
  25174. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  25175. return;
  25176. }
  25177. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  25178. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  25179. if ($package->getVersion() === $overrider->getVersion()) {
  25180. $actualText = 'same as actual';
  25181. } else {
  25182. $actualText = 'actual: '.$package->getPrettyVersion();
  25183. }
  25184. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  25185. return;
  25186. }
  25187. parent::addPackage($package);
  25188. }
  25189. private function addOverriddenPackage(array $override, $name = null)
  25190. {
  25191. $version = $this->versionParser->normalize($override['version']);
  25192. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  25193. $package->setDescription('Package overridden via config.platform');
  25194. $package->setExtra(array('config.platform' => true));
  25195. parent::addPackage($package);
  25196. return $package;
  25197. }
  25198. private function addExtension($name, $prettyVersion)
  25199. {
  25200. $extraDescription = null;
  25201. try {
  25202. $version = $this->versionParser->normalize($prettyVersion);
  25203. } catch (\UnexpectedValueException $e) {
  25204. $extraDescription = ' (actual version: '.$prettyVersion.')';
  25205. if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  25206. $prettyVersion = $match[1];
  25207. } else {
  25208. $prettyVersion = '0';
  25209. }
  25210. $version = $this->versionParser->normalize($prettyVersion);
  25211. }
  25212. $packageName = $this->buildPackageName($name);
  25213. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  25214. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  25215. if ($name === 'uuid') {
  25216. $ext->setReplaces(array(
  25217. new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  25218. ));
  25219. }
  25220. $this->addPackage($ext);
  25221. }
  25222. private function buildPackageName($name)
  25223. {
  25224. return 'ext-' . str_replace(' ', '-', strtolower($name));
  25225. }
  25226. private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
  25227. {
  25228. try {
  25229. $version = $this->versionParser->normalize($prettyVersion);
  25230. } catch (\UnexpectedValueException $e) {
  25231. return;
  25232. }
  25233. if ($description === null) {
  25234. $description = 'The '.$name.' library';
  25235. }
  25236. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  25237. $lib->setDescription($description);
  25238. $links = function ($alias) use ($name, $version, $lib) {
  25239. return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  25240. };
  25241. $lib->setReplaces(array_map($links, $replaces));
  25242. $lib->setProvides(array_map($links, $provides));
  25243. $this->addPackage($lib);
  25244. }
  25245. public static function isPlatformPackage($name)
  25246. {
  25247. static $cache = array();
  25248. if (isset($cache[$name])) {
  25249. return $cache[$name];
  25250. }
  25251. return $cache[$name] = (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  25252. }
  25253. }
  25254. <?php
  25255. namespace Composer\Repository;
  25256. use Composer\Factory;
  25257. use Composer\IO\IOInterface;
  25258. use Composer\Config;
  25259. use Composer\EventDispatcher\EventDispatcher;
  25260. use Composer\Util\HttpDownloader;
  25261. use Composer\Util\ProcessExecutor;
  25262. use Composer\Json\JsonFile;
  25263. class RepositoryFactory
  25264. {
  25265. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  25266. {
  25267. if (0 === strpos($repository, 'http')) {
  25268. $repoConfig = array('type' => 'composer', 'url' => $repository);
  25269. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  25270. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  25271. $data = $json->read();
  25272. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  25273. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  25274. } elseif ($allowFilesystem) {
  25275. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  25276. } else {
  25277. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  25278. }
  25279. } elseif (strpos($repository, '{') === 0) {
  25280. $repoConfig = JsonFile::parseJson($repository);
  25281. } else {
  25282. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  25283. }
  25284. return $repoConfig;
  25285. }
  25286. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
  25287. {
  25288. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  25289. return static::createRepo($io, $config, $repoConfig, $rm);
  25290. }
  25291. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
  25292. {
  25293. if (!$rm) {
  25294. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25295. }
  25296. $repos = static::createRepos($rm, array($repoConfig));
  25297. return reset($repos);
  25298. }
  25299. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  25300. {
  25301. if (!$config) {
  25302. $config = Factory::createConfig($io);
  25303. }
  25304. if ($io) {
  25305. $io->loadConfiguration($config);
  25306. }
  25307. if (!$rm) {
  25308. if (!$io) {
  25309. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  25310. }
  25311. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25312. }
  25313. return static::createRepos($rm, $config->getRepositories());
  25314. }
  25315. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25316. {
  25317. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  25318. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  25319. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  25320. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  25321. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  25322. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  25323. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  25324. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  25325. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  25326. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  25327. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  25328. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  25329. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  25330. $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
  25331. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  25332. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  25333. return $rm;
  25334. }
  25335. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  25336. {
  25337. $repos = array();
  25338. foreach ($repoConfigs as $index => $repo) {
  25339. if (is_string($repo)) {
  25340. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  25341. }
  25342. if (!is_array($repo)) {
  25343. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  25344. }
  25345. if (!isset($repo['type'])) {
  25346. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  25347. }
  25348. $name = self::generateRepositoryName($index, $repo, $repos);
  25349. if ($repo['type'] === 'filesystem') {
  25350. $repos[$name] = new FilesystemRepository($repo['json']);
  25351. } else {
  25352. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  25353. }
  25354. }
  25355. return $repos;
  25356. }
  25357. public static function generateRepositoryName($index, array $repo, array $existingRepos)
  25358. {
  25359. $name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
  25360. while (isset($existingRepos[$name])) {
  25361. $name .= '2';
  25362. }
  25363. return $name;
  25364. }
  25365. }
  25366. <?php
  25367. namespace Composer\Repository;
  25368. use Composer\Package\PackageInterface;
  25369. use Composer\Package\BasePackage;
  25370. use Composer\Semver\Constraint\ConstraintInterface;
  25371. interface RepositoryInterface extends \Countable
  25372. {
  25373. const SEARCH_FULLTEXT = 0;
  25374. const SEARCH_NAME = 1;
  25375. public function hasPackage(PackageInterface $package);
  25376. public function findPackage($name, $constraint);
  25377. public function findPackages($name, $constraint = null);
  25378. public function getPackages();
  25379. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  25380. public function search($query, $mode = 0, $type = null);
  25381. public function getProviders($packageName);
  25382. public function getRepoName();
  25383. }
  25384. <?php
  25385. namespace Composer\Repository;
  25386. use Composer\IO\IOInterface;
  25387. use Composer\Config;
  25388. use Composer\EventDispatcher\EventDispatcher;
  25389. use Composer\Package\PackageInterface;
  25390. use Composer\Util\HttpDownloader;
  25391. use Composer\Util\ProcessExecutor;
  25392. class RepositoryManager
  25393. {
  25394. private $localRepository;
  25395. private $repositories = array();
  25396. private $repositoryClasses = array();
  25397. private $io;
  25398. private $config;
  25399. private $httpDownloader;
  25400. private $eventDispatcher;
  25401. private $process;
  25402. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25403. {
  25404. $this->io = $io;
  25405. $this->config = $config;
  25406. $this->httpDownloader = $httpDownloader;
  25407. $this->eventDispatcher = $eventDispatcher;
  25408. $this->process = $process ?: new ProcessExecutor($io);
  25409. }
  25410. public function findPackage($name, $constraint)
  25411. {
  25412. foreach ($this->repositories as $repository) {
  25413. if ($package = $repository->findPackage($name, $constraint)) {
  25414. return $package;
  25415. }
  25416. }
  25417. return null;
  25418. }
  25419. public function findPackages($name, $constraint)
  25420. {
  25421. $packages = array();
  25422. foreach ($this->getRepositories() as $repository) {
  25423. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  25424. }
  25425. return $packages;
  25426. }
  25427. public function addRepository(RepositoryInterface $repository)
  25428. {
  25429. $this->repositories[] = $repository;
  25430. }
  25431. public function prependRepository(RepositoryInterface $repository)
  25432. {
  25433. array_unshift($this->repositories, $repository);
  25434. }
  25435. public function createRepository($type, $config, $name = null)
  25436. {
  25437. if (!isset($this->repositoryClasses[$type])) {
  25438. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  25439. }
  25440. if (isset($config['packagist']) && false === $config['packagist']) {
  25441. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  25442. }
  25443. $class = $this->repositoryClasses[$type];
  25444. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  25445. $filterConfig = $config;
  25446. unset($config['only'], $config['exclude'], $config['canonical']);
  25447. }
  25448. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  25449. if (isset($filterConfig)) {
  25450. $repository = new FilterRepository($repository, $filterConfig);
  25451. }
  25452. return $repository;
  25453. }
  25454. public function setRepositoryClass($type, $class)
  25455. {
  25456. $this->repositoryClasses[$type] = $class;
  25457. }
  25458. public function getRepositories()
  25459. {
  25460. return $this->repositories;
  25461. }
  25462. public function setLocalRepository(InstalledRepositoryInterface $repository)
  25463. {
  25464. $this->localRepository = $repository;
  25465. }
  25466. public function getLocalRepository()
  25467. {
  25468. return $this->localRepository;
  25469. }
  25470. }
  25471. <?php
  25472. namespace Composer\Repository;
  25473. class RepositorySecurityException extends \Exception
  25474. {
  25475. }
  25476. <?php
  25477. namespace Composer\Repository;
  25478. use Composer\DependencyResolver\Pool;
  25479. use Composer\DependencyResolver\PoolBuilder;
  25480. use Composer\DependencyResolver\Request;
  25481. use Composer\EventDispatcher\EventDispatcher;
  25482. use Composer\IO\IOInterface;
  25483. use Composer\IO\NullIO;
  25484. use Composer\Package\BasePackage;
  25485. use Composer\Package\AliasPackage;
  25486. use Composer\Semver\Constraint\ConstraintInterface;
  25487. use Composer\Package\Version\StabilityFilter;
  25488. class RepositorySet
  25489. {
  25490. const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  25491. const ALLOW_SHADOWED_REPOSITORIES = 2;
  25492. private $rootAliases;
  25493. private $rootReferences;
  25494. private $repositories = array();
  25495. private $acceptableStabilities;
  25496. private $stabilityFlags;
  25497. private $rootRequires;
  25498. private $locked = false;
  25499. private $allowInstalledRepositories = false;
  25500. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  25501. {
  25502. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  25503. $this->rootReferences = $rootReferences;
  25504. $this->acceptableStabilities = array();
  25505. foreach (BasePackage::$stabilities as $stability => $value) {
  25506. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  25507. $this->acceptableStabilities[$stability] = $value;
  25508. }
  25509. }
  25510. $this->stabilityFlags = $stabilityFlags;
  25511. $this->rootRequires = $rootRequires;
  25512. foreach ($rootRequires as $name => $constraint) {
  25513. if (PlatformRepository::isPlatformPackage($name)) {
  25514. unset($this->rootRequires[$name]);
  25515. }
  25516. }
  25517. }
  25518. public function allowInstalledRepositories($allow = true)
  25519. {
  25520. $this->allowInstalledRepositories = $allow;
  25521. }
  25522. public function getRootRequires()
  25523. {
  25524. return $this->rootRequires;
  25525. }
  25526. public function addRepository(RepositoryInterface $repo)
  25527. {
  25528. if ($this->locked) {
  25529. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  25530. }
  25531. if ($repo instanceof CompositeRepository) {
  25532. $repos = $repo->getRepositories();
  25533. } else {
  25534. $repos = array($repo);
  25535. }
  25536. foreach ($repos as $repo) {
  25537. $this->repositories[] = $repo;
  25538. }
  25539. }
  25540. public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
  25541. {
  25542. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  25543. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  25544. $packages = array();
  25545. if ($loadFromAllRepos) {
  25546. foreach ($this->repositories as $repository) {
  25547. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  25548. }
  25549. } else {
  25550. foreach ($this->repositories as $repository) {
  25551. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  25552. $packages[] = $result['packages'];
  25553. foreach ($result['namesFound'] as $nameFound) {
  25554. if ($name === $nameFound) {
  25555. break 2;
  25556. }
  25557. }
  25558. }
  25559. }
  25560. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  25561. if ($ignoreStability || !$loadFromAllRepos) {
  25562. return $candidates;
  25563. }
  25564. $result = array();
  25565. foreach ($candidates as $candidate) {
  25566. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  25567. $result[] = $candidate;
  25568. }
  25569. }
  25570. return $result;
  25571. }
  25572. public function getProviders($packageName)
  25573. {
  25574. $providers = array();
  25575. foreach ($this->repositories as $repository) {
  25576. if ($repoProviders = $repository->getProviders($packageName)) {
  25577. $providers = array_merge($providers, $repoProviders);
  25578. }
  25579. }
  25580. return $providers;
  25581. }
  25582. public function isPackageAcceptable($names, $stability)
  25583. {
  25584. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  25585. }
  25586. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null)
  25587. {
  25588. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher);
  25589. foreach ($this->repositories as $repo) {
  25590. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25591. throw new \LogicException('The pool can not accept packages from an installed repository');
  25592. }
  25593. }
  25594. $this->locked = true;
  25595. return $poolBuilder->buildPool($this->repositories, $request);
  25596. }
  25597. public function createPoolWithAllPackages()
  25598. {
  25599. foreach ($this->repositories as $repo) {
  25600. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25601. throw new \LogicException('The pool can not accept packages from an installed repository');
  25602. }
  25603. }
  25604. $this->locked = true;
  25605. $packages = array();
  25606. foreach ($this->repositories as $repository) {
  25607. foreach ($repository->getPackages() as $package) {
  25608. $packages[] = $package;
  25609. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  25610. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  25611. while ($package instanceof AliasPackage) {
  25612. $package = $package->getAliasOf();
  25613. }
  25614. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  25615. $aliasPackage->setRootPackageAlias(true);
  25616. $packages[] = $aliasPackage;
  25617. }
  25618. }
  25619. }
  25620. return new Pool($packages);
  25621. }
  25622. public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
  25623. {
  25624. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  25625. }
  25626. public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
  25627. {
  25628. $request = new Request($lockedRepo);
  25629. foreach ($packageNames as $packageName) {
  25630. if (PlatformRepository::isPlatformPackage($packageName)) {
  25631. throw new \LogicException('createPoolForPackage(s) can not be used for platform packages, as they are never loaded by the PoolBuilder which expects them to be fixed. Use createPoolWithAllPackages or pass in a proper request with the platform packages you need fixed in it.');
  25632. }
  25633. $request->requireName($packageName);
  25634. }
  25635. return $this->createPool($request, new NullIO());
  25636. }
  25637. private static function getRootAliasesPerPackage(array $aliases)
  25638. {
  25639. $normalizedAliases = array();
  25640. foreach ($aliases as $alias) {
  25641. $normalizedAliases[$alias['package']][$alias['version']] = array(
  25642. 'alias' => $alias['alias'],
  25643. 'alias_normalized' => $alias['alias_normalized'],
  25644. );
  25645. }
  25646. return $normalizedAliases;
  25647. }
  25648. }
  25649. <?php
  25650. namespace Composer\Repository;
  25651. use Composer\Package\RootPackageInterface;
  25652. class RootPackageRepository extends ArrayRepository
  25653. {
  25654. public function __construct(RootPackageInterface $package)
  25655. {
  25656. parent::__construct(array($package));
  25657. }
  25658. public function getRepoName()
  25659. {
  25660. return 'root package repo';
  25661. }
  25662. }
  25663. <?php
  25664. namespace Composer\Repository\Vcs;
  25665. use Composer\Cache;
  25666. use Composer\Downloader\TransportException;
  25667. use Composer\Json\JsonFile;
  25668. use Composer\Util\Bitbucket;
  25669. use Composer\Util\Http\Response;
  25670. abstract class BitbucketDriver extends VcsDriver
  25671. {
  25672. protected $owner;
  25673. protected $repository;
  25674. protected $hasIssues;
  25675. protected $rootIdentifier;
  25676. protected $tags;
  25677. protected $branches;
  25678. protected $branchesUrl = '';
  25679. protected $tagsUrl = '';
  25680. protected $homeUrl = '';
  25681. protected $website = '';
  25682. protected $cloneHttpsUrl = '';
  25683. protected $fallbackDriver;
  25684. protected $vcsType;
  25685. public function initialize()
  25686. {
  25687. preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)$#i', $this->url, $match);
  25688. $this->owner = $match[1];
  25689. $this->repository = $match[2];
  25690. $this->originUrl = 'bitbucket.org';
  25691. $this->cache = new Cache(
  25692. $this->io,
  25693. implode('/', array(
  25694. $this->config->get('cache-repo-dir'),
  25695. $this->originUrl,
  25696. $this->owner,
  25697. $this->repository,
  25698. ))
  25699. );
  25700. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25701. }
  25702. public function getUrl()
  25703. {
  25704. if ($this->fallbackDriver) {
  25705. return $this->fallbackDriver->getUrl();
  25706. }
  25707. return $this->cloneHttpsUrl;
  25708. }
  25709. protected function getRepoData()
  25710. {
  25711. $resource = sprintf(
  25712. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  25713. $this->owner,
  25714. $this->repository,
  25715. http_build_query(
  25716. array('fields' => '-project,-owner'),
  25717. null,
  25718. '&'
  25719. )
  25720. );
  25721. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  25722. if ($this->fallbackDriver) {
  25723. return false;
  25724. }
  25725. $this->parseCloneUrls($repoData['links']['clone']);
  25726. $this->hasIssues = !empty($repoData['has_issues']);
  25727. $this->branchesUrl = $repoData['links']['branches']['href'];
  25728. $this->tagsUrl = $repoData['links']['tags']['href'];
  25729. $this->homeUrl = $repoData['links']['html']['href'];
  25730. $this->website = $repoData['website'];
  25731. $this->vcsType = $repoData['scm'];
  25732. return true;
  25733. }
  25734. public function getComposerInformation($identifier)
  25735. {
  25736. if ($this->fallbackDriver) {
  25737. return $this->fallbackDriver->getComposerInformation($identifier);
  25738. }
  25739. if (!isset($this->infoCache[$identifier])) {
  25740. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  25741. $composer = JsonFile::parseJson($res);
  25742. } else {
  25743. $composer = $this->getBaseComposerInformation($identifier);
  25744. if ($this->shouldCache($identifier)) {
  25745. $this->cache->write($identifier, json_encode($composer));
  25746. }
  25747. }
  25748. if ($composer) {
  25749. if (!isset($composer['support']['source'])) {
  25750. $label = array_search(
  25751. $identifier,
  25752. $this->getTags()
  25753. ) ?: array_search(
  25754. $identifier,
  25755. $this->getBranches()
  25756. ) ?: $identifier;
  25757. if (array_key_exists($label, $tags = $this->getTags())) {
  25758. $hash = $tags[$label];
  25759. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  25760. $hash = $branches[$label];
  25761. }
  25762. if (!isset($hash)) {
  25763. $composer['support']['source'] = sprintf(
  25764. 'https://%s/%s/%s/src',
  25765. $this->originUrl,
  25766. $this->owner,
  25767. $this->repository
  25768. );
  25769. } else {
  25770. $composer['support']['source'] = sprintf(
  25771. 'https://%s/%s/%s/src/%s/?at=%s',
  25772. $this->originUrl,
  25773. $this->owner,
  25774. $this->repository,
  25775. $hash,
  25776. $label
  25777. );
  25778. }
  25779. }
  25780. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  25781. $composer['support']['issues'] = sprintf(
  25782. 'https://%s/%s/%s/issues',
  25783. $this->originUrl,
  25784. $this->owner,
  25785. $this->repository
  25786. );
  25787. }
  25788. if (!isset($composer['homepage'])) {
  25789. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  25790. }
  25791. }
  25792. $this->infoCache[$identifier] = $composer;
  25793. }
  25794. return $this->infoCache[$identifier];
  25795. }
  25796. public function getFileContent($file, $identifier)
  25797. {
  25798. if ($this->fallbackDriver) {
  25799. return $this->fallbackDriver->getFileContent($file, $identifier);
  25800. }
  25801. if (strpos($identifier, '/') !== false) {
  25802. $branches = $this->getBranches();
  25803. if (isset($branches[$identifier])) {
  25804. $identifier = $branches[$identifier];
  25805. }
  25806. }
  25807. $resource = sprintf(
  25808. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  25809. $this->owner,
  25810. $this->repository,
  25811. $identifier,
  25812. $file
  25813. );
  25814. return $this->fetchWithOAuthCredentials($resource)->getBody();
  25815. }
  25816. public function getChangeDate($identifier)
  25817. {
  25818. if ($this->fallbackDriver) {
  25819. return $this->fallbackDriver->getChangeDate($identifier);
  25820. }
  25821. if (strpos($identifier, '/') !== false) {
  25822. $branches = $this->getBranches();
  25823. if (isset($branches[$identifier])) {
  25824. $identifier = $branches[$identifier];
  25825. }
  25826. }
  25827. $resource = sprintf(
  25828. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  25829. $this->owner,
  25830. $this->repository,
  25831. $identifier
  25832. );
  25833. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25834. return new \DateTime($commit['date']);
  25835. }
  25836. public function getSource($identifier)
  25837. {
  25838. if ($this->fallbackDriver) {
  25839. return $this->fallbackDriver->getSource($identifier);
  25840. }
  25841. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  25842. }
  25843. public function getDist($identifier)
  25844. {
  25845. if ($this->fallbackDriver) {
  25846. return $this->fallbackDriver->getDist($identifier);
  25847. }
  25848. $url = sprintf(
  25849. 'https://bitbucket.org/%s/%s/get/%s.zip',
  25850. $this->owner,
  25851. $this->repository,
  25852. $identifier
  25853. );
  25854. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  25855. }
  25856. public function getTags()
  25857. {
  25858. if ($this->fallbackDriver) {
  25859. return $this->fallbackDriver->getTags();
  25860. }
  25861. if (null === $this->tags) {
  25862. $this->tags = array();
  25863. $resource = sprintf(
  25864. '%s?%s',
  25865. $this->tagsUrl,
  25866. http_build_query(
  25867. array(
  25868. 'pagelen' => 100,
  25869. 'fields' => 'values.name,values.target.hash,next',
  25870. 'sort' => '-target.date',
  25871. ),
  25872. null,
  25873. '&'
  25874. )
  25875. );
  25876. $hasNext = true;
  25877. while ($hasNext) {
  25878. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25879. foreach ($tagsData['values'] as $data) {
  25880. $this->tags[$data['name']] = $data['target']['hash'];
  25881. }
  25882. if (empty($tagsData['next'])) {
  25883. $hasNext = false;
  25884. } else {
  25885. $resource = $tagsData['next'];
  25886. }
  25887. }
  25888. if ($this->vcsType === 'hg') {
  25889. unset($this->tags['tip']);
  25890. }
  25891. }
  25892. return $this->tags;
  25893. }
  25894. public function getBranches()
  25895. {
  25896. if ($this->fallbackDriver) {
  25897. return $this->fallbackDriver->getBranches();
  25898. }
  25899. if (null === $this->branches) {
  25900. $this->branches = array();
  25901. $resource = sprintf(
  25902. '%s?%s',
  25903. $this->branchesUrl,
  25904. http_build_query(
  25905. array(
  25906. 'pagelen' => 100,
  25907. 'fields' => 'values.name,values.target.hash,values.heads,next',
  25908. 'sort' => '-target.date',
  25909. ),
  25910. null,
  25911. '&'
  25912. )
  25913. );
  25914. $hasNext = true;
  25915. while ($hasNext) {
  25916. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25917. foreach ($branchData['values'] as $data) {
  25918. if ($this->vcsType === 'hg' && empty($data['heads'])) {
  25919. continue;
  25920. }
  25921. $this->branches[$data['name']] = $data['target']['hash'];
  25922. }
  25923. if (empty($branchData['next'])) {
  25924. $hasNext = false;
  25925. } else {
  25926. $resource = $branchData['next'];
  25927. }
  25928. }
  25929. }
  25930. return $this->branches;
  25931. }
  25932. protected function fetchWithOAuthCredentials($url, $fetchingRepoData = false)
  25933. {
  25934. try {
  25935. return parent::getContents($url);
  25936. } catch (TransportException $e) {
  25937. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  25938. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  25939. if (!$this->io->hasAuthentication($this->originUrl)
  25940. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  25941. ) {
  25942. return parent::getContents($url);
  25943. }
  25944. if (!$this->io->isInteractive() && $fetchingRepoData) {
  25945. if ($this->attemptCloneFallback()) {
  25946. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  25947. }
  25948. }
  25949. }
  25950. throw $e;
  25951. }
  25952. }
  25953. abstract protected function generateSshUrl();
  25954. protected function attemptCloneFallback()
  25955. {
  25956. try {
  25957. $this->setupFallbackDriver($this->generateSshUrl());
  25958. return true;
  25959. } catch (\RuntimeException $e) {
  25960. $this->fallbackDriver = null;
  25961. $this->io->writeError(
  25962. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  25963. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  25964. );
  25965. throw $e;
  25966. }
  25967. }
  25968. abstract protected function setupFallbackDriver($url);
  25969. protected function parseCloneUrls(array $cloneLinks)
  25970. {
  25971. foreach ($cloneLinks as $cloneLink) {
  25972. if ($cloneLink['name'] === 'https') {
  25973. $this->cloneHttpsUrl = preg_replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  25974. }
  25975. }
  25976. }
  25977. protected function getMainBranchData()
  25978. {
  25979. $resource = sprintf(
  25980. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  25981. $this->owner,
  25982. $this->repository
  25983. );
  25984. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25985. if (isset($data['mainbranch'])) {
  25986. return $data['mainbranch'];
  25987. }
  25988. return null;
  25989. }
  25990. }
  25991. <?php
  25992. namespace Composer\Repository\Vcs;
  25993. use Composer\Cache;
  25994. use Composer\Config;
  25995. use Composer\Util\ProcessExecutor;
  25996. use Composer\Util\Filesystem;
  25997. use Composer\IO\IOInterface;
  25998. class FossilDriver extends VcsDriver
  25999. {
  26000. protected $tags;
  26001. protected $branches;
  26002. protected $rootIdentifier;
  26003. protected $repoFile;
  26004. protected $checkoutDir;
  26005. public function initialize()
  26006. {
  26007. $this->checkFossil();
  26008. $this->config->prohibitUrlByConfig($this->url, $this->io);
  26009. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  26010. $this->checkoutDir = $this->url;
  26011. } else {
  26012. if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26013. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26014. }
  26015. $localName = preg_replace('{[^a-z0-9]}i', '-', $this->url);
  26016. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  26017. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  26018. $this->updateLocalRepo();
  26019. }
  26020. $this->getTags();
  26021. $this->getBranches();
  26022. }
  26023. protected function checkFossil()
  26024. {
  26025. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  26026. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  26027. }
  26028. }
  26029. protected function updateLocalRepo()
  26030. {
  26031. $fs = new Filesystem();
  26032. $fs->ensureDirectoryExists($this->checkoutDir);
  26033. if (!is_writable(dirname($this->checkoutDir))) {
  26034. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  26035. }
  26036. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  26037. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  26038. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  26039. }
  26040. } else {
  26041. $fs->removeDirectory($this->checkoutDir);
  26042. $fs->remove($this->repoFile);
  26043. $fs->ensureDirectoryExists($this->checkoutDir);
  26044. if (0 !== $this->process->execute(sprintf('fossil clone %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  26045. $output = $this->process->getErrorOutput();
  26046. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  26047. }
  26048. if (0 !== $this->process->execute(sprintf('fossil open %s --nested', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  26049. $output = $this->process->getErrorOutput();
  26050. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  26051. }
  26052. }
  26053. }
  26054. public function getRootIdentifier()
  26055. {
  26056. if (null === $this->rootIdentifier) {
  26057. $this->rootIdentifier = 'trunk';
  26058. }
  26059. return $this->rootIdentifier;
  26060. }
  26061. public function getUrl()
  26062. {
  26063. return $this->url;
  26064. }
  26065. public function getSource($identifier)
  26066. {
  26067. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  26068. }
  26069. public function getDist($identifier)
  26070. {
  26071. return null;
  26072. }
  26073. public function getFileContent($file, $identifier)
  26074. {
  26075. $command = sprintf('fossil cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26076. $this->process->execute($command, $content, $this->checkoutDir);
  26077. if (!trim($content)) {
  26078. return null;
  26079. }
  26080. return $content;
  26081. }
  26082. public function getChangeDate($identifier)
  26083. {
  26084. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  26085. list(, $date) = explode(' ', trim($output), 3);
  26086. return new \DateTime($date, new \DateTimeZone('UTC'));
  26087. }
  26088. public function getTags()
  26089. {
  26090. if (null === $this->tags) {
  26091. $tags = array();
  26092. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  26093. foreach ($this->process->splitLines($output) as $tag) {
  26094. $tags[$tag] = $tag;
  26095. }
  26096. $this->tags = $tags;
  26097. }
  26098. return $this->tags;
  26099. }
  26100. public function getBranches()
  26101. {
  26102. if (null === $this->branches) {
  26103. $branches = array();
  26104. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  26105. foreach ($this->process->splitLines($output) as $branch) {
  26106. $branch = trim(preg_replace('/^\*/', '', trim($branch)));
  26107. $branches[$branch] = $branch;
  26108. }
  26109. $this->branches = $branches;
  26110. }
  26111. return $this->branches;
  26112. }
  26113. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26114. {
  26115. if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  26116. return true;
  26117. }
  26118. if (preg_match('!/fossil/|\.fossil!', $url)) {
  26119. return true;
  26120. }
  26121. if (Filesystem::isLocalPath($url)) {
  26122. $url = Filesystem::getPlatformPath($url);
  26123. if (!is_dir($url)) {
  26124. return false;
  26125. }
  26126. $process = new ProcessExecutor($io);
  26127. if ($process->execute('fossil info', $output, $url) === 0) {
  26128. return true;
  26129. }
  26130. }
  26131. return false;
  26132. }
  26133. }
  26134. <?php
  26135. namespace Composer\Repository\Vcs;
  26136. use Composer\Config;
  26137. use Composer\IO\IOInterface;
  26138. class GitBitbucketDriver extends BitbucketDriver
  26139. {
  26140. public function getRootIdentifier()
  26141. {
  26142. if ($this->fallbackDriver) {
  26143. return $this->fallbackDriver->getRootIdentifier();
  26144. }
  26145. if (null === $this->rootIdentifier) {
  26146. if (!$this->getRepoData()) {
  26147. return $this->fallbackDriver->getRootIdentifier();
  26148. }
  26149. if ($this->vcsType !== 'git') {
  26150. throw new \RuntimeException(
  26151. $this->url.' does not appear to be a git repository, use '.
  26152. $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository'
  26153. );
  26154. }
  26155. $mainBranchData = $this->getMainBranchData();
  26156. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  26157. }
  26158. return $this->rootIdentifier;
  26159. }
  26160. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26161. {
  26162. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/(.+?)\.git$#i', $url)) {
  26163. return false;
  26164. }
  26165. if (!extension_loaded('openssl')) {
  26166. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26167. return false;
  26168. }
  26169. return true;
  26170. }
  26171. protected function setupFallbackDriver($url)
  26172. {
  26173. $this->fallbackDriver = new GitDriver(
  26174. array('url' => $url),
  26175. $this->io,
  26176. $this->config,
  26177. $this->httpDownloader,
  26178. $this->process
  26179. );
  26180. $this->fallbackDriver->initialize();
  26181. }
  26182. protected function generateSshUrl()
  26183. {
  26184. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  26185. }
  26186. }
  26187. <?php
  26188. namespace Composer\Repository\Vcs;
  26189. use Composer\Util\ProcessExecutor;
  26190. use Composer\Util\Filesystem;
  26191. use Composer\Util\Url;
  26192. use Composer\Util\Git as GitUtil;
  26193. use Composer\IO\IOInterface;
  26194. use Composer\Cache;
  26195. use Composer\Config;
  26196. class GitDriver extends VcsDriver
  26197. {
  26198. protected $tags;
  26199. protected $branches;
  26200. protected $rootIdentifier;
  26201. protected $repoDir;
  26202. public function initialize()
  26203. {
  26204. if (Filesystem::isLocalPath($this->url)) {
  26205. $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url);
  26206. if (!is_dir($this->url)) {
  26207. throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist');
  26208. }
  26209. $this->repoDir = $this->url;
  26210. $cacheUrl = realpath($this->url);
  26211. } else {
  26212. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26213. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26214. }
  26215. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  26216. GitUtil::cleanEnv();
  26217. $fs = new Filesystem();
  26218. $fs->ensureDirectoryExists(dirname($this->repoDir));
  26219. if (!is_writable(dirname($this->repoDir))) {
  26220. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  26221. }
  26222. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  26223. throw new \InvalidArgumentException('The source URL '.$this->url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
  26224. }
  26225. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  26226. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  26227. if (!is_dir($this->repoDir)) {
  26228. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  26229. }
  26230. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  26231. }
  26232. $cacheUrl = $this->url;
  26233. }
  26234. $this->getTags();
  26235. $this->getBranches();
  26236. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  26237. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26238. }
  26239. public function getRootIdentifier()
  26240. {
  26241. if (null === $this->rootIdentifier) {
  26242. $this->rootIdentifier = 'master';
  26243. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  26244. $branches = $this->process->splitLines($output);
  26245. if (!in_array('* master', $branches)) {
  26246. foreach ($branches as $branch) {
  26247. if ($branch && preg_match('{^\* +(\S+)}', $branch, $match)) {
  26248. $this->rootIdentifier = $match[1];
  26249. break;
  26250. }
  26251. }
  26252. }
  26253. }
  26254. return $this->rootIdentifier;
  26255. }
  26256. public function getUrl()
  26257. {
  26258. return $this->url;
  26259. }
  26260. public function getSource($identifier)
  26261. {
  26262. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  26263. }
  26264. public function getDist($identifier)
  26265. {
  26266. return null;
  26267. }
  26268. public function getFileContent($file, $identifier)
  26269. {
  26270. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26271. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  26272. if (!trim($content)) {
  26273. return null;
  26274. }
  26275. return $content;
  26276. }
  26277. public function getChangeDate($identifier)
  26278. {
  26279. $this->process->execute(sprintf(
  26280. 'git -c log.showSignature=false log -1 --format=%%at %s',
  26281. ProcessExecutor::escape($identifier)
  26282. ), $output, $this->repoDir);
  26283. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  26284. }
  26285. public function getTags()
  26286. {
  26287. if (null === $this->tags) {
  26288. $this->tags = array();
  26289. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  26290. foreach ($output = $this->process->splitLines($output) as $tag) {
  26291. if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  26292. $this->tags[$match[2]] = $match[1];
  26293. }
  26294. }
  26295. }
  26296. return $this->tags;
  26297. }
  26298. public function getBranches()
  26299. {
  26300. if (null === $this->branches) {
  26301. $branches = array();
  26302. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  26303. foreach ($this->process->splitLines($output) as $branch) {
  26304. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  26305. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  26306. $branches[$match[1]] = $match[2];
  26307. }
  26308. }
  26309. }
  26310. $this->branches = $branches;
  26311. }
  26312. return $this->branches;
  26313. }
  26314. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26315. {
  26316. if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  26317. return true;
  26318. }
  26319. if (Filesystem::isLocalPath($url)) {
  26320. $url = Filesystem::getPlatformPath($url);
  26321. if (!is_dir($url)) {
  26322. return false;
  26323. }
  26324. $process = new ProcessExecutor($io);
  26325. if ($process->execute('git tag', $output, $url) === 0) {
  26326. return true;
  26327. }
  26328. }
  26329. if (!$deep) {
  26330. return false;
  26331. }
  26332. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  26333. GitUtil::cleanEnv();
  26334. try {
  26335. $gitUtil->runCommand(function ($url) {
  26336. return 'git ls-remote --heads ' . ProcessExecutor::escape($url);
  26337. }, $url, sys_get_temp_dir());
  26338. } catch (\RuntimeException $e) {
  26339. return false;
  26340. }
  26341. return true;
  26342. }
  26343. }
  26344. <?php
  26345. namespace Composer\Repository\Vcs;
  26346. use Composer\Config;
  26347. use Composer\Downloader\TransportException;
  26348. use Composer\Json\JsonFile;
  26349. use Composer\Cache;
  26350. use Composer\IO\IOInterface;
  26351. use Composer\Util\GitHub;
  26352. use Composer\Util\Http\Response;
  26353. class GitHubDriver extends VcsDriver
  26354. {
  26355. protected $owner;
  26356. protected $repository;
  26357. protected $tags;
  26358. protected $branches;
  26359. protected $rootIdentifier;
  26360. protected $repoData;
  26361. protected $hasIssues;
  26362. protected $isPrivate = false;
  26363. private $isArchived = false;
  26364. private $fundingInfo;
  26365. protected $gitDriver;
  26366. public function initialize()
  26367. {
  26368. preg_match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  26369. $this->owner = $match[3];
  26370. $this->repository = $match[4];
  26371. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  26372. if ($this->originUrl === 'www.github.com') {
  26373. $this->originUrl = 'github.com';
  26374. }
  26375. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  26376. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26377. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  26378. $this->setupGitDriver($this->url);
  26379. return;
  26380. }
  26381. $this->fetchRootIdentifier();
  26382. }
  26383. public function getRepositoryUrl()
  26384. {
  26385. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  26386. }
  26387. public function getRootIdentifier()
  26388. {
  26389. if ($this->gitDriver) {
  26390. return $this->gitDriver->getRootIdentifier();
  26391. }
  26392. return $this->rootIdentifier;
  26393. }
  26394. public function getUrl()
  26395. {
  26396. if ($this->gitDriver) {
  26397. return $this->gitDriver->getUrl();
  26398. }
  26399. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26400. }
  26401. protected function getApiUrl()
  26402. {
  26403. if ('github.com' === $this->originUrl) {
  26404. $apiUrl = 'api.github.com';
  26405. } else {
  26406. $apiUrl = $this->originUrl . '/api/v3';
  26407. }
  26408. return 'https://' . $apiUrl;
  26409. }
  26410. public function getSource($identifier)
  26411. {
  26412. if ($this->gitDriver) {
  26413. return $this->gitDriver->getSource($identifier);
  26414. }
  26415. if ($this->isPrivate) {
  26416. $url = $this->generateSshUrl();
  26417. } else {
  26418. $url = $this->getUrl();
  26419. }
  26420. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  26421. }
  26422. public function getDist($identifier)
  26423. {
  26424. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  26425. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26426. }
  26427. public function getComposerInformation($identifier)
  26428. {
  26429. if ($this->gitDriver) {
  26430. return $this->gitDriver->getComposerInformation($identifier);
  26431. }
  26432. if (!isset($this->infoCache[$identifier])) {
  26433. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26434. $composer = JsonFile::parseJson($res);
  26435. } else {
  26436. $composer = $this->getBaseComposerInformation($identifier);
  26437. if ($this->shouldCache($identifier)) {
  26438. $this->cache->write($identifier, json_encode($composer));
  26439. }
  26440. }
  26441. if ($composer) {
  26442. if (!isset($composer['support']['source'])) {
  26443. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  26444. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  26445. }
  26446. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  26447. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  26448. }
  26449. if (!isset($composer['abandoned']) && $this->isArchived) {
  26450. $composer['abandoned'] = true;
  26451. }
  26452. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  26453. $composer['funding'] = $funding;
  26454. }
  26455. }
  26456. $this->infoCache[$identifier] = $composer;
  26457. }
  26458. return $this->infoCache[$identifier];
  26459. }
  26460. private function getFundingInfo()
  26461. {
  26462. if (null !== $this->fundingInfo) {
  26463. return $this->fundingInfo;
  26464. }
  26465. if ($this->originUrl !== 'github.com') {
  26466. return $this->fundingInfo = false;
  26467. }
  26468. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  26469. try {
  26470. $response = $this->httpDownloader->get($file, array(
  26471. 'retry-auth-failure' => false,
  26472. ))->decodeJson();
  26473. } catch (TransportException $e) {
  26474. continue;
  26475. }
  26476. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  26477. continue;
  26478. }
  26479. break;
  26480. }
  26481. if (empty($funding)) {
  26482. return $this->fundingInfo = false;
  26483. }
  26484. $result = array();
  26485. $key = null;
  26486. foreach (preg_split('{\r?\n}', $funding) as $line) {
  26487. $line = trim($line);
  26488. if (preg_match('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  26489. if (preg_match('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  26490. foreach (array_map('trim', preg_split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  26491. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  26492. }
  26493. } elseif (preg_match('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  26494. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  26495. }
  26496. $key = null;
  26497. } elseif (preg_match('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  26498. $key = $match[1];
  26499. } elseif ($key && preg_match('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  26500. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  26501. }
  26502. }
  26503. foreach ($result as $key => $item) {
  26504. switch ($item['type']) {
  26505. case 'tidelift':
  26506. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  26507. break;
  26508. case 'github':
  26509. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  26510. break;
  26511. case 'patreon':
  26512. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  26513. break;
  26514. case 'otechie':
  26515. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  26516. break;
  26517. case 'open_collective':
  26518. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  26519. break;
  26520. case 'liberapay':
  26521. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  26522. break;
  26523. case 'ko_fi':
  26524. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  26525. break;
  26526. case 'issuehunt':
  26527. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  26528. break;
  26529. case 'community_bridge':
  26530. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  26531. break;
  26532. }
  26533. }
  26534. return $this->fundingInfo = $result;
  26535. }
  26536. public function getFileContent($file, $identifier)
  26537. {
  26538. if ($this->gitDriver) {
  26539. return $this->gitDriver->getFileContent($file, $identifier);
  26540. }
  26541. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  26542. $resource = $this->getContents($resource)->decodeJson();
  26543. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  26544. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  26545. }
  26546. return $content;
  26547. }
  26548. public function getChangeDate($identifier)
  26549. {
  26550. if ($this->gitDriver) {
  26551. return $this->gitDriver->getChangeDate($identifier);
  26552. }
  26553. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  26554. $commit = $this->getContents($resource)->decodeJson();
  26555. return new \DateTime($commit['commit']['committer']['date']);
  26556. }
  26557. public function getTags()
  26558. {
  26559. if ($this->gitDriver) {
  26560. return $this->gitDriver->getTags();
  26561. }
  26562. if (null === $this->tags) {
  26563. $this->tags = array();
  26564. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  26565. do {
  26566. $response = $this->getContents($resource);
  26567. $tagsData = $response->decodeJson();
  26568. foreach ($tagsData as $tag) {
  26569. $this->tags[$tag['name']] = $tag['commit']['sha'];
  26570. }
  26571. $resource = $this->getNextPage($response);
  26572. } while ($resource);
  26573. }
  26574. return $this->tags;
  26575. }
  26576. public function getBranches()
  26577. {
  26578. if ($this->gitDriver) {
  26579. return $this->gitDriver->getBranches();
  26580. }
  26581. if (null === $this->branches) {
  26582. $this->branches = array();
  26583. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  26584. do {
  26585. $response = $this->getContents($resource);
  26586. $branchData = $response->decodeJson();
  26587. foreach ($branchData as $branch) {
  26588. $name = substr($branch['ref'], 11);
  26589. if ($name !== 'gh-pages') {
  26590. $this->branches[$name] = $branch['object']['sha'];
  26591. }
  26592. }
  26593. $resource = $this->getNextPage($response);
  26594. } while ($resource);
  26595. }
  26596. return $this->branches;
  26597. }
  26598. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26599. {
  26600. if (!preg_match('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  26601. return false;
  26602. }
  26603. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  26604. if (!in_array(strtolower(preg_replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  26605. return false;
  26606. }
  26607. if (!extension_loaded('openssl')) {
  26608. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26609. return false;
  26610. }
  26611. return true;
  26612. }
  26613. public function getRepoData()
  26614. {
  26615. $this->fetchRootIdentifier();
  26616. return $this->repoData;
  26617. }
  26618. protected function generateSshUrl()
  26619. {
  26620. if (false !== strpos($this->originUrl, ':')) {
  26621. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26622. }
  26623. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  26624. }
  26625. protected function getContents($url, $fetchingRepoData = false)
  26626. {
  26627. try {
  26628. return parent::getContents($url);
  26629. } catch (TransportException $e) {
  26630. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  26631. switch ($e->getCode()) {
  26632. case 401:
  26633. case 404:
  26634. if (!$fetchingRepoData) {
  26635. throw $e;
  26636. }
  26637. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  26638. return parent::getContents($url);
  26639. }
  26640. if (!$this->io->isInteractive()) {
  26641. if ($this->attemptCloneFallback()) {
  26642. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26643. }
  26644. }
  26645. $scopesIssued = array();
  26646. $scopesNeeded = array();
  26647. if ($headers = $e->getHeaders()) {
  26648. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  26649. $scopesIssued = explode(' ', $scopes);
  26650. }
  26651. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  26652. $scopesNeeded = explode(' ', $scopes);
  26653. }
  26654. }
  26655. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  26656. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  26657. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26658. }
  26659. return parent::getContents($url);
  26660. case 403:
  26661. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  26662. return parent::getContents($url);
  26663. }
  26664. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26665. if ($this->attemptCloneFallback()) {
  26666. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26667. }
  26668. }
  26669. $rateLimited = $gitHubUtil->isRateLimited($e->getHeaders());
  26670. if (!$this->io->hasAuthentication($this->originUrl)) {
  26671. if (!$this->io->isInteractive()) {
  26672. $this->io->writeError('<error>GitHub API limit exhausted. Failed to get metadata for the '.$this->url.' repository, try running in interactive mode so that you can enter your GitHub credentials to increase the API limit</error>');
  26673. throw $e;
  26674. }
  26675. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  26676. return parent::getContents($url);
  26677. }
  26678. if ($rateLimited) {
  26679. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  26680. $this->io->writeError(sprintf(
  26681. '<error>GitHub API limit (%d calls/hr) is exhausted. You are already authorized so you have to wait until %s before doing more requests</error>',
  26682. $rateLimit['limit'],
  26683. $rateLimit['reset']
  26684. ));
  26685. }
  26686. throw $e;
  26687. default:
  26688. throw $e;
  26689. }
  26690. }
  26691. }
  26692. protected function fetchRootIdentifier()
  26693. {
  26694. if ($this->repoData) {
  26695. return;
  26696. }
  26697. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  26698. try {
  26699. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  26700. } catch (TransportException $e) {
  26701. if ($e->getCode() === 499) {
  26702. $this->attemptCloneFallback();
  26703. } else {
  26704. throw $e;
  26705. }
  26706. }
  26707. if (null === $this->repoData && null !== $this->gitDriver) {
  26708. return;
  26709. }
  26710. $this->owner = $this->repoData['owner']['login'];
  26711. $this->repository = $this->repoData['name'];
  26712. $this->isPrivate = !empty($this->repoData['private']);
  26713. if (isset($this->repoData['default_branch'])) {
  26714. $this->rootIdentifier = $this->repoData['default_branch'];
  26715. } elseif (isset($this->repoData['master_branch'])) {
  26716. $this->rootIdentifier = $this->repoData['master_branch'];
  26717. } else {
  26718. $this->rootIdentifier = 'master';
  26719. }
  26720. $this->hasIssues = !empty($this->repoData['has_issues']);
  26721. $this->isArchived = !empty($this->repoData['archived']);
  26722. }
  26723. protected function attemptCloneFallback()
  26724. {
  26725. $this->isPrivate = true;
  26726. try {
  26727. $this->setupGitDriver($this->generateSshUrl());
  26728. return true;
  26729. } catch (\RuntimeException $e) {
  26730. $this->gitDriver = null;
  26731. $this->io->writeError('<error>Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your GitHub credentials</error>');
  26732. throw $e;
  26733. }
  26734. }
  26735. protected function setupGitDriver($url)
  26736. {
  26737. $this->gitDriver = new GitDriver(
  26738. array('url' => $url),
  26739. $this->io,
  26740. $this->config,
  26741. $this->httpDownloader,
  26742. $this->process
  26743. );
  26744. $this->gitDriver->initialize();
  26745. }
  26746. protected function getNextPage(Response $response)
  26747. {
  26748. $header = $response->getHeader('link');
  26749. $links = explode(',', $header);
  26750. foreach ($links as $link) {
  26751. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26752. return $match[1];
  26753. }
  26754. }
  26755. }
  26756. }
  26757. <?php
  26758. namespace Composer\Repository\Vcs;
  26759. use Composer\Config;
  26760. use Composer\Cache;
  26761. use Composer\IO\IOInterface;
  26762. use Composer\Json\JsonFile;
  26763. use Composer\Downloader\TransportException;
  26764. use Composer\Util\HttpDownloader;
  26765. use Composer\Util\GitLab;
  26766. use Composer\Util\Http\Response;
  26767. class GitLabDriver extends VcsDriver
  26768. {
  26769. private $scheme;
  26770. private $namespace;
  26771. private $repository;
  26772. private $project;
  26773. private $commits = array();
  26774. private $tags;
  26775. private $branches;
  26776. protected $gitDriver;
  26777. private $isPrivate = true;
  26778. private $hasNonstandardOrigin = false;
  26779. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  26780. public function initialize()
  26781. {
  26782. if (!preg_match(self::URL_REGEX, $this->url, $match)) {
  26783. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  26784. }
  26785. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26786. $configuredDomains = $this->config->get('gitlab-domains');
  26787. $urlParts = explode('/', $match['parts']);
  26788. $this->scheme = !empty($match['scheme'])
  26789. ? $match['scheme']
  26790. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  26791. ;
  26792. $this->originUrl = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  26793. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  26794. $this->hasNonstandardOrigin = true;
  26795. }
  26796. $this->namespace = implode('/', $urlParts);
  26797. $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
  26798. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  26799. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26800. $this->fetchProject();
  26801. }
  26802. public function setHttpDownloader(HttpDownloader $httpDownloader)
  26803. {
  26804. $this->httpDownloader = $httpDownloader;
  26805. }
  26806. public function getComposerInformation($identifier)
  26807. {
  26808. if ($this->gitDriver) {
  26809. return $this->gitDriver->getComposerInformation($identifier);
  26810. }
  26811. if (!isset($this->infoCache[$identifier])) {
  26812. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26813. $composer = JsonFile::parseJson($res);
  26814. } else {
  26815. $composer = $this->getBaseComposerInformation($identifier);
  26816. if ($this->shouldCache($identifier)) {
  26817. $this->cache->write($identifier, json_encode($composer));
  26818. }
  26819. }
  26820. if ($composer) {
  26821. if (!isset($composer['support']['issues']) && isset($this->project['_links']['issues'])) {
  26822. $composer['support']['issues'] = $this->project['_links']['issues'];
  26823. }
  26824. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  26825. $composer['abandoned'] = true;
  26826. }
  26827. }
  26828. $this->infoCache[$identifier] = $composer;
  26829. }
  26830. return $this->infoCache[$identifier];
  26831. }
  26832. public function getFileContent($file, $identifier)
  26833. {
  26834. if ($this->gitDriver) {
  26835. return $this->gitDriver->getFileContent($file, $identifier);
  26836. }
  26837. if (!preg_match('{[a-f0-9]{40}}i', $identifier)) {
  26838. $branches = $this->getBranches();
  26839. if (isset($branches[$identifier])) {
  26840. $identifier = $branches[$identifier];
  26841. }
  26842. }
  26843. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  26844. try {
  26845. $content = $this->getContents($resource)->getBody();
  26846. } catch (TransportException $e) {
  26847. if ($e->getCode() !== 404) {
  26848. throw $e;
  26849. }
  26850. return null;
  26851. }
  26852. return $content;
  26853. }
  26854. public function getChangeDate($identifier)
  26855. {
  26856. if ($this->gitDriver) {
  26857. return $this->gitDriver->getChangeDate($identifier);
  26858. }
  26859. if (isset($this->commits[$identifier])) {
  26860. return new \DateTime($this->commits[$identifier]['committed_date']);
  26861. }
  26862. return new \DateTime();
  26863. }
  26864. public function getRepositoryUrl()
  26865. {
  26866. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  26867. }
  26868. public function getUrl()
  26869. {
  26870. if ($this->gitDriver) {
  26871. return $this->gitDriver->getUrl();
  26872. }
  26873. return $this->project['web_url'];
  26874. }
  26875. public function getDist($identifier)
  26876. {
  26877. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  26878. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26879. }
  26880. public function getSource($identifier)
  26881. {
  26882. if ($this->gitDriver) {
  26883. return $this->gitDriver->getSource($identifier);
  26884. }
  26885. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  26886. }
  26887. public function getRootIdentifier()
  26888. {
  26889. if ($this->gitDriver) {
  26890. return $this->gitDriver->getRootIdentifier();
  26891. }
  26892. return $this->project['default_branch'];
  26893. }
  26894. public function getBranches()
  26895. {
  26896. if ($this->gitDriver) {
  26897. return $this->gitDriver->getBranches();
  26898. }
  26899. if (!$this->branches) {
  26900. $this->branches = $this->getReferences('branches');
  26901. }
  26902. return $this->branches;
  26903. }
  26904. public function getTags()
  26905. {
  26906. if ($this->gitDriver) {
  26907. return $this->gitDriver->getTags();
  26908. }
  26909. if (!$this->tags) {
  26910. $this->tags = $this->getReferences('tags');
  26911. }
  26912. return $this->tags;
  26913. }
  26914. public function getApiUrl()
  26915. {
  26916. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  26917. }
  26918. private function urlEncodeAll($string)
  26919. {
  26920. $encoded = '';
  26921. for ($i = 0; isset($string[$i]); $i++) {
  26922. $character = $string[$i];
  26923. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  26924. $character = '%' . sprintf('%02X', ord($character));
  26925. }
  26926. $encoded .= $character;
  26927. }
  26928. return $encoded;
  26929. }
  26930. protected function getReferences($type)
  26931. {
  26932. $perPage = 100;
  26933. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  26934. $references = array();
  26935. do {
  26936. $response = $this->getContents($resource);
  26937. $data = $response->decodeJson();
  26938. foreach ($data as $datum) {
  26939. $references[$datum['name']] = $datum['commit']['id'];
  26940. $this->commits[$datum['commit']['id']] = $datum['commit'];
  26941. }
  26942. if (count($data) >= $perPage) {
  26943. $resource = $this->getNextPage($response);
  26944. } else {
  26945. $resource = false;
  26946. }
  26947. } while ($resource);
  26948. return $references;
  26949. }
  26950. protected function fetchProject()
  26951. {
  26952. $resource = $this->getApiUrl();
  26953. $this->project = $this->getContents($resource, true)->decodeJson();
  26954. if (isset($this->project['visibility'])) {
  26955. $this->isPrivate = $this->project['visibility'] !== 'public';
  26956. } else {
  26957. $this->isPrivate = false;
  26958. }
  26959. }
  26960. protected function attemptCloneFallback()
  26961. {
  26962. if ($this->isPrivate === false) {
  26963. $url = $this->generatePublicUrl();
  26964. } else {
  26965. $url = $this->generateSshUrl();
  26966. }
  26967. try {
  26968. $this->setupGitDriver($url);
  26969. return true;
  26970. } catch (\RuntimeException $e) {
  26971. $this->gitDriver = null;
  26972. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  26973. throw $e;
  26974. }
  26975. }
  26976. protected function generateSshUrl()
  26977. {
  26978. if ($this->hasNonstandardOrigin) {
  26979. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  26980. }
  26981. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  26982. }
  26983. protected function generatePublicUrl()
  26984. {
  26985. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  26986. }
  26987. protected function setupGitDriver($url)
  26988. {
  26989. $this->gitDriver = new GitDriver(
  26990. array('url' => $url),
  26991. $this->io,
  26992. $this->config,
  26993. $this->httpDownloader,
  26994. $this->process
  26995. );
  26996. $this->gitDriver->initialize();
  26997. }
  26998. protected function getContents($url, $fetchingRepoData = false)
  26999. {
  27000. try {
  27001. $response = parent::getContents($url);
  27002. if ($fetchingRepoData) {
  27003. $json = $response->decodeJson();
  27004. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  27005. $this->isPrivate = $json['visibility'] !== 'public';
  27006. $moreThanGuestAccess = false;
  27007. foreach ($json['permissions'] as $permission) {
  27008. if ($permission && $permission['access_level'] > 10) {
  27009. $moreThanGuestAccess = true;
  27010. }
  27011. }
  27012. if (!$moreThanGuestAccess) {
  27013. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  27014. return $this->attemptCloneFallback();
  27015. }
  27016. }
  27017. if (!isset($json['default_branch'])) {
  27018. if (!empty($json['id'])) {
  27019. $this->isPrivate = false;
  27020. }
  27021. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  27022. }
  27023. }
  27024. return $response;
  27025. } catch (TransportException $e) {
  27026. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  27027. switch ($e->getCode()) {
  27028. case 401:
  27029. case 404:
  27030. if (!$fetchingRepoData) {
  27031. throw $e;
  27032. }
  27033. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  27034. return parent::getContents($url);
  27035. }
  27036. if (!$this->io->isInteractive()) {
  27037. if ($this->attemptCloneFallback()) {
  27038. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  27039. }
  27040. }
  27041. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  27042. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  27043. return parent::getContents($url);
  27044. case 403:
  27045. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  27046. return parent::getContents($url);
  27047. }
  27048. if (!$this->io->isInteractive() && $fetchingRepoData) {
  27049. if ($this->attemptCloneFallback()) {
  27050. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  27051. }
  27052. }
  27053. throw $e;
  27054. default:
  27055. throw $e;
  27056. }
  27057. }
  27058. }
  27059. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27060. {
  27061. if (!preg_match(self::URL_REGEX, $url, $match)) {
  27062. return false;
  27063. }
  27064. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  27065. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  27066. $urlParts = explode('/', $match['parts']);
  27067. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  27068. return false;
  27069. }
  27070. if ('https' === $scheme && !extension_loaded('openssl')) {
  27071. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  27072. return false;
  27073. }
  27074. return true;
  27075. }
  27076. protected function getNextPage(Response $response)
  27077. {
  27078. $header = $response->getHeader('link');
  27079. $links = explode(',', $header);
  27080. foreach ($links as $link) {
  27081. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  27082. return $match[1];
  27083. }
  27084. }
  27085. }
  27086. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
  27087. {
  27088. $guessedDomain = strtolower($guessedDomain);
  27089. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  27090. if ($portNumber) {
  27091. return $guessedDomain.':'.$portNumber;
  27092. }
  27093. return $guessedDomain;
  27094. }
  27095. if ($portNumber) {
  27096. $guessedDomain .= ':'.$portNumber;
  27097. }
  27098. while (null !== ($part = array_shift($urlParts))) {
  27099. $guessedDomain .= '/' . $part;
  27100. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array(preg_replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  27101. return $guessedDomain;
  27102. }
  27103. }
  27104. return false;
  27105. }
  27106. }
  27107. <?php
  27108. namespace Composer\Repository\Vcs;
  27109. use Composer\Config;
  27110. use Composer\IO\IOInterface;
  27111. class HgBitbucketDriver extends BitbucketDriver
  27112. {
  27113. public function getRootIdentifier()
  27114. {
  27115. if ($this->fallbackDriver) {
  27116. return $this->fallbackDriver->getRootIdentifier();
  27117. }
  27118. if (null === $this->rootIdentifier) {
  27119. if (!$this->getRepoData()) {
  27120. return $this->fallbackDriver->getRootIdentifier();
  27121. }
  27122. if ($this->vcsType !== 'hg') {
  27123. throw new \RuntimeException(
  27124. $this->url.' does not appear to be a mercurial repository, use '.
  27125. $this->cloneHttpsUrl.' if this is a git bitbucket repository'
  27126. );
  27127. }
  27128. $mainBranchData = $this->getMainBranchData();
  27129. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default';
  27130. }
  27131. return $this->rootIdentifier;
  27132. }
  27133. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27134. {
  27135. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#i', $url)) {
  27136. return false;
  27137. }
  27138. if (!extension_loaded('openssl')) {
  27139. $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  27140. return false;
  27141. }
  27142. return true;
  27143. }
  27144. protected function setupFallbackDriver($url)
  27145. {
  27146. $this->fallbackDriver = new HgDriver(
  27147. array('url' => $url),
  27148. $this->io,
  27149. $this->config,
  27150. $this->httpDownloader,
  27151. $this->process
  27152. );
  27153. $this->fallbackDriver->initialize();
  27154. }
  27155. protected function generateSshUrl()
  27156. {
  27157. return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository;
  27158. }
  27159. }
  27160. <?php
  27161. namespace Composer\Repository\Vcs;
  27162. use Composer\Config;
  27163. use Composer\Cache;
  27164. use Composer\Util\Hg as HgUtils;
  27165. use Composer\Util\ProcessExecutor;
  27166. use Composer\Util\Filesystem;
  27167. use Composer\IO\IOInterface;
  27168. class HgDriver extends VcsDriver
  27169. {
  27170. protected $tags;
  27171. protected $branches;
  27172. protected $rootIdentifier;
  27173. protected $repoDir;
  27174. public function initialize()
  27175. {
  27176. if (Filesystem::isLocalPath($this->url)) {
  27177. $this->repoDir = $this->url;
  27178. } else {
  27179. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  27180. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27181. }
  27182. $cacheDir = $this->config->get('cache-vcs-dir');
  27183. $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  27184. $fs = new Filesystem();
  27185. $fs->ensureDirectoryExists($cacheDir);
  27186. if (!is_writable(dirname($this->repoDir))) {
  27187. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  27188. }
  27189. $this->config->prohibitUrlByConfig($this->url, $this->io);
  27190. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  27191. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  27192. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  27193. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  27194. }
  27195. } else {
  27196. $fs->removeDirectory($this->repoDir);
  27197. $repoDir = $this->repoDir;
  27198. $command = function ($url) use ($repoDir) {
  27199. return sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  27200. };
  27201. $hgUtils->runCommand($command, $this->url, null);
  27202. }
  27203. }
  27204. $this->getTags();
  27205. $this->getBranches();
  27206. }
  27207. public function getRootIdentifier()
  27208. {
  27209. if (null === $this->rootIdentifier) {
  27210. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  27211. $output = $this->process->splitLines($output);
  27212. $this->rootIdentifier = $output[0];
  27213. }
  27214. return $this->rootIdentifier;
  27215. }
  27216. public function getUrl()
  27217. {
  27218. return $this->url;
  27219. }
  27220. public function getSource($identifier)
  27221. {
  27222. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  27223. }
  27224. public function getDist($identifier)
  27225. {
  27226. return null;
  27227. }
  27228. public function getFileContent($file, $identifier)
  27229. {
  27230. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  27231. $this->process->execute($resource, $content, $this->repoDir);
  27232. if (!trim($content)) {
  27233. return;
  27234. }
  27235. return $content;
  27236. }
  27237. public function getChangeDate($identifier)
  27238. {
  27239. $this->process->execute(
  27240. sprintf(
  27241. 'hg log --template "{date|rfc3339date}" -r %s',
  27242. ProcessExecutor::escape($identifier)
  27243. ),
  27244. $output,
  27245. $this->repoDir
  27246. );
  27247. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  27248. }
  27249. public function getTags()
  27250. {
  27251. if (null === $this->tags) {
  27252. $tags = array();
  27253. $this->process->execute('hg tags', $output, $this->repoDir);
  27254. foreach ($this->process->splitLines($output) as $tag) {
  27255. if ($tag && preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  27256. $tags[$match[1]] = $match[2];
  27257. }
  27258. }
  27259. unset($tags['tip']);
  27260. $this->tags = $tags;
  27261. }
  27262. return $this->tags;
  27263. }
  27264. public function getBranches()
  27265. {
  27266. if (null === $this->branches) {
  27267. $branches = array();
  27268. $bookmarks = array();
  27269. $this->process->execute('hg branches', $output, $this->repoDir);
  27270. foreach ($this->process->splitLines($output) as $branch) {
  27271. if ($branch && preg_match('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  27272. $branches[$match[1]] = $match[2];
  27273. }
  27274. }
  27275. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  27276. foreach ($this->process->splitLines($output) as $branch) {
  27277. if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  27278. $bookmarks[$match[1]] = $match[2];
  27279. }
  27280. }
  27281. $this->branches = array_merge($bookmarks, $branches);
  27282. }
  27283. return $this->branches;
  27284. }
  27285. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27286. {
  27287. if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  27288. return true;
  27289. }
  27290. if (Filesystem::isLocalPath($url)) {
  27291. $url = Filesystem::getPlatformPath($url);
  27292. if (!is_dir($url)) {
  27293. return false;
  27294. }
  27295. $process = new ProcessExecutor($io);
  27296. if ($process->execute('hg summary', $output, $url) === 0) {
  27297. return true;
  27298. }
  27299. }
  27300. if (!$deep) {
  27301. return false;
  27302. }
  27303. $process = new ProcessExecutor($io);
  27304. $exit = $process->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored);
  27305. return $exit === 0;
  27306. }
  27307. }
  27308. <?php
  27309. namespace Composer\Repository\Vcs;
  27310. use Composer\Config;
  27311. use Composer\Cache;
  27312. use Composer\IO\IOInterface;
  27313. use Composer\Util\ProcessExecutor;
  27314. use Composer\Util\Perforce;
  27315. class PerforceDriver extends VcsDriver
  27316. {
  27317. protected $depot;
  27318. protected $branch;
  27319. protected $perforce;
  27320. public function initialize()
  27321. {
  27322. $this->depot = $this->repoConfig['depot'];
  27323. $this->branch = '';
  27324. if (!empty($this->repoConfig['branch'])) {
  27325. $this->branch = $this->repoConfig['branch'];
  27326. }
  27327. $this->initPerforce($this->repoConfig);
  27328. $this->perforce->p4Login();
  27329. $this->perforce->checkStream();
  27330. $this->perforce->writeP4ClientSpec();
  27331. $this->perforce->connectClient();
  27332. return true;
  27333. }
  27334. private function initPerforce($repoConfig)
  27335. {
  27336. if (!empty($this->perforce)) {
  27337. return;
  27338. }
  27339. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  27340. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27341. }
  27342. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  27343. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  27344. }
  27345. public function getFileContent($file, $identifier)
  27346. {
  27347. return $this->perforce->getFileContent($file, $identifier);
  27348. }
  27349. public function getChangeDate($identifier)
  27350. {
  27351. return null;
  27352. }
  27353. public function getRootIdentifier()
  27354. {
  27355. return $this->branch;
  27356. }
  27357. public function getBranches()
  27358. {
  27359. return $this->perforce->getBranches();
  27360. }
  27361. public function getTags()
  27362. {
  27363. return $this->perforce->getTags();
  27364. }
  27365. public function getDist($identifier)
  27366. {
  27367. return null;
  27368. }
  27369. public function getSource($identifier)
  27370. {
  27371. return array(
  27372. 'type' => 'perforce',
  27373. 'url' => $this->repoConfig['url'],
  27374. 'reference' => $identifier,
  27375. 'p4user' => $this->perforce->getUser(),
  27376. );
  27377. }
  27378. public function getUrl()
  27379. {
  27380. return $this->url;
  27381. }
  27382. public function hasComposerFile($identifier)
  27383. {
  27384. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  27385. return !empty($composerInfo);
  27386. }
  27387. public function getContents($url)
  27388. {
  27389. return false;
  27390. }
  27391. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27392. {
  27393. if ($deep || preg_match('#\b(perforce|p4)\b#i', $url)) {
  27394. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  27395. }
  27396. return false;
  27397. }
  27398. public function cleanup()
  27399. {
  27400. $this->perforce->cleanupClientSpec();
  27401. $this->perforce = null;
  27402. }
  27403. public function getDepot()
  27404. {
  27405. return $this->depot;
  27406. }
  27407. public function getBranch()
  27408. {
  27409. return $this->branch;
  27410. }
  27411. }
  27412. <?php
  27413. namespace Composer\Repository\Vcs;
  27414. use Composer\Cache;
  27415. use Composer\Config;
  27416. use Composer\Json\JsonFile;
  27417. use Composer\Util\ProcessExecutor;
  27418. use Composer\Util\Filesystem;
  27419. use Composer\Util\Url;
  27420. use Composer\Util\Svn as SvnUtil;
  27421. use Composer\IO\IOInterface;
  27422. use Composer\Downloader\TransportException;
  27423. class SvnDriver extends VcsDriver
  27424. {
  27425. protected $baseUrl;
  27426. protected $tags;
  27427. protected $branches;
  27428. protected $rootIdentifier;
  27429. protected $trunkPath = 'trunk';
  27430. protected $branchesPath = 'branches';
  27431. protected $tagsPath = 'tags';
  27432. protected $packagePath = '';
  27433. protected $cacheCredentials = true;
  27434. private $util;
  27435. public function initialize()
  27436. {
  27437. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  27438. SvnUtil::cleanEnv();
  27439. if (isset($this->repoConfig['trunk-path'])) {
  27440. $this->trunkPath = $this->repoConfig['trunk-path'];
  27441. }
  27442. if (isset($this->repoConfig['branches-path'])) {
  27443. $this->branchesPath = $this->repoConfig['branches-path'];
  27444. }
  27445. if (isset($this->repoConfig['tags-path'])) {
  27446. $this->tagsPath = $this->repoConfig['tags-path'];
  27447. }
  27448. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  27449. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  27450. }
  27451. if (isset($this->repoConfig['package-path'])) {
  27452. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  27453. }
  27454. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  27455. $this->baseUrl = substr($this->url, 0, $pos);
  27456. }
  27457. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  27458. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27459. $this->getBranches();
  27460. $this->getTags();
  27461. }
  27462. public function getRootIdentifier()
  27463. {
  27464. return $this->rootIdentifier ?: $this->trunkPath;
  27465. }
  27466. public function getUrl()
  27467. {
  27468. return $this->url;
  27469. }
  27470. public function getSource($identifier)
  27471. {
  27472. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  27473. }
  27474. public function getDist($identifier)
  27475. {
  27476. return null;
  27477. }
  27478. protected function shouldCache($identifier)
  27479. {
  27480. return $this->cache && preg_match('{@\d+$}', $identifier);
  27481. }
  27482. public function getComposerInformation($identifier)
  27483. {
  27484. if (!isset($this->infoCache[$identifier])) {
  27485. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  27486. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27487. }
  27488. try {
  27489. $composer = $this->getBaseComposerInformation($identifier);
  27490. } catch (TransportException $e) {
  27491. $message = $e->getMessage();
  27492. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  27493. throw $e;
  27494. }
  27495. $composer = '';
  27496. }
  27497. if ($this->shouldCache($identifier)) {
  27498. $this->cache->write($identifier.'.json', json_encode($composer));
  27499. }
  27500. $this->infoCache[$identifier] = $composer;
  27501. }
  27502. return $this->infoCache[$identifier];
  27503. }
  27504. public function getFileContent($file, $identifier)
  27505. {
  27506. $identifier = '/' . trim($identifier, '/') . '/';
  27507. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27508. if (!empty($match[2])) {
  27509. $path = $match[1];
  27510. $rev = $match[2];
  27511. } else {
  27512. $path = $identifier;
  27513. $rev = '';
  27514. }
  27515. try {
  27516. $resource = $path.$file;
  27517. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  27518. if (!trim($output)) {
  27519. return null;
  27520. }
  27521. } catch (\RuntimeException $e) {
  27522. throw new TransportException($e->getMessage());
  27523. }
  27524. return $output;
  27525. }
  27526. public function getChangeDate($identifier)
  27527. {
  27528. $identifier = '/' . trim($identifier, '/') . '/';
  27529. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27530. if (!empty($match[2])) {
  27531. $path = $match[1];
  27532. $rev = $match[2];
  27533. } else {
  27534. $path = $identifier;
  27535. $rev = '';
  27536. }
  27537. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  27538. foreach ($this->process->splitLines($output) as $line) {
  27539. if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  27540. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  27541. }
  27542. }
  27543. return null;
  27544. }
  27545. public function getTags()
  27546. {
  27547. if (null === $this->tags) {
  27548. $this->tags = array();
  27549. if ($this->tagsPath !== false) {
  27550. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  27551. if ($output) {
  27552. foreach ($this->process->splitLines($output) as $line) {
  27553. $line = trim($line);
  27554. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27555. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27556. $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  27557. '/' . $this->tagsPath . '/' . $match[2],
  27558. $match[1]
  27559. );
  27560. }
  27561. }
  27562. }
  27563. }
  27564. }
  27565. }
  27566. return $this->tags;
  27567. }
  27568. public function getBranches()
  27569. {
  27570. if (null === $this->branches) {
  27571. $this->branches = array();
  27572. if (false === $this->trunkPath) {
  27573. $trunkParent = $this->baseUrl . '/';
  27574. } else {
  27575. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  27576. }
  27577. $output = $this->execute('svn ls --verbose', $trunkParent);
  27578. if ($output) {
  27579. foreach ($this->process->splitLines($output) as $line) {
  27580. $line = trim($line);
  27581. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27582. if (isset($match[1], $match[2]) && $match[2] === './') {
  27583. $this->branches['trunk'] = $this->buildIdentifier(
  27584. '/' . $this->trunkPath,
  27585. $match[1]
  27586. );
  27587. $this->rootIdentifier = $this->branches['trunk'];
  27588. break;
  27589. }
  27590. }
  27591. }
  27592. }
  27593. unset($output);
  27594. if ($this->branchesPath !== false) {
  27595. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  27596. if ($output) {
  27597. foreach ($this->process->splitLines(trim($output)) as $line) {
  27598. $line = trim($line);
  27599. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27600. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27601. $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  27602. '/' . $this->branchesPath . '/' . $match[2],
  27603. $match[1]
  27604. );
  27605. }
  27606. }
  27607. }
  27608. }
  27609. }
  27610. }
  27611. return $this->branches;
  27612. }
  27613. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27614. {
  27615. $url = self::normalizeUrl($url);
  27616. if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  27617. return true;
  27618. }
  27619. if (!$deep && !Filesystem::isLocalPath($url)) {
  27620. return false;
  27621. }
  27622. $process = new ProcessExecutor($io);
  27623. $exit = $process->execute(
  27624. "svn info --non-interactive ".ProcessExecutor::escape($url),
  27625. $ignoredOutput
  27626. );
  27627. if ($exit === 0) {
  27628. return true;
  27629. }
  27630. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  27631. return true;
  27632. }
  27633. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  27634. return true;
  27635. }
  27636. return false;
  27637. }
  27638. protected static function normalizeUrl($url)
  27639. {
  27640. $fs = new Filesystem();
  27641. if ($fs->isAbsolutePath($url)) {
  27642. return 'file://' . strtr($url, '\\', '/');
  27643. }
  27644. return $url;
  27645. }
  27646. protected function execute($command, $url)
  27647. {
  27648. if (null === $this->util) {
  27649. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  27650. $this->util->setCacheCredentials($this->cacheCredentials);
  27651. }
  27652. try {
  27653. return $this->util->execute($command, $url);
  27654. } catch (\RuntimeException $e) {
  27655. if (null === $this->util->binaryVersion()) {
  27656. throw new \RuntimeException('Failed to load '.$this->url.', svn was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
  27657. }
  27658. throw new \RuntimeException(
  27659. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  27660. );
  27661. }
  27662. }
  27663. protected function buildIdentifier($baseDir, $revision)
  27664. {
  27665. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  27666. }
  27667. }
  27668. <?php
  27669. namespace Composer\Repository\Vcs;
  27670. use Composer\Cache;
  27671. use Composer\Downloader\TransportException;
  27672. use Composer\Config;
  27673. use Composer\IO\IOInterface;
  27674. use Composer\Json\JsonFile;
  27675. use Composer\Util\ProcessExecutor;
  27676. use Composer\Util\HttpDownloader;
  27677. use Composer\Util\Filesystem;
  27678. use Composer\Util\Http\Response;
  27679. abstract class VcsDriver implements VcsDriverInterface
  27680. {
  27681. protected $url;
  27682. protected $originUrl;
  27683. protected $repoConfig;
  27684. protected $io;
  27685. protected $config;
  27686. protected $process;
  27687. protected $httpDownloader;
  27688. protected $infoCache = array();
  27689. protected $cache;
  27690. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  27691. {
  27692. if (Filesystem::isLocalPath($repoConfig['url'])) {
  27693. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  27694. }
  27695. $this->url = $repoConfig['url'];
  27696. $this->originUrl = $repoConfig['url'];
  27697. $this->repoConfig = $repoConfig;
  27698. $this->io = $io;
  27699. $this->config = $config;
  27700. $this->httpDownloader = $httpDownloader;
  27701. $this->process = $process;
  27702. }
  27703. protected function shouldCache($identifier)
  27704. {
  27705. return $this->cache && preg_match('{^[a-f0-9]{40}$}iD', $identifier);
  27706. }
  27707. public function getComposerInformation($identifier)
  27708. {
  27709. if (!isset($this->infoCache[$identifier])) {
  27710. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  27711. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27712. }
  27713. $composer = $this->getBaseComposerInformation($identifier);
  27714. if ($this->shouldCache($identifier)) {
  27715. $this->cache->write($identifier, json_encode($composer));
  27716. }
  27717. $this->infoCache[$identifier] = $composer;
  27718. }
  27719. return $this->infoCache[$identifier];
  27720. }
  27721. protected function getBaseComposerInformation($identifier)
  27722. {
  27723. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  27724. if (!$composerFileContent) {
  27725. return null;
  27726. }
  27727. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  27728. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  27729. $composer['time'] = $changeDate->format(DATE_RFC3339);
  27730. }
  27731. return $composer;
  27732. }
  27733. public function hasComposerFile($identifier)
  27734. {
  27735. try {
  27736. return (bool) $this->getComposerInformation($identifier);
  27737. } catch (TransportException $e) {
  27738. }
  27739. return false;
  27740. }
  27741. protected function getScheme()
  27742. {
  27743. if (extension_loaded('openssl')) {
  27744. return 'https';
  27745. }
  27746. return 'http';
  27747. }
  27748. protected function getContents($url)
  27749. {
  27750. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  27751. return $this->httpDownloader->get($url, $options);
  27752. }
  27753. public function cleanup()
  27754. {
  27755. return;
  27756. }
  27757. }
  27758. <?php
  27759. namespace Composer\Repository\Vcs;
  27760. use Composer\Config;
  27761. use Composer\IO\IOInterface;
  27762. interface VcsDriverInterface
  27763. {
  27764. public function initialize();
  27765. public function getComposerInformation($identifier);
  27766. public function getFileContent($file, $identifier);
  27767. public function getChangeDate($identifier);
  27768. public function getRootIdentifier();
  27769. public function getBranches();
  27770. public function getTags();
  27771. public function getDist($identifier);
  27772. public function getSource($identifier);
  27773. public function getUrl();
  27774. public function hasComposerFile($identifier);
  27775. public function cleanup();
  27776. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  27777. }
  27778. <?php
  27779. namespace Composer\Repository;
  27780. use Composer\Downloader\TransportException;
  27781. use Composer\Repository\Vcs\VcsDriverInterface;
  27782. use Composer\Package\Version\VersionParser;
  27783. use Composer\Package\Loader\ArrayLoader;
  27784. use Composer\Package\Loader\ValidatingArrayLoader;
  27785. use Composer\Package\Loader\InvalidPackageException;
  27786. use Composer\Package\Loader\LoaderInterface;
  27787. use Composer\EventDispatcher\EventDispatcher;
  27788. use Composer\Util\ProcessExecutor;
  27789. use Composer\Util\HttpDownloader;
  27790. use Composer\Util\Url;
  27791. use Composer\Semver\Constraint\Constraint;
  27792. use Composer\IO\IOInterface;
  27793. use Composer\Config;
  27794. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27795. {
  27796. protected $url;
  27797. protected $packageName;
  27798. protected $isVerbose;
  27799. protected $isVeryVerbose;
  27800. protected $io;
  27801. protected $config;
  27802. protected $versionParser;
  27803. protected $type;
  27804. protected $loader;
  27805. protected $repoConfig;
  27806. protected $httpDownloader;
  27807. protected $processExecutor;
  27808. protected $branchErrorOccurred = false;
  27809. private $drivers;
  27810. private $driver;
  27811. private $versionCache;
  27812. private $emptyReferences = array();
  27813. private $versionTransportExceptions = array();
  27814. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  27815. {
  27816. parent::__construct();
  27817. $this->drivers = $drivers ?: array(
  27818. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  27819. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  27820. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  27821. 'git' => 'Composer\Repository\Vcs\GitDriver',
  27822. 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
  27823. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  27824. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  27825. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  27826. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  27827. );
  27828. $this->url = $repoConfig['url'];
  27829. $this->io = $io;
  27830. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  27831. $this->isVerbose = $io->isVerbose();
  27832. $this->isVeryVerbose = $io->isVeryVerbose();
  27833. $this->config = $config;
  27834. $this->repoConfig = $repoConfig;
  27835. $this->versionCache = $versionCache;
  27836. $this->httpDownloader = $httpDownloader;
  27837. $this->processExecutor = $process ?: new ProcessExecutor($io);
  27838. }
  27839. public function getRepoName()
  27840. {
  27841. $driverClass = get_class($this->getDriver());
  27842. $driverType = array_search($driverClass, $this->drivers);
  27843. if (!$driverType) {
  27844. $driverType = $driverClass;
  27845. }
  27846. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  27847. }
  27848. public function getRepoConfig()
  27849. {
  27850. return $this->repoConfig;
  27851. }
  27852. public function setLoader(LoaderInterface $loader)
  27853. {
  27854. $this->loader = $loader;
  27855. }
  27856. public function getDriver()
  27857. {
  27858. if ($this->driver) {
  27859. return $this->driver;
  27860. }
  27861. if (isset($this->drivers[$this->type])) {
  27862. $class = $this->drivers[$this->type];
  27863. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27864. $this->driver->initialize();
  27865. return $this->driver;
  27866. }
  27867. foreach ($this->drivers as $driver) {
  27868. if ($driver::supports($this->io, $this->config, $this->url)) {
  27869. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27870. $this->driver->initialize();
  27871. return $this->driver;
  27872. }
  27873. }
  27874. foreach ($this->drivers as $driver) {
  27875. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  27876. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27877. $this->driver->initialize();
  27878. return $this->driver;
  27879. }
  27880. }
  27881. }
  27882. public function hadInvalidBranches()
  27883. {
  27884. return $this->branchErrorOccurred;
  27885. }
  27886. public function getEmptyReferences()
  27887. {
  27888. return $this->emptyReferences;
  27889. }
  27890. public function getVersionTransportExceptions()
  27891. {
  27892. return $this->versionTransportExceptions;
  27893. }
  27894. protected function initialize()
  27895. {
  27896. parent::initialize();
  27897. $isVerbose = $this->isVerbose;
  27898. $isVeryVerbose = $this->isVeryVerbose;
  27899. $driver = $this->getDriver();
  27900. if (!$driver) {
  27901. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  27902. }
  27903. $this->versionParser = new VersionParser;
  27904. if (!$this->loader) {
  27905. $this->loader = new ArrayLoader($this->versionParser);
  27906. }
  27907. $hasRootIdentifierComposerJson = false;
  27908. try {
  27909. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  27910. if ($hasRootIdentifierComposerJson) {
  27911. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  27912. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  27913. }
  27914. } catch (\Exception $e) {
  27915. if ($isVeryVerbose) {
  27916. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  27917. }
  27918. }
  27919. foreach ($driver->getTags() as $tag => $identifier) {
  27920. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  27921. if ($isVeryVerbose) {
  27922. $this->io->writeError($msg);
  27923. } elseif ($isVerbose) {
  27924. $this->io->overwriteError($msg, false);
  27925. }
  27926. $tag = str_replace('release-', '', $tag);
  27927. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  27928. if ($cachedPackage) {
  27929. $this->addPackage($cachedPackage);
  27930. continue;
  27931. }
  27932. if ($cachedPackage === false) {
  27933. $this->emptyReferences[] = $identifier;
  27934. continue;
  27935. }
  27936. if (!$parsedTag = $this->validateTag($tag)) {
  27937. if ($isVeryVerbose) {
  27938. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  27939. }
  27940. continue;
  27941. }
  27942. try {
  27943. if (!$data = $driver->getComposerInformation($identifier)) {
  27944. if ($isVeryVerbose) {
  27945. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  27946. }
  27947. $this->emptyReferences[] = $identifier;
  27948. continue;
  27949. }
  27950. if (isset($data['version'])) {
  27951. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  27952. } else {
  27953. $data['version'] = $tag;
  27954. $data['version_normalized'] = $parsedTag;
  27955. }
  27956. $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
  27957. $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  27958. unset($data['default-branch']);
  27959. if ($data['version_normalized'] !== $parsedTag) {
  27960. if ($isVeryVerbose) {
  27961. if (preg_match('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  27962. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  27963. } else {
  27964. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  27965. }
  27966. }
  27967. continue;
  27968. }
  27969. $tagPackageName = $this->packageName ?: (isset($data['name']) ? $data['name'] : '');
  27970. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  27971. if ($isVeryVerbose) {
  27972. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  27973. }
  27974. continue;
  27975. }
  27976. if ($isVeryVerbose) {
  27977. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  27978. }
  27979. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  27980. } catch (\Exception $e) {
  27981. if ($e instanceof TransportException) {
  27982. $this->versionTransportExceptions['tags'][$tag] = $e;
  27983. if ($e->getCode() === 404) {
  27984. $this->emptyReferences[] = $identifier;
  27985. }
  27986. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27987. throw $e;
  27988. }
  27989. }
  27990. if ($isVeryVerbose) {
  27991. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  27992. }
  27993. continue;
  27994. }
  27995. }
  27996. if (!$isVeryVerbose) {
  27997. $this->io->overwriteError('', false);
  27998. }
  27999. $branches = $driver->getBranches();
  28000. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  28001. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  28002. }
  28003. foreach ($branches as $branch => $identifier) {
  28004. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  28005. if ($isVeryVerbose) {
  28006. $this->io->writeError($msg);
  28007. } elseif ($isVerbose) {
  28008. $this->io->overwriteError($msg, false);
  28009. }
  28010. if (!$parsedBranch = $this->validateBranch($branch)) {
  28011. if ($isVeryVerbose) {
  28012. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  28013. }
  28014. continue;
  28015. }
  28016. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  28017. $version = 'dev-' . $branch;
  28018. } else {
  28019. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  28020. $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
  28021. }
  28022. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  28023. if ($cachedPackage) {
  28024. $this->addPackage($cachedPackage);
  28025. continue;
  28026. }
  28027. if ($cachedPackage === false) {
  28028. $this->emptyReferences[] = $identifier;
  28029. continue;
  28030. }
  28031. try {
  28032. if (!$data = $driver->getComposerInformation($identifier)) {
  28033. if ($isVeryVerbose) {
  28034. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  28035. }
  28036. $this->emptyReferences[] = $identifier;
  28037. continue;
  28038. }
  28039. $data['version'] = $version;
  28040. $data['version_normalized'] = $parsedBranch;
  28041. unset($data['default-branch']);
  28042. if ($driver->getRootIdentifier() === $branch) {
  28043. $data['default-branch'] = true;
  28044. }
  28045. if ($isVeryVerbose) {
  28046. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  28047. }
  28048. $packageData = $this->preProcess($driver, $data, $identifier);
  28049. $package = $this->loader->load($packageData);
  28050. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  28051. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  28052. }
  28053. $this->addPackage($package);
  28054. } catch (TransportException $e) {
  28055. $this->versionTransportExceptions['branches'][$branch] = $e;
  28056. if ($e->getCode() === 404) {
  28057. $this->emptyReferences[] = $identifier;
  28058. }
  28059. if ($e->getCode() === 401 || $e->getCode() === 403) {
  28060. throw $e;
  28061. }
  28062. if ($isVeryVerbose) {
  28063. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  28064. }
  28065. continue;
  28066. } catch (\Exception $e) {
  28067. if (!$isVeryVerbose) {
  28068. $this->io->writeError('');
  28069. }
  28070. $this->branchErrorOccurred = true;
  28071. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  28072. $this->io->writeError('');
  28073. continue;
  28074. }
  28075. }
  28076. $driver->cleanup();
  28077. if (!$isVeryVerbose) {
  28078. $this->io->overwriteError('', false);
  28079. }
  28080. if (!$this->getPackages()) {
  28081. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  28082. }
  28083. }
  28084. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  28085. {
  28086. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  28087. $data['name'] = $this->packageName ?: $dataPackageName;
  28088. if (!isset($data['dist'])) {
  28089. $data['dist'] = $driver->getDist($identifier);
  28090. }
  28091. if (!isset($data['source'])) {
  28092. $data['source'] = $driver->getSource($identifier);
  28093. }
  28094. return $data;
  28095. }
  28096. private function validateBranch($branch)
  28097. {
  28098. try {
  28099. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  28100. $this->versionParser->parseConstraints($normalizedBranch);
  28101. return $normalizedBranch;
  28102. } catch (\Exception $e) {
  28103. }
  28104. return false;
  28105. }
  28106. private function validateTag($version)
  28107. {
  28108. try {
  28109. return $this->versionParser->normalize($version);
  28110. } catch (\Exception $e) {
  28111. }
  28112. return false;
  28113. }
  28114. private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
  28115. {
  28116. if (!$this->versionCache) {
  28117. return;
  28118. }
  28119. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  28120. if ($cachedPackage === false) {
  28121. if ($isVeryVerbose) {
  28122. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  28123. }
  28124. return false;
  28125. }
  28126. if ($cachedPackage) {
  28127. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  28128. if ($isVeryVerbose) {
  28129. $this->io->writeError($msg);
  28130. } elseif ($isVerbose) {
  28131. $this->io->overwriteError($msg, false);
  28132. }
  28133. unset($cachedPackage['default-branch']);
  28134. if ($isDefaultBranch) {
  28135. $cachedPackage['default-branch'] = true;
  28136. }
  28137. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  28138. if ($isVeryVerbose) {
  28139. $this->io->writeError('<warning>Skipped cached version '.$version.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$cachedPackage['version_normalized'].' internally</warning>');
  28140. }
  28141. $cachedPackage = null;
  28142. }
  28143. }
  28144. if ($cachedPackage) {
  28145. return $this->loader->load($cachedPackage);
  28146. }
  28147. return null;
  28148. }
  28149. }
  28150. <?php
  28151. namespace Composer\Repository;
  28152. interface VersionCacheInterface
  28153. {
  28154. public function getVersionPackage($version, $identifier);
  28155. }
  28156. <?php
  28157. namespace Composer\Repository;
  28158. use Composer\Package\AliasPackage;
  28159. use Composer\Installer\InstallationManager;
  28160. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  28161. {
  28162. protected $devPackageNames = array();
  28163. public function setDevPackageNames(array $devPackageNames)
  28164. {
  28165. $this->devPackageNames = $devPackageNames;
  28166. }
  28167. public function getDevPackageNames()
  28168. {
  28169. return $this->devPackageNames;
  28170. }
  28171. public function write($devMode, InstallationManager $installationManager)
  28172. {
  28173. }
  28174. public function reload()
  28175. {
  28176. }
  28177. public function getCanonicalPackages()
  28178. {
  28179. $packages = $this->getPackages();
  28180. $packagesByName = array();
  28181. foreach ($packages as $package) {
  28182. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  28183. $packagesByName[$package->getName()] = $package;
  28184. }
  28185. }
  28186. $canonicalPackages = array();
  28187. foreach ($packagesByName as $package) {
  28188. while ($package instanceof AliasPackage) {
  28189. $package = $package->getAliasOf();
  28190. }
  28191. $canonicalPackages[] = $package;
  28192. }
  28193. return $canonicalPackages;
  28194. }
  28195. }
  28196. <?php
  28197. namespace Composer\Repository;
  28198. use Composer\Package\PackageInterface;
  28199. use Composer\Installer\InstallationManager;
  28200. interface WritableRepositoryInterface extends RepositoryInterface
  28201. {
  28202. public function write($devMode, InstallationManager $installationManager);
  28203. public function addPackage(PackageInterface $package);
  28204. public function removePackage(PackageInterface $package);
  28205. public function getCanonicalPackages();
  28206. public function reload();
  28207. public function setDevPackageNames(array $devPackageNames);
  28208. public function getDevPackageNames();
  28209. }
  28210. <?php
  28211. namespace Composer\Script;
  28212. use Composer\Composer;
  28213. use Composer\IO\IOInterface;
  28214. use Composer\EventDispatcher\Event as BaseEvent;
  28215. class Event extends BaseEvent
  28216. {
  28217. private $composer;
  28218. private $io;
  28219. private $devMode;
  28220. private $originatingEvent;
  28221. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  28222. {
  28223. parent::__construct($name, $args, $flags);
  28224. $this->composer = $composer;
  28225. $this->io = $io;
  28226. $this->devMode = $devMode;
  28227. }
  28228. public function getComposer()
  28229. {
  28230. return $this->composer;
  28231. }
  28232. public function getIO()
  28233. {
  28234. return $this->io;
  28235. }
  28236. public function isDevMode()
  28237. {
  28238. return $this->devMode;
  28239. }
  28240. public function getOriginatingEvent()
  28241. {
  28242. return $this->originatingEvent;
  28243. }
  28244. public function setOriginatingEvent(BaseEvent $event)
  28245. {
  28246. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  28247. return $this;
  28248. }
  28249. private function calculateOriginatingEvent(BaseEvent $event)
  28250. {
  28251. if ($event instanceof Event && $event->getOriginatingEvent()) {
  28252. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  28253. }
  28254. return $event;
  28255. }
  28256. }
  28257. <?php
  28258. namespace Composer\Script;
  28259. class ScriptEvents
  28260. {
  28261. const PRE_INSTALL_CMD = 'pre-install-cmd';
  28262. const POST_INSTALL_CMD = 'post-install-cmd';
  28263. const PRE_UPDATE_CMD = 'pre-update-cmd';
  28264. const POST_UPDATE_CMD = 'post-update-cmd';
  28265. const PRE_STATUS_CMD = 'pre-status-cmd';
  28266. const POST_STATUS_CMD = 'post-status-cmd';
  28267. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  28268. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  28269. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  28270. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  28271. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  28272. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  28273. }
  28274. <?php
  28275. namespace Composer\SelfUpdate;
  28276. class Keys
  28277. {
  28278. public static function fingerprint($path)
  28279. {
  28280. $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path))));
  28281. return implode(' ', array(
  28282. substr($hash, 0, 8),
  28283. substr($hash, 8, 8),
  28284. substr($hash, 16, 8),
  28285. substr($hash, 24, 8),
  28286. '',
  28287. substr($hash, 32, 8),
  28288. substr($hash, 40, 8),
  28289. substr($hash, 48, 8),
  28290. substr($hash, 56, 8),
  28291. ));
  28292. }
  28293. }
  28294. <?php
  28295. namespace Composer\SelfUpdate;
  28296. use Composer\Util\HttpDownloader;
  28297. use Composer\Config;
  28298. class Versions
  28299. {
  28300. public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
  28301. private $httpDownloader;
  28302. private $config;
  28303. private $channel;
  28304. private $versionsData;
  28305. public function __construct(Config $config, HttpDownloader $httpDownloader)
  28306. {
  28307. $this->httpDownloader = $httpDownloader;
  28308. $this->config = $config;
  28309. }
  28310. public function getChannel()
  28311. {
  28312. if ($this->channel) {
  28313. return $this->channel;
  28314. }
  28315. $channelFile = $this->config->get('home').'/update-channel';
  28316. if (file_exists($channelFile)) {
  28317. $channel = trim(file_get_contents($channelFile));
  28318. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  28319. return $this->channel = $channel;
  28320. }
  28321. }
  28322. return $this->channel = 'stable';
  28323. }
  28324. public function setChannel($channel)
  28325. {
  28326. if (!in_array($channel, self::$channels, true)) {
  28327. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  28328. }
  28329. $channelFile = $this->config->get('home').'/update-channel';
  28330. $this->channel = $channel;
  28331. file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
  28332. }
  28333. public function getLatest($channel = null)
  28334. {
  28335. $versions = $this->getVersionsData();
  28336. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  28337. if ($version['min-php'] <= PHP_VERSION_ID) {
  28338. return $version;
  28339. }
  28340. }
  28341. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  28342. }
  28343. private function getVersionsData()
  28344. {
  28345. if (!$this->versionsData) {
  28346. if ($this->config->get('disable-tls') === true) {
  28347. $protocol = 'http';
  28348. } else {
  28349. $protocol = 'https';
  28350. }
  28351. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  28352. }
  28353. return $this->versionsData;
  28354. }
  28355. }
  28356. <?php
  28357. namespace Composer\Util;
  28358. use Composer\Config;
  28359. use Composer\IO\IOInterface;
  28360. use Composer\Downloader\TransportException;
  28361. class AuthHelper
  28362. {
  28363. protected $io;
  28364. protected $config;
  28365. private $displayedOriginAuthentications = array();
  28366. public function __construct(IOInterface $io, Config $config)
  28367. {
  28368. $this->io = $io;
  28369. $this->config = $config;
  28370. }
  28371. public function storeAuth($origin, $storeAuth)
  28372. {
  28373. $store = false;
  28374. $configSource = $this->config->getAuthConfigSource();
  28375. if ($storeAuth === true) {
  28376. $store = $configSource;
  28377. } elseif ($storeAuth === 'prompt') {
  28378. $answer = $this->io->askAndValidate(
  28379. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  28380. function ($value) {
  28381. $input = strtolower(substr(trim($value), 0, 1));
  28382. if (in_array($input, array('y','n'))) {
  28383. return $input;
  28384. }
  28385. throw new \RuntimeException('Please answer (y)es or (n)o');
  28386. },
  28387. null,
  28388. 'y'
  28389. );
  28390. if ($answer === 'y') {
  28391. $store = $configSource;
  28392. }
  28393. }
  28394. if ($store) {
  28395. $store->addConfigSetting(
  28396. 'http-basic.'.$origin,
  28397. $this->io->getAuthentication($origin)
  28398. );
  28399. }
  28400. }
  28401. public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
  28402. {
  28403. $storeAuth = false;
  28404. if (in_array($origin, $this->config->get('github-domains'), true)) {
  28405. $gitHubUtil = new GitHub($this->io, $this->config, null);
  28406. $message = "\n";
  28407. $rateLimited = $gitHubUtil->isRateLimited($headers);
  28408. if ($rateLimited) {
  28409. $rateLimit = $gitHubUtil->getRateLimit($headers);
  28410. if ($this->io->hasAuthentication($origin)) {
  28411. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  28412. } else {
  28413. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  28414. }
  28415. $message = sprintf(
  28416. 'GitHub API limit (%d calls/hr) is exhausted, could not fetch '.$url.'. '.$message.' You can also wait until %s for the rate limit to reset.',
  28417. $rateLimit['limit'],
  28418. $rateLimit['reset']
  28419. )."\n";
  28420. } else {
  28421. $message .= 'Could not fetch '.$url.', please ';
  28422. if ($this->io->hasAuthentication($origin)) {
  28423. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  28424. } else {
  28425. $message .= 'create a GitHub OAuth token to access private repos';
  28426. }
  28427. }
  28428. if (!$gitHubUtil->authorizeOAuth($origin)
  28429. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  28430. ) {
  28431. throw new TransportException('Could not authenticate against '.$origin, 401);
  28432. }
  28433. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  28434. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  28435. $gitLabUtil = new GitLab($this->io, $this->config, null);
  28436. if ($this->io->hasAuthentication($origin) && ($auth = $this->io->getAuthentication($origin)) && in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  28437. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28438. }
  28439. if (!$gitLabUtil->authorizeOAuth($origin)
  28440. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  28441. ) {
  28442. throw new TransportException('Could not authenticate against '.$origin, 401);
  28443. }
  28444. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  28445. $askForOAuthToken = true;
  28446. $origin = 'bitbucket.org';
  28447. if ($this->io->hasAuthentication($origin)) {
  28448. $auth = $this->io->getAuthentication($origin);
  28449. if ($auth['username'] !== 'x-token-auth') {
  28450. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  28451. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  28452. if (!empty($accessToken)) {
  28453. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  28454. $askForOAuthToken = false;
  28455. }
  28456. } else {
  28457. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28458. }
  28459. }
  28460. if ($askForOAuthToken) {
  28461. $message = "\n".'Could not fetch ' . $url . ', please create a bitbucket OAuth token to ' . (($statusCode === 401 || $statusCode === 403) ? 'access private repos' : 'go over the API rate limit');
  28462. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  28463. if (!$bitBucketUtil->authorizeOAuth($origin)
  28464. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  28465. ) {
  28466. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28467. }
  28468. }
  28469. } else {
  28470. if ($statusCode === 404) {
  28471. return;
  28472. }
  28473. if (!$this->io->isInteractive()) {
  28474. if ($statusCode === 401) {
  28475. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  28476. } elseif ($statusCode === 403) {
  28477. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  28478. } else {
  28479. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  28480. }
  28481. throw new TransportException($message, $statusCode);
  28482. }
  28483. if ($this->io->hasAuthentication($origin)) {
  28484. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28485. }
  28486. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  28487. $username = $this->io->ask(' Username: ');
  28488. $password = $this->io->askAndHideAnswer(' Password: ');
  28489. $this->io->setAuthentication($origin, $username, $password);
  28490. $storeAuth = $this->config->get('store-auths');
  28491. }
  28492. return array('retry' => true, 'storeAuth' => $storeAuth);
  28493. }
  28494. public function addAuthenticationHeader(array $headers, $origin, $url)
  28495. {
  28496. if ($this->io->hasAuthentication($origin)) {
  28497. $authenticationDisplayMessage = null;
  28498. $auth = $this->io->getAuthentication($origin);
  28499. if ($auth['password'] === 'bearer') {
  28500. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28501. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  28502. if (preg_match('{^https?://api\.github\.com/}', $url)) {
  28503. $headers[] = 'Authorization: token '.$auth['username'];
  28504. $authenticationDisplayMessage = 'Using GitHub token authentication';
  28505. }
  28506. } elseif (
  28507. in_array($origin, $this->config->get('gitlab-domains'), true)
  28508. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  28509. ) {
  28510. if ($auth['password'] === 'oauth2') {
  28511. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28512. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  28513. } elseif ($auth['password'] === 'private-token' || $auth['password'] === 'gitlab-ci-token') {
  28514. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  28515. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  28516. }
  28517. } elseif (
  28518. 'bitbucket.org' === $origin
  28519. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  28520. && 'x-token-auth' === $auth['username']
  28521. ) {
  28522. if (!$this->isPublicBitBucketDownload($url)) {
  28523. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  28524. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  28525. }
  28526. } else {
  28527. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  28528. $headers[] = 'Authorization: Basic '.$authStr;
  28529. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  28530. }
  28531. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  28532. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  28533. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  28534. }
  28535. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  28536. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  28537. }
  28538. return $headers;
  28539. }
  28540. public function isPublicBitBucketDownload($urlToBitBucketFile)
  28541. {
  28542. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  28543. if (strpos($domain, 'bitbucket.org') === false) {
  28544. return true;
  28545. }
  28546. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  28547. $pathParts = explode('/', $path);
  28548. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  28549. }
  28550. }
  28551. <?php
  28552. namespace Composer\Util;
  28553. use Composer\Factory;
  28554. use Composer\IO\IOInterface;
  28555. use Composer\Config;
  28556. use Composer\Downloader\TransportException;
  28557. class Bitbucket
  28558. {
  28559. private $io;
  28560. private $config;
  28561. private $process;
  28562. private $httpDownloader;
  28563. private $token = array();
  28564. private $time;
  28565. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  28566. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null)
  28567. {
  28568. $this->io = $io;
  28569. $this->config = $config;
  28570. $this->process = $process ?: new ProcessExecutor($io);
  28571. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  28572. $this->time = $time;
  28573. }
  28574. public function getToken()
  28575. {
  28576. if (!isset($this->token['access_token'])) {
  28577. return '';
  28578. }
  28579. return $this->token['access_token'];
  28580. }
  28581. public function authorizeOAuth($originUrl)
  28582. {
  28583. if ($originUrl !== 'bitbucket.org') {
  28584. return false;
  28585. }
  28586. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  28587. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  28588. return true;
  28589. }
  28590. return false;
  28591. }
  28592. private function requestAccessToken()
  28593. {
  28594. try {
  28595. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  28596. 'retry-auth-failure' => false,
  28597. 'http' => array(
  28598. 'method' => 'POST',
  28599. 'content' => 'grant_type=client_credentials',
  28600. ),
  28601. ));
  28602. $this->token = $response->decodeJson();
  28603. } catch (TransportException $e) {
  28604. if ($e->getCode() === 400) {
  28605. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28606. $this->io->writeError('This can have two reasons:');
  28607. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  28608. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  28609. return false;
  28610. }
  28611. if (in_array($e->getCode(), array(403, 401))) {
  28612. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28613. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28614. return false;
  28615. }
  28616. throw $e;
  28617. }
  28618. return true;
  28619. }
  28620. public function authorizeOAuthInteractively($originUrl, $message = null)
  28621. {
  28622. if ($message) {
  28623. $this->io->writeError($message);
  28624. }
  28625. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  28626. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  28627. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  28628. $this->io->writeError('Ensure you enter a "Callback URL" (http://example.com is fine) or it will not be possible to create an Access Token (this callback url will not be used by composer)');
  28629. $consumerKey = trim($this->io->askAndHideAnswer('Consumer Key (hidden): '));
  28630. if (!$consumerKey) {
  28631. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  28632. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28633. return false;
  28634. }
  28635. $consumerSecret = trim($this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  28636. if (!$consumerSecret) {
  28637. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  28638. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28639. return false;
  28640. }
  28641. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28642. if (!$this->requestAccessToken()) {
  28643. return false;
  28644. }
  28645. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28646. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  28647. $this->io->writeError('<info>Consumer stored successfully.</info>');
  28648. return true;
  28649. }
  28650. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  28651. {
  28652. if (!empty($this->token) || $this->getTokenFromConfig($originUrl)) {
  28653. return $this->token['access_token'];
  28654. }
  28655. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28656. if (!$this->requestAccessToken()) {
  28657. return '';
  28658. }
  28659. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28660. return $this->token['access_token'];
  28661. }
  28662. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  28663. {
  28664. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  28665. $time = null === $this->time ? time() : $this->time;
  28666. $consumer = array(
  28667. "consumer-key" => $consumerKey,
  28668. "consumer-secret" => $consumerSecret,
  28669. "access-token" => $this->token['access_token'],
  28670. "access-token-expiration" => $time + $this->token['expires_in'],
  28671. );
  28672. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  28673. }
  28674. private function getTokenFromConfig($originUrl)
  28675. {
  28676. $authConfig = $this->config->get('bitbucket-oauth');
  28677. if (
  28678. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  28679. || time() > $authConfig[$originUrl]['access-token-expiration']
  28680. ) {
  28681. return false;
  28682. }
  28683. $this->token = array(
  28684. 'access_token' => $authConfig[$originUrl]['access-token'],
  28685. );
  28686. return true;
  28687. }
  28688. }
  28689. <?php
  28690. namespace Composer\Util;
  28691. class ComposerMirror
  28692. {
  28693. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)
  28694. {
  28695. if ($reference) {
  28696. $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  28697. }
  28698. $version = strpos($version, '/') === false ? $version : md5($version);
  28699. return str_replace(
  28700. array('%package%', '%version%', '%reference%', '%type%'),
  28701. array($packageName, $version, $reference, $type),
  28702. $mirrorUrl
  28703. );
  28704. }
  28705. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  28706. {
  28707. if (preg_match('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  28708. $url = 'gh-'.$match[1].'/'.$match[2];
  28709. } elseif (preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  28710. $url = 'bb-'.$match[1].'/'.$match[2];
  28711. } else {
  28712. $url = preg_replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  28713. }
  28714. return str_replace(
  28715. array('%package%', '%normalizedUrl%', '%type%'),
  28716. array($packageName, $url, $type),
  28717. $mirrorUrl
  28718. );
  28719. }
  28720. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  28721. {
  28722. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  28723. }
  28724. }
  28725. <?php
  28726. namespace Composer\Util;
  28727. use Composer\Package\Loader\ArrayLoader;
  28728. use Composer\Package\Loader\ValidatingArrayLoader;
  28729. use Composer\Package\Loader\InvalidPackageException;
  28730. use Composer\Json\JsonValidationException;
  28731. use Composer\IO\IOInterface;
  28732. use Composer\Json\JsonFile;
  28733. use Composer\Spdx\SpdxLicenses;
  28734. class ConfigValidator
  28735. {
  28736. const CHECK_VERSION = 1;
  28737. private $io;
  28738. public function __construct(IOInterface $io)
  28739. {
  28740. $this->io = $io;
  28741. }
  28742. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
  28743. {
  28744. $errors = array();
  28745. $publishErrors = array();
  28746. $warnings = array();
  28747. $laxValid = false;
  28748. try {
  28749. $json = new JsonFile($file, null, $this->io);
  28750. $manifest = $json->read();
  28751. $json->validateSchema(JsonFile::LAX_SCHEMA);
  28752. $laxValid = true;
  28753. $json->validateSchema();
  28754. } catch (JsonValidationException $e) {
  28755. foreach ($e->getErrors() as $message) {
  28756. if ($laxValid) {
  28757. $publishErrors[] = $message;
  28758. } else {
  28759. $errors[] = $message;
  28760. }
  28761. }
  28762. } catch (\Exception $e) {
  28763. $errors[] = $e->getMessage();
  28764. return array($errors, $publishErrors, $warnings);
  28765. }
  28766. if (empty($manifest['license'])) {
  28767. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  28768. } else {
  28769. $licenses = (array) $manifest['license'];
  28770. foreach ($licenses as $key => $license) {
  28771. if ('proprietary' === $license) {
  28772. unset($licenses[$key]);
  28773. }
  28774. }
  28775. $licenseValidator = new SpdxLicenses();
  28776. foreach ($licenses as $license) {
  28777. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  28778. if ($spdxLicense && $spdxLicense[3]) {
  28779. if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  28780. $warnings[] = sprintf(
  28781. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  28782. $license
  28783. );
  28784. } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  28785. $warnings[] = sprintf(
  28786. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  28787. $license
  28788. );
  28789. } else {
  28790. $warnings[] = sprintf(
  28791. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  28792. $license
  28793. );
  28794. }
  28795. }
  28796. }
  28797. }
  28798. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  28799. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  28800. }
  28801. if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {
  28802. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  28803. $suggestName = strtolower($suggestName);
  28804. $publishErrors[] = sprintf(
  28805. 'Name "%s" does not match the best practice (e.g. lower-cased/with-dashes). We suggest using "%s" instead. As such you will not be able to submit it to Packagist.',
  28806. $manifest['name'],
  28807. $suggestName
  28808. );
  28809. }
  28810. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  28811. $warnings[] = "The package type 'composer-installer' is deprecated. Please distribute your custom installers as plugins from now on. See https://getcomposer.org/doc/articles/plugins.md for plugin documentation.";
  28812. }
  28813. if (isset($manifest['require'], $manifest['require-dev'])) {
  28814. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  28815. if (!empty($requireOverrides)) {
  28816. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  28817. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  28818. }
  28819. }
  28820. foreach (array('provide', 'replace') as $linkType) {
  28821. if (isset($manifest[$linkType])) {
  28822. foreach (array('require', 'require-dev') as $requireType) {
  28823. if (isset($manifest[$requireType])) {
  28824. foreach ($manifest[$linkType] as $provide => $constraint) {
  28825. if (isset($manifest[$requireType][$provide])) {
  28826. $warnings[] = 'The package ' . $provide . ' in '.$requireType.' is also listed in '.$linkType.' which satisfies the requirement. Remove it from '.$linkType.' if you wish to install it.';
  28827. }
  28828. }
  28829. }
  28830. }
  28831. }
  28832. }
  28833. $require = isset($manifest['require']) ? $manifest['require'] : array();
  28834. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  28835. $packages = array_merge($require, $requireDev);
  28836. foreach ($packages as $package => $version) {
  28837. if (preg_match('/#/', $version) === 1) {
  28838. $warnings[] = sprintf(
  28839. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  28840. $package
  28841. );
  28842. }
  28843. }
  28844. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  28845. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  28846. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  28847. if (!array_key_exists($scriptName, $scripts)) {
  28848. $warnings[] = sprintf(
  28849. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  28850. $scriptName
  28851. );
  28852. }
  28853. }
  28854. if (isset($manifest['autoload']['psr-0'][''])) {
  28855. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  28856. }
  28857. if (isset($manifest['autoload']['psr-4'][''])) {
  28858. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  28859. }
  28860. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  28861. try {
  28862. if (!isset($manifest['version'])) {
  28863. $manifest['version'] = '1.0.0';
  28864. }
  28865. if (!isset($manifest['name'])) {
  28866. $manifest['name'] = 'dummy/dummy';
  28867. }
  28868. $loader->load($manifest);
  28869. } catch (InvalidPackageException $e) {
  28870. $errors = array_merge($errors, $e->getErrors());
  28871. }
  28872. $warnings = array_merge($warnings, $loader->getWarnings());
  28873. return array($errors, $publishErrors, $warnings);
  28874. }
  28875. }
  28876. <?php
  28877. namespace Composer\Util;
  28878. use Composer\IO\IOInterface;
  28879. class ErrorHandler
  28880. {
  28881. private static $io;
  28882. public static function handle($level, $message, $file, $line)
  28883. {
  28884. if (!(error_reporting() & $level)) {
  28885. return;
  28886. }
  28887. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  28888. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  28889. "\na legitimately suppressed error that you were not supposed to see.";
  28890. }
  28891. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  28892. throw new \ErrorException($message, 0, $level, $file, $line);
  28893. }
  28894. if (self::$io) {
  28895. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  28896. if (self::$io->isVerbose()) {
  28897. self::$io->writeError('<warning>Stack trace:</warning>');
  28898. self::$io->writeError(array_filter(array_map(function ($a) {
  28899. if (isset($a['line'], $a['file'])) {
  28900. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  28901. }
  28902. return null;
  28903. }, array_slice(debug_backtrace(), 2))));
  28904. }
  28905. }
  28906. return true;
  28907. }
  28908. public static function register(IOInterface $io = null)
  28909. {
  28910. set_error_handler(array(__CLASS__, 'handle'));
  28911. error_reporting(E_ALL | E_STRICT);
  28912. self::$io = $io;
  28913. }
  28914. }
  28915. <?php
  28916. namespace Composer\Util;
  28917. use RecursiveDirectoryIterator;
  28918. use RecursiveIteratorIterator;
  28919. use Symfony\Component\Filesystem\Exception\IOException;
  28920. use Symfony\Component\Finder\Finder;
  28921. class Filesystem
  28922. {
  28923. private $processExecutor;
  28924. public function __construct(ProcessExecutor $executor = null)
  28925. {
  28926. $this->processExecutor = $executor;
  28927. }
  28928. public function remove($file)
  28929. {
  28930. if (is_dir($file)) {
  28931. return $this->removeDirectory($file);
  28932. }
  28933. if (file_exists($file)) {
  28934. return $this->unlink($file);
  28935. }
  28936. return false;
  28937. }
  28938. public function isDirEmpty($dir)
  28939. {
  28940. $finder = Finder::create()
  28941. ->ignoreVCS(false)
  28942. ->ignoreDotFiles(false)
  28943. ->depth(0)
  28944. ->in($dir);
  28945. return \count($finder) === 0;
  28946. }
  28947. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  28948. {
  28949. if (is_link($dir) && file_exists($dir)) {
  28950. $this->unlink($dir);
  28951. }
  28952. if ($ensureDirectoryExists) {
  28953. $this->ensureDirectoryExists($dir);
  28954. }
  28955. if (is_dir($dir)) {
  28956. $finder = Finder::create()
  28957. ->ignoreVCS(false)
  28958. ->ignoreDotFiles(false)
  28959. ->depth(0)
  28960. ->in($dir);
  28961. foreach ($finder as $path) {
  28962. $this->remove((string) $path);
  28963. }
  28964. }
  28965. }
  28966. public function removeDirectory($directory)
  28967. {
  28968. if ($this->isSymlinkedDirectory($directory)) {
  28969. return $this->unlinkSymlinkedDirectory($directory);
  28970. }
  28971. if ($this->isJunction($directory)) {
  28972. return $this->removeJunction($directory);
  28973. }
  28974. if (is_link($directory)) {
  28975. return unlink($directory);
  28976. }
  28977. if (!is_dir($directory) || !file_exists($directory)) {
  28978. return true;
  28979. }
  28980. if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  28981. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  28982. }
  28983. if (!\function_exists('proc_open')) {
  28984. return $this->removeDirectoryPhp($directory);
  28985. }
  28986. if (Platform::isWindows()) {
  28987. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  28988. } else {
  28989. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  28990. }
  28991. $result = $this->getProcess()->execute($cmd, $output) === 0;
  28992. clearstatcache();
  28993. if ($result && !is_dir($directory)) {
  28994. return true;
  28995. }
  28996. return $this->removeDirectoryPhp($directory);
  28997. }
  28998. public function removeDirectoryPhp($directory)
  28999. {
  29000. try {
  29001. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29002. } catch (\UnexpectedValueException $e) {
  29003. clearstatcache();
  29004. usleep(100000);
  29005. if (!is_dir($directory)) {
  29006. return true;
  29007. }
  29008. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29009. }
  29010. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  29011. foreach ($ri as $file) {
  29012. if ($file->isDir()) {
  29013. $this->rmdir($file->getPathname());
  29014. } else {
  29015. $this->unlink($file->getPathname());
  29016. }
  29017. }
  29018. return $this->rmdir($directory);
  29019. }
  29020. public function ensureDirectoryExists($directory)
  29021. {
  29022. if (!is_dir($directory)) {
  29023. if (file_exists($directory)) {
  29024. throw new \RuntimeException(
  29025. $directory.' exists and is not a directory.'
  29026. );
  29027. }
  29028. if (!@mkdir($directory, 0777, true)) {
  29029. throw new \RuntimeException(
  29030. $directory.' does not exist and could not be created.'
  29031. );
  29032. }
  29033. }
  29034. }
  29035. public function unlink($path)
  29036. {
  29037. $unlinked = @$this->unlinkImplementation($path);
  29038. if (!$unlinked) {
  29039. if (Platform::isWindows()) {
  29040. usleep(350000);
  29041. $unlinked = @$this->unlinkImplementation($path);
  29042. }
  29043. if (!$unlinked) {
  29044. $error = error_get_last();
  29045. $message = 'Could not delete '.$path.': ' . @$error['message'];
  29046. if (Platform::isWindows()) {
  29047. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  29048. }
  29049. throw new \RuntimeException($message);
  29050. }
  29051. }
  29052. return true;
  29053. }
  29054. public function rmdir($path)
  29055. {
  29056. $deleted = @rmdir($path);
  29057. if (!$deleted) {
  29058. if (Platform::isWindows()) {
  29059. usleep(350000);
  29060. $deleted = @rmdir($path);
  29061. }
  29062. if (!$deleted) {
  29063. $error = error_get_last();
  29064. $message = 'Could not delete '.$path.': ' . @$error['message'];
  29065. if (Platform::isWindows()) {
  29066. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  29067. }
  29068. throw new \RuntimeException($message);
  29069. }
  29070. }
  29071. return true;
  29072. }
  29073. public function copyThenRemove($source, $target)
  29074. {
  29075. $this->copy($source, $target);
  29076. if (!is_dir($source)) {
  29077. $this->unlink($source);
  29078. return;
  29079. }
  29080. $this->removeDirectoryPhp($source);
  29081. }
  29082. public function copy($source, $target)
  29083. {
  29084. if (!is_dir($source)) {
  29085. return copy($source, $target);
  29086. }
  29087. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  29088. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  29089. $this->ensureDirectoryExists($target);
  29090. $result = true;
  29091. foreach ($ri as $file) {
  29092. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  29093. if ($file->isDir()) {
  29094. $this->ensureDirectoryExists($targetPath);
  29095. } else {
  29096. $result = $result && copy($file->getPathname(), $targetPath);
  29097. }
  29098. }
  29099. return $result;
  29100. }
  29101. public function rename($source, $target)
  29102. {
  29103. if (true === @rename($source, $target)) {
  29104. return;
  29105. }
  29106. if (!\function_exists('proc_open')) {
  29107. $this->copyThenRemove($source, $target);
  29108. return;
  29109. }
  29110. if (Platform::isWindows()) {
  29111. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  29112. $result = $this->getProcess()->execute($command, $output);
  29113. clearstatcache();
  29114. if (0 === $result) {
  29115. $this->remove($source);
  29116. return;
  29117. }
  29118. } else {
  29119. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  29120. $result = $this->getProcess()->execute($command, $output);
  29121. clearstatcache();
  29122. if (0 === $result) {
  29123. return;
  29124. }
  29125. }
  29126. $this->copyThenRemove($source, $target);
  29127. }
  29128. public function findShortestPath($from, $to, $directories = false)
  29129. {
  29130. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  29131. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  29132. }
  29133. $from = lcfirst($this->normalizePath($from));
  29134. $to = lcfirst($this->normalizePath($to));
  29135. if ($directories) {
  29136. $from = rtrim($from, '/') . '/dummy_file';
  29137. }
  29138. if (\dirname($from) === \dirname($to)) {
  29139. return './'.basename($to);
  29140. }
  29141. $commonPath = $to;
  29142. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
  29143. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  29144. }
  29145. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  29146. return $to;
  29147. }
  29148. $commonPath = rtrim($commonPath, '/') . '/';
  29149. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
  29150. $commonPathCode = str_repeat('../', $sourcePathDepth);
  29151. return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
  29152. }
  29153. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  29154. {
  29155. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  29156. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  29157. }
  29158. $from = lcfirst($this->normalizePath($from));
  29159. $to = lcfirst($this->normalizePath($to));
  29160. if ($from === $to) {
  29161. return $directories ? '__DIR__' : '__FILE__';
  29162. }
  29163. $commonPath = $to;
  29164. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  29165. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  29166. }
  29167. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  29168. return var_export($to, true);
  29169. }
  29170. $commonPath = rtrim($commonPath, '/') . '/';
  29171. if (strpos($to, $from.'/') === 0) {
  29172. return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
  29173. }
  29174. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
  29175. if ($staticCode) {
  29176. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  29177. } else {
  29178. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  29179. }
  29180. $relTarget = substr($to, \strlen($commonPath));
  29181. return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  29182. }
  29183. public function isAbsolutePath($path)
  29184. {
  29185. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  29186. }
  29187. public function size($path)
  29188. {
  29189. if (!file_exists($path)) {
  29190. throw new \RuntimeException("$path does not exist.");
  29191. }
  29192. if (is_dir($path)) {
  29193. return $this->directorySize($path);
  29194. }
  29195. return filesize($path);
  29196. }
  29197. public function normalizePath($path)
  29198. {
  29199. $parts = array();
  29200. $path = strtr($path, '\\', '/');
  29201. $prefix = '';
  29202. $absolute = false;
  29203. if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  29204. $prefix = $match[1];
  29205. $path = substr($path, \strlen($prefix));
  29206. }
  29207. if (strpos($path, '/') === 0) {
  29208. $absolute = true;
  29209. $path = substr($path, 1);
  29210. }
  29211. $up = false;
  29212. foreach (explode('/', $path) as $chunk) {
  29213. if ('..' === $chunk && ($absolute || $up)) {
  29214. array_pop($parts);
  29215. $up = !(empty($parts) || '..' === end($parts));
  29216. } elseif ('.' !== $chunk && '' !== $chunk) {
  29217. $parts[] = $chunk;
  29218. $up = '..' !== $chunk;
  29219. }
  29220. }
  29221. return $prefix.($absolute ? '/' : '').implode('/', $parts);
  29222. }
  29223. public static function trimTrailingSlash($path)
  29224. {
  29225. if (!preg_match('{^[/\\\\]+$}', $path)) {
  29226. $path = rtrim($path, '/\\');
  29227. }
  29228. return $path;
  29229. }
  29230. public static function isLocalPath($path)
  29231. {
  29232. return (bool) preg_match('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  29233. }
  29234. public static function getPlatformPath($path)
  29235. {
  29236. if (Platform::isWindows()) {
  29237. $path = preg_replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  29238. }
  29239. return preg_replace('{^file://}i', '', $path);
  29240. }
  29241. protected function directorySize($directory)
  29242. {
  29243. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29244. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  29245. $size = 0;
  29246. foreach ($ri as $file) {
  29247. if ($file->isFile()) {
  29248. $size += $file->getSize();
  29249. }
  29250. }
  29251. return $size;
  29252. }
  29253. protected function getProcess()
  29254. {
  29255. if (!$this->processExecutor) {
  29256. $this->processExecutor = new ProcessExecutor();
  29257. }
  29258. return $this->processExecutor;
  29259. }
  29260. private function unlinkImplementation($path)
  29261. {
  29262. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  29263. return rmdir($path);
  29264. }
  29265. return unlink($path);
  29266. }
  29267. public function relativeSymlink($target, $link)
  29268. {
  29269. if (!function_exists('symlink')) {
  29270. return false;
  29271. }
  29272. $cwd = getcwd();
  29273. $relativePath = $this->findShortestPath($link, $target);
  29274. chdir(\dirname($link));
  29275. $result = @symlink($relativePath, $link);
  29276. chdir($cwd);
  29277. return $result;
  29278. }
  29279. public function isSymlinkedDirectory($directory)
  29280. {
  29281. if (!is_dir($directory)) {
  29282. return false;
  29283. }
  29284. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29285. return is_link($resolved);
  29286. }
  29287. private function unlinkSymlinkedDirectory($directory)
  29288. {
  29289. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29290. return $this->unlink($resolved);
  29291. }
  29292. private function resolveSymlinkedDirectorySymlink($pathname)
  29293. {
  29294. if (!is_dir($pathname)) {
  29295. return $pathname;
  29296. }
  29297. $resolved = rtrim($pathname, '/');
  29298. if (!\strlen($resolved)) {
  29299. return $pathname;
  29300. }
  29301. return $resolved;
  29302. }
  29303. public function junction($target, $junction)
  29304. {
  29305. if (!Platform::isWindows()) {
  29306. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  29307. }
  29308. if (!is_dir($target)) {
  29309. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  29310. }
  29311. $cmd = sprintf(
  29312. 'mklink /J %s %s',
  29313. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  29314. ProcessExecutor::escape(realpath($target))
  29315. );
  29316. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  29317. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  29318. }
  29319. clearstatcache(true, $junction);
  29320. }
  29321. public function isJunction($junction)
  29322. {
  29323. if (!Platform::isWindows()) {
  29324. return false;
  29325. }
  29326. clearstatcache(true, $junction);
  29327. if (!is_dir($junction) || is_link($junction)) {
  29328. return false;
  29329. }
  29330. $stat = lstat($junction);
  29331. return $stat ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  29332. }
  29333. public function removeJunction($junction)
  29334. {
  29335. if (!Platform::isWindows()) {
  29336. return false;
  29337. }
  29338. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  29339. if (!$this->isJunction($junction)) {
  29340. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  29341. }
  29342. return $this->rmdir($junction);
  29343. }
  29344. public function filePutContentsIfModified($path, $content)
  29345. {
  29346. $currentContent = @file_get_contents($path);
  29347. if (!$currentContent || ($currentContent != $content)) {
  29348. return file_put_contents($path, $content);
  29349. }
  29350. return 0;
  29351. }
  29352. public function safeCopy($source, $target)
  29353. {
  29354. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  29355. $source = fopen($source, 'r');
  29356. $target = fopen($target, 'w+');
  29357. stream_copy_to_stream($source, $target);
  29358. fclose($source);
  29359. fclose($target);
  29360. }
  29361. }
  29362. private function filesAreEqual($a, $b)
  29363. {
  29364. if (filesize($a) !== filesize($b)) {
  29365. return false;
  29366. }
  29367. $ah = fopen($a, 'rb');
  29368. $bh = fopen($b, 'rb');
  29369. $result = true;
  29370. while (!feof($ah)) {
  29371. if (fread($ah, 8192) != fread($bh, 8192)) {
  29372. $result = false;
  29373. break;
  29374. }
  29375. }
  29376. fclose($ah);
  29377. fclose($bh);
  29378. return $result;
  29379. }
  29380. }
  29381. <?php
  29382. namespace Composer\Util;
  29383. use Composer\Config;
  29384. use Composer\IO\IOInterface;
  29385. class Git
  29386. {
  29387. private static $version = false;
  29388. protected $io;
  29389. protected $config;
  29390. protected $process;
  29391. protected $filesystem;
  29392. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  29393. {
  29394. $this->io = $io;
  29395. $this->config = $config;
  29396. $this->process = $process;
  29397. $this->filesystem = $fs;
  29398. }
  29399. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  29400. {
  29401. $this->config->prohibitUrlByConfig($url, $this->io);
  29402. if ($initialClone) {
  29403. $origCwd = $cwd;
  29404. $cwd = null;
  29405. }
  29406. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  29407. throw new \InvalidArgumentException('The source URL ' . $url . ' is invalid, ssh URLs should have a port number after ":".' . "\n" . 'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
  29408. }
  29409. if (!$initialClone) {
  29410. $this->process->execute('git remote -v', $output, $cwd);
  29411. if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  29412. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  29413. }
  29414. }
  29415. $protocols = $this->config->get('github-protocols');
  29416. if (!is_array($protocols)) {
  29417. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  29418. }
  29419. if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  29420. $messages = array();
  29421. foreach ($protocols as $protocol) {
  29422. if ('ssh' === $protocol) {
  29423. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  29424. } else {
  29425. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  29426. }
  29427. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  29428. return;
  29429. }
  29430. $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
  29431. if ($initialClone && isset($origCwd)) {
  29432. $this->filesystem->removeDirectory($origCwd);
  29433. }
  29434. }
  29435. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  29436. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  29437. }
  29438. }
  29439. $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  29440. $command = call_user_func($commandCallable, $url);
  29441. $auth = null;
  29442. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  29443. $errorMsg = $this->process->getErrorOutput();
  29444. if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  29445. || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}i', $url, $match)
  29446. ) {
  29447. if (!$this->io->hasAuthentication($match[1])) {
  29448. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  29449. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  29450. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29451. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  29452. }
  29453. }
  29454. if ($this->io->hasAuthentication($match[1])) {
  29455. $auth = $this->io->getAuthentication($match[1]);
  29456. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29457. $command = call_user_func($commandCallable, $authUrl);
  29458. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29459. return;
  29460. }
  29461. $errorMsg = $this->process->getErrorOutput();
  29462. }
  29463. } elseif (preg_match('{^https://(bitbucket\.org)/(.*?)(?:\.git)?$}i', $url, $match)) {
  29464. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  29465. if (!$this->io->hasAuthentication($match[1])) {
  29466. $message = 'Enter your Bitbucket credentials to access private repos';
  29467. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29468. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  29469. $accessToken = $bitbucketUtil->getToken();
  29470. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29471. }
  29472. } else {
  29473. $auth = $this->io->getAuthentication($match[1]);
  29474. if ($auth['username'] !== 'x-token-auth') {
  29475. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  29476. if (!empty($accessToken)) {
  29477. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29478. }
  29479. }
  29480. }
  29481. if ($this->io->hasAuthentication($match[1])) {
  29482. $auth = $this->io->getAuthentication($match[1]);
  29483. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29484. $command = call_user_func($commandCallable, $authUrl);
  29485. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29486. return;
  29487. }
  29488. $errorMsg = $this->process->getErrorOutput();
  29489. } else {
  29490. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  29491. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  29492. $command = call_user_func($commandCallable, $sshUrl);
  29493. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29494. return;
  29495. }
  29496. $errorMsg = $this->process->getErrorOutput();
  29497. }
  29498. } elseif (
  29499. preg_match('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  29500. || preg_match('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}i', $url, $match)
  29501. ) {
  29502. if ($match[1] === 'git') {
  29503. $match[1] = 'https';
  29504. }
  29505. if (!$this->io->hasAuthentication($match[2])) {
  29506. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  29507. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  29508. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  29509. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  29510. }
  29511. }
  29512. if ($this->io->hasAuthentication($match[2])) {
  29513. $auth = $this->io->getAuthentication($match[2]);
  29514. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  29515. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  29516. } else {
  29517. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  29518. }
  29519. $command = call_user_func($commandCallable, $authUrl);
  29520. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29521. return;
  29522. }
  29523. $errorMsg = $this->process->getErrorOutput();
  29524. }
  29525. } elseif ($this->isAuthenticationFailure($url, $match)) {
  29526. if (strpos($match[2], '@')) {
  29527. list($authParts, $match[2]) = explode('@', $match[2], 2);
  29528. }
  29529. $storeAuth = false;
  29530. if ($this->io->hasAuthentication($match[2])) {
  29531. $auth = $this->io->getAuthentication($match[2]);
  29532. } elseif ($this->io->isInteractive()) {
  29533. $defaultUsername = null;
  29534. if (isset($authParts) && $authParts) {
  29535. if (false !== strpos($authParts, ':')) {
  29536. list($defaultUsername, ) = explode(':', $authParts, 2);
  29537. } else {
  29538. $defaultUsername = $authParts;
  29539. }
  29540. }
  29541. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  29542. $auth = array(
  29543. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  29544. 'password' => $this->io->askAndHideAnswer(' Password: '),
  29545. );
  29546. $storeAuth = $this->config->get('store-auths');
  29547. }
  29548. if ($auth) {
  29549. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  29550. $command = call_user_func($commandCallable, $authUrl);
  29551. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29552. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  29553. $authHelper = new AuthHelper($this->io, $this->config);
  29554. $authHelper->storeAuth($match[2], $storeAuth);
  29555. return;
  29556. }
  29557. $errorMsg = $this->process->getErrorOutput();
  29558. }
  29559. }
  29560. if ($initialClone && isset($origCwd)) {
  29561. $this->filesystem->removeDirectory($origCwd);
  29562. }
  29563. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  29564. }
  29565. }
  29566. public function syncMirror($url, $dir)
  29567. {
  29568. if (getenv('COMPOSER_DISABLE_NETWORK') && getenv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  29569. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  29570. return false;
  29571. }
  29572. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29573. try {
  29574. $commandCallable = function ($url) {
  29575. $sanitizedUrl = preg_replace('{://([^@]+?):(.+?)@}', '://', $url);
  29576. return sprintf('git remote set-url origin %s && git remote update --prune origin && git remote set-url origin %s && git gc --auto', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  29577. };
  29578. $this->runCommand($commandCallable, $url, $dir);
  29579. } catch (\Exception $e) {
  29580. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  29581. return false;
  29582. }
  29583. return true;
  29584. }
  29585. $this->filesystem->removeDirectory($dir);
  29586. $commandCallable = function ($url) use ($dir) {
  29587. return sprintf('git clone --mirror %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  29588. };
  29589. $this->runCommand($commandCallable, $url, $dir, true);
  29590. return true;
  29591. }
  29592. public function fetchRefOrSyncMirror($url, $dir, $ref)
  29593. {
  29594. if ($this->checkRefIsInMirror($dir, $ref)) {
  29595. return true;
  29596. }
  29597. if ($this->syncMirror($url, $dir)) {
  29598. return $this->checkRefIsInMirror($dir, $ref);
  29599. }
  29600. return false;
  29601. }
  29602. public static function getNoShowSignatureFlag(ProcessExecutor $process)
  29603. {
  29604. $gitVersion = self::getVersion($process);
  29605. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  29606. return ' --no-show-signature';
  29607. }
  29608. return '';
  29609. }
  29610. private function checkRefIsInMirror($dir, $ref)
  29611. {
  29612. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29613. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  29614. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  29615. if ($exitCode === 0) {
  29616. return true;
  29617. }
  29618. }
  29619. return false;
  29620. }
  29621. private function isAuthenticationFailure($url, &$match)
  29622. {
  29623. if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  29624. return false;
  29625. }
  29626. $authFailures = array(
  29627. 'fatal: Authentication failed',
  29628. 'remote error: Invalid username or password.',
  29629. 'error: 401 Unauthorized',
  29630. 'fatal: unable to access',
  29631. 'fatal: could not read Username',
  29632. );
  29633. $errorOutput = $this->process->getErrorOutput();
  29634. foreach ($authFailures as $authFailure) {
  29635. if (strpos($errorOutput, $authFailure) !== false) {
  29636. return true;
  29637. }
  29638. }
  29639. return false;
  29640. }
  29641. public static function cleanEnv()
  29642. {
  29643. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  29644. throw new \RuntimeException('safe_mode is enabled and safe_mode_allowed_env_vars does not contain GIT_ASKPASS, can not set env var. You can disable safe_mode with "-dsafe_mode=0" when running composer');
  29645. }
  29646. if (getenv('GIT_ASKPASS') !== 'echo') {
  29647. putenv('GIT_ASKPASS=echo');
  29648. $_SERVER['GIT_ASKPASS'] = 'echo';
  29649. }
  29650. if (getenv('GIT_DIR')) {
  29651. putenv('GIT_DIR');
  29652. unset($_SERVER['GIT_DIR']);
  29653. }
  29654. if (getenv('GIT_WORK_TREE')) {
  29655. putenv('GIT_WORK_TREE');
  29656. unset($_SERVER['GIT_WORK_TREE']);
  29657. }
  29658. if (getenv('LANGUAGE') !== 'C') {
  29659. putenv('LANGUAGE=C');
  29660. $_SERVER['LANGUAGE'] = 'C';
  29661. }
  29662. putenv("DYLD_LIBRARY_PATH");
  29663. unset($_SERVER['DYLD_LIBRARY_PATH']);
  29664. }
  29665. public static function getGitHubDomainsRegex(Config $config)
  29666. {
  29667. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  29668. }
  29669. public static function getGitLabDomainsRegex(Config $config)
  29670. {
  29671. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  29672. }
  29673. private function throwException($message, $url)
  29674. {
  29675. clearstatcache();
  29676. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  29677. throw new \RuntimeException(Url::sanitize('Failed to clone ' . $url . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()));
  29678. }
  29679. throw new \RuntimeException(Url::sanitize($message));
  29680. }
  29681. public static function getVersion(ProcessExecutor $process)
  29682. {
  29683. if (false === self::$version) {
  29684. self::$version = null;
  29685. if (0 === $process->execute('git --version', $output) && preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  29686. self::$version = $matches[1];
  29687. }
  29688. }
  29689. return self::$version;
  29690. }
  29691. }
  29692. <?php
  29693. namespace Composer\Util;
  29694. use Composer\Factory;
  29695. use Composer\IO\IOInterface;
  29696. use Composer\Config;
  29697. use Composer\Downloader\TransportException;
  29698. class GitHub
  29699. {
  29700. protected $io;
  29701. protected $config;
  29702. protected $process;
  29703. protected $httpDownloader;
  29704. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29705. {
  29706. $this->io = $io;
  29707. $this->config = $config;
  29708. $this->process = $process ?: new ProcessExecutor($io);
  29709. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29710. }
  29711. public function authorizeOAuth($originUrl)
  29712. {
  29713. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  29714. return false;
  29715. }
  29716. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  29717. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  29718. return true;
  29719. }
  29720. return false;
  29721. }
  29722. public function authorizeOAuthInteractively($originUrl, $message = null)
  29723. {
  29724. if ($message) {
  29725. $this->io->writeError($message);
  29726. }
  29727. $note = 'Composer';
  29728. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  29729. $note .= ' on ' . trim($output);
  29730. }
  29731. $note .= ' ' . date('Y-m-d Hi');
  29732. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  29733. $this->io->writeError(sprintf('Head to %s', $url));
  29734. $this->io->writeError(sprintf('to retrieve a token. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  29735. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  29736. if (!$token) {
  29737. $this->io->writeError('<warning>No token given, aborting.</warning>');
  29738. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29739. return false;
  29740. }
  29741. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  29742. try {
  29743. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  29744. $this->httpDownloader->get('https://'. $apiUrl, array(
  29745. 'retry-auth-failure' => false,
  29746. ));
  29747. } catch (TransportException $e) {
  29748. if (in_array($e->getCode(), array(403, 401))) {
  29749. $this->io->writeError('<error>Invalid token provided.</error>');
  29750. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29751. return false;
  29752. }
  29753. throw $e;
  29754. }
  29755. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  29756. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  29757. $this->io->writeError('<info>Token stored successfully.</info>');
  29758. return true;
  29759. }
  29760. public function getRateLimit(array $headers)
  29761. {
  29762. $rateLimit = array(
  29763. 'limit' => '?',
  29764. 'reset' => '?',
  29765. );
  29766. foreach ($headers as $header) {
  29767. $header = trim($header);
  29768. if (false === strpos($header, 'X-RateLimit-')) {
  29769. continue;
  29770. }
  29771. list($type, $value) = explode(':', $header, 2);
  29772. switch ($type) {
  29773. case 'X-RateLimit-Limit':
  29774. $rateLimit['limit'] = (int) trim($value);
  29775. break;
  29776. case 'X-RateLimit-Reset':
  29777. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  29778. break;
  29779. }
  29780. }
  29781. return $rateLimit;
  29782. }
  29783. public function isRateLimited(array $headers)
  29784. {
  29785. foreach ($headers as $header) {
  29786. if (preg_match('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  29787. return true;
  29788. }
  29789. }
  29790. return false;
  29791. }
  29792. }
  29793. <?php
  29794. namespace Composer\Util;
  29795. use Composer\IO\IOInterface;
  29796. use Composer\Config;
  29797. use Composer\Factory;
  29798. use Composer\Downloader\TransportException;
  29799. class GitLab
  29800. {
  29801. protected $io;
  29802. protected $config;
  29803. protected $process;
  29804. protected $httpDownloader;
  29805. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29806. {
  29807. $this->io = $io;
  29808. $this->config = $config;
  29809. $this->process = $process ?: new ProcessExecutor($io);
  29810. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29811. }
  29812. public function authorizeOAuth($originUrl)
  29813. {
  29814. $bcOriginUrl = preg_replace('{:\d+}', '', $originUrl);
  29815. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  29816. return false;
  29817. }
  29818. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  29819. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  29820. return true;
  29821. }
  29822. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  29823. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  29824. return true;
  29825. }
  29826. $authTokens = $this->config->get('gitlab-token');
  29827. if (isset($authTokens[$originUrl])) {
  29828. $token = $authTokens[$originUrl];
  29829. }
  29830. if (isset($authTokens[$bcOriginUrl])) {
  29831. $token = $authTokens[$bcOriginUrl];
  29832. }
  29833. if (isset($token)) {
  29834. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  29835. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  29836. $this->io->setAuthentication($originUrl, $username, $password);
  29837. return true;
  29838. }
  29839. return false;
  29840. }
  29841. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  29842. {
  29843. if ($message) {
  29844. $this->io->writeError($message);
  29845. }
  29846. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  29847. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/profile/applications');
  29848. $attemptCounter = 0;
  29849. while ($attemptCounter++ < 5) {
  29850. try {
  29851. $response = $this->createToken($scheme, $originUrl);
  29852. } catch (TransportException $e) {
  29853. if (in_array($e->getCode(), array(403, 401))) {
  29854. if (401 === $e->getCode()) {
  29855. $response = json_decode($e->getResponse(), true);
  29856. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  29857. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  29858. } else {
  29859. $this->io->writeError('Bad credentials.');
  29860. }
  29861. } else {
  29862. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  29863. }
  29864. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  29865. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  29866. continue;
  29867. }
  29868. throw $e;
  29869. }
  29870. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  29871. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  29872. return true;
  29873. }
  29874. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  29875. }
  29876. private function createToken($scheme, $originUrl)
  29877. {
  29878. $username = $this->io->ask('Username: ');
  29879. $password = $this->io->askAndHideAnswer('Password: ');
  29880. $headers = array('Content-Type: application/x-www-form-urlencoded');
  29881. $apiUrl = $originUrl;
  29882. $data = http_build_query(array(
  29883. 'username' => $username,
  29884. 'password' => $password,
  29885. 'grant_type' => 'password',
  29886. ), null, '&');
  29887. $options = array(
  29888. 'retry-auth-failure' => false,
  29889. 'http' => array(
  29890. 'method' => 'POST',
  29891. 'header' => $headers,
  29892. 'content' => $data,
  29893. ),
  29894. );
  29895. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  29896. $this->io->writeError('Token successfully created');
  29897. return $token;
  29898. }
  29899. }
  29900. <?php
  29901. namespace Composer\Util;
  29902. use Composer\Config;
  29903. use Composer\IO\IOInterface;
  29904. class Hg
  29905. {
  29906. private static $version = false;
  29907. private $io;
  29908. private $config;
  29909. private $process;
  29910. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  29911. {
  29912. $this->io = $io;
  29913. $this->config = $config;
  29914. $this->process = $process;
  29915. }
  29916. public function runCommand($commandCallable, $url, $cwd)
  29917. {
  29918. $this->config->prohibitUrlByConfig($url, $this->io);
  29919. $command = call_user_func($commandCallable, $url);
  29920. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29921. return;
  29922. }
  29923. if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  29924. $auth = $this->io->getAuthentication($match[5]);
  29925. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  29926. $command = call_user_func($commandCallable, $authenticatedUrl);
  29927. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29928. return;
  29929. }
  29930. $error = $this->process->getErrorOutput();
  29931. } else {
  29932. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  29933. }
  29934. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  29935. }
  29936. private function throwException($message, $url)
  29937. {
  29938. if (null === self::getVersion($this->process)) {
  29939. throw new \RuntimeException(Url::sanitize('Failed to clone ' . $url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()));
  29940. }
  29941. throw new \RuntimeException(Url::sanitize($message));
  29942. }
  29943. public static function getVersion(ProcessExecutor $process)
  29944. {
  29945. if (false === self::$version) {
  29946. self::$version = null;
  29947. if (0 === $process->execute('hg --version', $output) && preg_match('/^.+? (\d+(?:\.\d+)+)\)?\r?\n/', $output, $matches)) {
  29948. self::$version = $matches[1];
  29949. }
  29950. }
  29951. return self::$version;
  29952. }
  29953. }
  29954. <?php
  29955. namespace Composer\Util\Http;
  29956. use Composer\Config;
  29957. use Composer\Downloader\MaxFileSizeExceededException;
  29958. use Composer\IO\IOInterface;
  29959. use Composer\Downloader\TransportException;
  29960. use Composer\Util\StreamContextFactory;
  29961. use Composer\Util\AuthHelper;
  29962. use Composer\Util\Url;
  29963. use Composer\Util\HttpDownloader;
  29964. use React\Promise\Promise;
  29965. class CurlDownloader
  29966. {
  29967. private $multiHandle;
  29968. private $shareHandle;
  29969. private $jobs = array();
  29970. private $io;
  29971. private $config;
  29972. private $authHelper;
  29973. private $selectTimeout = 5.0;
  29974. private $maxRedirects = 20;
  29975. private $proxyManager;
  29976. private $supportsSecureProxy;
  29977. protected $multiErrors = array(
  29978. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  29979. CURLM_BAD_EASY_HANDLE => array('CURLM_BAD_EASY_HANDLE', "An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle."),
  29980. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  29981. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'),
  29982. );
  29983. private static $options = array(
  29984. 'http' => array(
  29985. 'method' => CURLOPT_CUSTOMREQUEST,
  29986. 'content' => CURLOPT_POSTFIELDS,
  29987. 'header' => CURLOPT_HTTPHEADER,
  29988. 'timeout' => CURLOPT_TIMEOUT,
  29989. ),
  29990. 'ssl' => array(
  29991. 'cafile' => CURLOPT_CAINFO,
  29992. 'capath' => CURLOPT_CAPATH,
  29993. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  29994. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  29995. 'local_cert' => CURLOPT_SSLCERT,
  29996. 'local_pk' => CURLOPT_SSLKEY,
  29997. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  29998. ),
  29999. );
  30000. private static $timeInfo = array(
  30001. 'total_time' => true,
  30002. 'namelookup_time' => true,
  30003. 'connect_time' => true,
  30004. 'pretransfer_time' => true,
  30005. 'starttransfer_time' => true,
  30006. 'redirect_time' => true,
  30007. );
  30008. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  30009. {
  30010. $this->io = $io;
  30011. $this->config = $config;
  30012. $this->multiHandle = $mh = curl_multi_init();
  30013. if (function_exists('curl_multi_setopt')) {
  30014. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  30015. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  30016. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  30017. }
  30018. }
  30019. if (function_exists('curl_share_init')) {
  30020. $this->shareHandle = $sh = curl_share_init();
  30021. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  30022. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  30023. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  30024. }
  30025. $this->authHelper = new AuthHelper($io, $config);
  30026. $this->proxyManager = ProxyManager::getInstance();
  30027. $version = curl_version();
  30028. $features = $version['features'];
  30029. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  30030. }
  30031. public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
  30032. {
  30033. $attributes = array();
  30034. if (isset($options['retry-auth-failure'])) {
  30035. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  30036. unset($options['retry-auth-failure']);
  30037. }
  30038. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  30039. }
  30040. private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
  30041. {
  30042. $attributes = array_merge(array(
  30043. 'retryAuthFailure' => true,
  30044. 'redirects' => 0,
  30045. 'storeAuth' => false,
  30046. ), $attributes);
  30047. $originalOptions = $options;
  30048. if (!preg_match('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  30049. $this->config->prohibitUrlByConfig($url, $this->io);
  30050. }
  30051. $curlHandle = curl_init();
  30052. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  30053. if ($copyTo) {
  30054. $errorMessage = '';
  30055. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  30056. if ($errorMessage) {
  30057. $errorMessage .= "\n";
  30058. }
  30059. $errorMessage .= preg_replace('{^fopen\(.*?\): }', '', $msg);
  30060. });
  30061. $bodyHandle = fopen($copyTo.'~', 'w+b');
  30062. restore_error_handler();
  30063. if (!$bodyHandle) {
  30064. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  30065. }
  30066. } else {
  30067. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  30068. }
  30069. curl_setopt($curlHandle, CURLOPT_URL, $url);
  30070. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  30071. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  30072. curl_setopt($curlHandle, CURLOPT_TIMEOUT, 300);
  30073. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  30074. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  30075. curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip");
  30076. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  30077. if (function_exists('curl_share_init')) {
  30078. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  30079. }
  30080. if (!isset($options['http']['header'])) {
  30081. $options['http']['header'] = array();
  30082. }
  30083. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  30084. $options['http']['header'][] = 'Connection: keep-alive';
  30085. $version = curl_version();
  30086. $features = $version['features'];
  30087. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  30088. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  30089. }
  30090. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  30091. $options = StreamContextFactory::initOptions($url, $options, true);
  30092. foreach (self::$options as $type => $curlOptions) {
  30093. foreach ($curlOptions as $name => $curlOption) {
  30094. if (isset($options[$type][$name])) {
  30095. if ($type === 'ssl' && $name === 'verify_peer_name') {
  30096. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  30097. } else {
  30098. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  30099. }
  30100. }
  30101. }
  30102. }
  30103. $proxy = $this->proxyManager->getProxyForRequest($url);
  30104. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  30105. if ($proxy->isSecure()) {
  30106. if (!$this->supportsSecureProxy) {
  30107. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  30108. }
  30109. if (!empty($options['ssl']['cafile'])) {
  30110. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  30111. }
  30112. if (!empty($options['ssl']['capath'])) {
  30113. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  30114. }
  30115. }
  30116. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  30117. $this->jobs[(int) $curlHandle] = array(
  30118. 'url' => $url,
  30119. 'origin' => $origin,
  30120. 'attributes' => $attributes,
  30121. 'options' => $originalOptions,
  30122. 'progress' => $progress,
  30123. 'curlHandle' => $curlHandle,
  30124. 'filename' => $copyTo,
  30125. 'headerHandle' => $headerHandle,
  30126. 'bodyHandle' => $bodyHandle,
  30127. 'resolve' => $resolve,
  30128. 'reject' => $reject,
  30129. );
  30130. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  30131. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  30132. if ($attributes['redirects'] === 0) {
  30133. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  30134. }
  30135. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  30136. return (int) $curlHandle;
  30137. }
  30138. public function abortRequest($id)
  30139. {
  30140. if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) {
  30141. $job = $this->jobs[$id];
  30142. curl_multi_remove_handle($this->multiHandle, $job['handle']);
  30143. curl_close($job['handle']);
  30144. if (is_resource($job['headerHandle'])) {
  30145. fclose($job['headerHandle']);
  30146. }
  30147. if (is_resource($job['bodyHandle'])) {
  30148. fclose($job['bodyHandle']);
  30149. }
  30150. if ($job['filename']) {
  30151. @unlink($job['filename'].'~');
  30152. }
  30153. unset($this->jobs[$id]);
  30154. }
  30155. }
  30156. public function tick()
  30157. {
  30158. if (!$this->jobs) {
  30159. return;
  30160. }
  30161. $active = true;
  30162. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  30163. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  30164. usleep(150);
  30165. }
  30166. while ($progress = curl_multi_info_read($this->multiHandle)) {
  30167. $curlHandle = $progress['handle'];
  30168. $result = $progress['result'];
  30169. $i = (int) $curlHandle;
  30170. if (!isset($this->jobs[$i])) {
  30171. continue;
  30172. }
  30173. $progress = curl_getinfo($curlHandle);
  30174. $job = $this->jobs[$i];
  30175. unset($this->jobs[$i]);
  30176. $error = curl_error($curlHandle);
  30177. $errno = curl_errno($curlHandle);
  30178. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  30179. curl_close($curlHandle);
  30180. $headers = null;
  30181. $statusCode = null;
  30182. $response = null;
  30183. try {
  30184. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  30185. $errno = $errno ?: $result;
  30186. if (!$error && function_exists('curl_strerror')) {
  30187. $error = curl_strerror($errno);
  30188. }
  30189. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  30190. }
  30191. $statusCode = $progress['http_code'];
  30192. rewind($job['headerHandle']);
  30193. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  30194. fclose($job['headerHandle']);
  30195. if ($statusCode === 0) {
  30196. throw new \LogicException('Received unexpected http status code 0 without error for '.Url::sanitize($progress['url']).': headers '.var_export($headers, true).' curl info '.var_export($progress, true));
  30197. }
  30198. if ($job['filename']) {
  30199. $contents = $job['filename'].'~';
  30200. if ($statusCode >= 300) {
  30201. rewind($job['bodyHandle']);
  30202. $contents = stream_get_contents($job['bodyHandle']);
  30203. }
  30204. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  30205. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  30206. } else {
  30207. rewind($job['bodyHandle']);
  30208. $contents = stream_get_contents($job['bodyHandle']);
  30209. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  30210. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  30211. }
  30212. fclose($job['bodyHandle']);
  30213. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  30214. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  30215. }
  30216. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  30217. if ($result['retry']) {
  30218. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  30219. continue;
  30220. }
  30221. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  30222. $location = $this->handleRedirect($job, $response);
  30223. if ($location) {
  30224. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  30225. continue;
  30226. }
  30227. }
  30228. if ($statusCode >= 400 && $statusCode <= 599) {
  30229. throw $this->failResponse($job, $response, $response->getStatusMessage());
  30230. }
  30231. if ($job['attributes']['storeAuth']) {
  30232. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  30233. }
  30234. if ($job['filename']) {
  30235. rename($job['filename'].'~', $job['filename']);
  30236. call_user_func($job['resolve'], $response);
  30237. } else {
  30238. call_user_func($job['resolve'], $response);
  30239. }
  30240. } catch (\Exception $e) {
  30241. if ($e instanceof TransportException && $headers) {
  30242. $e->setHeaders($headers);
  30243. $e->setStatusCode($statusCode);
  30244. }
  30245. if ($e instanceof TransportException && $response) {
  30246. $e->setResponse($response->getBody());
  30247. }
  30248. if ($e instanceof TransportException && $progress) {
  30249. $e->setResponseInfo($progress);
  30250. }
  30251. $this->rejectJob($job, $e);
  30252. }
  30253. }
  30254. foreach ($this->jobs as $i => $curlHandle) {
  30255. if (!isset($this->jobs[$i])) {
  30256. continue;
  30257. }
  30258. $curlHandle = $this->jobs[$i]['curlHandle'];
  30259. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  30260. if ($this->jobs[$i]['progress'] !== $progress) {
  30261. $this->jobs[$i]['progress'] = $progress;
  30262. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  30263. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  30264. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Content-length header indicates ' . $progress['download_content_length'] . ' bytes. Allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  30265. }
  30266. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  30267. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  30268. }
  30269. }
  30270. }
  30271. }
  30272. }
  30273. private function handleRedirect(array $job, Response $response)
  30274. {
  30275. if ($locationHeader = $response->getHeader('location')) {
  30276. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  30277. $targetUrl = $locationHeader;
  30278. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  30279. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  30280. } elseif ('/' === $locationHeader[0]) {
  30281. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  30282. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  30283. } else {
  30284. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  30285. }
  30286. }
  30287. if (!empty($targetUrl)) {
  30288. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  30289. return $targetUrl;
  30290. }
  30291. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  30292. }
  30293. private function isAuthenticatedRetryNeeded(array $job, Response $response)
  30294. {
  30295. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  30296. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  30297. if ($result['retry']) {
  30298. return $result;
  30299. }
  30300. }
  30301. $locationHeader = $response->getHeader('location');
  30302. $needsAuthRetry = false;
  30303. if (
  30304. $job['origin'] === 'bitbucket.org'
  30305. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  30306. && substr($job['url'], -4) === '.zip'
  30307. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  30308. && preg_match('{^text/html\b}i', $response->getHeader('content-type'))
  30309. ) {
  30310. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  30311. }
  30312. if (
  30313. $response->getStatusCode() === 404
  30314. && $this->config && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  30315. && false !== strpos($job['url'], 'archive.zip')
  30316. ) {
  30317. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  30318. }
  30319. if ($needsAuthRetry) {
  30320. if ($job['attributes']['retryAuthFailure']) {
  30321. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  30322. if ($result['retry']) {
  30323. return $result;
  30324. }
  30325. }
  30326. throw $this->failResponse($job, $response, $needsAuthRetry);
  30327. }
  30328. return array('retry' => false, 'storeAuth' => false);
  30329. }
  30330. private function restartJob(array $job, $url, array $attributes = array())
  30331. {
  30332. if ($job['filename']) {
  30333. @unlink($job['filename'].'~');
  30334. }
  30335. $attributes = array_merge($job['attributes'], $attributes);
  30336. $origin = Url::getOrigin($this->config, $url);
  30337. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  30338. }
  30339. private function failResponse(array $job, Response $response, $errorMessage)
  30340. {
  30341. if ($job['filename']) {
  30342. @unlink($job['filename'].'~');
  30343. }
  30344. $details = '';
  30345. if ($response->getHeader('content-type') === 'application/json') {
  30346. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  30347. }
  30348. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  30349. }
  30350. private function rejectJob(array $job, \Exception $e)
  30351. {
  30352. if (is_resource($job['headerHandle'])) {
  30353. fclose($job['headerHandle']);
  30354. }
  30355. if (is_resource($job['bodyHandle'])) {
  30356. fclose($job['bodyHandle']);
  30357. }
  30358. if ($job['filename']) {
  30359. @unlink($job['filename'].'~');
  30360. }
  30361. call_user_func($job['reject'], $e);
  30362. }
  30363. private function checkCurlResult($code)
  30364. {
  30365. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  30366. throw new \RuntimeException(
  30367. isset($this->multiErrors[$code])
  30368. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  30369. : 'Unexpected cURL error: ' . $code
  30370. );
  30371. }
  30372. }
  30373. }
  30374. <?php
  30375. namespace Composer\Util\Http;
  30376. class CurlResponse extends Response
  30377. {
  30378. private $curlInfo;
  30379. public function __construct(array $request, $code, array $headers, $body, array $curlInfo)
  30380. {
  30381. parent::__construct($request, $code, $headers, $body);
  30382. $this->curlInfo = $curlInfo;
  30383. }
  30384. public function getCurlInfo()
  30385. {
  30386. return $this->curlInfo;
  30387. }
  30388. }
  30389. <?php
  30390. namespace Composer\Util\Http;
  30391. class ProxyHelper
  30392. {
  30393. public static function getProxyData()
  30394. {
  30395. $httpProxy = null;
  30396. $httpsProxy = null;
  30397. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  30398. if ($env = self::getProxyEnv(array('http_proxy', 'HTTP_PROXY'), $name)) {
  30399. $httpProxy = self::checkProxy($env, $name);
  30400. }
  30401. }
  30402. if ($env = self::getProxyEnv(array('CGI_HTTP_PROXY'), $name)) {
  30403. $httpProxy = self::checkProxy($env, $name);
  30404. }
  30405. if ($env = self::getProxyEnv(array('https_proxy', 'HTTPS_PROXY'), $name)) {
  30406. $httpsProxy = self::checkProxy($env, $name);
  30407. } else {
  30408. $httpsProxy = $httpProxy;
  30409. }
  30410. $noProxy = self::getProxyEnv(array('no_proxy', 'NO_PROXY'), $name);
  30411. return array($httpProxy, $httpsProxy, $noProxy);
  30412. }
  30413. public static function getContextOptions($proxyUrl)
  30414. {
  30415. $proxy = parse_url($proxyUrl);
  30416. $proxyUrl = self::formatParsedUrl($proxy, false);
  30417. $proxyUrl = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyUrl);
  30418. $options['http']['proxy'] = $proxyUrl;
  30419. if (isset($proxy['user'])) {
  30420. $auth = rawurldecode($proxy['user']);
  30421. if (isset($proxy['pass'])) {
  30422. $auth .= ':' . rawurldecode($proxy['pass']);
  30423. }
  30424. $auth = base64_encode($auth);
  30425. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  30426. }
  30427. return $options;
  30428. }
  30429. public static function setRequestFullUri($requestUrl, array &$options)
  30430. {
  30431. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  30432. $options['http']['request_fulluri'] = true;
  30433. } else {
  30434. unset($options['http']['request_fulluri']);
  30435. }
  30436. }
  30437. private static function getProxyEnv(array $names, &$name)
  30438. {
  30439. foreach ($names as $name) {
  30440. if (!empty($_SERVER[$name])) {
  30441. return $_SERVER[$name];
  30442. }
  30443. }
  30444. }
  30445. private static function checkProxy($proxyUrl, $envName)
  30446. {
  30447. $error = sprintf('malformed %s url', $envName);
  30448. $proxy = parse_url($proxyUrl);
  30449. if (!isset($proxy['host'])) {
  30450. throw new \RuntimeException($error);
  30451. }
  30452. $proxyUrl = self::formatParsedUrl($proxy, true);
  30453. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  30454. throw new \RuntimeException($error);
  30455. }
  30456. return $proxyUrl;
  30457. }
  30458. private static function formatParsedUrl(array $proxy, $includeAuth)
  30459. {
  30460. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  30461. if ($includeAuth && isset($proxy['user'])) {
  30462. $proxyUrl .= $proxy['user'];
  30463. if (isset($proxy['pass'])) {
  30464. $proxyUrl .= ':' . $proxy['pass'];
  30465. }
  30466. $proxyUrl .= '@';
  30467. }
  30468. $proxyUrl .= $proxy['host'];
  30469. if (isset($proxy['port'])) {
  30470. $proxyUrl .= ':' . $proxy['port'];
  30471. } elseif (strpos($proxyUrl, 'http://') === 0) {
  30472. $proxyUrl .= ':80';
  30473. } elseif (strpos($proxyUrl, 'https://') === 0) {
  30474. $proxyUrl .= ':443';
  30475. }
  30476. return $proxyUrl;
  30477. }
  30478. }
  30479. <?php
  30480. namespace Composer\Util\Http;
  30481. use Composer\Downloader\TransportException;
  30482. use Composer\Util\NoProxyPattern;
  30483. use Composer\Util\Url;
  30484. class ProxyManager
  30485. {
  30486. private $error;
  30487. private $fullProxy;
  30488. private $safeProxy;
  30489. private $streams;
  30490. private $hasProxy;
  30491. private $info;
  30492. private $lastProxy;
  30493. private $noProxyHandler;
  30494. private static $instance;
  30495. private function __construct()
  30496. {
  30497. $this->fullProxy = $this->safeProxy = array(
  30498. 'http' => null,
  30499. 'https' => null,
  30500. );
  30501. $this->streams['http'] = $this->streams['https'] = array(
  30502. 'options' => null,
  30503. );
  30504. $this->hasProxy = false;
  30505. $this->initProxyData();
  30506. }
  30507. public static function getInstance()
  30508. {
  30509. if (!self::$instance) {
  30510. self::$instance = new self();
  30511. }
  30512. return self::$instance;
  30513. }
  30514. public static function reset()
  30515. {
  30516. self::$instance = null;
  30517. }
  30518. public function getProxyForRequest($requestUrl)
  30519. {
  30520. if ($this->error) {
  30521. throw new TransportException('Unable to use a proxy: '.$this->error);
  30522. }
  30523. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  30524. $proxyUrl = '';
  30525. $options = array();
  30526. $formattedProxyUrl = '';
  30527. if ($this->hasProxy && in_array($scheme, array('http', 'https'), true) && $this->fullProxy[$scheme]) {
  30528. if ($this->noProxy($requestUrl)) {
  30529. $formattedProxyUrl = 'excluded by no_proxy';
  30530. } else {
  30531. $proxyUrl = $this->fullProxy[$scheme];
  30532. $options = $this->streams[$scheme]['options'];
  30533. ProxyHelper::setRequestFullUri($requestUrl, $options);
  30534. $formattedProxyUrl = $this->safeProxy[$scheme];
  30535. }
  30536. }
  30537. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  30538. }
  30539. public function isProxying()
  30540. {
  30541. return $this->hasProxy;
  30542. }
  30543. public function getFormattedProxy()
  30544. {
  30545. return $this->hasProxy ? $this->info : $this->error;
  30546. }
  30547. private function initProxyData()
  30548. {
  30549. try {
  30550. list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
  30551. } catch (\RuntimeException $e) {
  30552. $this->error = $e->getMessage();
  30553. return;
  30554. }
  30555. $info = array();
  30556. if ($httpProxy) {
  30557. $info[] = $this->setData($httpProxy, 'http');
  30558. }
  30559. if ($httpsProxy) {
  30560. $info[] = $this->setData($httpsProxy, 'https');
  30561. }
  30562. if ($this->hasProxy) {
  30563. $this->info = implode(', ', $info);
  30564. if ($noProxy) {
  30565. $this->noProxyHandler = array(new NoProxyPattern($noProxy), 'test');
  30566. }
  30567. }
  30568. }
  30569. private function setData($url, $scheme)
  30570. {
  30571. $safeProxy = Url::sanitize($url);
  30572. $this->fullProxy[$scheme] = $url;
  30573. $this->safeProxy[$scheme] = $safeProxy;
  30574. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  30575. $this->hasProxy = true;
  30576. return sprintf('%s=%s', $scheme, $safeProxy);
  30577. }
  30578. private function noProxy($requestUrl)
  30579. {
  30580. if ($this->noProxyHandler) {
  30581. if (call_user_func($this->noProxyHandler, $requestUrl)) {
  30582. $this->lastProxy = 'excluded by no_proxy';
  30583. return true;
  30584. }
  30585. }
  30586. return false;
  30587. }
  30588. }
  30589. <?php
  30590. namespace Composer\Util\Http;
  30591. use Composer\Util\Url;
  30592. class RequestProxy
  30593. {
  30594. private $contextOptions;
  30595. private $isSecure;
  30596. private $formattedUrl;
  30597. private $url;
  30598. public function __construct($url, array $contextOptions, $formattedUrl)
  30599. {
  30600. $this->url = $url;
  30601. $this->contextOptions = $contextOptions;
  30602. $this->formattedUrl = $formattedUrl;
  30603. $this->isSecure = 0 === strpos($url, 'https://');
  30604. }
  30605. public function getContextOptions()
  30606. {
  30607. return $this->contextOptions;
  30608. }
  30609. public function getFormattedUrl($format = '')
  30610. {
  30611. $result = '';
  30612. if ($this->formattedUrl) {
  30613. $format = $format ?: '%s';
  30614. $result = sprintf($format, $this->formattedUrl);
  30615. }
  30616. return $result;
  30617. }
  30618. public function getUrl()
  30619. {
  30620. return $this->url;
  30621. }
  30622. public function isSecure()
  30623. {
  30624. return $this->isSecure;
  30625. }
  30626. }
  30627. <?php
  30628. namespace Composer\Util\Http;
  30629. use Composer\Json\JsonFile;
  30630. class Response
  30631. {
  30632. private $request;
  30633. private $code;
  30634. private $headers;
  30635. private $body;
  30636. public function __construct(array $request, $code, array $headers, $body)
  30637. {
  30638. if (!isset($request['url'])) {
  30639. throw new \LogicException('url key missing from request array');
  30640. }
  30641. $this->request = $request;
  30642. $this->code = (int) $code;
  30643. $this->headers = $headers;
  30644. $this->body = $body;
  30645. }
  30646. public function getStatusCode()
  30647. {
  30648. return $this->code;
  30649. }
  30650. public function getStatusMessage()
  30651. {
  30652. $value = null;
  30653. foreach ($this->headers as $header) {
  30654. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  30655. $value = $header;
  30656. }
  30657. }
  30658. return $value;
  30659. }
  30660. public function getHeaders()
  30661. {
  30662. return $this->headers;
  30663. }
  30664. public function getHeader($name)
  30665. {
  30666. return self::findHeaderValue($this->headers, $name);
  30667. }
  30668. public function getBody()
  30669. {
  30670. return $this->body;
  30671. }
  30672. public function decodeJson()
  30673. {
  30674. return JsonFile::parseJson($this->body, $this->request['url']);
  30675. }
  30676. public function collect()
  30677. {
  30678. $this->request = $this->code = $this->headers = $this->body = null;
  30679. }
  30680. public static function findHeaderValue(array $headers, $name)
  30681. {
  30682. $value = null;
  30683. foreach ($headers as $header) {
  30684. if (preg_match('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  30685. $value = $match[1];
  30686. }
  30687. }
  30688. return $value;
  30689. }
  30690. }
  30691. <?php
  30692. namespace Composer\Util;
  30693. use Composer\Config;
  30694. use Composer\IO\IOInterface;
  30695. use Composer\Downloader\TransportException;
  30696. use Composer\Util\Http\Response;
  30697. use Composer\Composer;
  30698. use Composer\Package\Version\VersionParser;
  30699. use Composer\Semver\Constraint\Constraint;
  30700. use Composer\Exception\IrrecoverableDownloadException;
  30701. use React\Promise\Promise;
  30702. class HttpDownloader
  30703. {
  30704. const STATUS_QUEUED = 1;
  30705. const STATUS_STARTED = 2;
  30706. const STATUS_COMPLETED = 3;
  30707. const STATUS_FAILED = 4;
  30708. const STATUS_ABORTED = 5;
  30709. private $io;
  30710. private $config;
  30711. private $jobs = array();
  30712. private $options = array();
  30713. private $runningJobs = 0;
  30714. private $maxJobs = 12;
  30715. private $curl;
  30716. private $rfs;
  30717. private $idGen = 0;
  30718. private $disabled;
  30719. private $allowAsync = false;
  30720. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  30721. {
  30722. $this->io = $io;
  30723. $this->disabled = (bool) getenv('COMPOSER_DISABLE_NETWORK');
  30724. if ($disableTls === false) {
  30725. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  30726. }
  30727. $this->options = array_replace_recursive($this->options, $options);
  30728. $this->config = $config;
  30729. if (self::isCurlEnabled()) {
  30730. $this->curl = new Http\CurlDownloader($io, $config, $options, $disableTls);
  30731. }
  30732. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  30733. if (is_numeric($maxJobs = getenv('COMPOSER_MAX_PARALLEL_HTTP'))) {
  30734. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  30735. }
  30736. }
  30737. public function get($url, $options = array())
  30738. {
  30739. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30740. $this->wait($job['id']);
  30741. $response = $this->getResponse($job['id']);
  30742. if (
  30743. $this->curl
  30744. && PHP_VERSION_ID < 70000
  30745. && $response->getBody() === null
  30746. && $response->getStatusCode() === 200
  30747. && $response->getHeader('content-length') !== '0'
  30748. ) {
  30749. $this->io->writeError('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
  30750. $this->curl = null;
  30751. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30752. $this->wait($job['id']);
  30753. $response = $this->getResponse($job['id']);
  30754. }
  30755. return $response;
  30756. }
  30757. public function add($url, $options = array())
  30758. {
  30759. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false));
  30760. return $promise;
  30761. }
  30762. public function copy($url, $to, $options = array())
  30763. {
  30764. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  30765. $this->wait($job['id']);
  30766. return $this->getResponse($job['id']);
  30767. }
  30768. public function addCopy($url, $to, $options = array())
  30769. {
  30770. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  30771. return $promise;
  30772. }
  30773. public function getOptions()
  30774. {
  30775. return $this->options;
  30776. }
  30777. public function setOptions(array $options)
  30778. {
  30779. $this->options = array_replace_recursive($this->options, $options);
  30780. }
  30781. private function addJob($request, $sync = false)
  30782. {
  30783. $request['options'] = array_replace_recursive($this->options, $request['options']);
  30784. $job = array(
  30785. 'id' => $this->idGen++,
  30786. 'status' => self::STATUS_QUEUED,
  30787. 'request' => $request,
  30788. 'sync' => $sync,
  30789. 'origin' => Url::getOrigin($this->config, $request['url']),
  30790. );
  30791. if (!$sync && !$this->allowAsync) {
  30792. throw new \LogicException('You must use the HttpDownloader instance which is part of a Composer\Loop instance to be able to run async http requests');
  30793. }
  30794. if (preg_match('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  30795. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  30796. }
  30797. $rfs = $this->rfs;
  30798. if ($this->canUseCurl($job)) {
  30799. $resolver = function ($resolve, $reject) use (&$job) {
  30800. $job['status'] = HttpDownloader::STATUS_QUEUED;
  30801. $job['resolve'] = $resolve;
  30802. $job['reject'] = $reject;
  30803. };
  30804. } else {
  30805. $resolver = function ($resolve, $reject) use (&$job, $rfs) {
  30806. $url = $job['request']['url'];
  30807. $options = $job['request']['options'];
  30808. $job['status'] = HttpDownloader::STATUS_STARTED;
  30809. if ($job['request']['copyTo']) {
  30810. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  30811. $headers = $rfs->getLastHeaders();
  30812. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  30813. $resolve($response);
  30814. } else {
  30815. $body = $rfs->getContents($job['origin'], $url, false , $options);
  30816. $headers = $rfs->getLastHeaders();
  30817. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  30818. $resolve($response);
  30819. }
  30820. };
  30821. }
  30822. $downloader = $this;
  30823. $curl = $this->curl;
  30824. $canceler = function () use (&$job, $curl) {
  30825. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  30826. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30827. }
  30828. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  30829. return;
  30830. }
  30831. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30832. if (isset($job['curl_id'])) {
  30833. $curl->abortRequest($job['curl_id']);
  30834. }
  30835. throw new IrrecoverableDownloadException('Download of ' . Url::sanitize($job['request']['url']) . ' canceled');
  30836. };
  30837. $promise = new Promise($resolver, $canceler);
  30838. $promise = $promise->then(function ($response) use (&$job, $downloader) {
  30839. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  30840. $job['response'] = $response;
  30841. $downloader->markJobDone();
  30842. return $response;
  30843. }, function ($e) use (&$job, $downloader) {
  30844. $job['status'] = HttpDownloader::STATUS_FAILED;
  30845. $job['exception'] = $e;
  30846. $downloader->markJobDone();
  30847. throw $e;
  30848. });
  30849. $this->jobs[$job['id']] = &$job;
  30850. if ($this->runningJobs < $this->maxJobs) {
  30851. $this->startJob($job['id']);
  30852. }
  30853. return array($job, $promise);
  30854. }
  30855. private function startJob($id)
  30856. {
  30857. $job = &$this->jobs[$id];
  30858. if ($job['status'] !== self::STATUS_QUEUED) {
  30859. return;
  30860. }
  30861. $job['status'] = self::STATUS_STARTED;
  30862. $this->runningJobs++;
  30863. $resolve = $job['resolve'];
  30864. $reject = $job['reject'];
  30865. $url = $job['request']['url'];
  30866. $options = $job['request']['options'];
  30867. $origin = $job['origin'];
  30868. if ($this->disabled) {
  30869. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  30870. $resolve(new Response(array('url' => $url), 304, array(), ''));
  30871. } else {
  30872. $e = new TransportException('Network disabled, request canceled: '.Url::sanitize($url), 499);
  30873. $e->setStatusCode(499);
  30874. $reject($e);
  30875. }
  30876. return;
  30877. }
  30878. try {
  30879. if ($job['request']['copyTo']) {
  30880. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  30881. } else {
  30882. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  30883. }
  30884. } catch (\Exception $exception) {
  30885. $reject($exception);
  30886. }
  30887. }
  30888. public function markJobDone()
  30889. {
  30890. $this->runningJobs--;
  30891. }
  30892. public function wait($index = null)
  30893. {
  30894. do {
  30895. $jobCount = $this->countActiveJobs($index);
  30896. } while ($jobCount);
  30897. }
  30898. public function enableAsync()
  30899. {
  30900. $this->allowAsync = true;
  30901. }
  30902. public function countActiveJobs($index = null)
  30903. {
  30904. if ($this->runningJobs < $this->maxJobs) {
  30905. foreach ($this->jobs as $job) {
  30906. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  30907. $this->startJob($job['id']);
  30908. }
  30909. }
  30910. }
  30911. if ($this->curl) {
  30912. $this->curl->tick();
  30913. }
  30914. if (null !== $index) {
  30915. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  30916. }
  30917. $active = 0;
  30918. foreach ($this->jobs as $job) {
  30919. if ($job['status'] < self::STATUS_COMPLETED) {
  30920. $active++;
  30921. } elseif (!$job['sync']) {
  30922. unset($this->jobs[$job['id']]);
  30923. }
  30924. }
  30925. return $active;
  30926. }
  30927. private function getResponse($index)
  30928. {
  30929. if (!isset($this->jobs[$index])) {
  30930. throw new \LogicException('Invalid request id');
  30931. }
  30932. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  30933. throw $this->jobs[$index]['exception'];
  30934. }
  30935. if (!isset($this->jobs[$index]['response'])) {
  30936. throw new \LogicException('Response not available yet, call wait() first');
  30937. }
  30938. $resp = $this->jobs[$index]['response'];
  30939. unset($this->jobs[$index]);
  30940. return $resp;
  30941. }
  30942. public static function outputWarnings(IOInterface $io, $url, $data)
  30943. {
  30944. foreach (array('warning', 'info') as $type) {
  30945. if (empty($data[$type])) {
  30946. continue;
  30947. }
  30948. if (!empty($data[$type . '-versions'])) {
  30949. $versionParser = new VersionParser();
  30950. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  30951. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  30952. if (!$constraint->matches($composer)) {
  30953. continue;
  30954. }
  30955. }
  30956. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$data[$type].'</'.$type.'>');
  30957. }
  30958. }
  30959. public static function getExceptionHints(\Exception $e)
  30960. {
  30961. if (!$e instanceof TransportException) {
  30962. return;
  30963. }
  30964. if (
  30965. false !== strpos($e->getMessage(), 'Resolving timed out')
  30966. || false !== strpos($e->getMessage(), 'Could not resolve host')
  30967. ) {
  30968. Silencer::suppress();
  30969. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
  30970. 'ssl' => array('verify_peer' => false),
  30971. 'http' => array('follow_location' => false, 'ignore_errors' => true),
  30972. )));
  30973. Silencer::restore();
  30974. if (false !== $testConnectivity) {
  30975. return array(
  30976. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  30977. );
  30978. }
  30979. return array(
  30980. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  30981. );
  30982. }
  30983. }
  30984. private function canUseCurl(array $job)
  30985. {
  30986. if (!$this->curl) {
  30987. return false;
  30988. }
  30989. if (!preg_match('{^https?://}i', $job['request']['url'])) {
  30990. return false;
  30991. }
  30992. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  30993. return false;
  30994. }
  30995. return true;
  30996. }
  30997. public static function isCurlEnabled()
  30998. {
  30999. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  31000. }
  31001. }
  31002. <?php
  31003. namespace Composer\Util;
  31004. use Composer\XdebugHandler\XdebugHandler;
  31005. class IniHelper
  31006. {
  31007. public static function getAll()
  31008. {
  31009. return XdebugHandler::getAllIniFiles();
  31010. }
  31011. public static function getMessage()
  31012. {
  31013. $paths = self::getAll();
  31014. if (empty($paths[0])) {
  31015. array_shift($paths);
  31016. }
  31017. $ini = array_shift($paths);
  31018. if (empty($ini)) {
  31019. return 'A php.ini file does not exist. You will have to create one.';
  31020. }
  31021. if (!empty($paths)) {
  31022. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  31023. }
  31024. return 'The php.ini used by your command-line PHP is: '.$ini;
  31025. }
  31026. }
  31027. <?php
  31028. namespace Composer\Util;
  31029. use React\Promise\Promise;
  31030. use Symfony\Component\Console\Helper\ProgressBar;
  31031. class Loop
  31032. {
  31033. private $httpDownloader;
  31034. private $processExecutor;
  31035. private $currentPromises = array();
  31036. private $waitIndex = 0;
  31037. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  31038. {
  31039. $this->httpDownloader = $httpDownloader;
  31040. $this->httpDownloader->enableAsync();
  31041. $this->processExecutor = $processExecutor;
  31042. if ($this->processExecutor) {
  31043. $this->processExecutor->enableAsync();
  31044. }
  31045. }
  31046. public function getHttpDownloader()
  31047. {
  31048. return $this->httpDownloader;
  31049. }
  31050. public function getProcessExecutor()
  31051. {
  31052. return $this->processExecutor;
  31053. }
  31054. public function wait(array $promises, ProgressBar $progress = null)
  31055. {
  31056. $uncaught = null;
  31057. \React\Promise\all($promises)->then(
  31058. function () {
  31059. },
  31060. function ($e) use (&$uncaught) {
  31061. $uncaught = $e;
  31062. }
  31063. );
  31064. $waitIndex = $this->waitIndex++;
  31065. $this->currentPromises[$waitIndex] = $promises;
  31066. if ($progress) {
  31067. $totalJobs = 0;
  31068. if ($this->httpDownloader) {
  31069. $totalJobs += $this->httpDownloader->countActiveJobs();
  31070. }
  31071. if ($this->processExecutor) {
  31072. $totalJobs += $this->processExecutor->countActiveJobs();
  31073. }
  31074. $progress->start($totalJobs);
  31075. }
  31076. $lastUpdate = 0;
  31077. while (true) {
  31078. $activeJobs = 0;
  31079. if ($this->httpDownloader) {
  31080. $activeJobs += $this->httpDownloader->countActiveJobs();
  31081. }
  31082. if ($this->processExecutor) {
  31083. $activeJobs += $this->processExecutor->countActiveJobs();
  31084. }
  31085. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  31086. $lastUpdate = microtime(true);
  31087. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  31088. }
  31089. if (!$activeJobs) {
  31090. break;
  31091. }
  31092. }
  31093. if ($progress) {
  31094. $progress->setProgress($progress->getMaxSteps());
  31095. }
  31096. unset($this->currentPromises[$waitIndex]);
  31097. if ($uncaught) {
  31098. throw $uncaught;
  31099. }
  31100. }
  31101. public function abortJobs()
  31102. {
  31103. foreach ($this->currentPromises as $promiseGroup) {
  31104. foreach ($promiseGroup as $promise) {
  31105. $promise->cancel();
  31106. }
  31107. }
  31108. }
  31109. }
  31110. <?php
  31111. namespace Composer\Util;
  31112. class MetadataMinifier
  31113. {
  31114. public static function expand(array $versions)
  31115. {
  31116. $expanded = array();
  31117. $expandedVersion = null;
  31118. foreach ($versions as $versionData) {
  31119. if (!$expandedVersion) {
  31120. $expandedVersion = $versionData;
  31121. $expanded[] = $expandedVersion;
  31122. continue;
  31123. }
  31124. foreach ($versionData as $key => $val) {
  31125. if ($val === '__unset') {
  31126. unset($expandedVersion[$key]);
  31127. } else {
  31128. $expandedVersion[$key] = $val;
  31129. }
  31130. }
  31131. $expanded[] = $expandedVersion;
  31132. }
  31133. return $expanded;
  31134. }
  31135. public static function minify(array $versions)
  31136. {
  31137. $minifiedVersions = array();
  31138. $lastKnownVersionData = null;
  31139. foreach ($versions as $version) {
  31140. if (!$lastKnownVersionData) {
  31141. $lastKnownVersionData = $version;
  31142. $minifiedVersions[] = $version;
  31143. continue;
  31144. }
  31145. $minifiedVersion = array();
  31146. foreach ($version as $key => $val) {
  31147. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  31148. $minifiedVersion[$key] = $val;
  31149. $lastKnownVersionData[$key] = $val;
  31150. }
  31151. }
  31152. foreach ($lastKnownVersionData as $key => $val) {
  31153. if (!isset($version[$key])) {
  31154. $minifiedVersion[$key] = "__unset";
  31155. unset($lastKnownVersionData[$key]);
  31156. }
  31157. }
  31158. $minifiedVersions[] = $minifiedVersion;
  31159. }
  31160. return $minifiedVersions;
  31161. }
  31162. }
  31163. <?php
  31164. namespace Composer\Util;
  31165. use stdClass;
  31166. class NoProxyPattern
  31167. {
  31168. protected $hostNames = array();
  31169. protected $rules = array();
  31170. protected $noproxy;
  31171. public function __construct($pattern)
  31172. {
  31173. $this->hostNames = preg_split('{[\s,]+}', $pattern, null, PREG_SPLIT_NO_EMPTY);
  31174. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  31175. }
  31176. public function test($url)
  31177. {
  31178. if ($this->noproxy) {
  31179. return true;
  31180. }
  31181. if (!$urlData = $this->getUrlData($url)) {
  31182. return false;
  31183. }
  31184. foreach ($this->hostNames as $index => $hostName) {
  31185. if ($this->match($index, $hostName, $urlData)) {
  31186. return true;
  31187. }
  31188. }
  31189. return false;
  31190. }
  31191. protected function getUrlData($url)
  31192. {
  31193. if (!$host = parse_url($url, PHP_URL_HOST)) {
  31194. return false;
  31195. }
  31196. $port = parse_url($url, PHP_URL_PORT);
  31197. if (empty($port)) {
  31198. switch (parse_url($url, PHP_URL_SCHEME)) {
  31199. case 'http':
  31200. $port = 80;
  31201. break;
  31202. case 'https':
  31203. $port = 443;
  31204. break;
  31205. }
  31206. }
  31207. $hostName = $host . ($port ? ':' . $port : '');
  31208. list($host, $port, $err) = $this->splitHostPort($hostName);
  31209. if ($err || !$this->ipCheckData($host, $ipdata)) {
  31210. return false;
  31211. }
  31212. return $this->makeData($host, $port, $ipdata);
  31213. }
  31214. protected function match($index, $hostName, $url)
  31215. {
  31216. if (!$rule = $this->getRule($index, $hostName)) {
  31217. return false;
  31218. }
  31219. if ($rule->ipdata) {
  31220. if (!$url->ipdata) {
  31221. return false;
  31222. }
  31223. if ($rule->ipdata->netmask) {
  31224. return $this->matchRange($rule->ipdata, $url->ipdata);
  31225. }
  31226. $match = $rule->ipdata->ip === $url->ipdata->ip;
  31227. } else {
  31228. $haystack = substr($url->name, -strlen($rule->name));
  31229. $match = stripos($haystack, $rule->name) === 0;
  31230. }
  31231. if ($match && $rule->port) {
  31232. $match = $rule->port === $url->port;
  31233. }
  31234. return $match;
  31235. }
  31236. protected function matchRange(stdClass $network, stdClass $target)
  31237. {
  31238. $net = unpack('C*', $network->ip);
  31239. $mask = unpack('C*', $network->netmask);
  31240. $ip = unpack('C*', $target->ip);
  31241. for ($i = 1; $i < 17; ++$i) {
  31242. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  31243. return false;
  31244. }
  31245. }
  31246. return true;
  31247. }
  31248. private function getRule($index, $hostName)
  31249. {
  31250. if (array_key_exists($index, $this->rules)) {
  31251. return $this->rules[$index];
  31252. }
  31253. $this->rules[$index] = null;
  31254. list($host, $port, $err) = $this->splitHostPort($hostName);
  31255. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  31256. return null;
  31257. }
  31258. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  31259. return $this->rules[$index];
  31260. }
  31261. private function ipCheckData($host, &$ipdata, $allowPrefix = false)
  31262. {
  31263. $ipdata = null;
  31264. $netmask = null;
  31265. $prefix = null;
  31266. $modified = false;
  31267. if (strpos($host, '/') !== false) {
  31268. list($host, $prefix) = explode('/', $host);
  31269. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  31270. return false;
  31271. }
  31272. $prefix = (int) $prefix;
  31273. $modified = true;
  31274. }
  31275. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  31276. return !$modified;
  31277. }
  31278. list($ip, $size) = $this->ipGetAddr($host);
  31279. if ($prefix !== null) {
  31280. if ($prefix > $size * 8) {
  31281. return false;
  31282. }
  31283. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  31284. }
  31285. $ipdata = $this->makeIpData($ip, $size, $netmask);
  31286. return true;
  31287. }
  31288. private function ipGetAddr($host)
  31289. {
  31290. $ip = inet_pton($host);
  31291. $size = strlen($ip);
  31292. $mapped = $this->ipMapTo6($ip, $size);
  31293. return array($mapped, $size);
  31294. }
  31295. private function ipGetMask($prefix, $size)
  31296. {
  31297. $mask = '';
  31298. if ($ones = floor($prefix / 8)) {
  31299. $mask = str_repeat(chr(255), $ones);
  31300. }
  31301. if ($remainder = $prefix % 8) {
  31302. $mask .= chr(0xff ^ (0xff >> $remainder));
  31303. }
  31304. $mask = str_pad($mask, $size, chr(0));
  31305. return $this->ipMapTo6($mask, $size);
  31306. }
  31307. private function ipGetNetwork($rangeIp, $size, $prefix)
  31308. {
  31309. $netmask = $this->ipGetMask($prefix, $size);
  31310. $mask = unpack('C*', $netmask);
  31311. $ip = unpack('C*', $rangeIp);
  31312. $net = '';
  31313. for ($i = 1; $i < 17; ++$i) {
  31314. $net .= chr($ip[$i] & $mask[$i]);
  31315. }
  31316. return array($net, $netmask);
  31317. }
  31318. private function ipMapTo6($binary, $size)
  31319. {
  31320. if ($size === 4) {
  31321. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  31322. $binary = $prefix . $binary;
  31323. }
  31324. return $binary;
  31325. }
  31326. private function makeData($host, $port, $ipdata)
  31327. {
  31328. return (object) array(
  31329. 'host' => $host,
  31330. 'name' => '.' . ltrim($host, '.'),
  31331. 'port' => $port,
  31332. 'ipdata' => $ipdata,
  31333. );
  31334. }
  31335. private function makeIpData($ip, $size, $netmask)
  31336. {
  31337. return (object) array(
  31338. 'ip' => $ip,
  31339. 'size' => $size,
  31340. 'netmask' => $netmask,
  31341. );
  31342. }
  31343. private function splitHostPort($hostName)
  31344. {
  31345. $error = array('', '', true);
  31346. $port = 0;
  31347. $ip6 = '';
  31348. if ($hostName[0] === '[') {
  31349. $index = strpos($hostName, ']');
  31350. if (false === $index || $index < 3) {
  31351. return $error;
  31352. }
  31353. $ip6 = substr($hostName, 1, $index - 1);
  31354. $hostName = substr($hostName, $index + 1);
  31355. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  31356. return $error;
  31357. }
  31358. }
  31359. if (substr_count($hostName, ':') === 1) {
  31360. $index = strpos($hostName, ':');
  31361. $port = substr($hostName, $index + 1);
  31362. $hostName = substr($hostName, 0, $index);
  31363. if (!$this->validateInt($port, 1, 65535)) {
  31364. return $error;
  31365. }
  31366. $port = (int) $port;
  31367. }
  31368. $host = $ip6 . $hostName;
  31369. return array($host, $port, false);
  31370. }
  31371. private function validateInt($int, $min, $max)
  31372. {
  31373. $options = array(
  31374. 'options' => array(
  31375. 'min_range' => $min,
  31376. 'max_range' => $max,
  31377. ),
  31378. );
  31379. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  31380. }
  31381. }
  31382. <?php
  31383. namespace Composer\Util;
  31384. use Composer\Package\Link;
  31385. use Composer\Package\PackageInterface;
  31386. class PackageSorter
  31387. {
  31388. public static function sortPackages(array $packages)
  31389. {
  31390. $usageList = array();
  31391. foreach ($packages as $package) {
  31392. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  31393. $target = $link->getTarget();
  31394. $usageList[$target][] = $package->getName();
  31395. }
  31396. }
  31397. $computing = array();
  31398. $computed = array();
  31399. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  31400. if (isset($computed[$name])) {
  31401. return $computed[$name];
  31402. }
  31403. if (isset($computing[$name])) {
  31404. return 0;
  31405. }
  31406. $computing[$name] = true;
  31407. $weight = 0;
  31408. if (isset($usageList[$name])) {
  31409. foreach ($usageList[$name] as $user) {
  31410. $weight -= 1 - $computeImportance($user);
  31411. }
  31412. }
  31413. unset($computing[$name]);
  31414. $computed[$name] = $weight;
  31415. return $weight;
  31416. };
  31417. $weightList = array();
  31418. foreach ($packages as $index => $package) {
  31419. $weight = $computeImportance($package->getName());
  31420. $weightList[$index] = $weight;
  31421. }
  31422. $stable_sort = function (&$array) {
  31423. static $transform, $restore;
  31424. $i = 0;
  31425. if (!$transform) {
  31426. $transform = function (&$v, $k) use (&$i) {
  31427. $v = array($v, ++$i, $k, $v);
  31428. };
  31429. $restore = function (&$v) {
  31430. $v = $v[3];
  31431. };
  31432. }
  31433. array_walk($array, $transform);
  31434. asort($array);
  31435. array_walk($array, $restore);
  31436. };
  31437. $stable_sort($weightList);
  31438. $sortedPackages = array();
  31439. foreach (array_keys($weightList) as $index) {
  31440. $sortedPackages[] = $packages[$index];
  31441. }
  31442. return $sortedPackages;
  31443. }
  31444. }
  31445. <?php
  31446. namespace Composer\Util;
  31447. use Composer\IO\IOInterface;
  31448. use Symfony\Component\Process\Process;
  31449. class Perforce
  31450. {
  31451. protected $path;
  31452. protected $p4Depot;
  31453. protected $p4Client;
  31454. protected $p4User;
  31455. protected $p4Password;
  31456. protected $p4Port;
  31457. protected $p4Stream;
  31458. protected $p4ClientSpec;
  31459. protected $p4DepotType;
  31460. protected $p4Branch;
  31461. protected $process;
  31462. protected $uniquePerforceClientName;
  31463. protected $windowsFlag;
  31464. protected $commandResult;
  31465. protected $io;
  31466. protected $filesystem;
  31467. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  31468. {
  31469. $this->windowsFlag = $isWindows;
  31470. $this->p4Port = $port;
  31471. $this->initializePath($path);
  31472. $this->process = $process;
  31473. $this->initialize($repoConfig);
  31474. $this->io = $io;
  31475. }
  31476. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  31477. {
  31478. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  31479. }
  31480. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  31481. {
  31482. $output = null;
  31483. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  31484. }
  31485. public function initialize($repoConfig)
  31486. {
  31487. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  31488. if (!$repoConfig) {
  31489. return;
  31490. }
  31491. if (isset($repoConfig['unique_perforce_client_name'])) {
  31492. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  31493. }
  31494. if (isset($repoConfig['depot'])) {
  31495. $this->p4Depot = $repoConfig['depot'];
  31496. }
  31497. if (isset($repoConfig['branch'])) {
  31498. $this->p4Branch = $repoConfig['branch'];
  31499. }
  31500. if (isset($repoConfig['p4user'])) {
  31501. $this->p4User = $repoConfig['p4user'];
  31502. } else {
  31503. $this->p4User = $this->getP4variable('P4USER');
  31504. }
  31505. if (isset($repoConfig['p4password'])) {
  31506. $this->p4Password = $repoConfig['p4password'];
  31507. }
  31508. }
  31509. public function initializeDepotAndBranch($depot, $branch)
  31510. {
  31511. if (isset($depot)) {
  31512. $this->p4Depot = $depot;
  31513. }
  31514. if (isset($branch)) {
  31515. $this->p4Branch = $branch;
  31516. }
  31517. }
  31518. public function generateUniquePerforceClientName()
  31519. {
  31520. return gethostname() . "_" . time();
  31521. }
  31522. public function cleanupClientSpec()
  31523. {
  31524. $client = $this->getClient();
  31525. $task = 'client -d ' . ProcessExecutor::escape($client);
  31526. $useP4Client = false;
  31527. $command = $this->generateP4Command($task, $useP4Client);
  31528. $this->executeCommand($command);
  31529. $clientSpec = $this->getP4ClientSpec();
  31530. $fileSystem = $this->getFilesystem();
  31531. $fileSystem->remove($clientSpec);
  31532. }
  31533. protected function executeCommand($command)
  31534. {
  31535. $this->commandResult = '';
  31536. return $this->process->execute($command, $this->commandResult);
  31537. }
  31538. public function getClient()
  31539. {
  31540. if (!isset($this->p4Client)) {
  31541. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  31542. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  31543. }
  31544. return $this->p4Client;
  31545. }
  31546. protected function getPath()
  31547. {
  31548. return $this->path;
  31549. }
  31550. public function initializePath($path)
  31551. {
  31552. $this->path = $path;
  31553. $fs = $this->getFilesystem();
  31554. $fs->ensureDirectoryExists($path);
  31555. }
  31556. protected function getPort()
  31557. {
  31558. return $this->p4Port;
  31559. }
  31560. public function setStream($stream)
  31561. {
  31562. $this->p4Stream = $stream;
  31563. $index = strrpos($stream, '/');
  31564. if ($index > 2) {
  31565. $this->p4DepotType = 'stream';
  31566. }
  31567. }
  31568. public function isStream()
  31569. {
  31570. return (strcmp($this->p4DepotType, 'stream') === 0);
  31571. }
  31572. public function getStream()
  31573. {
  31574. if (!isset($this->p4Stream)) {
  31575. if ($this->isStream()) {
  31576. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  31577. } else {
  31578. $this->p4Stream = '//' . $this->p4Depot;
  31579. }
  31580. }
  31581. return $this->p4Stream;
  31582. }
  31583. public function getStreamWithoutLabel($stream)
  31584. {
  31585. $index = strpos($stream, '@');
  31586. if ($index === false) {
  31587. return $stream;
  31588. }
  31589. return substr($stream, 0, $index);
  31590. }
  31591. public function getP4ClientSpec()
  31592. {
  31593. return $this->path . '/' . $this->getClient() . '.p4.spec';
  31594. }
  31595. public function getUser()
  31596. {
  31597. return $this->p4User;
  31598. }
  31599. public function setUser($user)
  31600. {
  31601. $this->p4User = $user;
  31602. }
  31603. public function queryP4User()
  31604. {
  31605. $this->getUser();
  31606. if (strlen($this->p4User) > 0) {
  31607. return;
  31608. }
  31609. $this->p4User = $this->getP4variable('P4USER');
  31610. if (strlen($this->p4User) > 0) {
  31611. return;
  31612. }
  31613. $this->p4User = $this->io->ask('Enter P4 User:');
  31614. if ($this->windowsFlag) {
  31615. $command = 'p4 set P4USER=' . $this->p4User;
  31616. } else {
  31617. $command = 'export P4USER=' . $this->p4User;
  31618. }
  31619. $this->executeCommand($command);
  31620. }
  31621. protected function getP4variable($name)
  31622. {
  31623. if ($this->windowsFlag) {
  31624. $command = 'p4 set';
  31625. $this->executeCommand($command);
  31626. $result = trim($this->commandResult);
  31627. $resArray = explode(PHP_EOL, $result);
  31628. foreach ($resArray as $line) {
  31629. $fields = explode('=', $line);
  31630. if (strcmp($name, $fields[0]) == 0) {
  31631. $index = strpos($fields[1], ' ');
  31632. if ($index === false) {
  31633. $value = $fields[1];
  31634. } else {
  31635. $value = substr($fields[1], 0, $index);
  31636. }
  31637. $value = trim($value);
  31638. return $value;
  31639. }
  31640. }
  31641. return null;
  31642. }
  31643. $command = 'echo $' . $name;
  31644. $this->executeCommand($command);
  31645. $result = trim($this->commandResult);
  31646. return $result;
  31647. }
  31648. public function queryP4Password()
  31649. {
  31650. if (isset($this->p4Password)) {
  31651. return $this->p4Password;
  31652. }
  31653. $password = $this->getP4variable('P4PASSWD');
  31654. if (strlen($password) <= 0) {
  31655. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  31656. }
  31657. $this->p4Password = $password;
  31658. return $password;
  31659. }
  31660. public function generateP4Command($command, $useClient = true)
  31661. {
  31662. $p4Command = 'p4 ';
  31663. $p4Command .= '-u ' . $this->getUser() . ' ';
  31664. if ($useClient) {
  31665. $p4Command .= '-c ' . $this->getClient() . ' ';
  31666. }
  31667. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  31668. return $p4Command;
  31669. }
  31670. public function isLoggedIn()
  31671. {
  31672. $command = $this->generateP4Command('login -s', false);
  31673. $exitCode = $this->executeCommand($command);
  31674. if ($exitCode) {
  31675. $errorOutput = $this->process->getErrorOutput();
  31676. $index = strpos($errorOutput, $this->getUser());
  31677. if ($index === false) {
  31678. $index = strpos($errorOutput, 'p4');
  31679. if ($index === false) {
  31680. return false;
  31681. }
  31682. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  31683. }
  31684. throw new \Exception('Invalid user name: ' . $this->getUser());
  31685. }
  31686. return true;
  31687. }
  31688. public function connectClient()
  31689. {
  31690. $p4CreateClientCommand = $this->generateP4Command(
  31691. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  31692. );
  31693. $this->executeCommand($p4CreateClientCommand);
  31694. }
  31695. public function syncCodeBase($sourceReference)
  31696. {
  31697. $prevDir = getcwd();
  31698. chdir($this->path);
  31699. $p4SyncCommand = $this->generateP4Command('sync -f ');
  31700. if (null !== $sourceReference) {
  31701. $p4SyncCommand .= '@' . $sourceReference;
  31702. }
  31703. $this->executeCommand($p4SyncCommand);
  31704. chdir($prevDir);
  31705. }
  31706. public function writeClientSpecToFile($spec)
  31707. {
  31708. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  31709. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  31710. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  31711. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  31712. fwrite($spec, 'Description:' . PHP_EOL);
  31713. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  31714. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  31715. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  31716. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  31717. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  31718. if ($this->isStream()) {
  31719. fwrite($spec, 'Stream:' . PHP_EOL);
  31720. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  31721. } else {
  31722. fwrite(
  31723. $spec,
  31724. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  31725. );
  31726. }
  31727. }
  31728. public function writeP4ClientSpec()
  31729. {
  31730. $clientSpec = $this->getP4ClientSpec();
  31731. $spec = fopen($clientSpec, 'w');
  31732. try {
  31733. $this->writeClientSpecToFile($spec);
  31734. } catch (\Exception $e) {
  31735. fclose($spec);
  31736. throw $e;
  31737. }
  31738. fclose($spec);
  31739. }
  31740. protected function read($pipe, $name)
  31741. {
  31742. if (feof($pipe)) {
  31743. return;
  31744. }
  31745. $line = fgets($pipe);
  31746. while ($line !== false) {
  31747. $line = fgets($pipe);
  31748. }
  31749. }
  31750. public function windowsLogin($password)
  31751. {
  31752. $command = $this->generateP4Command(' login -a');
  31753. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31754. $process = Process::fromShellCommandline($command, null, null, $password);
  31755. } else {
  31756. $process = new Process($command, null, null, $password);
  31757. }
  31758. return $process->run();
  31759. }
  31760. public function p4Login()
  31761. {
  31762. $this->queryP4User();
  31763. if (!$this->isLoggedIn()) {
  31764. $password = $this->queryP4Password();
  31765. if ($this->windowsFlag) {
  31766. $this->windowsLogin($password);
  31767. } else {
  31768. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  31769. $exitCode = $this->executeCommand($command);
  31770. if ($exitCode) {
  31771. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  31772. }
  31773. }
  31774. }
  31775. }
  31776. public function getComposerInformation($identifier)
  31777. {
  31778. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  31779. if (!$composerFileContent) {
  31780. return;
  31781. }
  31782. return json_decode($composerFileContent, true);
  31783. }
  31784. public function getFileContent($file, $identifier)
  31785. {
  31786. $path = $this->getFilePath($file, $identifier);
  31787. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  31788. $this->executeCommand($command);
  31789. $result = $this->commandResult;
  31790. if (!trim($result)) {
  31791. return null;
  31792. }
  31793. return $result;
  31794. }
  31795. public function getFilePath($file, $identifier)
  31796. {
  31797. $index = strpos($identifier, '@');
  31798. if ($index === false) {
  31799. return $identifier. '/' . $file;
  31800. }
  31801. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  31802. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  31803. $this->executeCommand($command);
  31804. $result = $this->commandResult;
  31805. $index2 = strpos($result, 'no such file(s).');
  31806. if ($index2 === false) {
  31807. $index3 = strpos($result, 'change');
  31808. if ($index3 !== false) {
  31809. $phrase = trim(substr($result, $index3));
  31810. $fields = explode(' ', $phrase);
  31811. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  31812. }
  31813. }
  31814. return null;
  31815. }
  31816. public function getBranches()
  31817. {
  31818. $possibleBranches = array();
  31819. if (!$this->isStream()) {
  31820. $possibleBranches[$this->p4Branch] = $this->getStream();
  31821. } else {
  31822. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  31823. $this->executeCommand($command);
  31824. $result = $this->commandResult;
  31825. $resArray = explode(PHP_EOL, $result);
  31826. foreach ($resArray as $line) {
  31827. $resBits = explode(' ', $line);
  31828. if (count($resBits) > 4) {
  31829. $branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  31830. $possibleBranches[$branch] = $resBits[1];
  31831. }
  31832. }
  31833. }
  31834. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  31835. $this->executeCommand($command);
  31836. $result = $this->commandResult;
  31837. $resArray = explode(PHP_EOL, $result);
  31838. $lastCommit = $resArray[0];
  31839. $lastCommitArr = explode(' ', $lastCommit);
  31840. $lastCommitNum = $lastCommitArr[1];
  31841. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  31842. }
  31843. public function getTags()
  31844. {
  31845. $command = $this->generateP4Command('labels');
  31846. $this->executeCommand($command);
  31847. $result = $this->commandResult;
  31848. $resArray = explode(PHP_EOL, $result);
  31849. $tags = array();
  31850. foreach ($resArray as $line) {
  31851. if (strpos($line, 'Label') !== false) {
  31852. $fields = explode(' ', $line);
  31853. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  31854. }
  31855. }
  31856. return $tags;
  31857. }
  31858. public function checkStream()
  31859. {
  31860. $command = $this->generateP4Command('depots', false);
  31861. $this->executeCommand($command);
  31862. $result = $this->commandResult;
  31863. $resArray = explode(PHP_EOL, $result);
  31864. foreach ($resArray as $line) {
  31865. if (strpos($line, 'Depot') !== false) {
  31866. $fields = explode(' ', $line);
  31867. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  31868. $this->p4DepotType = $fields[3];
  31869. return $this->isStream();
  31870. }
  31871. }
  31872. }
  31873. return false;
  31874. }
  31875. protected function getChangeList($reference)
  31876. {
  31877. $index = strpos($reference, '@');
  31878. if ($index === false) {
  31879. return null;
  31880. }
  31881. $label = substr($reference, $index);
  31882. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  31883. $this->executeCommand($command);
  31884. $changes = $this->commandResult;
  31885. if (strpos($changes, 'Change') !== 0) {
  31886. return null;
  31887. }
  31888. $fields = explode(' ', $changes);
  31889. return $fields[1];
  31890. }
  31891. public function getCommitLogs($fromReference, $toReference)
  31892. {
  31893. $fromChangeList = $this->getChangeList($fromReference);
  31894. if ($fromChangeList === null) {
  31895. return null;
  31896. }
  31897. $toChangeList = $this->getChangeList($toReference);
  31898. if ($toChangeList === null) {
  31899. return null;
  31900. }
  31901. $index = strpos($fromReference, '@');
  31902. $main = substr($fromReference, 0, $index) . '/...';
  31903. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  31904. $this->executeCommand($command);
  31905. return $this->commandResult;
  31906. }
  31907. public function getFilesystem()
  31908. {
  31909. if (empty($this->filesystem)) {
  31910. $this->filesystem = new Filesystem($this->process);
  31911. }
  31912. return $this->filesystem;
  31913. }
  31914. public function setFilesystem(Filesystem $fs)
  31915. {
  31916. $this->filesystem = $fs;
  31917. }
  31918. }
  31919. <?php
  31920. namespace Composer\Util;
  31921. class Platform
  31922. {
  31923. private static $isVirtualBoxGuest = null;
  31924. public static function expandPath($path)
  31925. {
  31926. if (preg_match('#^~[\\/]#', $path)) {
  31927. return self::getUserDirectory() . substr($path, 1);
  31928. }
  31929. return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  31930. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  31931. return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
  31932. }
  31933. return getenv($matches['var']) . $matches['path'];
  31934. }, $path);
  31935. }
  31936. public static function getUserDirectory()
  31937. {
  31938. if (false !== ($home = getenv('HOME'))) {
  31939. return $home;
  31940. }
  31941. if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
  31942. return $home;
  31943. }
  31944. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  31945. $info = posix_getpwuid(posix_getuid());
  31946. return $info['dir'];
  31947. }
  31948. throw new \RuntimeException('Could not determine user directory');
  31949. }
  31950. public static function isWindows()
  31951. {
  31952. return \defined('PHP_WINDOWS_VERSION_BUILD');
  31953. }
  31954. public static function strlen($str)
  31955. {
  31956. static $useMbString = null;
  31957. if (null === $useMbString) {
  31958. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  31959. }
  31960. if ($useMbString) {
  31961. return mb_strlen($str, '8bit');
  31962. }
  31963. return \strlen($str);
  31964. }
  31965. public static function isTty($fd = null)
  31966. {
  31967. if ($fd === null) {
  31968. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  31969. }
  31970. if (in_array(strtoupper(getenv('MSYSTEM') ?: ''), array('MINGW32', 'MINGW64'), true)) {
  31971. return true;
  31972. }
  31973. if (function_exists('stream_isatty')) {
  31974. return stream_isatty($fd);
  31975. }
  31976. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  31977. return true;
  31978. }
  31979. $stat = @fstat($fd);
  31980. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  31981. }
  31982. public static function workaroundFilesystemIssues()
  31983. {
  31984. if (self::isVirtualBoxGuest()) {
  31985. usleep(200000);
  31986. }
  31987. }
  31988. private static function isVirtualBoxGuest()
  31989. {
  31990. if (null === self::$isVirtualBoxGuest) {
  31991. self::$isVirtualBoxGuest = false;
  31992. if (self::isWindows()) {
  31993. return self::$isVirtualBoxGuest;
  31994. }
  31995. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  31996. $processUser = posix_getpwuid(posix_geteuid());
  31997. if ($processUser && $processUser['name'] === 'vagrant') {
  31998. return self::$isVirtualBoxGuest = true;
  31999. }
  32000. }
  32001. if (getenv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
  32002. return self::$isVirtualBoxGuest = true;
  32003. }
  32004. if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
  32005. $process = new ProcessExecutor();
  32006. try {
  32007. if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) {
  32008. return self::$isVirtualBoxGuest = true;
  32009. }
  32010. } catch (\Exception $e) {
  32011. }
  32012. }
  32013. }
  32014. return self::$isVirtualBoxGuest;
  32015. }
  32016. }
  32017. <?php
  32018. namespace Composer\Util;
  32019. use Composer\IO\IOInterface;
  32020. use Symfony\Component\Process\Process;
  32021. use Symfony\Component\Process\ProcessUtils;
  32022. use Symfony\Component\Process\Exception\RuntimeException;
  32023. use React\Promise\Promise;
  32024. class ProcessExecutor
  32025. {
  32026. const STATUS_QUEUED = 1;
  32027. const STATUS_STARTED = 2;
  32028. const STATUS_COMPLETED = 3;
  32029. const STATUS_FAILED = 4;
  32030. const STATUS_ABORTED = 5;
  32031. protected static $timeout = 300;
  32032. protected $captureOutput;
  32033. protected $errorOutput;
  32034. protected $io;
  32035. private $jobs = array();
  32036. private $runningJobs = 0;
  32037. private $maxJobs = 10;
  32038. private $idGen = 0;
  32039. private $allowAsync = false;
  32040. public function __construct(IOInterface $io = null)
  32041. {
  32042. $this->io = $io;
  32043. }
  32044. public function execute($command, &$output = null, $cwd = null)
  32045. {
  32046. if (func_num_args() > 1) {
  32047. return $this->doExecute($command, $cwd, false, $output);
  32048. }
  32049. return $this->doExecute($command, $cwd, false);
  32050. }
  32051. public function executeTty($command, $cwd = null)
  32052. {
  32053. if (Platform::isTty()) {
  32054. return $this->doExecute($command, $cwd, true);
  32055. }
  32056. return $this->doExecute($command, $cwd, false);
  32057. }
  32058. private function doExecute($command, $cwd, $tty, &$output = null)
  32059. {
  32060. if ($this->io && $this->io->isDebug()) {
  32061. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  32062. if (preg_match('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  32063. return '://***:***@';
  32064. }
  32065. return '://'.$m['user'].':***@';
  32066. }, $command);
  32067. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  32068. $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  32069. }
  32070. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  32071. $cwd = realpath(getcwd());
  32072. }
  32073. if (null !== $cwd && !is_dir($cwd)) {
  32074. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  32075. }
  32076. $this->captureOutput = func_num_args() > 3;
  32077. $this->errorOutput = null;
  32078. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  32079. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  32080. } else {
  32081. $process = new Process($command, $cwd, null, null, static::getTimeout());
  32082. }
  32083. if (!Platform::isWindows() && $tty) {
  32084. try {
  32085. $process->setTty(true);
  32086. } catch (RuntimeException $e) {
  32087. }
  32088. }
  32089. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  32090. $process->run($callback);
  32091. if ($this->captureOutput && !is_callable($output)) {
  32092. $output = $process->getOutput();
  32093. }
  32094. $this->errorOutput = $process->getErrorOutput();
  32095. return $process->getExitCode();
  32096. }
  32097. public function executeAsync($command, $cwd = null)
  32098. {
  32099. if (!$this->allowAsync) {
  32100. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  32101. }
  32102. $job = array(
  32103. 'id' => $this->idGen++,
  32104. 'status' => self::STATUS_QUEUED,
  32105. 'command' => $command,
  32106. 'cwd' => $cwd,
  32107. );
  32108. $resolver = function ($resolve, $reject) use (&$job) {
  32109. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  32110. $job['resolve'] = $resolve;
  32111. $job['reject'] = $reject;
  32112. };
  32113. $self = $this;
  32114. $canceler = function () use (&$job) {
  32115. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  32116. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  32117. }
  32118. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  32119. return;
  32120. }
  32121. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  32122. try {
  32123. if (defined('SIGINT')) {
  32124. $job['process']->signal(SIGINT);
  32125. }
  32126. } catch (\Exception $e) {
  32127. }
  32128. $job['process']->stop(1);
  32129. throw new \RuntimeException('Aborted process');
  32130. };
  32131. $promise = new Promise($resolver, $canceler);
  32132. $promise = $promise->then(function () use (&$job, $self) {
  32133. if ($job['process']->isSuccessful()) {
  32134. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  32135. } else {
  32136. $job['status'] = ProcessExecutor::STATUS_FAILED;
  32137. }
  32138. $self->markJobDone();
  32139. return $job['process'];
  32140. }, function ($e) use (&$job, $self) {
  32141. $job['status'] = ProcessExecutor::STATUS_FAILED;
  32142. $self->markJobDone();
  32143. throw $e;
  32144. });
  32145. $this->jobs[$job['id']] = &$job;
  32146. if ($this->runningJobs < $this->maxJobs) {
  32147. $this->startJob($job['id']);
  32148. }
  32149. return $promise;
  32150. }
  32151. private function startJob($id)
  32152. {
  32153. $job = &$this->jobs[$id];
  32154. if ($job['status'] !== self::STATUS_QUEUED) {
  32155. return;
  32156. }
  32157. $job['status'] = self::STATUS_STARTED;
  32158. $this->runningJobs++;
  32159. $command = $job['command'];
  32160. $cwd = $job['cwd'];
  32161. if ($this->io && $this->io->isDebug()) {
  32162. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  32163. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  32164. return '://***:***@';
  32165. }
  32166. return '://'.$m['user'].':***@';
  32167. }, $command);
  32168. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  32169. $this->io->writeError('Executing async command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  32170. }
  32171. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  32172. $cwd = realpath(getcwd());
  32173. }
  32174. if (null !== $cwd && !is_dir($cwd)) {
  32175. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  32176. }
  32177. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  32178. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  32179. } else {
  32180. $process = new Process($command, $cwd, null, null, static::getTimeout());
  32181. }
  32182. $job['process'] = $process;
  32183. $process->start();
  32184. }
  32185. public function wait($index = null)
  32186. {
  32187. while (true) {
  32188. if (!$this->countActiveJobs($index)) {
  32189. return;
  32190. }
  32191. usleep(1000);
  32192. }
  32193. }
  32194. public function enableAsync()
  32195. {
  32196. $this->allowAsync = true;
  32197. }
  32198. public function countActiveJobs($index = null)
  32199. {
  32200. foreach ($this->jobs as $job) {
  32201. if ($job['status'] === self::STATUS_STARTED) {
  32202. if (!$job['process']->isRunning()) {
  32203. call_user_func($job['resolve'], $job['process']);
  32204. }
  32205. }
  32206. if ($this->runningJobs < $this->maxJobs) {
  32207. if ($job['status'] === self::STATUS_QUEUED) {
  32208. $this->startJob($job['id']);
  32209. }
  32210. }
  32211. }
  32212. if (null !== $index) {
  32213. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  32214. }
  32215. $active = 0;
  32216. foreach ($this->jobs as $job) {
  32217. if ($job['status'] < self::STATUS_COMPLETED) {
  32218. $active++;
  32219. } else {
  32220. unset($this->jobs[$job['id']]);
  32221. }
  32222. }
  32223. return $active;
  32224. }
  32225. public function markJobDone()
  32226. {
  32227. $this->runningJobs--;
  32228. }
  32229. public function splitLines($output)
  32230. {
  32231. $output = trim($output);
  32232. return ((string) $output === '') ? array() : preg_split('{\r?\n}', $output);
  32233. }
  32234. public function getErrorOutput()
  32235. {
  32236. return $this->errorOutput;
  32237. }
  32238. public function outputHandler($type, $buffer)
  32239. {
  32240. if ($this->captureOutput) {
  32241. return;
  32242. }
  32243. if (null === $this->io) {
  32244. echo $buffer;
  32245. return;
  32246. }
  32247. if (Process::ERR === $type) {
  32248. $this->io->writeErrorRaw($buffer, false);
  32249. } else {
  32250. $this->io->writeRaw($buffer, false);
  32251. }
  32252. }
  32253. public static function getTimeout()
  32254. {
  32255. return static::$timeout;
  32256. }
  32257. public static function setTimeout($timeout)
  32258. {
  32259. static::$timeout = $timeout;
  32260. }
  32261. public static function escape($argument)
  32262. {
  32263. return self::escapeArgument($argument);
  32264. }
  32265. private static function escapeArgument($argument)
  32266. {
  32267. if ('\\' === DIRECTORY_SEPARATOR) {
  32268. if ((string) $argument === '') {
  32269. return escapeshellarg($argument);
  32270. }
  32271. $escapedArgument = '';
  32272. $quote = false;
  32273. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  32274. if ('"' === $part) {
  32275. $escapedArgument .= '\\"';
  32276. } elseif (self::isSurroundedBy($part, '%')) {
  32277. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  32278. } else {
  32279. if ('\\' === substr($part, -1)) {
  32280. $part .= '\\';
  32281. }
  32282. $quote = true;
  32283. $escapedArgument .= $part;
  32284. }
  32285. }
  32286. if ($quote) {
  32287. $escapedArgument = '"'.$escapedArgument.'"';
  32288. }
  32289. return $escapedArgument;
  32290. }
  32291. return "'".str_replace("'", "'\\''", $argument)."'";
  32292. }
  32293. private static function isSurroundedBy($arg, $char)
  32294. {
  32295. return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
  32296. }
  32297. }
  32298. <?php
  32299. namespace Composer\Util;
  32300. use Composer\Config;
  32301. use Composer\Downloader\MaxFileSizeExceededException;
  32302. use Composer\IO\IOInterface;
  32303. use Composer\Downloader\TransportException;
  32304. use Composer\CaBundle\CaBundle;
  32305. use Composer\Util\Http\Response;
  32306. use Composer\Util\Http\ProxyManager;
  32307. class RemoteFilesystem
  32308. {
  32309. private $io;
  32310. private $config;
  32311. private $scheme;
  32312. private $bytesMax;
  32313. private $originUrl;
  32314. private $fileUrl;
  32315. private $fileName;
  32316. private $retry;
  32317. private $progress;
  32318. private $lastProgress;
  32319. private $options = array();
  32320. private $peerCertificateMap = array();
  32321. private $disableTls = false;
  32322. private $lastHeaders;
  32323. private $storeAuth;
  32324. private $authHelper;
  32325. private $degradedMode = false;
  32326. private $redirects;
  32327. private $maxRedirects = 20;
  32328. private $proxyManager;
  32329. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false, AuthHelper $authHelper = null)
  32330. {
  32331. $this->io = $io;
  32332. if ($disableTls === false) {
  32333. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  32334. } else {
  32335. $this->disableTls = true;
  32336. }
  32337. $this->options = array_replace_recursive($this->options, $options);
  32338. $this->config = $config;
  32339. $this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
  32340. $this->proxyManager = ProxyManager::getInstance();
  32341. }
  32342. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  32343. {
  32344. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  32345. }
  32346. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  32347. {
  32348. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  32349. }
  32350. public function getOptions()
  32351. {
  32352. return $this->options;
  32353. }
  32354. public function setOptions(array $options)
  32355. {
  32356. $this->options = array_replace_recursive($this->options, $options);
  32357. }
  32358. public function isTlsDisabled()
  32359. {
  32360. return $this->disableTls === true;
  32361. }
  32362. public function getLastHeaders()
  32363. {
  32364. return $this->lastHeaders;
  32365. }
  32366. public static function findStatusCode(array $headers)
  32367. {
  32368. $value = null;
  32369. foreach ($headers as $header) {
  32370. if (preg_match('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  32371. $value = (int) $match[1];
  32372. }
  32373. }
  32374. return $value;
  32375. }
  32376. public function findStatusMessage(array $headers)
  32377. {
  32378. $value = null;
  32379. foreach ($headers as $header) {
  32380. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  32381. $value = $header;
  32382. }
  32383. }
  32384. return $value;
  32385. }
  32386. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  32387. {
  32388. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  32389. $this->bytesMax = 0;
  32390. $this->originUrl = $originUrl;
  32391. $this->fileUrl = $fileUrl;
  32392. $this->fileName = $fileName;
  32393. $this->progress = $progress;
  32394. $this->lastProgress = null;
  32395. $retryAuthFailure = true;
  32396. $this->lastHeaders = array();
  32397. $this->redirects = 1;
  32398. $tempAdditionalOptions = $additionalOptions;
  32399. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  32400. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  32401. unset($tempAdditionalOptions['retry-auth-failure']);
  32402. }
  32403. $isRedirect = false;
  32404. if (isset($tempAdditionalOptions['redirects'])) {
  32405. $this->redirects = $tempAdditionalOptions['redirects'];
  32406. $isRedirect = true;
  32407. unset($tempAdditionalOptions['redirects']);
  32408. }
  32409. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  32410. unset($tempAdditionalOptions);
  32411. $origFileUrl = $fileUrl;
  32412. if (isset($options['gitlab-token'])) {
  32413. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  32414. unset($options['gitlab-token']);
  32415. }
  32416. if (isset($options['http'])) {
  32417. $options['http']['ignore_errors'] = true;
  32418. }
  32419. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  32420. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  32421. $degradedPackagist = true;
  32422. }
  32423. $maxFileSize = null;
  32424. if (isset($options['max_file_size'])) {
  32425. $maxFileSize = $options['max_file_size'];
  32426. unset($options['max_file_size']);
  32427. }
  32428. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  32429. $proxy = $this->proxyManager->getProxyForRequest($fileUrl);
  32430. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  32431. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  32432. unset($origFileUrl, $proxy, $usingProxy);
  32433. if ((!preg_match('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
  32434. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  32435. }
  32436. if ($this->progress && !$isRedirect) {
  32437. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  32438. }
  32439. $errorMessage = '';
  32440. $errorCode = 0;
  32441. $result = false;
  32442. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32443. if ($errorMessage) {
  32444. $errorMessage .= "\n";
  32445. }
  32446. $errorMessage .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg);
  32447. return true;
  32448. });
  32449. $http_response_header = array();
  32450. try {
  32451. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  32452. if (!empty($http_response_header[0])) {
  32453. $statusCode = self::findStatusCode($http_response_header);
  32454. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  32455. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  32456. }
  32457. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  32458. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  32459. }
  32460. }
  32461. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  32462. if ($contentLength && Platform::strlen($result) < $contentLength) {
  32463. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  32464. $e->setHeaders($http_response_header);
  32465. $e->setStatusCode(self::findStatusCode($http_response_header));
  32466. try {
  32467. $e->setResponse($this->decodeResult($result, $http_response_header));
  32468. } catch (\Exception $e) {
  32469. $e->setResponse($result);
  32470. }
  32471. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  32472. throw $e;
  32473. }
  32474. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  32475. $params = stream_context_get_params($ctx);
  32476. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  32477. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  32478. if ($expectedPeerFingerprint !== $peerFingerprint) {
  32479. throw new TransportException('Peer fingerprint did not match');
  32480. }
  32481. }
  32482. } catch (\Exception $e) {
  32483. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  32484. $e->setHeaders($http_response_header);
  32485. $e->setStatusCode(self::findStatusCode($http_response_header));
  32486. }
  32487. if ($e instanceof TransportException && $result !== false) {
  32488. $e->setResponse($this->decodeResult($result, $http_response_header));
  32489. }
  32490. $result = false;
  32491. }
  32492. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  32493. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  32494. }
  32495. restore_error_handler();
  32496. if (isset($e) && !$this->retry) {
  32497. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32498. $this->degradedMode = true;
  32499. $this->io->writeError('');
  32500. $this->io->writeError(array(
  32501. '<error>'.$e->getMessage().'</error>',
  32502. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32503. ));
  32504. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32505. }
  32506. throw $e;
  32507. }
  32508. $statusCode = null;
  32509. $contentType = null;
  32510. $locationHeader = null;
  32511. if (!empty($http_response_header[0])) {
  32512. $statusCode = self::findStatusCode($http_response_header);
  32513. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  32514. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  32515. }
  32516. if ($originUrl === 'bitbucket.org'
  32517. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  32518. && substr($fileUrl, -4) === '.zip'
  32519. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  32520. && $contentType && preg_match('{^text/html\b}i', $contentType)
  32521. ) {
  32522. $result = false;
  32523. if ($retryAuthFailure) {
  32524. $this->promptAuthAndRetry(401);
  32525. }
  32526. }
  32527. if ($statusCode === 404
  32528. && $this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  32529. && false !== strpos($fileUrl, 'archive.zip')
  32530. ) {
  32531. $result = false;
  32532. if ($retryAuthFailure) {
  32533. $this->promptAuthAndRetry(401);
  32534. }
  32535. }
  32536. $hasFollowedRedirect = false;
  32537. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  32538. $hasFollowedRedirect = true;
  32539. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  32540. }
  32541. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  32542. if (!$this->retry) {
  32543. if ($this->progress && !$isRedirect) {
  32544. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  32545. }
  32546. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  32547. $e->setHeaders($http_response_header);
  32548. $e->setResponse($this->decodeResult($result, $http_response_header));
  32549. $e->setStatusCode($statusCode);
  32550. throw $e;
  32551. }
  32552. $result = false;
  32553. }
  32554. if ($this->progress && !$this->retry && !$isRedirect) {
  32555. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  32556. }
  32557. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  32558. try {
  32559. $result = $this->decodeResult($result, $http_response_header);
  32560. } catch (\Exception $e) {
  32561. if ($this->degradedMode) {
  32562. throw $e;
  32563. }
  32564. $this->degradedMode = true;
  32565. $this->io->writeError(array(
  32566. '',
  32567. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  32568. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32569. ));
  32570. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32571. }
  32572. }
  32573. if (false !== $result && null !== $fileName && !$isRedirect) {
  32574. if ('' === $result) {
  32575. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  32576. }
  32577. $errorMessage = '';
  32578. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32579. if ($errorMessage) {
  32580. $errorMessage .= "\n";
  32581. }
  32582. $errorMessage .= preg_replace('{^file_put_contents\(.*?\): }', '', $msg);
  32583. return true;
  32584. });
  32585. $result = (bool) file_put_contents($fileName, $result);
  32586. restore_error_handler();
  32587. if (false === $result) {
  32588. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  32589. }
  32590. }
  32591. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  32592. if (CaBundle::isOpensslParseSafe()) {
  32593. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  32594. if ($certDetails) {
  32595. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  32596. $this->retry = true;
  32597. }
  32598. } else {
  32599. $this->io->writeError('');
  32600. $this->io->writeError(sprintf(
  32601. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  32602. PHP_VERSION
  32603. ));
  32604. }
  32605. }
  32606. if ($this->retry) {
  32607. $this->retry = false;
  32608. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32609. if ($this->storeAuth && $this->config) {
  32610. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  32611. $this->storeAuth = false;
  32612. }
  32613. return $result;
  32614. }
  32615. if (false === $result) {
  32616. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  32617. if (!empty($http_response_header[0])) {
  32618. $e->setHeaders($http_response_header);
  32619. }
  32620. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32621. $this->degradedMode = true;
  32622. $this->io->writeError('');
  32623. $this->io->writeError(array(
  32624. '<error>'.$e->getMessage().'</error>',
  32625. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32626. ));
  32627. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32628. }
  32629. throw $e;
  32630. }
  32631. if (!empty($http_response_header[0])) {
  32632. $this->lastHeaders = $http_response_header;
  32633. }
  32634. return $result;
  32635. }
  32636. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null, $maxFileSize = null)
  32637. {
  32638. $result = false;
  32639. try {
  32640. $e = null;
  32641. if ($maxFileSize !== null) {
  32642. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  32643. } else {
  32644. $result = file_get_contents($fileUrl, false, $context);
  32645. }
  32646. } catch (\Throwable $e) {
  32647. } catch (\Exception $e) {
  32648. }
  32649. if ($maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  32650. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  32651. }
  32652. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  32653. if (null !== $e) {
  32654. throw $e;
  32655. }
  32656. return $result;
  32657. }
  32658. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  32659. {
  32660. switch ($notificationCode) {
  32661. case STREAM_NOTIFY_FAILURE:
  32662. if (400 === $messageCode) {
  32663. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  32664. }
  32665. break;
  32666. case STREAM_NOTIFY_FILE_SIZE_IS:
  32667. $this->bytesMax = $bytesMax;
  32668. break;
  32669. case STREAM_NOTIFY_PROGRESS:
  32670. if ($this->bytesMax > 0 && $this->progress) {
  32671. $progression = min(100, round($bytesTransferred / $this->bytesMax * 100));
  32672. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  32673. $this->lastProgress = $progression;
  32674. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  32675. }
  32676. }
  32677. break;
  32678. default:
  32679. break;
  32680. }
  32681. }
  32682. protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
  32683. {
  32684. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  32685. $this->storeAuth = $result['storeAuth'];
  32686. $this->retry = $result['retry'];
  32687. if ($this->retry) {
  32688. throw new TransportException('RETRY');
  32689. }
  32690. }
  32691. protected function getOptionsForUrl($originUrl, $additionalOptions)
  32692. {
  32693. $tlsOptions = array();
  32694. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  32695. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  32696. if (PHP_VERSION_ID < 50304) {
  32697. if ($host === 'github.com' || $host === 'api.github.com') {
  32698. $host = '*.github.com';
  32699. }
  32700. }
  32701. $tlsOptions['ssl']['CN_match'] = $host;
  32702. $tlsOptions['ssl']['SNI_server_name'] = $host;
  32703. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  32704. if (isset($this->peerCertificateMap[$urlAuthority])) {
  32705. $certMap = $this->peerCertificateMap[$urlAuthority];
  32706. $this->io->writeError('', true, IOInterface::DEBUG);
  32707. $this->io->writeError(sprintf(
  32708. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  32709. $certMap['cn'],
  32710. $urlAuthority
  32711. ), true, IOInterface::DEBUG);
  32712. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  32713. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  32714. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  32715. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  32716. }
  32717. }
  32718. $headers = array();
  32719. if (extension_loaded('zlib')) {
  32720. $headers[] = 'Accept-Encoding: gzip';
  32721. }
  32722. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  32723. if (!$this->degradedMode) {
  32724. $options['http']['protocol_version'] = 1.1;
  32725. $headers[] = 'Connection: close';
  32726. }
  32727. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  32728. $options['http']['follow_location'] = 0;
  32729. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  32730. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  32731. }
  32732. foreach ($headers as $header) {
  32733. $options['http']['header'][] = $header;
  32734. }
  32735. return $options;
  32736. }
  32737. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  32738. {
  32739. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  32740. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  32741. $targetUrl = $locationHeader;
  32742. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  32743. $targetUrl = $this->scheme.':'.$locationHeader;
  32744. } elseif ('/' === $locationHeader[0]) {
  32745. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  32746. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32747. } else {
  32748. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32749. }
  32750. }
  32751. if (!empty($targetUrl)) {
  32752. $this->redirects++;
  32753. $this->io->writeError('', true, IOInterface::DEBUG);
  32754. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  32755. $additionalOptions['redirects'] = $this->redirects;
  32756. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  32757. }
  32758. if (!$this->retry) {
  32759. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  32760. $e->setHeaders($http_response_header);
  32761. $e->setResponse($this->decodeResult($result, $http_response_header));
  32762. throw $e;
  32763. }
  32764. return false;
  32765. }
  32766. private function getCertificateCnAndFp($url, $options)
  32767. {
  32768. if (PHP_VERSION_ID >= 50600) {
  32769. throw new \BadMethodCallException(sprintf(
  32770. '%s must not be used on PHP >= 5.6',
  32771. __METHOD__
  32772. ));
  32773. }
  32774. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  32775. 'ssl' => array(
  32776. 'capture_peer_cert' => true,
  32777. 'verify_peer' => false,
  32778. ), ),
  32779. ));
  32780. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  32781. return;
  32782. }
  32783. fclose($handle);
  32784. $handle = null;
  32785. $params = stream_context_get_params($context);
  32786. if (!empty($params['options']['ssl']['peer_certificate'])) {
  32787. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  32788. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  32789. return array(
  32790. 'cn' => $commonName,
  32791. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  32792. );
  32793. }
  32794. }
  32795. }
  32796. private function getUrlAuthority($url)
  32797. {
  32798. $defaultPorts = array(
  32799. 'ftp' => 21,
  32800. 'http' => 80,
  32801. 'https' => 443,
  32802. 'ssh2.sftp' => 22,
  32803. 'ssh2.scp' => 22,
  32804. );
  32805. $scheme = parse_url($url, PHP_URL_SCHEME);
  32806. if (!isset($defaultPorts[$scheme])) {
  32807. throw new \InvalidArgumentException(sprintf(
  32808. 'Could not get default port for unknown scheme: %s',
  32809. $scheme
  32810. ));
  32811. }
  32812. $defaultPort = $defaultPorts[$scheme];
  32813. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  32814. return parse_url($url, PHP_URL_HOST).':'.$port;
  32815. }
  32816. private function decodeResult($result, $http_response_header)
  32817. {
  32818. if ($result && extension_loaded('zlib')) {
  32819. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  32820. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  32821. if ($decode) {
  32822. if (PHP_VERSION_ID >= 50400) {
  32823. $result = zlib_decode($result);
  32824. } else {
  32825. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  32826. }
  32827. if ($result === false) {
  32828. throw new TransportException('Failed to decode zlib stream');
  32829. }
  32830. }
  32831. }
  32832. return $result;
  32833. }
  32834. }
  32835. <?php
  32836. namespace Composer\Util;
  32837. class Silencer
  32838. {
  32839. private static $stack = array();
  32840. public static function suppress($mask = null)
  32841. {
  32842. if (!isset($mask)) {
  32843. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  32844. }
  32845. $old = error_reporting();
  32846. self::$stack[] = $old;
  32847. error_reporting($old & ~$mask);
  32848. return $old;
  32849. }
  32850. public static function restore()
  32851. {
  32852. if (!empty(self::$stack)) {
  32853. error_reporting(array_pop(self::$stack));
  32854. }
  32855. }
  32856. public static function call($callable )
  32857. {
  32858. try {
  32859. self::suppress();
  32860. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  32861. self::restore();
  32862. return $result;
  32863. } catch (\Exception $e) {
  32864. self::restore();
  32865. throw $e;
  32866. }
  32867. }
  32868. }
  32869. <?php
  32870. namespace Composer\Util;
  32871. use Composer\Composer;
  32872. use Composer\CaBundle\CaBundle;
  32873. use Composer\Downloader\TransportException;
  32874. use Composer\Util\Http\ProxyManager;
  32875. use Psr\Log\LoggerInterface;
  32876. final class StreamContextFactory
  32877. {
  32878. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  32879. {
  32880. $options = array('http' => array(
  32881. 'follow_location' => 1,
  32882. 'max_redirects' => 20,
  32883. ));
  32884. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  32885. unset($defaultOptions['http']['header']);
  32886. $options = array_replace_recursive($options, $defaultOptions);
  32887. if (isset($options['http']['header'])) {
  32888. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  32889. }
  32890. return stream_context_create($options, $defaultParams);
  32891. }
  32892. public static function initOptions($url, array $options, $forCurl = false)
  32893. {
  32894. if (!isset($options['http']['header'])) {
  32895. $options['http']['header'] = array();
  32896. }
  32897. if (is_string($options['http']['header'])) {
  32898. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  32899. }
  32900. if (!$forCurl) {
  32901. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  32902. if ($proxyOptions = $proxy->getContextOptions()) {
  32903. $isHttpsRequest = 0 === strpos($url, 'https://');
  32904. if ($proxy->isSecure()) {
  32905. if (!extension_loaded('openssl')) {
  32906. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  32907. }
  32908. if ($isHttpsRequest) {
  32909. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  32910. }
  32911. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  32912. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  32913. }
  32914. if (isset($proxyOptions['http']['header'])) {
  32915. $options['http']['header'][] = $proxyOptions['http']['header'];
  32916. unset($proxyOptions['http']['header']);
  32917. }
  32918. $options = array_replace_recursive($options, $proxyOptions);
  32919. }
  32920. }
  32921. if (defined('HHVM_VERSION')) {
  32922. $phpVersion = 'HHVM ' . HHVM_VERSION;
  32923. } else {
  32924. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  32925. }
  32926. if ($forCurl) {
  32927. $curl = curl_version();
  32928. $httpVersion = 'cURL '.$curl['version'];
  32929. } else {
  32930. $httpVersion = 'streams';
  32931. }
  32932. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  32933. $options['http']['header'][] = sprintf(
  32934. 'User-Agent: Composer/%s (%s; %s; %s; %s%s)',
  32935. Composer::getVersion(),
  32936. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  32937. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  32938. $phpVersion,
  32939. $httpVersion,
  32940. getenv('CI') ? '; CI' : ''
  32941. );
  32942. }
  32943. return $options;
  32944. }
  32945. public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
  32946. {
  32947. $ciphers = implode(':', array(
  32948. 'ECDHE-RSA-AES128-GCM-SHA256',
  32949. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  32950. 'ECDHE-RSA-AES256-GCM-SHA384',
  32951. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  32952. 'DHE-RSA-AES128-GCM-SHA256',
  32953. 'DHE-DSS-AES128-GCM-SHA256',
  32954. 'kEDH+AESGCM',
  32955. 'ECDHE-RSA-AES128-SHA256',
  32956. 'ECDHE-ECDSA-AES128-SHA256',
  32957. 'ECDHE-RSA-AES128-SHA',
  32958. 'ECDHE-ECDSA-AES128-SHA',
  32959. 'ECDHE-RSA-AES256-SHA384',
  32960. 'ECDHE-ECDSA-AES256-SHA384',
  32961. 'ECDHE-RSA-AES256-SHA',
  32962. 'ECDHE-ECDSA-AES256-SHA',
  32963. 'DHE-RSA-AES128-SHA256',
  32964. 'DHE-RSA-AES128-SHA',
  32965. 'DHE-DSS-AES128-SHA256',
  32966. 'DHE-RSA-AES256-SHA256',
  32967. 'DHE-DSS-AES256-SHA',
  32968. 'DHE-RSA-AES256-SHA',
  32969. 'AES128-GCM-SHA256',
  32970. 'AES256-GCM-SHA384',
  32971. 'AES128-SHA256',
  32972. 'AES256-SHA256',
  32973. 'AES128-SHA',
  32974. 'AES256-SHA',
  32975. 'AES',
  32976. 'CAMELLIA',
  32977. 'DES-CBC3-SHA',
  32978. '!aNULL',
  32979. '!eNULL',
  32980. '!EXPORT',
  32981. '!DES',
  32982. '!RC4',
  32983. '!MD5',
  32984. '!PSK',
  32985. '!aECDH',
  32986. '!EDH-DSS-DES-CBC3-SHA',
  32987. '!EDH-RSA-DES-CBC3-SHA',
  32988. '!KRB5-DES-CBC3-SHA',
  32989. ));
  32990. $defaults = array(
  32991. 'ssl' => array(
  32992. 'ciphers' => $ciphers,
  32993. 'verify_peer' => true,
  32994. 'verify_depth' => 7,
  32995. 'SNI_enabled' => true,
  32996. 'capture_peer_cert' => true,
  32997. ),
  32998. );
  32999. if (isset($options['ssl'])) {
  33000. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  33001. }
  33002. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  33003. $result = CaBundle::getSystemCaRootBundlePath($logger);
  33004. if (is_dir($result)) {
  33005. $defaults['ssl']['capath'] = $result;
  33006. } else {
  33007. $defaults['ssl']['cafile'] = $result;
  33008. }
  33009. }
  33010. if (isset($defaults['ssl']['cafile']) && (!is_readable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  33011. throw new TransportException('The configured cafile was not valid or could not be read.');
  33012. }
  33013. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !is_readable($defaults['ssl']['capath']))) {
  33014. throw new TransportException('The configured capath was not valid or could not be read.');
  33015. }
  33016. if (PHP_VERSION_ID >= 50413) {
  33017. $defaults['ssl']['disable_compression'] = true;
  33018. }
  33019. return $defaults;
  33020. }
  33021. private static function fixHttpHeaderField($header)
  33022. {
  33023. if (!is_array($header)) {
  33024. $header = explode("\r\n", $header);
  33025. }
  33026. uasort($header, function ($el) {
  33027. return stripos($el, 'content-type') === 0 ? 1 : -1;
  33028. });
  33029. return $header;
  33030. }
  33031. }
  33032. <?php
  33033. namespace Composer\Util;
  33034. use Composer\Config;
  33035. use Composer\IO\IOInterface;
  33036. class Svn
  33037. {
  33038. const MAX_QTY_AUTH_TRIES = 5;
  33039. protected $credentials;
  33040. protected $hasAuth;
  33041. protected $io;
  33042. protected $url;
  33043. protected $cacheCredentials = true;
  33044. protected $process;
  33045. protected $qtyAuthTries = 0;
  33046. protected $config;
  33047. private static $version;
  33048. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  33049. {
  33050. $this->url = $url;
  33051. $this->io = $io;
  33052. $this->config = $config;
  33053. $this->process = $process ?: new ProcessExecutor($io);
  33054. }
  33055. public static function cleanEnv()
  33056. {
  33057. putenv("DYLD_LIBRARY_PATH");
  33058. unset($_SERVER['DYLD_LIBRARY_PATH']);
  33059. }
  33060. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  33061. {
  33062. $this->config->prohibitUrlByConfig($url, $this->io);
  33063. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  33064. }
  33065. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  33066. {
  33067. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  33068. }
  33069. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  33070. {
  33071. $command = $this->getCommand($svnCommand, $url, $path);
  33072. $output = null;
  33073. $io = $this->io;
  33074. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  33075. if ($type !== 'out') {
  33076. return;
  33077. }
  33078. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  33079. return;
  33080. }
  33081. $output .= $buffer;
  33082. if ($verbose) {
  33083. $io->writeError($buffer, false);
  33084. }
  33085. };
  33086. $status = $this->process->execute($command, $handler, $cwd);
  33087. if (0 === $status) {
  33088. return $output;
  33089. }
  33090. $errorOutput = $this->process->getErrorOutput();
  33091. $fullOutput = implode("\n", array($output, $errorOutput));
  33092. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  33093. && false === stripos($fullOutput, 'authorization failed')
  33094. && false === stripos($fullOutput, 'svn: E170001:')
  33095. && false === stripos($fullOutput, 'svn: E215004:')) {
  33096. throw new \RuntimeException($fullOutput);
  33097. }
  33098. if (!$this->hasAuth()) {
  33099. $this->doAuthDance();
  33100. }
  33101. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  33102. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  33103. }
  33104. throw new \RuntimeException(
  33105. 'wrong credentials provided ('.$fullOutput.')'
  33106. );
  33107. }
  33108. public function setCacheCredentials($cacheCredentials)
  33109. {
  33110. $this->cacheCredentials = $cacheCredentials;
  33111. }
  33112. protected function doAuthDance()
  33113. {
  33114. if (!$this->io->isInteractive()) {
  33115. throw new \RuntimeException(
  33116. 'can not ask for authentication in non interactive mode'
  33117. );
  33118. }
  33119. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  33120. $this->hasAuth = true;
  33121. $this->credentials['username'] = $this->io->ask("Username: ");
  33122. $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
  33123. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  33124. return $this;
  33125. }
  33126. protected function getCommand($cmd, $url, $path = null)
  33127. {
  33128. $cmd = sprintf(
  33129. '%s %s%s %s',
  33130. $cmd,
  33131. '--non-interactive ',
  33132. $this->getCredentialString(),
  33133. ProcessExecutor::escape($url)
  33134. );
  33135. if ($path) {
  33136. $cmd .= ' ' . ProcessExecutor::escape($path);
  33137. }
  33138. return $cmd;
  33139. }
  33140. protected function getCredentialString()
  33141. {
  33142. if (!$this->hasAuth()) {
  33143. return '';
  33144. }
  33145. return sprintf(
  33146. ' %s--username %s --password %s ',
  33147. $this->getAuthCache(),
  33148. ProcessExecutor::escape($this->getUsername()),
  33149. ProcessExecutor::escape($this->getPassword())
  33150. );
  33151. }
  33152. protected function getPassword()
  33153. {
  33154. if ($this->credentials === null) {
  33155. throw new \LogicException("No svn auth detected.");
  33156. }
  33157. return isset($this->credentials['password']) ? $this->credentials['password'] : '';
  33158. }
  33159. protected function getUsername()
  33160. {
  33161. if ($this->credentials === null) {
  33162. throw new \LogicException("No svn auth detected.");
  33163. }
  33164. return $this->credentials['username'];
  33165. }
  33166. protected function hasAuth()
  33167. {
  33168. if (null !== $this->hasAuth) {
  33169. return $this->hasAuth;
  33170. }
  33171. if (false === $this->createAuthFromConfig()) {
  33172. $this->createAuthFromUrl();
  33173. }
  33174. return (bool) $this->hasAuth;
  33175. }
  33176. protected function getAuthCache()
  33177. {
  33178. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  33179. }
  33180. private function createAuthFromConfig()
  33181. {
  33182. if (!$this->config->has('http-basic')) {
  33183. return $this->hasAuth = false;
  33184. }
  33185. $authConfig = $this->config->get('http-basic');
  33186. $host = parse_url($this->url, PHP_URL_HOST);
  33187. if (isset($authConfig[$host])) {
  33188. $this->credentials['username'] = $authConfig[$host]['username'];
  33189. $this->credentials['password'] = $authConfig[$host]['password'];
  33190. return $this->hasAuth = true;
  33191. }
  33192. return $this->hasAuth = false;
  33193. }
  33194. private function createAuthFromUrl()
  33195. {
  33196. $uri = parse_url($this->url);
  33197. if (empty($uri['user'])) {
  33198. return $this->hasAuth = false;
  33199. }
  33200. $this->credentials['username'] = $uri['user'];
  33201. if (!empty($uri['pass'])) {
  33202. $this->credentials['password'] = $uri['pass'];
  33203. }
  33204. return $this->hasAuth = true;
  33205. }
  33206. public function binaryVersion()
  33207. {
  33208. if (!self::$version) {
  33209. if (0 === $this->process->execute('svn --version', $output)) {
  33210. if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
  33211. self::$version = $match[1];
  33212. }
  33213. }
  33214. }
  33215. return self::$version;
  33216. }
  33217. }
  33218. <?php
  33219. namespace Composer\Util;
  33220. use Composer\Downloader\DownloaderInterface;
  33221. use Composer\Package\PackageInterface;
  33222. use React\Promise\PromiseInterface;
  33223. class SyncHelper
  33224. {
  33225. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, $path, PackageInterface $package, PackageInterface $prevPackage = null)
  33226. {
  33227. $type = $prevPackage ? 'update' : 'install';
  33228. try {
  33229. self::await($loop, $downloader->download($package, $path, $prevPackage));
  33230. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  33231. if ($type === 'update') {
  33232. self::await($loop, $downloader->update($package, $path, $prevPackage));
  33233. } else {
  33234. self::await($loop, $downloader->install($package, $path, $prevPackage));
  33235. }
  33236. } catch (\Exception $e) {
  33237. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  33238. throw $e;
  33239. }
  33240. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  33241. }
  33242. public static function await(Loop $loop, PromiseInterface $promise = null)
  33243. {
  33244. if ($promise) {
  33245. $loop->wait(array($promise));
  33246. }
  33247. }
  33248. }
  33249. <?php
  33250. namespace Composer\Util;
  33251. class Tar
  33252. {
  33253. public static function getComposerJson($pathToArchive)
  33254. {
  33255. $phar = new \PharData($pathToArchive);
  33256. if (!$phar->valid()) {
  33257. return null;
  33258. }
  33259. return self::extractComposerJsonFromFolder($phar);
  33260. }
  33261. private static function extractComposerJsonFromFolder(\PharData $phar)
  33262. {
  33263. if (isset($phar['composer.json'])) {
  33264. return $phar['composer.json']->getContent();
  33265. }
  33266. $topLevelPaths = array();
  33267. foreach ($phar as $folderFile) {
  33268. $name = $folderFile->getBasename();
  33269. if ($folderFile->isDir()) {
  33270. $topLevelPaths[$name] = true;
  33271. if (\count($topLevelPaths) > 1) {
  33272. throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths)));
  33273. }
  33274. }
  33275. }
  33276. $composerJsonPath = key($topLevelPaths).'/composer.json';
  33277. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  33278. return $phar[$composerJsonPath]->getContent();
  33279. }
  33280. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  33281. }
  33282. }
  33283. <?php
  33284. namespace Composer\Util;
  33285. use Composer\CaBundle\CaBundle;
  33286. final class TlsHelper
  33287. {
  33288. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  33289. {
  33290. $names = self::getCertificateNames($certificate);
  33291. if (empty($names)) {
  33292. return false;
  33293. }
  33294. $combinedNames = array_merge($names['san'], array($names['cn']));
  33295. $hostname = strtolower($hostname);
  33296. foreach ($combinedNames as $certName) {
  33297. $matcher = self::certNameMatcher($certName);
  33298. if ($matcher && $matcher($hostname)) {
  33299. $cn = $names['cn'];
  33300. return true;
  33301. }
  33302. }
  33303. return false;
  33304. }
  33305. public static function getCertificateNames($certificate)
  33306. {
  33307. if (is_array($certificate)) {
  33308. $info = $certificate;
  33309. } elseif (CaBundle::isOpensslParseSafe()) {
  33310. $info = openssl_x509_parse($certificate, false);
  33311. }
  33312. if (!isset($info['subject']['commonName'])) {
  33313. return null;
  33314. }
  33315. $commonName = strtolower($info['subject']['commonName']);
  33316. $subjectAltNames = array();
  33317. if (isset($info['extensions']['subjectAltName'])) {
  33318. $subjectAltNames = preg_split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  33319. $subjectAltNames = array_filter(array_map(function ($name) {
  33320. if (0 === strpos($name, 'DNS:')) {
  33321. return strtolower(ltrim(substr($name, 4)));
  33322. }
  33323. return null;
  33324. }, $subjectAltNames));
  33325. $subjectAltNames = array_values($subjectAltNames);
  33326. }
  33327. return array(
  33328. 'cn' => $commonName,
  33329. 'san' => $subjectAltNames,
  33330. );
  33331. }
  33332. public static function getCertificateFingerprint($certificate)
  33333. {
  33334. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  33335. $pubkeypem = $pubkeydetails['key'];
  33336. $start = '-----BEGIN PUBLIC KEY-----';
  33337. $end = '-----END PUBLIC KEY-----';
  33338. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  33339. $der = base64_decode($pemtrim);
  33340. return sha1($der);
  33341. }
  33342. public static function isOpensslParseSafe()
  33343. {
  33344. return CaBundle::isOpensslParseSafe();
  33345. }
  33346. private static function certNameMatcher($certName)
  33347. {
  33348. $wildcards = substr_count($certName, '*');
  33349. if (0 === $wildcards) {
  33350. return function ($hostname) use ($certName) {
  33351. return $hostname === $certName;
  33352. };
  33353. }
  33354. if (1 === $wildcards) {
  33355. $components = explode('.', $certName);
  33356. if (3 > count($components)) {
  33357. return;
  33358. }
  33359. $firstComponent = $components[0];
  33360. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  33361. return;
  33362. }
  33363. $wildcardRegex = preg_quote($certName);
  33364. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  33365. $wildcardRegex = "{^{$wildcardRegex}$}";
  33366. return function ($hostname) use ($wildcardRegex) {
  33367. return 1 === preg_match($wildcardRegex, $hostname);
  33368. };
  33369. }
  33370. }
  33371. }
  33372. <?php
  33373. namespace Composer\Util;
  33374. use Composer\Config;
  33375. class Url
  33376. {
  33377. public static function updateDistReference(Config $config, $url, $ref)
  33378. {
  33379. $host = parse_url($url, PHP_URL_HOST);
  33380. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  33381. if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  33382. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33383. } elseif (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  33384. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33385. } elseif (preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  33386. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33387. }
  33388. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  33389. if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  33390. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  33391. }
  33392. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  33393. if (preg_match('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  33394. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  33395. }
  33396. } elseif (in_array($host, $config->get('github-domains'), true)) {
  33397. $url = preg_replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  33398. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  33399. $url = preg_replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  33400. }
  33401. return $url;
  33402. }
  33403. public static function getOrigin(Config $config, $url)
  33404. {
  33405. if (0 === strpos($url, 'file://')) {
  33406. return $url;
  33407. }
  33408. $origin = (string) parse_url($url, PHP_URL_HOST);
  33409. if ($port = parse_url($url, PHP_URL_PORT)) {
  33410. $origin .= ':'.$port;
  33411. }
  33412. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  33413. return 'github.com';
  33414. }
  33415. if ($origin === 'repo.packagist.org') {
  33416. return 'packagist.org';
  33417. }
  33418. if ($origin === '') {
  33419. $origin = $url;
  33420. }
  33421. if (
  33422. is_array($config->get('gitlab-domains'))
  33423. && false === strpos($origin, '/')
  33424. && !in_array($origin, $config->get('gitlab-domains'))
  33425. ) {
  33426. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  33427. if (0 === strpos($gitlabDomain, $origin)) {
  33428. return $gitlabDomain;
  33429. }
  33430. }
  33431. }
  33432. return $origin;
  33433. }
  33434. public static function sanitize($url)
  33435. {
  33436. $url = preg_replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  33437. $url = preg_replace_callback('{(?P<prefix>://|^)(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  33438. if (preg_match('{^([a-f0-9]{12,}|g[a-z]\d_[a-zA-Z0-9_]+)$}', $m['user'])) {
  33439. return $m['prefix'].'***:***@';
  33440. }
  33441. return $m['prefix'].$m['user'].':***@';
  33442. }, $url);
  33443. return $url;
  33444. }
  33445. }
  33446. <?php
  33447. namespace Composer\Util;
  33448. class Zip
  33449. {
  33450. public static function getComposerJson($pathToZip)
  33451. {
  33452. if (!extension_loaded('zip')) {
  33453. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  33454. }
  33455. $zip = new \ZipArchive();
  33456. if ($zip->open($pathToZip) !== true) {
  33457. return null;
  33458. }
  33459. if (0 == $zip->numFiles) {
  33460. $zip->close();
  33461. return null;
  33462. }
  33463. $foundFileIndex = self::locateFile($zip, 'composer.json');
  33464. if (false === $foundFileIndex) {
  33465. $zip->close();
  33466. return null;
  33467. }
  33468. $content = null;
  33469. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  33470. $stream = $zip->getStream($configurationFileName);
  33471. if (false !== $stream) {
  33472. $content = stream_get_contents($stream);
  33473. }
  33474. $zip->close();
  33475. return $content;
  33476. }
  33477. private static function locateFile(\ZipArchive $zip, $filename)
  33478. {
  33479. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  33480. return $index;
  33481. }
  33482. $topLevelPaths = array();
  33483. for ($i = 0; $i < $zip->numFiles; $i++) {
  33484. $name = $zip->getNameIndex($i);
  33485. $dirname = dirname($name);
  33486. if (strpos($name, '__MACOSX') !== false) {
  33487. continue;
  33488. }
  33489. if ($dirname === '.') {
  33490. $topLevelPaths[$name] = true;
  33491. if (\count($topLevelPaths) > 1) {
  33492. throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths)));
  33493. }
  33494. continue;
  33495. }
  33496. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  33497. $topLevelPaths[$dirname.'/'] = true;
  33498. if (\count($topLevelPaths) > 1) {
  33499. throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths)));
  33500. }
  33501. }
  33502. }
  33503. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  33504. return $index;
  33505. }
  33506. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  33507. }
  33508. }
  33509. <?php
  33510. function includeIfExists($file)
  33511. {
  33512. return file_exists($file) ? include $file : false;
  33513. }
  33514. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  33515. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  33516. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  33517. exit(1);
  33518. }
  33519. return $loader;
  33520. <?php
  33521. /*
  33522. * This file is part of Composer.
  33523. *
  33524. * (c) Nils Adermann <naderman@naderman.de>
  33525. * Jordi Boggiano <j.boggiano@seld.be>
  33526. *
  33527. * For the full copyright and license information, please view the LICENSE
  33528. * file that was distributed with this source code.
  33529. */
  33530. namespace Composer\Autoload;
  33531. /**
  33532. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  33533. *
  33534. * $loader = new \Composer\Autoload\ClassLoader();
  33535. *
  33536. * // register classes with namespaces
  33537. * $loader->add('Symfony\Component', __DIR__.'/component');
  33538. * $loader->add('Symfony', __DIR__.'/framework');
  33539. *
  33540. * // activate the autoloader
  33541. * $loader->register();
  33542. *
  33543. * // to enable searching the include path (eg. for PEAR packages)
  33544. * $loader->setUseIncludePath(true);
  33545. *
  33546. * In this example, if you try to use a class in the Symfony\Component
  33547. * namespace or one of its children (Symfony\Component\Console for instance),
  33548. * the autoloader will first look for the class under the component/
  33549. * directory, and it will then fallback to the framework/ directory if not
  33550. * found before giving up.
  33551. *
  33552. * This class is loosely based on the Symfony UniversalClassLoader.
  33553. *
  33554. * @author Fabien Potencier <fabien@symfony.com>
  33555. * @author Jordi Boggiano <j.boggiano@seld.be>
  33556. * @see https://www.php-fig.org/psr/psr-0/
  33557. * @see https://www.php-fig.org/psr/psr-4/
  33558. */
  33559. class ClassLoader
  33560. {
  33561. private $vendorDir;
  33562. // PSR-4
  33563. private $prefixLengthsPsr4 = array();
  33564. private $prefixDirsPsr4 = array();
  33565. private $fallbackDirsPsr4 = array();
  33566. // PSR-0
  33567. private $prefixesPsr0 = array();
  33568. private $fallbackDirsPsr0 = array();
  33569. private $useIncludePath = false;
  33570. private $classMap = array();
  33571. private $classMapAuthoritative = false;
  33572. private $missingClasses = array();
  33573. private $apcuPrefix;
  33574. private static $registeredLoaders = array();
  33575. public function __construct($vendorDir = null)
  33576. {
  33577. $this->vendorDir = $vendorDir;
  33578. }
  33579. public function getPrefixes()
  33580. {
  33581. if (!empty($this->prefixesPsr0)) {
  33582. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  33583. }
  33584. return array();
  33585. }
  33586. public function getPrefixesPsr4()
  33587. {
  33588. return $this->prefixDirsPsr4;
  33589. }
  33590. public function getFallbackDirs()
  33591. {
  33592. return $this->fallbackDirsPsr0;
  33593. }
  33594. public function getFallbackDirsPsr4()
  33595. {
  33596. return $this->fallbackDirsPsr4;
  33597. }
  33598. public function getClassMap()
  33599. {
  33600. return $this->classMap;
  33601. }
  33602. /**
  33603. * @param array $classMap Class to filename map
  33604. */
  33605. public function addClassMap(array $classMap)
  33606. {
  33607. if ($this->classMap) {
  33608. $this->classMap = array_merge($this->classMap, $classMap);
  33609. } else {
  33610. $this->classMap = $classMap;
  33611. }
  33612. }
  33613. /**
  33614. * Registers a set of PSR-0 directories for a given prefix, either
  33615. * appending or prepending to the ones previously set for this prefix.
  33616. *
  33617. * @param string $prefix The prefix
  33618. * @param array|string $paths The PSR-0 root directories
  33619. * @param bool $prepend Whether to prepend the directories
  33620. */
  33621. public function add($prefix, $paths, $prepend = false)
  33622. {
  33623. if (!$prefix) {
  33624. if ($prepend) {
  33625. $this->fallbackDirsPsr0 = array_merge(
  33626. (array) $paths,
  33627. $this->fallbackDirsPsr0
  33628. );
  33629. } else {
  33630. $this->fallbackDirsPsr0 = array_merge(
  33631. $this->fallbackDirsPsr0,
  33632. (array) $paths
  33633. );
  33634. }
  33635. return;
  33636. }
  33637. $first = $prefix[0];
  33638. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  33639. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  33640. return;
  33641. }
  33642. if ($prepend) {
  33643. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33644. (array) $paths,
  33645. $this->prefixesPsr0[$first][$prefix]
  33646. );
  33647. } else {
  33648. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33649. $this->prefixesPsr0[$first][$prefix],
  33650. (array) $paths
  33651. );
  33652. }
  33653. }
  33654. /**
  33655. * Registers a set of PSR-4 directories for a given namespace, either
  33656. * appending or prepending to the ones previously set for this namespace.
  33657. *
  33658. * @param string $prefix The prefix/namespace, with trailing '\\'
  33659. * @param array|string $paths The PSR-4 base directories
  33660. * @param bool $prepend Whether to prepend the directories
  33661. *
  33662. * @throws \InvalidArgumentException
  33663. */
  33664. public function addPsr4($prefix, $paths, $prepend = false)
  33665. {
  33666. if (!$prefix) {
  33667. // Register directories for the root namespace.
  33668. if ($prepend) {
  33669. $this->fallbackDirsPsr4 = array_merge(
  33670. (array) $paths,
  33671. $this->fallbackDirsPsr4
  33672. );
  33673. } else {
  33674. $this->fallbackDirsPsr4 = array_merge(
  33675. $this->fallbackDirsPsr4,
  33676. (array) $paths
  33677. );
  33678. }
  33679. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  33680. // Register directories for a new namespace.
  33681. $length = strlen($prefix);
  33682. if ('\\' !== $prefix[$length - 1]) {
  33683. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33684. }
  33685. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33686. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33687. } elseif ($prepend) {
  33688. // Prepend directories for an already registered namespace.
  33689. $this->prefixDirsPsr4[$prefix] = array_merge(
  33690. (array) $paths,
  33691. $this->prefixDirsPsr4[$prefix]
  33692. );
  33693. } else {
  33694. // Append directories for an already registered namespace.
  33695. $this->prefixDirsPsr4[$prefix] = array_merge(
  33696. $this->prefixDirsPsr4[$prefix],
  33697. (array) $paths
  33698. );
  33699. }
  33700. }
  33701. /**
  33702. * Registers a set of PSR-0 directories for a given prefix,
  33703. * replacing any others previously set for this prefix.
  33704. *
  33705. * @param string $prefix The prefix
  33706. * @param array|string $paths The PSR-0 base directories
  33707. */
  33708. public function set($prefix, $paths)
  33709. {
  33710. if (!$prefix) {
  33711. $this->fallbackDirsPsr0 = (array) $paths;
  33712. } else {
  33713. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  33714. }
  33715. }
  33716. /**
  33717. * Registers a set of PSR-4 directories for a given namespace,
  33718. * replacing any others previously set for this namespace.
  33719. *
  33720. * @param string $prefix The prefix/namespace, with trailing '\\'
  33721. * @param array|string $paths The PSR-4 base directories
  33722. *
  33723. * @throws \InvalidArgumentException
  33724. */
  33725. public function setPsr4($prefix, $paths)
  33726. {
  33727. if (!$prefix) {
  33728. $this->fallbackDirsPsr4 = (array) $paths;
  33729. } else {
  33730. $length = strlen($prefix);
  33731. if ('\\' !== $prefix[$length - 1]) {
  33732. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33733. }
  33734. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33735. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33736. }
  33737. }
  33738. /**
  33739. * Turns on searching the include path for class files.
  33740. *
  33741. * @param bool $useIncludePath
  33742. */
  33743. public function setUseIncludePath($useIncludePath)
  33744. {
  33745. $this->useIncludePath = $useIncludePath;
  33746. }
  33747. /**
  33748. * Can be used to check if the autoloader uses the include path to check
  33749. * for classes.
  33750. *
  33751. * @return bool
  33752. */
  33753. public function getUseIncludePath()
  33754. {
  33755. return $this->useIncludePath;
  33756. }
  33757. /**
  33758. * Turns off searching the prefix and fallback directories for classes
  33759. * that have not been registered with the class map.
  33760. *
  33761. * @param bool $classMapAuthoritative
  33762. */
  33763. public function setClassMapAuthoritative($classMapAuthoritative)
  33764. {
  33765. $this->classMapAuthoritative = $classMapAuthoritative;
  33766. }
  33767. /**
  33768. * Should class lookup fail if not found in the current class map?
  33769. *
  33770. * @return bool
  33771. */
  33772. public function isClassMapAuthoritative()
  33773. {
  33774. return $this->classMapAuthoritative;
  33775. }
  33776. /**
  33777. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  33778. *
  33779. * @param string|null $apcuPrefix
  33780. */
  33781. public function setApcuPrefix($apcuPrefix)
  33782. {
  33783. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  33784. }
  33785. /**
  33786. * The APCu prefix in use, or null if APCu caching is not enabled.
  33787. *
  33788. * @return string|null
  33789. */
  33790. public function getApcuPrefix()
  33791. {
  33792. return $this->apcuPrefix;
  33793. }
  33794. /**
  33795. * Registers this instance as an autoloader.
  33796. *
  33797. * @param bool $prepend Whether to prepend the autoloader or not
  33798. */
  33799. public function register($prepend = false)
  33800. {
  33801. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  33802. if (null === $this->vendorDir) {
  33803. return;
  33804. }
  33805. if ($prepend) {
  33806. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  33807. } else {
  33808. unset(self::$registeredLoaders[$this->vendorDir]);
  33809. self::$registeredLoaders[$this->vendorDir] = $this;
  33810. }
  33811. }
  33812. /**
  33813. * Unregisters this instance as an autoloader.
  33814. */
  33815. public function unregister()
  33816. {
  33817. spl_autoload_unregister(array($this, 'loadClass'));
  33818. if (null !== $this->vendorDir) {
  33819. unset(self::$registeredLoaders[$this->vendorDir]);
  33820. }
  33821. }
  33822. /**
  33823. * Loads the given class or interface.
  33824. *
  33825. * @param string $class The name of the class
  33826. * @return bool|null True if loaded, null otherwise
  33827. */
  33828. public function loadClass($class)
  33829. {
  33830. if ($file = $this->findFile($class)) {
  33831. includeFile($file);
  33832. return true;
  33833. }
  33834. }
  33835. /**
  33836. * Finds the path to the file where the class is defined.
  33837. *
  33838. * @param string $class The name of the class
  33839. *
  33840. * @return string|false The path if found, false otherwise
  33841. */
  33842. public function findFile($class)
  33843. {
  33844. // class map lookup
  33845. if (isset($this->classMap[$class])) {
  33846. return $this->classMap[$class];
  33847. }
  33848. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  33849. return false;
  33850. }
  33851. if (null !== $this->apcuPrefix) {
  33852. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  33853. if ($hit) {
  33854. return $file;
  33855. }
  33856. }
  33857. $file = $this->findFileWithExtension($class, '.php');
  33858. // Search for Hack files if we are running on HHVM
  33859. if (false === $file && defined('HHVM_VERSION')) {
  33860. $file = $this->findFileWithExtension($class, '.hh');
  33861. }
  33862. if (null !== $this->apcuPrefix) {
  33863. apcu_add($this->apcuPrefix.$class, $file);
  33864. }
  33865. if (false === $file) {
  33866. // Remember that this class does not exist.
  33867. $this->missingClasses[$class] = true;
  33868. }
  33869. return $file;
  33870. }
  33871. /**
  33872. * Returns the currently registered loaders indexed by their corresponding vendor directories.
  33873. *
  33874. * @return self[]
  33875. */
  33876. public static function getRegisteredLoaders()
  33877. {
  33878. return self::$registeredLoaders;
  33879. }
  33880. private function findFileWithExtension($class, $ext)
  33881. {
  33882. // PSR-4 lookup
  33883. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  33884. $first = $class[0];
  33885. if (isset($this->prefixLengthsPsr4[$first])) {
  33886. $subPath = $class;
  33887. while (false !== $lastPos = strrpos($subPath, '\\')) {
  33888. $subPath = substr($subPath, 0, $lastPos);
  33889. $search = $subPath . '\\';
  33890. if (isset($this->prefixDirsPsr4[$search])) {
  33891. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  33892. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  33893. if (file_exists($file = $dir . $pathEnd)) {
  33894. return $file;
  33895. }
  33896. }
  33897. }
  33898. }
  33899. }
  33900. // PSR-4 fallback dirs
  33901. foreach ($this->fallbackDirsPsr4 as $dir) {
  33902. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  33903. return $file;
  33904. }
  33905. }
  33906. // PSR-0 lookup
  33907. if (false !== $pos = strrpos($class, '\\')) {
  33908. // namespaced class name
  33909. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  33910. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  33911. } else {
  33912. // PEAR-like class name
  33913. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  33914. }
  33915. if (isset($this->prefixesPsr0[$first])) {
  33916. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  33917. if (0 === strpos($class, $prefix)) {
  33918. foreach ($dirs as $dir) {
  33919. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33920. return $file;
  33921. }
  33922. }
  33923. }
  33924. }
  33925. }
  33926. // PSR-0 fallback dirs
  33927. foreach ($this->fallbackDirsPsr0 as $dir) {
  33928. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33929. return $file;
  33930. }
  33931. }
  33932. // PSR-0 include paths.
  33933. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  33934. return $file;
  33935. }
  33936. return false;
  33937. }
  33938. }
  33939. /**
  33940. * Scope isolated include.
  33941. *
  33942. * Prevents access to $this/self from included files.
  33943. */
  33944. function includeFile($file)
  33945. {
  33946. include $file;
  33947. }
  33948. {
  33949. "$schema": "https://json-schema.org/draft-04/schema#",
  33950. "description": "A representation of packages metadata.",
  33951. "type": "object",
  33952. "oneOf": [
  33953. { "required": [ "packages" ] },
  33954. { "required": [ "providers" ] },
  33955. { "required": [ "provider-includes", "providers-url" ] }
  33956. ],
  33957. "properties": {
  33958. "packages": {
  33959. "type": ["object", "array"],
  33960. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33961. "additionalProperties": { "$ref": "#/definitions/versions" }
  33962. },
  33963. "providers-url": {
  33964. "type": "string",
  33965. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  33966. },
  33967. "provider-includes": {
  33968. "type": "object",
  33969. "description": "A hashmap of provider listings.",
  33970. "additionalProperties": { "$ref": "#/definitions/provider" }
  33971. },
  33972. "providers": {
  33973. "type": "object",
  33974. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33975. "additionalProperties": { "$ref": "#/definitions/provider" }
  33976. },
  33977. "notify-batch": {
  33978. "type": "string",
  33979. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  33980. },
  33981. "search": {
  33982. "type": "string",
  33983. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  33984. },
  33985. "warning": {
  33986. "type": "string",
  33987. "description": "A message that will be output by Composer as a warning when this source is consulted."
  33988. }
  33989. },
  33990. "definitions": {
  33991. "versions": {
  33992. "type": "object",
  33993. "description": "A hashmap of versions and their metadata.",
  33994. "additionalProperties": { "$ref": "#/definitions/version" }
  33995. },
  33996. "version": {
  33997. "type": "object",
  33998. "oneOf": [
  33999. { "$ref": "#/definitions/package" },
  34000. { "$ref": "#/definitions/metapackage" }
  34001. ]
  34002. },
  34003. "package-base": {
  34004. "properties": {
  34005. "name": { "type": "string" },
  34006. "type": { "type": "string" },
  34007. "version": { "type": "string" },
  34008. "version_normalized": {
  34009. "type": "string",
  34010. "description": "Normalized version, optional but can save computational time on client side."
  34011. },
  34012. "autoload": { "type": "object" },
  34013. "require": { "type": "object" },
  34014. "replace": { "type": "object" },
  34015. "conflict": { "type": "object" },
  34016. "provide": { "type": "object" },
  34017. "time": { "type": "string" }
  34018. },
  34019. "additionalProperties": true
  34020. },
  34021. "package": {
  34022. "allOf": [
  34023. { "$ref": "#/definitions/package-base" },
  34024. {
  34025. "properties": {
  34026. "dist": { "type": "object" },
  34027. "source": { "type": "object" }
  34028. }
  34029. },
  34030. { "oneOf": [
  34031. { "required": [ "name", "version", "source" ] },
  34032. { "required": [ "name", "version", "dist" ] }
  34033. ] }
  34034. ]
  34035. },
  34036. "metapackage": {
  34037. "allOf": [
  34038. { "$ref": "#/definitions/package-base" },
  34039. {
  34040. "properties": {
  34041. "type": { "type": "string", "enum": [ "metapackage" ] }
  34042. },
  34043. "required": [ "name", "version", "type" ]
  34044. }
  34045. ]
  34046. },
  34047. "provider": {
  34048. "type": "object",
  34049. "properties": {
  34050. "sha256": {
  34051. "type": "string",
  34052. "description": "Hash value that can be used to validate the resource."
  34053. }
  34054. }
  34055. }
  34056. }
  34057. }
  34058. {
  34059. "$schema": "https://json-schema.org/draft-04/schema#",
  34060. "name": "Package",
  34061. "type": "object",
  34062. "additionalProperties": false,
  34063. "required": [ "name", "description" ],
  34064. "properties": {
  34065. "name": {
  34066. "type": "string",
  34067. "description": "Package name, including 'vendor-name/' prefix.",
  34068. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  34069. },
  34070. "type": {
  34071. "description": "Package type, either 'library' for common packages, 'composer-plugin' for plugins, 'metapackage' for empty packages, or a custom type ([a-z0-9-]+) defined by whatever project this package applies to.",
  34072. "type": "string",
  34073. "pattern": "^[a-z0-9-]+$"
  34074. },
  34075. "target-dir": {
  34076. "description": "DEPRECATED: Forces the package to be installed into the given subdirectory path. This is used for autoloading PSR-0 packages that do not contain their full path. Use forward slashes for cross-platform compatibility.",
  34077. "type": "string"
  34078. },
  34079. "description": {
  34080. "type": "string",
  34081. "description": "Short package description."
  34082. },
  34083. "keywords": {
  34084. "type": "array",
  34085. "items": {
  34086. "type": "string",
  34087. "description": "A tag/keyword that this package relates to."
  34088. }
  34089. },
  34090. "homepage": {
  34091. "type": "string",
  34092. "description": "Homepage URL for the project.",
  34093. "format": "uri"
  34094. },
  34095. "readme": {
  34096. "type": "string",
  34097. "description": "Relative path to the readme document."
  34098. },
  34099. "version": {
  34100. "type": "string",
  34101. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  34102. "pattern": "^v?\\d+(((\\.\\d+)?\\.\\d+)?\\.\\d+)?|^dev-"
  34103. },
  34104. "time": {
  34105. "type": "string",
  34106. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  34107. },
  34108. "license": {
  34109. "type": ["string", "array"],
  34110. "description": "License name. Or an array of license names."
  34111. },
  34112. "authors": {
  34113. "$ref": "#/definitions/authors"
  34114. },
  34115. "require": {
  34116. "type": "object",
  34117. "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
  34118. "additionalProperties": {
  34119. "type": "string"
  34120. }
  34121. },
  34122. "replace": {
  34123. "type": "object",
  34124. "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
  34125. "additionalProperties": {
  34126. "type": "string"
  34127. }
  34128. },
  34129. "conflict": {
  34130. "type": "object",
  34131. "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
  34132. "additionalProperties": {
  34133. "type": "string"
  34134. }
  34135. },
  34136. "provide": {
  34137. "type": "object",
  34138. "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  34139. "additionalProperties": {
  34140. "type": "string"
  34141. }
  34142. },
  34143. "require-dev": {
  34144. "type": "object",
  34145. "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  34146. "additionalProperties": {
  34147. "type": "string"
  34148. }
  34149. },
  34150. "suggest": {
  34151. "type": "object",
  34152. "description": "This is a hash of package name (keys) and descriptions (values) that this package suggests work well with it (this will be suggested to the user during installation).",
  34153. "additionalProperties": {
  34154. "type": "string"
  34155. }
  34156. },
  34157. "config": {
  34158. "type": "object",
  34159. "description": "Composer options.",
  34160. "properties": {
  34161. "process-timeout": {
  34162. "type": "integer",
  34163. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  34164. },
  34165. "use-include-path": {
  34166. "type": "boolean",
  34167. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  34168. },
  34169. "preferred-install": {
  34170. "type": ["string", "object"],
  34171. "description": "The install method Composer will prefer to use, defaults to auto and can be any of source, dist, auto, or a hash of {\"pattern\": \"preference\"}."
  34172. },
  34173. "notify-on-install": {
  34174. "type": "boolean",
  34175. "description": "Composer allows repositories to define a notification URL, so that they get notified whenever a package from that repository is installed. This option allows you to disable that behaviour, defaults to true."
  34176. },
  34177. "github-protocols": {
  34178. "type": "array",
  34179. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  34180. "items": {
  34181. "type": "string"
  34182. }
  34183. },
  34184. "github-oauth": {
  34185. "type": "object",
  34186. "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  34187. "additionalProperties": {
  34188. "type": "string"
  34189. }
  34190. },
  34191. "gitlab-oauth": {
  34192. "type": "object",
  34193. "description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  34194. "additionalProperties": {
  34195. "type": "string"
  34196. }
  34197. },
  34198. "gitlab-token": {
  34199. "type": "object",
  34200. "description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  34201. "additionalProperties": {
  34202. "type": "string"
  34203. }
  34204. },
  34205. "bearer": {
  34206. "type": "object",
  34207. "description": "A hash of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  34208. "additionalProperties": {
  34209. "type": "string"
  34210. }
  34211. },
  34212. "disable-tls": {
  34213. "type": "boolean",
  34214. "description": "Defaults to `false`. If set to true all HTTPS URLs will be tried with HTTP instead and no network level encryption is performed. Enabling this is a security risk and is NOT recommended. The better way is to enable the php_openssl extension in php.ini."
  34215. },
  34216. "secure-http": {
  34217. "type": "boolean",
  34218. "description": "Defaults to `true`. If set to true only HTTPS URLs are allowed to be downloaded via Composer. If you really absolutely need HTTP access to something then you can disable it, but using \"Let's Encrypt\" to get a free SSL certificate is generally a better alternative."
  34219. },
  34220. "cafile": {
  34221. "type": "string",
  34222. "description": "A way to set the path to the openssl CA file. In PHP 5.6+ you should rather set this via openssl.cafile in php.ini, although PHP 5.6+ should be able to detect your system CA file automatically."
  34223. },
  34224. "capath": {
  34225. "type": "string",
  34226. "description": "If cafile is not specified or if the certificate is not found there, the directory pointed to by capath is searched for a suitable certificate. capath must be a correctly hashed certificate directory."
  34227. },
  34228. "http-basic": {
  34229. "type": "object",
  34230. "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  34231. "additionalProperties": {
  34232. "type": "object",
  34233. "required": ["username", "password"],
  34234. "properties": {
  34235. "username": {
  34236. "type": "string",
  34237. "description": "The username used for HTTP Basic authentication"
  34238. },
  34239. "password": {
  34240. "type": "string",
  34241. "description": "The password used for HTTP Basic authentication"
  34242. }
  34243. }
  34244. }
  34245. },
  34246. "store-auths": {
  34247. "type": ["string", "boolean"],
  34248. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  34249. },
  34250. "platform": {
  34251. "type": "object",
  34252. "description": "This is a hash of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  34253. "additionalProperties": {
  34254. "type": "string"
  34255. }
  34256. },
  34257. "vendor-dir": {
  34258. "type": "string",
  34259. "description": "The location where all packages are installed, defaults to \"vendor\"."
  34260. },
  34261. "bin-dir": {
  34262. "type": "string",
  34263. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  34264. },
  34265. "data-dir": {
  34266. "type": "string",
  34267. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  34268. },
  34269. "cache-dir": {
  34270. "type": "string",
  34271. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  34272. },
  34273. "cache-files-dir": {
  34274. "type": "string",
  34275. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  34276. },
  34277. "cache-repo-dir": {
  34278. "type": "string",
  34279. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  34280. },
  34281. "cache-vcs-dir": {
  34282. "type": "string",
  34283. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  34284. },
  34285. "cache-ttl": {
  34286. "type": "integer",
  34287. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  34288. },
  34289. "cache-files-ttl": {
  34290. "type": "integer",
  34291. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  34292. },
  34293. "cache-files-maxsize": {
  34294. "type": ["string", "integer"],
  34295. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  34296. },
  34297. "cache-read-only": {
  34298. "type": ["boolean"],
  34299. "description": "Whether to use the Composer cache in read-only mode."
  34300. },
  34301. "bin-compat": {
  34302. "enum": ["auto", "full"],
  34303. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)."
  34304. },
  34305. "discard-changes": {
  34306. "type": ["string", "boolean"],
  34307. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  34308. },
  34309. "autoloader-suffix": {
  34310. "type": "string",
  34311. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  34312. },
  34313. "optimize-autoloader": {
  34314. "type": "boolean",
  34315. "description": "Always optimize when dumping the autoloader."
  34316. },
  34317. "prepend-autoloader": {
  34318. "type": "boolean",
  34319. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  34320. },
  34321. "classmap-authoritative": {
  34322. "type": "boolean",
  34323. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  34324. },
  34325. "apcu-autoloader": {
  34326. "type": "boolean",
  34327. "description": "If true, the Composer autoloader will check for APCu and use it to cache found/not-found classes when the extension is enabled, defaults to false."
  34328. },
  34329. "github-domains": {
  34330. "type": "array",
  34331. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  34332. "items": {
  34333. "type": "string"
  34334. }
  34335. },
  34336. "github-expose-hostname": {
  34337. "type": "boolean",
  34338. "description": "Defaults to true. If set to false, the OAuth tokens created to access the github API will have a date instead of the machine hostname."
  34339. },
  34340. "gitlab-domains": {
  34341. "type": "array",
  34342. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  34343. "items": {
  34344. "type": "string"
  34345. }
  34346. },
  34347. "use-github-api": {
  34348. "type": "boolean",
  34349. "description": "Defaults to true. If set to false, globally disables the use of the GitHub API for all GitHub repositories and clones the repository as it would for any other repository."
  34350. },
  34351. "archive-format": {
  34352. "type": "string",
  34353. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  34354. },
  34355. "archive-dir": {
  34356. "type": "string",
  34357. "description": "The default archive path when not provided on cli, defaults to \".\"."
  34358. },
  34359. "htaccess-protect": {
  34360. "type": "boolean",
  34361. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  34362. },
  34363. "sort-packages": {
  34364. "type": "boolean",
  34365. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  34366. },
  34367. "lock": {
  34368. "type": "boolean",
  34369. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  34370. },
  34371. "platform-check": {
  34372. "type": ["boolean", "string"],
  34373. "description": "Defaults to \"php-only\" which checks only the PHP version. Setting to true will also check the presence of required PHP extensions. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
  34374. }
  34375. }
  34376. },
  34377. "extra": {
  34378. "type": ["object", "array"],
  34379. "description": "Arbitrary extra data that can be used by plugins, for example, package of type composer-plugin may have a 'class' key defining an installer class name.",
  34380. "additionalProperties": true
  34381. },
  34382. "autoload": {
  34383. "$ref": "#/definitions/autoload"
  34384. },
  34385. "autoload-dev": {
  34386. "type": "object",
  34387. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  34388. "properties": {
  34389. "psr-0": {
  34390. "type": "object",
  34391. "description": "This is a hash of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
  34392. "additionalProperties": {
  34393. "type": ["string", "array"],
  34394. "items": {
  34395. "type": "string"
  34396. }
  34397. }
  34398. },
  34399. "psr-4": {
  34400. "type": "object",
  34401. "description": "This is a hash of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  34402. "additionalProperties": {
  34403. "type": ["string", "array"],
  34404. "items": {
  34405. "type": "string"
  34406. }
  34407. }
  34408. },
  34409. "classmap": {
  34410. "type": "array",
  34411. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34412. },
  34413. "files": {
  34414. "type": "array",
  34415. "description": "This is an array of files that are always required on every request."
  34416. }
  34417. }
  34418. },
  34419. "archive": {
  34420. "type": ["object"],
  34421. "description": "Options for creating package archives for distribution.",
  34422. "properties": {
  34423. "name": {
  34424. "type": "string",
  34425. "description": "A base name for archive."
  34426. },
  34427. "exclude": {
  34428. "type": "array",
  34429. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  34430. }
  34431. }
  34432. },
  34433. "repositories": {
  34434. "type": ["object", "array"],
  34435. "description": "A set of additional repositories where packages can be found.",
  34436. "additionalProperties": {
  34437. "anyOf": [
  34438. { "$ref": "#/definitions/repository" },
  34439. { "type": "boolean", "enum": [false] }
  34440. ]
  34441. },
  34442. "items": {
  34443. "anyOf": [
  34444. { "$ref": "#/definitions/repository" },
  34445. {
  34446. "type": "object",
  34447. "additionalProperties": { "type": "boolean", "enum": [false] },
  34448. "minProperties": 1,
  34449. "maxProperties": 1
  34450. }
  34451. ]
  34452. }
  34453. },
  34454. "minimum-stability": {
  34455. "type": ["string"],
  34456. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  34457. "pattern": "^dev|alpha|beta|rc|RC|stable$"
  34458. },
  34459. "prefer-stable": {
  34460. "type": ["boolean"],
  34461. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  34462. },
  34463. "bin": {
  34464. "type": ["string", "array"],
  34465. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34466. "items": {
  34467. "type": "string"
  34468. }
  34469. },
  34470. "include-path": {
  34471. "type": ["array"],
  34472. "description": "DEPRECATED: A list of directories which should get added to PHP's include path. This is only present to support legacy projects, and all new code should preferably use autoloading.",
  34473. "items": {
  34474. "type": "string"
  34475. }
  34476. },
  34477. "scripts": {
  34478. "type": ["object"],
  34479. "description": "Script listeners that will be executed before/after some events.",
  34480. "properties": {
  34481. "pre-install-cmd": {
  34482. "type": ["array", "string"],
  34483. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  34484. },
  34485. "post-install-cmd": {
  34486. "type": ["array", "string"],
  34487. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  34488. },
  34489. "pre-update-cmd": {
  34490. "type": ["array", "string"],
  34491. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  34492. },
  34493. "post-update-cmd": {
  34494. "type": ["array", "string"],
  34495. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  34496. },
  34497. "pre-status-cmd": {
  34498. "type": ["array", "string"],
  34499. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  34500. },
  34501. "post-status-cmd": {
  34502. "type": ["array", "string"],
  34503. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  34504. },
  34505. "pre-package-install": {
  34506. "type": ["array", "string"],
  34507. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  34508. },
  34509. "post-package-install": {
  34510. "type": ["array", "string"],
  34511. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  34512. },
  34513. "pre-package-update": {
  34514. "type": ["array", "string"],
  34515. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  34516. },
  34517. "post-package-update": {
  34518. "type": ["array", "string"],
  34519. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  34520. },
  34521. "pre-package-uninstall": {
  34522. "type": ["array", "string"],
  34523. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34524. },
  34525. "post-package-uninstall": {
  34526. "type": ["array", "string"],
  34527. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34528. },
  34529. "pre-autoload-dump": {
  34530. "type": ["array", "string"],
  34531. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34532. },
  34533. "post-autoload-dump": {
  34534. "type": ["array", "string"],
  34535. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34536. },
  34537. "post-root-package-install": {
  34538. "type": ["array", "string"],
  34539. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  34540. },
  34541. "post-create-project-cmd": {
  34542. "type": ["array", "string"],
  34543. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  34544. }
  34545. }
  34546. },
  34547. "scripts-descriptions": {
  34548. "type": ["object"],
  34549. "description": "Descriptions for custom commands, shown in console help.",
  34550. "additionalProperties": {
  34551. "type": "string"
  34552. }
  34553. },
  34554. "support": {
  34555. "type": "object",
  34556. "properties": {
  34557. "email": {
  34558. "type": "string",
  34559. "description": "Email address for support.",
  34560. "format": "email"
  34561. },
  34562. "issues": {
  34563. "type": "string",
  34564. "description": "URL to the issue tracker.",
  34565. "format": "uri"
  34566. },
  34567. "forum": {
  34568. "type": "string",
  34569. "description": "URL to the forum.",
  34570. "format": "uri"
  34571. },
  34572. "wiki": {
  34573. "type": "string",
  34574. "description": "URL to the wiki.",
  34575. "format": "uri"
  34576. },
  34577. "irc": {
  34578. "type": "string",
  34579. "description": "IRC channel for support, as irc://server/channel.",
  34580. "format": "uri"
  34581. },
  34582. "chat": {
  34583. "type": "string",
  34584. "description": "URL to the support chat.",
  34585. "format": "uri"
  34586. },
  34587. "source": {
  34588. "type": "string",
  34589. "description": "URL to browse or download the sources.",
  34590. "format": "uri"
  34591. },
  34592. "docs": {
  34593. "type": "string",
  34594. "description": "URL to the documentation.",
  34595. "format": "uri"
  34596. },
  34597. "rss": {
  34598. "type": "string",
  34599. "description": "URL to the RSS feed.",
  34600. "format": "uri"
  34601. }
  34602. }
  34603. },
  34604. "funding": {
  34605. "type": "array",
  34606. "description": "A list of options to fund the development and maintenance of the package.",
  34607. "items": {
  34608. "type": "object",
  34609. "properties": {
  34610. "type": {
  34611. "type": "string",
  34612. "description": "Type of funding or platform through which funding is possible."
  34613. },
  34614. "url": {
  34615. "type": "string",
  34616. "description": "URL to a website with details on funding and a way to fund the package.",
  34617. "format": "uri"
  34618. }
  34619. }
  34620. }
  34621. },
  34622. "non-feature-branches": {
  34623. "type": ["array"],
  34624. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  34625. "items": {
  34626. "type": "string"
  34627. }
  34628. },
  34629. "default-branch": {
  34630. "type": ["boolean"],
  34631. "description": "Internal use only, do not specify this in composer.json. Indicates whether this version is the default branch of the linked VCS repository. Defaults to false."
  34632. },
  34633. "abandoned": {
  34634. "type": ["boolean", "string"],
  34635. "description": "Indicates whether this package has been abandoned, it can be boolean or a package name/URL pointing to a recommended alternative. Defaults to false."
  34636. },
  34637. "_comment": {
  34638. "type": ["array", "string"],
  34639. "description": "A key to store comments in"
  34640. }
  34641. },
  34642. "definitions": {
  34643. "authors": {
  34644. "type": "array",
  34645. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  34646. "items": {
  34647. "type": "object",
  34648. "additionalProperties": false,
  34649. "required": [ "name"],
  34650. "properties": {
  34651. "name": {
  34652. "type": "string",
  34653. "description": "Full name of the author."
  34654. },
  34655. "email": {
  34656. "type": "string",
  34657. "description": "Email address of the author.",
  34658. "format": "email"
  34659. },
  34660. "homepage": {
  34661. "type": "string",
  34662. "description": "Homepage URL for the author.",
  34663. "format": "uri"
  34664. },
  34665. "role": {
  34666. "type": "string",
  34667. "description": "Author's role in the project."
  34668. }
  34669. }
  34670. }
  34671. },
  34672. "autoload": {
  34673. "type": "object",
  34674. "description": "Description of how the package can be autoloaded.",
  34675. "properties": {
  34676. "psr-0": {
  34677. "type": "object",
  34678. "description": "This is a hash of namespaces (keys) and the directories they can be found in (values, can be arrays of paths) by the autoloader.",
  34679. "additionalProperties": {
  34680. "type": ["string", "array"],
  34681. "items": {
  34682. "type": "string"
  34683. }
  34684. }
  34685. },
  34686. "psr-4": {
  34687. "type": "object",
  34688. "description": "This is a hash of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  34689. "additionalProperties": {
  34690. "type": ["string", "array"],
  34691. "items": {
  34692. "type": "string"
  34693. }
  34694. }
  34695. },
  34696. "classmap": {
  34697. "type": "array",
  34698. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34699. },
  34700. "files": {
  34701. "type": "array",
  34702. "description": "This is an array of files that are always required on every request."
  34703. },
  34704. "exclude-from-classmap": {
  34705. "type": "array",
  34706. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  34707. }
  34708. }
  34709. },
  34710. "repository": {
  34711. "type": "object",
  34712. "anyOf": [
  34713. { "$ref": "#/definitions/composer-repository" },
  34714. { "$ref": "#/definitions/vcs-repository" },
  34715. { "$ref": "#/definitions/path-repository" },
  34716. { "$ref": "#/definitions/artifact-repository" },
  34717. { "$ref": "#/definitions/pear-repository" },
  34718. { "$ref": "#/definitions/package-repository" }
  34719. ]
  34720. },
  34721. "composer-repository": {
  34722. "type": "object",
  34723. "required": ["type", "url"],
  34724. "properties": {
  34725. "type": { "type": "string", "enum": ["composer"] },
  34726. "url": { "type": "string" },
  34727. "canonical": { "type": "boolean" },
  34728. "only": {
  34729. "type": "array",
  34730. "items": {
  34731. "type": "string"
  34732. }
  34733. },
  34734. "exclude": {
  34735. "type": "array",
  34736. "items": {
  34737. "type": "string"
  34738. }
  34739. },
  34740. "options": {
  34741. "type": "object",
  34742. "additionalProperties": true
  34743. },
  34744. "allow_ssl_downgrade": { "type": "boolean" },
  34745. "force-lazy-providers": { "type": "boolean" }
  34746. }
  34747. },
  34748. "vcs-repository": {
  34749. "type": "object",
  34750. "required": ["type", "url"],
  34751. "properties": {
  34752. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] },
  34753. "url": { "type": "string" },
  34754. "canonical": { "type": "boolean" },
  34755. "only": {
  34756. "type": "array",
  34757. "items": {
  34758. "type": "string"
  34759. }
  34760. },
  34761. "exclude": {
  34762. "type": "array",
  34763. "items": {
  34764. "type": "string"
  34765. }
  34766. },
  34767. "no-api": { "type": "boolean" },
  34768. "secure-http": { "type": "boolean" },
  34769. "svn-cache-credentials": { "type": "boolean" },
  34770. "trunk-path": { "type": ["string", "boolean"] },
  34771. "branches-path": { "type": ["string", "boolean"] },
  34772. "tags-path": { "type": ["string", "boolean"] },
  34773. "package-path": { "type": "string" },
  34774. "depot": { "type": "string" },
  34775. "branch": { "type": "string" },
  34776. "unique_perforce_client_name": { "type": "string" },
  34777. "p4user": { "type": "string" },
  34778. "p4password": { "type": "string" }
  34779. }
  34780. },
  34781. "path-repository": {
  34782. "type": "object",
  34783. "required": ["type", "url"],
  34784. "properties": {
  34785. "type": { "type": "string", "enum": ["path"] },
  34786. "url": { "type": "string" },
  34787. "canonical": { "type": "boolean" },
  34788. "only": {
  34789. "type": "array",
  34790. "items": {
  34791. "type": "string"
  34792. }
  34793. },
  34794. "exclude": {
  34795. "type": "array",
  34796. "items": {
  34797. "type": "string"
  34798. }
  34799. },
  34800. "options": {
  34801. "type": "object",
  34802. "properties": {
  34803. "symlink": { "type": ["boolean", "null"] }
  34804. },
  34805. "additionalProperties": true
  34806. }
  34807. }
  34808. },
  34809. "artifact-repository": {
  34810. "type": "object",
  34811. "required": ["type", "url"],
  34812. "properties": {
  34813. "type": { "type": "string", "enum": ["artifact"] },
  34814. "url": { "type": "string" },
  34815. "canonical": { "type": "boolean" },
  34816. "only": {
  34817. "type": "array",
  34818. "items": {
  34819. "type": "string"
  34820. }
  34821. },
  34822. "exclude": {
  34823. "type": "array",
  34824. "items": {
  34825. "type": "string"
  34826. }
  34827. }
  34828. }
  34829. },
  34830. "pear-repository": {
  34831. "type": "object",
  34832. "required": ["type", "url"],
  34833. "properties": {
  34834. "type": { "type": "string", "enum": ["pear"] },
  34835. "url": { "type": "string" },
  34836. "canonical": { "type": "boolean" },
  34837. "only": {
  34838. "type": "array",
  34839. "items": {
  34840. "type": "string"
  34841. }
  34842. },
  34843. "exclude": {
  34844. "type": "array",
  34845. "items": {
  34846. "type": "string"
  34847. }
  34848. },
  34849. "vendor-alias": { "type": "string" }
  34850. }
  34851. },
  34852. "package-repository": {
  34853. "type": "object",
  34854. "required": ["type", "package"],
  34855. "properties": {
  34856. "type": { "type": "string", "enum": ["package"] },
  34857. "canonical": { "type": "boolean" },
  34858. "only": {
  34859. "type": "array",
  34860. "items": {
  34861. "type": "string"
  34862. }
  34863. },
  34864. "exclude": {
  34865. "type": "array",
  34866. "items": {
  34867. "type": "string"
  34868. }
  34869. },
  34870. "package": {
  34871. "oneOf": [
  34872. { "$ref": "#/definitions/inline-package" },
  34873. {
  34874. "type": "array",
  34875. "items": { "$ref": "#/definitions/inline-package" }
  34876. }
  34877. ]
  34878. }
  34879. }
  34880. },
  34881. "inline-package": {
  34882. "type": "object",
  34883. "required": ["name", "version"],
  34884. "properties": {
  34885. "name": {
  34886. "type": "string",
  34887. "description": "Package name, including 'vendor-name/' prefix."
  34888. },
  34889. "type": {
  34890. "type": "string"
  34891. },
  34892. "target-dir": {
  34893. "description": "DEPRECATED: Forces the package to be installed into the given subdirectory path. This is used for autoloading PSR-0 packages that do not contain their full path. Use forward slashes for cross-platform compatibility.",
  34894. "type": "string"
  34895. },
  34896. "description": {
  34897. "type": "string"
  34898. },
  34899. "keywords": {
  34900. "type": "array",
  34901. "items": {
  34902. "type": "string"
  34903. }
  34904. },
  34905. "homepage": {
  34906. "type": "string",
  34907. "format": "uri"
  34908. },
  34909. "version": {
  34910. "type": "string"
  34911. },
  34912. "time": {
  34913. "type": "string"
  34914. },
  34915. "license": {
  34916. "type": [
  34917. "string",
  34918. "array"
  34919. ]
  34920. },
  34921. "authors": {
  34922. "$ref": "#/definitions/authors"
  34923. },
  34924. "require": {
  34925. "type": "object",
  34926. "additionalProperties": {
  34927. "type": "string"
  34928. }
  34929. },
  34930. "replace": {
  34931. "type": "object",
  34932. "additionalProperties": {
  34933. "type": "string"
  34934. }
  34935. },
  34936. "conflict": {
  34937. "type": "object",
  34938. "additionalProperties": {
  34939. "type": "string"
  34940. }
  34941. },
  34942. "provide": {
  34943. "type": "object",
  34944. "additionalProperties": {
  34945. "type": "string"
  34946. }
  34947. },
  34948. "require-dev": {
  34949. "type": "object",
  34950. "additionalProperties": {
  34951. "type": "string"
  34952. }
  34953. },
  34954. "suggest": {
  34955. "type": "object",
  34956. "additionalProperties": {
  34957. "type": "string"
  34958. }
  34959. },
  34960. "extra": {
  34961. "type": ["object", "array"],
  34962. "additionalProperties": true
  34963. },
  34964. "autoload": {
  34965. "$ref": "#/definitions/autoload"
  34966. },
  34967. "archive": {
  34968. "type": ["object"],
  34969. "properties": {
  34970. "exclude": {
  34971. "type": "array"
  34972. }
  34973. }
  34974. },
  34975. "bin": {
  34976. "type": ["string", "array"],
  34977. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34978. "items": {
  34979. "type": "string"
  34980. }
  34981. },
  34982. "include-path": {
  34983. "type": ["array"],
  34984. "description": "DEPRECATED: A list of directories which should get added to PHP's include path. This is only present to support legacy projects, and all new code should preferably use autoloading.",
  34985. "items": {
  34986. "type": "string"
  34987. }
  34988. },
  34989. "source": {
  34990. "type": "object",
  34991. "required": ["type", "url", "reference"],
  34992. "properties": {
  34993. "type": {
  34994. "type": "string"
  34995. },
  34996. "url": {
  34997. "type": "string"
  34998. },
  34999. "reference": {
  35000. "type": "string"
  35001. },
  35002. "mirrors": {
  35003. "type": "array"
  35004. }
  35005. }
  35006. },
  35007. "dist": {
  35008. "type": "object",
  35009. "required": ["type", "url"],
  35010. "properties": {
  35011. "type": {
  35012. "type": "string"
  35013. },
  35014. "url": {
  35015. "type": "string"
  35016. },
  35017. "reference": {
  35018. "type": "string"
  35019. },
  35020. "shasum": {
  35021. "type": "string"
  35022. },
  35023. "mirrors": {
  35024. "type": "array"
  35025. }
  35026. }
  35027. }
  35028. },
  35029. "additionalProperties": true
  35030. }
  35031. }
  35032. }
  35033. <?php
  35034. require_once __DIR__ . '/composer/autoload_real.php';
  35035. return ComposerAutoloaderInitComposerPhar1617264899::getLoader();
  35036. <?php
  35037. namespace Composer\Autoload;
  35038. class ClassLoader
  35039. {
  35040. private $vendorDir;
  35041. private $prefixLengthsPsr4 = array();
  35042. private $prefixDirsPsr4 = array();
  35043. private $fallbackDirsPsr4 = array();
  35044. private $prefixesPsr0 = array();
  35045. private $fallbackDirsPsr0 = array();
  35046. private $useIncludePath = false;
  35047. private $classMap = array();
  35048. private $classMapAuthoritative = false;
  35049. private $missingClasses = array();
  35050. private $apcuPrefix;
  35051. private static $registeredLoaders = array();
  35052. public function __construct($vendorDir = null)
  35053. {
  35054. $this->vendorDir = $vendorDir;
  35055. }
  35056. public function getPrefixes()
  35057. {
  35058. if (!empty($this->prefixesPsr0)) {
  35059. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  35060. }
  35061. return array();
  35062. }
  35063. public function getPrefixesPsr4()
  35064. {
  35065. return $this->prefixDirsPsr4;
  35066. }
  35067. public function getFallbackDirs()
  35068. {
  35069. return $this->fallbackDirsPsr0;
  35070. }
  35071. public function getFallbackDirsPsr4()
  35072. {
  35073. return $this->fallbackDirsPsr4;
  35074. }
  35075. public function getClassMap()
  35076. {
  35077. return $this->classMap;
  35078. }
  35079. public function addClassMap(array $classMap)
  35080. {
  35081. if ($this->classMap) {
  35082. $this->classMap = array_merge($this->classMap, $classMap);
  35083. } else {
  35084. $this->classMap = $classMap;
  35085. }
  35086. }
  35087. public function add($prefix, $paths, $prepend = false)
  35088. {
  35089. if (!$prefix) {
  35090. if ($prepend) {
  35091. $this->fallbackDirsPsr0 = array_merge(
  35092. (array) $paths,
  35093. $this->fallbackDirsPsr0
  35094. );
  35095. } else {
  35096. $this->fallbackDirsPsr0 = array_merge(
  35097. $this->fallbackDirsPsr0,
  35098. (array) $paths
  35099. );
  35100. }
  35101. return;
  35102. }
  35103. $first = $prefix[0];
  35104. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  35105. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  35106. return;
  35107. }
  35108. if ($prepend) {
  35109. $this->prefixesPsr0[$first][$prefix] = array_merge(
  35110. (array) $paths,
  35111. $this->prefixesPsr0[$first][$prefix]
  35112. );
  35113. } else {
  35114. $this->prefixesPsr0[$first][$prefix] = array_merge(
  35115. $this->prefixesPsr0[$first][$prefix],
  35116. (array) $paths
  35117. );
  35118. }
  35119. }
  35120. public function addPsr4($prefix, $paths, $prepend = false)
  35121. {
  35122. if (!$prefix) {
  35123. if ($prepend) {
  35124. $this->fallbackDirsPsr4 = array_merge(
  35125. (array) $paths,
  35126. $this->fallbackDirsPsr4
  35127. );
  35128. } else {
  35129. $this->fallbackDirsPsr4 = array_merge(
  35130. $this->fallbackDirsPsr4,
  35131. (array) $paths
  35132. );
  35133. }
  35134. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  35135. $length = strlen($prefix);
  35136. if ('\\' !== $prefix[$length - 1]) {
  35137. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  35138. }
  35139. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  35140. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  35141. } elseif ($prepend) {
  35142. $this->prefixDirsPsr4[$prefix] = array_merge(
  35143. (array) $paths,
  35144. $this->prefixDirsPsr4[$prefix]
  35145. );
  35146. } else {
  35147. $this->prefixDirsPsr4[$prefix] = array_merge(
  35148. $this->prefixDirsPsr4[$prefix],
  35149. (array) $paths
  35150. );
  35151. }
  35152. }
  35153. public function set($prefix, $paths)
  35154. {
  35155. if (!$prefix) {
  35156. $this->fallbackDirsPsr0 = (array) $paths;
  35157. } else {
  35158. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  35159. }
  35160. }
  35161. public function setPsr4($prefix, $paths)
  35162. {
  35163. if (!$prefix) {
  35164. $this->fallbackDirsPsr4 = (array) $paths;
  35165. } else {
  35166. $length = strlen($prefix);
  35167. if ('\\' !== $prefix[$length - 1]) {
  35168. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  35169. }
  35170. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  35171. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  35172. }
  35173. }
  35174. public function setUseIncludePath($useIncludePath)
  35175. {
  35176. $this->useIncludePath = $useIncludePath;
  35177. }
  35178. public function getUseIncludePath()
  35179. {
  35180. return $this->useIncludePath;
  35181. }
  35182. public function setClassMapAuthoritative($classMapAuthoritative)
  35183. {
  35184. $this->classMapAuthoritative = $classMapAuthoritative;
  35185. }
  35186. public function isClassMapAuthoritative()
  35187. {
  35188. return $this->classMapAuthoritative;
  35189. }
  35190. public function setApcuPrefix($apcuPrefix)
  35191. {
  35192. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  35193. }
  35194. public function getApcuPrefix()
  35195. {
  35196. return $this->apcuPrefix;
  35197. }
  35198. public function register($prepend = false)
  35199. {
  35200. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  35201. if (null === $this->vendorDir) {
  35202. return;
  35203. }
  35204. if ($prepend) {
  35205. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  35206. } else {
  35207. unset(self::$registeredLoaders[$this->vendorDir]);
  35208. self::$registeredLoaders[$this->vendorDir] = $this;
  35209. }
  35210. }
  35211. public function unregister()
  35212. {
  35213. spl_autoload_unregister(array($this, 'loadClass'));
  35214. if (null !== $this->vendorDir) {
  35215. unset(self::$registeredLoaders[$this->vendorDir]);
  35216. }
  35217. }
  35218. public function loadClass($class)
  35219. {
  35220. if ($file = $this->findFile($class)) {
  35221. includeFile($file);
  35222. return true;
  35223. }
  35224. }
  35225. public function findFile($class)
  35226. {
  35227. if (isset($this->classMap[$class])) {
  35228. return $this->classMap[$class];
  35229. }
  35230. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  35231. return false;
  35232. }
  35233. if (null !== $this->apcuPrefix) {
  35234. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  35235. if ($hit) {
  35236. return $file;
  35237. }
  35238. }
  35239. $file = $this->findFileWithExtension($class, '.php');
  35240. if (false === $file && defined('HHVM_VERSION')) {
  35241. $file = $this->findFileWithExtension($class, '.hh');
  35242. }
  35243. if (null !== $this->apcuPrefix) {
  35244. apcu_add($this->apcuPrefix.$class, $file);
  35245. }
  35246. if (false === $file) {
  35247. $this->missingClasses[$class] = true;
  35248. }
  35249. return $file;
  35250. }
  35251. public static function getRegisteredLoaders()
  35252. {
  35253. return self::$registeredLoaders;
  35254. }
  35255. private function findFileWithExtension($class, $ext)
  35256. {
  35257. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  35258. $first = $class[0];
  35259. if (isset($this->prefixLengthsPsr4[$first])) {
  35260. $subPath = $class;
  35261. while (false !== $lastPos = strrpos($subPath, '\\')) {
  35262. $subPath = substr($subPath, 0, $lastPos);
  35263. $search = $subPath . '\\';
  35264. if (isset($this->prefixDirsPsr4[$search])) {
  35265. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  35266. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  35267. if (file_exists($file = $dir . $pathEnd)) {
  35268. return $file;
  35269. }
  35270. }
  35271. }
  35272. }
  35273. }
  35274. foreach ($this->fallbackDirsPsr4 as $dir) {
  35275. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  35276. return $file;
  35277. }
  35278. }
  35279. if (false !== $pos = strrpos($class, '\\')) {
  35280. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  35281. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  35282. } else {
  35283. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  35284. }
  35285. if (isset($this->prefixesPsr0[$first])) {
  35286. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  35287. if (0 === strpos($class, $prefix)) {
  35288. foreach ($dirs as $dir) {
  35289. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35290. return $file;
  35291. }
  35292. }
  35293. }
  35294. }
  35295. }
  35296. foreach ($this->fallbackDirsPsr0 as $dir) {
  35297. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35298. return $file;
  35299. }
  35300. }
  35301. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  35302. return $file;
  35303. }
  35304. return false;
  35305. }
  35306. }
  35307. function includeFile($file)
  35308. {
  35309. include $file;
  35310. }
  35311. <?php
  35312. namespace Composer;
  35313. use Composer\Autoload\ClassLoader;
  35314. use Composer\Semver\VersionParser;
  35315. class InstalledVersions
  35316. {
  35317. private static $installed = array (
  35318. 'root' =>
  35319. array (
  35320. 'pretty_version' => '2.0.12',
  35321. 'version' => '2.0.12.0',
  35322. 'aliases' =>
  35323. array (
  35324. ),
  35325. 'reference' => '6c12ce263da71641903e399c3ce8ecb08fd375fb',
  35326. 'name' => 'composer/composer',
  35327. ),
  35328. 'versions' =>
  35329. array (
  35330. 'composer/ca-bundle' =>
  35331. array (
  35332. 'pretty_version' => '1.2.9',
  35333. 'version' => '1.2.9.0',
  35334. 'aliases' =>
  35335. array (
  35336. ),
  35337. 'reference' => '78a0e288fdcebf92aa2318a8d3656168da6ac1a5',
  35338. ),
  35339. 'composer/composer' =>
  35340. array (
  35341. 'pretty_version' => '2.0.12',
  35342. 'version' => '2.0.12.0',
  35343. 'aliases' =>
  35344. array (
  35345. ),
  35346. 'reference' => '6c12ce263da71641903e399c3ce8ecb08fd375fb',
  35347. ),
  35348. 'composer/semver' =>
  35349. array (
  35350. 'pretty_version' => '3.2.4',
  35351. 'version' => '3.2.4.0',
  35352. 'aliases' =>
  35353. array (
  35354. ),
  35355. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  35356. ),
  35357. 'composer/spdx-licenses' =>
  35358. array (
  35359. 'pretty_version' => '1.5.5',
  35360. 'version' => '1.5.5.0',
  35361. 'aliases' =>
  35362. array (
  35363. ),
  35364. 'reference' => 'de30328a7af8680efdc03e396aad24befd513200',
  35365. ),
  35366. 'composer/xdebug-handler' =>
  35367. array (
  35368. 'pretty_version' => '1.4.5',
  35369. 'version' => '1.4.5.0',
  35370. 'aliases' =>
  35371. array (
  35372. ),
  35373. 'reference' => 'f28d44c286812c714741478d968104c5e604a1d4',
  35374. ),
  35375. 'justinrainbow/json-schema' =>
  35376. array (
  35377. 'pretty_version' => '5.2.10',
  35378. 'version' => '5.2.10.0',
  35379. 'aliases' =>
  35380. array (
  35381. ),
  35382. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  35383. ),
  35384. 'psr/log' =>
  35385. array (
  35386. 'pretty_version' => '1.1.3',
  35387. 'version' => '1.1.3.0',
  35388. 'aliases' =>
  35389. array (
  35390. ),
  35391. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  35392. ),
  35393. 'react/promise' =>
  35394. array (
  35395. 'pretty_version' => 'v1.2.1',
  35396. 'version' => '1.2.1.0',
  35397. 'aliases' =>
  35398. array (
  35399. ),
  35400. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  35401. ),
  35402. 'seld/jsonlint' =>
  35403. array (
  35404. 'pretty_version' => '1.8.3',
  35405. 'version' => '1.8.3.0',
  35406. 'aliases' =>
  35407. array (
  35408. ),
  35409. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  35410. ),
  35411. 'seld/phar-utils' =>
  35412. array (
  35413. 'pretty_version' => '1.1.1',
  35414. 'version' => '1.1.1.0',
  35415. 'aliases' =>
  35416. array (
  35417. ),
  35418. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  35419. ),
  35420. 'symfony/console' =>
  35421. array (
  35422. 'pretty_version' => 'v2.8.52',
  35423. 'version' => '2.8.52.0',
  35424. 'aliases' =>
  35425. array (
  35426. ),
  35427. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  35428. ),
  35429. 'symfony/debug' =>
  35430. array (
  35431. 'pretty_version' => 'v2.8.52',
  35432. 'version' => '2.8.52.0',
  35433. 'aliases' =>
  35434. array (
  35435. ),
  35436. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  35437. ),
  35438. 'symfony/filesystem' =>
  35439. array (
  35440. 'pretty_version' => 'v2.8.52',
  35441. 'version' => '2.8.52.0',
  35442. 'aliases' =>
  35443. array (
  35444. ),
  35445. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  35446. ),
  35447. 'symfony/finder' =>
  35448. array (
  35449. 'pretty_version' => 'v2.8.52',
  35450. 'version' => '2.8.52.0',
  35451. 'aliases' =>
  35452. array (
  35453. ),
  35454. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  35455. ),
  35456. 'symfony/polyfill-ctype' =>
  35457. array (
  35458. 'pretty_version' => 'v1.19.0',
  35459. 'version' => '1.19.0.0',
  35460. 'aliases' =>
  35461. array (
  35462. ),
  35463. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  35464. ),
  35465. 'symfony/polyfill-mbstring' =>
  35466. array (
  35467. 'pretty_version' => 'v1.19.0',
  35468. 'version' => '1.19.0.0',
  35469. 'aliases' =>
  35470. array (
  35471. ),
  35472. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  35473. ),
  35474. 'symfony/process' =>
  35475. array (
  35476. 'pretty_version' => 'v2.8.52',
  35477. 'version' => '2.8.52.0',
  35478. 'aliases' =>
  35479. array (
  35480. ),
  35481. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  35482. ),
  35483. ),
  35484. );
  35485. private static $canGetVendors;
  35486. private static $installedByVendor = array();
  35487. public static function getInstalledPackages()
  35488. {
  35489. $packages = array();
  35490. foreach (self::getInstalled() as $installed) {
  35491. $packages[] = array_keys($installed['versions']);
  35492. }
  35493. if (1 === \count($packages)) {
  35494. return $packages[0];
  35495. }
  35496. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  35497. }
  35498. public static function isInstalled($packageName)
  35499. {
  35500. foreach (self::getInstalled() as $installed) {
  35501. if (isset($installed['versions'][$packageName])) {
  35502. return true;
  35503. }
  35504. }
  35505. return false;
  35506. }
  35507. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  35508. {
  35509. $constraint = $parser->parseConstraints($constraint);
  35510. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  35511. return $provided->matches($constraint);
  35512. }
  35513. public static function getVersionRanges($packageName)
  35514. {
  35515. foreach (self::getInstalled() as $installed) {
  35516. if (!isset($installed['versions'][$packageName])) {
  35517. continue;
  35518. }
  35519. $ranges = array();
  35520. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  35521. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  35522. }
  35523. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  35524. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  35525. }
  35526. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  35527. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  35528. }
  35529. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  35530. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  35531. }
  35532. return implode(' || ', $ranges);
  35533. }
  35534. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35535. }
  35536. public static function getVersion($packageName)
  35537. {
  35538. foreach (self::getInstalled() as $installed) {
  35539. if (!isset($installed['versions'][$packageName])) {
  35540. continue;
  35541. }
  35542. if (!isset($installed['versions'][$packageName]['version'])) {
  35543. return null;
  35544. }
  35545. return $installed['versions'][$packageName]['version'];
  35546. }
  35547. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35548. }
  35549. public static function getPrettyVersion($packageName)
  35550. {
  35551. foreach (self::getInstalled() as $installed) {
  35552. if (!isset($installed['versions'][$packageName])) {
  35553. continue;
  35554. }
  35555. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  35556. return null;
  35557. }
  35558. return $installed['versions'][$packageName]['pretty_version'];
  35559. }
  35560. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35561. }
  35562. public static function getReference($packageName)
  35563. {
  35564. foreach (self::getInstalled() as $installed) {
  35565. if (!isset($installed['versions'][$packageName])) {
  35566. continue;
  35567. }
  35568. if (!isset($installed['versions'][$packageName]['reference'])) {
  35569. return null;
  35570. }
  35571. return $installed['versions'][$packageName]['reference'];
  35572. }
  35573. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35574. }
  35575. public static function getRootPackage()
  35576. {
  35577. $installed = self::getInstalled();
  35578. return $installed[0]['root'];
  35579. }
  35580. public static function getRawData()
  35581. {
  35582. return self::$installed;
  35583. }
  35584. public static function reload($data)
  35585. {
  35586. self::$installed = $data;
  35587. self::$installedByVendor = array();
  35588. }
  35589. private static function getInstalled()
  35590. {
  35591. if (null === self::$canGetVendors) {
  35592. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  35593. }
  35594. $installed = array();
  35595. if (self::$canGetVendors) {
  35596. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  35597. if (isset(self::$installedByVendor[$vendorDir])) {
  35598. $installed[] = self::$installedByVendor[$vendorDir];
  35599. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  35600. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  35601. }
  35602. }
  35603. }
  35604. $installed[] = self::$installed;
  35605. return $installed;
  35606. }
  35607. }
  35608. <?php
  35609. $vendorDir = dirname(dirname(__FILE__));
  35610. $baseDir = dirname($vendorDir);
  35611. return array(
  35612. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  35613. );
  35614. <?php
  35615. $vendorDir = dirname(dirname(__FILE__));
  35616. $baseDir = dirname($vendorDir);
  35617. return array(
  35618. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  35619. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  35620. '7844cce90d4037f1a077c08319eef109' => $vendorDir . '/react/promise/src/React/Promise/functions_include.php',
  35621. );
  35622. <?php
  35623. $vendorDir = dirname(dirname(__FILE__));
  35624. $baseDir = dirname($vendorDir);
  35625. return array(
  35626. 'React\\Promise' => array($vendorDir . '/react/promise/src'),
  35627. );
  35628. <?php
  35629. $vendorDir = dirname(dirname(__FILE__));
  35630. $baseDir = dirname($vendorDir);
  35631. return array(
  35632. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  35633. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  35634. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  35635. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  35636. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  35637. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  35638. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  35639. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  35640. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  35641. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  35642. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  35643. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  35644. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  35645. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  35646. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  35647. 'Composer\\' => array($baseDir . '/src/Composer'),
  35648. );
  35649. <?php
  35650. class ComposerAutoloaderInitComposerPhar1617264899
  35651. {
  35652. private static $loader;
  35653. public static function loadClassLoader($class)
  35654. {
  35655. if ('Composer\Autoload\ClassLoader' === $class) {
  35656. require __DIR__ . '/ClassLoader.php';
  35657. }
  35658. }
  35659. public static function getLoader()
  35660. {
  35661. if (null !== self::$loader) {
  35662. return self::$loader;
  35663. }
  35664. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1617264899', 'loadClassLoader'), true, true);
  35665. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
  35666. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1617264899', 'loadClassLoader'));
  35667. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  35668. if ($useStaticLoader) {
  35669. require __DIR__ . '/autoload_static.php';
  35670. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1617264899::getInitializer($loader));
  35671. } else {
  35672. $map = require __DIR__ . '/autoload_namespaces.php';
  35673. foreach ($map as $namespace => $path) {
  35674. $loader->set($namespace, $path);
  35675. }
  35676. $map = require __DIR__ . '/autoload_psr4.php';
  35677. foreach ($map as $namespace => $path) {
  35678. $loader->setPsr4($namespace, $path);
  35679. }
  35680. $classMap = require __DIR__ . '/autoload_classmap.php';
  35681. if ($classMap) {
  35682. $loader->addClassMap($classMap);
  35683. }
  35684. }
  35685. $loader->register(true);
  35686. if ($useStaticLoader) {
  35687. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1617264899::$files;
  35688. } else {
  35689. $includeFiles = require __DIR__ . '/autoload_files.php';
  35690. }
  35691. foreach ($includeFiles as $fileIdentifier => $file) {
  35692. composerRequireComposerPhar1617264899($fileIdentifier, $file);
  35693. }
  35694. return $loader;
  35695. }
  35696. }
  35697. function composerRequireComposerPhar1617264899($fileIdentifier, $file)
  35698. {
  35699. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  35700. require $file;
  35701. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  35702. }
  35703. }
  35704. <?php
  35705. namespace Composer\Autoload;
  35706. class ComposerStaticInitComposerPhar1617264899
  35707. {
  35708. public static $files = array (
  35709. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  35710. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  35711. '7844cce90d4037f1a077c08319eef109' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions_include.php',
  35712. );
  35713. public static $prefixLengthsPsr4 = array (
  35714. 'S' =>
  35715. array (
  35716. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  35717. 'Symfony\\Polyfill\\Ctype\\' => 23,
  35718. 'Symfony\\Component\\Process\\' => 26,
  35719. 'Symfony\\Component\\Finder\\' => 25,
  35720. 'Symfony\\Component\\Filesystem\\' => 29,
  35721. 'Symfony\\Component\\Debug\\' => 24,
  35722. 'Symfony\\Component\\Console\\' => 26,
  35723. 'Seld\\PharUtils\\' => 15,
  35724. 'Seld\\JsonLint\\' => 14,
  35725. ),
  35726. 'P' =>
  35727. array (
  35728. 'Psr\\Log\\' => 8,
  35729. ),
  35730. 'J' =>
  35731. array (
  35732. 'JsonSchema\\' => 11,
  35733. ),
  35734. 'C' =>
  35735. array (
  35736. 'Composer\\XdebugHandler\\' => 23,
  35737. 'Composer\\Spdx\\' => 14,
  35738. 'Composer\\Semver\\' => 16,
  35739. 'Composer\\CaBundle\\' => 18,
  35740. 'Composer\\' => 9,
  35741. ),
  35742. );
  35743. public static $prefixDirsPsr4 = array (
  35744. 'Symfony\\Polyfill\\Mbstring\\' =>
  35745. array (
  35746. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  35747. ),
  35748. 'Symfony\\Polyfill\\Ctype\\' =>
  35749. array (
  35750. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  35751. ),
  35752. 'Symfony\\Component\\Process\\' =>
  35753. array (
  35754. 0 => __DIR__ . '/..' . '/symfony/process',
  35755. ),
  35756. 'Symfony\\Component\\Finder\\' =>
  35757. array (
  35758. 0 => __DIR__ . '/..' . '/symfony/finder',
  35759. ),
  35760. 'Symfony\\Component\\Filesystem\\' =>
  35761. array (
  35762. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  35763. ),
  35764. 'Symfony\\Component\\Debug\\' =>
  35765. array (
  35766. 0 => __DIR__ . '/..' . '/symfony/debug',
  35767. ),
  35768. 'Symfony\\Component\\Console\\' =>
  35769. array (
  35770. 0 => __DIR__ . '/..' . '/symfony/console',
  35771. ),
  35772. 'Seld\\PharUtils\\' =>
  35773. array (
  35774. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  35775. ),
  35776. 'Seld\\JsonLint\\' =>
  35777. array (
  35778. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  35779. ),
  35780. 'Psr\\Log\\' =>
  35781. array (
  35782. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  35783. ),
  35784. 'JsonSchema\\' =>
  35785. array (
  35786. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  35787. ),
  35788. 'Composer\\XdebugHandler\\' =>
  35789. array (
  35790. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  35791. ),
  35792. 'Composer\\Spdx\\' =>
  35793. array (
  35794. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  35795. ),
  35796. 'Composer\\Semver\\' =>
  35797. array (
  35798. 0 => __DIR__ . '/..' . '/composer/semver/src',
  35799. ),
  35800. 'Composer\\CaBundle\\' =>
  35801. array (
  35802. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  35803. ),
  35804. 'Composer\\' =>
  35805. array (
  35806. 0 => __DIR__ . '/../..' . '/src/Composer',
  35807. ),
  35808. );
  35809. public static $prefixesPsr0 = array (
  35810. 'R' =>
  35811. array (
  35812. 'React\\Promise' =>
  35813. array (
  35814. 0 => __DIR__ . '/..' . '/react/promise/src',
  35815. ),
  35816. ),
  35817. );
  35818. public static $classMap = array (
  35819. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  35820. );
  35821. public static function getInitializer(ClassLoader $loader)
  35822. {
  35823. return \Closure::bind(function () use ($loader) {
  35824. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1617264899::$prefixLengthsPsr4;
  35825. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1617264899::$prefixDirsPsr4;
  35826. $loader->prefixesPsr0 = ComposerStaticInitComposerPhar1617264899::$prefixesPsr0;
  35827. $loader->classMap = ComposerStaticInitComposerPhar1617264899::$classMap;
  35828. }, null, ClassLoader::class);
  35829. }
  35830. }
  35831. Copyright (C) 2016 Composer
  35832. Permission is hereby granted, free of charge, to any person obtaining a copy of
  35833. this software and associated documentation files (the "Software"), to deal in
  35834. the Software without restriction, including without limitation the rights to
  35835. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  35836. of the Software, and to permit persons to whom the Software is furnished to do
  35837. so, subject to the following conditions:
  35838. The above copyright notice and this permission notice shall be included in all
  35839. copies or substantial portions of the Software.
  35840. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35841. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  35842. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  35843. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  35844. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  35845. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  35846. SOFTWARE.
  35847. ##
  35848. ## Bundle of CA Root Certificates
  35849. ##
  35850. ## Certificate data from Mozilla as of: Tue Dec 8 04:12:05 2020 GMT
  35851. ##
  35852. ## This is a bundle of X.509 certificates of public Certificate Authorities
  35853. ## (CA). These were automatically extracted from Mozilla's root certificates
  35854. ## file (certdata.txt). This file can be found in the mozilla source tree:
  35855. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  35856. ##
  35857. ## It contains the certificates in PEM format and therefore
  35858. ## can be directly used with curl / libcurl / php_curl, or with
  35859. ## an Apache+mod_ssl webserver for SSL client authentication.
  35860. ## Just configure this file as the SSLCACertificateFile.
  35861. ##
  35862. ## Conversion done with mk-ca-bundle.pl version 1.28.
  35863. ## SHA256: d820b8696d8ffe42064a1384a56a8981cdc7e7e198036bbb5fa04a6c282dd9a2
  35864. ##
  35865. GlobalSign Root CA
  35866. ==================
  35867. -----BEGIN CERTIFICATE-----
  35868. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  35869. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  35870. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  35871. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  35872. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  35873. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  35874. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  35875. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  35876. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  35877. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  35878. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  35879. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  35880. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  35881. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  35882. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  35883. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  35884. -----END CERTIFICATE-----
  35885. GlobalSign Root CA - R2
  35886. =======================
  35887. -----BEGIN CERTIFICATE-----
  35888. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  35889. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  35890. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  35891. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  35892. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  35893. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  35894. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  35895. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  35896. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  35897. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  35898. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  35899. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  35900. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  35901. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  35902. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  35903. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  35904. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  35905. -----END CERTIFICATE-----
  35906. Entrust.net Premium 2048 Secure Server CA
  35907. =========================================
  35908. -----BEGIN CERTIFICATE-----
  35909. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  35910. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  35911. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  35912. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  35913. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  35914. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  35915. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  35916. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  35917. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  35918. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  35919. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  35920. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  35921. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  35922. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  35923. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  35924. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  35925. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  35926. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  35927. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  35928. -----END CERTIFICATE-----
  35929. Baltimore CyberTrust Root
  35930. =========================
  35931. -----BEGIN CERTIFICATE-----
  35932. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  35933. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  35934. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  35935. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  35936. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  35937. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  35938. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  35939. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  35940. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  35941. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  35942. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  35943. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  35944. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  35945. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  35946. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  35947. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  35948. -----END CERTIFICATE-----
  35949. Entrust Root Certification Authority
  35950. ====================================
  35951. -----BEGIN CERTIFICATE-----
  35952. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  35953. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  35954. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  35955. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  35956. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  35957. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  35958. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  35959. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  35960. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  35961. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  35962. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  35963. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  35964. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  35965. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  35966. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  35967. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  35968. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  35969. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  35970. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  35971. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  35972. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  35973. -----END CERTIFICATE-----
  35974. GeoTrust Global CA
  35975. ==================
  35976. -----BEGIN CERTIFICATE-----
  35977. MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK
  35978. Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw
  35979. MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j
  35980. LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  35981. CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo
  35982. BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet
  35983. 8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc
  35984. T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU
  35985. vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD
  35986. AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk
  35987. DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q
  35988. zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4
  35989. d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2
  35990. mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p
  35991. XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm
  35992. Mw==
  35993. -----END CERTIFICATE-----
  35994. GeoTrust Universal CA
  35995. =====================
  35996. -----BEGIN CERTIFICATE-----
  35997. MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  35998. R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1
  35999. MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu
  36000. Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  36001. ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t
  36002. JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e
  36003. RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs
  36004. 7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d
  36005. 8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V
  36006. qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga
  36007. Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB
  36008. Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu
  36009. KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08
  36010. ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0
  36011. XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB
  36012. hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
  36013. aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2
  36014. qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL
  36015. oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK
  36016. xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF
  36017. KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2
  36018. DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK
  36019. xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU
  36020. p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI
  36021. P/rmMuGNG2+k5o7Y+SlIis5z/iw=
  36022. -----END CERTIFICATE-----
  36023. GeoTrust Universal CA 2
  36024. =======================
  36025. -----BEGIN CERTIFICATE-----
  36026. MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  36027. R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0
  36028. MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg
  36029. SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA
  36030. A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0
  36031. DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17
  36032. j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q
  36033. JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a
  36034. QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2
  36035. WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP
  36036. 20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn
  36037. ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC
  36038. SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG
  36039. 8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2
  36040. +/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E
  36041. BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z
  36042. dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ
  36043. 4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+
  36044. mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq
  36045. A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg
  36046. Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP
  36047. pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d
  36048. FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp
  36049. gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm
  36050. X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS
  36051. -----END CERTIFICATE-----
  36052. Comodo AAA Services root
  36053. ========================
  36054. -----BEGIN CERTIFICATE-----
  36055. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  36056. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  36057. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  36058. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  36059. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  36060. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  36061. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  36062. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  36063. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  36064. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  36065. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  36066. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  36067. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  36068. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  36069. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  36070. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  36071. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  36072. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  36073. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  36074. -----END CERTIFICATE-----
  36075. QuoVadis Root CA
  36076. ================
  36077. -----BEGIN CERTIFICATE-----
  36078. MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE
  36079. ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
  36080. eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz
  36081. MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp
  36082. cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD
  36083. EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF
  36084. AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk
  36085. J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL
  36086. F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL
  36087. YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen
  36088. AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w
  36089. PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y
  36090. ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7
  36091. MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj
  36092. YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs
  36093. ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh
  36094. Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW
  36095. Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu
  36096. BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw
  36097. FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0
  36098. aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6
  36099. tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo
  36100. fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul
  36101. LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x
  36102. gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi
  36103. 5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi
  36104. 5nrQNiOKSnQ2+Q==
  36105. -----END CERTIFICATE-----
  36106. QuoVadis Root CA 2
  36107. ==================
  36108. -----BEGIN CERTIFICATE-----
  36109. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  36110. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  36111. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  36112. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  36113. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  36114. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  36115. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  36116. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  36117. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  36118. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  36119. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  36120. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  36121. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  36122. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  36123. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  36124. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  36125. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  36126. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  36127. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  36128. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  36129. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  36130. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  36131. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  36132. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  36133. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  36134. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  36135. -----END CERTIFICATE-----
  36136. QuoVadis Root CA 3
  36137. ==================
  36138. -----BEGIN CERTIFICATE-----
  36139. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  36140. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  36141. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  36142. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  36143. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  36144. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  36145. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  36146. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  36147. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  36148. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  36149. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  36150. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  36151. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  36152. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  36153. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  36154. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  36155. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  36156. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  36157. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  36158. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  36159. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  36160. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  36161. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  36162. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  36163. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  36164. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  36165. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  36166. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  36167. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  36168. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  36169. -----END CERTIFICATE-----
  36170. Security Communication Root CA
  36171. ==============================
  36172. -----BEGIN CERTIFICATE-----
  36173. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  36174. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  36175. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  36176. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  36177. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  36178. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  36179. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  36180. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  36181. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  36182. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  36183. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  36184. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  36185. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  36186. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  36187. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  36188. FL39vmwLAw==
  36189. -----END CERTIFICATE-----
  36190. Sonera Class 2 Root CA
  36191. ======================
  36192. -----BEGIN CERTIFICATE-----
  36193. MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG
  36194. U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw
  36195. NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh
  36196. IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3
  36197. /Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT
  36198. dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG
  36199. f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P
  36200. tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH
  36201. nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT
  36202. XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt
  36203. 0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI
  36204. cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph
  36205. Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx
  36206. EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH
  36207. llpwrN9M
  36208. -----END CERTIFICATE-----
  36209. XRamp Global CA Root
  36210. ====================
  36211. -----BEGIN CERTIFICATE-----
  36212. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  36213. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  36214. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  36215. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  36216. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  36217. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  36218. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  36219. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  36220. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  36221. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  36222. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  36223. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  36224. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  36225. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  36226. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  36227. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  36228. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  36229. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  36230. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  36231. -----END CERTIFICATE-----
  36232. Go Daddy Class 2 CA
  36233. ===================
  36234. -----BEGIN CERTIFICATE-----
  36235. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  36236. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  36237. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  36238. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  36239. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  36240. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  36241. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  36242. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  36243. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  36244. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  36245. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  36246. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  36247. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  36248. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  36249. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  36250. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  36251. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  36252. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  36253. vZ8=
  36254. -----END CERTIFICATE-----
  36255. Starfield Class 2 CA
  36256. ====================
  36257. -----BEGIN CERTIFICATE-----
  36258. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  36259. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  36260. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  36261. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  36262. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  36263. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  36264. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  36265. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  36266. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  36267. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  36268. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  36269. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  36270. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  36271. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  36272. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  36273. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  36274. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  36275. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  36276. QBFGmh95DmK/D5fs4C8fF5Q=
  36277. -----END CERTIFICATE-----
  36278. DigiCert Assured ID Root CA
  36279. ===========================
  36280. -----BEGIN CERTIFICATE-----
  36281. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  36282. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  36283. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  36284. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  36285. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  36286. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  36287. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  36288. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  36289. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  36290. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  36291. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  36292. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  36293. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  36294. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  36295. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  36296. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  36297. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  36298. -----END CERTIFICATE-----
  36299. DigiCert Global Root CA
  36300. =======================
  36301. -----BEGIN CERTIFICATE-----
  36302. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  36303. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  36304. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  36305. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  36306. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  36307. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  36308. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  36309. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  36310. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  36311. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  36312. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  36313. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  36314. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  36315. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  36316. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  36317. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  36318. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  36319. -----END CERTIFICATE-----
  36320. DigiCert High Assurance EV Root CA
  36321. ==================================
  36322. -----BEGIN CERTIFICATE-----
  36323. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  36324. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  36325. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  36326. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  36327. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  36328. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  36329. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  36330. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  36331. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  36332. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  36333. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  36334. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  36335. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  36336. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  36337. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  36338. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  36339. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  36340. -----END CERTIFICATE-----
  36341. DST Root CA X3
  36342. ==============
  36343. -----BEGIN CERTIFICATE-----
  36344. MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK
  36345. ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X
  36346. DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1
  36347. cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD
  36348. ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT
  36349. rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9
  36350. UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy
  36351. xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d
  36352. utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T
  36353. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ
  36354. MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug
  36355. dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE
  36356. GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw
  36357. RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS
  36358. fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
  36359. -----END CERTIFICATE-----
  36360. SwissSign Gold CA - G2
  36361. ======================
  36362. -----BEGIN CERTIFICATE-----
  36363. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  36364. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  36365. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  36366. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  36367. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  36368. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  36369. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  36370. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  36371. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  36372. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  36373. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  36374. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  36375. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  36376. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  36377. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  36378. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  36379. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  36380. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  36381. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  36382. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  36383. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  36384. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  36385. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  36386. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  36387. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  36388. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  36389. -----END CERTIFICATE-----
  36390. SwissSign Silver CA - G2
  36391. ========================
  36392. -----BEGIN CERTIFICATE-----
  36393. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  36394. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  36395. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  36396. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  36397. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  36398. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  36399. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  36400. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  36401. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  36402. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  36403. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  36404. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  36405. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  36406. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  36407. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  36408. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  36409. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  36410. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  36411. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  36412. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  36413. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  36414. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  36415. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  36416. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  36417. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  36418. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  36419. -----END CERTIFICATE-----
  36420. GeoTrust Primary Certification Authority
  36421. ========================================
  36422. -----BEGIN CERTIFICATE-----
  36423. MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG
  36424. EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD
  36425. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx
  36426. CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ
  36427. cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  36428. CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN
  36429. b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9
  36430. nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge
  36431. RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt
  36432. tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  36433. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI
  36434. hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K
  36435. Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN
  36436. NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa
  36437. Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG
  36438. 1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=
  36439. -----END CERTIFICATE-----
  36440. thawte Primary Root CA
  36441. ======================
  36442. -----BEGIN CERTIFICATE-----
  36443. MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE
  36444. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36445. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36446. cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3
  36447. MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg
  36448. SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv
  36449. KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT
  36450. FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs
  36451. oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ
  36452. 1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc
  36453. q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K
  36454. aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p
  36455. afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD
  36456. VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF
  36457. AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE
  36458. uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX
  36459. xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89
  36460. jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH
  36461. z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA==
  36462. -----END CERTIFICATE-----
  36463. VeriSign Class 3 Public Primary Certification Authority - G5
  36464. ============================================================
  36465. -----BEGIN CERTIFICATE-----
  36466. MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
  36467. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36468. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36469. IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
  36470. ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
  36471. yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
  36472. biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
  36473. dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
  36474. YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  36475. ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
  36476. j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
  36477. Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
  36478. Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
  36479. fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
  36480. BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
  36481. Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
  36482. aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
  36483. SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
  36484. X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
  36485. KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
  36486. Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
  36487. ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
  36488. -----END CERTIFICATE-----
  36489. SecureTrust CA
  36490. ==============
  36491. -----BEGIN CERTIFICATE-----
  36492. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  36493. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  36494. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  36495. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  36496. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  36497. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  36498. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  36499. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  36500. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  36501. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  36502. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  36503. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  36504. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  36505. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  36506. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  36507. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  36508. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  36509. -----END CERTIFICATE-----
  36510. Secure Global CA
  36511. ================
  36512. -----BEGIN CERTIFICATE-----
  36513. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  36514. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  36515. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  36516. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  36517. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  36518. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  36519. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  36520. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  36521. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  36522. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  36523. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  36524. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  36525. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  36526. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  36527. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  36528. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  36529. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  36530. -----END CERTIFICATE-----
  36531. COMODO Certification Authority
  36532. ==============================
  36533. -----BEGIN CERTIFICATE-----
  36534. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  36535. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  36536. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  36537. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  36538. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  36539. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  36540. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  36541. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  36542. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  36543. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  36544. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  36545. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  36546. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  36547. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  36548. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  36549. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  36550. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  36551. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  36552. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  36553. -----END CERTIFICATE-----
  36554. Network Solutions Certificate Authority
  36555. =======================================
  36556. -----BEGIN CERTIFICATE-----
  36557. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  36558. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  36559. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  36560. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  36561. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  36562. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  36563. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  36564. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  36565. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  36566. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  36567. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  36568. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  36569. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  36570. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  36571. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  36572. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  36573. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  36574. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  36575. -----END CERTIFICATE-----
  36576. COMODO ECC Certification Authority
  36577. ==================================
  36578. -----BEGIN CERTIFICATE-----
  36579. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  36580. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  36581. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  36582. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  36583. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  36584. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  36585. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  36586. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  36587. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  36588. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  36589. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  36590. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  36591. -----END CERTIFICATE-----
  36592. Certigna
  36593. ========
  36594. -----BEGIN CERTIFICATE-----
  36595. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  36596. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  36597. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  36598. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  36599. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  36600. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  36601. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  36602. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  36603. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  36604. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  36605. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  36606. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  36607. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  36608. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  36609. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  36610. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  36611. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  36612. -----END CERTIFICATE-----
  36613. Cybertrust Global Root
  36614. ======================
  36615. -----BEGIN CERTIFICATE-----
  36616. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  36617. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  36618. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  36619. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  36620. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  36621. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  36622. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  36623. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  36624. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  36625. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  36626. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  36627. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  36628. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  36629. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  36630. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  36631. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  36632. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  36633. -----END CERTIFICATE-----
  36634. ePKI Root Certification Authority
  36635. =================================
  36636. -----BEGIN CERTIFICATE-----
  36637. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  36638. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  36639. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  36640. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  36641. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  36642. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  36643. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  36644. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  36645. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  36646. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  36647. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  36648. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  36649. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  36650. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  36651. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  36652. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  36653. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  36654. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  36655. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  36656. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  36657. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  36658. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  36659. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  36660. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  36661. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  36662. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  36663. -----END CERTIFICATE-----
  36664. certSIGN ROOT CA
  36665. ================
  36666. -----BEGIN CERTIFICATE-----
  36667. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  36668. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  36669. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  36670. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  36671. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  36672. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  36673. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  36674. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  36675. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  36676. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  36677. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  36678. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  36679. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  36680. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  36681. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  36682. -----END CERTIFICATE-----
  36683. GeoTrust Primary Certification Authority - G3
  36684. =============================================
  36685. -----BEGIN CERTIFICATE-----
  36686. MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE
  36687. BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0
  36688. IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy
  36689. eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz
  36690. NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo
  36691. YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT
  36692. LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI
  36693. hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j
  36694. K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE
  36695. c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C
  36696. IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu
  36697. dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC
  36698. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr
  36699. 2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9
  36700. cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE
  36701. Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD
  36702. AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s
  36703. t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt
  36704. -----END CERTIFICATE-----
  36705. thawte Primary Root CA - G2
  36706. ===========================
  36707. -----BEGIN CERTIFICATE-----
  36708. MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC
  36709. VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu
  36710. IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg
  36711. Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV
  36712. MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG
  36713. b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt
  36714. IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS
  36715. LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5
  36716. 8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU
  36717. mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN
  36718. G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K
  36719. rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==
  36720. -----END CERTIFICATE-----
  36721. thawte Primary Root CA - G3
  36722. ===========================
  36723. -----BEGIN CERTIFICATE-----
  36724. MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE
  36725. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36726. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36727. cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w
  36728. ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh
  36729. d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD
  36730. VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG
  36731. A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  36732. MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At
  36733. P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC
  36734. +BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY
  36735. 7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW
  36736. vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E
  36737. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ
  36738. KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK
  36739. A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu
  36740. t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC
  36741. 8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm
  36742. er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A=
  36743. -----END CERTIFICATE-----
  36744. GeoTrust Primary Certification Authority - G2
  36745. =============================================
  36746. -----BEGIN CERTIFICATE-----
  36747. MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC
  36748. VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu
  36749. Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD
  36750. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1
  36751. OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg
  36752. MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl
  36753. b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG
  36754. BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc
  36755. KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD
  36756. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+
  36757. EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m
  36758. ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2
  36759. npaqBA+K
  36760. -----END CERTIFICATE-----
  36761. VeriSign Universal Root Certification Authority
  36762. ===============================================
  36763. -----BEGIN CERTIFICATE-----
  36764. MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
  36765. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36766. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36767. IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
  36768. IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
  36769. UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
  36770. cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
  36771. IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
  36772. aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
  36773. 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
  36774. MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
  36775. 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
  36776. AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
  36777. tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
  36778. CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
  36779. a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
  36780. DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
  36781. Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
  36782. Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
  36783. P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
  36784. wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
  36785. mJO37M2CYfE45k+XmCpajQ==
  36786. -----END CERTIFICATE-----
  36787. VeriSign Class 3 Public Primary Certification Authority - G4
  36788. ============================================================
  36789. -----BEGIN CERTIFICATE-----
  36790. MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
  36791. VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
  36792. b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
  36793. ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
  36794. YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
  36795. MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
  36796. cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
  36797. b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
  36798. IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
  36799. Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
  36800. rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
  36801. /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
  36802. HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
  36803. Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
  36804. A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
  36805. AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
  36806. -----END CERTIFICATE-----
  36807. NetLock Arany (Class Gold) Főtanúsítvány
  36808. ========================================
  36809. -----BEGIN CERTIFICATE-----
  36810. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  36811. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  36812. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  36813. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  36814. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  36815. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  36816. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  36817. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  36818. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  36819. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  36820. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  36821. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  36822. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  36823. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  36824. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  36825. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  36826. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  36827. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  36828. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  36829. -----END CERTIFICATE-----
  36830. Hongkong Post Root CA 1
  36831. =======================
  36832. -----BEGIN CERTIFICATE-----
  36833. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  36834. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  36835. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  36836. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  36837. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  36838. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  36839. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  36840. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  36841. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  36842. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  36843. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  36844. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  36845. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  36846. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  36847. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  36848. -----END CERTIFICATE-----
  36849. SecureSign RootCA11
  36850. ===================
  36851. -----BEGIN CERTIFICATE-----
  36852. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  36853. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  36854. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  36855. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  36856. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  36857. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  36858. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  36859. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  36860. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  36861. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  36862. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  36863. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  36864. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  36865. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  36866. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  36867. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  36868. -----END CERTIFICATE-----
  36869. Microsec e-Szigno Root CA 2009
  36870. ==============================
  36871. -----BEGIN CERTIFICATE-----
  36872. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  36873. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  36874. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  36875. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  36876. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  36877. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  36878. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  36879. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  36880. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  36881. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  36882. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  36883. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  36884. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  36885. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  36886. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  36887. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  36888. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  36889. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  36890. LXpUq3DDfSJlgnCW
  36891. -----END CERTIFICATE-----
  36892. GlobalSign Root CA - R3
  36893. =======================
  36894. -----BEGIN CERTIFICATE-----
  36895. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  36896. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  36897. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  36898. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  36899. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  36900. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  36901. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  36902. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  36903. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  36904. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  36905. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  36906. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  36907. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  36908. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  36909. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  36910. kpeDMdmztcpHWD9f
  36911. -----END CERTIFICATE-----
  36912. Autoridad de Certificacion Firmaprofesional CIF A62634068
  36913. =========================================================
  36914. -----BEGIN CERTIFICATE-----
  36915. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  36916. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  36917. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  36918. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  36919. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  36920. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  36921. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  36922. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  36923. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  36924. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  36925. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  36926. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  36927. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  36928. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  36929. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  36930. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  36931. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  36932. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  36933. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  36934. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  36935. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  36936. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  36937. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  36938. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  36939. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  36940. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  36941. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  36942. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  36943. -----END CERTIFICATE-----
  36944. Izenpe.com
  36945. ==========
  36946. -----BEGIN CERTIFICATE-----
  36947. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  36948. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  36949. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  36950. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  36951. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  36952. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  36953. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  36954. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  36955. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  36956. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  36957. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  36958. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  36959. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  36960. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  36961. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  36962. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  36963. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  36964. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  36965. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  36966. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  36967. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  36968. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  36969. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  36970. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  36971. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  36972. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  36973. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  36974. -----END CERTIFICATE-----
  36975. Chambers of Commerce Root - 2008
  36976. ================================
  36977. -----BEGIN CERTIFICATE-----
  36978. MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD
  36979. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  36980. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  36981. QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy
  36982. Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl
  36983. ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF
  36984. EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl
  36985. cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
  36986. AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA
  36987. XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj
  36988. h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/
  36989. ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk
  36990. NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g
  36991. D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331
  36992. lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ
  36993. 0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj
  36994. ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2
  36995. EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI
  36996. G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ
  36997. BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh
  36998. bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh
  36999. bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC
  37000. CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH
  37001. AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1
  37002. wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH
  37003. 3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU
  37004. RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6
  37005. M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1
  37006. YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF
  37007. 9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK
  37008. zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG
  37009. nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg
  37010. OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ
  37011. -----END CERTIFICATE-----
  37012. Global Chambersign Root - 2008
  37013. ==============================
  37014. -----BEGIN CERTIFICATE-----
  37015. MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD
  37016. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  37017. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  37018. QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx
  37019. NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg
  37020. Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ
  37021. QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD
  37022. aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf
  37023. VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf
  37024. XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0
  37025. ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB
  37026. /gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA
  37027. TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M
  37028. H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe
  37029. Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF
  37030. HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh
  37031. wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB
  37032. AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT
  37033. BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE
  37034. BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm
  37035. aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm
  37036. aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp
  37037. 1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0
  37038. dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG
  37039. /5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6
  37040. ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s
  37041. dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg
  37042. 9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH
  37043. foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du
  37044. qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr
  37045. P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq
  37046. c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z
  37047. 09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B
  37048. -----END CERTIFICATE-----
  37049. Go Daddy Root Certificate Authority - G2
  37050. ========================================
  37051. -----BEGIN CERTIFICATE-----
  37052. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  37053. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  37054. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  37055. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  37056. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  37057. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  37058. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  37059. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  37060. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  37061. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  37062. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  37063. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  37064. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  37065. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  37066. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  37067. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  37068. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  37069. -----END CERTIFICATE-----
  37070. Starfield Root Certificate Authority - G2
  37071. =========================================
  37072. -----BEGIN CERTIFICATE-----
  37073. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  37074. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  37075. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  37076. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  37077. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  37078. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  37079. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  37080. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  37081. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  37082. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  37083. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  37084. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  37085. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  37086. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  37087. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  37088. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  37089. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  37090. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  37091. -----END CERTIFICATE-----
  37092. Starfield Services Root Certificate Authority - G2
  37093. ==================================================
  37094. -----BEGIN CERTIFICATE-----
  37095. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  37096. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  37097. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  37098. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  37099. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  37100. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  37101. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  37102. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  37103. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  37104. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  37105. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  37106. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  37107. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  37108. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  37109. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  37110. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  37111. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  37112. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  37113. -----END CERTIFICATE-----
  37114. AffirmTrust Commercial
  37115. ======================
  37116. -----BEGIN CERTIFICATE-----
  37117. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  37118. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  37119. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  37120. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  37121. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  37122. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  37123. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  37124. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  37125. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  37126. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  37127. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  37128. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  37129. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  37130. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  37131. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  37132. -----END CERTIFICATE-----
  37133. AffirmTrust Networking
  37134. ======================
  37135. -----BEGIN CERTIFICATE-----
  37136. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  37137. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  37138. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  37139. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  37140. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  37141. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  37142. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  37143. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  37144. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  37145. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  37146. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  37147. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  37148. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  37149. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  37150. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  37151. -----END CERTIFICATE-----
  37152. AffirmTrust Premium
  37153. ===================
  37154. -----BEGIN CERTIFICATE-----
  37155. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  37156. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  37157. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  37158. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  37159. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  37160. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  37161. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  37162. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  37163. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  37164. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  37165. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  37166. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  37167. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  37168. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  37169. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  37170. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  37171. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  37172. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  37173. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  37174. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  37175. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  37176. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  37177. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  37178. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  37179. -----END CERTIFICATE-----
  37180. AffirmTrust Premium ECC
  37181. =======================
  37182. -----BEGIN CERTIFICATE-----
  37183. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  37184. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  37185. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  37186. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  37187. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  37188. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  37189. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  37190. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  37191. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  37192. eQ==
  37193. -----END CERTIFICATE-----
  37194. Certum Trusted Network CA
  37195. =========================
  37196. -----BEGIN CERTIFICATE-----
  37197. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  37198. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  37199. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  37200. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  37201. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  37202. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  37203. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  37204. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  37205. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  37206. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  37207. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  37208. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  37209. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  37210. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  37211. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  37212. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  37213. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  37214. -----END CERTIFICATE-----
  37215. TWCA Root Certification Authority
  37216. =================================
  37217. -----BEGIN CERTIFICATE-----
  37218. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  37219. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  37220. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  37221. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  37222. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  37223. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  37224. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  37225. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  37226. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  37227. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  37228. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  37229. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  37230. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  37231. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  37232. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  37233. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  37234. -----END CERTIFICATE-----
  37235. Security Communication RootCA2
  37236. ==============================
  37237. -----BEGIN CERTIFICATE-----
  37238. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  37239. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  37240. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  37241. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  37242. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  37243. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  37244. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  37245. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  37246. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  37247. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  37248. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  37249. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  37250. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  37251. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  37252. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  37253. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  37254. -----END CERTIFICATE-----
  37255. EC-ACC
  37256. ======
  37257. -----BEGIN CERTIFICATE-----
  37258. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  37259. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  37260. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  37261. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  37262. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  37263. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  37264. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  37265. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  37266. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  37267. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  37268. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  37269. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  37270. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  37271. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  37272. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  37273. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  37274. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  37275. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  37276. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  37277. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  37278. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  37279. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  37280. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  37281. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  37282. 5EI=
  37283. -----END CERTIFICATE-----
  37284. Hellenic Academic and Research Institutions RootCA 2011
  37285. =======================================================
  37286. -----BEGIN CERTIFICATE-----
  37287. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  37288. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  37289. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  37290. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  37291. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  37292. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  37293. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  37294. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  37295. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  37296. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  37297. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  37298. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  37299. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  37300. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  37301. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  37302. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  37303. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  37304. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  37305. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  37306. -----END CERTIFICATE-----
  37307. Actalis Authentication Root CA
  37308. ==============================
  37309. -----BEGIN CERTIFICATE-----
  37310. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  37311. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  37312. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  37313. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  37314. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  37315. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  37316. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  37317. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  37318. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  37319. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  37320. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  37321. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  37322. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  37323. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  37324. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  37325. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  37326. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  37327. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  37328. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  37329. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  37330. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  37331. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  37332. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  37333. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  37334. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  37335. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  37336. -----END CERTIFICATE-----
  37337. Trustis FPS Root CA
  37338. ===================
  37339. -----BEGIN CERTIFICATE-----
  37340. MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG
  37341. EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290
  37342. IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV
  37343. BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ
  37344. KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ
  37345. RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk
  37346. H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa
  37347. cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt
  37348. o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA
  37349. AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd
  37350. BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c
  37351. GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC
  37352. yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P
  37353. 8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV
  37354. l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl
  37355. iB6XzCGcKQENZetX2fNXlrtIzYE=
  37356. -----END CERTIFICATE-----
  37357. Buypass Class 2 Root CA
  37358. =======================
  37359. -----BEGIN CERTIFICATE-----
  37360. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  37361. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  37362. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  37363. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  37364. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  37365. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  37366. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  37367. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  37368. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  37369. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  37370. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  37371. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  37372. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  37373. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  37374. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  37375. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  37376. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  37377. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  37378. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  37379. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  37380. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  37381. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  37382. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  37383. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  37384. rJgWVqA=
  37385. -----END CERTIFICATE-----
  37386. Buypass Class 3 Root CA
  37387. =======================
  37388. -----BEGIN CERTIFICATE-----
  37389. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  37390. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  37391. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  37392. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  37393. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  37394. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  37395. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  37396. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  37397. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  37398. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  37399. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  37400. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  37401. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  37402. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  37403. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  37404. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  37405. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  37406. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  37407. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  37408. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  37409. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  37410. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  37411. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  37412. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  37413. Cp/HuZc=
  37414. -----END CERTIFICATE-----
  37415. T-TeleSec GlobalRoot Class 3
  37416. ============================
  37417. -----BEGIN CERTIFICATE-----
  37418. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37419. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37420. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  37421. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37422. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37423. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  37424. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  37425. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  37426. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  37427. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  37428. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  37429. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  37430. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  37431. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  37432. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  37433. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  37434. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  37435. -----END CERTIFICATE-----
  37436. D-TRUST Root Class 3 CA 2 2009
  37437. ==============================
  37438. -----BEGIN CERTIFICATE-----
  37439. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37440. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  37441. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  37442. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  37443. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  37444. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  37445. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  37446. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  37447. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  37448. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  37449. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  37450. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  37451. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  37452. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  37453. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  37454. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  37455. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  37456. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  37457. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  37458. -----END CERTIFICATE-----
  37459. D-TRUST Root Class 3 CA 2 EV 2009
  37460. =================================
  37461. -----BEGIN CERTIFICATE-----
  37462. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37463. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37464. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37465. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37466. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  37467. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  37468. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  37469. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  37470. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  37471. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  37472. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  37473. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  37474. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  37475. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  37476. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  37477. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  37478. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  37479. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  37480. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  37481. w9y4AyHqnxbxLFS1
  37482. -----END CERTIFICATE-----
  37483. CA Disig Root R2
  37484. ================
  37485. -----BEGIN CERTIFICATE-----
  37486. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  37487. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  37488. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  37489. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  37490. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  37491. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  37492. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  37493. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  37494. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  37495. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  37496. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  37497. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  37498. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  37499. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  37500. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  37501. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  37502. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  37503. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  37504. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  37505. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  37506. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  37507. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  37508. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  37509. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  37510. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  37511. -----END CERTIFICATE-----
  37512. ACCVRAIZ1
  37513. =========
  37514. -----BEGIN CERTIFICATE-----
  37515. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  37516. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  37517. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  37518. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  37519. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  37520. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  37521. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  37522. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  37523. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  37524. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  37525. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  37526. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  37527. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  37528. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  37529. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  37530. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  37531. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  37532. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  37533. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  37534. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  37535. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  37536. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  37537. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  37538. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  37539. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  37540. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  37541. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  37542. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  37543. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  37544. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  37545. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  37546. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  37547. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  37548. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  37549. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  37550. EfbRD0tVNEYqi4Y7
  37551. -----END CERTIFICATE-----
  37552. TWCA Global Root CA
  37553. ===================
  37554. -----BEGIN CERTIFICATE-----
  37555. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  37556. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  37557. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  37558. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  37559. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  37560. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  37561. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  37562. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  37563. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  37564. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  37565. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  37566. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  37567. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  37568. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  37569. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  37570. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  37571. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  37572. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  37573. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  37574. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  37575. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  37576. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  37577. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  37578. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  37579. -----END CERTIFICATE-----
  37580. TeliaSonera Root CA v1
  37581. ======================
  37582. -----BEGIN CERTIFICATE-----
  37583. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  37584. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  37585. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  37586. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  37587. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  37588. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  37589. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  37590. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  37591. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  37592. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  37593. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  37594. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  37595. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  37596. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  37597. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  37598. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  37599. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  37600. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  37601. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  37602. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  37603. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  37604. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  37605. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  37606. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  37607. -----END CERTIFICATE-----
  37608. E-Tugra Certification Authority
  37609. ===============================
  37610. -----BEGIN CERTIFICATE-----
  37611. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  37612. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  37613. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  37614. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  37615. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  37616. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  37617. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  37618. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  37619. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  37620. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  37621. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  37622. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  37623. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  37624. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  37625. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  37626. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  37627. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  37628. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  37629. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  37630. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  37631. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  37632. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  37633. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  37634. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  37635. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  37636. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  37637. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  37638. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  37639. C7TbO6Orb1wdtn7os4I07QZcJA==
  37640. -----END CERTIFICATE-----
  37641. T-TeleSec GlobalRoot Class 2
  37642. ============================
  37643. -----BEGIN CERTIFICATE-----
  37644. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37645. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37646. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  37647. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37648. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37649. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  37650. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  37651. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  37652. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  37653. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  37654. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  37655. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  37656. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  37657. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  37658. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  37659. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  37660. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  37661. -----END CERTIFICATE-----
  37662. Atos TrustedRoot 2011
  37663. =====================
  37664. -----BEGIN CERTIFICATE-----
  37665. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  37666. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  37667. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  37668. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  37669. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  37670. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  37671. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  37672. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  37673. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  37674. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  37675. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  37676. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  37677. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  37678. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  37679. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  37680. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  37681. -----END CERTIFICATE-----
  37682. QuoVadis Root CA 1 G3
  37683. =====================
  37684. -----BEGIN CERTIFICATE-----
  37685. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37686. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37687. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  37688. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  37689. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  37690. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  37691. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  37692. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  37693. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  37694. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  37695. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  37696. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  37697. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  37698. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37699. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  37700. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  37701. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  37702. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  37703. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  37704. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  37705. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  37706. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  37707. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  37708. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  37709. hMJKzRwuJIczYOXD
  37710. -----END CERTIFICATE-----
  37711. QuoVadis Root CA 2 G3
  37712. =====================
  37713. -----BEGIN CERTIFICATE-----
  37714. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37715. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37716. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  37717. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  37718. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  37719. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  37720. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  37721. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  37722. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  37723. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  37724. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  37725. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  37726. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  37727. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37728. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  37729. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  37730. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  37731. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  37732. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  37733. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  37734. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  37735. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  37736. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  37737. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  37738. O3jtZsSOeWmD3n+M
  37739. -----END CERTIFICATE-----
  37740. QuoVadis Root CA 3 G3
  37741. =====================
  37742. -----BEGIN CERTIFICATE-----
  37743. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  37744. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37745. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  37746. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  37747. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  37748. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  37749. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  37750. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  37751. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  37752. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  37753. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  37754. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  37755. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  37756. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37757. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  37758. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  37759. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  37760. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  37761. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  37762. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  37763. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  37764. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  37765. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  37766. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  37767. PpxxVJkES/1Y+Zj0
  37768. -----END CERTIFICATE-----
  37769. DigiCert Assured ID Root G2
  37770. ===========================
  37771. -----BEGIN CERTIFICATE-----
  37772. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  37773. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  37774. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  37775. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  37776. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  37777. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  37778. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  37779. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  37780. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  37781. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  37782. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  37783. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  37784. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  37785. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  37786. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  37787. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  37788. IhNzbM8m9Yop5w==
  37789. -----END CERTIFICATE-----
  37790. DigiCert Assured ID Root G3
  37791. ===========================
  37792. -----BEGIN CERTIFICATE-----
  37793. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  37794. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  37795. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37796. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37797. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  37798. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  37799. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  37800. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  37801. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  37802. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  37803. 1vUhZscv6pZjamVFkpUBtA==
  37804. -----END CERTIFICATE-----
  37805. DigiCert Global Root G2
  37806. =======================
  37807. -----BEGIN CERTIFICATE-----
  37808. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  37809. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  37810. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  37811. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  37812. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  37813. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  37814. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  37815. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  37816. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  37817. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  37818. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  37819. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  37820. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  37821. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  37822. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  37823. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  37824. MrY=
  37825. -----END CERTIFICATE-----
  37826. DigiCert Global Root G3
  37827. =======================
  37828. -----BEGIN CERTIFICATE-----
  37829. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  37830. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  37831. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  37832. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  37833. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  37834. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  37835. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  37836. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  37837. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  37838. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  37839. VOKa5Vt8sycX
  37840. -----END CERTIFICATE-----
  37841. DigiCert Trusted Root G4
  37842. ========================
  37843. -----BEGIN CERTIFICATE-----
  37844. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  37845. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  37846. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37847. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37848. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  37849. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  37850. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  37851. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  37852. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  37853. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  37854. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  37855. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  37856. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  37857. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  37858. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  37859. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  37860. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  37861. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  37862. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  37863. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  37864. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  37865. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  37866. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  37867. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  37868. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  37869. 82Z+
  37870. -----END CERTIFICATE-----
  37871. COMODO RSA Certification Authority
  37872. ==================================
  37873. -----BEGIN CERTIFICATE-----
  37874. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  37875. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  37876. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  37877. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  37878. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  37879. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  37880. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  37881. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  37882. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  37883. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  37884. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  37885. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  37886. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  37887. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  37888. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  37889. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  37890. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  37891. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  37892. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  37893. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  37894. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  37895. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  37896. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  37897. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  37898. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  37899. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  37900. LaZRfyHBNVOFBkpdn627G190
  37901. -----END CERTIFICATE-----
  37902. USERTrust RSA Certification Authority
  37903. =====================================
  37904. -----BEGIN CERTIFICATE-----
  37905. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  37906. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37907. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37908. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  37909. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37910. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37911. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  37912. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  37913. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  37914. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  37915. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  37916. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  37917. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  37918. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  37919. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  37920. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  37921. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  37922. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  37923. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  37924. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  37925. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  37926. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  37927. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  37928. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  37929. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  37930. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  37931. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  37932. -----END CERTIFICATE-----
  37933. USERTrust ECC Certification Authority
  37934. =====================================
  37935. -----BEGIN CERTIFICATE-----
  37936. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  37937. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37938. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37939. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  37940. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37941. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37942. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  37943. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  37944. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  37945. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  37946. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  37947. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  37948. -----END CERTIFICATE-----
  37949. GlobalSign ECC Root CA - R4
  37950. ===========================
  37951. -----BEGIN CERTIFICATE-----
  37952. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  37953. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37954. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37955. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37956. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  37957. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  37958. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  37959. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  37960. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  37961. -----END CERTIFICATE-----
  37962. GlobalSign ECC Root CA - R5
  37963. ===========================
  37964. -----BEGIN CERTIFICATE-----
  37965. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  37966. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37967. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37968. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37969. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  37970. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  37971. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  37972. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  37973. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  37974. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  37975. -----END CERTIFICATE-----
  37976. Staat der Nederlanden Root CA - G3
  37977. ==================================
  37978. -----BEGIN CERTIFICATE-----
  37979. MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
  37980. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  37981. Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
  37982. TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
  37983. ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
  37984. olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
  37985. x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
  37986. EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
  37987. Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
  37988. mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5
  37989. 1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp
  37990. 07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHPbMk7ccHViLVlvMDo
  37991. FxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXtBznaqB16nzaeErAMZRKQFWDZJkBE
  37992. 41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTtXUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMB
  37993. AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleu
  37994. yjWcLhL75LpdINyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD
  37995. U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwpLiniyMMB8jPq
  37996. KqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8Ipf3YF3qKS9Ysr1YvY2WTxB1
  37997. v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixpgZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA
  37998. 8KCWAg8zxXHzniN9lLf9OtMJgwYh/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b
  37999. 8KKaa8MFSu1BYBQw0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0r
  38000. mj1AfsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq4BZ+Extq
  38001. 1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR1VmiiXTTn74eS9fGbbeI
  38002. JG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV
  38003. tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk=
  38004. -----END CERTIFICATE-----
  38005. Staat der Nederlanden EV Root CA
  38006. ================================
  38007. -----BEGIN CERTIFICATE-----
  38008. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  38009. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  38010. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  38011. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  38012. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  38013. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  38014. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  38015. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  38016. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  38017. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  38018. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  38019. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  38020. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  38021. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  38022. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  38023. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  38024. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  38025. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  38026. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  38027. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  38028. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  38029. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  38030. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  38031. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  38032. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  38033. -----END CERTIFICATE-----
  38034. IdenTrust Commercial Root CA 1
  38035. ==============================
  38036. -----BEGIN CERTIFICATE-----
  38037. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  38038. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  38039. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  38040. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  38041. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  38042. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  38043. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  38044. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  38045. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  38046. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  38047. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  38048. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  38049. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  38050. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  38051. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  38052. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  38053. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  38054. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  38055. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  38056. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  38057. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  38058. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  38059. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  38060. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  38061. cGzM7vRX+Bi6hG6H
  38062. -----END CERTIFICATE-----
  38063. IdenTrust Public Sector Root CA 1
  38064. =================================
  38065. -----BEGIN CERTIFICATE-----
  38066. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  38067. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  38068. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  38069. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  38070. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  38071. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  38072. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  38073. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  38074. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  38075. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  38076. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  38077. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  38078. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  38079. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  38080. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  38081. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  38082. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  38083. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  38084. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  38085. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  38086. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  38087. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  38088. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  38089. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  38090. 3Wl9af0AVqW3rLatt8o+Ae+c
  38091. -----END CERTIFICATE-----
  38092. Entrust Root Certification Authority - G2
  38093. =========================================
  38094. -----BEGIN CERTIFICATE-----
  38095. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  38096. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  38097. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  38098. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  38099. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  38100. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  38101. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  38102. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  38103. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  38104. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  38105. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  38106. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  38107. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  38108. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  38109. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  38110. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  38111. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  38112. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  38113. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  38114. e4pIb4tF9g==
  38115. -----END CERTIFICATE-----
  38116. Entrust Root Certification Authority - EC1
  38117. ==========================================
  38118. -----BEGIN CERTIFICATE-----
  38119. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  38120. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  38121. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  38122. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  38123. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  38124. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  38125. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  38126. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  38127. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  38128. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  38129. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  38130. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  38131. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  38132. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  38133. -----END CERTIFICATE-----
  38134. CFCA EV ROOT
  38135. ============
  38136. -----BEGIN CERTIFICATE-----
  38137. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  38138. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  38139. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  38140. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  38141. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  38142. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  38143. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  38144. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  38145. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  38146. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  38147. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  38148. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  38149. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  38150. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  38151. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  38152. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  38153. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  38154. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  38155. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  38156. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  38157. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  38158. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  38159. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  38160. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  38161. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  38162. -----END CERTIFICATE-----
  38163. OISTE WISeKey Global Root GB CA
  38164. ===============================
  38165. -----BEGIN CERTIFICATE-----
  38166. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  38167. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  38168. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  38169. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  38170. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  38171. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  38172. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  38173. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  38174. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  38175. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  38176. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  38177. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  38178. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  38179. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  38180. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  38181. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  38182. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  38183. -----END CERTIFICATE-----
  38184. SZAFIR ROOT CA2
  38185. ===============
  38186. -----BEGIN CERTIFICATE-----
  38187. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  38188. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  38189. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  38190. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  38191. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  38192. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  38193. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  38194. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  38195. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  38196. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  38197. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  38198. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  38199. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  38200. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  38201. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  38202. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  38203. -----END CERTIFICATE-----
  38204. Certum Trusted Network CA 2
  38205. ===========================
  38206. -----BEGIN CERTIFICATE-----
  38207. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  38208. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  38209. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  38210. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  38211. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  38212. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  38213. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  38214. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  38215. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  38216. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  38217. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  38218. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  38219. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  38220. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  38221. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  38222. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  38223. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  38224. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  38225. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  38226. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  38227. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  38228. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  38229. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  38230. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  38231. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  38232. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  38233. zAYspsbiDrW5viSP
  38234. -----END CERTIFICATE-----
  38235. Hellenic Academic and Research Institutions RootCA 2015
  38236. =======================================================
  38237. -----BEGIN CERTIFICATE-----
  38238. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  38239. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  38240. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  38241. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  38242. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  38243. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  38244. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  38245. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  38246. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  38247. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  38248. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  38249. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  38250. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  38251. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  38252. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  38253. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  38254. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  38255. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  38256. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  38257. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  38258. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  38259. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  38260. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  38261. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  38262. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  38263. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  38264. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  38265. p/UsQu0yrbYhnr68
  38266. -----END CERTIFICATE-----
  38267. Hellenic Academic and Research Institutions ECC RootCA 2015
  38268. ===========================================================
  38269. -----BEGIN CERTIFICATE-----
  38270. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  38271. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  38272. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  38273. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  38274. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  38275. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  38276. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  38277. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  38278. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  38279. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  38280. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  38281. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  38282. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  38283. -----END CERTIFICATE-----
  38284. ISRG Root X1
  38285. ============
  38286. -----BEGIN CERTIFICATE-----
  38287. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  38288. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  38289. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  38290. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  38291. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  38292. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  38293. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  38294. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  38295. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  38296. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  38297. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  38298. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  38299. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  38300. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  38301. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  38302. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  38303. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  38304. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  38305. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  38306. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  38307. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  38308. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  38309. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  38310. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  38311. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  38312. -----END CERTIFICATE-----
  38313. AC RAIZ FNMT-RCM
  38314. ================
  38315. -----BEGIN CERTIFICATE-----
  38316. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  38317. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  38318. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  38319. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  38320. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  38321. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  38322. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  38323. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  38324. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  38325. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  38326. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  38327. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  38328. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  38329. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  38330. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  38331. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  38332. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  38333. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  38334. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  38335. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  38336. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  38337. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  38338. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  38339. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  38340. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  38341. -----END CERTIFICATE-----
  38342. Amazon Root CA 1
  38343. ================
  38344. -----BEGIN CERTIFICATE-----
  38345. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  38346. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  38347. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  38348. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  38349. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  38350. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  38351. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  38352. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  38353. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  38354. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  38355. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  38356. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  38357. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  38358. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  38359. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  38360. -----END CERTIFICATE-----
  38361. Amazon Root CA 2
  38362. ================
  38363. -----BEGIN CERTIFICATE-----
  38364. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  38365. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  38366. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  38367. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  38368. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  38369. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  38370. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  38371. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  38372. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  38373. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  38374. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  38375. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  38376. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  38377. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  38378. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  38379. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  38380. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  38381. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  38382. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  38383. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  38384. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  38385. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  38386. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  38387. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  38388. -----END CERTIFICATE-----
  38389. Amazon Root CA 3
  38390. ================
  38391. -----BEGIN CERTIFICATE-----
  38392. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  38393. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  38394. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38395. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  38396. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  38397. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  38398. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  38399. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  38400. -----END CERTIFICATE-----
  38401. Amazon Root CA 4
  38402. ================
  38403. -----BEGIN CERTIFICATE-----
  38404. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  38405. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  38406. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38407. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  38408. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  38409. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  38410. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  38411. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  38412. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  38413. -----END CERTIFICATE-----
  38414. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  38415. =============================================
  38416. -----BEGIN CERTIFICATE-----
  38417. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  38418. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  38419. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  38420. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  38421. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  38422. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  38423. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  38424. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  38425. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  38426. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  38427. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  38428. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  38429. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  38430. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  38431. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  38432. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  38433. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  38434. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  38435. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  38436. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  38437. -----END CERTIFICATE-----
  38438. GDCA TrustAUTH R5 ROOT
  38439. ======================
  38440. -----BEGIN CERTIFICATE-----
  38441. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  38442. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  38443. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  38444. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  38445. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  38446. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  38447. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  38448. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  38449. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  38450. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  38451. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  38452. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  38453. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  38454. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  38455. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  38456. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  38457. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  38458. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  38459. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  38460. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  38461. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  38462. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  38463. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  38464. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  38465. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  38466. -----END CERTIFICATE-----
  38467. TrustCor RootCert CA-1
  38468. ======================
  38469. -----BEGIN CERTIFICATE-----
  38470. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  38471. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38472. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38473. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  38474. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  38475. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  38476. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  38477. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  38478. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  38479. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  38480. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  38481. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  38482. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  38483. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  38484. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  38485. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  38486. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  38487. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  38488. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  38489. -----END CERTIFICATE-----
  38490. TrustCor RootCert CA-2
  38491. ======================
  38492. -----BEGIN CERTIFICATE-----
  38493. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  38494. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  38495. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  38496. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  38497. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  38498. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  38499. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  38500. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  38501. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  38502. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  38503. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  38504. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  38505. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  38506. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  38507. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  38508. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  38509. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  38510. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  38511. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  38512. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  38513. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  38514. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  38515. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  38516. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  38517. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  38518. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  38519. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  38520. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  38521. -----END CERTIFICATE-----
  38522. TrustCor ECA-1
  38523. ==============
  38524. -----BEGIN CERTIFICATE-----
  38525. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  38526. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38527. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38528. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  38529. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  38530. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  38531. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  38532. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  38533. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  38534. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  38535. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  38536. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  38537. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  38538. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  38539. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  38540. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  38541. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  38542. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  38543. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  38544. -----END CERTIFICATE-----
  38545. SSL.com Root Certification Authority RSA
  38546. ========================================
  38547. -----BEGIN CERTIFICATE-----
  38548. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  38549. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  38550. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  38551. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38552. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  38553. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  38554. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  38555. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  38556. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  38557. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  38558. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  38559. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  38560. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  38561. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  38562. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  38563. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  38564. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  38565. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  38566. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  38567. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  38568. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  38569. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  38570. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  38571. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  38572. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  38573. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  38574. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  38575. -----END CERTIFICATE-----
  38576. SSL.com Root Certification Authority ECC
  38577. ========================================
  38578. -----BEGIN CERTIFICATE-----
  38579. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  38580. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  38581. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  38582. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  38583. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  38584. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  38585. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  38586. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  38587. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  38588. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  38589. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  38590. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  38591. -----END CERTIFICATE-----
  38592. SSL.com EV Root Certification Authority RSA R2
  38593. ==============================================
  38594. -----BEGIN CERTIFICATE-----
  38595. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  38596. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  38597. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  38598. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  38599. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  38600. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  38601. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  38602. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  38603. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  38604. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  38605. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  38606. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  38607. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  38608. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  38609. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  38610. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  38611. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  38612. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  38613. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  38614. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  38615. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  38616. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  38617. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  38618. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  38619. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  38620. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  38621. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  38622. -----END CERTIFICATE-----
  38623. SSL.com EV Root Certification Authority ECC
  38624. ===========================================
  38625. -----BEGIN CERTIFICATE-----
  38626. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  38627. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  38628. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  38629. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38630. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  38631. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  38632. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  38633. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  38634. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  38635. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  38636. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  38637. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  38638. -----END CERTIFICATE-----
  38639. GlobalSign Root CA - R6
  38640. =======================
  38641. -----BEGIN CERTIFICATE-----
  38642. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  38643. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  38644. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  38645. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  38646. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  38647. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  38648. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  38649. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  38650. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  38651. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  38652. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  38653. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  38654. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  38655. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  38656. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  38657. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  38658. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  38659. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  38660. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  38661. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  38662. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  38663. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  38664. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  38665. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  38666. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  38667. -----END CERTIFICATE-----
  38668. OISTE WISeKey Global Root GC CA
  38669. ===============================
  38670. -----BEGIN CERTIFICATE-----
  38671. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  38672. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  38673. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  38674. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  38675. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  38676. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  38677. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  38678. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  38679. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  38680. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  38681. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  38682. -----END CERTIFICATE-----
  38683. GTS Root R1
  38684. ===========
  38685. -----BEGIN CERTIFICATE-----
  38686. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38687. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38688. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38689. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  38690. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  38691. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  38692. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  38693. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  38694. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  38695. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  38696. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  38697. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  38698. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  38699. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38700. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  38701. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  38702. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  38703. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  38704. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  38705. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  38706. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  38707. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  38708. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  38709. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  38710. CFF1pkgl
  38711. -----END CERTIFICATE-----
  38712. GTS Root R2
  38713. ===========
  38714. -----BEGIN CERTIFICATE-----
  38715. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38716. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38717. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38718. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  38719. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  38720. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  38721. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  38722. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  38723. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  38724. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  38725. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  38726. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  38727. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  38728. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38729. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  38730. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  38731. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  38732. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  38733. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  38734. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  38735. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  38736. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  38737. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  38738. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  38739. o/DUhgkC
  38740. -----END CERTIFICATE-----
  38741. GTS Root R3
  38742. ===========
  38743. -----BEGIN CERTIFICATE-----
  38744. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38745. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38746. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38747. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  38748. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  38749. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  38750. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  38751. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  38752. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  38753. KaqW04MjyaR7YbPMAuhd
  38754. -----END CERTIFICATE-----
  38755. GTS Root R4
  38756. ===========
  38757. -----BEGIN CERTIFICATE-----
  38758. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38759. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38760. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38761. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  38762. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  38763. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  38764. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  38765. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  38766. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  38767. zPKwTdb+mciUqXWi4w==
  38768. -----END CERTIFICATE-----
  38769. UCA Global G2 Root
  38770. ==================
  38771. -----BEGIN CERTIFICATE-----
  38772. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  38773. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  38774. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  38775. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  38776. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  38777. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  38778. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  38779. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  38780. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  38781. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  38782. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  38783. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  38784. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  38785. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  38786. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  38787. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  38788. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  38789. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  38790. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  38791. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  38792. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  38793. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  38794. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  38795. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  38796. -----END CERTIFICATE-----
  38797. UCA Extended Validation Root
  38798. ============================
  38799. -----BEGIN CERTIFICATE-----
  38800. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  38801. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  38802. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  38803. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  38804. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  38805. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  38806. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  38807. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  38808. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  38809. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  38810. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  38811. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  38812. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  38813. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  38814. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  38815. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  38816. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  38817. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  38818. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  38819. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  38820. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  38821. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  38822. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  38823. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  38824. dhh2n1ax
  38825. -----END CERTIFICATE-----
  38826. Certigna Root CA
  38827. ================
  38828. -----BEGIN CERTIFICATE-----
  38829. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  38830. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  38831. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  38832. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  38833. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  38834. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  38835. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  38836. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  38837. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  38838. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  38839. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  38840. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  38841. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  38842. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  38843. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  38844. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  38845. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  38846. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  38847. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  38848. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  38849. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  38850. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  38851. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  38852. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  38853. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  38854. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  38855. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  38856. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  38857. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  38858. -----END CERTIFICATE-----
  38859. emSign Root CA - G1
  38860. ===================
  38861. -----BEGIN CERTIFICATE-----
  38862. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  38863. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  38864. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  38865. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  38866. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  38867. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  38868. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  38869. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  38870. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  38871. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  38872. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  38873. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  38874. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  38875. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  38876. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  38877. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  38878. iN66zB+Afko=
  38879. -----END CERTIFICATE-----
  38880. emSign ECC Root CA - G3
  38881. =======================
  38882. -----BEGIN CERTIFICATE-----
  38883. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  38884. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  38885. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  38886. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  38887. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  38888. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  38889. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  38890. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  38891. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  38892. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  38893. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  38894. -----END CERTIFICATE-----
  38895. emSign Root CA - C1
  38896. ===================
  38897. -----BEGIN CERTIFICATE-----
  38898. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  38899. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  38900. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  38901. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  38902. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  38903. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  38904. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  38905. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  38906. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  38907. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  38908. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  38909. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  38910. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  38911. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  38912. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  38913. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  38914. -----END CERTIFICATE-----
  38915. emSign ECC Root CA - C3
  38916. =======================
  38917. -----BEGIN CERTIFICATE-----
  38918. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  38919. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  38920. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  38921. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  38922. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  38923. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  38924. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  38925. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  38926. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  38927. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  38928. -----END CERTIFICATE-----
  38929. Hongkong Post Root CA 3
  38930. =======================
  38931. -----BEGIN CERTIFICATE-----
  38932. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  38933. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  38934. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  38935. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  38936. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  38937. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  38938. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  38939. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  38940. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  38941. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  38942. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  38943. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  38944. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  38945. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  38946. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  38947. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  38948. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  38949. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  38950. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  38951. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  38952. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  38953. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  38954. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  38955. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  38956. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  38957. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  38958. dBb9HxEGmpv0
  38959. -----END CERTIFICATE-----
  38960. Entrust Root Certification Authority - G4
  38961. =========================================
  38962. -----BEGIN CERTIFICATE-----
  38963. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  38964. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  38965. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  38966. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  38967. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  38968. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  38969. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  38970. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  38971. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  38972. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  38973. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  38974. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  38975. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  38976. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  38977. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  38978. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  38979. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  38980. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  38981. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  38982. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  38983. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  38984. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  38985. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  38986. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  38987. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  38988. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  38989. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  38990. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  38991. kcpG2om3PVODLAgfi49T3f+sHw==
  38992. -----END CERTIFICATE-----
  38993. Microsoft ECC Root Certificate Authority 2017
  38994. =============================================
  38995. -----BEGIN CERTIFICATE-----
  38996. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  38997. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  38998. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  38999. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  39000. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  39001. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  39002. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  39003. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  39004. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  39005. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  39006. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  39007. -----END CERTIFICATE-----
  39008. Microsoft RSA Root Certificate Authority 2017
  39009. =============================================
  39010. -----BEGIN CERTIFICATE-----
  39011. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  39012. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  39013. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  39014. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  39015. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  39016. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  39017. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  39018. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  39019. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  39020. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  39021. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  39022. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  39023. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  39024. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  39025. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  39026. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  39027. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  39028. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  39029. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  39030. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  39031. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  39032. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  39033. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  39034. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  39035. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  39036. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  39037. -----END CERTIFICATE-----
  39038. e-Szigno Root CA 2017
  39039. =====================
  39040. -----BEGIN CERTIFICATE-----
  39041. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  39042. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  39043. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  39044. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  39045. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  39046. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  39047. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  39048. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  39049. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  39050. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  39051. svxyqltZ+efcMQ==
  39052. -----END CERTIFICATE-----
  39053. certSIGN Root CA G2
  39054. ===================
  39055. -----BEGIN CERTIFICATE-----
  39056. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  39057. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  39058. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  39059. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  39060. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  39061. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  39062. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  39063. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  39064. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  39065. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  39066. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  39067. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  39068. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  39069. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  39070. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  39071. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  39072. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  39073. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  39074. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  39075. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  39076. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  39077. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  39078. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  39079. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  39080. -----END CERTIFICATE-----
  39081. Trustwave Global Certification Authority
  39082. ========================================
  39083. -----BEGIN CERTIFICATE-----
  39084. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  39085. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  39086. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  39087. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  39088. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  39089. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  39090. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  39091. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  39092. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  39093. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  39094. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  39095. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  39096. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  39097. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  39098. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  39099. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  39100. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  39101. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  39102. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  39103. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  39104. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  39105. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  39106. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  39107. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  39108. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  39109. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  39110. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  39111. -----END CERTIFICATE-----
  39112. Trustwave Global ECC P256 Certification Authority
  39113. =================================================
  39114. -----BEGIN CERTIFICATE-----
  39115. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  39116. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  39117. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  39118. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  39119. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  39120. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  39121. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  39122. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  39123. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  39124. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  39125. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  39126. -----END CERTIFICATE-----
  39127. Trustwave Global ECC P384 Certification Authority
  39128. =================================================
  39129. -----BEGIN CERTIFICATE-----
  39130. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  39131. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  39132. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  39133. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  39134. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  39135. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  39136. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  39137. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  39138. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  39139. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  39140. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  39141. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  39142. -----END CERTIFICATE-----
  39143. <?php
  39144. namespace Composer\CaBundle;
  39145. use Psr\Log\LoggerInterface;
  39146. use Symfony\Component\Process\PhpProcess;
  39147. class CaBundle
  39148. {
  39149. private static $caPath;
  39150. private static $caFileValidity = array();
  39151. private static $useOpensslParse;
  39152. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  39153. {
  39154. if (self::$caPath !== null) {
  39155. return self::$caPath;
  39156. }
  39157. $caBundlePaths = array();
  39158. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  39159. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  39160. $caBundlePaths[] = ini_get('openssl.cafile');
  39161. $caBundlePaths[] = ini_get('openssl.capath');
  39162. $otherLocations = array(
  39163. '/etc/pki/tls/certs/ca-bundle.crt',
  39164. '/etc/ssl/certs/ca-certificates.crt',
  39165. '/etc/ssl/ca-bundle.pem',
  39166. '/usr/local/share/certs/ca-root-nss.crt',
  39167. '/usr/ssl/certs/ca-bundle.crt',
  39168. '/opt/local/share/curl/curl-ca-bundle.crt',
  39169. '/usr/local/share/curl/curl-ca-bundle.crt',
  39170. '/usr/share/ssl/certs/ca-bundle.crt',
  39171. '/etc/ssl/cert.pem',
  39172. '/usr/local/etc/ssl/cert.pem',
  39173. '/usr/local/etc/openssl/cert.pem',
  39174. '/usr/local/etc/openssl@1.1/cert.pem',
  39175. );
  39176. foreach($otherLocations as $location) {
  39177. $otherLocations[] = dirname($location);
  39178. }
  39179. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  39180. foreach ($caBundlePaths as $caBundle) {
  39181. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  39182. return self::$caPath = $caBundle;
  39183. }
  39184. if ($caBundle && self::caDirUsable($caBundle)) {
  39185. return self::$caPath = $caBundle;
  39186. }
  39187. }
  39188. return self::$caPath = static::getBundledCaBundlePath();
  39189. }
  39190. public static function getBundledCaBundlePath()
  39191. {
  39192. $caBundleFile = __DIR__.'/../res/cacert.pem';
  39193. if (0 === strpos($caBundleFile, 'phar://')) {
  39194. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  39195. if (false === $tempCaBundleFile) {
  39196. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  39197. }
  39198. file_put_contents(
  39199. $tempCaBundleFile,
  39200. file_get_contents($caBundleFile)
  39201. );
  39202. register_shutdown_function(function() use ($tempCaBundleFile) {
  39203. @unlink($tempCaBundleFile);
  39204. });
  39205. $caBundleFile = $tempCaBundleFile;
  39206. }
  39207. return $caBundleFile;
  39208. }
  39209. public static function validateCaFile($filename, LoggerInterface $logger = null)
  39210. {
  39211. static $warned = false;
  39212. if (isset(self::$caFileValidity[$filename])) {
  39213. return self::$caFileValidity[$filename];
  39214. }
  39215. $contents = file_get_contents($filename);
  39216. if (!static::isOpensslParseSafe()) {
  39217. if (!$warned && $logger) {
  39218. $logger->warning(sprintf(
  39219. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  39220. PHP_VERSION
  39221. ));
  39222. $warned = true;
  39223. }
  39224. $isValid = !empty($contents);
  39225. } elseif (is_string($contents) && strlen($contents) > 0) {
  39226. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  39227. if (null === $contents) {
  39228. $isValid = false;
  39229. } else {
  39230. $isValid = (bool) openssl_x509_parse($contents);
  39231. }
  39232. } else {
  39233. $isValid = false;
  39234. }
  39235. if ($logger) {
  39236. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  39237. }
  39238. return self::$caFileValidity[$filename] = $isValid;
  39239. }
  39240. public static function isOpensslParseSafe()
  39241. {
  39242. if (null !== self::$useOpensslParse) {
  39243. return self::$useOpensslParse;
  39244. }
  39245. if (PHP_VERSION_ID >= 50600) {
  39246. return self::$useOpensslParse = true;
  39247. }
  39248. if (
  39249. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  39250. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  39251. || PHP_VERSION_ID >= 50507
  39252. ) {
  39253. return self::$useOpensslParse = true;
  39254. }
  39255. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  39256. return self::$useOpensslParse = false;
  39257. }
  39258. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  39259. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  39260. if (preg_match($regex, PHP_VERSION, $m)) {
  39261. return ((int) $m[1]) >= $fixedVersion;
  39262. }
  39263. return false;
  39264. };
  39265. if (
  39266. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  39267. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  39268. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  39269. ) {
  39270. return self::$useOpensslParse = true;
  39271. }
  39272. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  39273. return self::$useOpensslParse = false;
  39274. }
  39275. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  39276. $script = <<<'EOT'
  39277. error_reporting(-1);
  39278. $info = openssl_x509_parse(base64_decode('%s'));
  39279. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  39280. EOT;
  39281. $script = '<'."?php\n".sprintf($script, $cert);
  39282. try {
  39283. $process = new PhpProcess($script);
  39284. $process->mustRun();
  39285. } catch (\Exception $e) {
  39286. return self::$useOpensslParse = false;
  39287. }
  39288. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  39289. $errorOutput = trim($process->getErrorOutput());
  39290. if (
  39291. is_array($output)
  39292. && count($output) === 3
  39293. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  39294. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  39295. && $output[2] === 'int(-1)'
  39296. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  39297. ) {
  39298. return self::$useOpensslParse = true;
  39299. }
  39300. return self::$useOpensslParse = false;
  39301. }
  39302. public static function reset()
  39303. {
  39304. self::$caFileValidity = array();
  39305. self::$caPath = null;
  39306. self::$useOpensslParse = null;
  39307. }
  39308. private static function getEnvVariable($name)
  39309. {
  39310. if (isset($_SERVER[$name])) {
  39311. return (string) $_SERVER[$name];
  39312. }
  39313. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  39314. return (string) $value;
  39315. }
  39316. return false;
  39317. }
  39318. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  39319. {
  39320. return $certFile && @is_file($certFile) && @is_readable($certFile) && static::validateCaFile($certFile, $logger);
  39321. }
  39322. private static function caDirUsable($certDir)
  39323. {
  39324. return $certDir && @is_dir($certDir) && @is_readable($certDir) && glob($certDir . '/*');
  39325. }
  39326. }
  39327. <?php return array (
  39328. 'root' =>
  39329. array (
  39330. 'pretty_version' => '2.0.12',
  39331. 'version' => '2.0.12.0',
  39332. 'aliases' =>
  39333. array (
  39334. ),
  39335. 'reference' => '6c12ce263da71641903e399c3ce8ecb08fd375fb',
  39336. 'name' => 'composer/composer',
  39337. ),
  39338. 'versions' =>
  39339. array (
  39340. 'composer/ca-bundle' =>
  39341. array (
  39342. 'pretty_version' => '1.2.9',
  39343. 'version' => '1.2.9.0',
  39344. 'aliases' =>
  39345. array (
  39346. ),
  39347. 'reference' => '78a0e288fdcebf92aa2318a8d3656168da6ac1a5',
  39348. ),
  39349. 'composer/composer' =>
  39350. array (
  39351. 'pretty_version' => '2.0.12',
  39352. 'version' => '2.0.12.0',
  39353. 'aliases' =>
  39354. array (
  39355. ),
  39356. 'reference' => '6c12ce263da71641903e399c3ce8ecb08fd375fb',
  39357. ),
  39358. 'composer/semver' =>
  39359. array (
  39360. 'pretty_version' => '3.2.4',
  39361. 'version' => '3.2.4.0',
  39362. 'aliases' =>
  39363. array (
  39364. ),
  39365. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  39366. ),
  39367. 'composer/spdx-licenses' =>
  39368. array (
  39369. 'pretty_version' => '1.5.5',
  39370. 'version' => '1.5.5.0',
  39371. 'aliases' =>
  39372. array (
  39373. ),
  39374. 'reference' => 'de30328a7af8680efdc03e396aad24befd513200',
  39375. ),
  39376. 'composer/xdebug-handler' =>
  39377. array (
  39378. 'pretty_version' => '1.4.5',
  39379. 'version' => '1.4.5.0',
  39380. 'aliases' =>
  39381. array (
  39382. ),
  39383. 'reference' => 'f28d44c286812c714741478d968104c5e604a1d4',
  39384. ),
  39385. 'justinrainbow/json-schema' =>
  39386. array (
  39387. 'pretty_version' => '5.2.10',
  39388. 'version' => '5.2.10.0',
  39389. 'aliases' =>
  39390. array (
  39391. ),
  39392. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  39393. ),
  39394. 'psr/log' =>
  39395. array (
  39396. 'pretty_version' => '1.1.3',
  39397. 'version' => '1.1.3.0',
  39398. 'aliases' =>
  39399. array (
  39400. ),
  39401. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  39402. ),
  39403. 'react/promise' =>
  39404. array (
  39405. 'pretty_version' => 'v1.2.1',
  39406. 'version' => '1.2.1.0',
  39407. 'aliases' =>
  39408. array (
  39409. ),
  39410. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  39411. ),
  39412. 'seld/jsonlint' =>
  39413. array (
  39414. 'pretty_version' => '1.8.3',
  39415. 'version' => '1.8.3.0',
  39416. 'aliases' =>
  39417. array (
  39418. ),
  39419. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  39420. ),
  39421. 'seld/phar-utils' =>
  39422. array (
  39423. 'pretty_version' => '1.1.1',
  39424. 'version' => '1.1.1.0',
  39425. 'aliases' =>
  39426. array (
  39427. ),
  39428. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  39429. ),
  39430. 'symfony/console' =>
  39431. array (
  39432. 'pretty_version' => 'v2.8.52',
  39433. 'version' => '2.8.52.0',
  39434. 'aliases' =>
  39435. array (
  39436. ),
  39437. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  39438. ),
  39439. 'symfony/debug' =>
  39440. array (
  39441. 'pretty_version' => 'v2.8.52',
  39442. 'version' => '2.8.52.0',
  39443. 'aliases' =>
  39444. array (
  39445. ),
  39446. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  39447. ),
  39448. 'symfony/filesystem' =>
  39449. array (
  39450. 'pretty_version' => 'v2.8.52',
  39451. 'version' => '2.8.52.0',
  39452. 'aliases' =>
  39453. array (
  39454. ),
  39455. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  39456. ),
  39457. 'symfony/finder' =>
  39458. array (
  39459. 'pretty_version' => 'v2.8.52',
  39460. 'version' => '2.8.52.0',
  39461. 'aliases' =>
  39462. array (
  39463. ),
  39464. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  39465. ),
  39466. 'symfony/polyfill-ctype' =>
  39467. array (
  39468. 'pretty_version' => 'v1.19.0',
  39469. 'version' => '1.19.0.0',
  39470. 'aliases' =>
  39471. array (
  39472. ),
  39473. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  39474. ),
  39475. 'symfony/polyfill-mbstring' =>
  39476. array (
  39477. 'pretty_version' => 'v1.19.0',
  39478. 'version' => '1.19.0.0',
  39479. 'aliases' =>
  39480. array (
  39481. ),
  39482. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  39483. ),
  39484. 'symfony/process' =>
  39485. array (
  39486. 'pretty_version' => 'v2.8.52',
  39487. 'version' => '2.8.52.0',
  39488. 'aliases' =>
  39489. array (
  39490. ),
  39491. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  39492. ),
  39493. ),
  39494. );
  39495. Copyright (C) 2015 Composer
  39496. Permission is hereby granted, free of charge, to any person obtaining a copy of
  39497. this software and associated documentation files (the "Software"), to deal in
  39498. the Software without restriction, including without limitation the rights to
  39499. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  39500. of the Software, and to permit persons to whom the Software is furnished to do
  39501. so, subject to the following conditions:
  39502. The above copyright notice and this permission notice shall be included in all
  39503. copies or substantial portions of the Software.
  39504. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39505. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  39506. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  39507. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39508. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39509. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  39510. SOFTWARE.
  39511. <?php
  39512. namespace Composer\Semver;
  39513. use Composer\Semver\Constraint\Constraint;
  39514. class Comparator
  39515. {
  39516. public static function greaterThan($version1, $version2)
  39517. {
  39518. return self::compare($version1, '>', $version2);
  39519. }
  39520. public static function greaterThanOrEqualTo($version1, $version2)
  39521. {
  39522. return self::compare($version1, '>=', $version2);
  39523. }
  39524. public static function lessThan($version1, $version2)
  39525. {
  39526. return self::compare($version1, '<', $version2);
  39527. }
  39528. public static function lessThanOrEqualTo($version1, $version2)
  39529. {
  39530. return self::compare($version1, '<=', $version2);
  39531. }
  39532. public static function equalTo($version1, $version2)
  39533. {
  39534. return self::compare($version1, '==', $version2);
  39535. }
  39536. public static function notEqualTo($version1, $version2)
  39537. {
  39538. return self::compare($version1, '!=', $version2);
  39539. }
  39540. public static function compare($version1, $operator, $version2)
  39541. {
  39542. $constraint = new Constraint($operator, $version2);
  39543. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  39544. }
  39545. }
  39546. <?php
  39547. namespace Composer\Semver;
  39548. use Composer\Semver\Constraint\Constraint;
  39549. use Composer\Semver\Constraint\ConstraintInterface;
  39550. class CompilingMatcher
  39551. {
  39552. private static $compiledCheckerCache = array();
  39553. private static $enabled;
  39554. private static $transOpInt = array(
  39555. Constraint::OP_EQ => '==',
  39556. Constraint::OP_LT => '<',
  39557. Constraint::OP_LE => '<=',
  39558. Constraint::OP_GT => '>',
  39559. Constraint::OP_GE => '>=',
  39560. Constraint::OP_NE => '!=',
  39561. );
  39562. public static function match(ConstraintInterface $constraint, $operator, $version)
  39563. {
  39564. if (self::$enabled === null) {
  39565. self::$enabled = !\in_array('eval', explode(',', ini_get('disable_functions')), true);
  39566. }
  39567. if (!self::$enabled) {
  39568. return $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  39569. }
  39570. $cacheKey = $operator.$constraint;
  39571. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  39572. $code = $constraint->compile($operator);
  39573. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  39574. } else {
  39575. $function = self::$compiledCheckerCache[$cacheKey];
  39576. }
  39577. return $function($version, strpos($version, 'dev-') === 0);
  39578. }
  39579. }
  39580. <?php
  39581. namespace Composer\Semver\Constraint;
  39582. class Bound
  39583. {
  39584. private $version;
  39585. private $isInclusive;
  39586. public function __construct($version, $isInclusive)
  39587. {
  39588. $this->version = $version;
  39589. $this->isInclusive = $isInclusive;
  39590. }
  39591. public function getVersion()
  39592. {
  39593. return $this->version;
  39594. }
  39595. public function isInclusive()
  39596. {
  39597. return $this->isInclusive;
  39598. }
  39599. public function isZero()
  39600. {
  39601. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  39602. }
  39603. public function isPositiveInfinity()
  39604. {
  39605. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  39606. }
  39607. public function compareTo(Bound $other, $operator)
  39608. {
  39609. if (!\in_array($operator, array('<', '>'), true)) {
  39610. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  39611. }
  39612. if ($this == $other) {
  39613. return false;
  39614. }
  39615. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  39616. if (0 !== $compareResult) {
  39617. return (('>' === $operator) ? 1 : -1) === $compareResult;
  39618. }
  39619. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  39620. }
  39621. public function __toString()
  39622. {
  39623. return sprintf(
  39624. '%s [%s]',
  39625. $this->getVersion(),
  39626. $this->isInclusive() ? 'inclusive' : 'exclusive'
  39627. );
  39628. }
  39629. public static function zero()
  39630. {
  39631. return new Bound('0.0.0.0-dev', true);
  39632. }
  39633. public static function positiveInfinity()
  39634. {
  39635. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  39636. }
  39637. }
  39638. <?php
  39639. namespace Composer\Semver\Constraint;
  39640. class Constraint implements ConstraintInterface
  39641. {
  39642. const OP_EQ = 0;
  39643. const OP_LT = 1;
  39644. const OP_LE = 2;
  39645. const OP_GT = 3;
  39646. const OP_GE = 4;
  39647. const OP_NE = 5;
  39648. private static $transOpStr = array(
  39649. '=' => self::OP_EQ,
  39650. '==' => self::OP_EQ,
  39651. '<' => self::OP_LT,
  39652. '<=' => self::OP_LE,
  39653. '>' => self::OP_GT,
  39654. '>=' => self::OP_GE,
  39655. '<>' => self::OP_NE,
  39656. '!=' => self::OP_NE,
  39657. );
  39658. private static $transOpInt = array(
  39659. self::OP_EQ => '==',
  39660. self::OP_LT => '<',
  39661. self::OP_LE => '<=',
  39662. self::OP_GT => '>',
  39663. self::OP_GE => '>=',
  39664. self::OP_NE => '!=',
  39665. );
  39666. protected $operator;
  39667. protected $version;
  39668. protected $prettyString;
  39669. protected $lowerBound;
  39670. protected $upperBound;
  39671. public function __construct($operator, $version)
  39672. {
  39673. if (!isset(self::$transOpStr[$operator])) {
  39674. throw new \InvalidArgumentException(sprintf(
  39675. 'Invalid operator "%s" given, expected one of: %s',
  39676. $operator,
  39677. implode(', ', self::getSupportedOperators())
  39678. ));
  39679. }
  39680. $this->operator = self::$transOpStr[$operator];
  39681. $this->version = $version;
  39682. }
  39683. public function getVersion()
  39684. {
  39685. return $this->version;
  39686. }
  39687. public function getOperator()
  39688. {
  39689. return self::$transOpInt[$this->operator];
  39690. }
  39691. public function matches(ConstraintInterface $provider)
  39692. {
  39693. if ($provider instanceof self) {
  39694. return $this->matchSpecific($provider);
  39695. }
  39696. return $provider->matches($this);
  39697. }
  39698. public function setPrettyString($prettyString)
  39699. {
  39700. $this->prettyString = $prettyString;
  39701. }
  39702. public function getPrettyString()
  39703. {
  39704. if ($this->prettyString) {
  39705. return $this->prettyString;
  39706. }
  39707. return $this->__toString();
  39708. }
  39709. public static function getSupportedOperators()
  39710. {
  39711. return array_keys(self::$transOpStr);
  39712. }
  39713. public static function getOperatorConstant($operator)
  39714. {
  39715. return self::$transOpStr[$operator];
  39716. }
  39717. public function versionCompare($a, $b, $operator, $compareBranches = false)
  39718. {
  39719. if (!isset(self::$transOpStr[$operator])) {
  39720. throw new \InvalidArgumentException(sprintf(
  39721. 'Invalid operator "%s" given, expected one of: %s',
  39722. $operator,
  39723. implode(', ', self::getSupportedOperators())
  39724. ));
  39725. }
  39726. $aIsBranch = strpos($a, 'dev-') === 0;
  39727. $bIsBranch = strpos($b, 'dev-') === 0;
  39728. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  39729. return $a !== $b;
  39730. }
  39731. if ($aIsBranch && $bIsBranch) {
  39732. return $operator === '==' && $a === $b;
  39733. }
  39734. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  39735. return false;
  39736. }
  39737. return \version_compare($a, $b, $operator);
  39738. }
  39739. public function compile($otherOperator)
  39740. {
  39741. if (strpos($this->version, 'dev-') === 0) {
  39742. if (self::OP_EQ === $this->operator) {
  39743. if (self::OP_EQ === $otherOperator) {
  39744. return sprintf('$b && $v === %s', \var_export($this->version, true));
  39745. }
  39746. if (self::OP_NE === $otherOperator) {
  39747. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39748. }
  39749. return 'false';
  39750. }
  39751. if (self::OP_NE === $this->operator) {
  39752. if (self::OP_EQ === $otherOperator) {
  39753. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39754. }
  39755. if (self::OP_NE === $otherOperator) {
  39756. return 'true';
  39757. }
  39758. return '!$b';
  39759. }
  39760. return 'false';
  39761. }
  39762. if (self::OP_EQ === $this->operator) {
  39763. if (self::OP_EQ === $otherOperator) {
  39764. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  39765. }
  39766. if (self::OP_NE === $otherOperator) {
  39767. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  39768. }
  39769. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  39770. }
  39771. if (self::OP_NE === $this->operator) {
  39772. if (self::OP_EQ === $otherOperator) {
  39773. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  39774. }
  39775. if (self::OP_NE === $otherOperator) {
  39776. return 'true';
  39777. }
  39778. return '!$b';
  39779. }
  39780. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  39781. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  39782. return '!$b';
  39783. }
  39784. } elseif (self::OP_GT === $this->operator || self::OP_GE === $this->operator) {
  39785. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  39786. return '!$b';
  39787. }
  39788. }
  39789. if (self::OP_NE === $otherOperator) {
  39790. return 'true';
  39791. }
  39792. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  39793. if ($this->operator === self::OP_LE) {
  39794. if ($otherOperator === self::OP_GT) {
  39795. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39796. }
  39797. } elseif ($this->operator === self::OP_GE) {
  39798. if ($otherOperator === self::OP_LT) {
  39799. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39800. }
  39801. }
  39802. return sprintf('!$b && %s', $codeComparison);
  39803. }
  39804. public function matchSpecific(Constraint $provider, $compareBranches = false)
  39805. {
  39806. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  39807. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  39808. $isEqualOp = self::OP_EQ === $this->operator;
  39809. $isNonEqualOp = self::OP_NE === $this->operator;
  39810. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  39811. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  39812. if ($isNonEqualOp || $isProviderNonEqualOp) {
  39813. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  39814. return false;
  39815. }
  39816. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  39817. return false;
  39818. }
  39819. if (!$isEqualOp && !$isProviderEqualOp) {
  39820. return true;
  39821. }
  39822. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  39823. }
  39824. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  39825. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  39826. }
  39827. $version1 = $isEqualOp ? $this->version : $provider->version;
  39828. $version2 = $isEqualOp ? $provider->version : $this->version;
  39829. $operator = $isEqualOp ? $provider->operator : $this->operator;
  39830. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  39831. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  39832. && self::$transOpInt[$this->operator] !== $noEqualOp
  39833. && \version_compare($provider->version, $this->version, '=='));
  39834. }
  39835. return false;
  39836. }
  39837. public function __toString()
  39838. {
  39839. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  39840. }
  39841. public function getLowerBound()
  39842. {
  39843. $this->extractBounds();
  39844. return $this->lowerBound;
  39845. }
  39846. public function getUpperBound()
  39847. {
  39848. $this->extractBounds();
  39849. return $this->upperBound;
  39850. }
  39851. private function extractBounds()
  39852. {
  39853. if (null !== $this->lowerBound) {
  39854. return;
  39855. }
  39856. if (strpos($this->version, 'dev-') === 0) {
  39857. $this->lowerBound = Bound::zero();
  39858. $this->upperBound = Bound::positiveInfinity();
  39859. return;
  39860. }
  39861. switch ($this->operator) {
  39862. case self::OP_EQ:
  39863. $this->lowerBound = new Bound($this->version, true);
  39864. $this->upperBound = new Bound($this->version, true);
  39865. break;
  39866. case self::OP_LT:
  39867. $this->lowerBound = Bound::zero();
  39868. $this->upperBound = new Bound($this->version, false);
  39869. break;
  39870. case self::OP_LE:
  39871. $this->lowerBound = Bound::zero();
  39872. $this->upperBound = new Bound($this->version, true);
  39873. break;
  39874. case self::OP_GT:
  39875. $this->lowerBound = new Bound($this->version, false);
  39876. $this->upperBound = Bound::positiveInfinity();
  39877. break;
  39878. case self::OP_GE:
  39879. $this->lowerBound = new Bound($this->version, true);
  39880. $this->upperBound = Bound::positiveInfinity();
  39881. break;
  39882. case self::OP_NE:
  39883. $this->lowerBound = Bound::zero();
  39884. $this->upperBound = Bound::positiveInfinity();
  39885. break;
  39886. }
  39887. }
  39888. }
  39889. <?php
  39890. namespace Composer\Semver\Constraint;
  39891. interface ConstraintInterface
  39892. {
  39893. public function matches(ConstraintInterface $provider);
  39894. public function compile($operator);
  39895. public function getUpperBound();
  39896. public function getLowerBound();
  39897. public function getPrettyString();
  39898. public function setPrettyString($prettyString);
  39899. public function __toString();
  39900. }
  39901. <?php
  39902. namespace Composer\Semver\Constraint;
  39903. class MatchAllConstraint implements ConstraintInterface
  39904. {
  39905. protected $prettyString;
  39906. public function matches(ConstraintInterface $provider)
  39907. {
  39908. return true;
  39909. }
  39910. public function compile($operator)
  39911. {
  39912. return 'true';
  39913. }
  39914. public function setPrettyString($prettyString)
  39915. {
  39916. $this->prettyString = $prettyString;
  39917. }
  39918. public function getPrettyString()
  39919. {
  39920. if ($this->prettyString) {
  39921. return $this->prettyString;
  39922. }
  39923. return (string) $this;
  39924. }
  39925. public function __toString()
  39926. {
  39927. return '*';
  39928. }
  39929. public function getUpperBound()
  39930. {
  39931. return Bound::positiveInfinity();
  39932. }
  39933. public function getLowerBound()
  39934. {
  39935. return Bound::zero();
  39936. }
  39937. }
  39938. <?php
  39939. namespace Composer\Semver\Constraint;
  39940. class MatchNoneConstraint implements ConstraintInterface
  39941. {
  39942. protected $prettyString;
  39943. public function matches(ConstraintInterface $provider)
  39944. {
  39945. return false;
  39946. }
  39947. public function compile($operator)
  39948. {
  39949. return 'false';
  39950. }
  39951. public function setPrettyString($prettyString)
  39952. {
  39953. $this->prettyString = $prettyString;
  39954. }
  39955. public function getPrettyString()
  39956. {
  39957. if ($this->prettyString) {
  39958. return $this->prettyString;
  39959. }
  39960. return (string) $this;
  39961. }
  39962. public function __toString()
  39963. {
  39964. return '[]';
  39965. }
  39966. public function getUpperBound()
  39967. {
  39968. return new Bound('0.0.0.0-dev', false);
  39969. }
  39970. public function getLowerBound()
  39971. {
  39972. return new Bound('0.0.0.0-dev', false);
  39973. }
  39974. }
  39975. <?php
  39976. namespace Composer\Semver\Constraint;
  39977. class MultiConstraint implements ConstraintInterface
  39978. {
  39979. protected $constraints;
  39980. protected $prettyString;
  39981. protected $string;
  39982. protected $conjunctive;
  39983. protected $lowerBound;
  39984. protected $upperBound;
  39985. public function __construct(array $constraints, $conjunctive = true)
  39986. {
  39987. if (\count($constraints) < 2) {
  39988. throw new \InvalidArgumentException(
  39989. 'Must provide at least two constraints for a MultiConstraint. Use '.
  39990. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  39991. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  39992. );
  39993. }
  39994. $this->constraints = $constraints;
  39995. $this->conjunctive = $conjunctive;
  39996. }
  39997. public function getConstraints()
  39998. {
  39999. return $this->constraints;
  40000. }
  40001. public function isConjunctive()
  40002. {
  40003. return $this->conjunctive;
  40004. }
  40005. public function isDisjunctive()
  40006. {
  40007. return !$this->conjunctive;
  40008. }
  40009. public function compile($otherOperator)
  40010. {
  40011. $parts = array();
  40012. foreach ($this->constraints as $constraint) {
  40013. $code = $constraint->compile($otherOperator);
  40014. if ($code === 'true') {
  40015. if (!$this->conjunctive) {
  40016. return 'true';
  40017. }
  40018. } elseif ($code === 'false') {
  40019. if ($this->conjunctive) {
  40020. return 'false';
  40021. }
  40022. } else {
  40023. $parts[] = '('.$code.')';
  40024. }
  40025. }
  40026. if (!$parts) {
  40027. return $this->conjunctive ? 'true' : 'false';
  40028. }
  40029. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  40030. }
  40031. public function matches(ConstraintInterface $provider)
  40032. {
  40033. if (false === $this->conjunctive) {
  40034. foreach ($this->constraints as $constraint) {
  40035. if ($provider->matches($constraint)) {
  40036. return true;
  40037. }
  40038. }
  40039. return false;
  40040. }
  40041. foreach ($this->constraints as $constraint) {
  40042. if (!$provider->matches($constraint)) {
  40043. return false;
  40044. }
  40045. }
  40046. return true;
  40047. }
  40048. public function setPrettyString($prettyString)
  40049. {
  40050. $this->prettyString = $prettyString;
  40051. }
  40052. public function getPrettyString()
  40053. {
  40054. if ($this->prettyString) {
  40055. return $this->prettyString;
  40056. }
  40057. return (string) $this;
  40058. }
  40059. public function __toString()
  40060. {
  40061. if ($this->string !== null) {
  40062. return $this->string;
  40063. }
  40064. $constraints = array();
  40065. foreach ($this->constraints as $constraint) {
  40066. $constraints[] = (string) $constraint;
  40067. }
  40068. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  40069. }
  40070. public function getLowerBound()
  40071. {
  40072. $this->extractBounds();
  40073. return $this->lowerBound;
  40074. }
  40075. public function getUpperBound()
  40076. {
  40077. $this->extractBounds();
  40078. return $this->upperBound;
  40079. }
  40080. public static function create(array $constraints, $conjunctive = true)
  40081. {
  40082. if (0 === \count($constraints)) {
  40083. return new MatchAllConstraint();
  40084. }
  40085. if (1 === \count($constraints)) {
  40086. return $constraints[0];
  40087. }
  40088. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  40089. if ($optimized !== null) {
  40090. list($constraints, $conjunctive) = $optimized;
  40091. if (\count($constraints) === 1) {
  40092. return $constraints[0];
  40093. }
  40094. }
  40095. return new self($constraints, $conjunctive);
  40096. }
  40097. private static function optimizeConstraints(array $constraints, $conjunctive)
  40098. {
  40099. if (!$conjunctive) {
  40100. $left = $constraints[0];
  40101. $mergedConstraints = array();
  40102. $optimized = false;
  40103. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  40104. $right = $constraints[$i];
  40105. if (
  40106. $left instanceof self
  40107. && $left->conjunctive
  40108. && $right instanceof self
  40109. && $right->conjunctive
  40110. && \count($left->constraints) === 2
  40111. && \count($right->constraints) === 2
  40112. && ($left0 = (string) $left->constraints[0])
  40113. && $left0[0] === '>' && $left0[1] === '='
  40114. && ($left1 = (string) $left->constraints[1])
  40115. && $left1[0] === '<'
  40116. && ($right0 = (string) $right->constraints[0])
  40117. && $right0[0] === '>' && $right0[1] === '='
  40118. && ($right1 = (string) $right->constraints[1])
  40119. && $right1[0] === '<'
  40120. && substr($left1, 2) === substr($right0, 3)
  40121. ) {
  40122. $optimized = true;
  40123. $left = new MultiConstraint(
  40124. array(
  40125. $left->constraints[0],
  40126. $right->constraints[1],
  40127. ),
  40128. true);
  40129. } else {
  40130. $mergedConstraints[] = $left;
  40131. $left = $right;
  40132. }
  40133. }
  40134. if ($optimized) {
  40135. $mergedConstraints[] = $left;
  40136. return array($mergedConstraints, false);
  40137. }
  40138. }
  40139. return null;
  40140. }
  40141. private function extractBounds()
  40142. {
  40143. if (null !== $this->lowerBound) {
  40144. return;
  40145. }
  40146. foreach ($this->constraints as $constraint) {
  40147. if (null === $this->lowerBound && null === $this->upperBound) {
  40148. $this->lowerBound = $constraint->getLowerBound();
  40149. $this->upperBound = $constraint->getUpperBound();
  40150. continue;
  40151. }
  40152. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  40153. $this->lowerBound = $constraint->getLowerBound();
  40154. }
  40155. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  40156. $this->upperBound = $constraint->getUpperBound();
  40157. }
  40158. }
  40159. }
  40160. }
  40161. <?php
  40162. namespace Composer\Semver;
  40163. use Composer\Semver\Constraint\Constraint;
  40164. class Interval
  40165. {
  40166. private $start;
  40167. private $end;
  40168. public function __construct(Constraint $start, Constraint $end)
  40169. {
  40170. $this->start = $start;
  40171. $this->end = $end;
  40172. }
  40173. public function getStart()
  40174. {
  40175. return $this->start;
  40176. }
  40177. public function getEnd()
  40178. {
  40179. return $this->end;
  40180. }
  40181. public static function fromZero()
  40182. {
  40183. static $zero;
  40184. if (null === $zero) {
  40185. $zero = new Constraint('>=', '0.0.0.0-dev');
  40186. }
  40187. return $zero;
  40188. }
  40189. public static function untilPositiveInfinity()
  40190. {
  40191. static $positiveInfinity;
  40192. if (null === $positiveInfinity) {
  40193. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  40194. }
  40195. return $positiveInfinity;
  40196. }
  40197. public static function any()
  40198. {
  40199. return new self(self::fromZero(), self::untilPositiveInfinity());
  40200. }
  40201. public static function anyDev()
  40202. {
  40203. return array('names' => array(), 'exclude' => true);
  40204. }
  40205. public static function noDev()
  40206. {
  40207. return array('names' => array(), 'exclude' => false);
  40208. }
  40209. }
  40210. <?php
  40211. namespace Composer\Semver;
  40212. use Composer\Semver\Constraint\Constraint;
  40213. use Composer\Semver\Constraint\ConstraintInterface;
  40214. use Composer\Semver\Constraint\MatchAllConstraint;
  40215. use Composer\Semver\Constraint\MatchNoneConstraint;
  40216. use Composer\Semver\Constraint\MultiConstraint;
  40217. class Intervals
  40218. {
  40219. private static $intervalsCache = array();
  40220. private static $opSortOrder = array(
  40221. '>=' => -3,
  40222. '<' => -2,
  40223. '>' => 2,
  40224. '<=' => 3,
  40225. );
  40226. public static function clear()
  40227. {
  40228. self::$intervalsCache = array();
  40229. }
  40230. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  40231. {
  40232. if ($constraint instanceof MatchAllConstraint) {
  40233. return true;
  40234. }
  40235. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  40236. return false;
  40237. }
  40238. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  40239. $candidateIntervals = self::get($candidate);
  40240. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  40241. return false;
  40242. }
  40243. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  40244. if (!isset($candidateIntervals['numeric'][$index])) {
  40245. return false;
  40246. }
  40247. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  40248. return false;
  40249. }
  40250. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  40251. return false;
  40252. }
  40253. }
  40254. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  40255. return false;
  40256. }
  40257. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  40258. return false;
  40259. }
  40260. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  40261. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  40262. return false;
  40263. }
  40264. }
  40265. return true;
  40266. }
  40267. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  40268. {
  40269. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  40270. return true;
  40271. }
  40272. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  40273. return false;
  40274. }
  40275. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  40276. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  40277. }
  40278. public static function compactConstraint(ConstraintInterface $constraint)
  40279. {
  40280. if (!$constraint instanceof MultiConstraint) {
  40281. return $constraint;
  40282. }
  40283. $intervals = self::generateIntervals($constraint);
  40284. $constraints = array();
  40285. $hasNumericMatchAll = false;
  40286. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  40287. $constraints[] = $intervals['numeric'][0]->getStart();
  40288. $hasNumericMatchAll = true;
  40289. } else {
  40290. $unEqualConstraints = array();
  40291. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  40292. $interval = $intervals['numeric'][$i];
  40293. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  40294. $nextInterval = $intervals['numeric'][$i+1];
  40295. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  40296. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  40297. $unEqualConstraints[] = $interval->getStart();
  40298. }
  40299. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  40300. continue;
  40301. }
  40302. }
  40303. if (\count($unEqualConstraints) > 0) {
  40304. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  40305. $unEqualConstraints[] = $interval->getEnd();
  40306. }
  40307. if (\count($unEqualConstraints) > 1) {
  40308. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  40309. } else {
  40310. $constraints[] = $unEqualConstraints[0];
  40311. }
  40312. $unEqualConstraints = array();
  40313. continue;
  40314. }
  40315. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  40316. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  40317. continue;
  40318. }
  40319. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  40320. $constraints[] = $interval->getEnd();
  40321. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  40322. $constraints[] = $interval->getStart();
  40323. } else {
  40324. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  40325. }
  40326. }
  40327. }
  40328. $devConstraints = array();
  40329. if (0 === \count($intervals['branches']['names'])) {
  40330. if ($intervals['branches']['exclude']) {
  40331. if ($hasNumericMatchAll) {
  40332. return new MatchAllConstraint;
  40333. }
  40334. }
  40335. } else {
  40336. foreach ($intervals['branches']['names'] as $branchName) {
  40337. if ($intervals['branches']['exclude']) {
  40338. $devConstraints[] = new Constraint('!=', $branchName);
  40339. } else {
  40340. $devConstraints[] = new Constraint('==', $branchName);
  40341. }
  40342. }
  40343. if ($intervals['branches']['exclude']) {
  40344. if (\count($constraints) > 1) {
  40345. return new MultiConstraint(array_merge(
  40346. array(new MultiConstraint($constraints, false)),
  40347. $devConstraints
  40348. ), true);
  40349. }
  40350. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  40351. if (\count($devConstraints) > 1) {
  40352. return new MultiConstraint($devConstraints, true);
  40353. }
  40354. return $devConstraints[0];
  40355. }
  40356. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  40357. }
  40358. $constraints = array_merge($constraints, $devConstraints);
  40359. }
  40360. if (\count($constraints) > 1) {
  40361. return new MultiConstraint($constraints, false);
  40362. }
  40363. if (\count($constraints) === 1) {
  40364. return $constraints[0];
  40365. }
  40366. return new MatchNoneConstraint;
  40367. }
  40368. public static function get(ConstraintInterface $constraint)
  40369. {
  40370. $key = (string) $constraint;
  40371. if (!isset(self::$intervalsCache[$key])) {
  40372. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  40373. }
  40374. return self::$intervalsCache[$key];
  40375. }
  40376. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  40377. {
  40378. if ($constraint instanceof MatchAllConstraint) {
  40379. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  40380. }
  40381. if ($constraint instanceof MatchNoneConstraint) {
  40382. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  40383. }
  40384. if ($constraint instanceof Constraint) {
  40385. return self::generateSingleConstraintIntervals($constraint);
  40386. }
  40387. if (!$constraint instanceof MultiConstraint) {
  40388. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  40389. }
  40390. $constraints = $constraint->getConstraints();
  40391. $numericGroups = array();
  40392. $constraintBranches = array();
  40393. foreach ($constraints as $c) {
  40394. $res = self::get($c);
  40395. $numericGroups[] = $res['numeric'];
  40396. $constraintBranches[] = $res['branches'];
  40397. }
  40398. if ($constraint->isDisjunctive()) {
  40399. $branches = Interval::noDev();
  40400. foreach ($constraintBranches as $b) {
  40401. if ($b['exclude']) {
  40402. if ($branches['exclude']) {
  40403. $branches['names'] = array_intersect($branches['names'], $b['names']);
  40404. } else {
  40405. $branches['exclude'] = true;
  40406. $branches['names'] = array_diff($b['names'], $branches['names']);
  40407. }
  40408. } else {
  40409. if ($branches['exclude']) {
  40410. $branches['names'] = array_diff($branches['names'], $b['names']);
  40411. } else {
  40412. $branches['names'] = array_merge($branches['names'], $b['names']);
  40413. }
  40414. }
  40415. }
  40416. } else {
  40417. $branches = Interval::anyDev();
  40418. foreach ($constraintBranches as $b) {
  40419. if ($b['exclude']) {
  40420. if ($branches['exclude']) {
  40421. $branches['names'] = array_merge($branches['names'], $b['names']);
  40422. } else {
  40423. $branches['names'] = array_diff($branches['names'], $b['names']);
  40424. }
  40425. } else {
  40426. if ($branches['exclude']) {
  40427. $branches['names'] = array_diff($b['names'], $branches['names']);
  40428. $branches['exclude'] = false;
  40429. } else {
  40430. $branches['names'] = array_intersect($branches['names'], $b['names']);
  40431. }
  40432. }
  40433. }
  40434. }
  40435. $branches['names'] = array_unique($branches['names']);
  40436. if (\count($numericGroups) === 1) {
  40437. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  40438. }
  40439. $borders = array();
  40440. foreach ($numericGroups as $group) {
  40441. foreach ($group as $interval) {
  40442. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  40443. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  40444. }
  40445. }
  40446. $opSortOrder = self::$opSortOrder;
  40447. usort($borders, function ($a, $b) use ($opSortOrder) {
  40448. $order = version_compare($a['version'], $b['version']);
  40449. if ($order === 0) {
  40450. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  40451. }
  40452. return $order;
  40453. });
  40454. $activeIntervals = 0;
  40455. $intervals = array();
  40456. $index = 0;
  40457. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  40458. $active = false;
  40459. $start = null;
  40460. foreach ($borders as $border) {
  40461. if ($border['side'] === 'start') {
  40462. $activeIntervals++;
  40463. } else {
  40464. $activeIntervals--;
  40465. }
  40466. if (!$active && $activeIntervals >= $activationThreshold) {
  40467. $start = new Constraint($border['operator'], $border['version']);
  40468. $active = true;
  40469. }
  40470. if ($active && $activeIntervals < $activationThreshold) {
  40471. $active = false;
  40472. if (
  40473. version_compare($start->getVersion(), $border['version'], '=')
  40474. && (
  40475. ($start->getOperator() === '>' && $border['operator'] === '<=')
  40476. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  40477. )
  40478. ) {
  40479. unset($intervals[$index]);
  40480. } else {
  40481. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  40482. $index++;
  40483. if ($stopOnFirstValidInterval) {
  40484. break;
  40485. }
  40486. }
  40487. $start = null;
  40488. }
  40489. }
  40490. return array('numeric' => $intervals, 'branches' => $branches);
  40491. }
  40492. private static function generateSingleConstraintIntervals(Constraint $constraint)
  40493. {
  40494. $op = $constraint->getOperator();
  40495. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  40496. $intervals = array();
  40497. $branches = array('names' => array(), 'exclude' => false);
  40498. if ($op === '!=') {
  40499. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  40500. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  40501. } elseif ($op === '==') {
  40502. $branches['names'][] = $constraint->getVersion();
  40503. }
  40504. return array(
  40505. 'numeric' => $intervals,
  40506. 'branches' => $branches,
  40507. );
  40508. }
  40509. if ($op[0] === '>') {
  40510. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  40511. }
  40512. if ($op[0] === '<') {
  40513. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  40514. }
  40515. if ($op === '!=') {
  40516. return array('numeric' => array(
  40517. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  40518. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  40519. ), 'branches' => Interval::anyDev());
  40520. }
  40521. return array('numeric' => array(
  40522. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  40523. ), 'branches' => Interval::noDev());
  40524. }
  40525. }
  40526. <?php
  40527. namespace Composer\Semver;
  40528. use Composer\Semver\Constraint\Constraint;
  40529. class Semver
  40530. {
  40531. const SORT_ASC = 1;
  40532. const SORT_DESC = -1;
  40533. private static $versionParser;
  40534. public static function satisfies($version, $constraints)
  40535. {
  40536. if (null === self::$versionParser) {
  40537. self::$versionParser = new VersionParser();
  40538. }
  40539. $versionParser = self::$versionParser;
  40540. $provider = new Constraint('==', $versionParser->normalize($version));
  40541. $parsedConstraints = $versionParser->parseConstraints($constraints);
  40542. return $parsedConstraints->matches($provider);
  40543. }
  40544. public static function satisfiedBy(array $versions, $constraints)
  40545. {
  40546. $versions = array_filter($versions, function ($version) use ($constraints) {
  40547. return Semver::satisfies($version, $constraints);
  40548. });
  40549. return array_values($versions);
  40550. }
  40551. public static function sort(array $versions)
  40552. {
  40553. return self::usort($versions, self::SORT_ASC);
  40554. }
  40555. public static function rsort(array $versions)
  40556. {
  40557. return self::usort($versions, self::SORT_DESC);
  40558. }
  40559. private static function usort(array $versions, $direction)
  40560. {
  40561. if (null === self::$versionParser) {
  40562. self::$versionParser = new VersionParser();
  40563. }
  40564. $versionParser = self::$versionParser;
  40565. $normalized = array();
  40566. foreach ($versions as $key => $version) {
  40567. $normalizedVersion = $versionParser->normalize($version);
  40568. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  40569. $normalized[] = array($normalizedVersion, $key);
  40570. }
  40571. usort($normalized, function (array $left, array $right) use ($direction) {
  40572. if ($left[0] === $right[0]) {
  40573. return 0;
  40574. }
  40575. if (Comparator::lessThan($left[0], $right[0])) {
  40576. return -$direction;
  40577. }
  40578. return $direction;
  40579. });
  40580. $sorted = array();
  40581. foreach ($normalized as $item) {
  40582. $sorted[] = $versions[$item[1]];
  40583. }
  40584. return $sorted;
  40585. }
  40586. }
  40587. <?php
  40588. namespace Composer\Semver;
  40589. use Composer\Semver\Constraint\ConstraintInterface;
  40590. use Composer\Semver\Constraint\MatchAllConstraint;
  40591. use Composer\Semver\Constraint\MultiConstraint;
  40592. use Composer\Semver\Constraint\Constraint;
  40593. class VersionParser
  40594. {
  40595. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  40596. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  40597. public static function parseStability($version)
  40598. {
  40599. $version = preg_replace('{#.+$}', '', $version);
  40600. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  40601. return 'dev';
  40602. }
  40603. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  40604. if (!empty($match[3])) {
  40605. return 'dev';
  40606. }
  40607. if (!empty($match[1])) {
  40608. if ('beta' === $match[1] || 'b' === $match[1]) {
  40609. return 'beta';
  40610. }
  40611. if ('alpha' === $match[1] || 'a' === $match[1]) {
  40612. return 'alpha';
  40613. }
  40614. if ('rc' === $match[1]) {
  40615. return 'RC';
  40616. }
  40617. }
  40618. return 'stable';
  40619. }
  40620. public static function normalizeStability($stability)
  40621. {
  40622. $stability = strtolower($stability);
  40623. return $stability === 'rc' ? 'RC' : $stability;
  40624. }
  40625. public function normalize($version, $fullVersion = null)
  40626. {
  40627. $version = trim($version);
  40628. $origVersion = $version;
  40629. if (null === $fullVersion) {
  40630. $fullVersion = $version;
  40631. }
  40632. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  40633. $version = $match[1];
  40634. }
  40635. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  40636. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  40637. }
  40638. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  40639. $version = 'dev-' . $version;
  40640. }
  40641. if (stripos($version, 'dev-') === 0) {
  40642. return 'dev-' . substr($version, 4);
  40643. }
  40644. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  40645. $version = $match[1];
  40646. }
  40647. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  40648. $version = $matches[1]
  40649. . (!empty($matches[2]) ? $matches[2] : '.0')
  40650. . (!empty($matches[3]) ? $matches[3] : '.0')
  40651. . (!empty($matches[4]) ? $matches[4] : '.0');
  40652. $index = 5;
  40653. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  40654. $version = preg_replace('{\D}', '.', $matches[1]);
  40655. $index = 2;
  40656. }
  40657. if (isset($index)) {
  40658. if (!empty($matches[$index])) {
  40659. if ('stable' === $matches[$index]) {
  40660. return $version;
  40661. }
  40662. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  40663. }
  40664. if (!empty($matches[$index + 2])) {
  40665. $version .= '-dev';
  40666. }
  40667. return $version;
  40668. }
  40669. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  40670. try {
  40671. $normalized = $this->normalizeBranch($match[1]);
  40672. if (strpos($normalized, 'dev-') === false) {
  40673. return $normalized;
  40674. }
  40675. } catch (\Exception $e) {
  40676. }
  40677. }
  40678. $extraMessage = '';
  40679. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  40680. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  40681. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  40682. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  40683. }
  40684. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  40685. }
  40686. public function parseNumericAliasPrefix($branch)
  40687. {
  40688. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  40689. return $matches['version'] . '.';
  40690. }
  40691. return false;
  40692. }
  40693. public function normalizeBranch($name)
  40694. {
  40695. $name = trim($name);
  40696. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  40697. $version = '';
  40698. for ($i = 1; $i < 5; ++$i) {
  40699. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  40700. }
  40701. return str_replace('x', '9999999', $version) . '-dev';
  40702. }
  40703. return 'dev-' . $name;
  40704. }
  40705. public function normalizeDefaultBranch($name)
  40706. {
  40707. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  40708. return '9999999-dev';
  40709. }
  40710. return $name;
  40711. }
  40712. public function parseConstraints($constraints)
  40713. {
  40714. $prettyConstraint = $constraints;
  40715. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  40716. $orGroups = array();
  40717. foreach ($orConstraints as $constraints) {
  40718. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  40719. if (\count($andConstraints) > 1) {
  40720. $constraintObjects = array();
  40721. foreach ($andConstraints as $constraint) {
  40722. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  40723. $constraintObjects[] = $parsedConstraint;
  40724. }
  40725. }
  40726. } else {
  40727. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  40728. }
  40729. if (1 === \count($constraintObjects)) {
  40730. $constraint = $constraintObjects[0];
  40731. } else {
  40732. $constraint = new MultiConstraint($constraintObjects);
  40733. }
  40734. $orGroups[] = $constraint;
  40735. }
  40736. $constraint = MultiConstraint::create($orGroups, false);
  40737. $constraint->setPrettyString($prettyConstraint);
  40738. return $constraint;
  40739. }
  40740. private function parseConstraint($constraint)
  40741. {
  40742. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  40743. $constraint = $match[1];
  40744. }
  40745. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  40746. $constraint = '' !== $match[1] ? $match[1] : '*';
  40747. if ($match[2] !== 'stable') {
  40748. $stabilityModifier = $match[2];
  40749. }
  40750. }
  40751. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  40752. $constraint = $match[1];
  40753. }
  40754. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  40755. if (!empty($match[1]) || !empty($match[2])) {
  40756. return array(new Constraint('>=', '0.0.0.0-dev'));
  40757. }
  40758. return array(new MatchAllConstraint());
  40759. }
  40760. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  40761. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  40762. if (strpos($constraint, '~>') === 0) {
  40763. throw new \UnexpectedValueException(
  40764. 'Could not parse version constraint ' . $constraint . ': ' .
  40765. 'Invalid operator "~>", you probably meant to use the "~" operator'
  40766. );
  40767. }
  40768. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  40769. $position = 4;
  40770. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40771. $position = 3;
  40772. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40773. $position = 2;
  40774. } else {
  40775. $position = 1;
  40776. }
  40777. if (!empty($matches[8])) {
  40778. $position++;
  40779. }
  40780. $stabilitySuffix = '';
  40781. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40782. $stabilitySuffix .= '-dev';
  40783. }
  40784. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40785. $lowerBound = new Constraint('>=', $lowVersion);
  40786. $highPosition = max(1, $position - 1);
  40787. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  40788. $upperBound = new Constraint('<', $highVersion);
  40789. return array(
  40790. $lowerBound,
  40791. $upperBound,
  40792. );
  40793. }
  40794. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  40795. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  40796. $position = 1;
  40797. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  40798. $position = 2;
  40799. } else {
  40800. $position = 3;
  40801. }
  40802. $stabilitySuffix = '';
  40803. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40804. $stabilitySuffix .= '-dev';
  40805. }
  40806. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40807. $lowerBound = new Constraint('>=', $lowVersion);
  40808. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40809. $upperBound = new Constraint('<', $highVersion);
  40810. return array(
  40811. $lowerBound,
  40812. $upperBound,
  40813. );
  40814. }
  40815. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  40816. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40817. $position = 3;
  40818. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40819. $position = 2;
  40820. } else {
  40821. $position = 1;
  40822. }
  40823. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  40824. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40825. if ($lowVersion === '0.0.0.0-dev') {
  40826. return array(new Constraint('<', $highVersion));
  40827. }
  40828. return array(
  40829. new Constraint('>=', $lowVersion),
  40830. new Constraint('<', $highVersion),
  40831. );
  40832. }
  40833. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  40834. $lowStabilitySuffix = '';
  40835. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  40836. $lowStabilitySuffix = '-dev';
  40837. }
  40838. $lowVersion = $this->normalize($matches['from']);
  40839. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  40840. $empty = function ($x) {
  40841. return ($x === 0 || $x === '0') ? false : empty($x);
  40842. };
  40843. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  40844. $highVersion = $this->normalize($matches['to']);
  40845. $upperBound = new Constraint('<=', $highVersion);
  40846. } else {
  40847. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  40848. $this->normalize($matches['to']);
  40849. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  40850. $upperBound = new Constraint('<', $highVersion);
  40851. }
  40852. return array(
  40853. $lowerBound,
  40854. $upperBound,
  40855. );
  40856. }
  40857. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  40858. try {
  40859. try {
  40860. $version = $this->normalize($matches[2]);
  40861. } catch (\UnexpectedValueException $e) {
  40862. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  40863. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  40864. } else {
  40865. throw $e;
  40866. }
  40867. }
  40868. $op = $matches[1] ?: '=';
  40869. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  40870. $version .= '-' . $stabilityModifier;
  40871. } elseif ('<' === $op || '>=' === $op) {
  40872. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  40873. if (strpos($matches[2], 'dev-') !== 0) {
  40874. $version .= '-dev';
  40875. }
  40876. }
  40877. }
  40878. return array(new Constraint($matches[1] ?: '=', $version));
  40879. } catch (\Exception $e) {
  40880. }
  40881. }
  40882. $message = 'Could not parse version constraint ' . $constraint;
  40883. if (isset($e)) {
  40884. $message .= ': ' . $e->getMessage();
  40885. }
  40886. throw new \UnexpectedValueException($message);
  40887. }
  40888. private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
  40889. {
  40890. for ($i = 4; $i > 0; --$i) {
  40891. if ($i > $position) {
  40892. $matches[$i] = $pad;
  40893. } elseif ($i === $position && $increment) {
  40894. $matches[$i] += $increment;
  40895. if ($matches[$i] < 0) {
  40896. $matches[$i] = $pad;
  40897. --$position;
  40898. if ($i === 1) {
  40899. return null;
  40900. }
  40901. }
  40902. }
  40903. }
  40904. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  40905. }
  40906. private function expandStability($stability)
  40907. {
  40908. $stability = strtolower($stability);
  40909. switch ($stability) {
  40910. case 'a':
  40911. return 'alpha';
  40912. case 'b':
  40913. return 'beta';
  40914. case 'p':
  40915. case 'pl':
  40916. return 'patch';
  40917. case 'rc':
  40918. return 'RC';
  40919. default:
  40920. return $stability;
  40921. }
  40922. }
  40923. }
  40924. Copyright (C) 2015 Composer
  40925. Permission is hereby granted, free of charge, to any person obtaining a copy of
  40926. this software and associated documentation files (the "Software"), to deal in
  40927. the Software without restriction, including without limitation the rights to
  40928. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  40929. of the Software, and to permit persons to whom the Software is furnished to do
  40930. so, subject to the following conditions:
  40931. The above copyright notice and this permission notice shall be included in all
  40932. copies or substantial portions of the Software.
  40933. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  40934. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40935. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  40936. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  40937. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  40938. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  40939. SOFTWARE.
  40940. {
  40941. "389-exception": [
  40942. "389 Directory Server Exception"
  40943. ],
  40944. "Autoconf-exception-2.0": [
  40945. "Autoconf exception 2.0"
  40946. ],
  40947. "Autoconf-exception-3.0": [
  40948. "Autoconf exception 3.0"
  40949. ],
  40950. "Bison-exception-2.2": [
  40951. "Bison exception 2.2"
  40952. ],
  40953. "Bootloader-exception": [
  40954. "Bootloader Distribution Exception"
  40955. ],
  40956. "Classpath-exception-2.0": [
  40957. "Classpath exception 2.0"
  40958. ],
  40959. "CLISP-exception-2.0": [
  40960. "CLISP exception 2.0"
  40961. ],
  40962. "DigiRule-FOSS-exception": [
  40963. "DigiRule FOSS License Exception"
  40964. ],
  40965. "eCos-exception-2.0": [
  40966. "eCos exception 2.0"
  40967. ],
  40968. "Fawkes-Runtime-exception": [
  40969. "Fawkes Runtime Exception"
  40970. ],
  40971. "FLTK-exception": [
  40972. "FLTK exception"
  40973. ],
  40974. "Font-exception-2.0": [
  40975. "Font exception 2.0"
  40976. ],
  40977. "freertos-exception-2.0": [
  40978. "FreeRTOS Exception 2.0"
  40979. ],
  40980. "GCC-exception-2.0": [
  40981. "GCC Runtime Library exception 2.0"
  40982. ],
  40983. "GCC-exception-3.1": [
  40984. "GCC Runtime Library exception 3.1"
  40985. ],
  40986. "gnu-javamail-exception": [
  40987. "GNU JavaMail exception"
  40988. ],
  40989. "GPL-3.0-linking-exception": [
  40990. "GPL-3.0 Linking Exception"
  40991. ],
  40992. "GPL-3.0-linking-source-exception": [
  40993. "GPL-3.0 Linking Exception (with Corresponding Source)"
  40994. ],
  40995. "GPL-CC-1.0": [
  40996. "GPL Cooperation Commitment 1.0"
  40997. ],
  40998. "i2p-gpl-java-exception": [
  40999. "i2p GPL+Java Exception"
  41000. ],
  41001. "LGPL-3.0-linking-exception": [
  41002. "LGPL-3.0 Linking Exception"
  41003. ],
  41004. "Libtool-exception": [
  41005. "Libtool Exception"
  41006. ],
  41007. "Linux-syscall-note": [
  41008. "Linux Syscall Note"
  41009. ],
  41010. "LLVM-exception": [
  41011. "LLVM Exception"
  41012. ],
  41013. "LZMA-exception": [
  41014. "LZMA exception"
  41015. ],
  41016. "mif-exception": [
  41017. "Macros and Inline Functions Exception"
  41018. ],
  41019. "Nokia-Qt-exception-1.1": [
  41020. "Nokia Qt LGPL exception 1.1"
  41021. ],
  41022. "OCaml-LGPL-linking-exception": [
  41023. "OCaml LGPL Linking Exception"
  41024. ],
  41025. "OCCT-exception-1.0": [
  41026. "Open CASCADE Exception 1.0"
  41027. ],
  41028. "OpenJDK-assembly-exception-1.0": [
  41029. "OpenJDK Assembly exception 1.0"
  41030. ],
  41031. "openvpn-openssl-exception": [
  41032. "OpenVPN OpenSSL Exception"
  41033. ],
  41034. "PS-or-PDF-font-exception-20170817": [
  41035. "PS/PDF font exception (2017-08-17)"
  41036. ],
  41037. "Qt-GPL-exception-1.0": [
  41038. "Qt GPL exception 1.0"
  41039. ],
  41040. "Qt-LGPL-exception-1.1": [
  41041. "Qt LGPL exception 1.1"
  41042. ],
  41043. "Qwt-exception-1.0": [
  41044. "Qwt exception 1.0"
  41045. ],
  41046. "SHL-2.0": [
  41047. "Solderpad Hardware License v2.0"
  41048. ],
  41049. "SHL-2.1": [
  41050. "Solderpad Hardware License v2.1"
  41051. ],
  41052. "Swift-exception": [
  41053. "Swift Exception"
  41054. ],
  41055. "u-boot-exception-2.0": [
  41056. "U-Boot exception 2.0"
  41057. ],
  41058. "Universal-FOSS-exception-1.0": [
  41059. "Universal FOSS Exception, Version 1.0"
  41060. ],
  41061. "WxWindows-exception-3.1": [
  41062. "WxWindows Library Exception 3.1"
  41063. ]
  41064. }{
  41065. "0BSD": [
  41066. "BSD Zero Clause License",
  41067. true,
  41068. false
  41069. ],
  41070. "AAL": [
  41071. "Attribution Assurance License",
  41072. true,
  41073. false
  41074. ],
  41075. "Abstyles": [
  41076. "Abstyles License",
  41077. false,
  41078. false
  41079. ],
  41080. "Adobe-2006": [
  41081. "Adobe Systems Incorporated Source Code License Agreement",
  41082. false,
  41083. false
  41084. ],
  41085. "Adobe-Glyph": [
  41086. "Adobe Glyph List License",
  41087. false,
  41088. false
  41089. ],
  41090. "ADSL": [
  41091. "Amazon Digital Services License",
  41092. false,
  41093. false
  41094. ],
  41095. "AFL-1.1": [
  41096. "Academic Free License v1.1",
  41097. true,
  41098. false
  41099. ],
  41100. "AFL-1.2": [
  41101. "Academic Free License v1.2",
  41102. true,
  41103. false
  41104. ],
  41105. "AFL-2.0": [
  41106. "Academic Free License v2.0",
  41107. true,
  41108. false
  41109. ],
  41110. "AFL-2.1": [
  41111. "Academic Free License v2.1",
  41112. true,
  41113. false
  41114. ],
  41115. "AFL-3.0": [
  41116. "Academic Free License v3.0",
  41117. true,
  41118. false
  41119. ],
  41120. "Afmparse": [
  41121. "Afmparse License",
  41122. false,
  41123. false
  41124. ],
  41125. "AGPL-1.0": [
  41126. "Affero General Public License v1.0",
  41127. false,
  41128. true
  41129. ],
  41130. "AGPL-1.0-only": [
  41131. "Affero General Public License v1.0 only",
  41132. false,
  41133. false
  41134. ],
  41135. "AGPL-1.0-or-later": [
  41136. "Affero General Public License v1.0 or later",
  41137. false,
  41138. false
  41139. ],
  41140. "AGPL-3.0": [
  41141. "GNU Affero General Public License v3.0",
  41142. true,
  41143. true
  41144. ],
  41145. "AGPL-3.0-only": [
  41146. "GNU Affero General Public License v3.0 only",
  41147. true,
  41148. false
  41149. ],
  41150. "AGPL-3.0-or-later": [
  41151. "GNU Affero General Public License v3.0 or later",
  41152. true,
  41153. false
  41154. ],
  41155. "Aladdin": [
  41156. "Aladdin Free Public License",
  41157. false,
  41158. false
  41159. ],
  41160. "AMDPLPA": [
  41161. "AMD's plpa_map.c License",
  41162. false,
  41163. false
  41164. ],
  41165. "AML": [
  41166. "Apple MIT License",
  41167. false,
  41168. false
  41169. ],
  41170. "AMPAS": [
  41171. "Academy of Motion Picture Arts and Sciences BSD",
  41172. false,
  41173. false
  41174. ],
  41175. "ANTLR-PD": [
  41176. "ANTLR Software Rights Notice",
  41177. false,
  41178. false
  41179. ],
  41180. "ANTLR-PD-fallback": [
  41181. "ANTLR Software Rights Notice with license fallback",
  41182. false,
  41183. false
  41184. ],
  41185. "Apache-1.0": [
  41186. "Apache License 1.0",
  41187. false,
  41188. false
  41189. ],
  41190. "Apache-1.1": [
  41191. "Apache License 1.1",
  41192. true,
  41193. false
  41194. ],
  41195. "Apache-2.0": [
  41196. "Apache License 2.0",
  41197. true,
  41198. false
  41199. ],
  41200. "APAFML": [
  41201. "Adobe Postscript AFM License",
  41202. false,
  41203. false
  41204. ],
  41205. "APL-1.0": [
  41206. "Adaptive Public License 1.0",
  41207. true,
  41208. false
  41209. ],
  41210. "APSL-1.0": [
  41211. "Apple Public Source License 1.0",
  41212. true,
  41213. false
  41214. ],
  41215. "APSL-1.1": [
  41216. "Apple Public Source License 1.1",
  41217. true,
  41218. false
  41219. ],
  41220. "APSL-1.2": [
  41221. "Apple Public Source License 1.2",
  41222. true,
  41223. false
  41224. ],
  41225. "APSL-2.0": [
  41226. "Apple Public Source License 2.0",
  41227. true,
  41228. false
  41229. ],
  41230. "Artistic-1.0": [
  41231. "Artistic License 1.0",
  41232. true,
  41233. false
  41234. ],
  41235. "Artistic-1.0-cl8": [
  41236. "Artistic License 1.0 w/clause 8",
  41237. true,
  41238. false
  41239. ],
  41240. "Artistic-1.0-Perl": [
  41241. "Artistic License 1.0 (Perl)",
  41242. true,
  41243. false
  41244. ],
  41245. "Artistic-2.0": [
  41246. "Artistic License 2.0",
  41247. true,
  41248. false
  41249. ],
  41250. "Bahyph": [
  41251. "Bahyph License",
  41252. false,
  41253. false
  41254. ],
  41255. "Barr": [
  41256. "Barr License",
  41257. false,
  41258. false
  41259. ],
  41260. "Beerware": [
  41261. "Beerware License",
  41262. false,
  41263. false
  41264. ],
  41265. "BitTorrent-1.0": [
  41266. "BitTorrent Open Source License v1.0",
  41267. false,
  41268. false
  41269. ],
  41270. "BitTorrent-1.1": [
  41271. "BitTorrent Open Source License v1.1",
  41272. false,
  41273. false
  41274. ],
  41275. "blessing": [
  41276. "SQLite Blessing",
  41277. false,
  41278. false
  41279. ],
  41280. "BlueOak-1.0.0": [
  41281. "Blue Oak Model License 1.0.0",
  41282. false,
  41283. false
  41284. ],
  41285. "Borceux": [
  41286. "Borceux license",
  41287. false,
  41288. false
  41289. ],
  41290. "BSD-1-Clause": [
  41291. "BSD 1-Clause License",
  41292. true,
  41293. false
  41294. ],
  41295. "BSD-2-Clause": [
  41296. "BSD 2-Clause \"Simplified\" License",
  41297. true,
  41298. false
  41299. ],
  41300. "BSD-2-Clause-FreeBSD": [
  41301. "BSD 2-Clause FreeBSD License",
  41302. false,
  41303. true
  41304. ],
  41305. "BSD-2-Clause-NetBSD": [
  41306. "BSD 2-Clause NetBSD License",
  41307. false,
  41308. true
  41309. ],
  41310. "BSD-2-Clause-Patent": [
  41311. "BSD-2-Clause Plus Patent License",
  41312. true,
  41313. false
  41314. ],
  41315. "BSD-2-Clause-Views": [
  41316. "BSD 2-Clause with views sentence",
  41317. false,
  41318. false
  41319. ],
  41320. "BSD-3-Clause": [
  41321. "BSD 3-Clause \"New\" or \"Revised\" License",
  41322. true,
  41323. false
  41324. ],
  41325. "BSD-3-Clause-Attribution": [
  41326. "BSD with attribution",
  41327. false,
  41328. false
  41329. ],
  41330. "BSD-3-Clause-Clear": [
  41331. "BSD 3-Clause Clear License",
  41332. false,
  41333. false
  41334. ],
  41335. "BSD-3-Clause-LBNL": [
  41336. "Lawrence Berkeley National Labs BSD variant license",
  41337. true,
  41338. false
  41339. ],
  41340. "BSD-3-Clause-No-Nuclear-License": [
  41341. "BSD 3-Clause No Nuclear License",
  41342. false,
  41343. false
  41344. ],
  41345. "BSD-3-Clause-No-Nuclear-License-2014": [
  41346. "BSD 3-Clause No Nuclear License 2014",
  41347. false,
  41348. false
  41349. ],
  41350. "BSD-3-Clause-No-Nuclear-Warranty": [
  41351. "BSD 3-Clause No Nuclear Warranty",
  41352. false,
  41353. false
  41354. ],
  41355. "BSD-3-Clause-Open-MPI": [
  41356. "BSD 3-Clause Open MPI variant",
  41357. false,
  41358. false
  41359. ],
  41360. "BSD-4-Clause": [
  41361. "BSD 4-Clause \"Original\" or \"Old\" License",
  41362. false,
  41363. false
  41364. ],
  41365. "BSD-4-Clause-UC": [
  41366. "BSD-4-Clause (University of California-Specific)",
  41367. false,
  41368. false
  41369. ],
  41370. "BSD-Protection": [
  41371. "BSD Protection License",
  41372. false,
  41373. false
  41374. ],
  41375. "BSD-Source-Code": [
  41376. "BSD Source Code Attribution",
  41377. false,
  41378. false
  41379. ],
  41380. "BSL-1.0": [
  41381. "Boost Software License 1.0",
  41382. true,
  41383. false
  41384. ],
  41385. "BUSL-1.1": [
  41386. "Business Source License 1.1",
  41387. false,
  41388. false
  41389. ],
  41390. "bzip2-1.0.5": [
  41391. "bzip2 and libbzip2 License v1.0.5",
  41392. false,
  41393. false
  41394. ],
  41395. "bzip2-1.0.6": [
  41396. "bzip2 and libbzip2 License v1.0.6",
  41397. false,
  41398. false
  41399. ],
  41400. "CAL-1.0": [
  41401. "Cryptographic Autonomy License 1.0",
  41402. true,
  41403. false
  41404. ],
  41405. "CAL-1.0-Combined-Work-Exception": [
  41406. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  41407. true,
  41408. false
  41409. ],
  41410. "Caldera": [
  41411. "Caldera License",
  41412. false,
  41413. false
  41414. ],
  41415. "CATOSL-1.1": [
  41416. "Computer Associates Trusted Open Source License 1.1",
  41417. true,
  41418. false
  41419. ],
  41420. "CC-BY-1.0": [
  41421. "Creative Commons Attribution 1.0 Generic",
  41422. false,
  41423. false
  41424. ],
  41425. "CC-BY-2.0": [
  41426. "Creative Commons Attribution 2.0 Generic",
  41427. false,
  41428. false
  41429. ],
  41430. "CC-BY-2.5": [
  41431. "Creative Commons Attribution 2.5 Generic",
  41432. false,
  41433. false
  41434. ],
  41435. "CC-BY-3.0": [
  41436. "Creative Commons Attribution 3.0 Unported",
  41437. false,
  41438. false
  41439. ],
  41440. "CC-BY-3.0-AT": [
  41441. "Creative Commons Attribution 3.0 Austria",
  41442. false,
  41443. false
  41444. ],
  41445. "CC-BY-3.0-US": [
  41446. "Creative Commons Attribution 3.0 United States",
  41447. false,
  41448. false
  41449. ],
  41450. "CC-BY-4.0": [
  41451. "Creative Commons Attribution 4.0 International",
  41452. false,
  41453. false
  41454. ],
  41455. "CC-BY-NC-1.0": [
  41456. "Creative Commons Attribution Non Commercial 1.0 Generic",
  41457. false,
  41458. false
  41459. ],
  41460. "CC-BY-NC-2.0": [
  41461. "Creative Commons Attribution Non Commercial 2.0 Generic",
  41462. false,
  41463. false
  41464. ],
  41465. "CC-BY-NC-2.5": [
  41466. "Creative Commons Attribution Non Commercial 2.5 Generic",
  41467. false,
  41468. false
  41469. ],
  41470. "CC-BY-NC-3.0": [
  41471. "Creative Commons Attribution Non Commercial 3.0 Unported",
  41472. false,
  41473. false
  41474. ],
  41475. "CC-BY-NC-4.0": [
  41476. "Creative Commons Attribution Non Commercial 4.0 International",
  41477. false,
  41478. false
  41479. ],
  41480. "CC-BY-NC-ND-1.0": [
  41481. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  41482. false,
  41483. false
  41484. ],
  41485. "CC-BY-NC-ND-2.0": [
  41486. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  41487. false,
  41488. false
  41489. ],
  41490. "CC-BY-NC-ND-2.5": [
  41491. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  41492. false,
  41493. false
  41494. ],
  41495. "CC-BY-NC-ND-3.0": [
  41496. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  41497. false,
  41498. false
  41499. ],
  41500. "CC-BY-NC-ND-3.0-IGO": [
  41501. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  41502. false,
  41503. false
  41504. ],
  41505. "CC-BY-NC-ND-4.0": [
  41506. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  41507. false,
  41508. false
  41509. ],
  41510. "CC-BY-NC-SA-1.0": [
  41511. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  41512. false,
  41513. false
  41514. ],
  41515. "CC-BY-NC-SA-2.0": [
  41516. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  41517. false,
  41518. false
  41519. ],
  41520. "CC-BY-NC-SA-2.5": [
  41521. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  41522. false,
  41523. false
  41524. ],
  41525. "CC-BY-NC-SA-3.0": [
  41526. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  41527. false,
  41528. false
  41529. ],
  41530. "CC-BY-NC-SA-4.0": [
  41531. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  41532. false,
  41533. false
  41534. ],
  41535. "CC-BY-ND-1.0": [
  41536. "Creative Commons Attribution No Derivatives 1.0 Generic",
  41537. false,
  41538. false
  41539. ],
  41540. "CC-BY-ND-2.0": [
  41541. "Creative Commons Attribution No Derivatives 2.0 Generic",
  41542. false,
  41543. false
  41544. ],
  41545. "CC-BY-ND-2.5": [
  41546. "Creative Commons Attribution No Derivatives 2.5 Generic",
  41547. false,
  41548. false
  41549. ],
  41550. "CC-BY-ND-3.0": [
  41551. "Creative Commons Attribution No Derivatives 3.0 Unported",
  41552. false,
  41553. false
  41554. ],
  41555. "CC-BY-ND-4.0": [
  41556. "Creative Commons Attribution No Derivatives 4.0 International",
  41557. false,
  41558. false
  41559. ],
  41560. "CC-BY-SA-1.0": [
  41561. "Creative Commons Attribution Share Alike 1.0 Generic",
  41562. false,
  41563. false
  41564. ],
  41565. "CC-BY-SA-2.0": [
  41566. "Creative Commons Attribution Share Alike 2.0 Generic",
  41567. false,
  41568. false
  41569. ],
  41570. "CC-BY-SA-2.0-UK": [
  41571. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  41572. false,
  41573. false
  41574. ],
  41575. "CC-BY-SA-2.5": [
  41576. "Creative Commons Attribution Share Alike 2.5 Generic",
  41577. false,
  41578. false
  41579. ],
  41580. "CC-BY-SA-3.0": [
  41581. "Creative Commons Attribution Share Alike 3.0 Unported",
  41582. false,
  41583. false
  41584. ],
  41585. "CC-BY-SA-3.0-AT": [
  41586. "Creative Commons Attribution-Share Alike 3.0 Austria",
  41587. false,
  41588. false
  41589. ],
  41590. "CC-BY-SA-4.0": [
  41591. "Creative Commons Attribution Share Alike 4.0 International",
  41592. false,
  41593. false
  41594. ],
  41595. "CC-PDDC": [
  41596. "Creative Commons Public Domain Dedication and Certification",
  41597. false,
  41598. false
  41599. ],
  41600. "CC0-1.0": [
  41601. "Creative Commons Zero v1.0 Universal",
  41602. false,
  41603. false
  41604. ],
  41605. "CDDL-1.0": [
  41606. "Common Development and Distribution License 1.0",
  41607. true,
  41608. false
  41609. ],
  41610. "CDDL-1.1": [
  41611. "Common Development and Distribution License 1.1",
  41612. false,
  41613. false
  41614. ],
  41615. "CDLA-Permissive-1.0": [
  41616. "Community Data License Agreement Permissive 1.0",
  41617. false,
  41618. false
  41619. ],
  41620. "CDLA-Sharing-1.0": [
  41621. "Community Data License Agreement Sharing 1.0",
  41622. false,
  41623. false
  41624. ],
  41625. "CECILL-1.0": [
  41626. "CeCILL Free Software License Agreement v1.0",
  41627. false,
  41628. false
  41629. ],
  41630. "CECILL-1.1": [
  41631. "CeCILL Free Software License Agreement v1.1",
  41632. false,
  41633. false
  41634. ],
  41635. "CECILL-2.0": [
  41636. "CeCILL Free Software License Agreement v2.0",
  41637. false,
  41638. false
  41639. ],
  41640. "CECILL-2.1": [
  41641. "CeCILL Free Software License Agreement v2.1",
  41642. true,
  41643. false
  41644. ],
  41645. "CECILL-B": [
  41646. "CeCILL-B Free Software License Agreement",
  41647. false,
  41648. false
  41649. ],
  41650. "CECILL-C": [
  41651. "CeCILL-C Free Software License Agreement",
  41652. false,
  41653. false
  41654. ],
  41655. "CERN-OHL-1.1": [
  41656. "CERN Open Hardware Licence v1.1",
  41657. false,
  41658. false
  41659. ],
  41660. "CERN-OHL-1.2": [
  41661. "CERN Open Hardware Licence v1.2",
  41662. false,
  41663. false
  41664. ],
  41665. "CERN-OHL-P-2.0": [
  41666. "CERN Open Hardware Licence Version 2 - Permissive",
  41667. false,
  41668. false
  41669. ],
  41670. "CERN-OHL-S-2.0": [
  41671. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  41672. false,
  41673. false
  41674. ],
  41675. "CERN-OHL-W-2.0": [
  41676. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  41677. false,
  41678. false
  41679. ],
  41680. "ClArtistic": [
  41681. "Clarified Artistic License",
  41682. false,
  41683. false
  41684. ],
  41685. "CNRI-Jython": [
  41686. "CNRI Jython License",
  41687. false,
  41688. false
  41689. ],
  41690. "CNRI-Python": [
  41691. "CNRI Python License",
  41692. true,
  41693. false
  41694. ],
  41695. "CNRI-Python-GPL-Compatible": [
  41696. "CNRI Python Open Source GPL Compatible License Agreement",
  41697. false,
  41698. false
  41699. ],
  41700. "Condor-1.1": [
  41701. "Condor Public License v1.1",
  41702. false,
  41703. false
  41704. ],
  41705. "copyleft-next-0.3.0": [
  41706. "copyleft-next 0.3.0",
  41707. false,
  41708. false
  41709. ],
  41710. "copyleft-next-0.3.1": [
  41711. "copyleft-next 0.3.1",
  41712. false,
  41713. false
  41714. ],
  41715. "CPAL-1.0": [
  41716. "Common Public Attribution License 1.0",
  41717. true,
  41718. false
  41719. ],
  41720. "CPL-1.0": [
  41721. "Common Public License 1.0",
  41722. true,
  41723. false
  41724. ],
  41725. "CPOL-1.02": [
  41726. "Code Project Open License 1.02",
  41727. false,
  41728. false
  41729. ],
  41730. "Crossword": [
  41731. "Crossword License",
  41732. false,
  41733. false
  41734. ],
  41735. "CrystalStacker": [
  41736. "CrystalStacker License",
  41737. false,
  41738. false
  41739. ],
  41740. "CUA-OPL-1.0": [
  41741. "CUA Office Public License v1.0",
  41742. true,
  41743. false
  41744. ],
  41745. "Cube": [
  41746. "Cube License",
  41747. false,
  41748. false
  41749. ],
  41750. "curl": [
  41751. "curl License",
  41752. false,
  41753. false
  41754. ],
  41755. "D-FSL-1.0": [
  41756. "Deutsche Freie Software Lizenz",
  41757. false,
  41758. false
  41759. ],
  41760. "diffmark": [
  41761. "diffmark license",
  41762. false,
  41763. false
  41764. ],
  41765. "DOC": [
  41766. "DOC License",
  41767. false,
  41768. false
  41769. ],
  41770. "Dotseqn": [
  41771. "Dotseqn License",
  41772. false,
  41773. false
  41774. ],
  41775. "DSDP": [
  41776. "DSDP License",
  41777. false,
  41778. false
  41779. ],
  41780. "dvipdfm": [
  41781. "dvipdfm License",
  41782. false,
  41783. false
  41784. ],
  41785. "ECL-1.0": [
  41786. "Educational Community License v1.0",
  41787. true,
  41788. false
  41789. ],
  41790. "ECL-2.0": [
  41791. "Educational Community License v2.0",
  41792. true,
  41793. false
  41794. ],
  41795. "eCos-2.0": [
  41796. "eCos license version 2.0",
  41797. false,
  41798. true
  41799. ],
  41800. "EFL-1.0": [
  41801. "Eiffel Forum License v1.0",
  41802. true,
  41803. false
  41804. ],
  41805. "EFL-2.0": [
  41806. "Eiffel Forum License v2.0",
  41807. true,
  41808. false
  41809. ],
  41810. "eGenix": [
  41811. "eGenix.com Public License 1.1.0",
  41812. false,
  41813. false
  41814. ],
  41815. "Entessa": [
  41816. "Entessa Public License v1.0",
  41817. true,
  41818. false
  41819. ],
  41820. "EPICS": [
  41821. "EPICS Open License",
  41822. false,
  41823. false
  41824. ],
  41825. "EPL-1.0": [
  41826. "Eclipse Public License 1.0",
  41827. true,
  41828. false
  41829. ],
  41830. "EPL-2.0": [
  41831. "Eclipse Public License 2.0",
  41832. true,
  41833. false
  41834. ],
  41835. "ErlPL-1.1": [
  41836. "Erlang Public License v1.1",
  41837. false,
  41838. false
  41839. ],
  41840. "etalab-2.0": [
  41841. "Etalab Open License 2.0",
  41842. false,
  41843. false
  41844. ],
  41845. "EUDatagrid": [
  41846. "EU DataGrid Software License",
  41847. true,
  41848. false
  41849. ],
  41850. "EUPL-1.0": [
  41851. "European Union Public License 1.0",
  41852. false,
  41853. false
  41854. ],
  41855. "EUPL-1.1": [
  41856. "European Union Public License 1.1",
  41857. true,
  41858. false
  41859. ],
  41860. "EUPL-1.2": [
  41861. "European Union Public License 1.2",
  41862. true,
  41863. false
  41864. ],
  41865. "Eurosym": [
  41866. "Eurosym License",
  41867. false,
  41868. false
  41869. ],
  41870. "Fair": [
  41871. "Fair License",
  41872. true,
  41873. false
  41874. ],
  41875. "Frameworx-1.0": [
  41876. "Frameworx Open License 1.0",
  41877. true,
  41878. false
  41879. ],
  41880. "FreeImage": [
  41881. "FreeImage Public License v1.0",
  41882. false,
  41883. false
  41884. ],
  41885. "FSFAP": [
  41886. "FSF All Permissive License",
  41887. false,
  41888. false
  41889. ],
  41890. "FSFUL": [
  41891. "FSF Unlimited License",
  41892. false,
  41893. false
  41894. ],
  41895. "FSFULLR": [
  41896. "FSF Unlimited License (with License Retention)",
  41897. false,
  41898. false
  41899. ],
  41900. "FTL": [
  41901. "Freetype Project License",
  41902. false,
  41903. false
  41904. ],
  41905. "GFDL-1.1": [
  41906. "GNU Free Documentation License v1.1",
  41907. false,
  41908. true
  41909. ],
  41910. "GFDL-1.1-invariants-only": [
  41911. "GNU Free Documentation License v1.1 only - invariants",
  41912. false,
  41913. false
  41914. ],
  41915. "GFDL-1.1-invariants-or-later": [
  41916. "GNU Free Documentation License v1.1 or later - invariants",
  41917. false,
  41918. false
  41919. ],
  41920. "GFDL-1.1-no-invariants-only": [
  41921. "GNU Free Documentation License v1.1 only - no invariants",
  41922. false,
  41923. false
  41924. ],
  41925. "GFDL-1.1-no-invariants-or-later": [
  41926. "GNU Free Documentation License v1.1 or later - no invariants",
  41927. false,
  41928. false
  41929. ],
  41930. "GFDL-1.1-only": [
  41931. "GNU Free Documentation License v1.1 only",
  41932. false,
  41933. false
  41934. ],
  41935. "GFDL-1.1-or-later": [
  41936. "GNU Free Documentation License v1.1 or later",
  41937. false,
  41938. false
  41939. ],
  41940. "GFDL-1.2": [
  41941. "GNU Free Documentation License v1.2",
  41942. false,
  41943. true
  41944. ],
  41945. "GFDL-1.2-invariants-only": [
  41946. "GNU Free Documentation License v1.2 only - invariants",
  41947. false,
  41948. false
  41949. ],
  41950. "GFDL-1.2-invariants-or-later": [
  41951. "GNU Free Documentation License v1.2 or later - invariants",
  41952. false,
  41953. false
  41954. ],
  41955. "GFDL-1.2-no-invariants-only": [
  41956. "GNU Free Documentation License v1.2 only - no invariants",
  41957. false,
  41958. false
  41959. ],
  41960. "GFDL-1.2-no-invariants-or-later": [
  41961. "GNU Free Documentation License v1.2 or later - no invariants",
  41962. false,
  41963. false
  41964. ],
  41965. "GFDL-1.2-only": [
  41966. "GNU Free Documentation License v1.2 only",
  41967. false,
  41968. false
  41969. ],
  41970. "GFDL-1.2-or-later": [
  41971. "GNU Free Documentation License v1.2 or later",
  41972. false,
  41973. false
  41974. ],
  41975. "GFDL-1.3": [
  41976. "GNU Free Documentation License v1.3",
  41977. false,
  41978. true
  41979. ],
  41980. "GFDL-1.3-invariants-only": [
  41981. "GNU Free Documentation License v1.3 only - invariants",
  41982. false,
  41983. false
  41984. ],
  41985. "GFDL-1.3-invariants-or-later": [
  41986. "GNU Free Documentation License v1.3 or later - invariants",
  41987. false,
  41988. false
  41989. ],
  41990. "GFDL-1.3-no-invariants-only": [
  41991. "GNU Free Documentation License v1.3 only - no invariants",
  41992. false,
  41993. false
  41994. ],
  41995. "GFDL-1.3-no-invariants-or-later": [
  41996. "GNU Free Documentation License v1.3 or later - no invariants",
  41997. false,
  41998. false
  41999. ],
  42000. "GFDL-1.3-only": [
  42001. "GNU Free Documentation License v1.3 only",
  42002. false,
  42003. false
  42004. ],
  42005. "GFDL-1.3-or-later": [
  42006. "GNU Free Documentation License v1.3 or later",
  42007. false,
  42008. false
  42009. ],
  42010. "Giftware": [
  42011. "Giftware License",
  42012. false,
  42013. false
  42014. ],
  42015. "GL2PS": [
  42016. "GL2PS License",
  42017. false,
  42018. false
  42019. ],
  42020. "Glide": [
  42021. "3dfx Glide License",
  42022. false,
  42023. false
  42024. ],
  42025. "Glulxe": [
  42026. "Glulxe License",
  42027. false,
  42028. false
  42029. ],
  42030. "GLWTPL": [
  42031. "Good Luck With That Public License",
  42032. false,
  42033. false
  42034. ],
  42035. "gnuplot": [
  42036. "gnuplot License",
  42037. false,
  42038. false
  42039. ],
  42040. "GPL-1.0": [
  42041. "GNU General Public License v1.0 only",
  42042. false,
  42043. true
  42044. ],
  42045. "GPL-1.0+": [
  42046. "GNU General Public License v1.0 or later",
  42047. false,
  42048. true
  42049. ],
  42050. "GPL-1.0-only": [
  42051. "GNU General Public License v1.0 only",
  42052. false,
  42053. false
  42054. ],
  42055. "GPL-1.0-or-later": [
  42056. "GNU General Public License v1.0 or later",
  42057. false,
  42058. false
  42059. ],
  42060. "GPL-2.0": [
  42061. "GNU General Public License v2.0 only",
  42062. true,
  42063. true
  42064. ],
  42065. "GPL-2.0+": [
  42066. "GNU General Public License v2.0 or later",
  42067. true,
  42068. true
  42069. ],
  42070. "GPL-2.0-only": [
  42071. "GNU General Public License v2.0 only",
  42072. true,
  42073. false
  42074. ],
  42075. "GPL-2.0-or-later": [
  42076. "GNU General Public License v2.0 or later",
  42077. true,
  42078. false
  42079. ],
  42080. "GPL-2.0-with-autoconf-exception": [
  42081. "GNU General Public License v2.0 w/Autoconf exception",
  42082. false,
  42083. true
  42084. ],
  42085. "GPL-2.0-with-bison-exception": [
  42086. "GNU General Public License v2.0 w/Bison exception",
  42087. false,
  42088. true
  42089. ],
  42090. "GPL-2.0-with-classpath-exception": [
  42091. "GNU General Public License v2.0 w/Classpath exception",
  42092. false,
  42093. true
  42094. ],
  42095. "GPL-2.0-with-font-exception": [
  42096. "GNU General Public License v2.0 w/Font exception",
  42097. false,
  42098. true
  42099. ],
  42100. "GPL-2.0-with-GCC-exception": [
  42101. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  42102. false,
  42103. true
  42104. ],
  42105. "GPL-3.0": [
  42106. "GNU General Public License v3.0 only",
  42107. true,
  42108. true
  42109. ],
  42110. "GPL-3.0+": [
  42111. "GNU General Public License v3.0 or later",
  42112. true,
  42113. true
  42114. ],
  42115. "GPL-3.0-only": [
  42116. "GNU General Public License v3.0 only",
  42117. true,
  42118. false
  42119. ],
  42120. "GPL-3.0-or-later": [
  42121. "GNU General Public License v3.0 or later",
  42122. true,
  42123. false
  42124. ],
  42125. "GPL-3.0-with-autoconf-exception": [
  42126. "GNU General Public License v3.0 w/Autoconf exception",
  42127. false,
  42128. true
  42129. ],
  42130. "GPL-3.0-with-GCC-exception": [
  42131. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  42132. true,
  42133. true
  42134. ],
  42135. "gSOAP-1.3b": [
  42136. "gSOAP Public License v1.3b",
  42137. false,
  42138. false
  42139. ],
  42140. "HaskellReport": [
  42141. "Haskell Language Report License",
  42142. false,
  42143. false
  42144. ],
  42145. "Hippocratic-2.1": [
  42146. "Hippocratic License 2.1",
  42147. false,
  42148. false
  42149. ],
  42150. "HPND": [
  42151. "Historical Permission Notice and Disclaimer",
  42152. true,
  42153. false
  42154. ],
  42155. "HPND-sell-variant": [
  42156. "Historical Permission Notice and Disclaimer - sell variant",
  42157. false,
  42158. false
  42159. ],
  42160. "HTMLTIDY": [
  42161. "HTML Tidy License",
  42162. false,
  42163. false
  42164. ],
  42165. "IBM-pibs": [
  42166. "IBM PowerPC Initialization and Boot Software",
  42167. false,
  42168. false
  42169. ],
  42170. "ICU": [
  42171. "ICU License",
  42172. false,
  42173. false
  42174. ],
  42175. "IJG": [
  42176. "Independent JPEG Group License",
  42177. false,
  42178. false
  42179. ],
  42180. "ImageMagick": [
  42181. "ImageMagick License",
  42182. false,
  42183. false
  42184. ],
  42185. "iMatix": [
  42186. "iMatix Standard Function Library Agreement",
  42187. false,
  42188. false
  42189. ],
  42190. "Imlib2": [
  42191. "Imlib2 License",
  42192. false,
  42193. false
  42194. ],
  42195. "Info-ZIP": [
  42196. "Info-ZIP License",
  42197. false,
  42198. false
  42199. ],
  42200. "Intel": [
  42201. "Intel Open Source License",
  42202. true,
  42203. false
  42204. ],
  42205. "Intel-ACPI": [
  42206. "Intel ACPI Software License Agreement",
  42207. false,
  42208. false
  42209. ],
  42210. "Interbase-1.0": [
  42211. "Interbase Public License v1.0",
  42212. false,
  42213. false
  42214. ],
  42215. "IPA": [
  42216. "IPA Font License",
  42217. true,
  42218. false
  42219. ],
  42220. "IPL-1.0": [
  42221. "IBM Public License v1.0",
  42222. true,
  42223. false
  42224. ],
  42225. "ISC": [
  42226. "ISC License",
  42227. true,
  42228. false
  42229. ],
  42230. "JasPer-2.0": [
  42231. "JasPer License",
  42232. false,
  42233. false
  42234. ],
  42235. "JPNIC": [
  42236. "Japan Network Information Center License",
  42237. false,
  42238. false
  42239. ],
  42240. "JSON": [
  42241. "JSON License",
  42242. false,
  42243. false
  42244. ],
  42245. "LAL-1.2": [
  42246. "Licence Art Libre 1.2",
  42247. false,
  42248. false
  42249. ],
  42250. "LAL-1.3": [
  42251. "Licence Art Libre 1.3",
  42252. false,
  42253. false
  42254. ],
  42255. "Latex2e": [
  42256. "Latex2e License",
  42257. false,
  42258. false
  42259. ],
  42260. "Leptonica": [
  42261. "Leptonica License",
  42262. false,
  42263. false
  42264. ],
  42265. "LGPL-2.0": [
  42266. "GNU Library General Public License v2 only",
  42267. true,
  42268. true
  42269. ],
  42270. "LGPL-2.0+": [
  42271. "GNU Library General Public License v2 or later",
  42272. true,
  42273. true
  42274. ],
  42275. "LGPL-2.0-only": [
  42276. "GNU Library General Public License v2 only",
  42277. true,
  42278. false
  42279. ],
  42280. "LGPL-2.0-or-later": [
  42281. "GNU Library General Public License v2 or later",
  42282. true,
  42283. false
  42284. ],
  42285. "LGPL-2.1": [
  42286. "GNU Lesser General Public License v2.1 only",
  42287. true,
  42288. true
  42289. ],
  42290. "LGPL-2.1+": [
  42291. "GNU Library General Public License v2.1 or later",
  42292. true,
  42293. true
  42294. ],
  42295. "LGPL-2.1-only": [
  42296. "GNU Lesser General Public License v2.1 only",
  42297. true,
  42298. false
  42299. ],
  42300. "LGPL-2.1-or-later": [
  42301. "GNU Lesser General Public License v2.1 or later",
  42302. true,
  42303. false
  42304. ],
  42305. "LGPL-3.0": [
  42306. "GNU Lesser General Public License v3.0 only",
  42307. true,
  42308. true
  42309. ],
  42310. "LGPL-3.0+": [
  42311. "GNU Lesser General Public License v3.0 or later",
  42312. true,
  42313. true
  42314. ],
  42315. "LGPL-3.0-only": [
  42316. "GNU Lesser General Public License v3.0 only",
  42317. true,
  42318. false
  42319. ],
  42320. "LGPL-3.0-or-later": [
  42321. "GNU Lesser General Public License v3.0 or later",
  42322. true,
  42323. false
  42324. ],
  42325. "LGPLLR": [
  42326. "Lesser General Public License For Linguistic Resources",
  42327. false,
  42328. false
  42329. ],
  42330. "Libpng": [
  42331. "libpng License",
  42332. false,
  42333. false
  42334. ],
  42335. "libpng-2.0": [
  42336. "PNG Reference Library version 2",
  42337. false,
  42338. false
  42339. ],
  42340. "libselinux-1.0": [
  42341. "libselinux public domain notice",
  42342. false,
  42343. false
  42344. ],
  42345. "libtiff": [
  42346. "libtiff License",
  42347. false,
  42348. false
  42349. ],
  42350. "LiLiQ-P-1.1": [
  42351. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  42352. true,
  42353. false
  42354. ],
  42355. "LiLiQ-R-1.1": [
  42356. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  42357. true,
  42358. false
  42359. ],
  42360. "LiLiQ-Rplus-1.1": [
  42361. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  42362. true,
  42363. false
  42364. ],
  42365. "Linux-OpenIB": [
  42366. "Linux Kernel Variant of OpenIB.org license",
  42367. false,
  42368. false
  42369. ],
  42370. "LPL-1.0": [
  42371. "Lucent Public License Version 1.0",
  42372. true,
  42373. false
  42374. ],
  42375. "LPL-1.02": [
  42376. "Lucent Public License v1.02",
  42377. true,
  42378. false
  42379. ],
  42380. "LPPL-1.0": [
  42381. "LaTeX Project Public License v1.0",
  42382. false,
  42383. false
  42384. ],
  42385. "LPPL-1.1": [
  42386. "LaTeX Project Public License v1.1",
  42387. false,
  42388. false
  42389. ],
  42390. "LPPL-1.2": [
  42391. "LaTeX Project Public License v1.2",
  42392. false,
  42393. false
  42394. ],
  42395. "LPPL-1.3a": [
  42396. "LaTeX Project Public License v1.3a",
  42397. false,
  42398. false
  42399. ],
  42400. "LPPL-1.3c": [
  42401. "LaTeX Project Public License v1.3c",
  42402. true,
  42403. false
  42404. ],
  42405. "MakeIndex": [
  42406. "MakeIndex License",
  42407. false,
  42408. false
  42409. ],
  42410. "MirOS": [
  42411. "The MirOS Licence",
  42412. true,
  42413. false
  42414. ],
  42415. "MIT": [
  42416. "MIT License",
  42417. true,
  42418. false
  42419. ],
  42420. "MIT-0": [
  42421. "MIT No Attribution",
  42422. true,
  42423. false
  42424. ],
  42425. "MIT-advertising": [
  42426. "Enlightenment License (e16)",
  42427. false,
  42428. false
  42429. ],
  42430. "MIT-CMU": [
  42431. "CMU License",
  42432. false,
  42433. false
  42434. ],
  42435. "MIT-enna": [
  42436. "enna License",
  42437. false,
  42438. false
  42439. ],
  42440. "MIT-feh": [
  42441. "feh License",
  42442. false,
  42443. false
  42444. ],
  42445. "MIT-open-group": [
  42446. "MIT Open Group variant",
  42447. false,
  42448. false
  42449. ],
  42450. "MITNFA": [
  42451. "MIT +no-false-attribs license",
  42452. false,
  42453. false
  42454. ],
  42455. "Motosoto": [
  42456. "Motosoto License",
  42457. true,
  42458. false
  42459. ],
  42460. "mpich2": [
  42461. "mpich2 License",
  42462. false,
  42463. false
  42464. ],
  42465. "MPL-1.0": [
  42466. "Mozilla Public License 1.0",
  42467. true,
  42468. false
  42469. ],
  42470. "MPL-1.1": [
  42471. "Mozilla Public License 1.1",
  42472. true,
  42473. false
  42474. ],
  42475. "MPL-2.0": [
  42476. "Mozilla Public License 2.0",
  42477. true,
  42478. false
  42479. ],
  42480. "MPL-2.0-no-copyleft-exception": [
  42481. "Mozilla Public License 2.0 (no copyleft exception)",
  42482. true,
  42483. false
  42484. ],
  42485. "MS-PL": [
  42486. "Microsoft Public License",
  42487. true,
  42488. false
  42489. ],
  42490. "MS-RL": [
  42491. "Microsoft Reciprocal License",
  42492. true,
  42493. false
  42494. ],
  42495. "MTLL": [
  42496. "Matrix Template Library License",
  42497. false,
  42498. false
  42499. ],
  42500. "MulanPSL-1.0": [
  42501. "Mulan Permissive Software License, Version 1",
  42502. false,
  42503. false
  42504. ],
  42505. "MulanPSL-2.0": [
  42506. "Mulan Permissive Software License, Version 2",
  42507. true,
  42508. false
  42509. ],
  42510. "Multics": [
  42511. "Multics License",
  42512. true,
  42513. false
  42514. ],
  42515. "Mup": [
  42516. "Mup License",
  42517. false,
  42518. false
  42519. ],
  42520. "NASA-1.3": [
  42521. "NASA Open Source Agreement 1.3",
  42522. true,
  42523. false
  42524. ],
  42525. "Naumen": [
  42526. "Naumen Public License",
  42527. true,
  42528. false
  42529. ],
  42530. "NBPL-1.0": [
  42531. "Net Boolean Public License v1",
  42532. false,
  42533. false
  42534. ],
  42535. "NCGL-UK-2.0": [
  42536. "Non-Commercial Government Licence",
  42537. false,
  42538. false
  42539. ],
  42540. "NCSA": [
  42541. "University of Illinois/NCSA Open Source License",
  42542. true,
  42543. false
  42544. ],
  42545. "Net-SNMP": [
  42546. "Net-SNMP License",
  42547. false,
  42548. false
  42549. ],
  42550. "NetCDF": [
  42551. "NetCDF license",
  42552. false,
  42553. false
  42554. ],
  42555. "Newsletr": [
  42556. "Newsletr License",
  42557. false,
  42558. false
  42559. ],
  42560. "NGPL": [
  42561. "Nethack General Public License",
  42562. true,
  42563. false
  42564. ],
  42565. "NIST-PD": [
  42566. "NIST Public Domain Notice",
  42567. false,
  42568. false
  42569. ],
  42570. "NIST-PD-fallback": [
  42571. "NIST Public Domain Notice with license fallback",
  42572. false,
  42573. false
  42574. ],
  42575. "NLOD-1.0": [
  42576. "Norwegian Licence for Open Government Data",
  42577. false,
  42578. false
  42579. ],
  42580. "NLPL": [
  42581. "No Limit Public License",
  42582. false,
  42583. false
  42584. ],
  42585. "Nokia": [
  42586. "Nokia Open Source License",
  42587. true,
  42588. false
  42589. ],
  42590. "NOSL": [
  42591. "Netizen Open Source License",
  42592. false,
  42593. false
  42594. ],
  42595. "Noweb": [
  42596. "Noweb License",
  42597. false,
  42598. false
  42599. ],
  42600. "NPL-1.0": [
  42601. "Netscape Public License v1.0",
  42602. false,
  42603. false
  42604. ],
  42605. "NPL-1.1": [
  42606. "Netscape Public License v1.1",
  42607. false,
  42608. false
  42609. ],
  42610. "NPOSL-3.0": [
  42611. "Non-Profit Open Software License 3.0",
  42612. true,
  42613. false
  42614. ],
  42615. "NRL": [
  42616. "NRL License",
  42617. false,
  42618. false
  42619. ],
  42620. "NTP": [
  42621. "NTP License",
  42622. true,
  42623. false
  42624. ],
  42625. "NTP-0": [
  42626. "NTP No Attribution",
  42627. false,
  42628. false
  42629. ],
  42630. "Nunit": [
  42631. "Nunit License",
  42632. false,
  42633. true
  42634. ],
  42635. "O-UDA-1.0": [
  42636. "Open Use of Data Agreement v1.0",
  42637. false,
  42638. false
  42639. ],
  42640. "OCCT-PL": [
  42641. "Open CASCADE Technology Public License",
  42642. false,
  42643. false
  42644. ],
  42645. "OCLC-2.0": [
  42646. "OCLC Research Public License 2.0",
  42647. true,
  42648. false
  42649. ],
  42650. "ODbL-1.0": [
  42651. "ODC Open Database License v1.0",
  42652. false,
  42653. false
  42654. ],
  42655. "ODC-By-1.0": [
  42656. "Open Data Commons Attribution License v1.0",
  42657. false,
  42658. false
  42659. ],
  42660. "OFL-1.0": [
  42661. "SIL Open Font License 1.0",
  42662. false,
  42663. false
  42664. ],
  42665. "OFL-1.0-no-RFN": [
  42666. "SIL Open Font License 1.0 with no Reserved Font Name",
  42667. false,
  42668. false
  42669. ],
  42670. "OFL-1.0-RFN": [
  42671. "SIL Open Font License 1.0 with Reserved Font Name",
  42672. false,
  42673. false
  42674. ],
  42675. "OFL-1.1": [
  42676. "SIL Open Font License 1.1",
  42677. true,
  42678. false
  42679. ],
  42680. "OFL-1.1-no-RFN": [
  42681. "SIL Open Font License 1.1 with no Reserved Font Name",
  42682. true,
  42683. false
  42684. ],
  42685. "OFL-1.1-RFN": [
  42686. "SIL Open Font License 1.1 with Reserved Font Name",
  42687. true,
  42688. false
  42689. ],
  42690. "OGC-1.0": [
  42691. "OGC Software License, Version 1.0",
  42692. false,
  42693. false
  42694. ],
  42695. "OGL-Canada-2.0": [
  42696. "Open Government Licence - Canada",
  42697. false,
  42698. false
  42699. ],
  42700. "OGL-UK-1.0": [
  42701. "Open Government Licence v1.0",
  42702. false,
  42703. false
  42704. ],
  42705. "OGL-UK-2.0": [
  42706. "Open Government Licence v2.0",
  42707. false,
  42708. false
  42709. ],
  42710. "OGL-UK-3.0": [
  42711. "Open Government Licence v3.0",
  42712. false,
  42713. false
  42714. ],
  42715. "OGTSL": [
  42716. "Open Group Test Suite License",
  42717. true,
  42718. false
  42719. ],
  42720. "OLDAP-1.1": [
  42721. "Open LDAP Public License v1.1",
  42722. false,
  42723. false
  42724. ],
  42725. "OLDAP-1.2": [
  42726. "Open LDAP Public License v1.2",
  42727. false,
  42728. false
  42729. ],
  42730. "OLDAP-1.3": [
  42731. "Open LDAP Public License v1.3",
  42732. false,
  42733. false
  42734. ],
  42735. "OLDAP-1.4": [
  42736. "Open LDAP Public License v1.4",
  42737. false,
  42738. false
  42739. ],
  42740. "OLDAP-2.0": [
  42741. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  42742. false,
  42743. false
  42744. ],
  42745. "OLDAP-2.0.1": [
  42746. "Open LDAP Public License v2.0.1",
  42747. false,
  42748. false
  42749. ],
  42750. "OLDAP-2.1": [
  42751. "Open LDAP Public License v2.1",
  42752. false,
  42753. false
  42754. ],
  42755. "OLDAP-2.2": [
  42756. "Open LDAP Public License v2.2",
  42757. false,
  42758. false
  42759. ],
  42760. "OLDAP-2.2.1": [
  42761. "Open LDAP Public License v2.2.1",
  42762. false,
  42763. false
  42764. ],
  42765. "OLDAP-2.2.2": [
  42766. "Open LDAP Public License 2.2.2",
  42767. false,
  42768. false
  42769. ],
  42770. "OLDAP-2.3": [
  42771. "Open LDAP Public License v2.3",
  42772. false,
  42773. false
  42774. ],
  42775. "OLDAP-2.4": [
  42776. "Open LDAP Public License v2.4",
  42777. false,
  42778. false
  42779. ],
  42780. "OLDAP-2.5": [
  42781. "Open LDAP Public License v2.5",
  42782. false,
  42783. false
  42784. ],
  42785. "OLDAP-2.6": [
  42786. "Open LDAP Public License v2.6",
  42787. false,
  42788. false
  42789. ],
  42790. "OLDAP-2.7": [
  42791. "Open LDAP Public License v2.7",
  42792. false,
  42793. false
  42794. ],
  42795. "OLDAP-2.8": [
  42796. "Open LDAP Public License v2.8",
  42797. true,
  42798. false
  42799. ],
  42800. "OML": [
  42801. "Open Market License",
  42802. false,
  42803. false
  42804. ],
  42805. "OpenSSL": [
  42806. "OpenSSL License",
  42807. false,
  42808. false
  42809. ],
  42810. "OPL-1.0": [
  42811. "Open Public License v1.0",
  42812. false,
  42813. false
  42814. ],
  42815. "OSET-PL-2.1": [
  42816. "OSET Public License version 2.1",
  42817. true,
  42818. false
  42819. ],
  42820. "OSL-1.0": [
  42821. "Open Software License 1.0",
  42822. true,
  42823. false
  42824. ],
  42825. "OSL-1.1": [
  42826. "Open Software License 1.1",
  42827. false,
  42828. false
  42829. ],
  42830. "OSL-2.0": [
  42831. "Open Software License 2.0",
  42832. true,
  42833. false
  42834. ],
  42835. "OSL-2.1": [
  42836. "Open Software License 2.1",
  42837. true,
  42838. false
  42839. ],
  42840. "OSL-3.0": [
  42841. "Open Software License 3.0",
  42842. true,
  42843. false
  42844. ],
  42845. "Parity-6.0.0": [
  42846. "The Parity Public License 6.0.0",
  42847. false,
  42848. false
  42849. ],
  42850. "Parity-7.0.0": [
  42851. "The Parity Public License 7.0.0",
  42852. false,
  42853. false
  42854. ],
  42855. "PDDL-1.0": [
  42856. "ODC Public Domain Dedication & License 1.0",
  42857. false,
  42858. false
  42859. ],
  42860. "PHP-3.0": [
  42861. "PHP License v3.0",
  42862. true,
  42863. false
  42864. ],
  42865. "PHP-3.01": [
  42866. "PHP License v3.01",
  42867. true,
  42868. false
  42869. ],
  42870. "Plexus": [
  42871. "Plexus Classworlds License",
  42872. false,
  42873. false
  42874. ],
  42875. "PolyForm-Noncommercial-1.0.0": [
  42876. "PolyForm Noncommercial License 1.0.0",
  42877. false,
  42878. false
  42879. ],
  42880. "PolyForm-Small-Business-1.0.0": [
  42881. "PolyForm Small Business License 1.0.0",
  42882. false,
  42883. false
  42884. ],
  42885. "PostgreSQL": [
  42886. "PostgreSQL License",
  42887. true,
  42888. false
  42889. ],
  42890. "PSF-2.0": [
  42891. "Python Software Foundation License 2.0",
  42892. false,
  42893. false
  42894. ],
  42895. "psfrag": [
  42896. "psfrag License",
  42897. false,
  42898. false
  42899. ],
  42900. "psutils": [
  42901. "psutils License",
  42902. false,
  42903. false
  42904. ],
  42905. "Python-2.0": [
  42906. "Python License 2.0",
  42907. true,
  42908. false
  42909. ],
  42910. "Qhull": [
  42911. "Qhull License",
  42912. false,
  42913. false
  42914. ],
  42915. "QPL-1.0": [
  42916. "Q Public License 1.0",
  42917. true,
  42918. false
  42919. ],
  42920. "Rdisc": [
  42921. "Rdisc License",
  42922. false,
  42923. false
  42924. ],
  42925. "RHeCos-1.1": [
  42926. "Red Hat eCos Public License v1.1",
  42927. false,
  42928. false
  42929. ],
  42930. "RPL-1.1": [
  42931. "Reciprocal Public License 1.1",
  42932. true,
  42933. false
  42934. ],
  42935. "RPL-1.5": [
  42936. "Reciprocal Public License 1.5",
  42937. true,
  42938. false
  42939. ],
  42940. "RPSL-1.0": [
  42941. "RealNetworks Public Source License v1.0",
  42942. true,
  42943. false
  42944. ],
  42945. "RSA-MD": [
  42946. "RSA Message-Digest License",
  42947. false,
  42948. false
  42949. ],
  42950. "RSCPL": [
  42951. "Ricoh Source Code Public License",
  42952. true,
  42953. false
  42954. ],
  42955. "Ruby": [
  42956. "Ruby License",
  42957. false,
  42958. false
  42959. ],
  42960. "SAX-PD": [
  42961. "Sax Public Domain Notice",
  42962. false,
  42963. false
  42964. ],
  42965. "Saxpath": [
  42966. "Saxpath License",
  42967. false,
  42968. false
  42969. ],
  42970. "SCEA": [
  42971. "SCEA Shared Source License",
  42972. false,
  42973. false
  42974. ],
  42975. "Sendmail": [
  42976. "Sendmail License",
  42977. false,
  42978. false
  42979. ],
  42980. "Sendmail-8.23": [
  42981. "Sendmail License 8.23",
  42982. false,
  42983. false
  42984. ],
  42985. "SGI-B-1.0": [
  42986. "SGI Free Software License B v1.0",
  42987. false,
  42988. false
  42989. ],
  42990. "SGI-B-1.1": [
  42991. "SGI Free Software License B v1.1",
  42992. false,
  42993. false
  42994. ],
  42995. "SGI-B-2.0": [
  42996. "SGI Free Software License B v2.0",
  42997. false,
  42998. false
  42999. ],
  43000. "SHL-0.5": [
  43001. "Solderpad Hardware License v0.5",
  43002. false,
  43003. false
  43004. ],
  43005. "SHL-0.51": [
  43006. "Solderpad Hardware License, Version 0.51",
  43007. false,
  43008. false
  43009. ],
  43010. "SimPL-2.0": [
  43011. "Simple Public License 2.0",
  43012. true,
  43013. false
  43014. ],
  43015. "SISSL": [
  43016. "Sun Industry Standards Source License v1.1",
  43017. true,
  43018. false
  43019. ],
  43020. "SISSL-1.2": [
  43021. "Sun Industry Standards Source License v1.2",
  43022. false,
  43023. false
  43024. ],
  43025. "Sleepycat": [
  43026. "Sleepycat License",
  43027. true,
  43028. false
  43029. ],
  43030. "SMLNJ": [
  43031. "Standard ML of New Jersey License",
  43032. false,
  43033. false
  43034. ],
  43035. "SMPPL": [
  43036. "Secure Messaging Protocol Public License",
  43037. false,
  43038. false
  43039. ],
  43040. "SNIA": [
  43041. "SNIA Public License 1.1",
  43042. false,
  43043. false
  43044. ],
  43045. "Spencer-86": [
  43046. "Spencer License 86",
  43047. false,
  43048. false
  43049. ],
  43050. "Spencer-94": [
  43051. "Spencer License 94",
  43052. false,
  43053. false
  43054. ],
  43055. "Spencer-99": [
  43056. "Spencer License 99",
  43057. false,
  43058. false
  43059. ],
  43060. "SPL-1.0": [
  43061. "Sun Public License v1.0",
  43062. true,
  43063. false
  43064. ],
  43065. "SSH-OpenSSH": [
  43066. "SSH OpenSSH license",
  43067. false,
  43068. false
  43069. ],
  43070. "SSH-short": [
  43071. "SSH short notice",
  43072. false,
  43073. false
  43074. ],
  43075. "SSPL-1.0": [
  43076. "Server Side Public License, v 1",
  43077. false,
  43078. false
  43079. ],
  43080. "StandardML-NJ": [
  43081. "Standard ML of New Jersey License",
  43082. false,
  43083. true
  43084. ],
  43085. "SugarCRM-1.1.3": [
  43086. "SugarCRM Public License v1.1.3",
  43087. false,
  43088. false
  43089. ],
  43090. "SWL": [
  43091. "Scheme Widget Library (SWL) Software License Agreement",
  43092. false,
  43093. false
  43094. ],
  43095. "TAPR-OHL-1.0": [
  43096. "TAPR Open Hardware License v1.0",
  43097. false,
  43098. false
  43099. ],
  43100. "TCL": [
  43101. "TCL/TK License",
  43102. false,
  43103. false
  43104. ],
  43105. "TCP-wrappers": [
  43106. "TCP Wrappers License",
  43107. false,
  43108. false
  43109. ],
  43110. "TMate": [
  43111. "TMate Open Source License",
  43112. false,
  43113. false
  43114. ],
  43115. "TORQUE-1.1": [
  43116. "TORQUE v2.5+ Software License v1.1",
  43117. false,
  43118. false
  43119. ],
  43120. "TOSL": [
  43121. "Trusster Open Source License",
  43122. false,
  43123. false
  43124. ],
  43125. "TU-Berlin-1.0": [
  43126. "Technische Universitaet Berlin License 1.0",
  43127. false,
  43128. false
  43129. ],
  43130. "TU-Berlin-2.0": [
  43131. "Technische Universitaet Berlin License 2.0",
  43132. false,
  43133. false
  43134. ],
  43135. "UCL-1.0": [
  43136. "Upstream Compatibility License v1.0",
  43137. true,
  43138. false
  43139. ],
  43140. "Unicode-DFS-2015": [
  43141. "Unicode License Agreement - Data Files and Software (2015)",
  43142. false,
  43143. false
  43144. ],
  43145. "Unicode-DFS-2016": [
  43146. "Unicode License Agreement - Data Files and Software (2016)",
  43147. true,
  43148. false
  43149. ],
  43150. "Unicode-TOU": [
  43151. "Unicode Terms of Use",
  43152. false,
  43153. false
  43154. ],
  43155. "Unlicense": [
  43156. "The Unlicense",
  43157. true,
  43158. false
  43159. ],
  43160. "UPL-1.0": [
  43161. "Universal Permissive License v1.0",
  43162. true,
  43163. false
  43164. ],
  43165. "Vim": [
  43166. "Vim License",
  43167. false,
  43168. false
  43169. ],
  43170. "VOSTROM": [
  43171. "VOSTROM Public License for Open Source",
  43172. false,
  43173. false
  43174. ],
  43175. "VSL-1.0": [
  43176. "Vovida Software License v1.0",
  43177. true,
  43178. false
  43179. ],
  43180. "W3C": [
  43181. "W3C Software Notice and License (2002-12-31)",
  43182. true,
  43183. false
  43184. ],
  43185. "W3C-19980720": [
  43186. "W3C Software Notice and License (1998-07-20)",
  43187. false,
  43188. false
  43189. ],
  43190. "W3C-20150513": [
  43191. "W3C Software Notice and Document License (2015-05-13)",
  43192. false,
  43193. false
  43194. ],
  43195. "Watcom-1.0": [
  43196. "Sybase Open Watcom Public License 1.0",
  43197. true,
  43198. false
  43199. ],
  43200. "Wsuipa": [
  43201. "Wsuipa License",
  43202. false,
  43203. false
  43204. ],
  43205. "WTFPL": [
  43206. "Do What The F*ck You Want To Public License",
  43207. false,
  43208. false
  43209. ],
  43210. "wxWindows": [
  43211. "wxWindows Library License",
  43212. false,
  43213. true
  43214. ],
  43215. "X11": [
  43216. "X11 License",
  43217. false,
  43218. false
  43219. ],
  43220. "Xerox": [
  43221. "Xerox License",
  43222. false,
  43223. false
  43224. ],
  43225. "XFree86-1.1": [
  43226. "XFree86 License 1.1",
  43227. false,
  43228. false
  43229. ],
  43230. "xinetd": [
  43231. "xinetd License",
  43232. false,
  43233. false
  43234. ],
  43235. "Xnet": [
  43236. "X.Net License",
  43237. true,
  43238. false
  43239. ],
  43240. "xpp": [
  43241. "XPP License",
  43242. false,
  43243. false
  43244. ],
  43245. "XSkat": [
  43246. "XSkat License",
  43247. false,
  43248. false
  43249. ],
  43250. "YPL-1.0": [
  43251. "Yahoo! Public License v1.0",
  43252. false,
  43253. false
  43254. ],
  43255. "YPL-1.1": [
  43256. "Yahoo! Public License v1.1",
  43257. false,
  43258. false
  43259. ],
  43260. "Zed": [
  43261. "Zed License",
  43262. false,
  43263. false
  43264. ],
  43265. "Zend-2.0": [
  43266. "Zend License v2.0",
  43267. false,
  43268. false
  43269. ],
  43270. "Zimbra-1.3": [
  43271. "Zimbra Public License v1.3",
  43272. false,
  43273. false
  43274. ],
  43275. "Zimbra-1.4": [
  43276. "Zimbra Public License v1.4",
  43277. false,
  43278. false
  43279. ],
  43280. "Zlib": [
  43281. "zlib License",
  43282. true,
  43283. false
  43284. ],
  43285. "zlib-acknowledgement": [
  43286. "zlib/libpng License with Acknowledgement",
  43287. false,
  43288. false
  43289. ],
  43290. "ZPL-1.1": [
  43291. "Zope Public License 1.1",
  43292. false,
  43293. false
  43294. ],
  43295. "ZPL-2.0": [
  43296. "Zope Public License 2.0",
  43297. true,
  43298. false
  43299. ],
  43300. "ZPL-2.1": [
  43301. "Zope Public License 2.1",
  43302. false,
  43303. false
  43304. ]
  43305. }<?php
  43306. namespace Composer\Spdx;
  43307. class SpdxLicenses
  43308. {
  43309. const LICENSES_FILE = 'spdx-licenses.json';
  43310. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  43311. private $licenses;
  43312. private $licensesExpression;
  43313. private $exceptions;
  43314. private $exceptionsExpression;
  43315. public function __construct()
  43316. {
  43317. $this->loadLicenses();
  43318. $this->loadExceptions();
  43319. }
  43320. public function getLicenseByIdentifier($identifier)
  43321. {
  43322. $key = strtolower($identifier);
  43323. if (!isset($this->licenses[$key])) {
  43324. return;
  43325. }
  43326. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  43327. return array(
  43328. $name,
  43329. $isOsiApproved,
  43330. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  43331. $isDeprecatedLicenseId,
  43332. );
  43333. }
  43334. public function getLicenses()
  43335. {
  43336. return $this->licenses;
  43337. }
  43338. public function getExceptionByIdentifier($identifier)
  43339. {
  43340. $key = strtolower($identifier);
  43341. if (!isset($this->exceptions[$key])) {
  43342. return;
  43343. }
  43344. list($identifier, $name) = $this->exceptions[$key];
  43345. return array(
  43346. $name,
  43347. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  43348. );
  43349. }
  43350. public function getIdentifierByName($name)
  43351. {
  43352. foreach ($this->licenses as $licenseData) {
  43353. if ($licenseData[1] === $name) {
  43354. return $licenseData[0];
  43355. }
  43356. }
  43357. foreach ($this->exceptions as $licenseData) {
  43358. if ($licenseData[1] === $name) {
  43359. return $licenseData[0];
  43360. }
  43361. }
  43362. }
  43363. public function isOsiApprovedByIdentifier($identifier)
  43364. {
  43365. return $this->licenses[strtolower($identifier)][2];
  43366. }
  43367. public function isDeprecatedByIdentifier($identifier)
  43368. {
  43369. return $this->licenses[strtolower($identifier)][3];
  43370. }
  43371. public function validate($license)
  43372. {
  43373. if (is_array($license)) {
  43374. $count = count($license);
  43375. if ($count !== count(array_filter($license, 'is_string'))) {
  43376. throw new \InvalidArgumentException('Array of strings expected.');
  43377. }
  43378. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  43379. }
  43380. if (!is_string($license)) {
  43381. throw new \InvalidArgumentException(sprintf(
  43382. 'Array or String expected, %s given.',
  43383. gettype($license)
  43384. ));
  43385. }
  43386. return $this->isValidLicenseString($license);
  43387. }
  43388. public static function getResourcesDir()
  43389. {
  43390. return dirname(__DIR__) . '/res';
  43391. }
  43392. private function loadLicenses()
  43393. {
  43394. if (null !== $this->licenses) {
  43395. return;
  43396. }
  43397. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  43398. $this->licenses = array();
  43399. foreach (json_decode($json, true) as $identifier => $license) {
  43400. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  43401. }
  43402. }
  43403. private function loadExceptions()
  43404. {
  43405. if (null !== $this->exceptions) {
  43406. return;
  43407. }
  43408. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  43409. $this->exceptions = array();
  43410. foreach (json_decode($json, true) as $identifier => $exception) {
  43411. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  43412. }
  43413. }
  43414. private function getLicensesExpression()
  43415. {
  43416. if (null === $this->licensesExpression) {
  43417. $licenses = array_map('preg_quote', array_keys($this->licenses));
  43418. rsort($licenses);
  43419. $licenses = implode('|', $licenses);
  43420. $this->licensesExpression = $licenses;
  43421. }
  43422. return $this->licensesExpression;
  43423. }
  43424. private function getExceptionsExpression()
  43425. {
  43426. if (null === $this->exceptionsExpression) {
  43427. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  43428. rsort($exceptions);
  43429. $exceptions = implode('|', $exceptions);
  43430. $this->exceptionsExpression = $exceptions;
  43431. }
  43432. return $this->exceptionsExpression;
  43433. }
  43434. private function isValidLicenseString($license)
  43435. {
  43436. if (isset($this->licenses[strtolower($license)])) {
  43437. return true;
  43438. }
  43439. $licenses = $this->getLicensesExpression();
  43440. $exceptions = $this->getExceptionsExpression();
  43441. $regex = <<<REGEX
  43442. {
  43443. (?(DEFINE)
  43444. # idstring: 1*( ALPHA / DIGIT / - / . )
  43445. (?<idstring>[\pL\pN.-]{1,})
  43446. # license-id: taken from list
  43447. (?<licenseid>${licenses})
  43448. # license-exception-id: taken from list
  43449. (?<licenseexceptionid>${exceptions})
  43450. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  43451. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  43452. # simple-expresssion: license-id / license-id+ / license-ref
  43453. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  43454. # compound-expression: 1*(
  43455. # simple-expression /
  43456. # simple-expression WITH license-exception-id /
  43457. # compound-expression AND compound-expression /
  43458. # compound-expression OR compound-expression
  43459. # ) / ( compound-expression ) )
  43460. (?<compound_head>
  43461. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  43462. | \( \s* (?&compound_expression) \s* \)
  43463. )
  43464. (?<compound_expression>
  43465. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  43466. )
  43467. # license-expression: 1*1(simple-expression / compound-expression)
  43468. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  43469. ) # end of define
  43470. ^(NONE | NOASSERTION | (?&license_expression))$
  43471. }xi
  43472. REGEX;
  43473. $match = preg_match($regex, $license);
  43474. if (0 === $match) {
  43475. return false;
  43476. }
  43477. if (false === $match) {
  43478. throw new \RuntimeException('Regex failed to compile/run.');
  43479. }
  43480. return true;
  43481. }
  43482. }
  43483. MIT License
  43484. Copyright (c) 2017 Composer
  43485. Permission is hereby granted, free of charge, to any person obtaining a copy
  43486. of this software and associated documentation files (the "Software"), to deal
  43487. in the Software without restriction, including without limitation the rights
  43488. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  43489. copies of the Software, and to permit persons to whom the Software is
  43490. furnished to do so, subject to the following conditions:
  43491. The above copyright notice and this permission notice shall be included in all
  43492. copies or substantial portions of the Software.
  43493. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  43494. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  43495. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  43496. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  43497. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  43498. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  43499. SOFTWARE.
  43500. <?php
  43501. namespace Composer\XdebugHandler;
  43502. class PhpConfig
  43503. {
  43504. public function useOriginal()
  43505. {
  43506. $this->getDataAndReset();
  43507. return array();
  43508. }
  43509. public function useStandard()
  43510. {
  43511. if ($data = $this->getDataAndReset()) {
  43512. return array('-n', '-c', $data['tmpIni']);
  43513. }
  43514. return array();
  43515. }
  43516. public function usePersistent()
  43517. {
  43518. if ($data = $this->getDataAndReset()) {
  43519. Process::setEnv('PHPRC', $data['tmpIni']);
  43520. Process::setEnv('PHP_INI_SCAN_DIR', '');
  43521. }
  43522. return array();
  43523. }
  43524. private function getDataAndReset()
  43525. {
  43526. if ($data = XdebugHandler::getRestartSettings()) {
  43527. Process::setEnv('PHPRC', $data['phprc']);
  43528. Process::setEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  43529. }
  43530. return $data;
  43531. }
  43532. }
  43533. <?php
  43534. namespace Composer\XdebugHandler;
  43535. class Process
  43536. {
  43537. public static function addColorOption(array $args, $colorOption)
  43538. {
  43539. if (!$colorOption
  43540. || in_array($colorOption, $args)
  43541. || !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
  43542. return $args;
  43543. }
  43544. if (isset($matches[2])) {
  43545. if (false !== ($index = array_search($matches[2].'auto', $args))) {
  43546. $args[$index] = $colorOption;
  43547. return $args;
  43548. } elseif (preg_grep('/^'.$matches[2].'/', $args)) {
  43549. return $args;
  43550. }
  43551. } elseif (in_array('--no-'.$matches[1], $args)) {
  43552. return $args;
  43553. }
  43554. if (false !== getenv('NO_COLOR')) {
  43555. return $args;
  43556. }
  43557. if (false !== ($index = array_search('--', $args))) {
  43558. array_splice($args, $index, 0, $colorOption);
  43559. } else {
  43560. $args[] = $colorOption;
  43561. }
  43562. return $args;
  43563. }
  43564. public static function escape($arg, $meta = true, $module = false)
  43565. {
  43566. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  43567. return "'".str_replace("'", "'\\''", $arg)."'";
  43568. }
  43569. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  43570. $arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  43571. if ($meta) {
  43572. $meta = $dquotes || preg_match('/%[^%]+%/', $arg);
  43573. if (!$meta) {
  43574. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  43575. } elseif ($module && !$dquotes && $quote) {
  43576. $meta = false;
  43577. }
  43578. }
  43579. if ($quote) {
  43580. $arg = '"'.preg_replace('/(\\\\*)$/', '$1$1', $arg).'"';
  43581. }
  43582. if ($meta) {
  43583. $arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
  43584. }
  43585. return $arg;
  43586. }
  43587. public static function supportsColor($output)
  43588. {
  43589. if ('Hyper' === getenv('TERM_PROGRAM')) {
  43590. return true;
  43591. }
  43592. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  43593. return (function_exists('sapi_windows_vt100_support')
  43594. && sapi_windows_vt100_support($output))
  43595. || false !== getenv('ANSICON')
  43596. || 'ON' === getenv('ConEmuANSI')
  43597. || 'xterm' === getenv('TERM');
  43598. }
  43599. if (function_exists('stream_isatty')) {
  43600. return stream_isatty($output);
  43601. }
  43602. if (function_exists('posix_isatty')) {
  43603. return posix_isatty($output);
  43604. }
  43605. $stat = fstat($output);
  43606. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  43607. }
  43608. public static function setEnv($name, $value = false)
  43609. {
  43610. $unset = false === $value;
  43611. if (!putenv($unset ? $name : $name.'='.$value)) {
  43612. return false;
  43613. }
  43614. if ($unset) {
  43615. unset($_SERVER[$name]);
  43616. } else {
  43617. $_SERVER[$name] = $value;
  43618. }
  43619. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  43620. if ($unset) {
  43621. unset($_ENV[$name]);
  43622. } else {
  43623. $_ENV[$name] = $value;
  43624. }
  43625. }
  43626. return true;
  43627. }
  43628. }
  43629. <?php
  43630. namespace Composer\XdebugHandler;
  43631. use Psr\Log\LoggerInterface;
  43632. use Psr\Log\LogLevel;
  43633. class Status
  43634. {
  43635. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  43636. const CHECK = 'Check';
  43637. const ERROR = 'Error';
  43638. const INFO = 'Info';
  43639. const NORESTART = 'NoRestart';
  43640. const RESTART = 'Restart';
  43641. const RESTARTING = 'Restarting';
  43642. const RESTARTED = 'Restarted';
  43643. private $debug;
  43644. private $envAllowXdebug;
  43645. private $loaded;
  43646. private $logger;
  43647. private $time;
  43648. public function __construct($envAllowXdebug, $debug)
  43649. {
  43650. $start = getenv(self::ENV_RESTART);
  43651. Process::setEnv(self::ENV_RESTART);
  43652. $this->time = $start ? round((microtime(true) - $start) * 1000) : 0;
  43653. $this->envAllowXdebug = $envAllowXdebug;
  43654. $this->debug = $debug && defined('STDERR');
  43655. }
  43656. public function setLogger(LoggerInterface $logger)
  43657. {
  43658. $this->logger = $logger;
  43659. }
  43660. public function report($op, $data)
  43661. {
  43662. if ($this->logger || $this->debug) {
  43663. call_user_func(array($this, 'report'.$op), $data);
  43664. }
  43665. }
  43666. private function output($text, $level = null)
  43667. {
  43668. if ($this->logger) {
  43669. $this->logger->log($level ?: LogLevel::DEBUG, $text);
  43670. }
  43671. if ($this->debug) {
  43672. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  43673. }
  43674. }
  43675. private function reportCheck($loaded)
  43676. {
  43677. $this->loaded = $loaded;
  43678. $this->output('Checking '.$this->envAllowXdebug);
  43679. }
  43680. private function reportError($error)
  43681. {
  43682. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  43683. }
  43684. private function reportInfo($info)
  43685. {
  43686. $this->output($info);
  43687. }
  43688. private function reportNoRestart()
  43689. {
  43690. $this->output($this->getLoadedMessage());
  43691. if ($this->loaded) {
  43692. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  43693. if (!getenv($this->envAllowXdebug)) {
  43694. $text .= ' Allowed by application';
  43695. }
  43696. $this->output($text);
  43697. }
  43698. }
  43699. private function reportRestart()
  43700. {
  43701. $this->output($this->getLoadedMessage());
  43702. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  43703. }
  43704. private function reportRestarted()
  43705. {
  43706. $loaded = $this->getLoadedMessage();
  43707. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  43708. $level = $this->loaded ? LogLevel::WARNING : null;
  43709. $this->output($text, $level);
  43710. }
  43711. private function reportRestarting($command)
  43712. {
  43713. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  43714. $this->output($text);
  43715. $text = 'Running '.$command;
  43716. $this->output($text);
  43717. }
  43718. private function getEnvAllow()
  43719. {
  43720. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  43721. }
  43722. private function getLoadedMessage()
  43723. {
  43724. $loaded = $this->loaded ? sprintf('loaded (%s)', $this->loaded) : 'not loaded';
  43725. return 'The Xdebug extension is '.$loaded;
  43726. }
  43727. }
  43728. <?php
  43729. namespace Composer\XdebugHandler;
  43730. use Psr\Log\LoggerInterface;
  43731. class XdebugHandler
  43732. {
  43733. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  43734. const SUFFIX_INIS = '_ORIGINAL_INIS';
  43735. const RESTART_ID = 'internal';
  43736. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  43737. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  43738. protected $tmpIni;
  43739. private static $inRestart;
  43740. private static $name;
  43741. private static $skipped;
  43742. private $cli;
  43743. private $colorOption;
  43744. private $debug;
  43745. private $envAllowXdebug;
  43746. private $envOriginalInis;
  43747. private $loaded;
  43748. private $persistent;
  43749. private $script;
  43750. private $statusWriter;
  43751. public function __construct($envPrefix, $colorOption = '')
  43752. {
  43753. if (!is_string($envPrefix) || empty($envPrefix) || !is_string($colorOption)) {
  43754. throw new \RuntimeException('Invalid constructor parameter');
  43755. }
  43756. self::$name = strtoupper($envPrefix);
  43757. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  43758. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  43759. $this->colorOption = $colorOption;
  43760. if (extension_loaded('xdebug')) {
  43761. $ext = new \ReflectionExtension('xdebug');
  43762. $this->loaded = $ext->getVersion() ?: 'unknown';
  43763. }
  43764. if ($this->cli = PHP_SAPI === 'cli') {
  43765. $this->debug = getenv(self::DEBUG);
  43766. }
  43767. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  43768. }
  43769. public function setLogger(LoggerInterface $logger)
  43770. {
  43771. $this->statusWriter->setLogger($logger);
  43772. return $this;
  43773. }
  43774. public function setMainScript($script)
  43775. {
  43776. $this->script = $script;
  43777. return $this;
  43778. }
  43779. public function setPersistent()
  43780. {
  43781. $this->persistent = true;
  43782. return $this;
  43783. }
  43784. public function check()
  43785. {
  43786. $this->notify(Status::CHECK, $this->loaded);
  43787. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  43788. if (empty($envArgs[0]) && $this->requiresRestart((bool) $this->loaded)) {
  43789. $this->notify(Status::RESTART);
  43790. if ($this->prepareRestart()) {
  43791. $command = $this->getCommand();
  43792. $this->restart($command);
  43793. }
  43794. return;
  43795. }
  43796. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  43797. $this->notify(Status::RESTARTED);
  43798. Process::setEnv($this->envAllowXdebug);
  43799. self::$inRestart = true;
  43800. if (!$this->loaded) {
  43801. self::$skipped = $envArgs[1];
  43802. }
  43803. $this->tryEnableSignals();
  43804. $this->setEnvRestartSettings($envArgs);
  43805. return;
  43806. }
  43807. $this->notify(Status::NORESTART);
  43808. if ($settings = self::getRestartSettings()) {
  43809. $this->syncSettings($settings);
  43810. }
  43811. }
  43812. public static function getAllIniFiles()
  43813. {
  43814. if (!empty(self::$name)) {
  43815. $env = getenv(self::$name.self::SUFFIX_INIS);
  43816. if (false !== $env) {
  43817. return explode(PATH_SEPARATOR, $env);
  43818. }
  43819. }
  43820. $paths = array((string) php_ini_loaded_file());
  43821. if ($scanned = php_ini_scanned_files()) {
  43822. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  43823. }
  43824. return $paths;
  43825. }
  43826. public static function getRestartSettings()
  43827. {
  43828. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  43829. if (count($envArgs) !== 6
  43830. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  43831. return;
  43832. }
  43833. return array(
  43834. 'tmpIni' => $envArgs[0],
  43835. 'scannedInis' => (bool) $envArgs[1],
  43836. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  43837. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  43838. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  43839. 'skipped' => $envArgs[5],
  43840. );
  43841. }
  43842. public static function getSkippedVersion()
  43843. {
  43844. return (string) self::$skipped;
  43845. }
  43846. protected function requiresRestart($isLoaded)
  43847. {
  43848. return $isLoaded;
  43849. }
  43850. protected function restart($command)
  43851. {
  43852. $this->doRestart($command);
  43853. }
  43854. private function doRestart($command)
  43855. {
  43856. $this->tryEnableSignals();
  43857. $this->notify(Status::RESTARTING, $command);
  43858. if (function_exists('proc_open')) {
  43859. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 80000) {
  43860. $command = '"'.$command.'"';
  43861. }
  43862. $process = proc_open($command, array(), $pipes);
  43863. if (is_resource($process)) {
  43864. $exitCode = proc_close($process);
  43865. }
  43866. } else {
  43867. passthru($command, $exitCode);
  43868. }
  43869. if (!isset($exitCode)) {
  43870. $this->notify(Status::ERROR, 'Unable to restart process');
  43871. $exitCode = -1;
  43872. } else {
  43873. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  43874. }
  43875. if ($this->debug === '2') {
  43876. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  43877. } else {
  43878. @unlink($this->tmpIni);
  43879. }
  43880. exit($exitCode);
  43881. }
  43882. private function prepareRestart()
  43883. {
  43884. $error = '';
  43885. $iniFiles = self::getAllIniFiles();
  43886. $scannedInis = count($iniFiles) > 1;
  43887. $tmpDir = sys_get_temp_dir();
  43888. if (!$this->cli) {
  43889. $error = 'Unsupported SAPI: '.PHP_SAPI;
  43890. } elseif (!defined('PHP_BINARY')) {
  43891. $error = 'PHP version is too old: '.PHP_VERSION;
  43892. } elseif (!$this->checkConfiguration($info)) {
  43893. $error = $info;
  43894. } elseif (!$this->checkScanDirConfig()) {
  43895. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  43896. } elseif (!$this->checkMainScript()) {
  43897. $error = 'Unable to access main script: '.$this->script;
  43898. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  43899. $error = $error ?: 'Unable to create temp ini file at: '.$tmpDir;
  43900. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  43901. $error = 'Unable to set environment variables';
  43902. }
  43903. if ($error) {
  43904. $this->notify(Status::ERROR, $error);
  43905. }
  43906. return empty($error);
  43907. }
  43908. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  43909. {
  43910. if (!$this->tmpIni = @tempnam($tmpDir, '')) {
  43911. return false;
  43912. }
  43913. if (empty($iniFiles[0])) {
  43914. array_shift($iniFiles);
  43915. }
  43916. $content = '';
  43917. $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  43918. foreach ($iniFiles as $file) {
  43919. if (($data = @file_get_contents($file)) === false) {
  43920. $error = 'Unable to read ini: '.$file;
  43921. return false;
  43922. }
  43923. $content .= preg_replace($regex, ';$1', $data).PHP_EOL;
  43924. }
  43925. if ($config = parse_ini_string($content)) {
  43926. $loaded = ini_get_all(null, false);
  43927. $content .= $this->mergeLoadedConfig($loaded, $config);
  43928. }
  43929. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  43930. return @file_put_contents($this->tmpIni, $content);
  43931. }
  43932. private function getCommand()
  43933. {
  43934. $php = array(PHP_BINARY);
  43935. $args = array_slice($_SERVER['argv'], 1);
  43936. if (!$this->persistent) {
  43937. array_push($php, '-n', '-c', $this->tmpIni);
  43938. }
  43939. if (defined('STDOUT') && Process::supportsColor(STDOUT)) {
  43940. $args = Process::addColorOption($args, $this->colorOption);
  43941. }
  43942. $args = array_merge($php, array($this->script), $args);
  43943. $cmd = Process::escape(array_shift($args), true, true);
  43944. foreach ($args as $arg) {
  43945. $cmd .= ' '.Process::escape($arg);
  43946. }
  43947. return $cmd;
  43948. }
  43949. private function setEnvironment($scannedInis, array $iniFiles)
  43950. {
  43951. $scanDir = getenv('PHP_INI_SCAN_DIR');
  43952. $phprc = getenv('PHPRC');
  43953. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  43954. return false;
  43955. }
  43956. if ($this->persistent) {
  43957. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  43958. return false;
  43959. }
  43960. }
  43961. $envArgs = array(
  43962. self::RESTART_ID,
  43963. $this->loaded,
  43964. (int) $scannedInis,
  43965. false === $scanDir ? '*' : $scanDir,
  43966. false === $phprc ? '*' : $phprc,
  43967. );
  43968. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  43969. }
  43970. private function notify($op, $data = null)
  43971. {
  43972. $this->statusWriter->report($op, $data);
  43973. }
  43974. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  43975. {
  43976. $content = '';
  43977. foreach ($loadedConfig as $name => $value) {
  43978. if (!is_string($value)
  43979. || strpos($name, 'xdebug') === 0
  43980. || $name === 'apc.mmap_file_mask') {
  43981. continue;
  43982. }
  43983. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  43984. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  43985. }
  43986. }
  43987. return $content;
  43988. }
  43989. private function checkMainScript()
  43990. {
  43991. if (null !== $this->script) {
  43992. return file_exists($this->script) || '--' === $this->script;
  43993. }
  43994. if (file_exists($this->script = $_SERVER['argv'][0])) {
  43995. return true;
  43996. }
  43997. $options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false;
  43998. $trace = debug_backtrace($options);
  43999. if (($main = end($trace)) && isset($main['file'])) {
  44000. return file_exists($this->script = $main['file']);
  44001. }
  44002. return false;
  44003. }
  44004. private function setEnvRestartSettings($envArgs)
  44005. {
  44006. $settings = array(
  44007. php_ini_loaded_file(),
  44008. $envArgs[2],
  44009. $envArgs[3],
  44010. $envArgs[4],
  44011. getenv($this->envOriginalInis),
  44012. self::$skipped,
  44013. );
  44014. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  44015. }
  44016. private function syncSettings(array $settings)
  44017. {
  44018. if (false === getenv($this->envOriginalInis)) {
  44019. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  44020. }
  44021. self::$skipped = $settings['skipped'];
  44022. $this->notify(Status::INFO, 'Process called with existing restart settings');
  44023. }
  44024. private function checkScanDirConfig()
  44025. {
  44026. return !(getenv('PHP_INI_SCAN_DIR')
  44027. && !PHP_CONFIG_FILE_SCAN_DIR
  44028. && (PHP_VERSION_ID < 70113
  44029. || PHP_VERSION_ID === 70200));
  44030. }
  44031. private function checkConfiguration(&$info)
  44032. {
  44033. if (false !== strpos(ini_get('disable_functions'), 'passthru')) {
  44034. $info = 'passthru function is disabled';
  44035. return false;
  44036. }
  44037. if (extension_loaded('uopz') && !ini_get('uopz.disable')) {
  44038. if (function_exists('uopz_allow_exit')) {
  44039. @uopz_allow_exit(true);
  44040. } else {
  44041. $info = 'uopz extension is not compatible';
  44042. return false;
  44043. }
  44044. }
  44045. return true;
  44046. }
  44047. private function tryEnableSignals()
  44048. {
  44049. if (!function_exists('pcntl_async_signals') || !function_exists('pcntl_signal')) {
  44050. return;
  44051. }
  44052. pcntl_async_signals(true);
  44053. $message = 'Async signals enabled';
  44054. if (!self::$inRestart) {
  44055. pcntl_signal(SIGINT, SIG_IGN);
  44056. $message .= ' (SIGINT = SIG_IGN)';
  44057. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  44058. pcntl_signal(SIGINT, SIG_DFL);
  44059. $message .= ' (SIGINT = SIG_DFL)';
  44060. }
  44061. $this->notify(Status::INFO, $message);
  44062. }
  44063. }
  44064. MIT License
  44065. Copyright (c) 2016
  44066. Permission is hereby granted, free of charge, to any person obtaining a copy
  44067. of this software and associated documentation files (the "Software"), to deal
  44068. in the Software without restriction, including without limitation the rights
  44069. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  44070. copies of the Software, and to permit persons to whom the Software is
  44071. furnished to do so, subject to the following conditions:
  44072. The above copyright notice and this permission notice shall be included in all
  44073. copies or substantial portions of the Software.
  44074. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  44075. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  44076. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  44077. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  44078. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  44079. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  44080. SOFTWARE.
  44081. <?php
  44082. namespace JsonSchema\Constraints;
  44083. use JsonSchema\Entity\JsonPointer;
  44084. use JsonSchema\Exception\InvalidArgumentException;
  44085. use JsonSchema\Exception\ValidationException;
  44086. use JsonSchema\Validator;
  44087. class BaseConstraint
  44088. {
  44089. protected $errors = array();
  44090. protected $errorMask = Validator::ERROR_NONE;
  44091. protected $factory;
  44092. public function __construct(Factory $factory = null)
  44093. {
  44094. $this->factory = $factory ?: new Factory();
  44095. }
  44096. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  44097. {
  44098. $error = array(
  44099. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  44100. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  44101. 'message' => $message,
  44102. 'constraint' => $constraint,
  44103. 'context' => $this->factory->getErrorContext(),
  44104. );
  44105. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  44106. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  44107. }
  44108. if (is_array($more) && count($more) > 0) {
  44109. $error += $more;
  44110. }
  44111. $this->errors[] = $error;
  44112. $this->errorMask |= $error['context'];
  44113. }
  44114. public function addErrors(array $errors)
  44115. {
  44116. if ($errors) {
  44117. $this->errors = array_merge($this->errors, $errors);
  44118. $errorMask = &$this->errorMask;
  44119. array_walk($errors, function ($error) use (&$errorMask) {
  44120. if (isset($error['context'])) {
  44121. $errorMask |= $error['context'];
  44122. }
  44123. });
  44124. }
  44125. }
  44126. public function getErrors($errorContext = Validator::ERROR_ALL)
  44127. {
  44128. if ($errorContext === Validator::ERROR_ALL) {
  44129. return $this->errors;
  44130. }
  44131. return array_filter($this->errors, function ($error) use ($errorContext) {
  44132. if ($errorContext & $error['context']) {
  44133. return true;
  44134. }
  44135. });
  44136. }
  44137. public function numErrors($errorContext = Validator::ERROR_ALL)
  44138. {
  44139. if ($errorContext === Validator::ERROR_ALL) {
  44140. return count($this->errors);
  44141. }
  44142. return count($this->getErrors($errorContext));
  44143. }
  44144. public function isValid()
  44145. {
  44146. return !$this->getErrors();
  44147. }
  44148. public function reset()
  44149. {
  44150. $this->errors = array();
  44151. $this->errorMask = Validator::ERROR_NONE;
  44152. }
  44153. public function getErrorMask()
  44154. {
  44155. return $this->errorMask;
  44156. }
  44157. public static function arrayToObjectRecursive($array)
  44158. {
  44159. $json = json_encode($array);
  44160. if (json_last_error() !== \JSON_ERROR_NONE) {
  44161. $message = 'Unable to encode schema array as JSON';
  44162. if (function_exists('json_last_error_msg')) {
  44163. $message .= ': ' . json_last_error_msg();
  44164. }
  44165. throw new InvalidArgumentException($message);
  44166. }
  44167. return (object) json_decode($json);
  44168. }
  44169. }
  44170. <?php
  44171. namespace JsonSchema\Constraints;
  44172. use JsonSchema\Entity\JsonPointer;
  44173. class CollectionConstraint extends Constraint
  44174. {
  44175. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44176. {
  44177. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  44178. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  44179. }
  44180. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  44181. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  44182. }
  44183. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  44184. $unique = $value;
  44185. if (is_array($value) && count($value)) {
  44186. $unique = array_map(function ($e) {
  44187. return var_export($e, true);
  44188. }, $value);
  44189. }
  44190. if (count(array_unique($unique)) != count($value)) {
  44191. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  44192. }
  44193. }
  44194. if (isset($schema->items)) {
  44195. $this->validateItems($value, $schema, $path, $i);
  44196. }
  44197. }
  44198. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44199. {
  44200. if (is_object($schema->items)) {
  44201. foreach ($value as $k => &$v) {
  44202. $initErrors = $this->getErrors();
  44203. $this->checkUndefined($v, $schema->items, $path, $k);
  44204. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  44205. $secondErrors = $this->getErrors();
  44206. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  44207. }
  44208. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  44209. $this->errors = $secondErrors;
  44210. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  44211. $this->errors = $initErrors;
  44212. }
  44213. }
  44214. unset($v);
  44215. } else {
  44216. foreach ($value as $k => &$v) {
  44217. if (array_key_exists($k, $schema->items)) {
  44218. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  44219. } else {
  44220. if (property_exists($schema, 'additionalItems')) {
  44221. if ($schema->additionalItems !== false) {
  44222. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  44223. } else {
  44224. $this->addError(
  44225. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  44226. }
  44227. } else {
  44228. $this->checkUndefined($v, new \stdClass(), $path, $k);
  44229. }
  44230. }
  44231. }
  44232. unset($v);
  44233. if (count($value) > 0) {
  44234. for ($k = count($value); $k < count($schema->items); $k++) {
  44235. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  44236. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  44237. }
  44238. }
  44239. }
  44240. }
  44241. }
  44242. <?php
  44243. namespace JsonSchema\Constraints;
  44244. use JsonSchema\Entity\JsonPointer;
  44245. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  44246. {
  44247. protected $inlineSchemaProperty = '$schema';
  44248. const CHECK_MODE_NONE = 0x00000000;
  44249. const CHECK_MODE_NORMAL = 0x00000001;
  44250. const CHECK_MODE_TYPE_CAST = 0x00000002;
  44251. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  44252. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  44253. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  44254. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  44255. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  44256. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  44257. protected function incrementPath(JsonPointer $path = null, $i)
  44258. {
  44259. $path = $path ?: new JsonPointer('');
  44260. $path = $path->withPropertyPaths(
  44261. array_merge(
  44262. $path->getPropertyPaths(),
  44263. array_filter(array($i), 'strlen')
  44264. )
  44265. );
  44266. return $path;
  44267. }
  44268. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44269. {
  44270. $validator = $this->factory->createInstanceFor('collection');
  44271. $validator->check($value, $schema, $path, $i);
  44272. $this->addErrors($validator->getErrors());
  44273. }
  44274. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  44275. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  44276. {
  44277. $validator = $this->factory->createInstanceFor('object');
  44278. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  44279. $this->addErrors($validator->getErrors());
  44280. }
  44281. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44282. {
  44283. $validator = $this->factory->createInstanceFor('type');
  44284. $validator->check($value, $schema, $path, $i);
  44285. $this->addErrors($validator->getErrors());
  44286. }
  44287. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  44288. {
  44289. $validator = $this->factory->createInstanceFor('undefined');
  44290. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  44291. $this->addErrors($validator->getErrors());
  44292. }
  44293. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  44294. {
  44295. $validator = $this->factory->createInstanceFor('string');
  44296. $validator->check($value, $schema, $path, $i);
  44297. $this->addErrors($validator->getErrors());
  44298. }
  44299. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  44300. {
  44301. $validator = $this->factory->createInstanceFor('number');
  44302. $validator->check($value, $schema, $path, $i);
  44303. $this->addErrors($validator->getErrors());
  44304. }
  44305. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  44306. {
  44307. $validator = $this->factory->createInstanceFor('enum');
  44308. $validator->check($value, $schema, $path, $i);
  44309. $this->addErrors($validator->getErrors());
  44310. }
  44311. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  44312. {
  44313. $validator = $this->factory->createInstanceFor('format');
  44314. $validator->check($value, $schema, $path, $i);
  44315. $this->addErrors($validator->getErrors());
  44316. }
  44317. protected function getTypeCheck()
  44318. {
  44319. return $this->factory->getTypeCheck();
  44320. }
  44321. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  44322. {
  44323. $result = array_map(
  44324. function ($path) {
  44325. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  44326. },
  44327. $pointer->getPropertyPaths()
  44328. );
  44329. return trim(implode('', $result), '.');
  44330. }
  44331. }
  44332. <?php
  44333. namespace JsonSchema\Constraints;
  44334. use JsonSchema\Entity\JsonPointer;
  44335. interface ConstraintInterface
  44336. {
  44337. public function getErrors();
  44338. public function addErrors(array $errors);
  44339. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  44340. public function isValid();
  44341. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  44342. }
  44343. <?php
  44344. namespace JsonSchema\Constraints;
  44345. use JsonSchema\Entity\JsonPointer;
  44346. class EnumConstraint extends Constraint
  44347. {
  44348. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44349. {
  44350. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  44351. return;
  44352. }
  44353. $type = gettype($element);
  44354. foreach ($schema->enum as $enum) {
  44355. $enumType = gettype($enum);
  44356. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  44357. if ((object) $element == $enum) {
  44358. return;
  44359. }
  44360. }
  44361. if ($type === gettype($enum)) {
  44362. if ($type == 'object') {
  44363. if ($element == $enum) {
  44364. return;
  44365. }
  44366. } elseif ($element === $enum) {
  44367. return;
  44368. }
  44369. }
  44370. }
  44371. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  44372. }
  44373. }
  44374. <?php
  44375. namespace JsonSchema\Constraints;
  44376. use JsonSchema\Exception\InvalidArgumentException;
  44377. use JsonSchema\SchemaStorage;
  44378. use JsonSchema\SchemaStorageInterface;
  44379. use JsonSchema\Uri\UriRetriever;
  44380. use JsonSchema\UriRetrieverInterface;
  44381. use JsonSchema\Validator;
  44382. class Factory
  44383. {
  44384. protected $schemaStorage;
  44385. protected $uriRetriever;
  44386. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  44387. private $typeCheck = array();
  44388. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  44389. protected $constraintMap = array(
  44390. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  44391. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  44392. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  44393. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  44394. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  44395. 'string' => 'JsonSchema\Constraints\StringConstraint',
  44396. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  44397. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  44398. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  44399. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  44400. 'validator' => 'JsonSchema\Validator'
  44401. );
  44402. private $instanceCache = array();
  44403. public function __construct(
  44404. SchemaStorageInterface $schemaStorage = null,
  44405. UriRetrieverInterface $uriRetriever = null,
  44406. $checkMode = Constraint::CHECK_MODE_NORMAL
  44407. ) {
  44408. $this->setConfig($checkMode);
  44409. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  44410. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  44411. }
  44412. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  44413. {
  44414. $this->checkMode = $checkMode;
  44415. }
  44416. public function addConfig($options)
  44417. {
  44418. $this->checkMode |= $options;
  44419. }
  44420. public function removeConfig($options)
  44421. {
  44422. $this->checkMode &= ~$options;
  44423. }
  44424. public function getConfig($options = null)
  44425. {
  44426. if ($options === null) {
  44427. return $this->checkMode;
  44428. }
  44429. return $this->checkMode & $options;
  44430. }
  44431. public function getUriRetriever()
  44432. {
  44433. return $this->uriRetriever;
  44434. }
  44435. public function getSchemaStorage()
  44436. {
  44437. return $this->schemaStorage;
  44438. }
  44439. public function getTypeCheck()
  44440. {
  44441. if (!isset($this->typeCheck[$this->checkMode])) {
  44442. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  44443. ? new TypeCheck\LooseTypeCheck()
  44444. : new TypeCheck\StrictTypeCheck();
  44445. }
  44446. return $this->typeCheck[$this->checkMode];
  44447. }
  44448. public function setConstraintClass($name, $class)
  44449. {
  44450. if (!class_exists($class)) {
  44451. throw new InvalidArgumentException('Unknown constraint ' . $name);
  44452. }
  44453. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  44454. throw new InvalidArgumentException('Invalid class ' . $name);
  44455. }
  44456. $this->constraintMap[$name] = $class;
  44457. return $this;
  44458. }
  44459. public function createInstanceFor($constraintName)
  44460. {
  44461. if (!isset($this->constraintMap[$constraintName])) {
  44462. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  44463. }
  44464. if (!isset($this->instanceCache[$constraintName])) {
  44465. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  44466. }
  44467. return clone $this->instanceCache[$constraintName];
  44468. }
  44469. public function getErrorContext()
  44470. {
  44471. return $this->errorContext;
  44472. }
  44473. public function setErrorContext($errorContext)
  44474. {
  44475. $this->errorContext = $errorContext;
  44476. }
  44477. }
  44478. <?php
  44479. namespace JsonSchema\Constraints;
  44480. use JsonSchema\Entity\JsonPointer;
  44481. use JsonSchema\Rfc3339;
  44482. class FormatConstraint extends Constraint
  44483. {
  44484. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44485. {
  44486. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  44487. return;
  44488. }
  44489. switch ($schema->format) {
  44490. case 'date':
  44491. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  44492. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  44493. }
  44494. break;
  44495. case 'time':
  44496. if (!$this->validateDateTime($element, 'H:i:s')) {
  44497. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  44498. }
  44499. break;
  44500. case 'date-time':
  44501. if (null === Rfc3339::createFromString($element)) {
  44502. $this->addError($path, sprintf('Invalid date-time %s, expected format YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DDThh:mm:ss+hh:mm', json_encode($element)), 'format', array('format' => $schema->format));
  44503. }
  44504. break;
  44505. case 'utc-millisec':
  44506. if (!$this->validateDateTime($element, 'U')) {
  44507. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  44508. }
  44509. break;
  44510. case 'regex':
  44511. if (!$this->validateRegex($element)) {
  44512. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  44513. }
  44514. break;
  44515. case 'color':
  44516. if (!$this->validateColor($element)) {
  44517. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  44518. }
  44519. break;
  44520. case 'style':
  44521. if (!$this->validateStyle($element)) {
  44522. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  44523. }
  44524. break;
  44525. case 'phone':
  44526. if (!$this->validatePhone($element)) {
  44527. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  44528. }
  44529. break;
  44530. case 'uri':
  44531. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  44532. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  44533. }
  44534. break;
  44535. case 'uriref':
  44536. case 'uri-reference':
  44537. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  44538. if (substr($element, 0, 2) === '//') {
  44539. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44540. } elseif (substr($element, 0, 1) === '/') {
  44541. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44542. } elseif (strlen($element)) {
  44543. $pathParts = explode('/', $element, 2);
  44544. if (strpos($pathParts[0], ':') !== false) {
  44545. $validURL = null;
  44546. } else {
  44547. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44548. }
  44549. } else {
  44550. $validURL = null;
  44551. }
  44552. if ($validURL === null) {
  44553. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  44554. }
  44555. }
  44556. break;
  44557. case 'email':
  44558. $filterFlags = FILTER_NULL_ON_FAILURE;
  44559. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  44560. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  44561. }
  44562. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  44563. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  44564. }
  44565. break;
  44566. case 'ip-address':
  44567. case 'ipv4':
  44568. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  44569. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44570. }
  44571. break;
  44572. case 'ipv6':
  44573. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  44574. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44575. }
  44576. break;
  44577. case 'host-name':
  44578. case 'hostname':
  44579. if (!$this->validateHostname($element)) {
  44580. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  44581. }
  44582. break;
  44583. default:
  44584. break;
  44585. }
  44586. }
  44587. protected function validateDateTime($datetime, $format)
  44588. {
  44589. $dt = \DateTime::createFromFormat($format, $datetime);
  44590. if (!$dt) {
  44591. return false;
  44592. }
  44593. if ($datetime === $dt->format($format)) {
  44594. return true;
  44595. }
  44596. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  44597. return true;
  44598. }
  44599. return false;
  44600. }
  44601. protected function validateRegex($regex)
  44602. {
  44603. return false !== @preg_match('/' . $regex . '/u', '');
  44604. }
  44605. protected function validateColor($color)
  44606. {
  44607. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  44608. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  44609. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  44610. return true;
  44611. }
  44612. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  44613. }
  44614. protected function validateStyle($style)
  44615. {
  44616. $properties = explode(';', rtrim($style, ';'));
  44617. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  44618. return empty($invalidEntries);
  44619. }
  44620. protected function validatePhone($phone)
  44621. {
  44622. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  44623. }
  44624. protected function validateHostname($host)
  44625. {
  44626. $hostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/i';
  44627. return preg_match($hostnameRegex, $host);
  44628. }
  44629. }
  44630. <?php
  44631. namespace JsonSchema\Constraints;
  44632. use JsonSchema\Entity\JsonPointer;
  44633. class NumberConstraint extends Constraint
  44634. {
  44635. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44636. {
  44637. if (isset($schema->exclusiveMinimum)) {
  44638. if (isset($schema->minimum)) {
  44639. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  44640. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  44641. } elseif ($element < $schema->minimum) {
  44642. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44643. }
  44644. } else {
  44645. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  44646. }
  44647. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  44648. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44649. }
  44650. if (isset($schema->exclusiveMaximum)) {
  44651. if (isset($schema->maximum)) {
  44652. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  44653. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  44654. } elseif ($element > $schema->maximum) {
  44655. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44656. }
  44657. } else {
  44658. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  44659. }
  44660. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  44661. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44662. }
  44663. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  44664. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  44665. }
  44666. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  44667. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  44668. }
  44669. $this->checkFormat($element, $schema, $path, $i);
  44670. }
  44671. private function fmod($number1, $number2)
  44672. {
  44673. $modulus = ($number1 - round($number1 / $number2) * $number2);
  44674. $precision = 0.0000000001;
  44675. if (-$precision < $modulus && $modulus < $precision) {
  44676. return 0.0;
  44677. }
  44678. return $modulus;
  44679. }
  44680. }
  44681. <?php
  44682. namespace JsonSchema\Constraints;
  44683. use JsonSchema\Entity\JsonPointer;
  44684. class ObjectConstraint extends Constraint
  44685. {
  44686. protected $appliedDefaults = array();
  44687. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  44688. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  44689. {
  44690. if ($element instanceof UndefinedConstraint) {
  44691. return;
  44692. }
  44693. $this->appliedDefaults = $appliedDefaults;
  44694. $matches = array();
  44695. if ($patternProperties) {
  44696. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  44697. }
  44698. if ($properties) {
  44699. $this->validateProperties($element, $properties, $path);
  44700. }
  44701. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  44702. }
  44703. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  44704. {
  44705. $try = array('/', '#', '+', '~', '%');
  44706. $matches = array();
  44707. foreach ($patternProperties as $pregex => $schema) {
  44708. $delimiter = '/';
  44709. foreach ($try as $delimiter) {
  44710. if (strpos($pregex, $delimiter) === false) {
  44711. break;
  44712. }
  44713. }
  44714. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  44715. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  44716. continue;
  44717. }
  44718. foreach ($element as $i => $value) {
  44719. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  44720. $matches[] = $i;
  44721. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  44722. }
  44723. }
  44724. }
  44725. return $matches;
  44726. }
  44727. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  44728. $properties = null, $additionalProp = null)
  44729. {
  44730. $this->validateMinMaxConstraint($element, $schema, $path);
  44731. foreach ($element as $i => $value) {
  44732. $definition = $this->getProperty($properties, $i);
  44733. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  44734. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  44735. }
  44736. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  44737. if ($additionalProp === true) {
  44738. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  44739. } else {
  44740. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  44741. }
  44742. }
  44743. $require = $this->getProperty($definition, 'requires');
  44744. if ($require && !$this->getProperty($element, $require)) {
  44745. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  44746. }
  44747. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  44748. if (is_object($property)) {
  44749. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  44750. }
  44751. }
  44752. }
  44753. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  44754. {
  44755. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  44756. foreach ($properties as $i => $value) {
  44757. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  44758. $definition = $this->getProperty($properties, $i);
  44759. if (is_object($definition)) {
  44760. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  44761. }
  44762. }
  44763. }
  44764. protected function &getProperty(&$element, $property, $fallback = null)
  44765. {
  44766. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  44767. return $element[$property];
  44768. } elseif (is_object($element) && property_exists($element, $property)) {
  44769. return $element->$property;
  44770. }
  44771. return $fallback;
  44772. }
  44773. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  44774. {
  44775. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  44776. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  44777. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  44778. }
  44779. }
  44780. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  44781. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  44782. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  44783. }
  44784. }
  44785. }
  44786. }
  44787. <?php
  44788. namespace JsonSchema\Constraints;
  44789. use JsonSchema\Entity\JsonPointer;
  44790. use JsonSchema\Exception\InvalidArgumentException;
  44791. use JsonSchema\Exception\InvalidSchemaException;
  44792. use JsonSchema\Exception\RuntimeException;
  44793. use JsonSchema\Validator;
  44794. class SchemaConstraint extends Constraint
  44795. {
  44796. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  44797. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44798. {
  44799. if ($schema !== null) {
  44800. $validationSchema = $schema;
  44801. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  44802. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  44803. } else {
  44804. throw new InvalidArgumentException('no schema found to verify against');
  44805. }
  44806. if (is_array($validationSchema)) {
  44807. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  44808. }
  44809. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  44810. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  44811. throw new RuntimeException('Cannot validate the schema of a non-object');
  44812. }
  44813. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  44814. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  44815. } else {
  44816. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  44817. }
  44818. $schemaStorage = $this->factory->getSchemaStorage();
  44819. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  44820. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  44821. }
  44822. $initialErrorCount = $this->numErrors();
  44823. $initialConfig = $this->factory->getConfig();
  44824. $initialContext = $this->factory->getErrorContext();
  44825. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  44826. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  44827. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  44828. try {
  44829. $this->check($validationSchema, $schemaSpec);
  44830. } catch (\Exception $e) {
  44831. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  44832. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  44833. }
  44834. }
  44835. if ($this->numErrors() > $initialErrorCount) {
  44836. $this->addError($path, 'Schema is not valid', 'schema');
  44837. }
  44838. $this->factory->setConfig($initialConfig);
  44839. $this->factory->setErrorContext($initialContext);
  44840. }
  44841. $this->checkUndefined($element, $validationSchema, $path, $i);
  44842. }
  44843. }
  44844. <?php
  44845. namespace JsonSchema\Constraints;
  44846. use JsonSchema\Entity\JsonPointer;
  44847. class StringConstraint extends Constraint
  44848. {
  44849. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44850. {
  44851. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  44852. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  44853. 'maxLength' => $schema->maxLength,
  44854. ));
  44855. }
  44856. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  44857. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  44858. 'minLength' => $schema->minLength,
  44859. ));
  44860. }
  44861. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  44862. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  44863. 'pattern' => $schema->pattern,
  44864. ));
  44865. }
  44866. $this->checkFormat($element, $schema, $path, $i);
  44867. }
  44868. private function strlen($string)
  44869. {
  44870. if (extension_loaded('mbstring')) {
  44871. return mb_strlen($string, mb_detect_encoding($string));
  44872. }
  44873. return strlen($string);
  44874. }
  44875. }
  44876. <?php
  44877. namespace JsonSchema\Constraints\TypeCheck;
  44878. class LooseTypeCheck implements TypeCheckInterface
  44879. {
  44880. public static function isObject($value)
  44881. {
  44882. return
  44883. is_object($value) ||
  44884. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  44885. }
  44886. public static function isArray($value)
  44887. {
  44888. return
  44889. is_array($value) &&
  44890. (count($value) == 0 || !self::isAssociativeArray($value));
  44891. }
  44892. public static function propertyGet($value, $property)
  44893. {
  44894. if (is_object($value)) {
  44895. return $value->{$property};
  44896. }
  44897. return $value[$property];
  44898. }
  44899. public static function propertySet(&$value, $property, $data)
  44900. {
  44901. if (is_object($value)) {
  44902. $value->{$property} = $data;
  44903. } else {
  44904. $value[$property] = $data;
  44905. }
  44906. }
  44907. public static function propertyExists($value, $property)
  44908. {
  44909. if (is_object($value)) {
  44910. return property_exists($value, $property);
  44911. }
  44912. return array_key_exists($property, $value);
  44913. }
  44914. public static function propertyCount($value)
  44915. {
  44916. if (is_object($value)) {
  44917. return count(get_object_vars($value));
  44918. }
  44919. return count($value);
  44920. }
  44921. private static function isAssociativeArray($arr)
  44922. {
  44923. return array_keys($arr) !== range(0, count($arr) - 1);
  44924. }
  44925. }
  44926. <?php
  44927. namespace JsonSchema\Constraints\TypeCheck;
  44928. class StrictTypeCheck implements TypeCheckInterface
  44929. {
  44930. public static function isObject($value)
  44931. {
  44932. return is_object($value);
  44933. }
  44934. public static function isArray($value)
  44935. {
  44936. return is_array($value);
  44937. }
  44938. public static function propertyGet($value, $property)
  44939. {
  44940. return $value->{$property};
  44941. }
  44942. public static function propertySet(&$value, $property, $data)
  44943. {
  44944. $value->{$property} = $data;
  44945. }
  44946. public static function propertyExists($value, $property)
  44947. {
  44948. return property_exists($value, $property);
  44949. }
  44950. public static function propertyCount($value)
  44951. {
  44952. if (!is_object($value)) {
  44953. return 0;
  44954. }
  44955. return count(get_object_vars($value));
  44956. }
  44957. }
  44958. <?php
  44959. namespace JsonSchema\Constraints\TypeCheck;
  44960. interface TypeCheckInterface
  44961. {
  44962. public static function isObject($value);
  44963. public static function isArray($value);
  44964. public static function propertyGet($value, $property);
  44965. public static function propertySet(&$value, $property, $data);
  44966. public static function propertyExists($value, $property);
  44967. public static function propertyCount($value);
  44968. }
  44969. <?php
  44970. namespace JsonSchema\Constraints;
  44971. use JsonSchema\Entity\JsonPointer;
  44972. use JsonSchema\Exception\InvalidArgumentException;
  44973. use UnexpectedValueException as StandardUnexpectedValueException;
  44974. class TypeConstraint extends Constraint
  44975. {
  44976. public static $wording = array(
  44977. 'integer' => 'an integer',
  44978. 'number' => 'a number',
  44979. 'boolean' => 'a boolean',
  44980. 'object' => 'an object',
  44981. 'array' => 'an array',
  44982. 'string' => 'a string',
  44983. 'null' => 'a null',
  44984. 'any' => null,
  44985. 0 => null,
  44986. );
  44987. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  44988. {
  44989. $type = isset($schema->type) ? $schema->type : null;
  44990. $isValid = false;
  44991. $wording = array();
  44992. if (is_array($type)) {
  44993. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  44994. } elseif (is_object($type)) {
  44995. $this->checkUndefined($value, $type, $path);
  44996. return;
  44997. } else {
  44998. $isValid = $this->validateType($value, $type);
  44999. }
  45000. if ($isValid === false) {
  45001. if (!is_array($type)) {
  45002. $this->validateTypeNameWording($type);
  45003. $wording[] = self::$wording[$type];
  45004. }
  45005. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  45006. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  45007. }
  45008. }
  45009. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  45010. {
  45011. foreach ($type as $tp) {
  45012. if (is_object($tp)) {
  45013. if (!$isValid) {
  45014. $validator = $this->factory->createInstanceFor('type');
  45015. $subSchema = new \stdClass();
  45016. $subSchema->type = $tp;
  45017. $validator->check($value, $subSchema, $path, null);
  45018. $error = $validator->getErrors();
  45019. $isValid = !(bool) $error;
  45020. $validTypesWording[] = self::$wording['object'];
  45021. }
  45022. } else {
  45023. $this->validateTypeNameWording($tp);
  45024. $validTypesWording[] = self::$wording[$tp];
  45025. if (!$isValid) {
  45026. $isValid = $this->validateType($value, $tp);
  45027. }
  45028. }
  45029. }
  45030. }
  45031. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  45032. {
  45033. if ($listEnd === false || !isset($elements[1])) {
  45034. return implode($delimiter, $elements);
  45035. }
  45036. $lastElement = array_slice($elements, -1);
  45037. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  45038. $implodedElements = array_merge(array($firsElements), $lastElement);
  45039. return join(" $listEnd ", $implodedElements);
  45040. }
  45041. protected function validateTypeNameWording($type)
  45042. {
  45043. if (!isset(self::$wording[$type])) {
  45044. throw new StandardUnexpectedValueException(
  45045. sprintf(
  45046. 'No wording for %s available, expected wordings are: [%s]',
  45047. var_export($type, true),
  45048. implode(', ', array_filter(self::$wording)))
  45049. );
  45050. }
  45051. }
  45052. protected function validateType(&$value, $type)
  45053. {
  45054. if (!$type) {
  45055. return true;
  45056. }
  45057. if ('any' === $type) {
  45058. return true;
  45059. }
  45060. if ('object' === $type) {
  45061. return $this->getTypeCheck()->isObject($value);
  45062. }
  45063. if ('array' === $type) {
  45064. return $this->getTypeCheck()->isArray($value);
  45065. }
  45066. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  45067. if ('integer' === $type) {
  45068. if ($coerce) {
  45069. $value = $this->toInteger($value);
  45070. }
  45071. return is_int($value);
  45072. }
  45073. if ('number' === $type) {
  45074. if ($coerce) {
  45075. $value = $this->toNumber($value);
  45076. }
  45077. return is_numeric($value) && !is_string($value);
  45078. }
  45079. if ('boolean' === $type) {
  45080. if ($coerce) {
  45081. $value = $this->toBoolean($value);
  45082. }
  45083. return is_bool($value);
  45084. }
  45085. if ('string' === $type) {
  45086. return is_string($value);
  45087. }
  45088. if ('email' === $type) {
  45089. return is_string($value);
  45090. }
  45091. if ('null' === $type) {
  45092. return is_null($value);
  45093. }
  45094. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  45095. }
  45096. protected function toBoolean($value)
  45097. {
  45098. if ($value === 'true') {
  45099. return true;
  45100. }
  45101. if ($value === 'false') {
  45102. return false;
  45103. }
  45104. return $value;
  45105. }
  45106. protected function toNumber($value)
  45107. {
  45108. if (is_numeric($value)) {
  45109. return $value + 0;
  45110. }
  45111. return $value;
  45112. }
  45113. protected function toInteger($value)
  45114. {
  45115. if (is_numeric($value) && (int) $value == $value) {
  45116. return (int) $value;
  45117. }
  45118. return $value;
  45119. }
  45120. }
  45121. <?php
  45122. namespace JsonSchema\Constraints;
  45123. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  45124. use JsonSchema\Entity\JsonPointer;
  45125. use JsonSchema\Exception\ValidationException;
  45126. use JsonSchema\Uri\UriResolver;
  45127. class UndefinedConstraint extends Constraint
  45128. {
  45129. protected $appliedDefaults = array();
  45130. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  45131. {
  45132. if (is_null($schema) || !is_object($schema)) {
  45133. return;
  45134. }
  45135. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  45136. if ($fromDefault) {
  45137. $path->setFromDefault();
  45138. }
  45139. $this->validateCommonProperties($value, $schema, $path, $i);
  45140. $this->validateOfProperties($value, $schema, $path, '');
  45141. $this->validateTypes($value, $schema, $path, $i);
  45142. }
  45143. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  45144. {
  45145. if ($this->getTypeCheck()->isArray($value)) {
  45146. $this->checkArray($value, $schema, $path, $i);
  45147. }
  45148. if (LooseTypeCheck::isObject($value)) {
  45149. $this->checkObject(
  45150. $value,
  45151. $schema,
  45152. $path,
  45153. isset($schema->properties) ? $schema->properties : null,
  45154. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  45155. isset($schema->patternProperties) ? $schema->patternProperties : null,
  45156. $this->appliedDefaults
  45157. );
  45158. }
  45159. if (is_string($value)) {
  45160. $this->checkString($value, $schema, $path, $i);
  45161. }
  45162. if (is_numeric($value)) {
  45163. $this->checkNumber($value, $schema, $path, $i);
  45164. }
  45165. if (isset($schema->enum)) {
  45166. $this->checkEnum($value, $schema, $path, $i);
  45167. }
  45168. }
  45169. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  45170. {
  45171. if (isset($schema->extends)) {
  45172. if (is_string($schema->extends)) {
  45173. $schema->extends = $this->validateUri($schema, $schema->extends);
  45174. }
  45175. if (is_array($schema->extends)) {
  45176. foreach ($schema->extends as $extends) {
  45177. $this->checkUndefined($value, $extends, $path, $i);
  45178. }
  45179. } else {
  45180. $this->checkUndefined($value, $schema->extends, $path, $i);
  45181. }
  45182. }
  45183. if (!$path->fromDefault()) {
  45184. $this->applyDefaultValues($value, $schema, $path);
  45185. }
  45186. if ($this->getTypeCheck()->isObject($value)) {
  45187. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  45188. foreach ($schema->required as $required) {
  45189. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  45190. $this->addError(
  45191. $this->incrementPath($path ?: new JsonPointer(''), $required),
  45192. 'The property ' . $required . ' is required',
  45193. 'required'
  45194. );
  45195. }
  45196. }
  45197. } elseif (isset($schema->required) && !is_array($schema->required)) {
  45198. if ($schema->required && $value instanceof self) {
  45199. $propertyPaths = $path->getPropertyPaths();
  45200. $propertyName = end($propertyPaths);
  45201. $this->addError(
  45202. $path,
  45203. 'The property ' . $propertyName . ' is required',
  45204. 'required'
  45205. );
  45206. }
  45207. } else {
  45208. if ($value instanceof self) {
  45209. return;
  45210. }
  45211. }
  45212. }
  45213. if (!($value instanceof self)) {
  45214. $this->checkType($value, $schema, $path, $i);
  45215. }
  45216. if (isset($schema->disallow)) {
  45217. $initErrors = $this->getErrors();
  45218. $typeSchema = new \stdClass();
  45219. $typeSchema->type = $schema->disallow;
  45220. $this->checkType($value, $typeSchema, $path);
  45221. if (count($this->getErrors()) == count($initErrors)) {
  45222. $this->addError($path, 'Disallowed value was matched', 'disallow');
  45223. } else {
  45224. $this->errors = $initErrors;
  45225. }
  45226. }
  45227. if (isset($schema->not)) {
  45228. $initErrors = $this->getErrors();
  45229. $this->checkUndefined($value, $schema->not, $path, $i);
  45230. if (count($this->getErrors()) == count($initErrors)) {
  45231. $this->addError($path, 'Matched a schema which it should not', 'not');
  45232. } else {
  45233. $this->errors = $initErrors;
  45234. }
  45235. }
  45236. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  45237. $this->validateDependencies($value, $schema->dependencies, $path);
  45238. }
  45239. }
  45240. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  45241. {
  45242. if (!$requiredOnly) {
  45243. return true;
  45244. }
  45245. if (
  45246. $name !== null
  45247. && isset($parentSchema->required)
  45248. && is_array($parentSchema->required)
  45249. && in_array($name, $parentSchema->required)
  45250. ) {
  45251. return true;
  45252. }
  45253. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  45254. return true;
  45255. }
  45256. return false;
  45257. }
  45258. protected function applyDefaultValues(&$value, $schema, $path)
  45259. {
  45260. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  45261. return;
  45262. }
  45263. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  45264. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  45265. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  45266. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  45267. if (
  45268. !LooseTypeCheck::propertyExists($value, $currentProperty)
  45269. && property_exists($propertyDefinition, 'default')
  45270. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  45271. ) {
  45272. if (is_object($propertyDefinition->default)) {
  45273. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  45274. } else {
  45275. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  45276. }
  45277. $this->appliedDefaults[] = $currentProperty;
  45278. }
  45279. }
  45280. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  45281. $items = array();
  45282. if (LooseTypeCheck::isArray($schema->items)) {
  45283. $items = $schema->items;
  45284. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  45285. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  45286. }
  45287. foreach ($items as $currentItem => $itemDefinition) {
  45288. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  45289. if (
  45290. !array_key_exists($currentItem, $value)
  45291. && property_exists($itemDefinition, 'default')
  45292. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  45293. if (is_object($itemDefinition->default)) {
  45294. $value[$currentItem] = clone $itemDefinition->default;
  45295. } else {
  45296. $value[$currentItem] = $itemDefinition->default;
  45297. }
  45298. }
  45299. $path->setFromDefault();
  45300. }
  45301. } elseif (
  45302. $value instanceof self
  45303. && property_exists($schema, 'default')
  45304. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  45305. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  45306. $path->setFromDefault();
  45307. }
  45308. }
  45309. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  45310. {
  45311. if ($value instanceof self) {
  45312. return;
  45313. }
  45314. if (isset($schema->allOf)) {
  45315. $isValid = true;
  45316. foreach ($schema->allOf as $allOf) {
  45317. $initErrors = $this->getErrors();
  45318. $this->checkUndefined($value, $allOf, $path, $i);
  45319. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  45320. }
  45321. if (!$isValid) {
  45322. $this->addError($path, 'Failed to match all schemas', 'allOf');
  45323. }
  45324. }
  45325. if (isset($schema->anyOf)) {
  45326. $isValid = false;
  45327. $startErrors = $this->getErrors();
  45328. $caughtException = null;
  45329. foreach ($schema->anyOf as $anyOf) {
  45330. $initErrors = $this->getErrors();
  45331. try {
  45332. $this->checkUndefined($value, $anyOf, $path, $i);
  45333. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  45334. break;
  45335. }
  45336. } catch (ValidationException $e) {
  45337. $isValid = false;
  45338. }
  45339. }
  45340. if (!$isValid) {
  45341. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  45342. } else {
  45343. $this->errors = $startErrors;
  45344. }
  45345. }
  45346. if (isset($schema->oneOf)) {
  45347. $allErrors = array();
  45348. $matchedSchemas = 0;
  45349. $startErrors = $this->getErrors();
  45350. foreach ($schema->oneOf as $oneOf) {
  45351. try {
  45352. $this->errors = array();
  45353. $this->checkUndefined($value, $oneOf, $path, $i);
  45354. if (count($this->getErrors()) == 0) {
  45355. $matchedSchemas++;
  45356. }
  45357. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  45358. } catch (ValidationException $e) {
  45359. }
  45360. }
  45361. if ($matchedSchemas !== 1) {
  45362. $this->addErrors(array_merge($allErrors, $startErrors));
  45363. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  45364. } else {
  45365. $this->errors = $startErrors;
  45366. }
  45367. }
  45368. }
  45369. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  45370. {
  45371. foreach ($dependencies as $key => $dependency) {
  45372. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  45373. if (is_string($dependency)) {
  45374. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  45375. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  45376. }
  45377. } elseif (is_array($dependency)) {
  45378. foreach ($dependency as $d) {
  45379. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  45380. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  45381. }
  45382. }
  45383. } elseif (is_object($dependency)) {
  45384. $this->checkUndefined($value, $dependency, $path, $i);
  45385. }
  45386. }
  45387. }
  45388. }
  45389. protected function validateUri($schema, $schemaUri = null)
  45390. {
  45391. $resolver = new UriResolver();
  45392. $retriever = $this->factory->getUriRetriever();
  45393. $jsonSchema = null;
  45394. if ($resolver->isValid($schemaUri)) {
  45395. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  45396. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  45397. }
  45398. return $jsonSchema;
  45399. }
  45400. }
  45401. <?php
  45402. namespace JsonSchema\Entity;
  45403. use JsonSchema\Exception\InvalidArgumentException;
  45404. class JsonPointer
  45405. {
  45406. private $filename;
  45407. private $propertyPaths = array();
  45408. private $fromDefault = false;
  45409. public function __construct($value)
  45410. {
  45411. if (!is_string($value)) {
  45412. throw new InvalidArgumentException('Ref value must be a string');
  45413. }
  45414. $splitRef = explode('#', $value, 2);
  45415. $this->filename = $splitRef[0];
  45416. if (array_key_exists(1, $splitRef)) {
  45417. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  45418. }
  45419. }
  45420. private function decodePropertyPaths($propertyPathString)
  45421. {
  45422. $paths = array();
  45423. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  45424. $path = $this->decodePath($path);
  45425. if (is_string($path) && '' !== $path) {
  45426. $paths[] = $path;
  45427. }
  45428. }
  45429. return $paths;
  45430. }
  45431. private function encodePropertyPaths()
  45432. {
  45433. return array_map(
  45434. array($this, 'encodePath'),
  45435. $this->getPropertyPaths()
  45436. );
  45437. }
  45438. private function decodePath($path)
  45439. {
  45440. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  45441. }
  45442. private function encodePath($path)
  45443. {
  45444. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  45445. }
  45446. public function getFilename()
  45447. {
  45448. return $this->filename;
  45449. }
  45450. public function getPropertyPaths()
  45451. {
  45452. return $this->propertyPaths;
  45453. }
  45454. public function withPropertyPaths(array $propertyPaths)
  45455. {
  45456. $new = clone $this;
  45457. $new->propertyPaths = $propertyPaths;
  45458. return $new;
  45459. }
  45460. public function getPropertyPathAsString()
  45461. {
  45462. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  45463. }
  45464. public function __toString()
  45465. {
  45466. return $this->getFilename() . $this->getPropertyPathAsString();
  45467. }
  45468. public function setFromDefault()
  45469. {
  45470. $this->fromDefault = true;
  45471. }
  45472. public function fromDefault()
  45473. {
  45474. return $this->fromDefault;
  45475. }
  45476. }
  45477. <?php
  45478. namespace JsonSchema\Exception;
  45479. interface ExceptionInterface
  45480. {
  45481. }
  45482. <?php
  45483. namespace JsonSchema\Exception;
  45484. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  45485. {
  45486. }
  45487. <?php
  45488. namespace JsonSchema\Exception;
  45489. class InvalidConfigException extends RuntimeException
  45490. {
  45491. }
  45492. <?php
  45493. namespace JsonSchema\Exception;
  45494. class InvalidSchemaException extends RuntimeException
  45495. {
  45496. }
  45497. <?php
  45498. namespace JsonSchema\Exception;
  45499. class InvalidSchemaMediaTypeException extends RuntimeException
  45500. {
  45501. }
  45502. <?php
  45503. namespace JsonSchema\Exception;
  45504. class InvalidSourceUriException extends InvalidArgumentException
  45505. {
  45506. }
  45507. <?php
  45508. namespace JsonSchema\Exception;
  45509. class JsonDecodingException extends RuntimeException
  45510. {
  45511. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  45512. {
  45513. switch ($code) {
  45514. case JSON_ERROR_DEPTH:
  45515. $message = 'The maximum stack depth has been exceeded';
  45516. break;
  45517. case JSON_ERROR_STATE_MISMATCH:
  45518. $message = 'Invalid or malformed JSON';
  45519. break;
  45520. case JSON_ERROR_CTRL_CHAR:
  45521. $message = 'Control character error, possibly incorrectly encoded';
  45522. break;
  45523. case JSON_ERROR_UTF8:
  45524. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  45525. break;
  45526. case JSON_ERROR_SYNTAX:
  45527. $message = 'JSON syntax is malformed';
  45528. break;
  45529. default:
  45530. $message = 'Syntax error';
  45531. }
  45532. parent::__construct($message, $code, $previous);
  45533. }
  45534. }
  45535. <?php
  45536. namespace JsonSchema\Exception;
  45537. class ResourceNotFoundException extends RuntimeException
  45538. {
  45539. }
  45540. <?php
  45541. namespace JsonSchema\Exception;
  45542. class RuntimeException extends \RuntimeException implements ExceptionInterface
  45543. {
  45544. }
  45545. <?php
  45546. namespace JsonSchema\Exception;
  45547. class UnresolvableJsonPointerException extends InvalidArgumentException
  45548. {
  45549. }
  45550. <?php
  45551. namespace JsonSchema\Exception;
  45552. class UriResolverException extends RuntimeException
  45553. {
  45554. }
  45555. <?php
  45556. namespace JsonSchema\Exception;
  45557. class ValidationException extends RuntimeException
  45558. {
  45559. }
  45560. <?php
  45561. namespace JsonSchema\Iterator;
  45562. class ObjectIterator implements \Iterator, \Countable
  45563. {
  45564. private $object;
  45565. private $position = 0;
  45566. private $data = array();
  45567. private $initialized = false;
  45568. public function __construct($object)
  45569. {
  45570. $this->object = $object;
  45571. }
  45572. public function current()
  45573. {
  45574. $this->initialize();
  45575. return $this->data[$this->position];
  45576. }
  45577. public function next()
  45578. {
  45579. $this->initialize();
  45580. $this->position++;
  45581. }
  45582. public function key()
  45583. {
  45584. $this->initialize();
  45585. return $this->position;
  45586. }
  45587. public function valid()
  45588. {
  45589. $this->initialize();
  45590. return isset($this->data[$this->position]);
  45591. }
  45592. public function rewind()
  45593. {
  45594. $this->initialize();
  45595. $this->position = 0;
  45596. }
  45597. public function count()
  45598. {
  45599. $this->initialize();
  45600. return count($this->data);
  45601. }
  45602. private function initialize()
  45603. {
  45604. if (!$this->initialized) {
  45605. $this->data = $this->buildDataFromObject($this->object);
  45606. $this->initialized = true;
  45607. }
  45608. }
  45609. private function buildDataFromObject($object)
  45610. {
  45611. $result = array();
  45612. $stack = new \SplStack();
  45613. $stack->push($object);
  45614. while (!$stack->isEmpty()) {
  45615. $current = $stack->pop();
  45616. if (is_object($current)) {
  45617. array_push($result, $current);
  45618. }
  45619. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  45620. if (is_object($propertyValue) || is_array($propertyValue)) {
  45621. $stack->push($propertyValue);
  45622. }
  45623. }
  45624. }
  45625. return $result;
  45626. }
  45627. private function getDataFromItem($item)
  45628. {
  45629. if (!is_object($item) && !is_array($item)) {
  45630. return array();
  45631. }
  45632. return is_object($item) ? get_object_vars($item) : $item;
  45633. }
  45634. }
  45635. <?php
  45636. namespace JsonSchema;
  45637. class Rfc3339
  45638. {
  45639. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  45640. public static function createFromString($string)
  45641. {
  45642. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  45643. return null;
  45644. }
  45645. $dateAndTime = $matches[1];
  45646. $microseconds = $matches[2] ?: '.000000';
  45647. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  45648. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  45649. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  45650. return $dateTime ?: null;
  45651. }
  45652. }
  45653. <?php
  45654. namespace JsonSchema;
  45655. use JsonSchema\Constraints\BaseConstraint;
  45656. use JsonSchema\Entity\JsonPointer;
  45657. use JsonSchema\Exception\UnresolvableJsonPointerException;
  45658. use JsonSchema\Uri\UriResolver;
  45659. use JsonSchema\Uri\UriRetriever;
  45660. class SchemaStorage implements SchemaStorageInterface
  45661. {
  45662. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  45663. protected $uriRetriever;
  45664. protected $uriResolver;
  45665. protected $schemas = array();
  45666. public function __construct(
  45667. UriRetrieverInterface $uriRetriever = null,
  45668. UriResolverInterface $uriResolver = null
  45669. ) {
  45670. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  45671. $this->uriResolver = $uriResolver ?: new UriResolver();
  45672. }
  45673. public function getUriRetriever()
  45674. {
  45675. return $this->uriRetriever;
  45676. }
  45677. public function getUriResolver()
  45678. {
  45679. return $this->uriResolver;
  45680. }
  45681. public function addSchema($id, $schema = null)
  45682. {
  45683. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  45684. $schema = $this->uriRetriever->retrieve($id);
  45685. }
  45686. if (is_array($schema)) {
  45687. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  45688. }
  45689. if (is_object($schema) && property_exists($schema, 'id')) {
  45690. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  45691. $schema->properties->id->format = 'uri-reference';
  45692. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  45693. $schema->properties->id->format = 'uri-reference';
  45694. $schema->properties->{'$ref'}->format = 'uri-reference';
  45695. }
  45696. }
  45697. $this->expandRefs($schema, $id);
  45698. $this->schemas[$id] = $schema;
  45699. }
  45700. private function expandRefs(&$schema, $base = null)
  45701. {
  45702. if (!is_object($schema)) {
  45703. if (is_array($schema)) {
  45704. foreach ($schema as &$member) {
  45705. $this->expandRefs($member, $base);
  45706. }
  45707. }
  45708. return;
  45709. }
  45710. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  45711. $base = $this->uriResolver->resolve($schema->id, $base);
  45712. }
  45713. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  45714. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  45715. $schema->{'$ref'} = (string) $refPointer;
  45716. }
  45717. foreach ($schema as &$member) {
  45718. $this->expandRefs($member, $base);
  45719. }
  45720. }
  45721. public function getSchema($id)
  45722. {
  45723. if (!array_key_exists($id, $this->schemas)) {
  45724. $this->addSchema($id);
  45725. }
  45726. return $this->schemas[$id];
  45727. }
  45728. public function resolveRef($ref)
  45729. {
  45730. $jsonPointer = new JsonPointer($ref);
  45731. $fileName = $jsonPointer->getFilename();
  45732. if (!strlen($fileName)) {
  45733. throw new UnresolvableJsonPointerException(sprintf(
  45734. "Could not resolve fragment '%s': no file is defined",
  45735. $jsonPointer->getPropertyPathAsString()
  45736. ));
  45737. }
  45738. $refSchema = $this->getSchema($fileName);
  45739. foreach ($jsonPointer->getPropertyPaths() as $path) {
  45740. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  45741. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  45742. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  45743. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  45744. } else {
  45745. throw new UnresolvableJsonPointerException(sprintf(
  45746. 'File: %s is found, but could not resolve fragment: %s',
  45747. $jsonPointer->getFilename(),
  45748. $jsonPointer->getPropertyPathAsString()
  45749. ));
  45750. }
  45751. }
  45752. return $refSchema;
  45753. }
  45754. public function resolveRefSchema($refSchema)
  45755. {
  45756. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  45757. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  45758. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  45759. unset($refSchema->{'$ref'});
  45760. }
  45761. return $refSchema;
  45762. }
  45763. }
  45764. <?php
  45765. namespace JsonSchema;
  45766. interface SchemaStorageInterface
  45767. {
  45768. public function addSchema($id, $schema = null);
  45769. public function getSchema($id);
  45770. public function resolveRef($ref);
  45771. public function resolveRefSchema($refSchema);
  45772. }
  45773. <?php
  45774. namespace JsonSchema\Uri\Retrievers;
  45775. abstract class AbstractRetriever implements UriRetrieverInterface
  45776. {
  45777. protected $contentType;
  45778. public function getContentType()
  45779. {
  45780. return $this->contentType;
  45781. }
  45782. }
  45783. <?php
  45784. namespace JsonSchema\Uri\Retrievers;
  45785. use JsonSchema\Exception\RuntimeException;
  45786. use JsonSchema\Validator;
  45787. class Curl extends AbstractRetriever
  45788. {
  45789. protected $messageBody;
  45790. public function __construct()
  45791. {
  45792. if (!function_exists('curl_init')) {
  45793. throw new RuntimeException('cURL not installed');
  45794. }
  45795. }
  45796. public function retrieve($uri)
  45797. {
  45798. $ch = curl_init();
  45799. curl_setopt($ch, CURLOPT_URL, $uri);
  45800. curl_setopt($ch, CURLOPT_HEADER, true);
  45801. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  45802. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  45803. $response = curl_exec($ch);
  45804. if (false === $response) {
  45805. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  45806. }
  45807. $this->fetchMessageBody($response);
  45808. $this->fetchContentType($response);
  45809. curl_close($ch);
  45810. return $this->messageBody;
  45811. }
  45812. private function fetchMessageBody($response)
  45813. {
  45814. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  45815. $this->messageBody = $match[1];
  45816. }
  45817. protected function fetchContentType($response)
  45818. {
  45819. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  45820. $this->contentType = trim($match[1]);
  45821. return true;
  45822. }
  45823. return false;
  45824. }
  45825. }
  45826. <?php
  45827. namespace JsonSchema\Uri\Retrievers;
  45828. use JsonSchema\Exception\ResourceNotFoundException;
  45829. class FileGetContents extends AbstractRetriever
  45830. {
  45831. protected $messageBody;
  45832. public function retrieve($uri)
  45833. {
  45834. $errorMessage = null;
  45835. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  45836. $errorMessage = $errstr;
  45837. });
  45838. $response = file_get_contents($uri);
  45839. restore_error_handler();
  45840. if ($errorMessage) {
  45841. throw new ResourceNotFoundException($errorMessage);
  45842. }
  45843. if (false === $response) {
  45844. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45845. }
  45846. if ($response == ''
  45847. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  45848. ) {
  45849. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45850. }
  45851. $this->messageBody = $response;
  45852. if (!empty($http_response_header)) {
  45853. $this->fetchContentType($http_response_header);
  45854. } else {
  45855. $this->contentType = null;
  45856. }
  45857. return $this->messageBody;
  45858. }
  45859. private function fetchContentType(array $headers)
  45860. {
  45861. foreach ($headers as $header) {
  45862. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  45863. return true;
  45864. }
  45865. }
  45866. return false;
  45867. }
  45868. protected static function getContentTypeMatchInHeader($header)
  45869. {
  45870. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  45871. return trim($match[1]);
  45872. }
  45873. return null;
  45874. }
  45875. }
  45876. <?php
  45877. namespace JsonSchema\Uri\Retrievers;
  45878. use JsonSchema\Validator;
  45879. class PredefinedArray extends AbstractRetriever
  45880. {
  45881. private $schemas;
  45882. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  45883. {
  45884. $this->schemas = $schemas;
  45885. $this->contentType = $contentType;
  45886. }
  45887. public function retrieve($uri)
  45888. {
  45889. if (!array_key_exists($uri, $this->schemas)) {
  45890. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  45891. 'The JSON schema "%s" was not found.',
  45892. $uri
  45893. ));
  45894. }
  45895. return $this->schemas[$uri];
  45896. }
  45897. }
  45898. <?php
  45899. namespace JsonSchema\Uri\Retrievers;
  45900. interface UriRetrieverInterface
  45901. {
  45902. public function retrieve($uri);
  45903. public function getContentType();
  45904. }
  45905. <?php
  45906. namespace JsonSchema\Uri;
  45907. use JsonSchema\Exception\UriResolverException;
  45908. use JsonSchema\UriResolverInterface;
  45909. class UriResolver implements UriResolverInterface
  45910. {
  45911. public function parse($uri)
  45912. {
  45913. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  45914. $components = array();
  45915. if (5 < count($match)) {
  45916. $components = array(
  45917. 'scheme' => $match[2],
  45918. 'authority' => $match[4],
  45919. 'path' => $match[5]
  45920. );
  45921. }
  45922. if (7 < count($match)) {
  45923. $components['query'] = $match[7];
  45924. }
  45925. if (9 < count($match)) {
  45926. $components['fragment'] = $match[9];
  45927. }
  45928. return $components;
  45929. }
  45930. public function generate(array $components)
  45931. {
  45932. $uri = $components['scheme'] . '://'
  45933. . $components['authority']
  45934. . $components['path'];
  45935. if (array_key_exists('query', $components) && strlen($components['query'])) {
  45936. $uri .= '?' . $components['query'];
  45937. }
  45938. if (array_key_exists('fragment', $components)) {
  45939. $uri .= '#' . $components['fragment'];
  45940. }
  45941. return $uri;
  45942. }
  45943. public function resolve($uri, $baseUri = null)
  45944. {
  45945. if (
  45946. !is_null($baseUri) &&
  45947. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  45948. !preg_match('|^[^/]+://|u', $baseUri)
  45949. ) {
  45950. if (is_file($baseUri)) {
  45951. $baseUri = 'file://' . realpath($baseUri);
  45952. } elseif (is_dir($baseUri)) {
  45953. $baseUri = 'file://' . realpath($baseUri) . '/';
  45954. } else {
  45955. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  45956. }
  45957. }
  45958. if ($uri == '') {
  45959. return $baseUri;
  45960. }
  45961. $components = $this->parse($uri);
  45962. $path = $components['path'];
  45963. if (!empty($components['scheme'])) {
  45964. return $uri;
  45965. }
  45966. $baseComponents = $this->parse($baseUri);
  45967. $basePath = $baseComponents['path'];
  45968. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  45969. if (isset($components['fragment'])) {
  45970. $baseComponents['fragment'] = $components['fragment'];
  45971. }
  45972. return $this->generate($baseComponents);
  45973. }
  45974. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  45975. {
  45976. $relativePath = self::normalizePath($relativePath);
  45977. if ($relativePath == '') {
  45978. return $basePath;
  45979. }
  45980. if ($relativePath[0] == '/') {
  45981. return $relativePath;
  45982. }
  45983. $basePathSegments = explode('/', $basePath);
  45984. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  45985. $numLevelUp = strlen($match[0]) /3 + 1;
  45986. if ($numLevelUp >= count($basePathSegments)) {
  45987. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  45988. }
  45989. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  45990. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  45991. return implode('/', $basePathSegments) . '/' . $path;
  45992. }
  45993. private static function normalizePath($path)
  45994. {
  45995. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  45996. $path = preg_replace('|//|', '/', $path);
  45997. return $path;
  45998. }
  45999. public function isValid($uri)
  46000. {
  46001. $components = $this->parse($uri);
  46002. return !empty($components);
  46003. }
  46004. }
  46005. <?php
  46006. namespace JsonSchema\Uri;
  46007. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  46008. use JsonSchema\Exception\JsonDecodingException;
  46009. use JsonSchema\Exception\ResourceNotFoundException;
  46010. use JsonSchema\Uri\Retrievers\FileGetContents;
  46011. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  46012. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  46013. use JsonSchema\Validator;
  46014. class UriRetriever implements BaseUriRetrieverInterface
  46015. {
  46016. protected $translationMap = array(
  46017. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  46018. );
  46019. protected $allowedInvalidContentTypeEndpoints = array(
  46020. 'http://json-schema.org/',
  46021. 'https://json-schema.org/'
  46022. );
  46023. protected $uriRetriever = null;
  46024. private $schemaCache = array();
  46025. public function addInvalidContentTypeEndpoint($endpoint)
  46026. {
  46027. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  46028. }
  46029. public function confirmMediaType($uriRetriever, $uri)
  46030. {
  46031. $contentType = $uriRetriever->getContentType();
  46032. if (is_null($contentType)) {
  46033. return;
  46034. }
  46035. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  46036. return;
  46037. }
  46038. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  46039. if (strpos($uri, $endpoint) === 0) {
  46040. return true;
  46041. }
  46042. }
  46043. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  46044. }
  46045. public function getUriRetriever()
  46046. {
  46047. if (is_null($this->uriRetriever)) {
  46048. $this->setUriRetriever(new FileGetContents());
  46049. }
  46050. return $this->uriRetriever;
  46051. }
  46052. public function resolvePointer($jsonSchema, $uri)
  46053. {
  46054. $resolver = new UriResolver();
  46055. $parsed = $resolver->parse($uri);
  46056. if (empty($parsed['fragment'])) {
  46057. return $jsonSchema;
  46058. }
  46059. $path = explode('/', $parsed['fragment']);
  46060. while ($path) {
  46061. $pathElement = array_shift($path);
  46062. if (!empty($pathElement)) {
  46063. $pathElement = str_replace('~1', '/', $pathElement);
  46064. $pathElement = str_replace('~0', '~', $pathElement);
  46065. if (!empty($jsonSchema->$pathElement)) {
  46066. $jsonSchema = $jsonSchema->$pathElement;
  46067. } else {
  46068. throw new ResourceNotFoundException(
  46069. 'Fragment "' . $parsed['fragment'] . '" not found'
  46070. . ' in ' . $uri
  46071. );
  46072. }
  46073. if (!is_object($jsonSchema)) {
  46074. throw new ResourceNotFoundException(
  46075. 'Fragment part "' . $pathElement . '" is no object '
  46076. . ' in ' . $uri
  46077. );
  46078. }
  46079. }
  46080. }
  46081. return $jsonSchema;
  46082. }
  46083. public function retrieve($uri, $baseUri = null, $translate = true)
  46084. {
  46085. $resolver = new UriResolver();
  46086. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  46087. $arParts = $resolver->parse($resolvedUri);
  46088. if (isset($arParts['fragment'])) {
  46089. unset($arParts['fragment']);
  46090. $fetchUri = $resolver->generate($arParts);
  46091. }
  46092. if ($translate) {
  46093. $fetchUri = $this->translate($fetchUri);
  46094. }
  46095. $jsonSchema = $this->loadSchema($fetchUri);
  46096. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  46097. if ($jsonSchema instanceof \stdClass) {
  46098. $jsonSchema->id = $resolvedUri;
  46099. }
  46100. return $jsonSchema;
  46101. }
  46102. protected function loadSchema($fetchUri)
  46103. {
  46104. if (isset($this->schemaCache[$fetchUri])) {
  46105. return $this->schemaCache[$fetchUri];
  46106. }
  46107. $uriRetriever = $this->getUriRetriever();
  46108. $contents = $this->uriRetriever->retrieve($fetchUri);
  46109. $this->confirmMediaType($uriRetriever, $fetchUri);
  46110. $jsonSchema = json_decode($contents);
  46111. if (JSON_ERROR_NONE < $error = json_last_error()) {
  46112. throw new JsonDecodingException($error);
  46113. }
  46114. $this->schemaCache[$fetchUri] = $jsonSchema;
  46115. return $jsonSchema;
  46116. }
  46117. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  46118. {
  46119. $this->uriRetriever = $uriRetriever;
  46120. return $this;
  46121. }
  46122. public function parse($uri)
  46123. {
  46124. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  46125. $components = array();
  46126. if (5 < count($match)) {
  46127. $components = array(
  46128. 'scheme' => $match[2],
  46129. 'authority' => $match[4],
  46130. 'path' => $match[5]
  46131. );
  46132. }
  46133. if (7 < count($match)) {
  46134. $components['query'] = $match[7];
  46135. }
  46136. if (9 < count($match)) {
  46137. $components['fragment'] = $match[9];
  46138. }
  46139. return $components;
  46140. }
  46141. public function generate(array $components)
  46142. {
  46143. $uri = $components['scheme'] . '://'
  46144. . $components['authority']
  46145. . $components['path'];
  46146. if (array_key_exists('query', $components)) {
  46147. $uri .= $components['query'];
  46148. }
  46149. if (array_key_exists('fragment', $components)) {
  46150. $uri .= $components['fragment'];
  46151. }
  46152. return $uri;
  46153. }
  46154. public function resolve($uri, $baseUri = null)
  46155. {
  46156. $components = $this->parse($uri);
  46157. $path = $components['path'];
  46158. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  46159. return $uri;
  46160. }
  46161. $baseComponents = $this->parse($baseUri);
  46162. $basePath = $baseComponents['path'];
  46163. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  46164. return $this->generate($baseComponents);
  46165. }
  46166. public function isValid($uri)
  46167. {
  46168. $components = $this->parse($uri);
  46169. return !empty($components);
  46170. }
  46171. public function setTranslation($from, $to)
  46172. {
  46173. $this->translationMap[$from] = $to;
  46174. }
  46175. public function translate($uri)
  46176. {
  46177. foreach ($this->translationMap as $from => $to) {
  46178. $uri = preg_replace($from, $to, $uri);
  46179. }
  46180. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  46181. return $uri;
  46182. }
  46183. }
  46184. <?php
  46185. namespace JsonSchema;
  46186. interface UriResolverInterface
  46187. {
  46188. public function resolve($uri, $baseUri = null);
  46189. }
  46190. <?php
  46191. namespace JsonSchema;
  46192. interface UriRetrieverInterface
  46193. {
  46194. public function retrieve($uri, $baseUri = null);
  46195. }
  46196. <?php
  46197. namespace JsonSchema;
  46198. use JsonSchema\Constraints\BaseConstraint;
  46199. use JsonSchema\Constraints\Constraint;
  46200. class Validator extends BaseConstraint
  46201. {
  46202. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  46203. const ERROR_NONE = 0x00000000;
  46204. const ERROR_ALL = 0xFFFFFFFF;
  46205. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  46206. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  46207. public function validate(&$value, $schema = null, $checkMode = null)
  46208. {
  46209. if (is_array($schema)) {
  46210. $schema = self::arrayToObjectRecursive($schema);
  46211. }
  46212. $initialCheckMode = $this->factory->getConfig();
  46213. if ($checkMode !== null) {
  46214. $this->factory->setConfig($checkMode);
  46215. }
  46216. if (is_object($schema) && property_exists($schema, 'id')) {
  46217. $schemaURI = $schema->id;
  46218. } else {
  46219. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  46220. }
  46221. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  46222. $validator = $this->factory->createInstanceFor('schema');
  46223. $validator->check(
  46224. $value,
  46225. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  46226. );
  46227. $this->factory->setConfig($initialCheckMode);
  46228. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  46229. return $validator->getErrorMask();
  46230. }
  46231. public function check($value, $schema)
  46232. {
  46233. return $this->validate($value, $schema);
  46234. }
  46235. public function coerce(&$value, $schema)
  46236. {
  46237. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  46238. }
  46239. }
  46240. Copyright (c) 2012 PHP Framework Interoperability Group
  46241. Permission is hereby granted, free of charge, to any person obtaining a copy
  46242. of this software and associated documentation files (the "Software"), to deal
  46243. in the Software without restriction, including without limitation the rights
  46244. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46245. copies of the Software, and to permit persons to whom the Software is
  46246. furnished to do so, subject to the following conditions:
  46247. The above copyright notice and this permission notice shall be included in
  46248. all copies or substantial portions of the Software.
  46249. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46250. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46251. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46252. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46253. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46254. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  46255. THE SOFTWARE.
  46256. <?php
  46257. namespace Psr\Log;
  46258. abstract class AbstractLogger implements LoggerInterface
  46259. {
  46260. public function emergency($message, array $context = array())
  46261. {
  46262. $this->log(LogLevel::EMERGENCY, $message, $context);
  46263. }
  46264. public function alert($message, array $context = array())
  46265. {
  46266. $this->log(LogLevel::ALERT, $message, $context);
  46267. }
  46268. public function critical($message, array $context = array())
  46269. {
  46270. $this->log(LogLevel::CRITICAL, $message, $context);
  46271. }
  46272. public function error($message, array $context = array())
  46273. {
  46274. $this->log(LogLevel::ERROR, $message, $context);
  46275. }
  46276. public function warning($message, array $context = array())
  46277. {
  46278. $this->log(LogLevel::WARNING, $message, $context);
  46279. }
  46280. public function notice($message, array $context = array())
  46281. {
  46282. $this->log(LogLevel::NOTICE, $message, $context);
  46283. }
  46284. public function info($message, array $context = array())
  46285. {
  46286. $this->log(LogLevel::INFO, $message, $context);
  46287. }
  46288. public function debug($message, array $context = array())
  46289. {
  46290. $this->log(LogLevel::DEBUG, $message, $context);
  46291. }
  46292. }
  46293. <?php
  46294. namespace Psr\Log;
  46295. class InvalidArgumentException extends \InvalidArgumentException
  46296. {
  46297. }
  46298. <?php
  46299. namespace Psr\Log;
  46300. class LogLevel
  46301. {
  46302. const EMERGENCY = 'emergency';
  46303. const ALERT = 'alert';
  46304. const CRITICAL = 'critical';
  46305. const ERROR = 'error';
  46306. const WARNING = 'warning';
  46307. const NOTICE = 'notice';
  46308. const INFO = 'info';
  46309. const DEBUG = 'debug';
  46310. }
  46311. <?php
  46312. namespace Psr\Log;
  46313. interface LoggerAwareInterface
  46314. {
  46315. public function setLogger(LoggerInterface $logger);
  46316. }
  46317. <?php
  46318. namespace Psr\Log;
  46319. trait LoggerAwareTrait
  46320. {
  46321. protected $logger;
  46322. public function setLogger(LoggerInterface $logger)
  46323. {
  46324. $this->logger = $logger;
  46325. }
  46326. }
  46327. <?php
  46328. namespace Psr\Log;
  46329. interface LoggerInterface
  46330. {
  46331. public function emergency($message, array $context = array());
  46332. public function alert($message, array $context = array());
  46333. public function critical($message, array $context = array());
  46334. public function error($message, array $context = array());
  46335. public function warning($message, array $context = array());
  46336. public function notice($message, array $context = array());
  46337. public function info($message, array $context = array());
  46338. public function debug($message, array $context = array());
  46339. public function log($level, $message, array $context = array());
  46340. }
  46341. <?php
  46342. namespace Psr\Log;
  46343. trait LoggerTrait
  46344. {
  46345. public function emergency($message, array $context = array())
  46346. {
  46347. $this->log(LogLevel::EMERGENCY, $message, $context);
  46348. }
  46349. public function alert($message, array $context = array())
  46350. {
  46351. $this->log(LogLevel::ALERT, $message, $context);
  46352. }
  46353. public function critical($message, array $context = array())
  46354. {
  46355. $this->log(LogLevel::CRITICAL, $message, $context);
  46356. }
  46357. public function error($message, array $context = array())
  46358. {
  46359. $this->log(LogLevel::ERROR, $message, $context);
  46360. }
  46361. public function warning($message, array $context = array())
  46362. {
  46363. $this->log(LogLevel::WARNING, $message, $context);
  46364. }
  46365. public function notice($message, array $context = array())
  46366. {
  46367. $this->log(LogLevel::NOTICE, $message, $context);
  46368. }
  46369. public function info($message, array $context = array())
  46370. {
  46371. $this->log(LogLevel::INFO, $message, $context);
  46372. }
  46373. public function debug($message, array $context = array())
  46374. {
  46375. $this->log(LogLevel::DEBUG, $message, $context);
  46376. }
  46377. abstract public function log($level, $message, array $context = array());
  46378. }
  46379. <?php
  46380. namespace Psr\Log;
  46381. class NullLogger extends AbstractLogger
  46382. {
  46383. public function log($level, $message, array $context = array())
  46384. {
  46385. }
  46386. }
  46387. <?php
  46388. namespace Psr\Log\Test;
  46389. class DummyTest
  46390. {
  46391. public function __toString()
  46392. {
  46393. return 'DummyTest';
  46394. }
  46395. }
  46396. <?php
  46397. namespace Psr\Log\Test;
  46398. use Psr\Log\LoggerInterface;
  46399. use Psr\Log\LogLevel;
  46400. use PHPUnit\Framework\TestCase;
  46401. abstract class LoggerInterfaceTest extends TestCase
  46402. {
  46403. abstract public function getLogger();
  46404. abstract public function getLogs();
  46405. public function testImplements()
  46406. {
  46407. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  46408. }
  46409. public function testLogsAtAllLevels($level, $message)
  46410. {
  46411. $logger = $this->getLogger();
  46412. $logger->{$level}($message, array('user' => 'Bob'));
  46413. $logger->log($level, $message, array('user' => 'Bob'));
  46414. $expected = array(
  46415. $level.' message of level '.$level.' with context: Bob',
  46416. $level.' message of level '.$level.' with context: Bob',
  46417. );
  46418. $this->assertEquals($expected, $this->getLogs());
  46419. }
  46420. public function provideLevelsAndMessages()
  46421. {
  46422. return array(
  46423. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  46424. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  46425. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  46426. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  46427. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  46428. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  46429. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  46430. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  46431. );
  46432. }
  46433. public function testThrowsOnInvalidLevel()
  46434. {
  46435. $logger = $this->getLogger();
  46436. $logger->log('invalid level', 'Foo');
  46437. }
  46438. public function testContextReplacement()
  46439. {
  46440. $logger = $this->getLogger();
  46441. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  46442. $expected = array('info {Message {nothing} Bob Bar a}');
  46443. $this->assertEquals($expected, $this->getLogs());
  46444. }
  46445. public function testObjectCastToString()
  46446. {
  46447. if (method_exists($this, 'createPartialMock')) {
  46448. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  46449. } else {
  46450. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  46451. }
  46452. $dummy->expects($this->once())
  46453. ->method('__toString')
  46454. ->will($this->returnValue('DUMMY'));
  46455. $this->getLogger()->warning($dummy);
  46456. $expected = array('warning DUMMY');
  46457. $this->assertEquals($expected, $this->getLogs());
  46458. }
  46459. public function testContextCanContainAnything()
  46460. {
  46461. $closed = fopen('php://memory', 'r');
  46462. fclose($closed);
  46463. $context = array(
  46464. 'bool' => true,
  46465. 'null' => null,
  46466. 'string' => 'Foo',
  46467. 'int' => 0,
  46468. 'float' => 0.5,
  46469. 'nested' => array('with object' => new DummyTest),
  46470. 'object' => new \DateTime,
  46471. 'resource' => fopen('php://memory', 'r'),
  46472. 'closed' => $closed,
  46473. );
  46474. $this->getLogger()->warning('Crazy context data', $context);
  46475. $expected = array('warning Crazy context data');
  46476. $this->assertEquals($expected, $this->getLogs());
  46477. }
  46478. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  46479. {
  46480. $logger = $this->getLogger();
  46481. $logger->warning('Random message', array('exception' => 'oops'));
  46482. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  46483. $expected = array(
  46484. 'warning Random message',
  46485. 'critical Uncaught Exception!'
  46486. );
  46487. $this->assertEquals($expected, $this->getLogs());
  46488. }
  46489. }
  46490. <?php
  46491. namespace Psr\Log\Test;
  46492. use Psr\Log\AbstractLogger;
  46493. class TestLogger extends AbstractLogger
  46494. {
  46495. public $records = [];
  46496. public $recordsByLevel = [];
  46497. public function log($level, $message, array $context = [])
  46498. {
  46499. $record = [
  46500. 'level' => $level,
  46501. 'message' => $message,
  46502. 'context' => $context,
  46503. ];
  46504. $this->recordsByLevel[$record['level']][] = $record;
  46505. $this->records[] = $record;
  46506. }
  46507. public function hasRecords($level)
  46508. {
  46509. return isset($this->recordsByLevel[$level]);
  46510. }
  46511. public function hasRecord($record, $level)
  46512. {
  46513. if (is_string($record)) {
  46514. $record = ['message' => $record];
  46515. }
  46516. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  46517. if ($rec['message'] !== $record['message']) {
  46518. return false;
  46519. }
  46520. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  46521. return false;
  46522. }
  46523. return true;
  46524. }, $level);
  46525. }
  46526. public function hasRecordThatContains($message, $level)
  46527. {
  46528. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  46529. return strpos($rec['message'], $message) !== false;
  46530. }, $level);
  46531. }
  46532. public function hasRecordThatMatches($regex, $level)
  46533. {
  46534. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  46535. return preg_match($regex, $rec['message']) > 0;
  46536. }, $level);
  46537. }
  46538. public function hasRecordThatPasses(callable $predicate, $level)
  46539. {
  46540. if (!isset($this->recordsByLevel[$level])) {
  46541. return false;
  46542. }
  46543. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  46544. if (call_user_func($predicate, $rec, $i)) {
  46545. return true;
  46546. }
  46547. }
  46548. return false;
  46549. }
  46550. public function __call($method, $args)
  46551. {
  46552. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  46553. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  46554. $level = strtolower($matches[2]);
  46555. if (method_exists($this, $genericMethod)) {
  46556. $args[] = $level;
  46557. return call_user_func_array([$this, $genericMethod], $args);
  46558. }
  46559. }
  46560. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  46561. }
  46562. public function reset()
  46563. {
  46564. $this->records = [];
  46565. $this->recordsByLevel = [];
  46566. }
  46567. }
  46568. Copyright (c) 2012-2016 Jan Sorgalla
  46569. Permission is hereby granted, free of charge, to any person
  46570. obtaining a copy of this software and associated documentation
  46571. files (the "Software"), to deal in the Software without
  46572. restriction, including without limitation the rights to use,
  46573. copy, modify, merge, publish, distribute, sublicense, and/or sell
  46574. copies of the Software, and to permit persons to whom the
  46575. Software is furnished to do so, subject to the following
  46576. conditions:
  46577. The above copyright notice and this permission notice shall be
  46578. included in all copies or substantial portions of the Software.
  46579. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  46580. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  46581. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  46582. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  46583. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  46584. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  46585. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  46586. OTHER DEALINGS IN THE SOFTWARE.
  46587. <?php
  46588. namespace React\Promise;
  46589. interface CancellablePromiseInterface extends PromiseInterface
  46590. {
  46591. public function cancel();
  46592. }
  46593. <?php
  46594. namespace React\Promise;
  46595. class Deferred implements PromiseInterface, ResolverInterface, PromisorInterface, CancellablePromiseInterface
  46596. {
  46597. private $completed;
  46598. private $promise;
  46599. private $resolver;
  46600. private $handlers = array();
  46601. private $progressHandlers = array();
  46602. private $canceller;
  46603. private $requiredCancelRequests = 0;
  46604. private $cancelRequests = 0;
  46605. public function __construct($canceller = null)
  46606. {
  46607. if ($canceller !== null && !is_callable($canceller)) {
  46608. throw new \InvalidArgumentException(
  46609. sprintf(
  46610. 'The canceller argument must be null or of type callable, %s given.',
  46611. gettype($canceller)
  46612. )
  46613. );
  46614. }
  46615. $this->canceller = $canceller;
  46616. }
  46617. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46618. {
  46619. if (null !== $this->completed) {
  46620. return $this->completed->then($fulfilledHandler, $errorHandler, $progressHandler);
  46621. }
  46622. $canceller = null;
  46623. if ($this->canceller !== null) {
  46624. $this->requiredCancelRequests++;
  46625. $that = $this;
  46626. $current =& $this->cancelRequests;
  46627. $required =& $this->requiredCancelRequests;
  46628. $canceller = function () use ($that, &$current, &$required) {
  46629. if (++$current < $required) {
  46630. return;
  46631. }
  46632. $that->cancel();
  46633. };
  46634. }
  46635. $deferred = new static($canceller);
  46636. if (is_callable($progressHandler)) {
  46637. $progHandler = function ($update) use ($deferred, $progressHandler) {
  46638. try {
  46639. $deferred->progress(call_user_func($progressHandler, $update));
  46640. } catch (\Exception $e) {
  46641. $deferred->progress($e);
  46642. }
  46643. };
  46644. } else {
  46645. if (null !== $progressHandler) {
  46646. trigger_error('Invalid $progressHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46647. }
  46648. $progHandler = array($deferred, 'progress');
  46649. }
  46650. $this->handlers[] = function ($promise) use ($fulfilledHandler, $errorHandler, $deferred, $progHandler) {
  46651. $promise
  46652. ->then($fulfilledHandler, $errorHandler)
  46653. ->then(
  46654. array($deferred, 'resolve'),
  46655. array($deferred, 'reject'),
  46656. $progHandler
  46657. );
  46658. };
  46659. $this->progressHandlers[] = $progHandler;
  46660. return $deferred->promise();
  46661. }
  46662. public function resolve($result = null)
  46663. {
  46664. if (null !== $this->completed) {
  46665. return resolve($result);
  46666. }
  46667. $this->completed = resolve($result);
  46668. $this->processQueue($this->handlers, $this->completed);
  46669. $this->progressHandlers = $this->handlers = array();
  46670. return $this->completed;
  46671. }
  46672. public function reject($reason = null)
  46673. {
  46674. return $this->resolve(reject($reason));
  46675. }
  46676. public function progress($update = null)
  46677. {
  46678. if (null !== $this->completed) {
  46679. return;
  46680. }
  46681. $this->processQueue($this->progressHandlers, $update);
  46682. }
  46683. public function promise()
  46684. {
  46685. if (null === $this->promise) {
  46686. $this->promise = new DeferredPromise($this);
  46687. }
  46688. return $this->promise;
  46689. }
  46690. public function resolver()
  46691. {
  46692. if (null === $this->resolver) {
  46693. $this->resolver = new DeferredResolver($this);
  46694. }
  46695. return $this->resolver;
  46696. }
  46697. public function cancel()
  46698. {
  46699. if (null === $this->canceller || null !== $this->completed) {
  46700. return;
  46701. }
  46702. $canceller = $this->canceller;
  46703. $this->canceller = null;
  46704. try {
  46705. $that = $this;
  46706. call_user_func(
  46707. $canceller,
  46708. function ($value = null) use ($that) {
  46709. $that->resolve($value);
  46710. },
  46711. function ($reason = null) use ($that) {
  46712. $that->reject($reason);
  46713. },
  46714. function ($update = null) use ($that) {
  46715. $that->progress($update);
  46716. }
  46717. );
  46718. } catch (\Exception $e) {
  46719. $this->reject($e);
  46720. }
  46721. }
  46722. protected function processQueue($queue, $value)
  46723. {
  46724. foreach ($queue as $handler) {
  46725. call_user_func($handler, $value);
  46726. }
  46727. }
  46728. }
  46729. <?php
  46730. namespace React\Promise;
  46731. class DeferredPromise implements PromiseInterface, CancellablePromiseInterface
  46732. {
  46733. private $deferred;
  46734. public function __construct(Deferred $deferred)
  46735. {
  46736. $this->deferred = $deferred;
  46737. }
  46738. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46739. {
  46740. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46741. }
  46742. public function cancel()
  46743. {
  46744. $this->deferred->cancel();
  46745. }
  46746. }
  46747. <?php
  46748. namespace React\Promise;
  46749. class DeferredResolver implements ResolverInterface
  46750. {
  46751. private $deferred;
  46752. public function __construct(Deferred $deferred)
  46753. {
  46754. $this->deferred = $deferred;
  46755. }
  46756. public function resolve($result = null)
  46757. {
  46758. return $this->deferred->resolve($result);
  46759. }
  46760. public function reject($reason = null)
  46761. {
  46762. return $this->deferred->reject($reason);
  46763. }
  46764. public function progress($update = null)
  46765. {
  46766. return $this->deferred->progress($update);
  46767. }
  46768. }
  46769. <?php
  46770. namespace React\Promise;
  46771. class FulfilledPromise implements PromiseInterface, CancellablePromiseInterface
  46772. {
  46773. private $result;
  46774. public function __construct($result = null)
  46775. {
  46776. $this->result = $result;
  46777. }
  46778. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46779. {
  46780. try {
  46781. $result = $this->result;
  46782. if (is_callable($fulfilledHandler)) {
  46783. $result = call_user_func($fulfilledHandler, $result);
  46784. } elseif (null !== $fulfilledHandler) {
  46785. trigger_error('Invalid $fulfilledHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46786. }
  46787. return resolve($result);
  46788. } catch (\Exception $exception) {
  46789. return new RejectedPromise($exception);
  46790. }
  46791. }
  46792. public function cancel()
  46793. {
  46794. }
  46795. }
  46796. <?php
  46797. namespace React\Promise;
  46798. class LazyPromise implements PromiseInterface, CancellablePromiseInterface
  46799. {
  46800. private $factory;
  46801. private $promise;
  46802. public function __construct($factory)
  46803. {
  46804. $this->factory = $factory;
  46805. }
  46806. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46807. {
  46808. return $this->promise()->then($fulfilledHandler, $errorHandler, $progressHandler);
  46809. }
  46810. public function cancel()
  46811. {
  46812. $promise = $this->promise();
  46813. if ($promise instanceof CancellablePromiseInterface) {
  46814. $promise->cancel();
  46815. }
  46816. }
  46817. private function promise()
  46818. {
  46819. if (null === $this->promise) {
  46820. try {
  46821. $this->promise = resolve(call_user_func($this->factory));
  46822. } catch (\Exception $exception) {
  46823. $this->promise = new RejectedPromise($exception);
  46824. }
  46825. }
  46826. return $this->promise;
  46827. }
  46828. }
  46829. <?php
  46830. namespace React\Promise;
  46831. class Promise implements PromiseInterface, CancellablePromiseInterface
  46832. {
  46833. private $deferred;
  46834. public function __construct($resolver, $canceller = null)
  46835. {
  46836. if (!is_callable($resolver)) {
  46837. throw new \InvalidArgumentException(
  46838. sprintf(
  46839. 'The resolver argument must be of type callable, %s given.',
  46840. gettype($resolver)
  46841. )
  46842. );
  46843. }
  46844. $this->deferred = new Deferred($canceller);
  46845. $this->call($resolver);
  46846. }
  46847. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46848. {
  46849. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46850. }
  46851. public function cancel()
  46852. {
  46853. $this->deferred->cancel();
  46854. }
  46855. private function call($callback)
  46856. {
  46857. $deferred = $this->deferred;
  46858. try {
  46859. call_user_func(
  46860. $callback,
  46861. function ($result = null) use ($deferred) {
  46862. $deferred->resolve($result);
  46863. },
  46864. function ($reason = null) use ($deferred) {
  46865. $deferred->reject($reason);
  46866. },
  46867. function ($update = null) use ($deferred) {
  46868. $deferred->progress($update);
  46869. }
  46870. );
  46871. } catch (\Exception $e) {
  46872. $this->deferred->reject($e);
  46873. }
  46874. }
  46875. }
  46876. <?php
  46877. namespace React\Promise;
  46878. interface PromiseInterface
  46879. {
  46880. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
  46881. }
  46882. <?php
  46883. namespace React\Promise;
  46884. interface PromisorInterface
  46885. {
  46886. public function promise();
  46887. }
  46888. <?php
  46889. namespace React\Promise;
  46890. class RejectedPromise implements PromiseInterface, CancellablePromiseInterface
  46891. {
  46892. private $reason;
  46893. public function __construct($reason = null)
  46894. {
  46895. $this->reason = $reason;
  46896. }
  46897. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46898. {
  46899. try {
  46900. if (!is_callable($errorHandler)) {
  46901. if (null !== $errorHandler) {
  46902. trigger_error('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46903. }
  46904. return new RejectedPromise($this->reason);
  46905. }
  46906. return resolve(call_user_func($errorHandler, $this->reason));
  46907. } catch (\Exception $exception) {
  46908. return new RejectedPromise($exception);
  46909. }
  46910. }
  46911. public function cancel()
  46912. {
  46913. }
  46914. }
  46915. <?php
  46916. namespace React\Promise;
  46917. interface ResolverInterface
  46918. {
  46919. public function resolve($result = null);
  46920. public function reject($reason = null);
  46921. public function progress($update = null);
  46922. }
  46923. <?php
  46924. namespace React\Promise;
  46925. class Util
  46926. {
  46927. public static function promiseFor($promiseOrValue)
  46928. {
  46929. return resolve($promiseOrValue);
  46930. }
  46931. public static function rejectedPromiseFor($promiseOrValue)
  46932. {
  46933. return reject($promiseOrValue);
  46934. }
  46935. }
  46936. <?php
  46937. namespace React\Promise;
  46938. class When
  46939. {
  46940. public static function resolve($promiseOrValue = null)
  46941. {
  46942. return resolve($promiseOrValue);
  46943. }
  46944. public static function reject($promiseOrValue = null)
  46945. {
  46946. return reject($promiseOrValue);
  46947. }
  46948. public static function lazy($factory)
  46949. {
  46950. return new LazyPromise($factory);
  46951. }
  46952. public static function all($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46953. {
  46954. return all($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46955. }
  46956. public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46957. {
  46958. return any($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46959. }
  46960. public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46961. {
  46962. return some($promisesOrValues, $howMany)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46963. }
  46964. public static function map($promisesOrValues, $mapFunc)
  46965. {
  46966. return map($promisesOrValues, $mapFunc);
  46967. }
  46968. public static function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  46969. {
  46970. return reduce($promisesOrValues, $reduceFunc, $initialValue);
  46971. }
  46972. }
  46973. <?php
  46974. namespace React\Promise;
  46975. function resolve($promiseOrValue = null)
  46976. {
  46977. if ($promiseOrValue instanceof PromiseInterface) {
  46978. return $promiseOrValue;
  46979. }
  46980. return new FulfilledPromise($promiseOrValue);
  46981. }
  46982. function reject($promiseOrValue = null)
  46983. {
  46984. if ($promiseOrValue instanceof PromiseInterface) {
  46985. return $promiseOrValue->then(function ($value) {
  46986. return new RejectedPromise($value);
  46987. });
  46988. }
  46989. return new RejectedPromise($promiseOrValue);
  46990. }
  46991. function all($promisesOrValues)
  46992. {
  46993. return map($promisesOrValues, function ($val) {
  46994. return $val;
  46995. });
  46996. }
  46997. function any($promisesOrValues)
  46998. {
  46999. return some($promisesOrValues, 1)->then(function($val) {
  47000. return array_shift($val);
  47001. });
  47002. }
  47003. function some($promisesOrValues, $howMany)
  47004. {
  47005. return resolve($promisesOrValues)->then(function ($array) use ($howMany) {
  47006. if (!is_array($array)) {
  47007. $array = array();
  47008. }
  47009. $len = count($array);
  47010. $toResolve = max(0, min($howMany, $len));
  47011. $values = array();
  47012. $deferred = new Deferred();
  47013. if (!$toResolve) {
  47014. $deferred->resolve($values);
  47015. } else {
  47016. $toReject = ($len - $toResolve) + 1;
  47017. $reasons = array();
  47018. $progress = array($deferred, 'progress');
  47019. $fulfillOne = function ($val, $i) use (&$values, &$toResolve, $deferred) {
  47020. $values[$i] = $val;
  47021. if (0 === --$toResolve) {
  47022. $deferred->resolve($values);
  47023. return true;
  47024. }
  47025. };
  47026. $rejectOne = function ($reason, $i) use (&$reasons, &$toReject, $deferred) {
  47027. $reasons[$i] = $reason;
  47028. if (0 === --$toReject) {
  47029. $deferred->reject($reasons);
  47030. return true;
  47031. }
  47032. };
  47033. foreach ($array as $i => $promiseOrValue) {
  47034. $fulfiller = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  47035. $reset = $fulfillOne($val, $i);
  47036. if (true === $reset) {
  47037. $fulfillOne = $rejectOne = function () {};
  47038. }
  47039. };
  47040. $rejecter = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  47041. $reset = $rejectOne($val, $i);
  47042. if (true === $reset) {
  47043. $fulfillOne = $rejectOne = function () {};
  47044. }
  47045. };
  47046. resolve($promiseOrValue)->then($fulfiller, $rejecter, $progress);
  47047. }
  47048. }
  47049. return $deferred->promise();
  47050. });
  47051. }
  47052. function map($promisesOrValues, $mapFunc)
  47053. {
  47054. return resolve($promisesOrValues)->then(function ($array) use ($mapFunc) {
  47055. if (!is_array($array)) {
  47056. $array = array();
  47057. }
  47058. $toResolve = count($array);
  47059. $results = array();
  47060. $deferred = new Deferred();
  47061. if (!$toResolve) {
  47062. $deferred->resolve($results);
  47063. } else {
  47064. $resolve = function ($item, $i) use ($mapFunc, &$results, &$toResolve, $deferred) {
  47065. resolve($item)
  47066. ->then($mapFunc)
  47067. ->then(
  47068. function ($mapped) use (&$results, $i, &$toResolve, $deferred) {
  47069. $results[$i] = $mapped;
  47070. if (0 === --$toResolve) {
  47071. $deferred->resolve($results);
  47072. }
  47073. },
  47074. array($deferred, 'reject')
  47075. );
  47076. };
  47077. foreach ($array as $i => $item) {
  47078. $resolve($item, $i);
  47079. }
  47080. }
  47081. return $deferred->promise();
  47082. });
  47083. }
  47084. function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  47085. {
  47086. return resolve($promisesOrValues)->then(function ($array) use ($reduceFunc, $initialValue) {
  47087. if (!is_array($array)) {
  47088. $array = array();
  47089. }
  47090. $total = count($array);
  47091. $i = 0;
  47092. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $total, &$i) {
  47093. return resolve($current)->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  47094. return resolve($val)->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  47095. return call_user_func($reduceFunc, $c, $value, $i++, $total);
  47096. });
  47097. });
  47098. };
  47099. return array_reduce($array, $wrappedReduceFunc, $initialValue);
  47100. });
  47101. }
  47102. <?php
  47103. if (!function_exists('React\Promise\resolve')) {
  47104. require __DIR__.'/functions.php';
  47105. }
  47106. Copyright (c) 2011 Jordi Boggiano
  47107. Permission is hereby granted, free of charge, to any person obtaining a copy
  47108. of this software and associated documentation files (the "Software"), to deal
  47109. in the Software without restriction, including without limitation the rights
  47110. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47111. copies of the Software, and to permit persons to whom the Software is furnished
  47112. to do so, subject to the following conditions:
  47113. The above copyright notice and this permission notice shall be included in all
  47114. copies or substantial portions of the Software.
  47115. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47116. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47117. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47118. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47119. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47120. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47121. THE SOFTWARE.
  47122. <?php
  47123. namespace Seld\JsonLint;
  47124. class DuplicateKeyException extends ParsingException
  47125. {
  47126. public function __construct($message, $key, array $details = array())
  47127. {
  47128. $details['key'] = $key;
  47129. parent::__construct($message, $details);
  47130. }
  47131. public function getKey()
  47132. {
  47133. return $this->details['key'];
  47134. }
  47135. public function getDetails()
  47136. {
  47137. return $this->details;
  47138. }
  47139. }
  47140. <?php
  47141. namespace Seld\JsonLint;
  47142. use stdClass;
  47143. class JsonParser
  47144. {
  47145. const DETECT_KEY_CONFLICTS = 1;
  47146. const ALLOW_DUPLICATE_KEYS = 2;
  47147. const PARSE_TO_ASSOC = 4;
  47148. private $lexer;
  47149. private $flags;
  47150. private $stack;
  47151. private $vstack;
  47152. private $lstack;
  47153. private $symbols = array(
  47154. 'error' => 2,
  47155. 'JSONString' => 3,
  47156. 'STRING' => 4,
  47157. 'JSONNumber' => 5,
  47158. 'NUMBER' => 6,
  47159. 'JSONNullLiteral' => 7,
  47160. 'NULL' => 8,
  47161. 'JSONBooleanLiteral' => 9,
  47162. 'TRUE' => 10,
  47163. 'FALSE' => 11,
  47164. 'JSONText' => 12,
  47165. 'JSONValue' => 13,
  47166. 'EOF' => 14,
  47167. 'JSONObject' => 15,
  47168. 'JSONArray' => 16,
  47169. '{' => 17,
  47170. '}' => 18,
  47171. 'JSONMemberList' => 19,
  47172. 'JSONMember' => 20,
  47173. ':' => 21,
  47174. ',' => 22,
  47175. '[' => 23,
  47176. ']' => 24,
  47177. 'JSONElementList' => 25,
  47178. '$accept' => 0,
  47179. '$end' => 1,
  47180. );
  47181. private $terminals_ = array(
  47182. 2 => "error",
  47183. 4 => "STRING",
  47184. 6 => "NUMBER",
  47185. 8 => "NULL",
  47186. 10 => "TRUE",
  47187. 11 => "FALSE",
  47188. 14 => "EOF",
  47189. 17 => "{",
  47190. 18 => "}",
  47191. 21 => ":",
  47192. 22 => ",",
  47193. 23 => "[",
  47194. 24 => "]",
  47195. );
  47196. private $productions_ = array(
  47197. 0,
  47198. array(3, 1),
  47199. array(5, 1),
  47200. array(7, 1),
  47201. array(9, 1),
  47202. array(9, 1),
  47203. array(12, 2),
  47204. array(13, 1),
  47205. array(13, 1),
  47206. array(13, 1),
  47207. array(13, 1),
  47208. array(13, 1),
  47209. array(13, 1),
  47210. array(15, 2),
  47211. array(15, 3),
  47212. array(20, 3),
  47213. array(19, 1),
  47214. array(19, 3),
  47215. array(16, 2),
  47216. array(16, 3),
  47217. array(25, 1),
  47218. array(25, 3)
  47219. );
  47220. private $table = array(array(3 => 5, 4 => array(1,12), 5 => 6, 6 => array(1,13), 7 => 3, 8 => array(1,9), 9 => 4, 10 => array(1,10), 11 => array(1,11), 12 => 1, 13 => 2, 15 => 7, 16 => 8, 17 => array(1,14), 23 => array(1,15)), array( 1 => array(3)), array( 14 => array(1,16)), array( 14 => array(2,7), 18 => array(2,7), 22 => array(2,7), 24 => array(2,7)), array( 14 => array(2,8), 18 => array(2,8), 22 => array(2,8), 24 => array(2,8)), array( 14 => array(2,9), 18 => array(2,9), 22 => array(2,9), 24 => array(2,9)), array( 14 => array(2,10), 18 => array(2,10), 22 => array(2,10), 24 => array(2,10)), array( 14 => array(2,11), 18 => array(2,11), 22 => array(2,11), 24 => array(2,11)), array( 14 => array(2,12), 18 => array(2,12), 22 => array(2,12), 24 => array(2,12)), array( 14 => array(2,3), 18 => array(2,3), 22 => array(2,3), 24 => array(2,3)), array( 14 => array(2,4), 18 => array(2,4), 22 => array(2,4), 24 => array(2,4)), array( 14 => array(2,5), 18 => array(2,5), 22 => array(2,5), 24 => array(2,5)), array( 14 => array(2,1), 18 => array(2,1), 21 => array(2,1), 22 => array(2,1), 24 => array(2,1)), array( 14 => array(2,2), 18 => array(2,2), 22 => array(2,2), 24 => array(2,2)), array( 3 => 20, 4 => array(1,12), 18 => array(1,17), 19 => 18, 20 => 19 ), array( 3 => 5, 4 => array(1,12), 5 => 6, 6 => array(1,13), 7 => 3, 8 => array(1,9), 9 => 4, 10 => array(1,10), 11 => array(1,11), 13 => 23, 15 => 7, 16 => 8, 17 => array(1,14), 23 => array(1,15), 24 => array(1,21), 25 => 22 ), array( 1 => array(2,6)), array( 14 => array(2,13), 18 => array(2,13), 22 => array(2,13), 24 => array(2,13)), array( 18 => array(1,24), 22 => array(1,25)), array( 18 => array(2,16), 22 => array(2,16)), array( 21 => array(1,26)), array( 14 => array(2,18), 18 => array(2,18), 22 => array(2,18), 24 => array(2,18)), array( 22 => array(1,28), 24 => array(1,27)), array( 22 => array(2,20), 24 => array(2,20)), array( 14 => array(2,14), 18 => array(2,14), 22 => array(2,14), 24 => array(2,14)), array( 3 => 20, 4 => array(1,12), 20 => 29 ), array( 3 => 5, 4 => array(1,12), 5 => 6, 6 => array(1,13), 7 => 3, 8 => array(1,9), 9 => 4, 10 => array(1,10), 11 => array(1,11), 13 => 30, 15 => 7, 16 => 8, 17 => array(1,14), 23 => array(1,15)), array( 14 => array(2,19), 18 => array(2,19), 22 => array(2,19), 24 => array(2,19)), array( 3 => 5, 4 => array(1,12), 5 => 6, 6 => array(1,13), 7 => 3, 8 => array(1,9), 9 => 4, 10 => array(1,10), 11 => array(1,11), 13 => 31, 15 => 7, 16 => 8, 17 => array(1,14), 23 => array(1,15)), array( 18 => array(2,17), 22 => array(2,17)), array( 18 => array(2,15), 22 => array(2,15)), array( 22 => array(2,21), 24 => array(2,21)),
  47221. );
  47222. private $defaultActions = array(
  47223. 16 => array(2, 6)
  47224. );
  47225. public function lint($input, $flags = 0)
  47226. {
  47227. try {
  47228. $this->parse($input, $flags);
  47229. } catch (ParsingException $e) {
  47230. return $e;
  47231. }
  47232. return null;
  47233. }
  47234. public function parse($input, $flags = 0)
  47235. {
  47236. $this->failOnBOM($input);
  47237. $this->flags = $flags;
  47238. $this->stack = array(0);
  47239. $this->vstack = array(null);
  47240. $this->lstack = array();
  47241. $yytext = '';
  47242. $yylineno = 0;
  47243. $yyleng = 0;
  47244. $recovering = 0;
  47245. $TERROR = 2;
  47246. $EOF = 1;
  47247. $this->lexer = new Lexer();
  47248. $this->lexer->setInput($input);
  47249. $yyloc = $this->lexer->yylloc;
  47250. $this->lstack[] = $yyloc;
  47251. $symbol = null;
  47252. $preErrorSymbol = null;
  47253. $state = null;
  47254. $action = null;
  47255. $a = null;
  47256. $r = null;
  47257. $yyval = new stdClass;
  47258. $p = null;
  47259. $len = null;
  47260. $newState = null;
  47261. $expected = null;
  47262. $errStr = null;
  47263. while (true) {
  47264. $state = $this->stack[\count($this->stack)-1];
  47265. if (isset($this->defaultActions[$state])) {
  47266. $action = $this->defaultActions[$state];
  47267. } else {
  47268. if ($symbol == null) {
  47269. $symbol = $this->lex();
  47270. }
  47271. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  47272. }
  47273. if (!$action || !$action[0]) {
  47274. if (!$recovering) {
  47275. $expected = array();
  47276. foreach ($this->table[$state] as $p => $ignore) {
  47277. if (isset($this->terminals_[$p]) && $p > 2) {
  47278. $expected[] = "'" . $this->terminals_[$p] . "'";
  47279. }
  47280. }
  47281. $message = null;
  47282. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  47283. $message = "Invalid string";
  47284. if ("'" === substr($this->lexer->match, 0, 1)) {
  47285. $message .= ", it appears you used single quotes instead of double quotes";
  47286. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  47287. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  47288. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  47289. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  47290. }
  47291. }
  47292. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47293. $errStr .= $this->lexer->showPosition() . "\n";
  47294. if ($message) {
  47295. $errStr .= $message;
  47296. } else {
  47297. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  47298. $errStr .= implode(', ', $expected);
  47299. }
  47300. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  47301. $errStr .= " - It appears you have an extra trailing comma";
  47302. }
  47303. $this->parseError($errStr, array(
  47304. 'text' => $this->lexer->match,
  47305. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  47306. 'line' => $this->lexer->yylineno,
  47307. 'loc' => $yyloc,
  47308. 'expected' => $expected,
  47309. ));
  47310. }
  47311. if ($recovering == 3) {
  47312. if ($symbol == $EOF) {
  47313. throw new ParsingException($errStr ?: 'Parsing halted.');
  47314. }
  47315. $yyleng = $this->lexer->yyleng;
  47316. $yytext = $this->lexer->yytext;
  47317. $yylineno = $this->lexer->yylineno;
  47318. $yyloc = $this->lexer->yylloc;
  47319. $symbol = $this->lex();
  47320. }
  47321. while (true) {
  47322. if (\array_key_exists($TERROR, $this->table[$state])) {
  47323. break;
  47324. }
  47325. if ($state == 0) {
  47326. throw new ParsingException($errStr ?: 'Parsing halted.');
  47327. }
  47328. $this->popStack(1);
  47329. $state = $this->stack[\count($this->stack)-1];
  47330. }
  47331. $preErrorSymbol = $symbol;
  47332. $symbol = $TERROR;
  47333. $state = $this->stack[\count($this->stack)-1];
  47334. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  47335. $recovering = 3;
  47336. }
  47337. if (\is_array($action[0]) && \count($action) > 1) {
  47338. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  47339. }
  47340. switch ($action[0]) {
  47341. case 1:
  47342. $this->stack[] = $symbol;
  47343. $this->vstack[] = $this->lexer->yytext;
  47344. $this->lstack[] = $this->lexer->yylloc;
  47345. $this->stack[] = $action[1];
  47346. $symbol = null;
  47347. if (!$preErrorSymbol) {
  47348. $yyleng = $this->lexer->yyleng;
  47349. $yytext = $this->lexer->yytext;
  47350. $yylineno = $this->lexer->yylineno;
  47351. $yyloc = $this->lexer->yylloc;
  47352. if ($recovering > 0) {
  47353. $recovering--;
  47354. }
  47355. } else {
  47356. $symbol = $preErrorSymbol;
  47357. $preErrorSymbol = null;
  47358. }
  47359. break;
  47360. case 2:
  47361. $len = $this->productions_[$action[1]][1];
  47362. $yyval->token = $this->vstack[\count($this->vstack) - $len];
  47363. $yyval->store = array(
  47364. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  47365. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  47366. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  47367. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  47368. );
  47369. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
  47370. if (!$r instanceof Undefined) {
  47371. return $r;
  47372. }
  47373. if ($len) {
  47374. $this->popStack($len);
  47375. }
  47376. $this->stack[] = $this->productions_[$action[1]][0];
  47377. $this->vstack[] = $yyval->token;
  47378. $this->lstack[] = $yyval->store;
  47379. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  47380. $this->stack[] = $newState;
  47381. break;
  47382. case 3:
  47383. return true;
  47384. }
  47385. }
  47386. }
  47387. protected function parseError($str, $hash)
  47388. {
  47389. throw new ParsingException($str, $hash);
  47390. }
  47391. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  47392. {
  47393. $len = \count($tokens) - 1;
  47394. switch ($yystate) {
  47395. case 1:
  47396. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  47397. $yyval->token = $yytext;
  47398. break;
  47399. case 2:
  47400. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  47401. $yyval->token = \floatval($yytext);
  47402. } else {
  47403. $yyval->token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  47404. }
  47405. break;
  47406. case 3:
  47407. $yyval->token = null;
  47408. break;
  47409. case 4:
  47410. $yyval->token = true;
  47411. break;
  47412. case 5:
  47413. $yyval->token = false;
  47414. break;
  47415. case 6:
  47416. return $yyval->token = $tokens[$len-1];
  47417. case 13:
  47418. if ($this->flags & self::PARSE_TO_ASSOC) {
  47419. $yyval->token = array();
  47420. } else {
  47421. $yyval->token = new stdClass;
  47422. }
  47423. break;
  47424. case 14:
  47425. $yyval->token = $tokens[$len-1];
  47426. break;
  47427. case 15:
  47428. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  47429. break;
  47430. case 16:
  47431. if (PHP_VERSION_ID < 70100) {
  47432. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  47433. } else {
  47434. $property = $tokens[$len][0];
  47435. }
  47436. if ($this->flags & self::PARSE_TO_ASSOC) {
  47437. $yyval->token = array();
  47438. $yyval->token[$property] = $tokens[$len][1];
  47439. } else {
  47440. $yyval->token = new stdClass;
  47441. $yyval->token->$property = $tokens[$len][1];
  47442. }
  47443. break;
  47444. case 17:
  47445. if ($this->flags & self::PARSE_TO_ASSOC) {
  47446. $yyval->token =& $tokens[$len-2];
  47447. $key = $tokens[$len][0];
  47448. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  47449. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47450. $errStr .= $this->lexer->showPosition() . "\n";
  47451. $errStr .= "Duplicate key: ".$tokens[$len][0];
  47452. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  47453. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  47454. $duplicateCount = 1;
  47455. do {
  47456. $duplicateKey = $key . '.' . $duplicateCount++;
  47457. } while (isset($tokens[$len-2][$duplicateKey]));
  47458. $key = $duplicateKey;
  47459. }
  47460. $tokens[$len-2][$key] = $tokens[$len][1];
  47461. } else {
  47462. $yyval->token = $tokens[$len-2];
  47463. if (PHP_VERSION_ID < 70100) {
  47464. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  47465. } else {
  47466. $key = $tokens[$len][0];
  47467. }
  47468. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  47469. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47470. $errStr .= $this->lexer->showPosition() . "\n";
  47471. $errStr .= "Duplicate key: ".$tokens[$len][0];
  47472. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  47473. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  47474. $duplicateCount = 1;
  47475. do {
  47476. $duplicateKey = $key . '.' . $duplicateCount++;
  47477. } while (isset($tokens[$len-2]->$duplicateKey));
  47478. $key = $duplicateKey;
  47479. }
  47480. $tokens[$len-2]->$key = $tokens[$len][1];
  47481. }
  47482. break;
  47483. case 18:
  47484. $yyval->token = array();
  47485. break;
  47486. case 19:
  47487. $yyval->token = $tokens[$len-1];
  47488. break;
  47489. case 20:
  47490. $yyval->token = array($tokens[$len]);
  47491. break;
  47492. case 21:
  47493. $tokens[$len-2][] = $tokens[$len];
  47494. $yyval->token = $tokens[$len-2];
  47495. break;
  47496. }
  47497. return new Undefined();
  47498. }
  47499. private function stringInterpolation($match)
  47500. {
  47501. switch ($match[0]) {
  47502. case '\\\\':
  47503. return '\\';
  47504. case '\"':
  47505. return '"';
  47506. case '\b':
  47507. return \chr(8);
  47508. case '\f':
  47509. return \chr(12);
  47510. case '\n':
  47511. return "\n";
  47512. case '\r':
  47513. return "\r";
  47514. case '\t':
  47515. return "\t";
  47516. case '\/':
  47517. return "/";
  47518. default:
  47519. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  47520. }
  47521. }
  47522. private function popStack($n)
  47523. {
  47524. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  47525. $this->vstack = \array_slice($this->vstack, 0, - $n);
  47526. $this->lstack = \array_slice($this->lstack, 0, - $n);
  47527. }
  47528. private function lex()
  47529. {
  47530. $token = $this->lexer->lex() ?: 1;
  47531. if (!is_numeric($token)) {
  47532. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  47533. }
  47534. return $token;
  47535. }
  47536. private function failOnBOM($input)
  47537. {
  47538. $bom = "\xEF\xBB\xBF";
  47539. if (substr($input, 0, 3) === $bom) {
  47540. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  47541. }
  47542. }
  47543. }
  47544. <?php
  47545. namespace Seld\JsonLint;
  47546. class Lexer
  47547. {
  47548. private $EOF = 1;
  47549. private $rules = array(
  47550. 0 => '/\G\s+/',
  47551. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  47552. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  47553. 3 => '/\G\{/',
  47554. 4 => '/\G\}/',
  47555. 5 => '/\G\[/',
  47556. 6 => '/\G\]/',
  47557. 7 => '/\G,/',
  47558. 8 => '/\G:/',
  47559. 9 => '/\Gtrue\b/',
  47560. 10 => '/\Gfalse\b/',
  47561. 11 => '/\Gnull\b/',
  47562. 12 => '/\G$/',
  47563. 13 => '/\G./',
  47564. );
  47565. private $conditions = array(
  47566. "INITIAL" => array(
  47567. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  47568. "inclusive" => true,
  47569. ),
  47570. );
  47571. private $conditionStack;
  47572. private $input;
  47573. private $more;
  47574. private $done;
  47575. private $offset;
  47576. public $match;
  47577. public $yylineno;
  47578. public $yyleng;
  47579. public $yytext;
  47580. public $yylloc;
  47581. public function lex()
  47582. {
  47583. $r = $this->next();
  47584. if (!$r instanceof Undefined) {
  47585. return $r;
  47586. }
  47587. return $this->lex();
  47588. }
  47589. public function setInput($input)
  47590. {
  47591. $this->input = $input;
  47592. $this->more = false;
  47593. $this->done = false;
  47594. $this->offset = 0;
  47595. $this->yylineno = $this->yyleng = 0;
  47596. $this->yytext = $this->match = '';
  47597. $this->conditionStack = array('INITIAL');
  47598. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  47599. return $this;
  47600. }
  47601. public function showPosition()
  47602. {
  47603. $pre = str_replace("\n", '', $this->getPastInput());
  47604. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  47605. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  47606. }
  47607. public function getPastInput()
  47608. {
  47609. $pastLength = $this->offset - \strlen($this->match);
  47610. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  47611. }
  47612. public function getUpcomingInput()
  47613. {
  47614. $next = $this->match;
  47615. if (\strlen($next) < 20) {
  47616. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47617. }
  47618. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  47619. }
  47620. public function getFullUpcomingInput()
  47621. {
  47622. $next = $this->match;
  47623. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  47624. $len = \strlen($this->input);
  47625. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  47626. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  47627. } elseif (\strlen($next) < 20) {
  47628. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47629. }
  47630. return $next;
  47631. }
  47632. protected function parseError($str, $hash)
  47633. {
  47634. throw new \Exception($str);
  47635. }
  47636. private function next()
  47637. {
  47638. if ($this->done) {
  47639. return $this->EOF;
  47640. }
  47641. if ($this->offset === \strlen($this->input)) {
  47642. $this->done = true;
  47643. }
  47644. $token = null;
  47645. $match = null;
  47646. $col = null;
  47647. $lines = null;
  47648. if (!$this->more) {
  47649. $this->yytext = '';
  47650. $this->match = '';
  47651. }
  47652. $rules = $this->getCurrentRules();
  47653. $rulesLen = \count($rules);
  47654. for ($i=0; $i < $rulesLen; $i++) {
  47655. if (preg_match($this->rules[$rules[$i]], $this->input, $match, 0, $this->offset)) {
  47656. preg_match_all('/\n.*/', $match[0], $lines);
  47657. $lines = $lines[0];
  47658. if ($lines) {
  47659. $this->yylineno += \count($lines);
  47660. }
  47661. $this->yylloc = array(
  47662. 'first_line' => $this->yylloc['last_line'],
  47663. 'last_line' => $this->yylineno+1,
  47664. 'first_column' => $this->yylloc['last_column'],
  47665. 'last_column' => $lines ? \strlen($lines[\count($lines) - 1]) - 1 : $this->yylloc['last_column'] + \strlen($match[0]),
  47666. );
  47667. $this->yytext .= $match[0];
  47668. $this->match .= $match[0];
  47669. $this->yyleng = \strlen($this->yytext);
  47670. $this->more = false;
  47671. $this->offset += \strlen($match[0]);
  47672. $token = $this->performAction($rules[$i], $this->conditionStack[\count($this->conditionStack)-1]);
  47673. if ($token) {
  47674. return $token;
  47675. }
  47676. return new Undefined();
  47677. }
  47678. }
  47679. if ($this->offset === \strlen($this->input)) {
  47680. return $this->EOF;
  47681. }
  47682. $this->parseError(
  47683. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  47684. array(
  47685. 'text' => "",
  47686. 'token' => null,
  47687. 'line' => $this->yylineno,
  47688. )
  47689. );
  47690. }
  47691. private function getCurrentRules()
  47692. {
  47693. return $this->conditions[$this->conditionStack[\count($this->conditionStack)-1]]['rules'];
  47694. }
  47695. private function performAction($avoiding_name_collisions, $YY_START)
  47696. {
  47697. switch ($avoiding_name_collisions) {
  47698. case 0:
  47699. break;
  47700. case 1:
  47701. return 6;
  47702. case 2:
  47703. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  47704. return 4;
  47705. case 3:
  47706. return 17;
  47707. case 4:
  47708. return 18;
  47709. case 5:
  47710. return 23;
  47711. case 6:
  47712. return 24;
  47713. case 7:
  47714. return 22;
  47715. case 8:
  47716. return 21;
  47717. case 9:
  47718. return 10;
  47719. case 10:
  47720. return 11;
  47721. case 11:
  47722. return 8;
  47723. case 12:
  47724. return 14;
  47725. case 13:
  47726. return 'INVALID';
  47727. }
  47728. }
  47729. }
  47730. <?php
  47731. namespace Seld\JsonLint;
  47732. class ParsingException extends \Exception
  47733. {
  47734. protected $details;
  47735. public function __construct($message, $details = array())
  47736. {
  47737. $this->details = $details;
  47738. parent::__construct($message);
  47739. }
  47740. public function getDetails()
  47741. {
  47742. return $this->details;
  47743. }
  47744. }
  47745. <?php
  47746. namespace Seld\JsonLint;
  47747. class Undefined
  47748. {
  47749. }
  47750. Copyright (c) 2015 Jordi Boggiano
  47751. Permission is hereby granted, free of charge, to any person obtaining a copy
  47752. of this software and associated documentation files (the "Software"), to deal
  47753. in the Software without restriction, including without limitation the rights
  47754. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47755. copies of the Software, and to permit persons to whom the Software is furnished
  47756. to do so, subject to the following conditions:
  47757. The above copyright notice and this permission notice shall be included in all
  47758. copies or substantial portions of the Software.
  47759. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47760. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47761. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47762. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47763. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47764. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47765. THE SOFTWARE.
  47766. <?php
  47767. namespace Seld\PharUtils;
  47768. class Linter
  47769. {
  47770. public static function lint($path)
  47771. {
  47772. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  47773. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  47774. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  47775. if (!$tmpFile || !is_writable($tmpFile)) {
  47776. throw new \RuntimeException('Unable to create temp file');
  47777. }
  47778. $php = self::escapeWindowsPath($php);
  47779. $tmpFile = self::escapeWindowsPath($tmpFile);
  47780. if (PHP_VERSION_ID >= 80000) {
  47781. $format = '%s -l %s';
  47782. } else {
  47783. $format = '"%s -l %s"';
  47784. }
  47785. $command = sprintf($format, $php, $tmpFile);
  47786. } else {
  47787. $command = "'".$php."' -l";
  47788. }
  47789. $descriptorspec = array(
  47790. 0 => array('pipe', 'r'),
  47791. 1 => array('pipe', 'w'),
  47792. 2 => array('pipe', 'w')
  47793. );
  47794. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  47795. if ($file->isDir()) {
  47796. continue;
  47797. }
  47798. if (substr($file, -4) === '.php') {
  47799. $filename = (string) $file;
  47800. if ($isWindows) {
  47801. file_put_contents($tmpFile, file_get_contents($filename));
  47802. }
  47803. $process = proc_open($command, $descriptorspec, $pipes);
  47804. if (is_resource($process)) {
  47805. if (!$isWindows) {
  47806. fwrite($pipes[0], file_get_contents($filename));
  47807. }
  47808. fclose($pipes[0]);
  47809. $stdout = stream_get_contents($pipes[1]);
  47810. fclose($pipes[1]);
  47811. $stderr = stream_get_contents($pipes[2]);
  47812. fclose($pipes[2]);
  47813. $exitCode = proc_close($process);
  47814. if ($exitCode !== 0) {
  47815. if ($isWindows) {
  47816. $stderr = str_replace($tmpFile, $filename, $stderr);
  47817. }
  47818. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  47819. }
  47820. } else {
  47821. throw new \RuntimeException('Could not start linter process');
  47822. }
  47823. }
  47824. }
  47825. if ($isWindows) {
  47826. @unlink($tmpFile);
  47827. }
  47828. }
  47829. private static function escapeWindowsPath($path)
  47830. {
  47831. if (strpbrk($path, " ()") !== false) {
  47832. $path = '"'.$path.'"';
  47833. }
  47834. return $path;
  47835. }
  47836. }
  47837. <?php
  47838. namespace Seld\PharUtils;
  47839. class Timestamps
  47840. {
  47841. private $contents;
  47842. public function __construct($file)
  47843. {
  47844. $this->contents = file_get_contents($file);
  47845. }
  47846. public function updateTimestamps($timestamp = null)
  47847. {
  47848. if ($timestamp instanceof \DateTime) {
  47849. $timestamp = $timestamp->getTimestamp();
  47850. } elseif (is_string($timestamp)) {
  47851. $timestamp = strtotime($timestamp);
  47852. } elseif (!is_int($timestamp)) {
  47853. $timestamp = strtotime('1984-12-24T00:00:00Z');
  47854. }
  47855. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47856. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47857. }
  47858. $pos = $match[0][1] + strlen($match[0][0]);
  47859. $stubEnd = $pos + $this->readUint($pos, 4);
  47860. $pos += 4;
  47861. $numFiles = $this->readUint($pos, 4);
  47862. $pos += 4;
  47863. $pos += 2;
  47864. $pos += 4;
  47865. $aliasLength = $this->readUint($pos, 4);
  47866. $pos += 4 + $aliasLength;
  47867. $metadataLength = $this->readUint($pos, 4);
  47868. $pos += 4 + $metadataLength;
  47869. while ($pos < $stubEnd) {
  47870. $filenameLength = $this->readUint($pos, 4);
  47871. $pos += 4 + $filenameLength;
  47872. $pos += 4;
  47873. $this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
  47874. $pos += 4*4;
  47875. $metadataLength = $this->readUint($pos, 4);
  47876. $pos += 4 + $metadataLength;
  47877. $numFiles--;
  47878. }
  47879. if ($numFiles !== 0) {
  47880. throw new \LogicException('All files were not processed, something must have gone wrong');
  47881. }
  47882. }
  47883. public function save($path, $signatureAlgo)
  47884. {
  47885. $pos = $this->determineSignatureBegin();
  47886. $algos = array(
  47887. \Phar::MD5 => 'md5',
  47888. \Phar::SHA1 => 'sha1',
  47889. \Phar::SHA256 => 'sha256',
  47890. \Phar::SHA512 => 'sha512',
  47891. );
  47892. if (!isset($algos[$signatureAlgo])) {
  47893. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  47894. }
  47895. $algo = $algos[$signatureAlgo];
  47896. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  47897. . pack('L', $signatureAlgo)
  47898. . 'GBMB';
  47899. $this->contents = substr($this->contents, 0, $pos) . $signature;
  47900. return file_put_contents($path, $this->contents);
  47901. }
  47902. private function readUint($pos, $bytes)
  47903. {
  47904. $res = unpack('V', substr($this->contents, $pos, $bytes));
  47905. return $res[1];
  47906. }
  47907. private function determineSignatureBegin()
  47908. {
  47909. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47910. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47911. }
  47912. $pos = $match[0][1] + strlen($match[0][0]);
  47913. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  47914. $pos += 4;
  47915. $numFiles = $this->readUint($pos, 4);
  47916. $pos += 4;
  47917. $pos += 2;
  47918. $pos += 4;
  47919. $aliasLength = $this->readUint($pos, 4);
  47920. $pos += 4 + $aliasLength;
  47921. $metadataLength = $this->readUint($pos, 4);
  47922. $pos += 4 + $metadataLength;
  47923. $compressedSizes = 0;
  47924. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  47925. $filenameLength = $this->readUint($pos, 4);
  47926. $pos += 4 + $filenameLength;
  47927. $pos += 2*4;
  47928. $compressedSizes += $this->readUint($pos, 4);
  47929. $pos += 3*4;
  47930. $metadataLength = $this->readUint($pos, 4);
  47931. $pos += 4 + $metadataLength;
  47932. $numFiles--;
  47933. }
  47934. if ($numFiles !== 0) {
  47935. throw new \LogicException('All files were not processed, something must have gone wrong');
  47936. }
  47937. return $manifestEnd + $compressedSizes;
  47938. }
  47939. }
  47940. <?php
  47941. namespace Symfony\Component\Console;
  47942. use Symfony\Component\Console\Command\Command;
  47943. use Symfony\Component\Console\Command\HelpCommand;
  47944. use Symfony\Component\Console\Command\ListCommand;
  47945. use Symfony\Component\Console\Descriptor\TextDescriptor;
  47946. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  47947. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  47948. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  47949. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  47950. use Symfony\Component\Console\Exception\CommandNotFoundException;
  47951. use Symfony\Component\Console\Exception\ExceptionInterface;
  47952. use Symfony\Component\Console\Exception\LogicException;
  47953. use Symfony\Component\Console\Formatter\OutputFormatter;
  47954. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  47955. use Symfony\Component\Console\Helper\DialogHelper;
  47956. use Symfony\Component\Console\Helper\FormatterHelper;
  47957. use Symfony\Component\Console\Helper\Helper;
  47958. use Symfony\Component\Console\Helper\HelperSet;
  47959. use Symfony\Component\Console\Helper\ProcessHelper;
  47960. use Symfony\Component\Console\Helper\ProgressHelper;
  47961. use Symfony\Component\Console\Helper\QuestionHelper;
  47962. use Symfony\Component\Console\Helper\TableHelper;
  47963. use Symfony\Component\Console\Input\ArgvInput;
  47964. use Symfony\Component\Console\Input\ArrayInput;
  47965. use Symfony\Component\Console\Input\InputArgument;
  47966. use Symfony\Component\Console\Input\InputAwareInterface;
  47967. use Symfony\Component\Console\Input\InputDefinition;
  47968. use Symfony\Component\Console\Input\InputInterface;
  47969. use Symfony\Component\Console\Input\InputOption;
  47970. use Symfony\Component\Console\Output\BufferedOutput;
  47971. use Symfony\Component\Console\Output\ConsoleOutput;
  47972. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  47973. use Symfony\Component\Console\Output\OutputInterface;
  47974. use Symfony\Component\Debug\Exception\FatalThrowableError;
  47975. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  47976. class Application
  47977. {
  47978. private $commands = array();
  47979. private $wantHelps = false;
  47980. private $runningCommand;
  47981. private $name;
  47982. private $version;
  47983. private $catchExceptions = true;
  47984. private $autoExit = true;
  47985. private $definition;
  47986. private $helperSet;
  47987. private $dispatcher;
  47988. private $terminalDimensions;
  47989. private $defaultCommand;
  47990. private $initialized;
  47991. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  47992. {
  47993. $this->name = $name;
  47994. $this->version = $version;
  47995. $this->defaultCommand = 'list';
  47996. }
  47997. public function setDispatcher(EventDispatcherInterface $dispatcher)
  47998. {
  47999. $this->dispatcher = $dispatcher;
  48000. }
  48001. public function run(InputInterface $input = null, OutputInterface $output = null)
  48002. {
  48003. if (null === $input) {
  48004. $input = new ArgvInput();
  48005. }
  48006. if (null === $output) {
  48007. $output = new ConsoleOutput();
  48008. }
  48009. $this->configureIO($input, $output);
  48010. try {
  48011. $e = null;
  48012. $exitCode = $this->doRun($input, $output);
  48013. } catch (\Exception $e) {
  48014. }
  48015. if (null !== $e) {
  48016. if (!$this->catchExceptions) {
  48017. throw $e;
  48018. }
  48019. if ($output instanceof ConsoleOutputInterface) {
  48020. $this->renderException($e, $output->getErrorOutput());
  48021. } else {
  48022. $this->renderException($e, $output);
  48023. }
  48024. $exitCode = $this->getExitCodeForThrowable($e);
  48025. }
  48026. if ($this->autoExit) {
  48027. if ($exitCode > 255) {
  48028. $exitCode = 255;
  48029. }
  48030. exit($exitCode);
  48031. }
  48032. return $exitCode;
  48033. }
  48034. public function doRun(InputInterface $input, OutputInterface $output)
  48035. {
  48036. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  48037. $output->writeln($this->getLongVersion());
  48038. return 0;
  48039. }
  48040. $name = $this->getCommandName($input);
  48041. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  48042. if (!$name) {
  48043. $name = 'help';
  48044. $input = new ArrayInput(array('command' => 'help'));
  48045. } else {
  48046. $this->wantHelps = true;
  48047. }
  48048. }
  48049. if (!$name) {
  48050. $name = $this->defaultCommand;
  48051. $definition = $this->getDefinition();
  48052. $definition->setArguments(array_merge(
  48053. $definition->getArguments(),
  48054. array(
  48055. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  48056. )
  48057. ));
  48058. }
  48059. $this->runningCommand = null;
  48060. $command = $this->find($name);
  48061. $this->runningCommand = $command;
  48062. $exitCode = $this->doRunCommand($command, $input, $output);
  48063. $this->runningCommand = null;
  48064. return $exitCode;
  48065. }
  48066. public function setHelperSet(HelperSet $helperSet)
  48067. {
  48068. $this->helperSet = $helperSet;
  48069. }
  48070. public function getHelperSet()
  48071. {
  48072. if (!$this->helperSet) {
  48073. $this->helperSet = $this->getDefaultHelperSet();
  48074. }
  48075. return $this->helperSet;
  48076. }
  48077. public function setDefinition(InputDefinition $definition)
  48078. {
  48079. $this->definition = $definition;
  48080. }
  48081. public function getDefinition()
  48082. {
  48083. if (!$this->definition) {
  48084. $this->definition = $this->getDefaultInputDefinition();
  48085. }
  48086. return $this->definition;
  48087. }
  48088. public function getHelp()
  48089. {
  48090. return $this->getLongVersion();
  48091. }
  48092. public function setCatchExceptions($boolean)
  48093. {
  48094. $this->catchExceptions = (bool) $boolean;
  48095. }
  48096. public function setAutoExit($boolean)
  48097. {
  48098. $this->autoExit = (bool) $boolean;
  48099. }
  48100. public function getName()
  48101. {
  48102. return $this->name;
  48103. }
  48104. public function setName($name)
  48105. {
  48106. $this->name = $name;
  48107. }
  48108. public function getVersion()
  48109. {
  48110. return $this->version;
  48111. }
  48112. public function setVersion($version)
  48113. {
  48114. $this->version = $version;
  48115. }
  48116. public function getLongVersion()
  48117. {
  48118. if ('UNKNOWN' !== $this->getName()) {
  48119. if ('UNKNOWN' !== $this->getVersion()) {
  48120. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  48121. }
  48122. return sprintf('<info>%s</info>', $this->getName());
  48123. }
  48124. return '<info>Console Tool</info>';
  48125. }
  48126. public function register($name)
  48127. {
  48128. return $this->add(new Command($name));
  48129. }
  48130. public function addCommands(array $commands)
  48131. {
  48132. foreach ($commands as $command) {
  48133. $this->add($command);
  48134. }
  48135. }
  48136. public function add(Command $command)
  48137. {
  48138. $this->init();
  48139. $command->setApplication($this);
  48140. if (!$command->isEnabled()) {
  48141. $command->setApplication(null);
  48142. return;
  48143. }
  48144. if (null === $command->getDefinition()) {
  48145. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  48146. }
  48147. $this->commands[$command->getName()] = $command;
  48148. foreach ($command->getAliases() as $alias) {
  48149. $this->commands[$alias] = $command;
  48150. }
  48151. return $command;
  48152. }
  48153. public function get($name)
  48154. {
  48155. $this->init();
  48156. if (!isset($this->commands[$name])) {
  48157. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  48158. }
  48159. $command = $this->commands[$name];
  48160. if ($this->wantHelps) {
  48161. $this->wantHelps = false;
  48162. $helpCommand = $this->get('help');
  48163. $helpCommand->setCommand($command);
  48164. return $helpCommand;
  48165. }
  48166. return $command;
  48167. }
  48168. public function has($name)
  48169. {
  48170. $this->init();
  48171. return isset($this->commands[$name]);
  48172. }
  48173. public function getNamespaces()
  48174. {
  48175. $namespaces = array();
  48176. foreach ($this->all() as $command) {
  48177. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  48178. foreach ($command->getAliases() as $alias) {
  48179. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  48180. }
  48181. }
  48182. return array_values(array_unique(array_filter($namespaces)));
  48183. }
  48184. public function findNamespace($namespace)
  48185. {
  48186. $allNamespaces = $this->getNamespaces();
  48187. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  48188. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  48189. if (empty($namespaces)) {
  48190. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  48191. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  48192. if (1 == \count($alternatives)) {
  48193. $message .= "\n\nDid you mean this?\n ";
  48194. } else {
  48195. $message .= "\n\nDid you mean one of these?\n ";
  48196. }
  48197. $message .= implode("\n ", $alternatives);
  48198. }
  48199. throw new CommandNotFoundException($message, $alternatives);
  48200. }
  48201. $exact = \in_array($namespace, $namespaces, true);
  48202. if (\count($namespaces) > 1 && !$exact) {
  48203. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  48204. }
  48205. return $exact ? $namespace : reset($namespaces);
  48206. }
  48207. public function find($name)
  48208. {
  48209. $this->init();
  48210. $aliases = array();
  48211. $allCommands = array_keys($this->commands);
  48212. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  48213. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  48214. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  48215. if (false !== $pos = strrpos($name, ':')) {
  48216. $this->findNamespace(substr($name, 0, $pos));
  48217. }
  48218. $message = sprintf('Command "%s" is not defined.', $name);
  48219. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  48220. if (1 == \count($alternatives)) {
  48221. $message .= "\n\nDid you mean this?\n ";
  48222. } else {
  48223. $message .= "\n\nDid you mean one of these?\n ";
  48224. }
  48225. $message .= implode("\n ", $alternatives);
  48226. }
  48227. throw new CommandNotFoundException($message, $alternatives);
  48228. }
  48229. if (\count($commands) > 1) {
  48230. $commandList = $this->commands;
  48231. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  48232. $commandName = $commandList[$nameOrAlias]->getName();
  48233. $aliases[$nameOrAlias] = $commandName;
  48234. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  48235. });
  48236. }
  48237. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  48238. if (!$exact && \count($commands) > 1) {
  48239. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  48240. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  48241. }
  48242. return $this->get($exact ? $name : reset($commands));
  48243. }
  48244. public function all($namespace = null)
  48245. {
  48246. $this->init();
  48247. if (null === $namespace) {
  48248. return $this->commands;
  48249. }
  48250. $commands = array();
  48251. foreach ($this->commands as $name => $command) {
  48252. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  48253. $commands[$name] = $command;
  48254. }
  48255. }
  48256. return $commands;
  48257. }
  48258. public static function getAbbreviations($names)
  48259. {
  48260. $abbrevs = array();
  48261. foreach ($names as $name) {
  48262. for ($len = \strlen($name); $len > 0; --$len) {
  48263. $abbrev = substr($name, 0, $len);
  48264. $abbrevs[$abbrev][] = $name;
  48265. }
  48266. }
  48267. return $abbrevs;
  48268. }
  48269. public function asText($namespace = null, $raw = false)
  48270. {
  48271. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48272. $descriptor = new TextDescriptor();
  48273. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  48274. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  48275. return $output->fetch();
  48276. }
  48277. public function asXml($namespace = null, $asDom = false)
  48278. {
  48279. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48280. $descriptor = new XmlDescriptor();
  48281. if ($asDom) {
  48282. return $descriptor->getApplicationDocument($this, $namespace);
  48283. }
  48284. $output = new BufferedOutput();
  48285. $descriptor->describe($output, $this, array('namespace' => $namespace));
  48286. return $output->fetch();
  48287. }
  48288. public function renderException($e, $output)
  48289. {
  48290. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48291. do {
  48292. $title = sprintf(' [%s] ', \get_class($e));
  48293. $len = Helper::strlen($title);
  48294. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  48295. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  48296. $width = 1 << 31;
  48297. }
  48298. $lines = array();
  48299. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  48300. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  48301. $lineLength = Helper::strlen($line) + 4;
  48302. $lines[] = array($line, $lineLength);
  48303. $len = max($lineLength, $len);
  48304. }
  48305. }
  48306. $messages = array();
  48307. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  48308. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  48309. foreach ($lines as $line) {
  48310. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  48311. }
  48312. $messages[] = $emptyLine;
  48313. $messages[] = '';
  48314. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  48315. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  48316. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  48317. $trace = $e->getTrace();
  48318. array_unshift($trace, array(
  48319. 'function' => '',
  48320. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  48321. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  48322. 'args' => array(),
  48323. ));
  48324. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  48325. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  48326. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  48327. $function = $trace[$i]['function'];
  48328. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  48329. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  48330. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  48331. }
  48332. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48333. }
  48334. } while ($e = $e->getPrevious());
  48335. if (null !== $this->runningCommand) {
  48336. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  48337. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48338. }
  48339. }
  48340. protected function getTerminalWidth()
  48341. {
  48342. $dimensions = $this->getTerminalDimensions();
  48343. return $dimensions[0];
  48344. }
  48345. protected function getTerminalHeight()
  48346. {
  48347. $dimensions = $this->getTerminalDimensions();
  48348. return $dimensions[1];
  48349. }
  48350. public function getTerminalDimensions()
  48351. {
  48352. if ($this->terminalDimensions) {
  48353. return $this->terminalDimensions;
  48354. }
  48355. if ('\\' === \DIRECTORY_SEPARATOR) {
  48356. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  48357. return array((int) $matches[1], (int) $matches[2]);
  48358. }
  48359. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  48360. return array((int) $matches[1], (int) $matches[2]);
  48361. }
  48362. }
  48363. if ($sttyString = $this->getSttyColumns()) {
  48364. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  48365. return array((int) $matches[2], (int) $matches[1]);
  48366. }
  48367. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  48368. return array((int) $matches[2], (int) $matches[1]);
  48369. }
  48370. }
  48371. return array(null, null);
  48372. }
  48373. public function setTerminalDimensions($width, $height)
  48374. {
  48375. $this->terminalDimensions = array($width, $height);
  48376. return $this;
  48377. }
  48378. protected function configureIO(InputInterface $input, OutputInterface $output)
  48379. {
  48380. if (true === $input->hasParameterOption(array('--ansi'))) {
  48381. $output->setDecorated(true);
  48382. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  48383. $output->setDecorated(false);
  48384. }
  48385. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  48386. $input->setInteractive(false);
  48387. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  48388. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  48389. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  48390. $input->setInteractive(false);
  48391. }
  48392. }
  48393. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  48394. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  48395. $input->setInteractive(false);
  48396. } else {
  48397. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  48398. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  48399. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  48400. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  48401. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  48402. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  48403. }
  48404. }
  48405. }
  48406. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  48407. {
  48408. foreach ($command->getHelperSet() as $helper) {
  48409. if ($helper instanceof InputAwareInterface) {
  48410. $helper->setInput($input);
  48411. }
  48412. }
  48413. if (null === $this->dispatcher) {
  48414. return $command->run($input, $output);
  48415. }
  48416. try {
  48417. $command->mergeApplicationDefinition();
  48418. $input->bind($command->getDefinition());
  48419. } catch (ExceptionInterface $e) {
  48420. }
  48421. $event = new ConsoleCommandEvent($command, $input, $output);
  48422. $e = null;
  48423. try {
  48424. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  48425. if ($event->commandShouldRun()) {
  48426. $exitCode = $command->run($input, $output);
  48427. } else {
  48428. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  48429. }
  48430. } catch (\Exception $e) {
  48431. } catch (\Throwable $e) {
  48432. }
  48433. if (null !== $e) {
  48434. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  48435. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  48436. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  48437. if ($x !== $event->getException()) {
  48438. $e = $event->getException();
  48439. }
  48440. $exitCode = $this->getExitCodeForThrowable($e);
  48441. }
  48442. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  48443. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  48444. if (null !== $e) {
  48445. throw $e;
  48446. }
  48447. return $event->getExitCode();
  48448. }
  48449. protected function getCommandName(InputInterface $input)
  48450. {
  48451. return $input->getFirstArgument();
  48452. }
  48453. protected function getDefaultInputDefinition()
  48454. {
  48455. return new InputDefinition(array(
  48456. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  48457. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  48458. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  48459. new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
  48460. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  48461. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  48462. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  48463. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  48464. ));
  48465. }
  48466. protected function getDefaultCommands()
  48467. {
  48468. return array(new HelpCommand(), new ListCommand());
  48469. }
  48470. protected function getDefaultHelperSet()
  48471. {
  48472. return new HelperSet(array(
  48473. new FormatterHelper(),
  48474. new DialogHelper(false),
  48475. new ProgressHelper(false),
  48476. new TableHelper(false),
  48477. new DebugFormatterHelper(),
  48478. new ProcessHelper(),
  48479. new QuestionHelper(),
  48480. ));
  48481. }
  48482. private function getSttyColumns()
  48483. {
  48484. if (!\function_exists('proc_open')) {
  48485. return;
  48486. }
  48487. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  48488. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  48489. if (\is_resource($process)) {
  48490. $info = stream_get_contents($pipes[1]);
  48491. fclose($pipes[1]);
  48492. fclose($pipes[2]);
  48493. proc_close($process);
  48494. return $info;
  48495. }
  48496. }
  48497. private function getConsoleMode()
  48498. {
  48499. if (!\function_exists('proc_open')) {
  48500. return;
  48501. }
  48502. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  48503. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  48504. if (\is_resource($process)) {
  48505. $info = stream_get_contents($pipes[1]);
  48506. fclose($pipes[1]);
  48507. fclose($pipes[2]);
  48508. proc_close($process);
  48509. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  48510. return $matches[2].'x'.$matches[1];
  48511. }
  48512. }
  48513. }
  48514. private function getAbbreviationSuggestions($abbrevs)
  48515. {
  48516. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  48517. }
  48518. public function extractNamespace($name, $limit = null)
  48519. {
  48520. $parts = explode(':', $name);
  48521. array_pop($parts);
  48522. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  48523. }
  48524. private function findAlternatives($name, $collection)
  48525. {
  48526. $threshold = 1e3;
  48527. $alternatives = array();
  48528. $collectionParts = array();
  48529. foreach ($collection as $item) {
  48530. $collectionParts[$item] = explode(':', $item);
  48531. }
  48532. foreach (explode(':', $name) as $i => $subname) {
  48533. foreach ($collectionParts as $collectionName => $parts) {
  48534. $exists = isset($alternatives[$collectionName]);
  48535. if (!isset($parts[$i]) && $exists) {
  48536. $alternatives[$collectionName] += $threshold;
  48537. continue;
  48538. } elseif (!isset($parts[$i])) {
  48539. continue;
  48540. }
  48541. $lev = levenshtein($subname, $parts[$i]);
  48542. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  48543. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  48544. } elseif ($exists) {
  48545. $alternatives[$collectionName] += $threshold;
  48546. }
  48547. }
  48548. }
  48549. foreach ($collection as $item) {
  48550. $lev = levenshtein($name, $item);
  48551. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  48552. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  48553. }
  48554. }
  48555. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  48556. asort($alternatives);
  48557. return array_keys($alternatives);
  48558. }
  48559. public function setDefaultCommand($commandName)
  48560. {
  48561. $this->defaultCommand = $commandName;
  48562. }
  48563. private function splitStringByWidth($string, $width)
  48564. {
  48565. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  48566. return str_split($string, $width);
  48567. }
  48568. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  48569. $lines = array();
  48570. $line = '';
  48571. foreach (preg_split('//u', $utf8String) as $char) {
  48572. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  48573. $line .= $char;
  48574. continue;
  48575. }
  48576. $lines[] = str_pad($line, $width);
  48577. $line = $char;
  48578. }
  48579. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  48580. mb_convert_variables($encoding, 'utf8', $lines);
  48581. return $lines;
  48582. }
  48583. private function extractAllNamespaces($name)
  48584. {
  48585. $parts = explode(':', $name, -1);
  48586. $namespaces = array();
  48587. foreach ($parts as $part) {
  48588. if (\count($namespaces)) {
  48589. $namespaces[] = end($namespaces).':'.$part;
  48590. } else {
  48591. $namespaces[] = $part;
  48592. }
  48593. }
  48594. return $namespaces;
  48595. }
  48596. private function init()
  48597. {
  48598. if ($this->initialized) {
  48599. return;
  48600. }
  48601. $this->initialized = true;
  48602. foreach ($this->getDefaultCommands() as $command) {
  48603. $this->add($command);
  48604. }
  48605. }
  48606. private function getExitCodeForThrowable($throwable)
  48607. {
  48608. $exitCode = $throwable->getCode();
  48609. if (is_numeric($exitCode)) {
  48610. $exitCode = (int) $exitCode;
  48611. if (0 === $exitCode) {
  48612. $exitCode = 1;
  48613. }
  48614. } else {
  48615. $exitCode = 1;
  48616. }
  48617. return $exitCode;
  48618. }
  48619. }
  48620. <?php
  48621. namespace Symfony\Component\Console\Command;
  48622. use Symfony\Component\Console\Application;
  48623. use Symfony\Component\Console\Descriptor\TextDescriptor;
  48624. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  48625. use Symfony\Component\Console\Exception\ExceptionInterface;
  48626. use Symfony\Component\Console\Exception\InvalidArgumentException;
  48627. use Symfony\Component\Console\Exception\LogicException;
  48628. use Symfony\Component\Console\Helper\HelperSet;
  48629. use Symfony\Component\Console\Input\InputArgument;
  48630. use Symfony\Component\Console\Input\InputDefinition;
  48631. use Symfony\Component\Console\Input\InputInterface;
  48632. use Symfony\Component\Console\Input\InputOption;
  48633. use Symfony\Component\Console\Output\BufferedOutput;
  48634. use Symfony\Component\Console\Output\OutputInterface;
  48635. class Command
  48636. {
  48637. private $application;
  48638. private $name;
  48639. private $processTitle;
  48640. private $aliases = array();
  48641. private $definition;
  48642. private $help;
  48643. private $description;
  48644. private $ignoreValidationErrors = false;
  48645. private $applicationDefinitionMerged = false;
  48646. private $applicationDefinitionMergedWithArgs = false;
  48647. private $code;
  48648. private $synopsis = array();
  48649. private $usages = array();
  48650. private $helperSet;
  48651. public function __construct($name = null)
  48652. {
  48653. $this->definition = new InputDefinition();
  48654. if (null !== $name) {
  48655. $this->setName($name);
  48656. }
  48657. $this->configure();
  48658. if (!$this->name) {
  48659. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  48660. }
  48661. }
  48662. public function ignoreValidationErrors()
  48663. {
  48664. $this->ignoreValidationErrors = true;
  48665. }
  48666. public function setApplication(Application $application = null)
  48667. {
  48668. $this->application = $application;
  48669. if ($application) {
  48670. $this->setHelperSet($application->getHelperSet());
  48671. } else {
  48672. $this->helperSet = null;
  48673. }
  48674. }
  48675. public function setHelperSet(HelperSet $helperSet)
  48676. {
  48677. $this->helperSet = $helperSet;
  48678. }
  48679. public function getHelperSet()
  48680. {
  48681. return $this->helperSet;
  48682. }
  48683. public function getApplication()
  48684. {
  48685. return $this->application;
  48686. }
  48687. public function isEnabled()
  48688. {
  48689. return true;
  48690. }
  48691. protected function configure()
  48692. {
  48693. }
  48694. protected function execute(InputInterface $input, OutputInterface $output)
  48695. {
  48696. throw new LogicException('You must override the execute() method in the concrete command class.');
  48697. }
  48698. protected function interact(InputInterface $input, OutputInterface $output)
  48699. {
  48700. }
  48701. protected function initialize(InputInterface $input, OutputInterface $output)
  48702. {
  48703. }
  48704. public function run(InputInterface $input, OutputInterface $output)
  48705. {
  48706. $this->getSynopsis(true);
  48707. $this->getSynopsis(false);
  48708. $this->mergeApplicationDefinition();
  48709. try {
  48710. $input->bind($this->definition);
  48711. } catch (ExceptionInterface $e) {
  48712. if (!$this->ignoreValidationErrors) {
  48713. throw $e;
  48714. }
  48715. }
  48716. $this->initialize($input, $output);
  48717. if (null !== $this->processTitle) {
  48718. if (\function_exists('cli_set_process_title')) {
  48719. if (!@cli_set_process_title($this->processTitle)) {
  48720. if ('Darwin' === PHP_OS) {
  48721. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  48722. } else {
  48723. cli_set_process_title($this->processTitle);
  48724. }
  48725. }
  48726. } elseif (\function_exists('setproctitle')) {
  48727. setproctitle($this->processTitle);
  48728. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  48729. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  48730. }
  48731. }
  48732. if ($input->isInteractive()) {
  48733. $this->interact($input, $output);
  48734. }
  48735. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  48736. $input->setArgument('command', $this->getName());
  48737. }
  48738. $input->validate();
  48739. if ($this->code) {
  48740. $statusCode = \call_user_func($this->code, $input, $output);
  48741. } else {
  48742. $statusCode = $this->execute($input, $output);
  48743. }
  48744. return is_numeric($statusCode) ? (int) $statusCode : 0;
  48745. }
  48746. public function setCode($code)
  48747. {
  48748. if (!\is_callable($code)) {
  48749. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  48750. }
  48751. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  48752. $r = new \ReflectionFunction($code);
  48753. if (null === $r->getClosureThis()) {
  48754. if (\PHP_VERSION_ID < 70000) {
  48755. $code = @\Closure::bind($code, $this);
  48756. } else {
  48757. $code = \Closure::bind($code, $this);
  48758. }
  48759. }
  48760. }
  48761. $this->code = $code;
  48762. return $this;
  48763. }
  48764. public function mergeApplicationDefinition($mergeArgs = true)
  48765. {
  48766. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  48767. return;
  48768. }
  48769. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  48770. $this->applicationDefinitionMerged = true;
  48771. if ($mergeArgs) {
  48772. $currentArguments = $this->definition->getArguments();
  48773. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  48774. $this->definition->addArguments($currentArguments);
  48775. $this->applicationDefinitionMergedWithArgs = true;
  48776. }
  48777. }
  48778. public function setDefinition($definition)
  48779. {
  48780. if ($definition instanceof InputDefinition) {
  48781. $this->definition = $definition;
  48782. } else {
  48783. $this->definition->setDefinition($definition);
  48784. }
  48785. $this->applicationDefinitionMerged = false;
  48786. return $this;
  48787. }
  48788. public function getDefinition()
  48789. {
  48790. return $this->definition;
  48791. }
  48792. public function getNativeDefinition()
  48793. {
  48794. return $this->getDefinition();
  48795. }
  48796. public function addArgument($name, $mode = null, $description = '', $default = null)
  48797. {
  48798. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  48799. return $this;
  48800. }
  48801. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  48802. {
  48803. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  48804. return $this;
  48805. }
  48806. public function setName($name)
  48807. {
  48808. $this->validateName($name);
  48809. $this->name = $name;
  48810. return $this;
  48811. }
  48812. public function setProcessTitle($title)
  48813. {
  48814. $this->processTitle = $title;
  48815. return $this;
  48816. }
  48817. public function getName()
  48818. {
  48819. return $this->name;
  48820. }
  48821. public function setDescription($description)
  48822. {
  48823. $this->description = $description;
  48824. return $this;
  48825. }
  48826. public function getDescription()
  48827. {
  48828. return $this->description;
  48829. }
  48830. public function setHelp($help)
  48831. {
  48832. $this->help = $help;
  48833. return $this;
  48834. }
  48835. public function getHelp()
  48836. {
  48837. return $this->help;
  48838. }
  48839. public function getProcessedHelp()
  48840. {
  48841. $name = $this->name;
  48842. $placeholders = array(
  48843. '%command.name%',
  48844. '%command.full_name%',
  48845. );
  48846. $replacements = array(
  48847. $name,
  48848. $_SERVER['PHP_SELF'].' '.$name,
  48849. );
  48850. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  48851. }
  48852. public function setAliases($aliases)
  48853. {
  48854. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  48855. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  48856. }
  48857. foreach ($aliases as $alias) {
  48858. $this->validateName($alias);
  48859. }
  48860. $this->aliases = $aliases;
  48861. return $this;
  48862. }
  48863. public function getAliases()
  48864. {
  48865. return $this->aliases;
  48866. }
  48867. public function getSynopsis($short = false)
  48868. {
  48869. $key = $short ? 'short' : 'long';
  48870. if (!isset($this->synopsis[$key])) {
  48871. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  48872. }
  48873. return $this->synopsis[$key];
  48874. }
  48875. public function addUsage($usage)
  48876. {
  48877. if (0 !== strpos($usage, $this->name)) {
  48878. $usage = sprintf('%s %s', $this->name, $usage);
  48879. }
  48880. $this->usages[] = $usage;
  48881. return $this;
  48882. }
  48883. public function getUsages()
  48884. {
  48885. return $this->usages;
  48886. }
  48887. public function getHelper($name)
  48888. {
  48889. if (null === $this->helperSet) {
  48890. throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
  48891. }
  48892. return $this->helperSet->get($name);
  48893. }
  48894. public function asText()
  48895. {
  48896. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48897. $descriptor = new TextDescriptor();
  48898. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  48899. $descriptor->describe($output, $this, array('raw_output' => true));
  48900. return $output->fetch();
  48901. }
  48902. public function asXml($asDom = false)
  48903. {
  48904. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48905. $descriptor = new XmlDescriptor();
  48906. if ($asDom) {
  48907. return $descriptor->getCommandDocument($this);
  48908. }
  48909. $output = new BufferedOutput();
  48910. $descriptor->describe($output, $this);
  48911. return $output->fetch();
  48912. }
  48913. private function validateName($name)
  48914. {
  48915. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  48916. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  48917. }
  48918. }
  48919. }
  48920. <?php
  48921. namespace Symfony\Component\Console\Command;
  48922. use Symfony\Component\Console\Helper\DescriptorHelper;
  48923. use Symfony\Component\Console\Input\InputArgument;
  48924. use Symfony\Component\Console\Input\InputInterface;
  48925. use Symfony\Component\Console\Input\InputOption;
  48926. use Symfony\Component\Console\Output\OutputInterface;
  48927. class HelpCommand extends Command
  48928. {
  48929. private $command;
  48930. protected function configure()
  48931. {
  48932. $this->ignoreValidationErrors();
  48933. $this
  48934. ->setName('help')
  48935. ->setDefinition(array(
  48936. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  48937. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  48938. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  48939. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  48940. ))
  48941. ->setDescription('Displays help for a command')
  48942. ->setHelp(<<<'EOF'
  48943. The <info>%command.name%</info> command displays help for a given command:
  48944. <info>php %command.full_name% list</info>
  48945. You can also output the help in other formats by using the <comment>--format</comment> option:
  48946. <info>php %command.full_name% --format=xml list</info>
  48947. To display the list of available commands, please use the <info>list</info> command.
  48948. EOF
  48949. )
  48950. ;
  48951. }
  48952. public function setCommand(Command $command)
  48953. {
  48954. $this->command = $command;
  48955. }
  48956. protected function execute(InputInterface $input, OutputInterface $output)
  48957. {
  48958. if (null === $this->command) {
  48959. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  48960. }
  48961. if ($input->getOption('xml')) {
  48962. @trigger_error('The --xml option was deprecated in version 2.7 and will be removed in version 3.0. Use the --format option instead.', E_USER_DEPRECATED);
  48963. $input->setOption('format', 'xml');
  48964. }
  48965. $helper = new DescriptorHelper();
  48966. $helper->describe($output, $this->command, array(
  48967. 'format' => $input->getOption('format'),
  48968. 'raw_text' => $input->getOption('raw'),
  48969. ));
  48970. $this->command = null;
  48971. }
  48972. }
  48973. <?php
  48974. namespace Symfony\Component\Console\Command;
  48975. use Symfony\Component\Console\Helper\DescriptorHelper;
  48976. use Symfony\Component\Console\Input\InputArgument;
  48977. use Symfony\Component\Console\Input\InputDefinition;
  48978. use Symfony\Component\Console\Input\InputInterface;
  48979. use Symfony\Component\Console\Input\InputOption;
  48980. use Symfony\Component\Console\Output\OutputInterface;
  48981. class ListCommand extends Command
  48982. {
  48983. protected function configure()
  48984. {
  48985. $this
  48986. ->setName('list')
  48987. ->setDefinition($this->createDefinition())
  48988. ->setDescription('Lists commands')
  48989. ->setHelp(<<<'EOF'
  48990. The <info>%command.name%</info> command lists all commands:
  48991. <info>php %command.full_name%</info>
  48992. You can also display the commands for a specific namespace:
  48993. <info>php %command.full_name% test</info>
  48994. You can also output the information in other formats by using the <comment>--format</comment> option:
  48995. <info>php %command.full_name% --format=xml</info>
  48996. It's also possible to get raw list of commands (useful for embedding command runner):
  48997. <info>php %command.full_name% --raw</info>
  48998. EOF
  48999. )
  49000. ;
  49001. }
  49002. public function getNativeDefinition()
  49003. {
  49004. return $this->createDefinition();
  49005. }
  49006. protected function execute(InputInterface $input, OutputInterface $output)
  49007. {
  49008. if ($input->getOption('xml')) {
  49009. @trigger_error('The --xml option was deprecated in version 2.7 and will be removed in version 3.0. Use the --format option instead.', E_USER_DEPRECATED);
  49010. $input->setOption('format', 'xml');
  49011. }
  49012. $helper = new DescriptorHelper();
  49013. $helper->describe($output, $this->getApplication(), array(
  49014. 'format' => $input->getOption('format'),
  49015. 'raw_text' => $input->getOption('raw'),
  49016. 'namespace' => $input->getArgument('namespace'),
  49017. ));
  49018. }
  49019. private function createDefinition()
  49020. {
  49021. return new InputDefinition(array(
  49022. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  49023. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  49024. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  49025. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  49026. ));
  49027. }
  49028. }
  49029. <?php
  49030. namespace Symfony\Component\Console;
  49031. final class ConsoleEvents
  49032. {
  49033. const COMMAND = 'console.command';
  49034. const TERMINATE = 'console.terminate';
  49035. const EXCEPTION = 'console.exception';
  49036. }
  49037. <?php
  49038. namespace Symfony\Component\Console\Descriptor;
  49039. use Symfony\Component\Console\Application;
  49040. use Symfony\Component\Console\Command\Command;
  49041. use Symfony\Component\Console\Exception\CommandNotFoundException;
  49042. class ApplicationDescription
  49043. {
  49044. const GLOBAL_NAMESPACE = '_global';
  49045. private $application;
  49046. private $namespace;
  49047. private $namespaces;
  49048. private $commands;
  49049. private $aliases;
  49050. public function __construct(Application $application, $namespace = null)
  49051. {
  49052. $this->application = $application;
  49053. $this->namespace = $namespace;
  49054. }
  49055. public function getNamespaces()
  49056. {
  49057. if (null === $this->namespaces) {
  49058. $this->inspectApplication();
  49059. }
  49060. return $this->namespaces;
  49061. }
  49062. public function getCommands()
  49063. {
  49064. if (null === $this->commands) {
  49065. $this->inspectApplication();
  49066. }
  49067. return $this->commands;
  49068. }
  49069. public function getCommand($name)
  49070. {
  49071. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  49072. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  49073. }
  49074. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  49075. }
  49076. private function inspectApplication()
  49077. {
  49078. $this->commands = array();
  49079. $this->namespaces = array();
  49080. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  49081. foreach ($this->sortCommands($all) as $namespace => $commands) {
  49082. $names = array();
  49083. foreach ($commands as $name => $command) {
  49084. if (!$command->getName()) {
  49085. continue;
  49086. }
  49087. if ($command->getName() === $name) {
  49088. $this->commands[$name] = $command;
  49089. } else {
  49090. $this->aliases[$name] = $command;
  49091. }
  49092. $names[] = $name;
  49093. }
  49094. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  49095. }
  49096. }
  49097. private function sortCommands(array $commands)
  49098. {
  49099. $namespacedCommands = array();
  49100. $globalCommands = array();
  49101. foreach ($commands as $name => $command) {
  49102. $key = $this->application->extractNamespace($name, 1);
  49103. if (!$key) {
  49104. $globalCommands['_global'][$name] = $command;
  49105. } else {
  49106. $namespacedCommands[$key][$name] = $command;
  49107. }
  49108. }
  49109. ksort($namespacedCommands);
  49110. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  49111. foreach ($namespacedCommands as &$commandsSet) {
  49112. ksort($commandsSet);
  49113. }
  49114. unset($commandsSet);
  49115. return $namespacedCommands;
  49116. }
  49117. }
  49118. <?php
  49119. namespace Symfony\Component\Console\Descriptor;
  49120. use Symfony\Component\Console\Application;
  49121. use Symfony\Component\Console\Command\Command;
  49122. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49123. use Symfony\Component\Console\Input\InputArgument;
  49124. use Symfony\Component\Console\Input\InputDefinition;
  49125. use Symfony\Component\Console\Input\InputOption;
  49126. use Symfony\Component\Console\Output\OutputInterface;
  49127. abstract class Descriptor implements DescriptorInterface
  49128. {
  49129. private $output;
  49130. public function describe(OutputInterface $output, $object, array $options = array())
  49131. {
  49132. $this->output = $output;
  49133. switch (true) {
  49134. case $object instanceof InputArgument:
  49135. $this->describeInputArgument($object, $options);
  49136. break;
  49137. case $object instanceof InputOption:
  49138. $this->describeInputOption($object, $options);
  49139. break;
  49140. case $object instanceof InputDefinition:
  49141. $this->describeInputDefinition($object, $options);
  49142. break;
  49143. case $object instanceof Command:
  49144. $this->describeCommand($object, $options);
  49145. break;
  49146. case $object instanceof Application:
  49147. $this->describeApplication($object, $options);
  49148. break;
  49149. default:
  49150. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  49151. }
  49152. }
  49153. protected function write($content, $decorated = false)
  49154. {
  49155. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  49156. }
  49157. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  49158. abstract protected function describeInputOption(InputOption $option, array $options = array());
  49159. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  49160. abstract protected function describeCommand(Command $command, array $options = array());
  49161. abstract protected function describeApplication(Application $application, array $options = array());
  49162. }
  49163. <?php
  49164. namespace Symfony\Component\Console\Descriptor;
  49165. use Symfony\Component\Console\Output\OutputInterface;
  49166. interface DescriptorInterface
  49167. {
  49168. public function describe(OutputInterface $output, $object, array $options = array());
  49169. }
  49170. <?php
  49171. namespace Symfony\Component\Console\Descriptor;
  49172. use Symfony\Component\Console\Application;
  49173. use Symfony\Component\Console\Command\Command;
  49174. use Symfony\Component\Console\Input\InputArgument;
  49175. use Symfony\Component\Console\Input\InputDefinition;
  49176. use Symfony\Component\Console\Input\InputOption;
  49177. class JsonDescriptor extends Descriptor
  49178. {
  49179. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49180. {
  49181. $this->writeData($this->getInputArgumentData($argument), $options);
  49182. }
  49183. protected function describeInputOption(InputOption $option, array $options = array())
  49184. {
  49185. $this->writeData($this->getInputOptionData($option), $options);
  49186. }
  49187. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49188. {
  49189. $this->writeData($this->getInputDefinitionData($definition), $options);
  49190. }
  49191. protected function describeCommand(Command $command, array $options = array())
  49192. {
  49193. $this->writeData($this->getCommandData($command), $options);
  49194. }
  49195. protected function describeApplication(Application $application, array $options = array())
  49196. {
  49197. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49198. $description = new ApplicationDescription($application, $describedNamespace);
  49199. $commands = array();
  49200. foreach ($description->getCommands() as $command) {
  49201. $commands[] = $this->getCommandData($command);
  49202. }
  49203. $data = $describedNamespace
  49204. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  49205. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  49206. $this->writeData($data, $options);
  49207. }
  49208. private function writeData(array $data, array $options)
  49209. {
  49210. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  49211. }
  49212. private function getInputArgumentData(InputArgument $argument)
  49213. {
  49214. return array(
  49215. 'name' => $argument->getName(),
  49216. 'is_required' => $argument->isRequired(),
  49217. 'is_array' => $argument->isArray(),
  49218. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  49219. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  49220. );
  49221. }
  49222. private function getInputOptionData(InputOption $option)
  49223. {
  49224. return array(
  49225. 'name' => '--'.$option->getName(),
  49226. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  49227. 'accept_value' => $option->acceptValue(),
  49228. 'is_value_required' => $option->isValueRequired(),
  49229. 'is_multiple' => $option->isArray(),
  49230. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  49231. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  49232. );
  49233. }
  49234. private function getInputDefinitionData(InputDefinition $definition)
  49235. {
  49236. $inputArguments = array();
  49237. foreach ($definition->getArguments() as $name => $argument) {
  49238. $inputArguments[$name] = $this->getInputArgumentData($argument);
  49239. }
  49240. $inputOptions = array();
  49241. foreach ($definition->getOptions() as $name => $option) {
  49242. $inputOptions[$name] = $this->getInputOptionData($option);
  49243. }
  49244. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  49245. }
  49246. private function getCommandData(Command $command)
  49247. {
  49248. $command->getSynopsis();
  49249. $command->mergeApplicationDefinition(false);
  49250. return array(
  49251. 'name' => $command->getName(),
  49252. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  49253. 'description' => $command->getDescription(),
  49254. 'help' => $command->getProcessedHelp(),
  49255. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  49256. );
  49257. }
  49258. }
  49259. <?php
  49260. namespace Symfony\Component\Console\Descriptor;
  49261. use Symfony\Component\Console\Application;
  49262. use Symfony\Component\Console\Command\Command;
  49263. use Symfony\Component\Console\Helper\Helper;
  49264. use Symfony\Component\Console\Input\InputArgument;
  49265. use Symfony\Component\Console\Input\InputDefinition;
  49266. use Symfony\Component\Console\Input\InputOption;
  49267. class MarkdownDescriptor extends Descriptor
  49268. {
  49269. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49270. {
  49271. $this->write(
  49272. '**'.$argument->getName().':**'."\n\n"
  49273. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  49274. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  49275. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  49276. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  49277. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  49278. );
  49279. }
  49280. protected function describeInputOption(InputOption $option, array $options = array())
  49281. {
  49282. $this->write(
  49283. '**'.$option->getName().':**'."\n\n"
  49284. .'* Name: `--'.$option->getName().'`'."\n"
  49285. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  49286. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  49287. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  49288. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  49289. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  49290. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  49291. );
  49292. }
  49293. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49294. {
  49295. if ($showArguments = \count($definition->getArguments()) > 0) {
  49296. $this->write('### Arguments:');
  49297. foreach ($definition->getArguments() as $argument) {
  49298. $this->write("\n\n");
  49299. $this->write($this->describeInputArgument($argument));
  49300. }
  49301. }
  49302. if (\count($definition->getOptions()) > 0) {
  49303. if ($showArguments) {
  49304. $this->write("\n\n");
  49305. }
  49306. $this->write('### Options:');
  49307. foreach ($definition->getOptions() as $option) {
  49308. $this->write("\n\n");
  49309. $this->write($this->describeInputOption($option));
  49310. }
  49311. }
  49312. }
  49313. protected function describeCommand(Command $command, array $options = array())
  49314. {
  49315. $command->getSynopsis();
  49316. $command->mergeApplicationDefinition(false);
  49317. $this->write(
  49318. $command->getName()."\n"
  49319. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  49320. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  49321. .'* Usage:'."\n\n"
  49322. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  49323. return $carry.' * `'.$usage.'`'."\n";
  49324. })
  49325. );
  49326. if ($help = $command->getProcessedHelp()) {
  49327. $this->write("\n");
  49328. $this->write($help);
  49329. }
  49330. if ($command->getNativeDefinition()) {
  49331. $this->write("\n\n");
  49332. $this->describeInputDefinition($command->getNativeDefinition());
  49333. }
  49334. }
  49335. protected function describeApplication(Application $application, array $options = array())
  49336. {
  49337. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49338. $description = new ApplicationDescription($application, $describedNamespace);
  49339. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  49340. foreach ($description->getNamespaces() as $namespace) {
  49341. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  49342. $this->write("\n\n");
  49343. $this->write('**'.$namespace['id'].':**');
  49344. }
  49345. $this->write("\n\n");
  49346. $this->write(implode("\n", array_map(function ($commandName) {
  49347. return '* '.$commandName;
  49348. }, $namespace['commands'])));
  49349. }
  49350. foreach ($description->getCommands() as $command) {
  49351. $this->write("\n\n");
  49352. $this->write($this->describeCommand($command));
  49353. }
  49354. }
  49355. }
  49356. <?php
  49357. namespace Symfony\Component\Console\Descriptor;
  49358. use Symfony\Component\Console\Application;
  49359. use Symfony\Component\Console\Command\Command;
  49360. use Symfony\Component\Console\Formatter\OutputFormatter;
  49361. use Symfony\Component\Console\Helper\Helper;
  49362. use Symfony\Component\Console\Input\InputArgument;
  49363. use Symfony\Component\Console\Input\InputDefinition;
  49364. use Symfony\Component\Console\Input\InputOption;
  49365. class TextDescriptor extends Descriptor
  49366. {
  49367. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49368. {
  49369. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  49370. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  49371. } else {
  49372. $default = '';
  49373. }
  49374. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  49375. $spacingWidth = $totalWidth - \strlen($argument->getName());
  49376. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  49377. $argument->getName(),
  49378. str_repeat(' ', $spacingWidth),
  49379. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  49380. $default
  49381. ), $options);
  49382. }
  49383. protected function describeInputOption(InputOption $option, array $options = array())
  49384. {
  49385. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  49386. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  49387. } else {
  49388. $default = '';
  49389. }
  49390. $value = '';
  49391. if ($option->acceptValue()) {
  49392. $value = '='.strtoupper($option->getName());
  49393. if ($option->isValueOptional()) {
  49394. $value = '['.$value.']';
  49395. }
  49396. }
  49397. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  49398. $synopsis = sprintf('%s%s',
  49399. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  49400. sprintf('--%s%s', $option->getName(), $value)
  49401. );
  49402. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  49403. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  49404. $synopsis,
  49405. str_repeat(' ', $spacingWidth),
  49406. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  49407. $default,
  49408. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  49409. ), $options);
  49410. }
  49411. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49412. {
  49413. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  49414. foreach ($definition->getArguments() as $argument) {
  49415. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  49416. }
  49417. if ($definition->getArguments()) {
  49418. $this->writeText('<comment>Arguments:</comment>', $options);
  49419. $this->writeText("\n");
  49420. foreach ($definition->getArguments() as $argument) {
  49421. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  49422. $this->writeText("\n");
  49423. }
  49424. }
  49425. if ($definition->getArguments() && $definition->getOptions()) {
  49426. $this->writeText("\n");
  49427. }
  49428. if ($definition->getOptions()) {
  49429. $laterOptions = array();
  49430. $this->writeText('<comment>Options:</comment>', $options);
  49431. foreach ($definition->getOptions() as $option) {
  49432. if (\strlen($option->getShortcut()) > 1) {
  49433. $laterOptions[] = $option;
  49434. continue;
  49435. }
  49436. $this->writeText("\n");
  49437. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  49438. }
  49439. foreach ($laterOptions as $option) {
  49440. $this->writeText("\n");
  49441. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  49442. }
  49443. }
  49444. }
  49445. protected function describeCommand(Command $command, array $options = array())
  49446. {
  49447. $command->getSynopsis(true);
  49448. $command->getSynopsis(false);
  49449. $command->mergeApplicationDefinition(false);
  49450. $this->writeText('<comment>Usage:</comment>', $options);
  49451. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  49452. $this->writeText("\n");
  49453. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  49454. }
  49455. $this->writeText("\n");
  49456. $definition = $command->getNativeDefinition();
  49457. if ($definition->getOptions() || $definition->getArguments()) {
  49458. $this->writeText("\n");
  49459. $this->describeInputDefinition($definition, $options);
  49460. $this->writeText("\n");
  49461. }
  49462. if ($help = $command->getProcessedHelp()) {
  49463. $this->writeText("\n");
  49464. $this->writeText('<comment>Help:</comment>', $options);
  49465. $this->writeText("\n");
  49466. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  49467. $this->writeText("\n");
  49468. }
  49469. }
  49470. protected function describeApplication(Application $application, array $options = array())
  49471. {
  49472. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49473. $description = new ApplicationDescription($application, $describedNamespace);
  49474. if (isset($options['raw_text']) && $options['raw_text']) {
  49475. $width = $this->getColumnWidth($description->getCommands());
  49476. foreach ($description->getCommands() as $command) {
  49477. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  49478. $this->writeText("\n");
  49479. }
  49480. } else {
  49481. if ('' != $help = $application->getHelp()) {
  49482. $this->writeText("$help\n\n", $options);
  49483. }
  49484. $this->writeText("<comment>Usage:</comment>\n", $options);
  49485. $this->writeText(" command [options] [arguments]\n\n", $options);
  49486. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  49487. $this->writeText("\n");
  49488. $this->writeText("\n");
  49489. $width = $this->getColumnWidth($description->getCommands());
  49490. if ($describedNamespace) {
  49491. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  49492. } else {
  49493. $this->writeText('<comment>Available commands:</comment>', $options);
  49494. }
  49495. foreach ($description->getNamespaces() as $namespace) {
  49496. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  49497. $this->writeText("\n");
  49498. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  49499. }
  49500. foreach ($namespace['commands'] as $name) {
  49501. $this->writeText("\n");
  49502. $spacingWidth = $width - Helper::strlen($name);
  49503. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  49504. }
  49505. }
  49506. $this->writeText("\n");
  49507. }
  49508. }
  49509. private function writeText($content, array $options = array())
  49510. {
  49511. $this->write(
  49512. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  49513. isset($options['raw_output']) ? !$options['raw_output'] : true
  49514. );
  49515. }
  49516. private function formatDefaultValue($default)
  49517. {
  49518. if (INF === $default) {
  49519. return 'INF';
  49520. }
  49521. if (\is_string($default)) {
  49522. $default = OutputFormatter::escape($default);
  49523. } elseif (\is_array($default)) {
  49524. foreach ($default as $key => $value) {
  49525. if (\is_string($value)) {
  49526. $default[$key] = OutputFormatter::escape($value);
  49527. }
  49528. }
  49529. }
  49530. if (\PHP_VERSION_ID < 50400) {
  49531. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  49532. }
  49533. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  49534. }
  49535. private function getColumnWidth(array $commands)
  49536. {
  49537. $widths = array();
  49538. foreach ($commands as $command) {
  49539. $widths[] = Helper::strlen($command->getName());
  49540. foreach ($command->getAliases() as $alias) {
  49541. $widths[] = Helper::strlen($alias);
  49542. }
  49543. }
  49544. return max($widths) + 2;
  49545. }
  49546. private function calculateTotalWidthForOptions(array $options)
  49547. {
  49548. $totalWidth = 0;
  49549. foreach ($options as $option) {
  49550. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  49551. if ($option->acceptValue()) {
  49552. $valueLength = 1 + Helper::strlen($option->getName());
  49553. $valueLength += $option->isValueOptional() ? 2 : 0;
  49554. $nameLength += $valueLength;
  49555. }
  49556. $totalWidth = max($totalWidth, $nameLength);
  49557. }
  49558. return $totalWidth;
  49559. }
  49560. }
  49561. <?php
  49562. namespace Symfony\Component\Console\Descriptor;
  49563. use Symfony\Component\Console\Application;
  49564. use Symfony\Component\Console\Command\Command;
  49565. use Symfony\Component\Console\Input\InputArgument;
  49566. use Symfony\Component\Console\Input\InputDefinition;
  49567. use Symfony\Component\Console\Input\InputOption;
  49568. class XmlDescriptor extends Descriptor
  49569. {
  49570. public function getInputDefinitionDocument(InputDefinition $definition)
  49571. {
  49572. $dom = new \DOMDocument('1.0', 'UTF-8');
  49573. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  49574. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  49575. foreach ($definition->getArguments() as $argument) {
  49576. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  49577. }
  49578. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  49579. foreach ($definition->getOptions() as $option) {
  49580. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  49581. }
  49582. return $dom;
  49583. }
  49584. public function getCommandDocument(Command $command)
  49585. {
  49586. $dom = new \DOMDocument('1.0', 'UTF-8');
  49587. $dom->appendChild($commandXML = $dom->createElement('command'));
  49588. $command->getSynopsis();
  49589. $command->mergeApplicationDefinition(false);
  49590. $commandXML->setAttribute('id', $command->getName());
  49591. $commandXML->setAttribute('name', $command->getName());
  49592. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  49593. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  49594. $usagesXML->appendChild($dom->createElement('usage', $usage));
  49595. }
  49596. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  49597. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  49598. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  49599. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  49600. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  49601. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  49602. return $dom;
  49603. }
  49604. public function getApplicationDocument(Application $application, $namespace = null)
  49605. {
  49606. $dom = new \DOMDocument('1.0', 'UTF-8');
  49607. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  49608. if ('UNKNOWN' !== $application->getName()) {
  49609. $rootXml->setAttribute('name', $application->getName());
  49610. if ('UNKNOWN' !== $application->getVersion()) {
  49611. $rootXml->setAttribute('version', $application->getVersion());
  49612. }
  49613. }
  49614. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  49615. $description = new ApplicationDescription($application, $namespace);
  49616. if ($namespace) {
  49617. $commandsXML->setAttribute('namespace', $namespace);
  49618. }
  49619. foreach ($description->getCommands() as $command) {
  49620. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  49621. }
  49622. if (!$namespace) {
  49623. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  49624. foreach ($description->getNamespaces() as $namespaceDescription) {
  49625. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  49626. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  49627. foreach ($namespaceDescription['commands'] as $name) {
  49628. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  49629. $commandXML->appendChild($dom->createTextNode($name));
  49630. }
  49631. }
  49632. }
  49633. return $dom;
  49634. }
  49635. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49636. {
  49637. $this->writeDocument($this->getInputArgumentDocument($argument));
  49638. }
  49639. protected function describeInputOption(InputOption $option, array $options = array())
  49640. {
  49641. $this->writeDocument($this->getInputOptionDocument($option));
  49642. }
  49643. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49644. {
  49645. $this->writeDocument($this->getInputDefinitionDocument($definition));
  49646. }
  49647. protected function describeCommand(Command $command, array $options = array())
  49648. {
  49649. $this->writeDocument($this->getCommandDocument($command));
  49650. }
  49651. protected function describeApplication(Application $application, array $options = array())
  49652. {
  49653. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  49654. }
  49655. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  49656. {
  49657. foreach ($importedParent->childNodes as $childNode) {
  49658. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  49659. }
  49660. }
  49661. private function writeDocument(\DOMDocument $dom)
  49662. {
  49663. $dom->formatOutput = true;
  49664. $this->write($dom->saveXML());
  49665. }
  49666. private function getInputArgumentDocument(InputArgument $argument)
  49667. {
  49668. $dom = new \DOMDocument('1.0', 'UTF-8');
  49669. $dom->appendChild($objectXML = $dom->createElement('argument'));
  49670. $objectXML->setAttribute('name', $argument->getName());
  49671. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  49672. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  49673. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49674. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  49675. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49676. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  49677. foreach ($defaults as $default) {
  49678. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49679. $defaultXML->appendChild($dom->createTextNode($default));
  49680. }
  49681. return $dom;
  49682. }
  49683. private function getInputOptionDocument(InputOption $option)
  49684. {
  49685. $dom = new \DOMDocument('1.0', 'UTF-8');
  49686. $dom->appendChild($objectXML = $dom->createElement('option'));
  49687. $objectXML->setAttribute('name', '--'.$option->getName());
  49688. $pos = strpos($option->getShortcut(), '|');
  49689. if (false !== $pos) {
  49690. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  49691. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  49692. } else {
  49693. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  49694. }
  49695. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  49696. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  49697. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  49698. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49699. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  49700. if ($option->acceptValue()) {
  49701. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  49702. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49703. if (!empty($defaults)) {
  49704. foreach ($defaults as $default) {
  49705. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49706. $defaultXML->appendChild($dom->createTextNode($default));
  49707. }
  49708. }
  49709. }
  49710. return $dom;
  49711. }
  49712. }
  49713. <?php
  49714. namespace Symfony\Component\Console\Event;
  49715. class ConsoleCommandEvent extends ConsoleEvent
  49716. {
  49717. const RETURN_CODE_DISABLED = 113;
  49718. private $commandShouldRun = true;
  49719. public function disableCommand()
  49720. {
  49721. return $this->commandShouldRun = false;
  49722. }
  49723. public function enableCommand()
  49724. {
  49725. return $this->commandShouldRun = true;
  49726. }
  49727. public function commandShouldRun()
  49728. {
  49729. return $this->commandShouldRun;
  49730. }
  49731. }
  49732. <?php
  49733. namespace Symfony\Component\Console\Event;
  49734. use Symfony\Component\Console\Command\Command;
  49735. use Symfony\Component\Console\Input\InputInterface;
  49736. use Symfony\Component\Console\Output\OutputInterface;
  49737. use Symfony\Component\EventDispatcher\Event;
  49738. class ConsoleEvent extends Event
  49739. {
  49740. protected $command;
  49741. private $input;
  49742. private $output;
  49743. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  49744. {
  49745. $this->command = $command;
  49746. $this->input = $input;
  49747. $this->output = $output;
  49748. }
  49749. public function getCommand()
  49750. {
  49751. return $this->command;
  49752. }
  49753. public function getInput()
  49754. {
  49755. return $this->input;
  49756. }
  49757. public function getOutput()
  49758. {
  49759. return $this->output;
  49760. }
  49761. }
  49762. <?php
  49763. namespace Symfony\Component\Console\Event;
  49764. use Symfony\Component\Console\Command\Command;
  49765. use Symfony\Component\Console\Input\InputInterface;
  49766. use Symfony\Component\Console\Output\OutputInterface;
  49767. class ConsoleExceptionEvent extends ConsoleEvent
  49768. {
  49769. private $exception;
  49770. private $exitCode;
  49771. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  49772. {
  49773. parent::__construct($command, $input, $output);
  49774. $this->setException($exception);
  49775. $this->exitCode = (int) $exitCode;
  49776. }
  49777. public function getException()
  49778. {
  49779. return $this->exception;
  49780. }
  49781. public function setException(\Exception $exception)
  49782. {
  49783. $this->exception = $exception;
  49784. }
  49785. public function getExitCode()
  49786. {
  49787. return $this->exitCode;
  49788. }
  49789. }
  49790. <?php
  49791. namespace Symfony\Component\Console\Event;
  49792. use Symfony\Component\Console\Command\Command;
  49793. use Symfony\Component\Console\Input\InputInterface;
  49794. use Symfony\Component\Console\Output\OutputInterface;
  49795. class ConsoleTerminateEvent extends ConsoleEvent
  49796. {
  49797. private $exitCode;
  49798. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  49799. {
  49800. parent::__construct($command, $input, $output);
  49801. $this->setExitCode($exitCode);
  49802. }
  49803. public function setExitCode($exitCode)
  49804. {
  49805. $this->exitCode = (int) $exitCode;
  49806. }
  49807. public function getExitCode()
  49808. {
  49809. return $this->exitCode;
  49810. }
  49811. }
  49812. <?php
  49813. namespace Symfony\Component\Console\Exception;
  49814. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  49815. {
  49816. private $alternatives;
  49817. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  49818. {
  49819. parent::__construct($message, $code, $previous);
  49820. $this->alternatives = $alternatives;
  49821. }
  49822. public function getAlternatives()
  49823. {
  49824. return $this->alternatives;
  49825. }
  49826. }
  49827. <?php
  49828. namespace Symfony\Component\Console\Exception;
  49829. interface ExceptionInterface
  49830. {
  49831. }
  49832. <?php
  49833. namespace Symfony\Component\Console\Exception;
  49834. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  49835. {
  49836. }
  49837. <?php
  49838. namespace Symfony\Component\Console\Exception;
  49839. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  49840. {
  49841. }
  49842. <?php
  49843. namespace Symfony\Component\Console\Exception;
  49844. class LogicException extends \LogicException implements ExceptionInterface
  49845. {
  49846. }
  49847. <?php
  49848. namespace Symfony\Component\Console\Exception;
  49849. class RuntimeException extends \RuntimeException implements ExceptionInterface
  49850. {
  49851. }
  49852. <?php
  49853. namespace Symfony\Component\Console\Formatter;
  49854. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49855. class OutputFormatter implements OutputFormatterInterface
  49856. {
  49857. private $decorated;
  49858. private $styles = array();
  49859. private $styleStack;
  49860. public static function escape($text)
  49861. {
  49862. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  49863. return self::escapeTrailingBackslash($text);
  49864. }
  49865. public static function escapeTrailingBackslash($text)
  49866. {
  49867. if ('\\' === substr($text, -1)) {
  49868. $len = \strlen($text);
  49869. $text = rtrim($text, '\\');
  49870. $text = str_replace("\0", '', $text);
  49871. $text .= str_repeat("\0", $len - \strlen($text));
  49872. }
  49873. return $text;
  49874. }
  49875. public function __construct($decorated = false, array $styles = array())
  49876. {
  49877. $this->decorated = (bool) $decorated;
  49878. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  49879. $this->setStyle('info', new OutputFormatterStyle('green'));
  49880. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  49881. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  49882. foreach ($styles as $name => $style) {
  49883. $this->setStyle($name, $style);
  49884. }
  49885. $this->styleStack = new OutputFormatterStyleStack();
  49886. }
  49887. public function setDecorated($decorated)
  49888. {
  49889. $this->decorated = (bool) $decorated;
  49890. }
  49891. public function isDecorated()
  49892. {
  49893. return $this->decorated;
  49894. }
  49895. public function setStyle($name, OutputFormatterStyleInterface $style)
  49896. {
  49897. $this->styles[strtolower($name)] = $style;
  49898. }
  49899. public function hasStyle($name)
  49900. {
  49901. return isset($this->styles[strtolower($name)]);
  49902. }
  49903. public function getStyle($name)
  49904. {
  49905. if (!$this->hasStyle($name)) {
  49906. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  49907. }
  49908. return $this->styles[strtolower($name)];
  49909. }
  49910. public function format($message)
  49911. {
  49912. $message = (string) $message;
  49913. $offset = 0;
  49914. $output = '';
  49915. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  49916. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  49917. foreach ($matches[0] as $i => $match) {
  49918. $pos = $match[1];
  49919. $text = $match[0];
  49920. if (0 != $pos && '\\' == $message[$pos - 1]) {
  49921. continue;
  49922. }
  49923. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  49924. $offset = $pos + \strlen($text);
  49925. if ($open = '/' != $text[1]) {
  49926. $tag = $matches[1][$i][0];
  49927. } else {
  49928. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  49929. }
  49930. if (!$open && !$tag) {
  49931. $this->styleStack->pop();
  49932. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  49933. $output .= $this->applyCurrentStyle($text);
  49934. } elseif ($open) {
  49935. $this->styleStack->push($style);
  49936. } else {
  49937. $this->styleStack->pop($style);
  49938. }
  49939. }
  49940. $output .= $this->applyCurrentStyle(substr($message, $offset));
  49941. if (false !== strpos($output, "\0")) {
  49942. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  49943. }
  49944. return str_replace('\\<', '<', $output);
  49945. }
  49946. public function getStyleStack()
  49947. {
  49948. return $this->styleStack;
  49949. }
  49950. private function createStyleFromString($string)
  49951. {
  49952. if (isset($this->styles[$string])) {
  49953. return $this->styles[$string];
  49954. }
  49955. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  49956. return false;
  49957. }
  49958. $style = new OutputFormatterStyle();
  49959. foreach ($matches as $match) {
  49960. array_shift($match);
  49961. if ('fg' == $match[0]) {
  49962. $style->setForeground($match[1]);
  49963. } elseif ('bg' == $match[0]) {
  49964. $style->setBackground($match[1]);
  49965. } else {
  49966. try {
  49967. $style->setOption($match[1]);
  49968. } catch (\InvalidArgumentException $e) {
  49969. return false;
  49970. }
  49971. }
  49972. }
  49973. return $style;
  49974. }
  49975. private function applyCurrentStyle($text)
  49976. {
  49977. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  49978. }
  49979. }
  49980. <?php
  49981. namespace Symfony\Component\Console\Formatter;
  49982. interface OutputFormatterInterface
  49983. {
  49984. public function setDecorated($decorated);
  49985. public function isDecorated();
  49986. public function setStyle($name, OutputFormatterStyleInterface $style);
  49987. public function hasStyle($name);
  49988. public function getStyle($name);
  49989. public function format($message);
  49990. }
  49991. <?php
  49992. namespace Symfony\Component\Console\Formatter;
  49993. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49994. class OutputFormatterStyle implements OutputFormatterStyleInterface
  49995. {
  49996. private static $availableForegroundColors = array(
  49997. 'black' => array('set' => 30, 'unset' => 39),
  49998. 'red' => array('set' => 31, 'unset' => 39),
  49999. 'green' => array('set' => 32, 'unset' => 39),
  50000. 'yellow' => array('set' => 33, 'unset' => 39),
  50001. 'blue' => array('set' => 34, 'unset' => 39),
  50002. 'magenta' => array('set' => 35, 'unset' => 39),
  50003. 'cyan' => array('set' => 36, 'unset' => 39),
  50004. 'white' => array('set' => 37, 'unset' => 39),
  50005. 'default' => array('set' => 39, 'unset' => 39),
  50006. );
  50007. private static $availableBackgroundColors = array(
  50008. 'black' => array('set' => 40, 'unset' => 49),
  50009. 'red' => array('set' => 41, 'unset' => 49),
  50010. 'green' => array('set' => 42, 'unset' => 49),
  50011. 'yellow' => array('set' => 43, 'unset' => 49),
  50012. 'blue' => array('set' => 44, 'unset' => 49),
  50013. 'magenta' => array('set' => 45, 'unset' => 49),
  50014. 'cyan' => array('set' => 46, 'unset' => 49),
  50015. 'white' => array('set' => 47, 'unset' => 49),
  50016. 'default' => array('set' => 49, 'unset' => 49),
  50017. );
  50018. private static $availableOptions = array(
  50019. 'bold' => array('set' => 1, 'unset' => 22),
  50020. 'underscore' => array('set' => 4, 'unset' => 24),
  50021. 'blink' => array('set' => 5, 'unset' => 25),
  50022. 'reverse' => array('set' => 7, 'unset' => 27),
  50023. 'conceal' => array('set' => 8, 'unset' => 28),
  50024. );
  50025. private $foreground;
  50026. private $background;
  50027. private $options = array();
  50028. public function __construct($foreground = null, $background = null, array $options = array())
  50029. {
  50030. if (null !== $foreground) {
  50031. $this->setForeground($foreground);
  50032. }
  50033. if (null !== $background) {
  50034. $this->setBackground($background);
  50035. }
  50036. if (\count($options)) {
  50037. $this->setOptions($options);
  50038. }
  50039. }
  50040. public function setForeground($color = null)
  50041. {
  50042. if (null === $color) {
  50043. $this->foreground = null;
  50044. return;
  50045. }
  50046. if (!isset(static::$availableForegroundColors[$color])) {
  50047. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  50048. }
  50049. $this->foreground = static::$availableForegroundColors[$color];
  50050. }
  50051. public function setBackground($color = null)
  50052. {
  50053. if (null === $color) {
  50054. $this->background = null;
  50055. return;
  50056. }
  50057. if (!isset(static::$availableBackgroundColors[$color])) {
  50058. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  50059. }
  50060. $this->background = static::$availableBackgroundColors[$color];
  50061. }
  50062. public function setOption($option)
  50063. {
  50064. if (!isset(static::$availableOptions[$option])) {
  50065. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  50066. }
  50067. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  50068. $this->options[] = static::$availableOptions[$option];
  50069. }
  50070. }
  50071. public function unsetOption($option)
  50072. {
  50073. if (!isset(static::$availableOptions[$option])) {
  50074. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  50075. }
  50076. $pos = array_search(static::$availableOptions[$option], $this->options);
  50077. if (false !== $pos) {
  50078. unset($this->options[$pos]);
  50079. }
  50080. }
  50081. public function setOptions(array $options)
  50082. {
  50083. $this->options = array();
  50084. foreach ($options as $option) {
  50085. $this->setOption($option);
  50086. }
  50087. }
  50088. public function apply($text)
  50089. {
  50090. $setCodes = array();
  50091. $unsetCodes = array();
  50092. if (null !== $this->foreground) {
  50093. $setCodes[] = $this->foreground['set'];
  50094. $unsetCodes[] = $this->foreground['unset'];
  50095. }
  50096. if (null !== $this->background) {
  50097. $setCodes[] = $this->background['set'];
  50098. $unsetCodes[] = $this->background['unset'];
  50099. }
  50100. if (\count($this->options)) {
  50101. foreach ($this->options as $option) {
  50102. $setCodes[] = $option['set'];
  50103. $unsetCodes[] = $option['unset'];
  50104. }
  50105. }
  50106. if (0 === \count($setCodes)) {
  50107. return $text;
  50108. }
  50109. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  50110. }
  50111. }
  50112. <?php
  50113. namespace Symfony\Component\Console\Formatter;
  50114. interface OutputFormatterStyleInterface
  50115. {
  50116. public function setForeground($color = null);
  50117. public function setBackground($color = null);
  50118. public function setOption($option);
  50119. public function unsetOption($option);
  50120. public function setOptions(array $options);
  50121. public function apply($text);
  50122. }
  50123. <?php
  50124. namespace Symfony\Component\Console\Formatter;
  50125. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50126. class OutputFormatterStyleStack
  50127. {
  50128. private $styles;
  50129. private $emptyStyle;
  50130. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  50131. {
  50132. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  50133. $this->reset();
  50134. }
  50135. public function reset()
  50136. {
  50137. $this->styles = array();
  50138. }
  50139. public function push(OutputFormatterStyleInterface $style)
  50140. {
  50141. $this->styles[] = $style;
  50142. }
  50143. public function pop(OutputFormatterStyleInterface $style = null)
  50144. {
  50145. if (empty($this->styles)) {
  50146. return $this->emptyStyle;
  50147. }
  50148. if (null === $style) {
  50149. return array_pop($this->styles);
  50150. }
  50151. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  50152. if ($style->apply('') === $stackedStyle->apply('')) {
  50153. $this->styles = \array_slice($this->styles, 0, $index);
  50154. return $stackedStyle;
  50155. }
  50156. }
  50157. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  50158. }
  50159. public function getCurrent()
  50160. {
  50161. if (empty($this->styles)) {
  50162. return $this->emptyStyle;
  50163. }
  50164. return $this->styles[\count($this->styles) - 1];
  50165. }
  50166. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  50167. {
  50168. $this->emptyStyle = $emptyStyle;
  50169. return $this;
  50170. }
  50171. public function getEmptyStyle()
  50172. {
  50173. return $this->emptyStyle;
  50174. }
  50175. }
  50176. <?php
  50177. namespace Symfony\Component\Console\Helper;
  50178. class DebugFormatterHelper extends Helper
  50179. {
  50180. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  50181. private $started = array();
  50182. private $count = -1;
  50183. public function start($id, $message, $prefix = 'RUN')
  50184. {
  50185. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  50186. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  50187. }
  50188. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  50189. {
  50190. $message = '';
  50191. if ($error) {
  50192. if (isset($this->started[$id]['out'])) {
  50193. $message .= "\n";
  50194. unset($this->started[$id]['out']);
  50195. }
  50196. if (!isset($this->started[$id]['err'])) {
  50197. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  50198. $this->started[$id]['err'] = true;
  50199. }
  50200. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  50201. } else {
  50202. if (isset($this->started[$id]['err'])) {
  50203. $message .= "\n";
  50204. unset($this->started[$id]['err']);
  50205. }
  50206. if (!isset($this->started[$id]['out'])) {
  50207. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  50208. $this->started[$id]['out'] = true;
  50209. }
  50210. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  50211. }
  50212. return $message;
  50213. }
  50214. public function stop($id, $message, $successful, $prefix = 'RES')
  50215. {
  50216. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  50217. if ($successful) {
  50218. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  50219. }
  50220. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  50221. unset($this->started[$id]['out'], $this->started[$id]['err']);
  50222. return $message;
  50223. }
  50224. private function getBorder($id)
  50225. {
  50226. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  50227. }
  50228. public function getName()
  50229. {
  50230. return 'debug_formatter';
  50231. }
  50232. }
  50233. <?php
  50234. namespace Symfony\Component\Console\Helper;
  50235. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  50236. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  50237. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  50238. use Symfony\Component\Console\Descriptor\TextDescriptor;
  50239. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  50240. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50241. use Symfony\Component\Console\Output\OutputInterface;
  50242. class DescriptorHelper extends Helper
  50243. {
  50244. private $descriptors = array();
  50245. public function __construct()
  50246. {
  50247. $this
  50248. ->register('txt', new TextDescriptor())
  50249. ->register('xml', new XmlDescriptor())
  50250. ->register('json', new JsonDescriptor())
  50251. ->register('md', new MarkdownDescriptor())
  50252. ;
  50253. }
  50254. public function describe(OutputInterface $output, $object, array $options = array())
  50255. {
  50256. $options = array_merge(array(
  50257. 'raw_text' => false,
  50258. 'format' => 'txt',
  50259. ), $options);
  50260. if (!isset($this->descriptors[$options['format']])) {
  50261. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  50262. }
  50263. $descriptor = $this->descriptors[$options['format']];
  50264. $descriptor->describe($output, $object, $options);
  50265. }
  50266. public function register($format, DescriptorInterface $descriptor)
  50267. {
  50268. $this->descriptors[$format] = $descriptor;
  50269. return $this;
  50270. }
  50271. public function getName()
  50272. {
  50273. return 'descriptor';
  50274. }
  50275. }
  50276. <?php
  50277. namespace Symfony\Component\Console\Helper;
  50278. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50279. use Symfony\Component\Console\Exception\RuntimeException;
  50280. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  50281. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50282. use Symfony\Component\Console\Output\OutputInterface;
  50283. class DialogHelper extends InputAwareHelper
  50284. {
  50285. private $inputStream;
  50286. private static $shell;
  50287. private static $stty;
  50288. public function __construct($triggerDeprecationError = true)
  50289. {
  50290. if ($triggerDeprecationError) {
  50291. @trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since Symfony 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED);
  50292. }
  50293. }
  50294. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  50295. {
  50296. if ($output instanceof ConsoleOutputInterface) {
  50297. $output = $output->getErrorOutput();
  50298. }
  50299. $width = max(array_map('strlen', array_keys($choices)));
  50300. $messages = (array) $question;
  50301. foreach ($choices as $key => $value) {
  50302. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  50303. }
  50304. $output->writeln($messages);
  50305. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  50306. $selectedChoices = str_replace(' ', '', $picked);
  50307. if ($multiselect) {
  50308. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  50309. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  50310. }
  50311. $selectedChoices = explode(',', $selectedChoices);
  50312. } else {
  50313. $selectedChoices = array($picked);
  50314. }
  50315. $multiselectChoices = array();
  50316. foreach ($selectedChoices as $value) {
  50317. if (empty($choices[$value])) {
  50318. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  50319. }
  50320. $multiselectChoices[] = $value;
  50321. }
  50322. if ($multiselect) {
  50323. return $multiselectChoices;
  50324. }
  50325. return $picked;
  50326. }, $attempts, $default);
  50327. return $result;
  50328. }
  50329. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  50330. {
  50331. if ($this->input && !$this->input->isInteractive()) {
  50332. return $default;
  50333. }
  50334. if ($output instanceof ConsoleOutputInterface) {
  50335. $output = $output->getErrorOutput();
  50336. }
  50337. $output->write($question);
  50338. $inputStream = $this->inputStream ?: STDIN;
  50339. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  50340. $ret = fgets($inputStream, 4096);
  50341. if (false === $ret) {
  50342. throw new RuntimeException('Aborted');
  50343. }
  50344. $ret = trim($ret);
  50345. } else {
  50346. $ret = '';
  50347. $i = 0;
  50348. $ofs = -1;
  50349. $matches = $autocomplete;
  50350. $numMatches = \count($matches);
  50351. $sttyMode = shell_exec('stty -g');
  50352. shell_exec('stty -icanon -echo');
  50353. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  50354. while (!feof($inputStream)) {
  50355. $c = fread($inputStream, 1);
  50356. if ("\177" === $c) {
  50357. if (0 === $numMatches && 0 !== $i) {
  50358. --$i;
  50359. $output->write("\033[1D");
  50360. }
  50361. if (0 === $i) {
  50362. $ofs = -1;
  50363. $matches = $autocomplete;
  50364. $numMatches = \count($matches);
  50365. } else {
  50366. $numMatches = 0;
  50367. }
  50368. $ret = substr($ret, 0, $i);
  50369. } elseif ("\033" === $c) {
  50370. $c .= fread($inputStream, 2);
  50371. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  50372. if ('A' === $c[2] && -1 === $ofs) {
  50373. $ofs = 0;
  50374. }
  50375. if (0 === $numMatches) {
  50376. continue;
  50377. }
  50378. $ofs += ('A' === $c[2]) ? -1 : 1;
  50379. $ofs = ($numMatches + $ofs) % $numMatches;
  50380. }
  50381. } elseif (\ord($c) < 32) {
  50382. if ("\t" === $c || "\n" === $c) {
  50383. if ($numMatches > 0 && -1 !== $ofs) {
  50384. $ret = $matches[$ofs];
  50385. $output->write(substr($ret, $i));
  50386. $i = \strlen($ret);
  50387. }
  50388. if ("\n" === $c) {
  50389. $output->write($c);
  50390. break;
  50391. }
  50392. $numMatches = 0;
  50393. }
  50394. continue;
  50395. } else {
  50396. $output->write($c);
  50397. $ret .= $c;
  50398. ++$i;
  50399. $numMatches = 0;
  50400. $ofs = 0;
  50401. foreach ($autocomplete as $value) {
  50402. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  50403. $matches[$numMatches++] = $value;
  50404. }
  50405. }
  50406. }
  50407. $output->write("\033[K");
  50408. if ($numMatches > 0 && -1 !== $ofs) {
  50409. $output->write("\0337");
  50410. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  50411. $output->write("\0338");
  50412. }
  50413. }
  50414. shell_exec(sprintf('stty %s', $sttyMode));
  50415. }
  50416. return \strlen($ret) > 0 ? $ret : $default;
  50417. }
  50418. public function askConfirmation(OutputInterface $output, $question, $default = true)
  50419. {
  50420. $answer = 'z';
  50421. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  50422. $answer = $this->ask($output, $question);
  50423. }
  50424. if (false === $default) {
  50425. return $answer && 'y' == strtolower($answer[0]);
  50426. }
  50427. return !$answer || 'y' == strtolower($answer[0]);
  50428. }
  50429. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  50430. {
  50431. if ($output instanceof ConsoleOutputInterface) {
  50432. $output = $output->getErrorOutput();
  50433. }
  50434. if ('\\' === \DIRECTORY_SEPARATOR) {
  50435. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  50436. if ('phar:' === substr(__FILE__, 0, 5)) {
  50437. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  50438. copy($exe, $tmpExe);
  50439. $exe = $tmpExe;
  50440. }
  50441. $output->write($question);
  50442. $value = rtrim(shell_exec($exe));
  50443. $output->writeln('');
  50444. if (isset($tmpExe)) {
  50445. unlink($tmpExe);
  50446. }
  50447. return $value;
  50448. }
  50449. if ($this->hasSttyAvailable()) {
  50450. $output->write($question);
  50451. $sttyMode = shell_exec('stty -g');
  50452. shell_exec('stty -echo');
  50453. $value = fgets($this->inputStream ?: STDIN, 4096);
  50454. shell_exec(sprintf('stty %s', $sttyMode));
  50455. if (false === $value) {
  50456. throw new RuntimeException('Aborted');
  50457. }
  50458. $value = trim($value);
  50459. $output->writeln('');
  50460. return $value;
  50461. }
  50462. if (false !== $shell = $this->getShell()) {
  50463. $output->write($question);
  50464. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  50465. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  50466. $value = rtrim(shell_exec($command));
  50467. $output->writeln('');
  50468. return $value;
  50469. }
  50470. if ($fallback) {
  50471. return $this->ask($output, $question);
  50472. }
  50473. throw new RuntimeException('Unable to hide the response');
  50474. }
  50475. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  50476. {
  50477. $that = $this;
  50478. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  50479. return $that->ask($output, $question, $default, $autocomplete);
  50480. };
  50481. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  50482. }
  50483. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  50484. {
  50485. $that = $this;
  50486. $interviewer = function () use ($output, $question, $fallback, $that) {
  50487. return $that->askHiddenResponse($output, $question, $fallback);
  50488. };
  50489. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  50490. }
  50491. public function setInputStream($stream)
  50492. {
  50493. $this->inputStream = $stream;
  50494. }
  50495. public function getInputStream()
  50496. {
  50497. return $this->inputStream;
  50498. }
  50499. public function getName()
  50500. {
  50501. return 'dialog';
  50502. }
  50503. private function getShell()
  50504. {
  50505. if (null !== self::$shell) {
  50506. return self::$shell;
  50507. }
  50508. self::$shell = false;
  50509. if (file_exists('/usr/bin/env')) {
  50510. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  50511. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  50512. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  50513. self::$shell = $sh;
  50514. break;
  50515. }
  50516. }
  50517. }
  50518. return self::$shell;
  50519. }
  50520. private function hasSttyAvailable()
  50521. {
  50522. if (null !== self::$stty) {
  50523. return self::$stty;
  50524. }
  50525. exec('stty 2>&1', $output, $exitcode);
  50526. return self::$stty = 0 === $exitcode;
  50527. }
  50528. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  50529. {
  50530. if ($output instanceof ConsoleOutputInterface) {
  50531. $output = $output->getErrorOutput();
  50532. }
  50533. $e = null;
  50534. while (false === $attempts || $attempts--) {
  50535. if (null !== $e) {
  50536. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  50537. }
  50538. try {
  50539. return \call_user_func($validator, $interviewer());
  50540. } catch (\Exception $e) {
  50541. }
  50542. }
  50543. throw $e;
  50544. }
  50545. }
  50546. <?php
  50547. namespace Symfony\Component\Console\Helper;
  50548. use Symfony\Component\Console\Formatter\OutputFormatter;
  50549. class FormatterHelper extends Helper
  50550. {
  50551. public function formatSection($section, $message, $style = 'info')
  50552. {
  50553. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  50554. }
  50555. public function formatBlock($messages, $style, $large = false)
  50556. {
  50557. if (!\is_array($messages)) {
  50558. $messages = array($messages);
  50559. }
  50560. $len = 0;
  50561. $lines = array();
  50562. foreach ($messages as $message) {
  50563. $message = OutputFormatter::escape($message);
  50564. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  50565. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  50566. }
  50567. $messages = $large ? array(str_repeat(' ', $len)) : array();
  50568. for ($i = 0; isset($lines[$i]); ++$i) {
  50569. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  50570. }
  50571. if ($large) {
  50572. $messages[] = str_repeat(' ', $len);
  50573. }
  50574. for ($i = 0; isset($messages[$i]); ++$i) {
  50575. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  50576. }
  50577. return implode("\n", $messages);
  50578. }
  50579. public function getName()
  50580. {
  50581. return 'formatter';
  50582. }
  50583. }
  50584. <?php
  50585. namespace Symfony\Component\Console\Helper;
  50586. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  50587. abstract class Helper implements HelperInterface
  50588. {
  50589. protected $helperSet = null;
  50590. public function setHelperSet(HelperSet $helperSet = null)
  50591. {
  50592. $this->helperSet = $helperSet;
  50593. }
  50594. public function getHelperSet()
  50595. {
  50596. return $this->helperSet;
  50597. }
  50598. public static function strlen($string)
  50599. {
  50600. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  50601. return \strlen($string);
  50602. }
  50603. return mb_strwidth($string, $encoding);
  50604. }
  50605. public static function formatTime($secs)
  50606. {
  50607. static $timeFormats = array(
  50608. array(0, '< 1 sec'),
  50609. array(1, '1 sec'),
  50610. array(2, 'secs', 1),
  50611. array(60, '1 min'),
  50612. array(120, 'mins', 60),
  50613. array(3600, '1 hr'),
  50614. array(7200, 'hrs', 3600),
  50615. array(86400, '1 day'),
  50616. array(172800, 'days', 86400),
  50617. );
  50618. foreach ($timeFormats as $index => $format) {
  50619. if ($secs >= $format[0]) {
  50620. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  50621. || $index == \count($timeFormats) - 1
  50622. ) {
  50623. if (2 == \count($format)) {
  50624. return $format[1];
  50625. }
  50626. return floor($secs / $format[2]).' '.$format[1];
  50627. }
  50628. }
  50629. }
  50630. }
  50631. public static function formatMemory($memory)
  50632. {
  50633. if ($memory >= 1024 * 1024 * 1024) {
  50634. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  50635. }
  50636. if ($memory >= 1024 * 1024) {
  50637. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  50638. }
  50639. if ($memory >= 1024) {
  50640. return sprintf('%d KiB', $memory / 1024);
  50641. }
  50642. return sprintf('%d B', $memory);
  50643. }
  50644. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  50645. {
  50646. return self::strlen(self::removeDecoration($formatter, $string));
  50647. }
  50648. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  50649. {
  50650. $isDecorated = $formatter->isDecorated();
  50651. $formatter->setDecorated(false);
  50652. $string = $formatter->format($string);
  50653. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  50654. $formatter->setDecorated($isDecorated);
  50655. return $string;
  50656. }
  50657. }
  50658. <?php
  50659. namespace Symfony\Component\Console\Helper;
  50660. interface HelperInterface
  50661. {
  50662. public function setHelperSet(HelperSet $helperSet = null);
  50663. public function getHelperSet();
  50664. public function getName();
  50665. }
  50666. <?php
  50667. namespace Symfony\Component\Console\Helper;
  50668. use Symfony\Component\Console\Command\Command;
  50669. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50670. class HelperSet implements \IteratorAggregate
  50671. {
  50672. private $helpers = array();
  50673. private $command;
  50674. public function __construct(array $helpers = array())
  50675. {
  50676. foreach ($helpers as $alias => $helper) {
  50677. $this->set($helper, \is_int($alias) ? null : $alias);
  50678. }
  50679. }
  50680. public function set(HelperInterface $helper, $alias = null)
  50681. {
  50682. $this->helpers[$helper->getName()] = $helper;
  50683. if (null !== $alias) {
  50684. $this->helpers[$alias] = $helper;
  50685. }
  50686. $helper->setHelperSet($this);
  50687. }
  50688. public function has($name)
  50689. {
  50690. return isset($this->helpers[$name]);
  50691. }
  50692. public function get($name)
  50693. {
  50694. if (!$this->has($name)) {
  50695. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  50696. }
  50697. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  50698. @trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since Symfony 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED);
  50699. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  50700. @trigger_error('"Symfony\Component\Console\Helper\ProgressHelper" is deprecated since Symfony 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\ProgressBar" instead.', E_USER_DEPRECATED);
  50701. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  50702. @trigger_error('"Symfony\Component\Console\Helper\TableHelper" is deprecated since Symfony 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Table" instead.', E_USER_DEPRECATED);
  50703. }
  50704. return $this->helpers[$name];
  50705. }
  50706. public function setCommand(Command $command = null)
  50707. {
  50708. $this->command = $command;
  50709. }
  50710. public function getCommand()
  50711. {
  50712. return $this->command;
  50713. }
  50714. public function getIterator()
  50715. {
  50716. return new \ArrayIterator($this->helpers);
  50717. }
  50718. }
  50719. <?php
  50720. namespace Symfony\Component\Console\Helper;
  50721. use Symfony\Component\Console\Input\InputAwareInterface;
  50722. use Symfony\Component\Console\Input\InputInterface;
  50723. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  50724. {
  50725. protected $input;
  50726. public function setInput(InputInterface $input)
  50727. {
  50728. $this->input = $input;
  50729. }
  50730. }
  50731. <?php
  50732. namespace Symfony\Component\Console\Helper;
  50733. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50734. use Symfony\Component\Console\Output\OutputInterface;
  50735. use Symfony\Component\Process\Exception\ProcessFailedException;
  50736. use Symfony\Component\Process\Process;
  50737. use Symfony\Component\Process\ProcessBuilder;
  50738. class ProcessHelper extends Helper
  50739. {
  50740. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  50741. {
  50742. if ($output instanceof ConsoleOutputInterface) {
  50743. $output = $output->getErrorOutput();
  50744. }
  50745. $formatter = $this->getHelperSet()->get('debug_formatter');
  50746. if (\is_array($cmd)) {
  50747. $process = ProcessBuilder::create($cmd)->getProcess();
  50748. } elseif ($cmd instanceof Process) {
  50749. $process = $cmd;
  50750. } else {
  50751. $process = new Process($cmd);
  50752. }
  50753. if ($verbosity <= $output->getVerbosity()) {
  50754. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  50755. }
  50756. if ($output->isDebug()) {
  50757. $callback = $this->wrapCallback($output, $process, $callback);
  50758. }
  50759. $process->run($callback);
  50760. if ($verbosity <= $output->getVerbosity()) {
  50761. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  50762. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  50763. }
  50764. if (!$process->isSuccessful() && null !== $error) {
  50765. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  50766. }
  50767. return $process;
  50768. }
  50769. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  50770. {
  50771. $process = $this->run($output, $cmd, $error, $callback);
  50772. if (!$process->isSuccessful()) {
  50773. throw new ProcessFailedException($process);
  50774. }
  50775. return $process;
  50776. }
  50777. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  50778. {
  50779. if ($output instanceof ConsoleOutputInterface) {
  50780. $output = $output->getErrorOutput();
  50781. }
  50782. $formatter = $this->getHelperSet()->get('debug_formatter');
  50783. $that = $this;
  50784. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  50785. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  50786. if (null !== $callback) {
  50787. \call_user_func($callback, $type, $buffer);
  50788. }
  50789. };
  50790. }
  50791. public function escapeString($str)
  50792. {
  50793. return str_replace('<', '\\<', $str);
  50794. }
  50795. public function getName()
  50796. {
  50797. return 'process';
  50798. }
  50799. }
  50800. <?php
  50801. namespace Symfony\Component\Console\Helper;
  50802. use Symfony\Component\Console\Exception\LogicException;
  50803. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50804. use Symfony\Component\Console\Output\OutputInterface;
  50805. class ProgressBar
  50806. {
  50807. private $barWidth = 28;
  50808. private $barChar;
  50809. private $emptyBarChar = '-';
  50810. private $progressChar = '>';
  50811. private $format;
  50812. private $internalFormat;
  50813. private $redrawFreq = 1;
  50814. private $output;
  50815. private $step = 0;
  50816. private $max;
  50817. private $startTime;
  50818. private $stepWidth;
  50819. private $percent = 0.0;
  50820. private $formatLineCount;
  50821. private $messages = array();
  50822. private $overwrite = true;
  50823. private $firstRun = true;
  50824. private static $formatters;
  50825. private static $formats;
  50826. public function __construct(OutputInterface $output, $max = 0)
  50827. {
  50828. if ($output instanceof ConsoleOutputInterface) {
  50829. $output = $output->getErrorOutput();
  50830. }
  50831. $this->output = $output;
  50832. $this->setMaxSteps($max);
  50833. if (!$this->output->isDecorated()) {
  50834. $this->overwrite = false;
  50835. $this->setRedrawFrequency($max / 10);
  50836. }
  50837. $this->startTime = time();
  50838. }
  50839. public static function setPlaceholderFormatterDefinition($name, $callable)
  50840. {
  50841. if (!self::$formatters) {
  50842. self::$formatters = self::initPlaceholderFormatters();
  50843. }
  50844. self::$formatters[$name] = $callable;
  50845. }
  50846. public static function getPlaceholderFormatterDefinition($name)
  50847. {
  50848. if (!self::$formatters) {
  50849. self::$formatters = self::initPlaceholderFormatters();
  50850. }
  50851. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  50852. }
  50853. public static function setFormatDefinition($name, $format)
  50854. {
  50855. if (!self::$formats) {
  50856. self::$formats = self::initFormats();
  50857. }
  50858. self::$formats[$name] = $format;
  50859. }
  50860. public static function getFormatDefinition($name)
  50861. {
  50862. if (!self::$formats) {
  50863. self::$formats = self::initFormats();
  50864. }
  50865. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  50866. }
  50867. public function setMessage($message, $name = 'message')
  50868. {
  50869. $this->messages[$name] = $message;
  50870. }
  50871. public function getMessage($name = 'message')
  50872. {
  50873. return $this->messages[$name];
  50874. }
  50875. public function getStartTime()
  50876. {
  50877. return $this->startTime;
  50878. }
  50879. public function getMaxSteps()
  50880. {
  50881. return $this->max;
  50882. }
  50883. public function getStep()
  50884. {
  50885. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the getProgress() method instead.', E_USER_DEPRECATED);
  50886. return $this->getProgress();
  50887. }
  50888. public function getProgress()
  50889. {
  50890. return $this->step;
  50891. }
  50892. public function getStepWidth()
  50893. {
  50894. return $this->stepWidth;
  50895. }
  50896. public function getProgressPercent()
  50897. {
  50898. return $this->percent;
  50899. }
  50900. public function setBarWidth($size)
  50901. {
  50902. $this->barWidth = (int) $size;
  50903. }
  50904. public function getBarWidth()
  50905. {
  50906. return $this->barWidth;
  50907. }
  50908. public function setBarCharacter($char)
  50909. {
  50910. $this->barChar = $char;
  50911. }
  50912. public function getBarCharacter()
  50913. {
  50914. if (null === $this->barChar) {
  50915. return $this->max ? '=' : $this->emptyBarChar;
  50916. }
  50917. return $this->barChar;
  50918. }
  50919. public function setEmptyBarCharacter($char)
  50920. {
  50921. $this->emptyBarChar = $char;
  50922. }
  50923. public function getEmptyBarCharacter()
  50924. {
  50925. return $this->emptyBarChar;
  50926. }
  50927. public function setProgressCharacter($char)
  50928. {
  50929. $this->progressChar = $char;
  50930. }
  50931. public function getProgressCharacter()
  50932. {
  50933. return $this->progressChar;
  50934. }
  50935. public function setFormat($format)
  50936. {
  50937. $this->format = null;
  50938. $this->internalFormat = $format;
  50939. }
  50940. public function setRedrawFrequency($freq)
  50941. {
  50942. $this->redrawFreq = max((int) $freq, 1);
  50943. }
  50944. public function start($max = null)
  50945. {
  50946. $this->startTime = time();
  50947. $this->step = 0;
  50948. $this->percent = 0.0;
  50949. if (null !== $max) {
  50950. $this->setMaxSteps($max);
  50951. }
  50952. $this->display();
  50953. }
  50954. public function advance($step = 1)
  50955. {
  50956. $this->setProgress($this->step + $step);
  50957. }
  50958. public function setCurrent($step)
  50959. {
  50960. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the setProgress() method instead.', E_USER_DEPRECATED);
  50961. $this->setProgress($step);
  50962. }
  50963. public function setOverwrite($overwrite)
  50964. {
  50965. $this->overwrite = (bool) $overwrite;
  50966. }
  50967. public function setProgress($step)
  50968. {
  50969. $step = (int) $step;
  50970. if ($step < $this->step) {
  50971. throw new LogicException('You can\'t regress the progress bar.');
  50972. }
  50973. if ($this->max && $step > $this->max) {
  50974. $this->max = $step;
  50975. }
  50976. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  50977. $currPeriod = (int) ($step / $this->redrawFreq);
  50978. $this->step = $step;
  50979. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  50980. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  50981. $this->display();
  50982. }
  50983. }
  50984. public function finish()
  50985. {
  50986. if (!$this->max) {
  50987. $this->max = $this->step;
  50988. }
  50989. if ($this->step === $this->max && !$this->overwrite) {
  50990. return;
  50991. }
  50992. $this->setProgress($this->max);
  50993. }
  50994. public function display()
  50995. {
  50996. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  50997. return;
  50998. }
  50999. if (null === $this->format) {
  51000. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  51001. }
  51002. $self = $this;
  51003. $output = $this->output;
  51004. $messages = $this->messages;
  51005. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  51006. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  51007. $text = \call_user_func($formatter, $self, $output);
  51008. } elseif (isset($messages[$matches[1]])) {
  51009. $text = $messages[$matches[1]];
  51010. } else {
  51011. return $matches[0];
  51012. }
  51013. if (isset($matches[2])) {
  51014. $text = sprintf('%'.$matches[2], $text);
  51015. }
  51016. return $text;
  51017. }, $this->format));
  51018. }
  51019. public function clear()
  51020. {
  51021. if (!$this->overwrite) {
  51022. return;
  51023. }
  51024. if (null === $this->format) {
  51025. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  51026. }
  51027. $this->overwrite('');
  51028. }
  51029. private function setRealFormat($format)
  51030. {
  51031. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  51032. $this->format = self::getFormatDefinition($format.'_nomax');
  51033. } elseif (null !== self::getFormatDefinition($format)) {
  51034. $this->format = self::getFormatDefinition($format);
  51035. } else {
  51036. $this->format = $format;
  51037. }
  51038. $this->formatLineCount = substr_count($this->format, "\n");
  51039. }
  51040. private function setMaxSteps($max)
  51041. {
  51042. $this->max = max(0, (int) $max);
  51043. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  51044. }
  51045. private function overwrite($message)
  51046. {
  51047. if ($this->overwrite) {
  51048. if (!$this->firstRun) {
  51049. $this->output->write("\x0D");
  51050. $this->output->write("\x1B[2K");
  51051. if ($this->formatLineCount > 0) {
  51052. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  51053. }
  51054. }
  51055. } elseif ($this->step > 0) {
  51056. $this->output->writeln('');
  51057. }
  51058. $this->firstRun = false;
  51059. $this->output->write($message);
  51060. }
  51061. private function determineBestFormat()
  51062. {
  51063. switch ($this->output->getVerbosity()) {
  51064. case OutputInterface::VERBOSITY_VERBOSE:
  51065. return $this->max ? 'verbose' : 'verbose_nomax';
  51066. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51067. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  51068. case OutputInterface::VERBOSITY_DEBUG:
  51069. return $this->max ? 'debug' : 'debug_nomax';
  51070. default:
  51071. return $this->max ? 'normal' : 'normal_nomax';
  51072. }
  51073. }
  51074. private static function initPlaceholderFormatters()
  51075. {
  51076. return array(
  51077. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  51078. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  51079. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  51080. if ($completeBars < $bar->getBarWidth()) {
  51081. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  51082. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  51083. }
  51084. return $display;
  51085. },
  51086. 'elapsed' => function (ProgressBar $bar) {
  51087. return Helper::formatTime(time() - $bar->getStartTime());
  51088. },
  51089. 'remaining' => function (ProgressBar $bar) {
  51090. if (!$bar->getMaxSteps()) {
  51091. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  51092. }
  51093. if (!$bar->getProgress()) {
  51094. $remaining = 0;
  51095. } else {
  51096. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  51097. }
  51098. return Helper::formatTime($remaining);
  51099. },
  51100. 'estimated' => function (ProgressBar $bar) {
  51101. if (!$bar->getMaxSteps()) {
  51102. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  51103. }
  51104. if (!$bar->getProgress()) {
  51105. $estimated = 0;
  51106. } else {
  51107. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  51108. }
  51109. return Helper::formatTime($estimated);
  51110. },
  51111. 'memory' => function (ProgressBar $bar) {
  51112. return Helper::formatMemory(memory_get_usage(true));
  51113. },
  51114. 'current' => function (ProgressBar $bar) {
  51115. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  51116. },
  51117. 'max' => function (ProgressBar $bar) {
  51118. return $bar->getMaxSteps();
  51119. },
  51120. 'percent' => function (ProgressBar $bar) {
  51121. return floor($bar->getProgressPercent() * 100);
  51122. },
  51123. );
  51124. }
  51125. private static function initFormats()
  51126. {
  51127. return array(
  51128. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  51129. 'normal_nomax' => ' %current% [%bar%]',
  51130. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  51131. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  51132. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  51133. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  51134. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  51135. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  51136. );
  51137. }
  51138. }
  51139. <?php
  51140. namespace Symfony\Component\Console\Helper;
  51141. use Symfony\Component\Console\Exception\LogicException;
  51142. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  51143. use Symfony\Component\Console\Output\NullOutput;
  51144. use Symfony\Component\Console\Output\OutputInterface;
  51145. class ProgressHelper extends Helper
  51146. {
  51147. const FORMAT_QUIET = ' %percent%%';
  51148. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  51149. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  51150. const FORMAT_QUIET_NOMAX = ' %current%';
  51151. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  51152. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  51153. private $barWidth = 28;
  51154. private $barChar = '=';
  51155. private $emptyBarChar = '-';
  51156. private $progressChar = '>';
  51157. private $format = null;
  51158. private $redrawFreq = 1;
  51159. private $lastMessagesLength;
  51160. private $barCharOriginal;
  51161. private $output;
  51162. private $current;
  51163. private $max;
  51164. private $startTime;
  51165. private $defaultFormatVars = array(
  51166. 'current',
  51167. 'max',
  51168. 'bar',
  51169. 'percent',
  51170. 'elapsed',
  51171. );
  51172. private $formatVars;
  51173. private $widths = array(
  51174. 'current' => 4,
  51175. 'max' => 4,
  51176. 'percent' => 3,
  51177. 'elapsed' => 6,
  51178. );
  51179. private $timeFormats = array(
  51180. array(0, '???'),
  51181. array(2, '1 sec'),
  51182. array(59, 'secs', 1),
  51183. array(60, '1 min'),
  51184. array(3600, 'mins', 60),
  51185. array(5400, '1 hr'),
  51186. array(86400, 'hrs', 3600),
  51187. array(129600, '1 day'),
  51188. array(604800, 'days', 86400),
  51189. );
  51190. public function __construct($triggerDeprecationError = true)
  51191. {
  51192. if ($triggerDeprecationError) {
  51193. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\Console\Helper\ProgressBar class instead.', E_USER_DEPRECATED);
  51194. }
  51195. }
  51196. public function setBarWidth($size)
  51197. {
  51198. $this->barWidth = (int) $size;
  51199. }
  51200. public function setBarCharacter($char)
  51201. {
  51202. $this->barChar = $char;
  51203. }
  51204. public function setEmptyBarCharacter($char)
  51205. {
  51206. $this->emptyBarChar = $char;
  51207. }
  51208. public function setProgressCharacter($char)
  51209. {
  51210. $this->progressChar = $char;
  51211. }
  51212. public function setFormat($format)
  51213. {
  51214. $this->format = $format;
  51215. }
  51216. public function setRedrawFrequency($freq)
  51217. {
  51218. $this->redrawFreq = (int) $freq;
  51219. }
  51220. public function start(OutputInterface $output, $max = null)
  51221. {
  51222. if ($output instanceof ConsoleOutputInterface) {
  51223. $output = $output->getErrorOutput();
  51224. }
  51225. $this->startTime = time();
  51226. $this->current = 0;
  51227. $this->max = (int) $max;
  51228. $this->output = $output->isDecorated() ? $output : new NullOutput();
  51229. $this->lastMessagesLength = 0;
  51230. $this->barCharOriginal = '';
  51231. if (null === $this->format) {
  51232. switch ($output->getVerbosity()) {
  51233. case OutputInterface::VERBOSITY_QUIET:
  51234. $this->format = self::FORMAT_QUIET_NOMAX;
  51235. if ($this->max > 0) {
  51236. $this->format = self::FORMAT_QUIET;
  51237. }
  51238. break;
  51239. case OutputInterface::VERBOSITY_VERBOSE:
  51240. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51241. case OutputInterface::VERBOSITY_DEBUG:
  51242. $this->format = self::FORMAT_VERBOSE_NOMAX;
  51243. if ($this->max > 0) {
  51244. $this->format = self::FORMAT_VERBOSE;
  51245. }
  51246. break;
  51247. default:
  51248. $this->format = self::FORMAT_NORMAL_NOMAX;
  51249. if ($this->max > 0) {
  51250. $this->format = self::FORMAT_NORMAL;
  51251. }
  51252. break;
  51253. }
  51254. }
  51255. $this->initialize();
  51256. }
  51257. public function advance($step = 1, $redraw = false)
  51258. {
  51259. $this->setCurrent($this->current + $step, $redraw);
  51260. }
  51261. public function setCurrent($current, $redraw = false)
  51262. {
  51263. if (null === $this->startTime) {
  51264. throw new LogicException('You must start the progress bar before calling setCurrent().');
  51265. }
  51266. $current = (int) $current;
  51267. if ($current < $this->current) {
  51268. throw new LogicException('You can\'t regress the progress bar');
  51269. }
  51270. if (0 === $this->current) {
  51271. $redraw = true;
  51272. }
  51273. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  51274. $this->current = $current;
  51275. $currPeriod = (int) ($this->current / $this->redrawFreq);
  51276. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  51277. $this->display();
  51278. }
  51279. }
  51280. public function display($finish = false)
  51281. {
  51282. if (null === $this->startTime) {
  51283. throw new LogicException('You must start the progress bar before calling display().');
  51284. }
  51285. $message = $this->format;
  51286. foreach ($this->generate($finish) as $name => $value) {
  51287. $message = str_replace("%{$name}%", $value, $message);
  51288. }
  51289. $this->overwrite($this->output, $message);
  51290. }
  51291. public function clear()
  51292. {
  51293. $this->overwrite($this->output, '');
  51294. }
  51295. public function finish()
  51296. {
  51297. if (null === $this->startTime) {
  51298. throw new LogicException('You must start the progress bar before calling finish().');
  51299. }
  51300. if (null !== $this->startTime) {
  51301. if (!$this->max) {
  51302. $this->barChar = $this->barCharOriginal;
  51303. $this->display(true);
  51304. }
  51305. $this->startTime = null;
  51306. $this->output->writeln('');
  51307. $this->output = null;
  51308. }
  51309. }
  51310. private function initialize()
  51311. {
  51312. $this->formatVars = array();
  51313. foreach ($this->defaultFormatVars as $var) {
  51314. if (false !== strpos($this->format, "%{$var}%")) {
  51315. $this->formatVars[$var] = true;
  51316. }
  51317. }
  51318. if ($this->max > 0) {
  51319. $this->widths['max'] = $this->strlen($this->max);
  51320. $this->widths['current'] = $this->widths['max'];
  51321. } else {
  51322. $this->barCharOriginal = $this->barChar;
  51323. $this->barChar = $this->emptyBarChar;
  51324. }
  51325. }
  51326. private function generate($finish = false)
  51327. {
  51328. $vars = array();
  51329. $percent = 0;
  51330. if ($this->max > 0) {
  51331. $percent = (float) $this->current / $this->max;
  51332. }
  51333. if (isset($this->formatVars['bar'])) {
  51334. if ($this->max > 0) {
  51335. $completeBars = floor($percent * $this->barWidth);
  51336. } else {
  51337. if (!$finish) {
  51338. $completeBars = floor($this->current % $this->barWidth);
  51339. } else {
  51340. $completeBars = $this->barWidth;
  51341. }
  51342. }
  51343. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  51344. $bar = str_repeat($this->barChar, $completeBars);
  51345. if ($completeBars < $this->barWidth) {
  51346. $bar .= $this->progressChar;
  51347. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  51348. }
  51349. $vars['bar'] = $bar;
  51350. }
  51351. if (isset($this->formatVars['elapsed'])) {
  51352. $elapsed = time() - $this->startTime;
  51353. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  51354. }
  51355. if (isset($this->formatVars['current'])) {
  51356. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  51357. }
  51358. if (isset($this->formatVars['max'])) {
  51359. $vars['max'] = $this->max;
  51360. }
  51361. if (isset($this->formatVars['percent'])) {
  51362. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  51363. }
  51364. return $vars;
  51365. }
  51366. private function humaneTime($secs)
  51367. {
  51368. $text = '';
  51369. foreach ($this->timeFormats as $format) {
  51370. if ($secs < $format[0]) {
  51371. if (2 == \count($format)) {
  51372. $text = $format[1];
  51373. break;
  51374. } else {
  51375. $text = ceil($secs / $format[2]).' '.$format[1];
  51376. break;
  51377. }
  51378. }
  51379. }
  51380. return $text;
  51381. }
  51382. private function overwrite(OutputInterface $output, $message)
  51383. {
  51384. $length = $this->strlen($message);
  51385. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  51386. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  51387. }
  51388. $output->write("\x0D");
  51389. $output->write($message);
  51390. $this->lastMessagesLength = $this->strlen($message);
  51391. }
  51392. public function getName()
  51393. {
  51394. return 'progress';
  51395. }
  51396. }
  51397. <?php
  51398. namespace Symfony\Component\Console\Helper;
  51399. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51400. use Symfony\Component\Console\Exception\LogicException;
  51401. use Symfony\Component\Console\Output\OutputInterface;
  51402. class ProgressIndicator
  51403. {
  51404. private $output;
  51405. private $startTime;
  51406. private $format;
  51407. private $message;
  51408. private $indicatorValues;
  51409. private $indicatorCurrent;
  51410. private $indicatorChangeInterval;
  51411. private $indicatorUpdateTime;
  51412. private $started = false;
  51413. private static $formatters;
  51414. private static $formats;
  51415. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  51416. {
  51417. $this->output = $output;
  51418. if (null === $format) {
  51419. $format = $this->determineBestFormat();
  51420. }
  51421. if (null === $indicatorValues) {
  51422. $indicatorValues = array('-', '\\', '|', '/');
  51423. }
  51424. $indicatorValues = array_values($indicatorValues);
  51425. if (2 > \count($indicatorValues)) {
  51426. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  51427. }
  51428. $this->format = self::getFormatDefinition($format);
  51429. $this->indicatorChangeInterval = $indicatorChangeInterval;
  51430. $this->indicatorValues = $indicatorValues;
  51431. $this->startTime = time();
  51432. }
  51433. public function setMessage($message)
  51434. {
  51435. $this->message = $message;
  51436. $this->display();
  51437. }
  51438. public function getMessage()
  51439. {
  51440. return $this->message;
  51441. }
  51442. public function getStartTime()
  51443. {
  51444. return $this->startTime;
  51445. }
  51446. public function getCurrentValue()
  51447. {
  51448. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  51449. }
  51450. public function start($message)
  51451. {
  51452. if ($this->started) {
  51453. throw new LogicException('Progress indicator already started.');
  51454. }
  51455. $this->message = $message;
  51456. $this->started = true;
  51457. $this->startTime = time();
  51458. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  51459. $this->indicatorCurrent = 0;
  51460. $this->display();
  51461. }
  51462. public function advance()
  51463. {
  51464. if (!$this->started) {
  51465. throw new LogicException('Progress indicator has not yet been started.');
  51466. }
  51467. if (!$this->output->isDecorated()) {
  51468. return;
  51469. }
  51470. $currentTime = $this->getCurrentTimeInMilliseconds();
  51471. if ($currentTime < $this->indicatorUpdateTime) {
  51472. return;
  51473. }
  51474. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  51475. ++$this->indicatorCurrent;
  51476. $this->display();
  51477. }
  51478. public function finish($message)
  51479. {
  51480. if (!$this->started) {
  51481. throw new LogicException('Progress indicator has not yet been started.');
  51482. }
  51483. $this->message = $message;
  51484. $this->display();
  51485. $this->output->writeln('');
  51486. $this->started = false;
  51487. }
  51488. public static function getFormatDefinition($name)
  51489. {
  51490. if (!self::$formats) {
  51491. self::$formats = self::initFormats();
  51492. }
  51493. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  51494. }
  51495. public static function setPlaceholderFormatterDefinition($name, $callable)
  51496. {
  51497. if (!self::$formatters) {
  51498. self::$formatters = self::initPlaceholderFormatters();
  51499. }
  51500. self::$formatters[$name] = $callable;
  51501. }
  51502. public static function getPlaceholderFormatterDefinition($name)
  51503. {
  51504. if (!self::$formatters) {
  51505. self::$formatters = self::initPlaceholderFormatters();
  51506. }
  51507. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  51508. }
  51509. private function display()
  51510. {
  51511. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  51512. return;
  51513. }
  51514. $self = $this;
  51515. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  51516. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  51517. return \call_user_func($formatter, $self);
  51518. }
  51519. return $matches[0];
  51520. }, $this->format));
  51521. }
  51522. private function determineBestFormat()
  51523. {
  51524. switch ($this->output->getVerbosity()) {
  51525. case OutputInterface::VERBOSITY_VERBOSE:
  51526. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  51527. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51528. case OutputInterface::VERBOSITY_DEBUG:
  51529. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  51530. default:
  51531. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  51532. }
  51533. }
  51534. private function overwrite($message)
  51535. {
  51536. if ($this->output->isDecorated()) {
  51537. $this->output->write("\x0D\x1B[2K");
  51538. $this->output->write($message);
  51539. } else {
  51540. $this->output->writeln($message);
  51541. }
  51542. }
  51543. private function getCurrentTimeInMilliseconds()
  51544. {
  51545. return round(microtime(true) * 1000);
  51546. }
  51547. private static function initPlaceholderFormatters()
  51548. {
  51549. return array(
  51550. 'indicator' => function (ProgressIndicator $indicator) {
  51551. return $indicator->getCurrentValue();
  51552. },
  51553. 'message' => function (ProgressIndicator $indicator) {
  51554. return $indicator->getMessage();
  51555. },
  51556. 'elapsed' => function (ProgressIndicator $indicator) {
  51557. return Helper::formatTime(time() - $indicator->getStartTime());
  51558. },
  51559. 'memory' => function () {
  51560. return Helper::formatMemory(memory_get_usage(true));
  51561. },
  51562. );
  51563. }
  51564. private static function initFormats()
  51565. {
  51566. return array(
  51567. 'normal' => ' %indicator% %message%',
  51568. 'normal_no_ansi' => ' %message%',
  51569. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  51570. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  51571. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  51572. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  51573. );
  51574. }
  51575. }
  51576. <?php
  51577. namespace Symfony\Component\Console\Helper;
  51578. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51579. use Symfony\Component\Console\Exception\RuntimeException;
  51580. use Symfony\Component\Console\Formatter\OutputFormatter;
  51581. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  51582. use Symfony\Component\Console\Input\InputInterface;
  51583. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  51584. use Symfony\Component\Console\Output\OutputInterface;
  51585. use Symfony\Component\Console\Question\ChoiceQuestion;
  51586. use Symfony\Component\Console\Question\Question;
  51587. class QuestionHelper extends Helper
  51588. {
  51589. private $inputStream;
  51590. private static $shell;
  51591. private static $stty;
  51592. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51593. {
  51594. if ($output instanceof ConsoleOutputInterface) {
  51595. $output = $output->getErrorOutput();
  51596. }
  51597. if (!$input->isInteractive()) {
  51598. $default = $question->getDefault();
  51599. if (null !== $default && $question instanceof ChoiceQuestion) {
  51600. $choices = $question->getChoices();
  51601. if (!$question->isMultiselect()) {
  51602. return isset($choices[$default]) ? $choices[$default] : $default;
  51603. }
  51604. $default = explode(',', $default);
  51605. foreach ($default as $k => $v) {
  51606. $v = trim($v);
  51607. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  51608. }
  51609. }
  51610. return $default;
  51611. }
  51612. if (!$question->getValidator()) {
  51613. return $this->doAsk($output, $question);
  51614. }
  51615. $that = $this;
  51616. $interviewer = function () use ($output, $question, $that) {
  51617. return $that->doAsk($output, $question);
  51618. };
  51619. return $this->validateAttempts($interviewer, $output, $question);
  51620. }
  51621. public function setInputStream($stream)
  51622. {
  51623. if (!\is_resource($stream)) {
  51624. throw new InvalidArgumentException('Input stream must be a valid resource.');
  51625. }
  51626. $this->inputStream = $stream;
  51627. }
  51628. public function getInputStream()
  51629. {
  51630. return $this->inputStream;
  51631. }
  51632. public function getName()
  51633. {
  51634. return 'question';
  51635. }
  51636. public function doAsk(OutputInterface $output, Question $question)
  51637. {
  51638. $this->writePrompt($output, $question);
  51639. $inputStream = $this->inputStream ?: STDIN;
  51640. $autocomplete = $question->getAutocompleterValues();
  51641. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  51642. $ret = false;
  51643. if ($question->isHidden()) {
  51644. try {
  51645. $ret = trim($this->getHiddenResponse($output, $inputStream));
  51646. } catch (RuntimeException $e) {
  51647. if (!$question->isHiddenFallback()) {
  51648. throw $e;
  51649. }
  51650. }
  51651. }
  51652. if (false === $ret) {
  51653. $ret = fgets($inputStream, 4096);
  51654. if (false === $ret) {
  51655. throw new RuntimeException('Aborted');
  51656. }
  51657. $ret = trim($ret);
  51658. }
  51659. } else {
  51660. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  51661. }
  51662. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  51663. if ($normalizer = $question->getNormalizer()) {
  51664. return $normalizer($ret);
  51665. }
  51666. return $ret;
  51667. }
  51668. protected function writePrompt(OutputInterface $output, Question $question)
  51669. {
  51670. $message = $question->getQuestion();
  51671. if ($question instanceof ChoiceQuestion) {
  51672. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  51673. $messages = (array) $question->getQuestion();
  51674. foreach ($question->getChoices() as $key => $value) {
  51675. $width = $maxWidth - $this->strlen($key);
  51676. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  51677. }
  51678. $output->writeln($messages);
  51679. $message = $question->getPrompt();
  51680. }
  51681. $output->write($message);
  51682. }
  51683. protected function writeError(OutputInterface $output, \Exception $error)
  51684. {
  51685. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  51686. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  51687. } else {
  51688. $message = '<error>'.$error->getMessage().'</error>';
  51689. }
  51690. $output->writeln($message);
  51691. }
  51692. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  51693. {
  51694. $ret = '';
  51695. $i = 0;
  51696. $ofs = -1;
  51697. $matches = $autocomplete;
  51698. $numMatches = \count($matches);
  51699. $sttyMode = shell_exec('stty -g');
  51700. shell_exec('stty -icanon -echo');
  51701. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  51702. while (!feof($inputStream)) {
  51703. $c = fread($inputStream, 1);
  51704. if ("\177" === $c) {
  51705. if (0 === $numMatches && 0 !== $i) {
  51706. --$i;
  51707. $output->write("\033[1D");
  51708. }
  51709. if (0 === $i) {
  51710. $ofs = -1;
  51711. $matches = $autocomplete;
  51712. $numMatches = \count($matches);
  51713. } else {
  51714. $numMatches = 0;
  51715. }
  51716. $ret = substr($ret, 0, $i);
  51717. } elseif ("\033" === $c) {
  51718. $c .= fread($inputStream, 2);
  51719. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  51720. if ('A' === $c[2] && -1 === $ofs) {
  51721. $ofs = 0;
  51722. }
  51723. if (0 === $numMatches) {
  51724. continue;
  51725. }
  51726. $ofs += ('A' === $c[2]) ? -1 : 1;
  51727. $ofs = ($numMatches + $ofs) % $numMatches;
  51728. }
  51729. } elseif (\ord($c) < 32) {
  51730. if ("\t" === $c || "\n" === $c) {
  51731. if ($numMatches > 0 && -1 !== $ofs) {
  51732. $ret = $matches[$ofs];
  51733. $output->write(substr($ret, $i));
  51734. $i = \strlen($ret);
  51735. }
  51736. if ("\n" === $c) {
  51737. $output->write($c);
  51738. break;
  51739. }
  51740. $numMatches = 0;
  51741. }
  51742. continue;
  51743. } else {
  51744. $output->write($c);
  51745. $ret .= $c;
  51746. ++$i;
  51747. $numMatches = 0;
  51748. $ofs = 0;
  51749. foreach ($autocomplete as $value) {
  51750. if (0 === strpos($value, $ret)) {
  51751. $matches[$numMatches++] = $value;
  51752. }
  51753. }
  51754. }
  51755. $output->write("\033[K");
  51756. if ($numMatches > 0 && -1 !== $ofs) {
  51757. $output->write("\0337");
  51758. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  51759. $output->write("\0338");
  51760. }
  51761. }
  51762. shell_exec(sprintf('stty %s', $sttyMode));
  51763. return $ret;
  51764. }
  51765. private function getHiddenResponse(OutputInterface $output, $inputStream)
  51766. {
  51767. if ('\\' === \DIRECTORY_SEPARATOR) {
  51768. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  51769. if ('phar:' === substr(__FILE__, 0, 5)) {
  51770. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  51771. copy($exe, $tmpExe);
  51772. $exe = $tmpExe;
  51773. }
  51774. $value = rtrim(shell_exec($exe));
  51775. $output->writeln('');
  51776. if (isset($tmpExe)) {
  51777. unlink($tmpExe);
  51778. }
  51779. return $value;
  51780. }
  51781. if ($this->hasSttyAvailable()) {
  51782. $sttyMode = shell_exec('stty -g');
  51783. shell_exec('stty -echo');
  51784. $value = fgets($inputStream, 4096);
  51785. shell_exec(sprintf('stty %s', $sttyMode));
  51786. if (false === $value) {
  51787. throw new RuntimeException('Aborted');
  51788. }
  51789. $value = trim($value);
  51790. $output->writeln('');
  51791. return $value;
  51792. }
  51793. if (false !== $shell = $this->getShell()) {
  51794. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  51795. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  51796. $value = rtrim(shell_exec($command));
  51797. $output->writeln('');
  51798. return $value;
  51799. }
  51800. throw new RuntimeException('Unable to hide the response.');
  51801. }
  51802. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  51803. {
  51804. $error = null;
  51805. $attempts = $question->getMaxAttempts();
  51806. while (null === $attempts || $attempts--) {
  51807. if (null !== $error) {
  51808. $this->writeError($output, $error);
  51809. }
  51810. try {
  51811. return \call_user_func($question->getValidator(), $interviewer());
  51812. } catch (RuntimeException $e) {
  51813. throw $e;
  51814. } catch (\Exception $error) {
  51815. }
  51816. }
  51817. throw $error;
  51818. }
  51819. private function getShell()
  51820. {
  51821. if (null !== self::$shell) {
  51822. return self::$shell;
  51823. }
  51824. self::$shell = false;
  51825. if (file_exists('/usr/bin/env')) {
  51826. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  51827. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  51828. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  51829. self::$shell = $sh;
  51830. break;
  51831. }
  51832. }
  51833. }
  51834. return self::$shell;
  51835. }
  51836. private function hasSttyAvailable()
  51837. {
  51838. if (null !== self::$stty) {
  51839. return self::$stty;
  51840. }
  51841. exec('stty 2>&1', $output, $exitcode);
  51842. return self::$stty = 0 === $exitcode;
  51843. }
  51844. }
  51845. <?php
  51846. namespace Symfony\Component\Console\Helper;
  51847. use Symfony\Component\Console\Exception\LogicException;
  51848. use Symfony\Component\Console\Formatter\OutputFormatter;
  51849. use Symfony\Component\Console\Input\InputInterface;
  51850. use Symfony\Component\Console\Output\OutputInterface;
  51851. use Symfony\Component\Console\Question\ChoiceQuestion;
  51852. use Symfony\Component\Console\Question\ConfirmationQuestion;
  51853. use Symfony\Component\Console\Question\Question;
  51854. use Symfony\Component\Console\Style\SymfonyStyle;
  51855. class SymfonyQuestionHelper extends QuestionHelper
  51856. {
  51857. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51858. {
  51859. $validator = $question->getValidator();
  51860. $question->setValidator(function ($value) use ($validator) {
  51861. if (null !== $validator) {
  51862. $value = $validator($value);
  51863. } else {
  51864. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  51865. throw new LogicException('A value is required.');
  51866. }
  51867. }
  51868. return $value;
  51869. });
  51870. return parent::ask($input, $output, $question);
  51871. }
  51872. protected function writePrompt(OutputInterface $output, Question $question)
  51873. {
  51874. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  51875. $default = $question->getDefault();
  51876. switch (true) {
  51877. case null === $default:
  51878. $text = sprintf(' <info>%s</info>:', $text);
  51879. break;
  51880. case $question instanceof ConfirmationQuestion:
  51881. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  51882. break;
  51883. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  51884. $choices = $question->getChoices();
  51885. $default = explode(',', $default);
  51886. foreach ($default as $key => $value) {
  51887. $default[$key] = $choices[trim($value)];
  51888. }
  51889. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  51890. break;
  51891. case $question instanceof ChoiceQuestion:
  51892. $choices = $question->getChoices();
  51893. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  51894. break;
  51895. default:
  51896. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  51897. }
  51898. $output->writeln($text);
  51899. if ($question instanceof ChoiceQuestion) {
  51900. $width = max(array_map('strlen', array_keys($question->getChoices())));
  51901. foreach ($question->getChoices() as $key => $value) {
  51902. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  51903. }
  51904. }
  51905. $output->write(' > ');
  51906. }
  51907. protected function writeError(OutputInterface $output, \Exception $error)
  51908. {
  51909. if ($output instanceof SymfonyStyle) {
  51910. $output->newLine();
  51911. $output->error($error->getMessage());
  51912. return;
  51913. }
  51914. parent::writeError($output, $error);
  51915. }
  51916. }
  51917. <?php
  51918. namespace Symfony\Component\Console\Helper;
  51919. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51920. use Symfony\Component\Console\Output\OutputInterface;
  51921. class Table
  51922. {
  51923. private $headers = array();
  51924. private $rows = array();
  51925. private $columnWidths = array();
  51926. private $numberOfColumns;
  51927. private $output;
  51928. private $style;
  51929. private $columnStyles = array();
  51930. private static $styles;
  51931. public function __construct(OutputInterface $output)
  51932. {
  51933. $this->output = $output;
  51934. if (!self::$styles) {
  51935. self::$styles = self::initStyles();
  51936. }
  51937. $this->setStyle('default');
  51938. }
  51939. public static function setStyleDefinition($name, TableStyle $style)
  51940. {
  51941. if (!self::$styles) {
  51942. self::$styles = self::initStyles();
  51943. }
  51944. self::$styles[$name] = $style;
  51945. }
  51946. public static function getStyleDefinition($name)
  51947. {
  51948. if (!self::$styles) {
  51949. self::$styles = self::initStyles();
  51950. }
  51951. if (isset(self::$styles[$name])) {
  51952. return self::$styles[$name];
  51953. }
  51954. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  51955. }
  51956. public function setStyle($name)
  51957. {
  51958. $this->style = $this->resolveStyle($name);
  51959. return $this;
  51960. }
  51961. public function getStyle()
  51962. {
  51963. return $this->style;
  51964. }
  51965. public function setColumnStyle($columnIndex, $name)
  51966. {
  51967. $columnIndex = (int) $columnIndex;
  51968. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  51969. return $this;
  51970. }
  51971. public function getColumnStyle($columnIndex)
  51972. {
  51973. if (isset($this->columnStyles[$columnIndex])) {
  51974. return $this->columnStyles[$columnIndex];
  51975. }
  51976. return $this->getStyle();
  51977. }
  51978. public function setHeaders(array $headers)
  51979. {
  51980. $headers = array_values($headers);
  51981. if (!empty($headers) && !\is_array($headers[0])) {
  51982. $headers = array($headers);
  51983. }
  51984. $this->headers = $headers;
  51985. return $this;
  51986. }
  51987. public function setRows(array $rows)
  51988. {
  51989. $this->rows = array();
  51990. return $this->addRows($rows);
  51991. }
  51992. public function addRows(array $rows)
  51993. {
  51994. foreach ($rows as $row) {
  51995. $this->addRow($row);
  51996. }
  51997. return $this;
  51998. }
  51999. public function addRow($row)
  52000. {
  52001. if ($row instanceof TableSeparator) {
  52002. $this->rows[] = $row;
  52003. return $this;
  52004. }
  52005. if (!\is_array($row)) {
  52006. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  52007. }
  52008. $this->rows[] = array_values($row);
  52009. return $this;
  52010. }
  52011. public function setRow($column, array $row)
  52012. {
  52013. $this->rows[$column] = $row;
  52014. return $this;
  52015. }
  52016. public function render()
  52017. {
  52018. $this->calculateNumberOfColumns();
  52019. $rows = $this->buildTableRows($this->rows);
  52020. $headers = $this->buildTableRows($this->headers);
  52021. $this->calculateColumnsWidth(array_merge($headers, $rows));
  52022. $this->renderRowSeparator();
  52023. if (!empty($headers)) {
  52024. foreach ($headers as $header) {
  52025. $this->renderRow($header, $this->style->getCellHeaderFormat());
  52026. $this->renderRowSeparator();
  52027. }
  52028. }
  52029. foreach ($rows as $row) {
  52030. if ($row instanceof TableSeparator) {
  52031. $this->renderRowSeparator();
  52032. } else {
  52033. $this->renderRow($row, $this->style->getCellRowFormat());
  52034. }
  52035. }
  52036. if (!empty($rows)) {
  52037. $this->renderRowSeparator();
  52038. }
  52039. $this->cleanup();
  52040. }
  52041. private function renderRowSeparator()
  52042. {
  52043. if (0 === $count = $this->numberOfColumns) {
  52044. return;
  52045. }
  52046. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  52047. return;
  52048. }
  52049. $markup = $this->style->getCrossingChar();
  52050. for ($column = 0; $column < $count; ++$column) {
  52051. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  52052. }
  52053. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  52054. }
  52055. private function renderColumnSeparator()
  52056. {
  52057. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  52058. }
  52059. private function renderRow(array $row, $cellFormat)
  52060. {
  52061. if (empty($row)) {
  52062. return;
  52063. }
  52064. $rowContent = $this->renderColumnSeparator();
  52065. foreach ($this->getRowColumns($row) as $column) {
  52066. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  52067. $rowContent .= $this->renderColumnSeparator();
  52068. }
  52069. $this->output->writeln($rowContent);
  52070. }
  52071. private function renderCell(array $row, $column, $cellFormat)
  52072. {
  52073. $cell = isset($row[$column]) ? $row[$column] : '';
  52074. $width = $this->columnWidths[$column];
  52075. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  52076. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  52077. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  52078. }
  52079. }
  52080. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  52081. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  52082. }
  52083. $style = $this->getColumnStyle($column);
  52084. if ($cell instanceof TableSeparator) {
  52085. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  52086. }
  52087. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  52088. $content = sprintf($style->getCellRowContentFormat(), $cell);
  52089. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  52090. }
  52091. private function calculateNumberOfColumns()
  52092. {
  52093. if (null !== $this->numberOfColumns) {
  52094. return;
  52095. }
  52096. $columns = array(0);
  52097. foreach (array_merge($this->headers, $this->rows) as $row) {
  52098. if ($row instanceof TableSeparator) {
  52099. continue;
  52100. }
  52101. $columns[] = $this->getNumberOfColumns($row);
  52102. }
  52103. $this->numberOfColumns = max($columns);
  52104. }
  52105. private function buildTableRows($rows)
  52106. {
  52107. $unmergedRows = array();
  52108. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  52109. $rows = $this->fillNextRows($rows, $rowKey);
  52110. foreach ($rows[$rowKey] as $column => $cell) {
  52111. if (!strstr($cell, "\n")) {
  52112. continue;
  52113. }
  52114. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  52115. foreach ($lines as $lineKey => $line) {
  52116. if ($cell instanceof TableCell) {
  52117. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  52118. }
  52119. if (0 === $lineKey) {
  52120. $rows[$rowKey][$column] = $line;
  52121. } else {
  52122. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  52123. }
  52124. }
  52125. }
  52126. }
  52127. $tableRows = array();
  52128. foreach ($rows as $rowKey => $row) {
  52129. $tableRows[] = $this->fillCells($row);
  52130. if (isset($unmergedRows[$rowKey])) {
  52131. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  52132. }
  52133. }
  52134. return $tableRows;
  52135. }
  52136. private function fillNextRows(array $rows, $line)
  52137. {
  52138. $unmergedRows = array();
  52139. foreach ($rows[$line] as $column => $cell) {
  52140. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  52141. $nbLines = $cell->getRowspan() - 1;
  52142. $lines = array($cell);
  52143. if (strstr($cell, "\n")) {
  52144. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  52145. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  52146. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  52147. unset($lines[0]);
  52148. }
  52149. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  52150. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  52151. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  52152. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  52153. if ($nbLines === $unmergedRowKey - $line) {
  52154. break;
  52155. }
  52156. }
  52157. }
  52158. }
  52159. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  52160. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  52161. foreach ($unmergedRow as $cellKey => $cell) {
  52162. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  52163. }
  52164. } else {
  52165. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  52166. foreach ($unmergedRow as $column => $cell) {
  52167. if (!empty($cell)) {
  52168. $row[$column] = $unmergedRow[$column];
  52169. }
  52170. }
  52171. array_splice($rows, $unmergedRowKey, 0, array($row));
  52172. }
  52173. }
  52174. return $rows;
  52175. }
  52176. private function fillCells($row)
  52177. {
  52178. $newRow = array();
  52179. foreach ($row as $column => $cell) {
  52180. $newRow[] = $cell;
  52181. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  52182. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  52183. $newRow[] = '';
  52184. }
  52185. }
  52186. }
  52187. return $newRow ?: $row;
  52188. }
  52189. private function copyRow(array $rows, $line)
  52190. {
  52191. $row = $rows[$line];
  52192. foreach ($row as $cellKey => $cellValue) {
  52193. $row[$cellKey] = '';
  52194. if ($cellValue instanceof TableCell) {
  52195. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  52196. }
  52197. }
  52198. return $row;
  52199. }
  52200. private function getNumberOfColumns(array $row)
  52201. {
  52202. $columns = \count($row);
  52203. foreach ($row as $column) {
  52204. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  52205. }
  52206. return $columns;
  52207. }
  52208. private function getRowColumns(array $row)
  52209. {
  52210. $columns = range(0, $this->numberOfColumns - 1);
  52211. foreach ($row as $cellKey => $cell) {
  52212. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  52213. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  52214. }
  52215. }
  52216. return $columns;
  52217. }
  52218. private function calculateColumnsWidth($rows)
  52219. {
  52220. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  52221. $lengths = array();
  52222. foreach ($rows as $row) {
  52223. if ($row instanceof TableSeparator) {
  52224. continue;
  52225. }
  52226. foreach ($row as $i => $cell) {
  52227. if ($cell instanceof TableCell) {
  52228. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  52229. $textLength = Helper::strlen($textContent);
  52230. if ($textLength > 0) {
  52231. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  52232. foreach ($contentColumns as $position => $content) {
  52233. $row[$i + $position] = $content;
  52234. }
  52235. }
  52236. }
  52237. }
  52238. $lengths[] = $this->getCellWidth($row, $column);
  52239. }
  52240. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  52241. }
  52242. }
  52243. private function getColumnSeparatorWidth()
  52244. {
  52245. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  52246. }
  52247. private function getCellWidth(array $row, $column)
  52248. {
  52249. if (isset($row[$column])) {
  52250. $cell = $row[$column];
  52251. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  52252. return $cellWidth;
  52253. }
  52254. return 0;
  52255. }
  52256. private function cleanup()
  52257. {
  52258. $this->columnWidths = array();
  52259. $this->numberOfColumns = null;
  52260. }
  52261. private static function initStyles()
  52262. {
  52263. $borderless = new TableStyle();
  52264. $borderless
  52265. ->setHorizontalBorderChar('=')
  52266. ->setVerticalBorderChar(' ')
  52267. ->setCrossingChar(' ')
  52268. ;
  52269. $compact = new TableStyle();
  52270. $compact
  52271. ->setHorizontalBorderChar('')
  52272. ->setVerticalBorderChar(' ')
  52273. ->setCrossingChar('')
  52274. ->setCellRowContentFormat('%s')
  52275. ;
  52276. $styleGuide = new TableStyle();
  52277. $styleGuide
  52278. ->setHorizontalBorderChar('-')
  52279. ->setVerticalBorderChar(' ')
  52280. ->setCrossingChar(' ')
  52281. ->setCellHeaderFormat('%s')
  52282. ;
  52283. return array(
  52284. 'default' => new TableStyle(),
  52285. 'borderless' => $borderless,
  52286. 'compact' => $compact,
  52287. 'symfony-style-guide' => $styleGuide,
  52288. );
  52289. }
  52290. private function resolveStyle($name)
  52291. {
  52292. if ($name instanceof TableStyle) {
  52293. return $name;
  52294. }
  52295. if (isset(self::$styles[$name])) {
  52296. return self::$styles[$name];
  52297. }
  52298. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  52299. }
  52300. }
  52301. <?php
  52302. namespace Symfony\Component\Console\Helper;
  52303. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52304. class TableCell
  52305. {
  52306. private $value;
  52307. private $options = array(
  52308. 'rowspan' => 1,
  52309. 'colspan' => 1,
  52310. );
  52311. public function __construct($value = '', array $options = array())
  52312. {
  52313. if (is_numeric($value) && !\is_string($value)) {
  52314. $value = (string) $value;
  52315. }
  52316. $this->value = $value;
  52317. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  52318. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  52319. }
  52320. $this->options = array_merge($this->options, $options);
  52321. }
  52322. public function __toString()
  52323. {
  52324. return $this->value;
  52325. }
  52326. public function getColspan()
  52327. {
  52328. return (int) $this->options['colspan'];
  52329. }
  52330. public function getRowspan()
  52331. {
  52332. return (int) $this->options['rowspan'];
  52333. }
  52334. }
  52335. <?php
  52336. namespace Symfony\Component\Console\Helper;
  52337. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52338. use Symfony\Component\Console\Output\NullOutput;
  52339. use Symfony\Component\Console\Output\OutputInterface;
  52340. class TableHelper extends Helper
  52341. {
  52342. const LAYOUT_DEFAULT = 0;
  52343. const LAYOUT_BORDERLESS = 1;
  52344. const LAYOUT_COMPACT = 2;
  52345. private $table;
  52346. public function __construct($triggerDeprecationError = true)
  52347. {
  52348. if ($triggerDeprecationError) {
  52349. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.5 and will be removed in 3.0. Use the Symfony\Component\Console\Helper\Table class instead.', E_USER_DEPRECATED);
  52350. }
  52351. $this->table = new Table(new NullOutput());
  52352. }
  52353. public function setLayout($layout)
  52354. {
  52355. switch ($layout) {
  52356. case self::LAYOUT_BORDERLESS:
  52357. $this->table->setStyle('borderless');
  52358. break;
  52359. case self::LAYOUT_COMPACT:
  52360. $this->table->setStyle('compact');
  52361. break;
  52362. case self::LAYOUT_DEFAULT:
  52363. $this->table->setStyle('default');
  52364. break;
  52365. default:
  52366. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  52367. }
  52368. return $this;
  52369. }
  52370. public function setHeaders(array $headers)
  52371. {
  52372. $this->table->setHeaders($headers);
  52373. return $this;
  52374. }
  52375. public function setRows(array $rows)
  52376. {
  52377. $this->table->setRows($rows);
  52378. return $this;
  52379. }
  52380. public function addRows(array $rows)
  52381. {
  52382. $this->table->addRows($rows);
  52383. return $this;
  52384. }
  52385. public function addRow(array $row)
  52386. {
  52387. $this->table->addRow($row);
  52388. return $this;
  52389. }
  52390. public function setRow($column, array $row)
  52391. {
  52392. $this->table->setRow($column, $row);
  52393. return $this;
  52394. }
  52395. public function setPaddingChar($paddingChar)
  52396. {
  52397. $this->table->getStyle()->setPaddingChar($paddingChar);
  52398. return $this;
  52399. }
  52400. public function setHorizontalBorderChar($horizontalBorderChar)
  52401. {
  52402. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  52403. return $this;
  52404. }
  52405. public function setVerticalBorderChar($verticalBorderChar)
  52406. {
  52407. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  52408. return $this;
  52409. }
  52410. public function setCrossingChar($crossingChar)
  52411. {
  52412. $this->table->getStyle()->setCrossingChar($crossingChar);
  52413. return $this;
  52414. }
  52415. public function setCellHeaderFormat($cellHeaderFormat)
  52416. {
  52417. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  52418. return $this;
  52419. }
  52420. public function setCellRowFormat($cellRowFormat)
  52421. {
  52422. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  52423. return $this;
  52424. }
  52425. public function setCellRowContentFormat($cellRowContentFormat)
  52426. {
  52427. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  52428. return $this;
  52429. }
  52430. public function setBorderFormat($borderFormat)
  52431. {
  52432. $this->table->getStyle()->setBorderFormat($borderFormat);
  52433. return $this;
  52434. }
  52435. public function setPadType($padType)
  52436. {
  52437. $this->table->getStyle()->setPadType($padType);
  52438. return $this;
  52439. }
  52440. public function render(OutputInterface $output)
  52441. {
  52442. $p = new \ReflectionProperty($this->table, 'output');
  52443. $p->setAccessible(true);
  52444. $p->setValue($this->table, $output);
  52445. $this->table->render();
  52446. }
  52447. public function getName()
  52448. {
  52449. return 'table';
  52450. }
  52451. }
  52452. <?php
  52453. namespace Symfony\Component\Console\Helper;
  52454. class TableSeparator extends TableCell
  52455. {
  52456. public function __construct(array $options = array())
  52457. {
  52458. parent::__construct('', $options);
  52459. }
  52460. }
  52461. <?php
  52462. namespace Symfony\Component\Console\Helper;
  52463. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52464. use Symfony\Component\Console\Exception\LogicException;
  52465. class TableStyle
  52466. {
  52467. private $paddingChar = ' ';
  52468. private $horizontalBorderChar = '-';
  52469. private $verticalBorderChar = '|';
  52470. private $crossingChar = '+';
  52471. private $cellHeaderFormat = '<info>%s</info>';
  52472. private $cellRowFormat = '%s';
  52473. private $cellRowContentFormat = ' %s ';
  52474. private $borderFormat = '%s';
  52475. private $padType = STR_PAD_RIGHT;
  52476. public function setPaddingChar($paddingChar)
  52477. {
  52478. if (!$paddingChar) {
  52479. throw new LogicException('The padding char must not be empty');
  52480. }
  52481. $this->paddingChar = $paddingChar;
  52482. return $this;
  52483. }
  52484. public function getPaddingChar()
  52485. {
  52486. return $this->paddingChar;
  52487. }
  52488. public function setHorizontalBorderChar($horizontalBorderChar)
  52489. {
  52490. $this->horizontalBorderChar = $horizontalBorderChar;
  52491. return $this;
  52492. }
  52493. public function getHorizontalBorderChar()
  52494. {
  52495. return $this->horizontalBorderChar;
  52496. }
  52497. public function setVerticalBorderChar($verticalBorderChar)
  52498. {
  52499. $this->verticalBorderChar = $verticalBorderChar;
  52500. return $this;
  52501. }
  52502. public function getVerticalBorderChar()
  52503. {
  52504. return $this->verticalBorderChar;
  52505. }
  52506. public function setCrossingChar($crossingChar)
  52507. {
  52508. $this->crossingChar = $crossingChar;
  52509. return $this;
  52510. }
  52511. public function getCrossingChar()
  52512. {
  52513. return $this->crossingChar;
  52514. }
  52515. public function setCellHeaderFormat($cellHeaderFormat)
  52516. {
  52517. $this->cellHeaderFormat = $cellHeaderFormat;
  52518. return $this;
  52519. }
  52520. public function getCellHeaderFormat()
  52521. {
  52522. return $this->cellHeaderFormat;
  52523. }
  52524. public function setCellRowFormat($cellRowFormat)
  52525. {
  52526. $this->cellRowFormat = $cellRowFormat;
  52527. return $this;
  52528. }
  52529. public function getCellRowFormat()
  52530. {
  52531. return $this->cellRowFormat;
  52532. }
  52533. public function setCellRowContentFormat($cellRowContentFormat)
  52534. {
  52535. $this->cellRowContentFormat = $cellRowContentFormat;
  52536. return $this;
  52537. }
  52538. public function getCellRowContentFormat()
  52539. {
  52540. return $this->cellRowContentFormat;
  52541. }
  52542. public function setBorderFormat($borderFormat)
  52543. {
  52544. $this->borderFormat = $borderFormat;
  52545. return $this;
  52546. }
  52547. public function getBorderFormat()
  52548. {
  52549. return $this->borderFormat;
  52550. }
  52551. public function setPadType($padType)
  52552. {
  52553. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  52554. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  52555. }
  52556. $this->padType = $padType;
  52557. return $this;
  52558. }
  52559. public function getPadType()
  52560. {
  52561. return $this->padType;
  52562. }
  52563. }
  52564. <?php
  52565. namespace Symfony\Component\Console\Input;
  52566. use Symfony\Component\Console\Exception\RuntimeException;
  52567. class ArgvInput extends Input
  52568. {
  52569. private $tokens;
  52570. private $parsed;
  52571. public function __construct(array $argv = null, InputDefinition $definition = null)
  52572. {
  52573. if (null === $argv) {
  52574. $argv = $_SERVER['argv'];
  52575. }
  52576. array_shift($argv);
  52577. $this->tokens = $argv;
  52578. parent::__construct($definition);
  52579. }
  52580. protected function setTokens(array $tokens)
  52581. {
  52582. $this->tokens = $tokens;
  52583. }
  52584. protected function parse()
  52585. {
  52586. $parseOptions = true;
  52587. $this->parsed = $this->tokens;
  52588. while (null !== $token = array_shift($this->parsed)) {
  52589. if ($parseOptions && '' == $token) {
  52590. $this->parseArgument($token);
  52591. } elseif ($parseOptions && '--' == $token) {
  52592. $parseOptions = false;
  52593. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  52594. $this->parseLongOption($token);
  52595. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  52596. $this->parseShortOption($token);
  52597. } else {
  52598. $this->parseArgument($token);
  52599. }
  52600. }
  52601. }
  52602. private function parseShortOption($token)
  52603. {
  52604. $name = substr($token, 1);
  52605. if (\strlen($name) > 1) {
  52606. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  52607. $this->addShortOption($name[0], substr($name, 1));
  52608. } else {
  52609. $this->parseShortOptionSet($name);
  52610. }
  52611. } else {
  52612. $this->addShortOption($name, null);
  52613. }
  52614. }
  52615. private function parseShortOptionSet($name)
  52616. {
  52617. $len = \strlen($name);
  52618. for ($i = 0; $i < $len; ++$i) {
  52619. if (!$this->definition->hasShortcut($name[$i])) {
  52620. $encoding = mb_detect_encoding($name, null, true);
  52621. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  52622. }
  52623. $option = $this->definition->getOptionForShortcut($name[$i]);
  52624. if ($option->acceptValue()) {
  52625. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  52626. break;
  52627. } else {
  52628. $this->addLongOption($option->getName(), null);
  52629. }
  52630. }
  52631. }
  52632. private function parseLongOption($token)
  52633. {
  52634. $name = substr($token, 2);
  52635. if (false !== $pos = strpos($name, '=')) {
  52636. if (0 === \strlen($value = substr($name, $pos + 1))) {
  52637. array_unshift($this->parsed, null);
  52638. }
  52639. $this->addLongOption(substr($name, 0, $pos), $value);
  52640. } else {
  52641. $this->addLongOption($name, null);
  52642. }
  52643. }
  52644. private function parseArgument($token)
  52645. {
  52646. $c = \count($this->arguments);
  52647. if ($this->definition->hasArgument($c)) {
  52648. $arg = $this->definition->getArgument($c);
  52649. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  52650. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  52651. $arg = $this->definition->getArgument($c - 1);
  52652. $this->arguments[$arg->getName()][] = $token;
  52653. } else {
  52654. $all = $this->definition->getArguments();
  52655. if (\count($all)) {
  52656. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  52657. }
  52658. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  52659. }
  52660. }
  52661. private function addShortOption($shortcut, $value)
  52662. {
  52663. if (!$this->definition->hasShortcut($shortcut)) {
  52664. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  52665. }
  52666. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52667. }
  52668. private function addLongOption($name, $value)
  52669. {
  52670. if (!$this->definition->hasOption($name)) {
  52671. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  52672. }
  52673. $option = $this->definition->getOption($name);
  52674. if (!isset($value[0])) {
  52675. $value = null;
  52676. }
  52677. if (null !== $value && !$option->acceptValue()) {
  52678. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  52679. }
  52680. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  52681. $next = array_shift($this->parsed);
  52682. if (isset($next[0]) && '-' !== $next[0]) {
  52683. $value = $next;
  52684. } elseif (empty($next)) {
  52685. $value = null;
  52686. } else {
  52687. array_unshift($this->parsed, $next);
  52688. }
  52689. }
  52690. if (null === $value) {
  52691. if ($option->isValueRequired()) {
  52692. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  52693. }
  52694. if (!$option->isArray()) {
  52695. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52696. }
  52697. }
  52698. if ($option->isArray()) {
  52699. $this->options[$name][] = $value;
  52700. } else {
  52701. $this->options[$name] = $value;
  52702. }
  52703. }
  52704. public function getFirstArgument()
  52705. {
  52706. foreach ($this->tokens as $token) {
  52707. if ($token && '-' === $token[0]) {
  52708. continue;
  52709. }
  52710. return $token;
  52711. }
  52712. }
  52713. public function hasParameterOption($values)
  52714. {
  52715. $values = (array) $values;
  52716. foreach ($this->tokens as $token) {
  52717. foreach ($values as $value) {
  52718. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52719. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  52720. return true;
  52721. }
  52722. }
  52723. }
  52724. return false;
  52725. }
  52726. public function getParameterOption($values, $default = false)
  52727. {
  52728. $values = (array) $values;
  52729. $tokens = $this->tokens;
  52730. while (0 < \count($tokens)) {
  52731. $token = array_shift($tokens);
  52732. foreach ($values as $value) {
  52733. if ($token === $value) {
  52734. return array_shift($tokens);
  52735. }
  52736. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52737. if ('' !== $leading && 0 === strpos($token, $leading)) {
  52738. return substr($token, \strlen($leading));
  52739. }
  52740. }
  52741. }
  52742. return $default;
  52743. }
  52744. public function __toString()
  52745. {
  52746. $self = $this;
  52747. $tokens = array_map(function ($token) use ($self) {
  52748. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  52749. return $match[1].$self->escapeToken($match[2]);
  52750. }
  52751. if ($token && '-' !== $token[0]) {
  52752. return $self->escapeToken($token);
  52753. }
  52754. return $token;
  52755. }, $this->tokens);
  52756. return implode(' ', $tokens);
  52757. }
  52758. }
  52759. <?php
  52760. namespace Symfony\Component\Console\Input;
  52761. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52762. use Symfony\Component\Console\Exception\InvalidOptionException;
  52763. class ArrayInput extends Input
  52764. {
  52765. private $parameters;
  52766. public function __construct(array $parameters, InputDefinition $definition = null)
  52767. {
  52768. $this->parameters = $parameters;
  52769. parent::__construct($definition);
  52770. }
  52771. public function getFirstArgument()
  52772. {
  52773. foreach ($this->parameters as $key => $value) {
  52774. if ($key && '-' === $key[0]) {
  52775. continue;
  52776. }
  52777. return $value;
  52778. }
  52779. }
  52780. public function hasParameterOption($values)
  52781. {
  52782. $values = (array) $values;
  52783. foreach ($this->parameters as $k => $v) {
  52784. if (!\is_int($k)) {
  52785. $v = $k;
  52786. }
  52787. if (\in_array($v, $values)) {
  52788. return true;
  52789. }
  52790. }
  52791. return false;
  52792. }
  52793. public function getParameterOption($values, $default = false)
  52794. {
  52795. $values = (array) $values;
  52796. foreach ($this->parameters as $k => $v) {
  52797. if (\is_int($k)) {
  52798. if (\in_array($v, $values)) {
  52799. return true;
  52800. }
  52801. } elseif (\in_array($k, $values)) {
  52802. return $v;
  52803. }
  52804. }
  52805. return $default;
  52806. }
  52807. public function __toString()
  52808. {
  52809. $params = array();
  52810. foreach ($this->parameters as $param => $val) {
  52811. if ($param && '-' === $param[0]) {
  52812. if (\is_array($val)) {
  52813. foreach ($val as $v) {
  52814. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  52815. }
  52816. } else {
  52817. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  52818. }
  52819. } else {
  52820. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  52821. }
  52822. }
  52823. return implode(' ', $params);
  52824. }
  52825. protected function parse()
  52826. {
  52827. foreach ($this->parameters as $key => $value) {
  52828. if (0 === strpos($key, '--')) {
  52829. $this->addLongOption(substr($key, 2), $value);
  52830. } elseif ('-' === $key[0]) {
  52831. $this->addShortOption(substr($key, 1), $value);
  52832. } else {
  52833. $this->addArgument($key, $value);
  52834. }
  52835. }
  52836. }
  52837. private function addShortOption($shortcut, $value)
  52838. {
  52839. if (!$this->definition->hasShortcut($shortcut)) {
  52840. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  52841. }
  52842. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52843. }
  52844. private function addLongOption($name, $value)
  52845. {
  52846. if (!$this->definition->hasOption($name)) {
  52847. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  52848. }
  52849. $option = $this->definition->getOption($name);
  52850. if (null === $value) {
  52851. if ($option->isValueRequired()) {
  52852. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  52853. }
  52854. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52855. }
  52856. $this->options[$name] = $value;
  52857. }
  52858. private function addArgument($name, $value)
  52859. {
  52860. if (!$this->definition->hasArgument($name)) {
  52861. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52862. }
  52863. $this->arguments[$name] = $value;
  52864. }
  52865. }
  52866. <?php
  52867. namespace Symfony\Component\Console\Input;
  52868. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52869. use Symfony\Component\Console\Exception\RuntimeException;
  52870. abstract class Input implements InputInterface
  52871. {
  52872. protected $definition;
  52873. protected $options = array();
  52874. protected $arguments = array();
  52875. protected $interactive = true;
  52876. public function __construct(InputDefinition $definition = null)
  52877. {
  52878. if (null === $definition) {
  52879. $this->definition = new InputDefinition();
  52880. } else {
  52881. $this->bind($definition);
  52882. $this->validate();
  52883. }
  52884. }
  52885. public function bind(InputDefinition $definition)
  52886. {
  52887. $this->arguments = array();
  52888. $this->options = array();
  52889. $this->definition = $definition;
  52890. $this->parse();
  52891. }
  52892. abstract protected function parse();
  52893. public function validate()
  52894. {
  52895. $definition = $this->definition;
  52896. $givenArguments = $this->arguments;
  52897. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  52898. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  52899. });
  52900. if (\count($missingArguments) > 0) {
  52901. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  52902. }
  52903. }
  52904. public function isInteractive()
  52905. {
  52906. return $this->interactive;
  52907. }
  52908. public function setInteractive($interactive)
  52909. {
  52910. $this->interactive = (bool) $interactive;
  52911. }
  52912. public function getArguments()
  52913. {
  52914. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  52915. }
  52916. public function getArgument($name)
  52917. {
  52918. if (!$this->definition->hasArgument($name)) {
  52919. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52920. }
  52921. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  52922. }
  52923. public function setArgument($name, $value)
  52924. {
  52925. if (!$this->definition->hasArgument($name)) {
  52926. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52927. }
  52928. $this->arguments[$name] = $value;
  52929. }
  52930. public function hasArgument($name)
  52931. {
  52932. return $this->definition->hasArgument($name);
  52933. }
  52934. public function getOptions()
  52935. {
  52936. return array_merge($this->definition->getOptionDefaults(), $this->options);
  52937. }
  52938. public function getOption($name)
  52939. {
  52940. if (!$this->definition->hasOption($name)) {
  52941. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  52942. }
  52943. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  52944. }
  52945. public function setOption($name, $value)
  52946. {
  52947. if (!$this->definition->hasOption($name)) {
  52948. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  52949. }
  52950. $this->options[$name] = $value;
  52951. }
  52952. public function hasOption($name)
  52953. {
  52954. return $this->definition->hasOption($name);
  52955. }
  52956. public function escapeToken($token)
  52957. {
  52958. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  52959. }
  52960. }
  52961. <?php
  52962. namespace Symfony\Component\Console\Input;
  52963. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52964. use Symfony\Component\Console\Exception\LogicException;
  52965. class InputArgument
  52966. {
  52967. const REQUIRED = 1;
  52968. const OPTIONAL = 2;
  52969. const IS_ARRAY = 4;
  52970. private $name;
  52971. private $mode;
  52972. private $default;
  52973. private $description;
  52974. public function __construct($name, $mode = null, $description = '', $default = null)
  52975. {
  52976. if (null === $mode) {
  52977. $mode = self::OPTIONAL;
  52978. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  52979. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  52980. }
  52981. $this->name = $name;
  52982. $this->mode = $mode;
  52983. $this->description = $description;
  52984. $this->setDefault($default);
  52985. }
  52986. public function getName()
  52987. {
  52988. return $this->name;
  52989. }
  52990. public function isRequired()
  52991. {
  52992. return self::REQUIRED === (self::REQUIRED & $this->mode);
  52993. }
  52994. public function isArray()
  52995. {
  52996. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  52997. }
  52998. public function setDefault($default = null)
  52999. {
  53000. if (self::REQUIRED === $this->mode && null !== $default) {
  53001. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  53002. }
  53003. if ($this->isArray()) {
  53004. if (null === $default) {
  53005. $default = array();
  53006. } elseif (!\is_array($default)) {
  53007. throw new LogicException('A default value for an array argument must be an array.');
  53008. }
  53009. }
  53010. $this->default = $default;
  53011. }
  53012. public function getDefault()
  53013. {
  53014. return $this->default;
  53015. }
  53016. public function getDescription()
  53017. {
  53018. return $this->description;
  53019. }
  53020. }
  53021. <?php
  53022. namespace Symfony\Component\Console\Input;
  53023. interface InputAwareInterface
  53024. {
  53025. public function setInput(InputInterface $input);
  53026. }
  53027. <?php
  53028. namespace Symfony\Component\Console\Input;
  53029. use Symfony\Component\Console\Descriptor\TextDescriptor;
  53030. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  53031. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53032. use Symfony\Component\Console\Exception\LogicException;
  53033. use Symfony\Component\Console\Output\BufferedOutput;
  53034. class InputDefinition
  53035. {
  53036. private $arguments;
  53037. private $requiredCount;
  53038. private $hasAnArrayArgument = false;
  53039. private $hasOptional;
  53040. private $options;
  53041. private $shortcuts;
  53042. public function __construct(array $definition = array())
  53043. {
  53044. $this->setDefinition($definition);
  53045. }
  53046. public function setDefinition(array $definition)
  53047. {
  53048. $arguments = array();
  53049. $options = array();
  53050. foreach ($definition as $item) {
  53051. if ($item instanceof InputOption) {
  53052. $options[] = $item;
  53053. } else {
  53054. $arguments[] = $item;
  53055. }
  53056. }
  53057. $this->setArguments($arguments);
  53058. $this->setOptions($options);
  53059. }
  53060. public function setArguments($arguments = array())
  53061. {
  53062. $this->arguments = array();
  53063. $this->requiredCount = 0;
  53064. $this->hasOptional = false;
  53065. $this->hasAnArrayArgument = false;
  53066. $this->addArguments($arguments);
  53067. }
  53068. public function addArguments($arguments = array())
  53069. {
  53070. if (null !== $arguments) {
  53071. foreach ($arguments as $argument) {
  53072. $this->addArgument($argument);
  53073. }
  53074. }
  53075. }
  53076. public function addArgument(InputArgument $argument)
  53077. {
  53078. if (isset($this->arguments[$argument->getName()])) {
  53079. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  53080. }
  53081. if ($this->hasAnArrayArgument) {
  53082. throw new LogicException('Cannot add an argument after an array argument.');
  53083. }
  53084. if ($argument->isRequired() && $this->hasOptional) {
  53085. throw new LogicException('Cannot add a required argument after an optional one.');
  53086. }
  53087. if ($argument->isArray()) {
  53088. $this->hasAnArrayArgument = true;
  53089. }
  53090. if ($argument->isRequired()) {
  53091. ++$this->requiredCount;
  53092. } else {
  53093. $this->hasOptional = true;
  53094. }
  53095. $this->arguments[$argument->getName()] = $argument;
  53096. }
  53097. public function getArgument($name)
  53098. {
  53099. if (!$this->hasArgument($name)) {
  53100. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  53101. }
  53102. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  53103. return $arguments[$name];
  53104. }
  53105. public function hasArgument($name)
  53106. {
  53107. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  53108. return isset($arguments[$name]);
  53109. }
  53110. public function getArguments()
  53111. {
  53112. return $this->arguments;
  53113. }
  53114. public function getArgumentCount()
  53115. {
  53116. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  53117. }
  53118. public function getArgumentRequiredCount()
  53119. {
  53120. return $this->requiredCount;
  53121. }
  53122. public function getArgumentDefaults()
  53123. {
  53124. $values = array();
  53125. foreach ($this->arguments as $argument) {
  53126. $values[$argument->getName()] = $argument->getDefault();
  53127. }
  53128. return $values;
  53129. }
  53130. public function setOptions($options = array())
  53131. {
  53132. $this->options = array();
  53133. $this->shortcuts = array();
  53134. $this->addOptions($options);
  53135. }
  53136. public function addOptions($options = array())
  53137. {
  53138. foreach ($options as $option) {
  53139. $this->addOption($option);
  53140. }
  53141. }
  53142. public function addOption(InputOption $option)
  53143. {
  53144. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  53145. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  53146. }
  53147. if ($option->getShortcut()) {
  53148. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  53149. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  53150. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  53151. }
  53152. }
  53153. }
  53154. $this->options[$option->getName()] = $option;
  53155. if ($option->getShortcut()) {
  53156. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  53157. $this->shortcuts[$shortcut] = $option->getName();
  53158. }
  53159. }
  53160. }
  53161. public function getOption($name)
  53162. {
  53163. if (!$this->hasOption($name)) {
  53164. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  53165. }
  53166. return $this->options[$name];
  53167. }
  53168. public function hasOption($name)
  53169. {
  53170. return isset($this->options[$name]);
  53171. }
  53172. public function getOptions()
  53173. {
  53174. return $this->options;
  53175. }
  53176. public function hasShortcut($name)
  53177. {
  53178. return isset($this->shortcuts[$name]);
  53179. }
  53180. public function getOptionForShortcut($shortcut)
  53181. {
  53182. return $this->getOption($this->shortcutToName($shortcut));
  53183. }
  53184. public function getOptionDefaults()
  53185. {
  53186. $values = array();
  53187. foreach ($this->options as $option) {
  53188. $values[$option->getName()] = $option->getDefault();
  53189. }
  53190. return $values;
  53191. }
  53192. private function shortcutToName($shortcut)
  53193. {
  53194. if (!isset($this->shortcuts[$shortcut])) {
  53195. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  53196. }
  53197. return $this->shortcuts[$shortcut];
  53198. }
  53199. public function getSynopsis($short = false)
  53200. {
  53201. $elements = array();
  53202. if ($short && $this->getOptions()) {
  53203. $elements[] = '[options]';
  53204. } elseif (!$short) {
  53205. foreach ($this->getOptions() as $option) {
  53206. $value = '';
  53207. if ($option->acceptValue()) {
  53208. $value = sprintf(
  53209. ' %s%s%s',
  53210. $option->isValueOptional() ? '[' : '',
  53211. strtoupper($option->getName()),
  53212. $option->isValueOptional() ? ']' : ''
  53213. );
  53214. }
  53215. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  53216. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  53217. }
  53218. }
  53219. if (\count($elements) && $this->getArguments()) {
  53220. $elements[] = '[--]';
  53221. }
  53222. foreach ($this->getArguments() as $argument) {
  53223. $element = '<'.$argument->getName().'>';
  53224. if (!$argument->isRequired()) {
  53225. $element = '['.$element.']';
  53226. } elseif ($argument->isArray()) {
  53227. $element .= ' ('.$element.')';
  53228. }
  53229. if ($argument->isArray()) {
  53230. $element .= '...';
  53231. }
  53232. $elements[] = $element;
  53233. }
  53234. return implode(' ', $elements);
  53235. }
  53236. public function asText()
  53237. {
  53238. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  53239. $descriptor = new TextDescriptor();
  53240. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  53241. $descriptor->describe($output, $this, array('raw_output' => true));
  53242. return $output->fetch();
  53243. }
  53244. public function asXml($asDom = false)
  53245. {
  53246. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  53247. $descriptor = new XmlDescriptor();
  53248. if ($asDom) {
  53249. return $descriptor->getInputDefinitionDocument($this);
  53250. }
  53251. $output = new BufferedOutput();
  53252. $descriptor->describe($output, $this);
  53253. return $output->fetch();
  53254. }
  53255. }
  53256. <?php
  53257. namespace Symfony\Component\Console\Input;
  53258. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53259. use Symfony\Component\Console\Exception\RuntimeException;
  53260. interface InputInterface
  53261. {
  53262. public function getFirstArgument();
  53263. public function hasParameterOption($values);
  53264. public function getParameterOption($values, $default = false);
  53265. public function bind(InputDefinition $definition);
  53266. public function validate();
  53267. public function getArguments();
  53268. public function getArgument($name);
  53269. public function setArgument($name, $value);
  53270. public function hasArgument($name);
  53271. public function getOptions();
  53272. public function getOption($name);
  53273. public function setOption($name, $value);
  53274. public function hasOption($name);
  53275. public function isInteractive();
  53276. public function setInteractive($interactive);
  53277. }
  53278. <?php
  53279. namespace Symfony\Component\Console\Input;
  53280. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53281. use Symfony\Component\Console\Exception\LogicException;
  53282. class InputOption
  53283. {
  53284. const VALUE_NONE = 1;
  53285. const VALUE_REQUIRED = 2;
  53286. const VALUE_OPTIONAL = 4;
  53287. const VALUE_IS_ARRAY = 8;
  53288. private $name;
  53289. private $shortcut;
  53290. private $mode;
  53291. private $default;
  53292. private $description;
  53293. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  53294. {
  53295. if (0 === strpos($name, '--')) {
  53296. $name = substr($name, 2);
  53297. }
  53298. if (empty($name)) {
  53299. throw new InvalidArgumentException('An option name cannot be empty.');
  53300. }
  53301. if (empty($shortcut)) {
  53302. $shortcut = null;
  53303. }
  53304. if (null !== $shortcut) {
  53305. if (\is_array($shortcut)) {
  53306. $shortcut = implode('|', $shortcut);
  53307. }
  53308. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  53309. $shortcuts = array_filter($shortcuts);
  53310. $shortcut = implode('|', $shortcuts);
  53311. if (empty($shortcut)) {
  53312. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  53313. }
  53314. }
  53315. if (null === $mode) {
  53316. $mode = self::VALUE_NONE;
  53317. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  53318. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  53319. }
  53320. $this->name = $name;
  53321. $this->shortcut = $shortcut;
  53322. $this->mode = $mode;
  53323. $this->description = $description;
  53324. if ($this->isArray() && !$this->acceptValue()) {
  53325. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  53326. }
  53327. $this->setDefault($default);
  53328. }
  53329. public function getShortcut()
  53330. {
  53331. return $this->shortcut;
  53332. }
  53333. public function getName()
  53334. {
  53335. return $this->name;
  53336. }
  53337. public function acceptValue()
  53338. {
  53339. return $this->isValueRequired() || $this->isValueOptional();
  53340. }
  53341. public function isValueRequired()
  53342. {
  53343. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  53344. }
  53345. public function isValueOptional()
  53346. {
  53347. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  53348. }
  53349. public function isArray()
  53350. {
  53351. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  53352. }
  53353. public function setDefault($default = null)
  53354. {
  53355. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  53356. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  53357. }
  53358. if ($this->isArray()) {
  53359. if (null === $default) {
  53360. $default = array();
  53361. } elseif (!\is_array($default)) {
  53362. throw new LogicException('A default value for an array option must be an array.');
  53363. }
  53364. }
  53365. $this->default = $this->acceptValue() ? $default : false;
  53366. }
  53367. public function getDefault()
  53368. {
  53369. return $this->default;
  53370. }
  53371. public function getDescription()
  53372. {
  53373. return $this->description;
  53374. }
  53375. public function equals(self $option)
  53376. {
  53377. return $option->getName() === $this->getName()
  53378. && $option->getShortcut() === $this->getShortcut()
  53379. && $option->getDefault() === $this->getDefault()
  53380. && $option->isArray() === $this->isArray()
  53381. && $option->isValueRequired() === $this->isValueRequired()
  53382. && $option->isValueOptional() === $this->isValueOptional()
  53383. ;
  53384. }
  53385. }
  53386. <?php
  53387. namespace Symfony\Component\Console\Input;
  53388. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53389. class StringInput extends ArgvInput
  53390. {
  53391. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  53392. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  53393. public function __construct($input, InputDefinition $definition = null)
  53394. {
  53395. if ($definition) {
  53396. @trigger_error('The $definition argument of the '.__METHOD__.' method is deprecated and will be removed in 3.0. Set this parameter with the bind() method instead.', E_USER_DEPRECATED);
  53397. }
  53398. parent::__construct(array(), null);
  53399. $this->setTokens($this->tokenize($input));
  53400. if (null !== $definition) {
  53401. $this->bind($definition);
  53402. }
  53403. }
  53404. private function tokenize($input)
  53405. {
  53406. $tokens = array();
  53407. $length = \strlen($input);
  53408. $cursor = 0;
  53409. while ($cursor < $length) {
  53410. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  53411. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  53412. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  53413. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  53414. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  53415. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  53416. $tokens[] = stripcslashes($match[1]);
  53417. } else {
  53418. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  53419. }
  53420. $cursor += \strlen($match[0]);
  53421. }
  53422. return $tokens;
  53423. }
  53424. }
  53425. Copyright (c) 2004-2018 Fabien Potencier
  53426. Permission is hereby granted, free of charge, to any person obtaining a copy
  53427. of this software and associated documentation files (the "Software"), to deal
  53428. in the Software without restriction, including without limitation the rights
  53429. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  53430. copies of the Software, and to permit persons to whom the Software is furnished
  53431. to do so, subject to the following conditions:
  53432. The above copyright notice and this permission notice shall be included in all
  53433. copies or substantial portions of the Software.
  53434. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53435. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  53436. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  53437. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  53438. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  53439. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  53440. THE SOFTWARE.
  53441. <?php
  53442. namespace Symfony\Component\Console\Logger;
  53443. use Psr\Log\AbstractLogger;
  53444. use Psr\Log\InvalidArgumentException;
  53445. use Psr\Log\LogLevel;
  53446. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  53447. use Symfony\Component\Console\Output\OutputInterface;
  53448. class ConsoleLogger extends AbstractLogger
  53449. {
  53450. const INFO = 'info';
  53451. const ERROR = 'error';
  53452. private $output;
  53453. private $verbosityLevelMap = array(
  53454. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  53455. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  53456. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  53457. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  53458. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  53459. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  53460. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  53461. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  53462. );
  53463. private $formatLevelMap = array(
  53464. LogLevel::EMERGENCY => self::ERROR,
  53465. LogLevel::ALERT => self::ERROR,
  53466. LogLevel::CRITICAL => self::ERROR,
  53467. LogLevel::ERROR => self::ERROR,
  53468. LogLevel::WARNING => self::INFO,
  53469. LogLevel::NOTICE => self::INFO,
  53470. LogLevel::INFO => self::INFO,
  53471. LogLevel::DEBUG => self::INFO,
  53472. );
  53473. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  53474. {
  53475. $this->output = $output;
  53476. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  53477. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  53478. }
  53479. public function log($level, $message, array $context = array())
  53480. {
  53481. if (!isset($this->verbosityLevelMap[$level])) {
  53482. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  53483. }
  53484. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  53485. $output = $this->output->getErrorOutput();
  53486. } else {
  53487. $output = $this->output;
  53488. }
  53489. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  53490. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  53491. }
  53492. }
  53493. private function interpolate($message, array $context)
  53494. {
  53495. $replace = array();
  53496. foreach ($context as $key => $val) {
  53497. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  53498. $replace[sprintf('{%s}', $key)] = $val;
  53499. }
  53500. }
  53501. return strtr($message, $replace);
  53502. }
  53503. }
  53504. <?php
  53505. namespace Symfony\Component\Console\Output;
  53506. class BufferedOutput extends Output
  53507. {
  53508. private $buffer = '';
  53509. public function fetch()
  53510. {
  53511. $content = $this->buffer;
  53512. $this->buffer = '';
  53513. return $content;
  53514. }
  53515. protected function doWrite($message, $newline)
  53516. {
  53517. $this->buffer .= $message;
  53518. if ($newline) {
  53519. $this->buffer .= PHP_EOL;
  53520. }
  53521. }
  53522. }
  53523. <?php
  53524. namespace Symfony\Component\Console\Output;
  53525. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53526. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  53527. {
  53528. private $stderr;
  53529. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  53530. {
  53531. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  53532. $actualDecorated = $this->isDecorated();
  53533. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  53534. if (null === $decorated) {
  53535. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  53536. }
  53537. }
  53538. public function setDecorated($decorated)
  53539. {
  53540. parent::setDecorated($decorated);
  53541. $this->stderr->setDecorated($decorated);
  53542. }
  53543. public function setFormatter(OutputFormatterInterface $formatter)
  53544. {
  53545. parent::setFormatter($formatter);
  53546. $this->stderr->setFormatter($formatter);
  53547. }
  53548. public function setVerbosity($level)
  53549. {
  53550. parent::setVerbosity($level);
  53551. $this->stderr->setVerbosity($level);
  53552. }
  53553. public function getErrorOutput()
  53554. {
  53555. return $this->stderr;
  53556. }
  53557. public function setErrorOutput(OutputInterface $error)
  53558. {
  53559. $this->stderr = $error;
  53560. }
  53561. protected function hasStdoutSupport()
  53562. {
  53563. return false === $this->isRunningOS400();
  53564. }
  53565. protected function hasStderrSupport()
  53566. {
  53567. return false === $this->isRunningOS400();
  53568. }
  53569. private function isRunningOS400()
  53570. {
  53571. $checks = array(
  53572. \function_exists('php_uname') ? php_uname('s') : '',
  53573. getenv('OSTYPE'),
  53574. PHP_OS,
  53575. );
  53576. return false !== stripos(implode(';', $checks), 'OS400');
  53577. }
  53578. private function openOutputStream()
  53579. {
  53580. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  53581. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  53582. }
  53583. private function openErrorStream()
  53584. {
  53585. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  53586. return fopen($errorStream, 'w');
  53587. }
  53588. }
  53589. <?php
  53590. namespace Symfony\Component\Console\Output;
  53591. interface ConsoleOutputInterface extends OutputInterface
  53592. {
  53593. public function getErrorOutput();
  53594. public function setErrorOutput(OutputInterface $error);
  53595. }
  53596. <?php
  53597. namespace Symfony\Component\Console\Output;
  53598. use Symfony\Component\Console\Formatter\OutputFormatter;
  53599. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53600. class NullOutput implements OutputInterface
  53601. {
  53602. public function setFormatter(OutputFormatterInterface $formatter)
  53603. {
  53604. }
  53605. public function getFormatter()
  53606. {
  53607. return new OutputFormatter();
  53608. }
  53609. public function setDecorated($decorated)
  53610. {
  53611. }
  53612. public function isDecorated()
  53613. {
  53614. return false;
  53615. }
  53616. public function setVerbosity($level)
  53617. {
  53618. }
  53619. public function getVerbosity()
  53620. {
  53621. return self::VERBOSITY_QUIET;
  53622. }
  53623. public function isQuiet()
  53624. {
  53625. return true;
  53626. }
  53627. public function isVerbose()
  53628. {
  53629. return false;
  53630. }
  53631. public function isVeryVerbose()
  53632. {
  53633. return false;
  53634. }
  53635. public function isDebug()
  53636. {
  53637. return false;
  53638. }
  53639. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53640. {
  53641. }
  53642. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53643. {
  53644. }
  53645. }
  53646. <?php
  53647. namespace Symfony\Component\Console\Output;
  53648. use Symfony\Component\Console\Formatter\OutputFormatter;
  53649. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53650. abstract class Output implements OutputInterface
  53651. {
  53652. private $verbosity;
  53653. private $formatter;
  53654. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  53655. {
  53656. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  53657. $this->formatter = $formatter ?: new OutputFormatter();
  53658. $this->formatter->setDecorated($decorated);
  53659. }
  53660. public function setFormatter(OutputFormatterInterface $formatter)
  53661. {
  53662. $this->formatter = $formatter;
  53663. }
  53664. public function getFormatter()
  53665. {
  53666. return $this->formatter;
  53667. }
  53668. public function setDecorated($decorated)
  53669. {
  53670. $this->formatter->setDecorated($decorated);
  53671. }
  53672. public function isDecorated()
  53673. {
  53674. return $this->formatter->isDecorated();
  53675. }
  53676. public function setVerbosity($level)
  53677. {
  53678. $this->verbosity = (int) $level;
  53679. }
  53680. public function getVerbosity()
  53681. {
  53682. return $this->verbosity;
  53683. }
  53684. public function isQuiet()
  53685. {
  53686. return self::VERBOSITY_QUIET === $this->verbosity;
  53687. }
  53688. public function isVerbose()
  53689. {
  53690. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  53691. }
  53692. public function isVeryVerbose()
  53693. {
  53694. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  53695. }
  53696. public function isDebug()
  53697. {
  53698. return self::VERBOSITY_DEBUG <= $this->verbosity;
  53699. }
  53700. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53701. {
  53702. $this->write($messages, true, $options);
  53703. }
  53704. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53705. {
  53706. $messages = (array) $messages;
  53707. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  53708. $type = $types & $options ?: self::OUTPUT_NORMAL;
  53709. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  53710. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  53711. if ($verbosity > $this->getVerbosity()) {
  53712. return;
  53713. }
  53714. foreach ($messages as $message) {
  53715. switch ($type) {
  53716. case OutputInterface::OUTPUT_NORMAL:
  53717. $message = $this->formatter->format($message);
  53718. break;
  53719. case OutputInterface::OUTPUT_RAW:
  53720. break;
  53721. case OutputInterface::OUTPUT_PLAIN:
  53722. $message = strip_tags($this->formatter->format($message));
  53723. break;
  53724. }
  53725. $this->doWrite($message, $newline);
  53726. }
  53727. }
  53728. abstract protected function doWrite($message, $newline);
  53729. }
  53730. <?php
  53731. namespace Symfony\Component\Console\Output;
  53732. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53733. interface OutputInterface
  53734. {
  53735. const VERBOSITY_QUIET = 16;
  53736. const VERBOSITY_NORMAL = 32;
  53737. const VERBOSITY_VERBOSE = 64;
  53738. const VERBOSITY_VERY_VERBOSE = 128;
  53739. const VERBOSITY_DEBUG = 256;
  53740. const OUTPUT_NORMAL = 1;
  53741. const OUTPUT_RAW = 2;
  53742. const OUTPUT_PLAIN = 4;
  53743. public function write($messages, $newline = false, $options = 0);
  53744. public function writeln($messages, $options = 0);
  53745. public function setVerbosity($level);
  53746. public function getVerbosity();
  53747. public function setDecorated($decorated);
  53748. public function isDecorated();
  53749. public function setFormatter(OutputFormatterInterface $formatter);
  53750. public function getFormatter();
  53751. }
  53752. <?php
  53753. namespace Symfony\Component\Console\Output;
  53754. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53755. use Symfony\Component\Console\Exception\RuntimeException;
  53756. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53757. class StreamOutput extends Output
  53758. {
  53759. private $stream;
  53760. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  53761. {
  53762. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  53763. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  53764. }
  53765. $this->stream = $stream;
  53766. if (null === $decorated) {
  53767. $decorated = $this->hasColorSupport();
  53768. }
  53769. parent::__construct($verbosity, $decorated, $formatter);
  53770. }
  53771. public function getStream()
  53772. {
  53773. return $this->stream;
  53774. }
  53775. protected function doWrite($message, $newline)
  53776. {
  53777. if ($newline) {
  53778. $message .= PHP_EOL;
  53779. }
  53780. if (false === @fwrite($this->stream, $message)) {
  53781. throw new RuntimeException('Unable to write output.');
  53782. }
  53783. fflush($this->stream);
  53784. }
  53785. protected function hasColorSupport()
  53786. {
  53787. if ('Hyper' === getenv('TERM_PROGRAM')) {
  53788. return true;
  53789. }
  53790. if (\DIRECTORY_SEPARATOR === '\\') {
  53791. return (\function_exists('sapi_windows_vt100_support')
  53792. && @sapi_windows_vt100_support($this->stream))
  53793. || false !== getenv('ANSICON')
  53794. || 'ON' === getenv('ConEmuANSI')
  53795. || 'xterm' === getenv('TERM');
  53796. }
  53797. if (\function_exists('stream_isatty')) {
  53798. return @stream_isatty($this->stream);
  53799. }
  53800. if (\function_exists('posix_isatty')) {
  53801. return @posix_isatty($this->stream);
  53802. }
  53803. $stat = @fstat($this->stream);
  53804. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  53805. }
  53806. }
  53807. <?php
  53808. namespace Symfony\Component\Console\Question;
  53809. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53810. class ChoiceQuestion extends Question
  53811. {
  53812. private $choices;
  53813. private $multiselect = false;
  53814. private $prompt = ' > ';
  53815. private $errorMessage = 'Value "%s" is invalid';
  53816. public function __construct($question, array $choices, $default = null)
  53817. {
  53818. if (!$choices) {
  53819. throw new \LogicException('Choice question must have at least 1 choice available.');
  53820. }
  53821. parent::__construct($question, $default);
  53822. $this->choices = $choices;
  53823. $this->setValidator($this->getDefaultValidator());
  53824. $this->setAutocompleterValues($choices);
  53825. }
  53826. public function getChoices()
  53827. {
  53828. return $this->choices;
  53829. }
  53830. public function setMultiselect($multiselect)
  53831. {
  53832. $this->multiselect = $multiselect;
  53833. $this->setValidator($this->getDefaultValidator());
  53834. return $this;
  53835. }
  53836. public function isMultiselect()
  53837. {
  53838. return $this->multiselect;
  53839. }
  53840. public function getPrompt()
  53841. {
  53842. return $this->prompt;
  53843. }
  53844. public function setPrompt($prompt)
  53845. {
  53846. $this->prompt = $prompt;
  53847. return $this;
  53848. }
  53849. public function setErrorMessage($errorMessage)
  53850. {
  53851. $this->errorMessage = $errorMessage;
  53852. $this->setValidator($this->getDefaultValidator());
  53853. return $this;
  53854. }
  53855. private function getDefaultValidator()
  53856. {
  53857. $choices = $this->choices;
  53858. $errorMessage = $this->errorMessage;
  53859. $multiselect = $this->multiselect;
  53860. $isAssoc = $this->isAssoc($choices);
  53861. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  53862. $selectedChoices = str_replace(' ', '', $selected);
  53863. if ($multiselect) {
  53864. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  53865. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  53866. }
  53867. $selectedChoices = explode(',', $selectedChoices);
  53868. } else {
  53869. $selectedChoices = array($selected);
  53870. }
  53871. $multiselectChoices = array();
  53872. foreach ($selectedChoices as $value) {
  53873. $results = array();
  53874. foreach ($choices as $key => $choice) {
  53875. if ($choice === $value) {
  53876. $results[] = $key;
  53877. }
  53878. }
  53879. if (\count($results) > 1) {
  53880. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  53881. }
  53882. $result = array_search($value, $choices);
  53883. if (!$isAssoc) {
  53884. if (false !== $result) {
  53885. $result = $choices[$result];
  53886. } elseif (isset($choices[$value])) {
  53887. $result = $choices[$value];
  53888. }
  53889. } elseif (false === $result && isset($choices[$value])) {
  53890. $result = $value;
  53891. }
  53892. if (false === $result) {
  53893. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  53894. }
  53895. $multiselectChoices[] = (string) $result;
  53896. }
  53897. if ($multiselect) {
  53898. return $multiselectChoices;
  53899. }
  53900. return current($multiselectChoices);
  53901. };
  53902. }
  53903. }
  53904. <?php
  53905. namespace Symfony\Component\Console\Question;
  53906. class ConfirmationQuestion extends Question
  53907. {
  53908. private $trueAnswerRegex;
  53909. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  53910. {
  53911. parent::__construct($question, (bool) $default);
  53912. $this->trueAnswerRegex = $trueAnswerRegex;
  53913. $this->setNormalizer($this->getDefaultNormalizer());
  53914. }
  53915. private function getDefaultNormalizer()
  53916. {
  53917. $default = $this->getDefault();
  53918. $regex = $this->trueAnswerRegex;
  53919. return function ($answer) use ($default, $regex) {
  53920. if (\is_bool($answer)) {
  53921. return $answer;
  53922. }
  53923. $answerIsTrue = (bool) preg_match($regex, $answer);
  53924. if (false === $default) {
  53925. return $answer && $answerIsTrue;
  53926. }
  53927. return !$answer || $answerIsTrue;
  53928. };
  53929. }
  53930. }
  53931. <?php
  53932. namespace Symfony\Component\Console\Question;
  53933. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53934. use Symfony\Component\Console\Exception\LogicException;
  53935. class Question
  53936. {
  53937. private $question;
  53938. private $attempts;
  53939. private $hidden = false;
  53940. private $hiddenFallback = true;
  53941. private $autocompleterValues;
  53942. private $validator;
  53943. private $default;
  53944. private $normalizer;
  53945. public function __construct($question, $default = null)
  53946. {
  53947. $this->question = $question;
  53948. $this->default = $default;
  53949. }
  53950. public function getQuestion()
  53951. {
  53952. return $this->question;
  53953. }
  53954. public function getDefault()
  53955. {
  53956. return $this->default;
  53957. }
  53958. public function isHidden()
  53959. {
  53960. return $this->hidden;
  53961. }
  53962. public function setHidden($hidden)
  53963. {
  53964. if ($this->autocompleterValues) {
  53965. throw new LogicException('A hidden question cannot use the autocompleter.');
  53966. }
  53967. $this->hidden = (bool) $hidden;
  53968. return $this;
  53969. }
  53970. public function isHiddenFallback()
  53971. {
  53972. return $this->hiddenFallback;
  53973. }
  53974. public function setHiddenFallback($fallback)
  53975. {
  53976. $this->hiddenFallback = (bool) $fallback;
  53977. return $this;
  53978. }
  53979. public function getAutocompleterValues()
  53980. {
  53981. return $this->autocompleterValues;
  53982. }
  53983. public function setAutocompleterValues($values)
  53984. {
  53985. if (\is_array($values)) {
  53986. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  53987. }
  53988. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  53989. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  53990. }
  53991. if ($this->hidden) {
  53992. throw new LogicException('A hidden question cannot use the autocompleter.');
  53993. }
  53994. $this->autocompleterValues = $values;
  53995. return $this;
  53996. }
  53997. public function setValidator($validator)
  53998. {
  53999. $this->validator = $validator;
  54000. return $this;
  54001. }
  54002. public function getValidator()
  54003. {
  54004. return $this->validator;
  54005. }
  54006. public function setMaxAttempts($attempts)
  54007. {
  54008. if (null !== $attempts && $attempts < 1) {
  54009. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  54010. }
  54011. $this->attempts = $attempts;
  54012. return $this;
  54013. }
  54014. public function getMaxAttempts()
  54015. {
  54016. return $this->attempts;
  54017. }
  54018. public function setNormalizer($normalizer)
  54019. {
  54020. $this->normalizer = $normalizer;
  54021. return $this;
  54022. }
  54023. public function getNormalizer()
  54024. {
  54025. return $this->normalizer;
  54026. }
  54027. protected function isAssoc($array)
  54028. {
  54029. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  54030. }
  54031. }
  54032. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  54033. $�������Æ,Í;§Bž;§Bž;§Bž2ßמ:§Bž2ßÁž-§Bž2ßÆž9§Bž2ßÑž?§Bža9ž8§Bž;§Cž§Bž2ßÈž:§Bž2ßÖž:§Bž2ßÓž:§BžRich;§Bž��������PE��L�¬MoO��������à�  ��
  54034. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  54035. ����������������� ��`.rdata����� ���
  54036. �����������������@��@.data�������0��������������������@��À.rsrc��� ���@��������������������@��@.reloc��Ì���P������"��������������@��B��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������j$¸æ@�èx��jöÿ @�ƒeÐ�‹ð�EÐPVÿ� @�‹EЃàûPVÿ @��MÔÿX @�ƒeü��EÔPÿ5H @�ÿL @�YYÿ5\ @��EÔPÿ5` @�ÿD @�YY‹ÈÿP @�ƒMüÿ�MÔÿT @�3ÀèH��Ã; �0@�uóÃé¬��h€@�è£��¡l3@�Ç$40@�ÿ5h3@�£40@�h$0@�h(0@�h 0@�ÿ  @�ƒÄ£00@�…À}jè¹��YÃjh"@�è��3Û‰]üd¡���‹p‰]ä¿€3@�SVWÿ0 @�;Ãt;Æu3öF‰uäëhè��ÿ4 @�ëÚ3öF¡|3@�;Æu
  54037. jè\��Yë;¡|3@�…Àu,‰5|3@�hð @�hä @�è§��YY…ÀtÇEüþÿÿÿ¸ÿ���éÝ���‰5<0@�¡|3@�;Æuhà @�hØ @�èl��YYÇ|3@����9]äuSWÿ8 @�9Œ3@�thŒ3@�èƒ��Y…Àt
  54038. SjSÿŒ3@�¡$0@�‹ ¼ @�‰ÿ5$0@�ÿ5(0@�ÿ5 0@�èþÿÿƒÄ £80@�9,0@�u7PÿÀ @�‹Eì‹‹ ‰MàPQèŽ��YYËeè‹Eà£80@�3Û9,0@�uPÿh @�9<0@�uÿœ @�ÇEüþÿÿÿ¡80@�èû��øMZ��f9��@�t3ÀëM¡<�@��€��@��8PE��ué·H�ù ��t�ù ��uÕƒ¸„���vÌ3É9ˆø���ëƒxtv¼3É9ˆè���•Á‹Áj£,0@�ÿp @�jÿÿl @�YY£„3@�£ˆ3@�ÿÌ @�‹ t3@�‰ÿˆ @�‹ p3@�‰¡¨ @�‹�£x3@�èV��è¬��ƒ=0@��u hµ@�ÿ¬ @�Yèg��ƒ=0@�ÿu jÿÿ° @�Y3ÀÃè{��éŸýÿÿ‹ÿU‹ì�ì(��£H1@�‰ D1@�‰@1@�‰<1@�‰581@�‰=41@�fŒ`1@�fŒ T1@�fŒ01@�fŒ,1@�fŒ%(1@�fŒ-$1@�œ�X1@�‹E�£L1@�‹E£P1@��E£\1@�‹…àüÿÿǘ0@���¡P1@�£L0@�Ç@0@� �ÀÇD0@����¡�0@�‰…Øüÿÿ¡0@�‰…Üüÿÿÿ @�£�0@�jè?��Yj�ÿ @�h!@�ÿ$ @�ƒ=�0@��ujè��Yh �Àÿ( @�Pÿ, @�ÉËÿU‹ì‹E‹��8csmàu*ƒxu$‹@= “t=!“t="“t=�@™uèÐ��3À]Â�hH@�ÿ @�3ÀÃÿ%¤ @�jh("@�èb��ÿ5ˆ3@�‹5Œ @�ÿÖY‰Eäƒøÿu ÿuÿÄ @�Yëgjè’��Yƒeü�ÿ5ˆ3@�ÿÖ‰Eäÿ5„3@�ÿÖYY‰Eà�EàP�EäPÿu‹5l @�ÿÖYPèU��‰EÜÿuäÿÖ£ˆ3@�ÿuàÿփģ„3@�ÇEüþÿÿÿè ���‹EÜè��Ãjè��YËÿU‹ìÿuèNÿÿÿ÷ØÀ÷ØYH]ËÿV¸ü!@�¾ü!@�W‹ø;Æs‹…ÀtÿЃÇ;þrñ_^ËÿV¸"@�¾"@�W‹ø;Æs‹…ÀtÿЃÇ;þrñ_^Ãÿ%È @�ÌÌÌÌ‹ÿU‹ì‹M¸MZ��f9t3À]ËA<Á�8PE��uï3Ò¹ ��f9H”‹Â]ÃÌÌÌÌÌÌÌÌÌÌÌ‹ÿU‹ì‹E‹H<È·ASV·q3ÒW�D…öv‹} ‹H ;ùr ‹XÙ;ûr
  54039. BƒÀ(;Örè3À_^[]ÃÌÌÌÌÌÌÌÌÌÌÌÌ‹ÿU‹ìjþhH"@�he@�d¡����PƒìSVW¡�0@�1Eø3ÅP�Eðd£����‰eèÇEü����h��@�è*ÿÿÿƒÄ…ÀtU‹E-��@�Ph��@�èPÿÿÿƒÄ…Àt;‹@$Áè÷ЃàÇEüþÿÿÿ‹Mðd‰ ����Y_^[‹å]ËEì‹‹3Ò=��À”‹ÂËeèÇEüþÿÿÿ3À‹Mðd‰ ����Y_^[‹å]ÃÌÿ%¸ @�ÿ%´ @�ÌÌhe@�dÿ5����‹D$‰l$�l$+àSVW¡�0@�1Eü3ÅP‰eèÿuø‹EüÇEüþÿÿÿ‰Eø�Eðd£����ËMðd‰ ����Y__^[‹å]QËÿU‹ìÿuÿuÿu ÿuh‡@�h�0@�èç���ƒÄ]ËÿVh���h���3öVèÙ���ƒÄ …Àt VVVVVèÂ���ƒÄ^Ã3ÀËÿU‹ìƒì¡�0@�ƒeø�ƒeü�SW¿Næ@»»��ÿÿ;Çt …Ãt ÷У0@�ë`V�EøPÿ< @�‹uü3uøÿ @�3ðÿ @�3ðÿ @�3ð�EðPÿ @�‹Eô3Eð3ð;÷u¾Oæ@»ë …óu‹ÆÁà ð‰5�0@�÷Ö‰50@�^_[ÉÃÿ%t @�ÿ%x @�ÿ%| @�ÿ%€ @�ÿ%„ @�ÿ%� @�ÿ%” @�ÿ%˜ @�ÿ%Ð @�Pdÿ5�����D$ +d$ SVW‰(‹è¡�0@�3ÅP‰EðÿuüÇEüÿÿÿÿ�Eôd£����ËMôd‰ ����Y__^[‹å]QËMð3Íè¯÷ÿÿéÝÿÿÿ�MÔÿ%T @�‹T$�B ‹JÌ3Èè�÷ÿÿ‹Jü3Èè†÷ÿÿ¸l"@�ésÿÿÿ�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������¸#��Ê#��Ü#��ˆ)��r)��b)��H)��4)��)��ú(��æ(��Ò(��´(��¬(��–(��ž)������ú#��à$��%��Ê%��&��d&��®&��¤$������('��Ä'��Ö'��è'��þ'��(��((��6(��¦'��H(��Z(��t(��†(��'��'���'��–'��‚'��l'��^'��R'��F'��>'��>(��0'��¶'��¸)����������–@���������W@�Š@���������������������¬MoO�������l���€!��€��@0@�˜0@�bad allocation������H������������������������������������������������������������0@�ð!@����RSDSÑŒ³´�J¨!öÌëLZ����c:\users\seld\documents\visual studio 2010\Projects\hiddeninp\Release\hiddeninp.pdb�����e��æ������������������þÿÿÿ����Ðÿÿÿ����þÿÿÿ@�@�����þÿÿÿ����Ìÿÿÿ����þÿÿÿ����:@�����þÿÿÿ����Øÿÿÿ����þÿÿÿË@�ß@�ÿÿÿÿÝ@�"“���d"@������������������������à"����������ì#��� ��$#����������ô&��D ��H#����������(��h ����������������������¸#��Ê#��Ü#��ˆ)��r)��b)��H)��4)��)��ú(��æ(��Ò(��´(��¬(��–(��ž)������ú#��à$��%��Ê%��&��d&��®&��¤$������('��Ä'��Ö'��è'��þ'��(��((��6(��¦'��H(��Z(��t(��†(��'��'���'��–'��‚'��l'��^'��R'��F'��>'��>(��0'��¶'��¸)������•GetConsoleMode��·SetConsoleMode��;GetStdHandle��KERNEL32.dll���??$?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z�‘?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A��J?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A�Â�??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z�??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z��_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ��{??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ��³?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z��MSVCP90.dll�_amsg_exit��Ÿ�__getmainargs�,_cexit��|_exit�f�_XcptFilter�Ìexit�� �__initenv�_initterm�_initterm_e�<_configthreadlocale�ã�__setusermatherr�� _adjust_fdiv��Ë�__p__commode��Ï�__p__fmode��j_encode_pointer�à�__set_app_type��K_crt_debugger_hook��C�?terminate@@YAXXZ�MSVCR90.dll�æ_unlock�–�__dllonexit�v_lock�_onexit�`_decode_pointer�s_except_handler4_common� _invoke_watson��?_controlfp_s��½InterlockedExchange�!Sleep�ºInterlockedCompareExchange��-TerminateProcess��©GetCurrentProcess�>UnhandledExceptionFilter��SetUnhandledExceptionFilter�ÑIsDebuggerPresent�TQueryPerformanceCounter�fGetTickCount��­GetCurrentThreadId��ªGetCurrentProcessId�OGetSystemTimeAsFileTime�s�__CxxFrameHandler3����������������������������������������������������Næ@»±¿Dÿÿÿÿÿÿÿÿþÿÿÿ���$!@���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ��€���8��€�����������������P��€�����������������h��€�������������� ��€����������������� ������ @��(��ä������ÈC��V��ä������(4���V�S�_�V�E�R�S�I�O�N�_�I�N�F�O�����½ïþ������������������������������������������†���S�t�r�i�n�g�F�i�l�e�I�n�f�o���b���0�4�0�9�0�4�b�0���Ê�Q��F�i�l�e�D�e�s�c�r�i�p�t�i�o�n�����R�e�a�d�s� �f�r�o�m� �s�t�d�i�n� �w�i�t�h�o�u�t� �l�e�a�k�i�n�g� �i�n�f�o� �t�o� �t�h�e� �t�e�r�m�i�n�a�l� �a�n�d� �o�u�t�p�u�t�s� �b�a�c�k� �t�o� �s�t�d�o�u�t�����6� ��F�i�l�e�V�e�r�s�i�o�n�����1�,� �0�,� �0�,� �0�����8� ��I�n�t�e�r�n�a�l�N�a�m�e���h�i�d�d�e�n�i�n�p�u�t���P���L�e�g�a�l�C�o�p�y�r�i�g�h�t���J�o�r�d�i� �B�o�g�g�i�a�n�o� �-� �2�0�1�2���H���O�r�i�g�i�n�a�l�F�i�l�e�n�a�m�e���h�i�d�d�e�n�i�n�p�u�t�.�e�x�e���:� ��P�r�o�d�u�c�t�N�a�m�e�����H�i�d�d�e�n� �I�n�p�u�t�����:� ��P�r�o�d�u�c�t�V�e�r�s�i�o�n���1�,� �0�,� �0�,� �0�����D����V�a�r�F�i�l�e�I�n�f�o�����$����T�r�a�n�s�l�a�t�i�o�n����� °<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  54040. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  54041. <security>
  54042. <requestedPrivileges>
  54043. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  54044. </requestedPrivileges>
  54045. </security>
  54046. </trustInfo>
  54047. <dependency>
  54048. <dependentAssembly>
  54049. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  54050. </dependentAssembly>
  54051. </dependency>
  54052. </assembly>PAPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDING���@��00!0/080F0L0T0^0d0n0{0‰0—0¡0¨0®0³0¸0½0Â0È0Ð0ä0ÿ01#1-1@1J1O1T1v1{1„1‰1–1§1­1´1È1Í1Ó1Û1á1ç1ô1ú12"2*23292A2M2_2j2p2¹2¿2Ç2Î2Ó2Ù2ß2ç2í2ô2û2 333%303N3T3Z3`3f3l3s3z3�3ˆ3�3–3�3¥3­3µ3Á3Ê3Ï3Õ3ß3è3ó3ÿ34444%4;4B4‹4‘4š4¡4¬4²4Æ4Û4æ4þ45!5^5c5„5‰5¨5H6M6_6}6‘6—6�77 7*7w7|7Á7ä7ñ7ý78 88=8E8P8V8\8b8h8n8t8z8€8œ8â89��� ��$���Ü0è0ì01 1t1x12 2@2\2`2h2t2�0�� ���0��������������������������������������������������������������������������������������������������������������������������������������������������<?php
  54053. namespace Symfony\Component\Console;
  54054. use Symfony\Component\Console\Exception\RuntimeException;
  54055. use Symfony\Component\Console\Input\StringInput;
  54056. use Symfony\Component\Console\Output\ConsoleOutput;
  54057. use Symfony\Component\Process\PhpExecutableFinder;
  54058. use Symfony\Component\Process\ProcessBuilder;
  54059. class Shell
  54060. {
  54061. private $application;
  54062. private $history;
  54063. private $output;
  54064. private $hasReadline;
  54065. private $processIsolation = false;
  54066. public function __construct(Application $application)
  54067. {
  54068. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  54069. $this->hasReadline = \function_exists('readline');
  54070. $this->application = $application;
  54071. $this->history = getenv('HOME').'/.history_'.$application->getName();
  54072. $this->output = new ConsoleOutput();
  54073. }
  54074. public function run()
  54075. {
  54076. $this->application->setAutoExit(false);
  54077. $this->application->setCatchExceptions(true);
  54078. if ($this->hasReadline) {
  54079. readline_read_history($this->history);
  54080. readline_completion_function(array($this, 'autocompleter'));
  54081. }
  54082. $this->output->writeln($this->getHeader());
  54083. $php = null;
  54084. if ($this->processIsolation) {
  54085. $finder = new PhpExecutableFinder();
  54086. $php = $finder->find();
  54087. $this->output->writeln(<<<'EOF'
  54088. <info>Running with process isolation, you should consider this:</info>
  54089. * each command is executed as separate process,
  54090. * commands don't support interactivity, all params must be passed explicitly,
  54091. * commands output is not colorized.
  54092. EOF
  54093. );
  54094. }
  54095. while (true) {
  54096. $command = $this->readline();
  54097. if (false === $command) {
  54098. $this->output->writeln("\n");
  54099. break;
  54100. }
  54101. if ($this->hasReadline) {
  54102. readline_add_history($command);
  54103. readline_write_history($this->history);
  54104. }
  54105. if ($this->processIsolation) {
  54106. $pb = new ProcessBuilder();
  54107. $process = $pb
  54108. ->add($php)
  54109. ->add($_SERVER['argv'][0])
  54110. ->add($command)
  54111. ->inheritEnvironmentVariables(true)
  54112. ->getProcess()
  54113. ;
  54114. $output = $this->output;
  54115. $process->run(function ($type, $data) use ($output) {
  54116. $output->writeln($data);
  54117. });
  54118. $ret = $process->getExitCode();
  54119. } else {
  54120. $ret = $this->application->run(new StringInput($command), $this->output);
  54121. }
  54122. if (0 !== $ret) {
  54123. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  54124. }
  54125. }
  54126. }
  54127. protected function getHeader()
  54128. {
  54129. return <<<EOF
  54130. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  54131. At the prompt, type <comment>help</comment> for some help,
  54132. or <comment>list</comment> to get a list of available commands.
  54133. To exit the shell, type <comment>^D</comment>.
  54134. EOF;
  54135. }
  54136. protected function getPrompt()
  54137. {
  54138. return $this->output->getFormatter()->format($this->application->getName().' > ');
  54139. }
  54140. protected function getOutput()
  54141. {
  54142. return $this->output;
  54143. }
  54144. protected function getApplication()
  54145. {
  54146. return $this->application;
  54147. }
  54148. private function autocompleter($text)
  54149. {
  54150. $info = readline_info();
  54151. $text = substr($info['line_buffer'], 0, $info['end']);
  54152. if ($info['point'] !== $info['end']) {
  54153. return true;
  54154. }
  54155. if (false === strpos($text, ' ') || !$text) {
  54156. return array_keys($this->application->all());
  54157. }
  54158. try {
  54159. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  54160. } catch (\Exception $e) {
  54161. return true;
  54162. }
  54163. $list = array('--help');
  54164. foreach ($command->getDefinition()->getOptions() as $option) {
  54165. $list[] = '--'.$option->getName();
  54166. }
  54167. return $list;
  54168. }
  54169. private function readline()
  54170. {
  54171. if ($this->hasReadline) {
  54172. $line = readline($this->getPrompt());
  54173. } else {
  54174. $this->output->write($this->getPrompt());
  54175. $line = fgets(STDIN, 1024);
  54176. $line = (false === $line || '' === $line) ? false : rtrim($line);
  54177. }
  54178. return $line;
  54179. }
  54180. public function getProcessIsolation()
  54181. {
  54182. return $this->processIsolation;
  54183. }
  54184. public function setProcessIsolation($processIsolation)
  54185. {
  54186. $this->processIsolation = (bool) $processIsolation;
  54187. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  54188. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  54189. }
  54190. }
  54191. }
  54192. <?php
  54193. namespace Symfony\Component\Console\Style;
  54194. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  54195. use Symfony\Component\Console\Helper\ProgressBar;
  54196. use Symfony\Component\Console\Output\OutputInterface;
  54197. abstract class OutputStyle implements OutputInterface, StyleInterface
  54198. {
  54199. private $output;
  54200. public function __construct(OutputInterface $output)
  54201. {
  54202. $this->output = $output;
  54203. }
  54204. public function newLine($count = 1)
  54205. {
  54206. $this->output->write(str_repeat(PHP_EOL, $count));
  54207. }
  54208. public function createProgressBar($max = 0)
  54209. {
  54210. return new ProgressBar($this->output, $max);
  54211. }
  54212. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  54213. {
  54214. $this->output->write($messages, $newline, $type);
  54215. }
  54216. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  54217. {
  54218. $this->output->writeln($messages, $type);
  54219. }
  54220. public function setVerbosity($level)
  54221. {
  54222. $this->output->setVerbosity($level);
  54223. }
  54224. public function getVerbosity()
  54225. {
  54226. return $this->output->getVerbosity();
  54227. }
  54228. public function setDecorated($decorated)
  54229. {
  54230. $this->output->setDecorated($decorated);
  54231. }
  54232. public function isDecorated()
  54233. {
  54234. return $this->output->isDecorated();
  54235. }
  54236. public function setFormatter(OutputFormatterInterface $formatter)
  54237. {
  54238. $this->output->setFormatter($formatter);
  54239. }
  54240. public function getFormatter()
  54241. {
  54242. return $this->output->getFormatter();
  54243. }
  54244. }
  54245. <?php
  54246. namespace Symfony\Component\Console\Style;
  54247. interface StyleInterface
  54248. {
  54249. public function title($message);
  54250. public function section($message);
  54251. public function listing(array $elements);
  54252. public function text($message);
  54253. public function success($message);
  54254. public function error($message);
  54255. public function warning($message);
  54256. public function note($message);
  54257. public function caution($message);
  54258. public function table(array $headers, array $rows);
  54259. public function ask($question, $default = null, $validator = null);
  54260. public function askHidden($question, $validator = null);
  54261. public function confirm($question, $default = true);
  54262. public function choice($question, array $choices, $default = null);
  54263. public function newLine($count = 1);
  54264. public function progressStart($max = 0);
  54265. public function progressAdvance($step = 1);
  54266. public function progressFinish();
  54267. }
  54268. <?php
  54269. namespace Symfony\Component\Console\Style;
  54270. use Symfony\Component\Console\Application;
  54271. use Symfony\Component\Console\Exception\RuntimeException;
  54272. use Symfony\Component\Console\Formatter\OutputFormatter;
  54273. use Symfony\Component\Console\Helper\Helper;
  54274. use Symfony\Component\Console\Helper\ProgressBar;
  54275. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  54276. use Symfony\Component\Console\Helper\Table;
  54277. use Symfony\Component\Console\Input\InputInterface;
  54278. use Symfony\Component\Console\Output\BufferedOutput;
  54279. use Symfony\Component\Console\Output\OutputInterface;
  54280. use Symfony\Component\Console\Question\ChoiceQuestion;
  54281. use Symfony\Component\Console\Question\ConfirmationQuestion;
  54282. use Symfony\Component\Console\Question\Question;
  54283. class SymfonyStyle extends OutputStyle
  54284. {
  54285. const MAX_LINE_LENGTH = 120;
  54286. private $input;
  54287. private $questionHelper;
  54288. private $progressBar;
  54289. private $lineLength;
  54290. private $bufferedOutput;
  54291. public function __construct(InputInterface $input, OutputInterface $output)
  54292. {
  54293. $this->input = $input;
  54294. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  54295. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  54296. parent::__construct($output);
  54297. }
  54298. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  54299. {
  54300. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  54301. $this->autoPrependBlock();
  54302. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  54303. $this->newLine();
  54304. }
  54305. public function title($message)
  54306. {
  54307. $this->autoPrependBlock();
  54308. $this->writeln(array(
  54309. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  54310. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  54311. ));
  54312. $this->newLine();
  54313. }
  54314. public function section($message)
  54315. {
  54316. $this->autoPrependBlock();
  54317. $this->writeln(array(
  54318. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  54319. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  54320. ));
  54321. $this->newLine();
  54322. }
  54323. public function listing(array $elements)
  54324. {
  54325. $this->autoPrependText();
  54326. $elements = array_map(function ($element) {
  54327. return sprintf(' * %s', $element);
  54328. }, $elements);
  54329. $this->writeln($elements);
  54330. $this->newLine();
  54331. }
  54332. public function text($message)
  54333. {
  54334. $this->autoPrependText();
  54335. $messages = \is_array($message) ? array_values($message) : array($message);
  54336. foreach ($messages as $message) {
  54337. $this->writeln(sprintf(' %s', $message));
  54338. }
  54339. }
  54340. public function comment($message)
  54341. {
  54342. $messages = \is_array($message) ? array_values($message) : array($message);
  54343. $this->autoPrependBlock();
  54344. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  54345. $this->newLine();
  54346. }
  54347. public function success($message)
  54348. {
  54349. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  54350. }
  54351. public function error($message)
  54352. {
  54353. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  54354. }
  54355. public function warning($message)
  54356. {
  54357. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  54358. }
  54359. public function note($message)
  54360. {
  54361. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  54362. }
  54363. public function caution($message)
  54364. {
  54365. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  54366. }
  54367. public function table(array $headers, array $rows)
  54368. {
  54369. $style = clone Table::getStyleDefinition('symfony-style-guide');
  54370. $style->setCellHeaderFormat('<info>%s</info>');
  54371. $table = new Table($this);
  54372. $table->setHeaders($headers);
  54373. $table->setRows($rows);
  54374. $table->setStyle($style);
  54375. $table->render();
  54376. $this->newLine();
  54377. }
  54378. public function ask($question, $default = null, $validator = null)
  54379. {
  54380. $question = new Question($question, $default);
  54381. $question->setValidator($validator);
  54382. return $this->askQuestion($question);
  54383. }
  54384. public function askHidden($question, $validator = null)
  54385. {
  54386. $question = new Question($question);
  54387. $question->setHidden(true);
  54388. $question->setValidator($validator);
  54389. return $this->askQuestion($question);
  54390. }
  54391. public function confirm($question, $default = true)
  54392. {
  54393. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  54394. }
  54395. public function choice($question, array $choices, $default = null)
  54396. {
  54397. if (null !== $default) {
  54398. $values = array_flip($choices);
  54399. $default = $values[$default];
  54400. }
  54401. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  54402. }
  54403. public function progressStart($max = 0)
  54404. {
  54405. $this->progressBar = $this->createProgressBar($max);
  54406. $this->progressBar->start();
  54407. }
  54408. public function progressAdvance($step = 1)
  54409. {
  54410. $this->getProgressBar()->advance($step);
  54411. }
  54412. public function progressFinish()
  54413. {
  54414. $this->getProgressBar()->finish();
  54415. $this->newLine(2);
  54416. $this->progressBar = null;
  54417. }
  54418. public function createProgressBar($max = 0)
  54419. {
  54420. $progressBar = parent::createProgressBar($max);
  54421. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  54422. $progressBar->setEmptyBarCharacter('â–‘');
  54423. $progressBar->setProgressCharacter('');
  54424. $progressBar->setBarCharacter('â–“');
  54425. }
  54426. return $progressBar;
  54427. }
  54428. public function askQuestion(Question $question)
  54429. {
  54430. if ($this->input->isInteractive()) {
  54431. $this->autoPrependBlock();
  54432. }
  54433. if (!$this->questionHelper) {
  54434. $this->questionHelper = new SymfonyQuestionHelper();
  54435. }
  54436. $answer = $this->questionHelper->ask($this->input, $this, $question);
  54437. if ($this->input->isInteractive()) {
  54438. $this->newLine();
  54439. $this->bufferedOutput->write("\n");
  54440. }
  54441. return $answer;
  54442. }
  54443. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  54444. {
  54445. parent::writeln($messages, $type);
  54446. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  54447. }
  54448. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  54449. {
  54450. parent::write($messages, $newline, $type);
  54451. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  54452. }
  54453. public function newLine($count = 1)
  54454. {
  54455. parent::newLine($count);
  54456. $this->bufferedOutput->write(str_repeat("\n", $count));
  54457. }
  54458. private function getProgressBar()
  54459. {
  54460. if (!$this->progressBar) {
  54461. throw new RuntimeException('The ProgressBar is not started.');
  54462. }
  54463. return $this->progressBar;
  54464. }
  54465. private function getTerminalWidth()
  54466. {
  54467. $application = new Application();
  54468. $dimensions = $application->getTerminalDimensions();
  54469. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  54470. }
  54471. private function autoPrependBlock()
  54472. {
  54473. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  54474. if (!isset($chars[0])) {
  54475. return $this->newLine();
  54476. }
  54477. $this->newLine(2 - substr_count($chars, "\n"));
  54478. }
  54479. private function autoPrependText()
  54480. {
  54481. $fetched = $this->bufferedOutput->fetch();
  54482. if ("\n" !== substr($fetched, -1)) {
  54483. $this->newLine();
  54484. }
  54485. }
  54486. private function reduceBuffer($messages)
  54487. {
  54488. return array_map(function ($value) {
  54489. return substr($value, -4);
  54490. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  54491. }
  54492. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  54493. {
  54494. $indentLength = 0;
  54495. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  54496. $lines = array();
  54497. if (null !== $type) {
  54498. $type = sprintf('[%s] ', $type);
  54499. $indentLength = \strlen($type);
  54500. $lineIndentation = str_repeat(' ', $indentLength);
  54501. }
  54502. foreach ($messages as $key => $message) {
  54503. if ($escape) {
  54504. $message = OutputFormatter::escape($message);
  54505. }
  54506. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  54507. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  54508. $lines[] = '';
  54509. }
  54510. }
  54511. $firstLineIndex = 0;
  54512. if ($padding && $this->isDecorated()) {
  54513. $firstLineIndex = 1;
  54514. array_unshift($lines, '');
  54515. $lines[] = '';
  54516. }
  54517. foreach ($lines as $i => &$line) {
  54518. if (null !== $type) {
  54519. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  54520. }
  54521. $line = $prefix.$line;
  54522. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  54523. if ($style) {
  54524. $line = sprintf('<%s>%s</>', $style, $line);
  54525. }
  54526. }
  54527. return $lines;
  54528. }
  54529. }
  54530. <?php
  54531. namespace Symfony\Component\Console\Tester;
  54532. use Symfony\Component\Console\Application;
  54533. use Symfony\Component\Console\Input\ArrayInput;
  54534. use Symfony\Component\Console\Input\InputInterface;
  54535. use Symfony\Component\Console\Output\OutputInterface;
  54536. use Symfony\Component\Console\Output\StreamOutput;
  54537. class ApplicationTester
  54538. {
  54539. private $application;
  54540. private $input;
  54541. private $output;
  54542. private $statusCode;
  54543. public function __construct(Application $application)
  54544. {
  54545. $this->application = $application;
  54546. }
  54547. public function run(array $input, $options = array())
  54548. {
  54549. $this->input = new ArrayInput($input);
  54550. if (isset($options['interactive'])) {
  54551. $this->input->setInteractive($options['interactive']);
  54552. }
  54553. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  54554. if (isset($options['decorated'])) {
  54555. $this->output->setDecorated($options['decorated']);
  54556. }
  54557. if (isset($options['verbosity'])) {
  54558. $this->output->setVerbosity($options['verbosity']);
  54559. }
  54560. return $this->statusCode = $this->application->run($this->input, $this->output);
  54561. }
  54562. public function getDisplay($normalize = false)
  54563. {
  54564. rewind($this->output->getStream());
  54565. $display = stream_get_contents($this->output->getStream());
  54566. if ($normalize) {
  54567. $display = str_replace(PHP_EOL, "\n", $display);
  54568. }
  54569. return $display;
  54570. }
  54571. public function getInput()
  54572. {
  54573. return $this->input;
  54574. }
  54575. public function getOutput()
  54576. {
  54577. return $this->output;
  54578. }
  54579. public function getStatusCode()
  54580. {
  54581. return $this->statusCode;
  54582. }
  54583. }
  54584. <?php
  54585. namespace Symfony\Component\Console\Tester;
  54586. use Symfony\Component\Console\Command\Command;
  54587. use Symfony\Component\Console\Input\ArrayInput;
  54588. use Symfony\Component\Console\Input\InputInterface;
  54589. use Symfony\Component\Console\Output\OutputInterface;
  54590. use Symfony\Component\Console\Output\StreamOutput;
  54591. class CommandTester
  54592. {
  54593. private $command;
  54594. private $input;
  54595. private $output;
  54596. private $statusCode;
  54597. public function __construct(Command $command)
  54598. {
  54599. $this->command = $command;
  54600. }
  54601. public function execute(array $input, array $options = array())
  54602. {
  54603. if (!isset($input['command'])
  54604. && (null !== $application = $this->command->getApplication())
  54605. && $application->getDefinition()->hasArgument('command')
  54606. ) {
  54607. $input = array_merge(array('command' => $this->command->getName()), $input);
  54608. }
  54609. $this->input = new ArrayInput($input);
  54610. if (isset($options['interactive'])) {
  54611. $this->input->setInteractive($options['interactive']);
  54612. }
  54613. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  54614. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  54615. if (isset($options['verbosity'])) {
  54616. $this->output->setVerbosity($options['verbosity']);
  54617. }
  54618. return $this->statusCode = $this->command->run($this->input, $this->output);
  54619. }
  54620. public function getDisplay($normalize = false)
  54621. {
  54622. rewind($this->output->getStream());
  54623. $display = stream_get_contents($this->output->getStream());
  54624. if ($normalize) {
  54625. $display = str_replace(PHP_EOL, "\n", $display);
  54626. }
  54627. return $display;
  54628. }
  54629. public function getInput()
  54630. {
  54631. return $this->input;
  54632. }
  54633. public function getOutput()
  54634. {
  54635. return $this->output;
  54636. }
  54637. public function getStatusCode()
  54638. {
  54639. return $this->statusCode;
  54640. }
  54641. }
  54642. <?php
  54643. namespace Symfony\Component\Debug;
  54644. use Psr\Log\AbstractLogger;
  54645. class BufferingLogger extends AbstractLogger
  54646. {
  54647. private $logs = array();
  54648. public function log($level, $message, array $context = array())
  54649. {
  54650. $this->logs[] = array($level, $message, $context);
  54651. }
  54652. public function cleanLogs()
  54653. {
  54654. $logs = $this->logs;
  54655. $this->logs = array();
  54656. return $logs;
  54657. }
  54658. }
  54659. <?php
  54660. namespace Symfony\Component\Debug;
  54661. class Debug
  54662. {
  54663. private static $enabled = false;
  54664. public static function enable($errorReportingLevel = null, $displayErrors = true)
  54665. {
  54666. if (static::$enabled) {
  54667. return;
  54668. }
  54669. static::$enabled = true;
  54670. if (null !== $errorReportingLevel) {
  54671. error_reporting($errorReportingLevel);
  54672. } else {
  54673. error_reporting(-1);
  54674. }
  54675. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  54676. ini_set('display_errors', 0);
  54677. ExceptionHandler::register();
  54678. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  54679. ini_set('display_errors', 1);
  54680. }
  54681. if ($displayErrors) {
  54682. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  54683. } else {
  54684. ErrorHandler::register()->throwAt(0, true);
  54685. }
  54686. DebugClassLoader::enable();
  54687. }
  54688. }
  54689. <?php
  54690. namespace Symfony\Component\Debug;
  54691. class DebugClassLoader
  54692. {
  54693. private $classLoader;
  54694. private $isFinder;
  54695. private $loaded = array();
  54696. private $wasFinder;
  54697. private static $caseCheck;
  54698. private static $deprecated = array();
  54699. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  54700. private static $darwinCache = array('/' => array('/', array()));
  54701. public function __construct($classLoader)
  54702. {
  54703. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  54704. if ($this->wasFinder) {
  54705. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  54706. $this->classLoader = array($classLoader, 'loadClass');
  54707. $this->isFinder = true;
  54708. } else {
  54709. $this->classLoader = $classLoader;
  54710. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  54711. }
  54712. if (!isset(self::$caseCheck)) {
  54713. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  54714. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  54715. $dir = substr($file, 0, 1 + $i);
  54716. $file = substr($file, 1 + $i);
  54717. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  54718. $test = realpath($dir.$test);
  54719. if (false === $test || false === $i) {
  54720. self::$caseCheck = 0;
  54721. } elseif (substr($test, -\strlen($file)) === $file) {
  54722. self::$caseCheck = 1;
  54723. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  54724. self::$caseCheck = 2;
  54725. } else {
  54726. self::$caseCheck = 0;
  54727. }
  54728. }
  54729. }
  54730. public function getClassLoader()
  54731. {
  54732. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  54733. }
  54734. public static function enable()
  54735. {
  54736. class_exists('Symfony\Component\Debug\ErrorHandler');
  54737. class_exists('Psr\Log\LogLevel');
  54738. if (!\is_array($functions = spl_autoload_functions())) {
  54739. return;
  54740. }
  54741. foreach ($functions as $function) {
  54742. spl_autoload_unregister($function);
  54743. }
  54744. foreach ($functions as $function) {
  54745. if (!\is_array($function) || !$function[0] instanceof self) {
  54746. $function = array(new static($function), 'loadClass');
  54747. }
  54748. spl_autoload_register($function);
  54749. }
  54750. }
  54751. public static function disable()
  54752. {
  54753. if (!\is_array($functions = spl_autoload_functions())) {
  54754. return;
  54755. }
  54756. foreach ($functions as $function) {
  54757. spl_autoload_unregister($function);
  54758. }
  54759. foreach ($functions as $function) {
  54760. if (\is_array($function) && $function[0] instanceof self) {
  54761. $function = $function[0]->getClassLoader();
  54762. }
  54763. spl_autoload_register($function);
  54764. }
  54765. }
  54766. public function findFile($class)
  54767. {
  54768. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  54769. if ($this->wasFinder) {
  54770. return $this->classLoader[0]->findFile($class);
  54771. }
  54772. }
  54773. public function loadClass($class)
  54774. {
  54775. ErrorHandler::stackErrors();
  54776. try {
  54777. if ($this->isFinder && !isset($this->loaded[$class])) {
  54778. $this->loaded[$class] = true;
  54779. if ($file = $this->classLoader[0]->findFile($class)) {
  54780. require $file;
  54781. }
  54782. } else {
  54783. \call_user_func($this->classLoader, $class);
  54784. $file = false;
  54785. }
  54786. } catch (\Exception $e) {
  54787. ErrorHandler::unstackErrors();
  54788. throw $e;
  54789. } catch (\Throwable $e) {
  54790. ErrorHandler::unstackErrors();
  54791. throw $e;
  54792. }
  54793. ErrorHandler::unstackErrors();
  54794. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  54795. if ($class && '\\' === $class[0]) {
  54796. $class = substr($class, 1);
  54797. }
  54798. if ($exists) {
  54799. $refl = new \ReflectionClass($class);
  54800. $name = $refl->getName();
  54801. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  54802. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  54803. }
  54804. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  54805. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  54806. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  54807. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  54808. } else {
  54809. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  54810. $len = 0;
  54811. $ns = '';
  54812. } else {
  54813. $ns = substr($name, 0, $len);
  54814. }
  54815. $parent = get_parent_class($class);
  54816. if (!$parent || strncmp($ns, $parent, $len)) {
  54817. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  54818. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  54819. }
  54820. $parentInterfaces = array();
  54821. $deprecatedInterfaces = array();
  54822. if ($parent) {
  54823. foreach (class_implements($parent) as $interface) {
  54824. $parentInterfaces[$interface] = 1;
  54825. }
  54826. }
  54827. foreach ($refl->getInterfaceNames() as $interface) {
  54828. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  54829. $deprecatedInterfaces[] = $interface;
  54830. }
  54831. foreach (class_implements($interface) as $interface) {
  54832. $parentInterfaces[$interface] = 1;
  54833. }
  54834. }
  54835. foreach ($deprecatedInterfaces as $interface) {
  54836. if (!isset($parentInterfaces[$interface])) {
  54837. @trigger_error(sprintf('The %s %s %s that is deprecated %s', $name, $refl->isInterface() ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
  54838. }
  54839. }
  54840. }
  54841. }
  54842. }
  54843. if ($file) {
  54844. if (!$exists) {
  54845. if (false !== strpos($class, '/')) {
  54846. throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
  54847. }
  54848. throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
  54849. }
  54850. if (self::$caseCheck) {
  54851. $real = explode('\\', $class.strrchr($file, '.'));
  54852. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  54853. $i = \count($tail) - 1;
  54854. $j = \count($real) - 1;
  54855. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  54856. --$i;
  54857. --$j;
  54858. }
  54859. array_splice($tail, 0, $i + 1);
  54860. }
  54861. if (self::$caseCheck && $tail) {
  54862. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  54863. $tailLen = \strlen($tail);
  54864. $real = $refl->getFileName();
  54865. if (2 === self::$caseCheck) {
  54866. $i = 1 + strrpos($real, '/');
  54867. $file = substr($real, $i);
  54868. $real = substr($real, 0, $i);
  54869. if (isset(self::$darwinCache[$real])) {
  54870. $kDir = $real;
  54871. } else {
  54872. $kDir = strtolower($real);
  54873. if (isset(self::$darwinCache[$kDir])) {
  54874. $real = self::$darwinCache[$kDir][0];
  54875. } else {
  54876. $dir = getcwd();
  54877. chdir($real);
  54878. $real = getcwd().'/';
  54879. chdir($dir);
  54880. $dir = $real;
  54881. $k = $kDir;
  54882. $i = \strlen($dir) - 1;
  54883. while (!isset(self::$darwinCache[$k])) {
  54884. self::$darwinCache[$k] = array($dir, array());
  54885. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  54886. while ('/' !== $dir[--$i]) {
  54887. }
  54888. $k = substr($k, 0, ++$i);
  54889. $dir = substr($dir, 0, $i--);
  54890. }
  54891. }
  54892. }
  54893. $dirFiles = self::$darwinCache[$kDir][1];
  54894. if (isset($dirFiles[$file])) {
  54895. $kFile = $file;
  54896. } else {
  54897. $kFile = strtolower($file);
  54898. if (!isset($dirFiles[$kFile])) {
  54899. foreach (scandir($real, 2) as $f) {
  54900. if ('.' !== $f[0]) {
  54901. $dirFiles[$f] = $f;
  54902. if ($f === $file) {
  54903. $kFile = $k = $file;
  54904. } elseif ($f !== $k = strtolower($f)) {
  54905. $dirFiles[$k] = $f;
  54906. }
  54907. }
  54908. }
  54909. self::$darwinCache[$kDir][1] = $dirFiles;
  54910. }
  54911. }
  54912. $real .= $dirFiles[$kFile];
  54913. }
  54914. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  54915. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  54916. ) {
  54917. throw new \RuntimeException(sprintf('Case mismatch between class and real file names: %s vs %s in %s', substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)));
  54918. }
  54919. }
  54920. return true;
  54921. }
  54922. }
  54923. }
  54924. <?php
  54925. namespace Symfony\Component\Debug;
  54926. use Psr\Log\LoggerInterface;
  54927. use Psr\Log\LogLevel;
  54928. use Symfony\Component\Debug\Exception\ContextErrorException;
  54929. use Symfony\Component\Debug\Exception\FatalErrorException;
  54930. use Symfony\Component\Debug\Exception\FatalThrowableError;
  54931. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  54932. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  54933. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  54934. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  54935. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  54936. class ErrorHandler
  54937. {
  54938. const TYPE_DEPRECATION = -100;
  54939. private $levels = array(
  54940. E_DEPRECATED => 'Deprecated',
  54941. E_USER_DEPRECATED => 'User Deprecated',
  54942. E_NOTICE => 'Notice',
  54943. E_USER_NOTICE => 'User Notice',
  54944. E_STRICT => 'Runtime Notice',
  54945. E_WARNING => 'Warning',
  54946. E_USER_WARNING => 'User Warning',
  54947. E_COMPILE_WARNING => 'Compile Warning',
  54948. E_CORE_WARNING => 'Core Warning',
  54949. E_USER_ERROR => 'User Error',
  54950. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  54951. E_COMPILE_ERROR => 'Compile Error',
  54952. E_PARSE => 'Parse Error',
  54953. E_ERROR => 'Error',
  54954. E_CORE_ERROR => 'Core Error',
  54955. );
  54956. private $loggers = array(
  54957. E_DEPRECATED => array(null, LogLevel::INFO),
  54958. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  54959. E_NOTICE => array(null, LogLevel::WARNING),
  54960. E_USER_NOTICE => array(null, LogLevel::WARNING),
  54961. E_STRICT => array(null, LogLevel::WARNING),
  54962. E_WARNING => array(null, LogLevel::WARNING),
  54963. E_USER_WARNING => array(null, LogLevel::WARNING),
  54964. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  54965. E_CORE_WARNING => array(null, LogLevel::WARNING),
  54966. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  54967. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  54968. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  54969. E_PARSE => array(null, LogLevel::CRITICAL),
  54970. E_ERROR => array(null, LogLevel::CRITICAL),
  54971. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  54972. );
  54973. private $thrownErrors = 0x1FFF;
  54974. private $scopedErrors = 0x1FFF;
  54975. private $tracedErrors = 0x77FB;
  54976. private $screamedErrors = 0x55;
  54977. private $loggedErrors = 0;
  54978. private $loggedTraces = array();
  54979. private $isRecursive = 0;
  54980. private $isRoot = false;
  54981. private $exceptionHandler;
  54982. private $bootstrappingLogger;
  54983. private static $reservedMemory;
  54984. private static $stackedErrors = array();
  54985. private static $stackedErrorLevels = array();
  54986. private static $toStringException = null;
  54987. private static $exitCode = 0;
  54988. private $displayErrors = 0x1FFF;
  54989. public static function register($handler = null, $replace = true)
  54990. {
  54991. if (null === self::$reservedMemory) {
  54992. self::$reservedMemory = str_repeat('x', 10240);
  54993. register_shutdown_function(__CLASS__.'::handleFatalError');
  54994. }
  54995. $levels = -1;
  54996. if ($handlerIsNew = !$handler instanceof self) {
  54997. if (null !== $handler) {
  54998. $levels = $replace ? $handler : 0;
  54999. $replace = true;
  55000. }
  55001. $handler = new static();
  55002. }
  55003. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  55004. restore_error_handler();
  55005. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  55006. $handler->isRoot = true;
  55007. }
  55008. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  55009. $handler = $prev[0];
  55010. $replace = false;
  55011. }
  55012. if (!$replace && $prev) {
  55013. restore_error_handler();
  55014. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  55015. } else {
  55016. $handlerIsRegistered = true;
  55017. }
  55018. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  55019. restore_exception_handler();
  55020. if (!$handlerIsRegistered) {
  55021. $handler = $prev[0];
  55022. } elseif ($handler !== $prev[0] && $replace) {
  55023. set_exception_handler(array($handler, 'handleException'));
  55024. $p = $prev[0]->setExceptionHandler(null);
  55025. $handler->setExceptionHandler($p);
  55026. $prev[0]->setExceptionHandler($p);
  55027. }
  55028. } else {
  55029. $handler->setExceptionHandler($prev);
  55030. }
  55031. $handler->throwAt($levels & $handler->thrownErrors, true);
  55032. return $handler;
  55033. }
  55034. public function __construct(BufferingLogger $bootstrappingLogger = null)
  55035. {
  55036. if ($bootstrappingLogger) {
  55037. $this->bootstrappingLogger = $bootstrappingLogger;
  55038. $this->setDefaultLogger($bootstrappingLogger);
  55039. }
  55040. }
  55041. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  55042. {
  55043. $loggers = array();
  55044. if (\is_array($levels)) {
  55045. foreach ($levels as $type => $logLevel) {
  55046. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  55047. $loggers[$type] = array($logger, $logLevel);
  55048. }
  55049. }
  55050. } else {
  55051. if (null === $levels) {
  55052. $levels = E_ALL | E_STRICT;
  55053. }
  55054. foreach ($this->loggers as $type => $log) {
  55055. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  55056. $log[0] = $logger;
  55057. $loggers[$type] = $log;
  55058. }
  55059. }
  55060. }
  55061. $this->setLoggers($loggers);
  55062. }
  55063. public function setLoggers(array $loggers)
  55064. {
  55065. $prevLogged = $this->loggedErrors;
  55066. $prev = $this->loggers;
  55067. $flush = array();
  55068. foreach ($loggers as $type => $log) {
  55069. if (!isset($prev[$type])) {
  55070. throw new \InvalidArgumentException('Unknown error type: '.$type);
  55071. }
  55072. if (!\is_array($log)) {
  55073. $log = array($log);
  55074. } elseif (!array_key_exists(0, $log)) {
  55075. throw new \InvalidArgumentException('No logger provided');
  55076. }
  55077. if (null === $log[0]) {
  55078. $this->loggedErrors &= ~$type;
  55079. } elseif ($log[0] instanceof LoggerInterface) {
  55080. $this->loggedErrors |= $type;
  55081. } else {
  55082. throw new \InvalidArgumentException('Invalid logger provided');
  55083. }
  55084. $this->loggers[$type] = $log + $prev[$type];
  55085. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  55086. $flush[$type] = $type;
  55087. }
  55088. }
  55089. $this->reRegister($prevLogged | $this->thrownErrors);
  55090. if ($flush) {
  55091. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  55092. $type = $log[2]['type'];
  55093. if (!isset($flush[$type])) {
  55094. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  55095. } elseif ($this->loggers[$type][0]) {
  55096. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  55097. }
  55098. }
  55099. }
  55100. return $prev;
  55101. }
  55102. public function setExceptionHandler($handler)
  55103. {
  55104. if (null !== $handler && !\is_callable($handler)) {
  55105. throw new \LogicException('The exception handler must be a valid PHP callable.');
  55106. }
  55107. $prev = $this->exceptionHandler;
  55108. $this->exceptionHandler = $handler;
  55109. return $prev;
  55110. }
  55111. public function throwAt($levels, $replace = false)
  55112. {
  55113. $prev = $this->thrownErrors;
  55114. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  55115. if (!$replace) {
  55116. $this->thrownErrors |= $prev;
  55117. }
  55118. $this->reRegister($prev | $this->loggedErrors);
  55119. $this->displayErrors = $this->thrownErrors;
  55120. return $prev;
  55121. }
  55122. public function scopeAt($levels, $replace = false)
  55123. {
  55124. $prev = $this->scopedErrors;
  55125. $this->scopedErrors = (int) $levels;
  55126. if (!$replace) {
  55127. $this->scopedErrors |= $prev;
  55128. }
  55129. return $prev;
  55130. }
  55131. public function traceAt($levels, $replace = false)
  55132. {
  55133. $prev = $this->tracedErrors;
  55134. $this->tracedErrors = (int) $levels;
  55135. if (!$replace) {
  55136. $this->tracedErrors |= $prev;
  55137. }
  55138. return $prev;
  55139. }
  55140. public function screamAt($levels, $replace = false)
  55141. {
  55142. $prev = $this->screamedErrors;
  55143. $this->screamedErrors = (int) $levels;
  55144. if (!$replace) {
  55145. $this->screamedErrors |= $prev;
  55146. }
  55147. return $prev;
  55148. }
  55149. private function reRegister($prev)
  55150. {
  55151. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  55152. $handler = set_error_handler('var_dump');
  55153. $handler = \is_array($handler) ? $handler[0] : null;
  55154. restore_error_handler();
  55155. if ($handler === $this) {
  55156. restore_error_handler();
  55157. if ($this->isRoot) {
  55158. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  55159. } else {
  55160. set_error_handler(array($this, 'handleError'));
  55161. }
  55162. }
  55163. }
  55164. }
  55165. public function handleError($type, $message, $file, $line)
  55166. {
  55167. $level = error_reporting();
  55168. $silenced = 0 === ($level & $type);
  55169. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  55170. $log = $this->loggedErrors & $type;
  55171. $throw = $this->thrownErrors & $type & $level;
  55172. $type &= $level | $this->screamedErrors;
  55173. if (!$type || (!$log && !$throw)) {
  55174. return !$silenced && $type && $log;
  55175. }
  55176. $scope = $this->scopedErrors & $type;
  55177. if (4 < $numArgs = \func_num_args()) {
  55178. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  55179. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  55180. } else {
  55181. $context = array();
  55182. $backtrace = null;
  55183. }
  55184. if (isset($context['GLOBALS']) && $scope) {
  55185. $e = $context;
  55186. unset($e['GLOBALS'], $context);
  55187. $context = $e;
  55188. }
  55189. if (null !== $backtrace && $type & E_ERROR) {
  55190. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  55191. return true;
  55192. }
  55193. if ($throw) {
  55194. if (null !== self::$toStringException) {
  55195. $throw = self::$toStringException;
  55196. self::$toStringException = null;
  55197. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  55198. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  55199. } else {
  55200. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  55201. }
  55202. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  55203. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  55204. }
  55205. if (E_USER_ERROR & $type) {
  55206. $backtrace = $backtrace ?: $throw->getTrace();
  55207. for ($i = 1; isset($backtrace[$i]); ++$i) {
  55208. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  55209. && '__toString' === $backtrace[$i]['function']
  55210. && '->' === $backtrace[$i]['type']
  55211. && !isset($backtrace[$i - 1]['class'])
  55212. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  55213. ) {
  55214. foreach ($context as $e) {
  55215. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  55216. if (1 === $i) {
  55217. $throw = $e;
  55218. break;
  55219. }
  55220. self::$toStringException = $e;
  55221. return true;
  55222. }
  55223. }
  55224. if (1 < $i) {
  55225. $this->handleException($throw);
  55226. return false;
  55227. }
  55228. }
  55229. }
  55230. }
  55231. throw $throw;
  55232. }
  55233. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  55234. $trace = true;
  55235. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  55236. $trace = false;
  55237. } else {
  55238. $this->loggedTraces[$e] = 1;
  55239. }
  55240. $e = compact('type', 'file', 'line', 'level');
  55241. if ($type & $level) {
  55242. if ($scope) {
  55243. $e['scope_vars'] = $context;
  55244. if ($trace) {
  55245. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  55246. }
  55247. } elseif ($trace) {
  55248. if (null === $backtrace) {
  55249. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  55250. } else {
  55251. foreach ($backtrace as &$frame) {
  55252. unset($frame['args'], $frame);
  55253. }
  55254. $e['stack'] = $backtrace;
  55255. }
  55256. }
  55257. }
  55258. if ($this->isRecursive) {
  55259. $log = 0;
  55260. } elseif (self::$stackedErrorLevels) {
  55261. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  55262. } else {
  55263. try {
  55264. $this->isRecursive = true;
  55265. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  55266. $this->isRecursive = false;
  55267. } catch (\Exception $e) {
  55268. $this->isRecursive = false;
  55269. throw $e;
  55270. } catch (\Throwable $e) {
  55271. $this->isRecursive = false;
  55272. throw $e;
  55273. }
  55274. }
  55275. return !$silenced && $type && $log;
  55276. }
  55277. public function handleException($exception, array $error = null)
  55278. {
  55279. if (null === $error) {
  55280. self::$exitCode = 255;
  55281. }
  55282. if (!$exception instanceof \Exception) {
  55283. $exception = new FatalThrowableError($exception);
  55284. }
  55285. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  55286. $handlerException = null;
  55287. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  55288. $e = array(
  55289. 'type' => $type,
  55290. 'file' => $exception->getFile(),
  55291. 'line' => $exception->getLine(),
  55292. 'level' => error_reporting(),
  55293. 'stack' => $exception->getTrace(),
  55294. );
  55295. if ($exception instanceof FatalErrorException) {
  55296. if ($exception instanceof FatalThrowableError) {
  55297. $error = array(
  55298. 'type' => $type,
  55299. 'message' => $message = $exception->getMessage(),
  55300. 'file' => $e['file'],
  55301. 'line' => $e['line'],
  55302. );
  55303. } else {
  55304. $message = 'Fatal '.$exception->getMessage();
  55305. }
  55306. } elseif ($exception instanceof \ErrorException) {
  55307. $message = 'Uncaught '.$exception->getMessage();
  55308. if ($exception instanceof ContextErrorException) {
  55309. $e['context'] = $exception->getContext();
  55310. }
  55311. } else {
  55312. $message = 'Uncaught Exception: '.$exception->getMessage();
  55313. }
  55314. }
  55315. if ($this->loggedErrors & $type) {
  55316. try {
  55317. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  55318. } catch (\Exception $handlerException) {
  55319. } catch (\Throwable $handlerException) {
  55320. }
  55321. }
  55322. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  55323. foreach ($this->getFatalErrorHandlers() as $handler) {
  55324. if ($e = $handler->handleError($error, $exception)) {
  55325. $exception = $e;
  55326. break;
  55327. }
  55328. }
  55329. }
  55330. $exceptionHandler = $this->exceptionHandler;
  55331. $this->exceptionHandler = null;
  55332. try {
  55333. if (null !== $exceptionHandler) {
  55334. return \call_user_func($exceptionHandler, $exception);
  55335. }
  55336. $handlerException = $handlerException ?: $exception;
  55337. } catch (\Exception $handlerException) {
  55338. } catch (\Throwable $handlerException) {
  55339. }
  55340. if ($exception === $handlerException) {
  55341. self::$reservedMemory = null;
  55342. throw $exception;
  55343. }
  55344. $this->handleException($handlerException);
  55345. }
  55346. public static function handleFatalError(array $error = null)
  55347. {
  55348. if (null === self::$reservedMemory) {
  55349. return;
  55350. }
  55351. $handler = self::$reservedMemory = null;
  55352. $handlers = array();
  55353. $previousHandler = null;
  55354. $sameHandlerLimit = 10;
  55355. while (!\is_array($handler) || !$handler[0] instanceof self) {
  55356. $handler = set_exception_handler('var_dump');
  55357. restore_exception_handler();
  55358. if (!$handler) {
  55359. break;
  55360. }
  55361. restore_exception_handler();
  55362. if ($handler !== $previousHandler) {
  55363. array_unshift($handlers, $handler);
  55364. $previousHandler = $handler;
  55365. } elseif (0 === --$sameHandlerLimit) {
  55366. $handler = null;
  55367. break;
  55368. }
  55369. }
  55370. foreach ($handlers as $h) {
  55371. set_exception_handler($h);
  55372. }
  55373. if (!$handler) {
  55374. return;
  55375. }
  55376. if ($handler !== $h) {
  55377. $handler[0]->setExceptionHandler($h);
  55378. }
  55379. $handler = $handler[0];
  55380. $handlers = array();
  55381. if ($exit = null === $error) {
  55382. $error = error_get_last();
  55383. }
  55384. try {
  55385. while (self::$stackedErrorLevels) {
  55386. static::unstackErrors();
  55387. }
  55388. } catch (\Exception $exception) {
  55389. } catch (\Throwable $exception) {
  55390. }
  55391. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  55392. $handler->throwAt(0, true);
  55393. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  55394. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  55395. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  55396. } else {
  55397. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  55398. }
  55399. }
  55400. try {
  55401. if (isset($exception)) {
  55402. self::$exitCode = 255;
  55403. $handler->handleException($exception, $error);
  55404. }
  55405. } catch (FatalErrorException $e) {
  55406. }
  55407. if ($exit && self::$exitCode) {
  55408. $exitCode = self::$exitCode;
  55409. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  55410. }
  55411. }
  55412. public static function stackErrors()
  55413. {
  55414. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  55415. }
  55416. public static function unstackErrors()
  55417. {
  55418. $level = array_pop(self::$stackedErrorLevels);
  55419. if (null !== $level) {
  55420. $e = error_reporting($level);
  55421. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  55422. error_reporting($e);
  55423. }
  55424. }
  55425. if (empty(self::$stackedErrorLevels)) {
  55426. $errors = self::$stackedErrors;
  55427. self::$stackedErrors = array();
  55428. foreach ($errors as $e) {
  55429. $e[0]->log($e[1], $e[2], $e[3]);
  55430. }
  55431. }
  55432. }
  55433. protected function getFatalErrorHandlers()
  55434. {
  55435. return array(
  55436. new UndefinedFunctionFatalErrorHandler(),
  55437. new UndefinedMethodFatalErrorHandler(),
  55438. new ClassNotFoundFatalErrorHandler(),
  55439. );
  55440. }
  55441. public function setLevel($level)
  55442. {
  55443. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the throwAt() method instead.', E_USER_DEPRECATED);
  55444. $level = null === $level ? error_reporting() : $level;
  55445. $this->throwAt($level, true);
  55446. }
  55447. public function setDisplayErrors($displayErrors)
  55448. {
  55449. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the throwAt() method instead.', E_USER_DEPRECATED);
  55450. if ($displayErrors) {
  55451. $this->throwAt($this->displayErrors, true);
  55452. } else {
  55453. $displayErrors = $this->displayErrors;
  55454. $this->throwAt(0, true);
  55455. $this->displayErrors = $displayErrors;
  55456. }
  55457. }
  55458. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  55459. {
  55460. @trigger_error('The '.__METHOD__.' static method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the setLoggers() or setDefaultLogger() methods instead.', E_USER_DEPRECATED);
  55461. $handler = set_error_handler('var_dump');
  55462. $handler = \is_array($handler) ? $handler[0] : null;
  55463. restore_error_handler();
  55464. if (!$handler instanceof self) {
  55465. return;
  55466. }
  55467. if ('deprecation' === $channel) {
  55468. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  55469. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  55470. } elseif ('scream' === $channel) {
  55471. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  55472. $handler->screamAt(E_ALL | E_STRICT);
  55473. } elseif ('emergency' === $channel) {
  55474. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  55475. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  55476. }
  55477. }
  55478. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  55479. {
  55480. $this->handleError(E_USER_DEPRECATED, 'The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the handleError() method instead.', __FILE__, __LINE__, array());
  55481. return $this->handleError($level, $message, $file, $line, (array) $context);
  55482. }
  55483. public function handleFatal()
  55484. {
  55485. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0. Use the handleFatalError() method instead.', E_USER_DEPRECATED);
  55486. static::handleFatalError();
  55487. }
  55488. }
  55489. class ErrorHandlerCanary
  55490. {
  55491. private static $displayErrors = null;
  55492. public function __construct()
  55493. {
  55494. if (null === self::$displayErrors) {
  55495. self::$displayErrors = ini_set('display_errors', 1);
  55496. }
  55497. }
  55498. public function __destruct()
  55499. {
  55500. if (null !== self::$displayErrors) {
  55501. ini_set('display_errors', self::$displayErrors);
  55502. self::$displayErrors = null;
  55503. }
  55504. }
  55505. }
  55506. <?php
  55507. namespace Symfony\Component\Debug\Exception;
  55508. class ClassNotFoundException extends FatalErrorException
  55509. {
  55510. public function __construct($message, \ErrorException $previous)
  55511. {
  55512. parent::__construct(
  55513. $message,
  55514. $previous->getCode(),
  55515. $previous->getSeverity(),
  55516. $previous->getFile(),
  55517. $previous->getLine(),
  55518. null,
  55519. true,
  55520. null,
  55521. $previous->getPrevious()
  55522. );
  55523. $this->setTrace($previous->getTrace());
  55524. }
  55525. }
  55526. <?php
  55527. namespace Symfony\Component\Debug\Exception;
  55528. class ContextErrorException extends \ErrorException
  55529. {
  55530. private $context = array();
  55531. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  55532. {
  55533. parent::__construct($message, $code, $severity, $filename, $lineno);
  55534. $this->context = $context;
  55535. }
  55536. public function getContext()
  55537. {
  55538. return $this->context;
  55539. }
  55540. }
  55541. <?php
  55542. namespace Symfony\Component\Debug\Exception;
  55543. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  55544. class DummyException extends \ErrorException
  55545. {
  55546. }
  55547. <?php
  55548. namespace Symfony\Component\HttpKernel\Exception;
  55549. class FatalErrorException extends \ErrorException
  55550. {
  55551. }
  55552. namespace Symfony\Component\Debug\Exception;
  55553. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  55554. class FatalErrorException extends LegacyFatalErrorException
  55555. {
  55556. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  55557. {
  55558. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  55559. if (null !== $trace) {
  55560. if (!$traceArgs) {
  55561. foreach ($trace as &$frame) {
  55562. unset($frame['args'], $frame['this'], $frame);
  55563. }
  55564. }
  55565. $this->setTrace($trace);
  55566. } elseif (null !== $traceOffset) {
  55567. if (\function_exists('xdebug_get_function_stack')) {
  55568. $trace = xdebug_get_function_stack();
  55569. if (0 < $traceOffset) {
  55570. array_splice($trace, -$traceOffset);
  55571. }
  55572. foreach ($trace as &$frame) {
  55573. if (!isset($frame['type'])) {
  55574. if (isset($frame['class'])) {
  55575. $frame['type'] = '::';
  55576. }
  55577. } elseif ('dynamic' === $frame['type']) {
  55578. $frame['type'] = '->';
  55579. } elseif ('static' === $frame['type']) {
  55580. $frame['type'] = '::';
  55581. }
  55582. if (!$traceArgs) {
  55583. unset($frame['params'], $frame['args']);
  55584. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  55585. $frame['args'] = $frame['params'];
  55586. unset($frame['params']);
  55587. }
  55588. }
  55589. unset($frame);
  55590. $trace = array_reverse($trace);
  55591. } elseif (\function_exists('symfony_debug_backtrace')) {
  55592. $trace = symfony_debug_backtrace();
  55593. if (0 < $traceOffset) {
  55594. array_splice($trace, 0, $traceOffset);
  55595. }
  55596. } else {
  55597. $trace = array();
  55598. }
  55599. $this->setTrace($trace);
  55600. }
  55601. }
  55602. protected function setTrace($trace)
  55603. {
  55604. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  55605. $traceReflector->setAccessible(true);
  55606. $traceReflector->setValue($this, $trace);
  55607. }
  55608. }
  55609. <?php
  55610. namespace Symfony\Component\Debug\Exception;
  55611. class FatalThrowableError extends FatalErrorException
  55612. {
  55613. public function __construct(\Throwable $e)
  55614. {
  55615. if ($e instanceof \ParseError) {
  55616. $message = 'Parse error: '.$e->getMessage();
  55617. $severity = E_PARSE;
  55618. } elseif ($e instanceof \TypeError) {
  55619. $message = 'Type error: '.$e->getMessage();
  55620. $severity = E_RECOVERABLE_ERROR;
  55621. } else {
  55622. $message = $e->getMessage();
  55623. $severity = E_ERROR;
  55624. }
  55625. \ErrorException::__construct(
  55626. $message,
  55627. $e->getCode(),
  55628. $severity,
  55629. $e->getFile(),
  55630. $e->getLine(),
  55631. $e->getPrevious()
  55632. );
  55633. $this->setTrace($e->getTrace());
  55634. }
  55635. }
  55636. <?php
  55637. namespace Symfony\Component\HttpKernel\Exception;
  55638. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  55639. class FlattenException
  55640. {
  55641. private $handler;
  55642. public static function __callStatic($method, $args)
  55643. {
  55644. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  55645. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  55646. }
  55647. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  55648. }
  55649. public function __call($method, $args)
  55650. {
  55651. if (!isset($this->handler)) {
  55652. $this->handler = new DebugFlattenException();
  55653. }
  55654. if (!method_exists($this->handler, $method)) {
  55655. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  55656. }
  55657. return \call_user_func_array(array($this->handler, $method), $args);
  55658. }
  55659. }
  55660. namespace Symfony\Component\Debug\Exception;
  55661. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  55662. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  55663. class FlattenException extends LegacyFlattenException
  55664. {
  55665. private $message;
  55666. private $code;
  55667. private $previous;
  55668. private $trace;
  55669. private $class;
  55670. private $statusCode;
  55671. private $headers;
  55672. private $file;
  55673. private $line;
  55674. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  55675. {
  55676. $e = new static();
  55677. $e->setMessage($exception->getMessage());
  55678. $e->setCode($exception->getCode());
  55679. if ($exception instanceof HttpExceptionInterface) {
  55680. $statusCode = $exception->getStatusCode();
  55681. $headers = array_merge($headers, $exception->getHeaders());
  55682. }
  55683. if (null === $statusCode) {
  55684. $statusCode = 500;
  55685. }
  55686. $e->setStatusCode($statusCode);
  55687. $e->setHeaders($headers);
  55688. $e->setTraceFromException($exception);
  55689. $e->setClass(\get_class($exception));
  55690. $e->setFile($exception->getFile());
  55691. $e->setLine($exception->getLine());
  55692. $previous = $exception->getPrevious();
  55693. if ($previous instanceof \Exception) {
  55694. $e->setPrevious(static::create($previous));
  55695. } elseif ($previous instanceof \Throwable) {
  55696. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  55697. }
  55698. return $e;
  55699. }
  55700. public function toArray()
  55701. {
  55702. $exceptions = array();
  55703. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  55704. $exceptions[] = array(
  55705. 'message' => $exception->getMessage(),
  55706. 'class' => $exception->getClass(),
  55707. 'trace' => $exception->getTrace(),
  55708. );
  55709. }
  55710. return $exceptions;
  55711. }
  55712. public function getStatusCode()
  55713. {
  55714. return $this->statusCode;
  55715. }
  55716. public function setStatusCode($code)
  55717. {
  55718. $this->statusCode = $code;
  55719. }
  55720. public function getHeaders()
  55721. {
  55722. return $this->headers;
  55723. }
  55724. public function setHeaders(array $headers)
  55725. {
  55726. $this->headers = $headers;
  55727. }
  55728. public function getClass()
  55729. {
  55730. return $this->class;
  55731. }
  55732. public function setClass($class)
  55733. {
  55734. $this->class = $class;
  55735. }
  55736. public function getFile()
  55737. {
  55738. return $this->file;
  55739. }
  55740. public function setFile($file)
  55741. {
  55742. $this->file = $file;
  55743. }
  55744. public function getLine()
  55745. {
  55746. return $this->line;
  55747. }
  55748. public function setLine($line)
  55749. {
  55750. $this->line = $line;
  55751. }
  55752. public function getMessage()
  55753. {
  55754. return $this->message;
  55755. }
  55756. public function setMessage($message)
  55757. {
  55758. $this->message = $message;
  55759. }
  55760. public function getCode()
  55761. {
  55762. return $this->code;
  55763. }
  55764. public function setCode($code)
  55765. {
  55766. $this->code = $code;
  55767. }
  55768. public function getPrevious()
  55769. {
  55770. return $this->previous;
  55771. }
  55772. public function setPrevious(FlattenException $previous)
  55773. {
  55774. $this->previous = $previous;
  55775. }
  55776. public function getAllPrevious()
  55777. {
  55778. $exceptions = array();
  55779. $e = $this;
  55780. while ($e = $e->getPrevious()) {
  55781. $exceptions[] = $e;
  55782. }
  55783. return $exceptions;
  55784. }
  55785. public function getTrace()
  55786. {
  55787. return $this->trace;
  55788. }
  55789. public function setTraceFromException(\Exception $exception)
  55790. {
  55791. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  55792. }
  55793. public function setTrace($trace, $file, $line)
  55794. {
  55795. $this->trace = array();
  55796. $this->trace[] = array(
  55797. 'namespace' => '',
  55798. 'short_class' => '',
  55799. 'class' => '',
  55800. 'type' => '',
  55801. 'function' => '',
  55802. 'file' => $file,
  55803. 'line' => $line,
  55804. 'args' => array(),
  55805. );
  55806. foreach ($trace as $entry) {
  55807. $class = '';
  55808. $namespace = '';
  55809. if (isset($entry['class'])) {
  55810. $parts = explode('\\', $entry['class']);
  55811. $class = array_pop($parts);
  55812. $namespace = implode('\\', $parts);
  55813. }
  55814. $this->trace[] = array(
  55815. 'namespace' => $namespace,
  55816. 'short_class' => $class,
  55817. 'class' => isset($entry['class']) ? $entry['class'] : '',
  55818. 'type' => isset($entry['type']) ? $entry['type'] : '',
  55819. 'function' => isset($entry['function']) ? $entry['function'] : null,
  55820. 'file' => isset($entry['file']) ? $entry['file'] : null,
  55821. 'line' => isset($entry['line']) ? $entry['line'] : null,
  55822. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  55823. );
  55824. }
  55825. }
  55826. private function flattenArgs($args, $level = 0, &$count = 0)
  55827. {
  55828. $result = array();
  55829. foreach ($args as $key => $value) {
  55830. if (++$count > 1e4) {
  55831. return array('array', '*SKIPPED over 10000 entries*');
  55832. }
  55833. if ($value instanceof \__PHP_Incomplete_Class) {
  55834. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  55835. } elseif (\is_object($value)) {
  55836. $result[$key] = array('object', \get_class($value));
  55837. } elseif (\is_array($value)) {
  55838. if ($level > 10) {
  55839. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  55840. } else {
  55841. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  55842. }
  55843. } elseif (null === $value) {
  55844. $result[$key] = array('null', null);
  55845. } elseif (\is_bool($value)) {
  55846. $result[$key] = array('boolean', $value);
  55847. } elseif (\is_resource($value)) {
  55848. $result[$key] = array('resource', get_resource_type($value));
  55849. } else {
  55850. $result[$key] = array('string', (string) $value);
  55851. }
  55852. }
  55853. return $result;
  55854. }
  55855. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  55856. {
  55857. $array = new \ArrayObject($value);
  55858. return $array['__PHP_Incomplete_Class_Name'];
  55859. }
  55860. }
  55861. <?php
  55862. namespace Symfony\Component\Debug\Exception;
  55863. class OutOfMemoryException extends FatalErrorException
  55864. {
  55865. }
  55866. <?php
  55867. namespace Symfony\Component\Debug\Exception;
  55868. class UndefinedFunctionException extends FatalErrorException
  55869. {
  55870. public function __construct($message, \ErrorException $previous)
  55871. {
  55872. parent::__construct(
  55873. $message,
  55874. $previous->getCode(),
  55875. $previous->getSeverity(),
  55876. $previous->getFile(),
  55877. $previous->getLine(),
  55878. null,
  55879. true,
  55880. null,
  55881. $previous->getPrevious()
  55882. );
  55883. $this->setTrace($previous->getTrace());
  55884. }
  55885. }
  55886. <?php
  55887. namespace Symfony\Component\Debug\Exception;
  55888. class UndefinedMethodException extends FatalErrorException
  55889. {
  55890. public function __construct($message, \ErrorException $previous)
  55891. {
  55892. parent::__construct(
  55893. $message,
  55894. $previous->getCode(),
  55895. $previous->getSeverity(),
  55896. $previous->getFile(),
  55897. $previous->getLine(),
  55898. null,
  55899. true,
  55900. null,
  55901. $previous->getPrevious()
  55902. );
  55903. $this->setTrace($previous->getTrace());
  55904. }
  55905. }
  55906. <?php
  55907. namespace Symfony\Component\Debug;
  55908. use Symfony\Component\Debug\Exception\FlattenException;
  55909. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  55910. use Symfony\Component\HttpFoundation\Response;
  55911. class ExceptionHandler
  55912. {
  55913. private $debug;
  55914. private $charset;
  55915. private $handler;
  55916. private $caughtBuffer;
  55917. private $caughtLength;
  55918. private $fileLinkFormat;
  55919. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  55920. {
  55921. if (false !== strpos($charset, '%')) {
  55922. @trigger_error('Providing $fileLinkFormat as second argument to '.__METHOD__.' is deprecated since Symfony 2.8 and will be unsupported in 3.0. Please provide it as third argument, after $charset.', E_USER_DEPRECATED);
  55923. $pivot = $fileLinkFormat;
  55924. $fileLinkFormat = $charset;
  55925. $charset = $pivot;
  55926. }
  55927. $this->debug = $debug;
  55928. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  55929. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  55930. }
  55931. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  55932. {
  55933. $handler = new static($debug, $charset, $fileLinkFormat);
  55934. $prev = set_exception_handler(array($handler, 'handle'));
  55935. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  55936. restore_exception_handler();
  55937. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  55938. }
  55939. return $handler;
  55940. }
  55941. public function setHandler($handler)
  55942. {
  55943. if (null !== $handler && !\is_callable($handler)) {
  55944. throw new \LogicException('The exception handler must be a valid PHP callable.');
  55945. }
  55946. $old = $this->handler;
  55947. $this->handler = $handler;
  55948. return $old;
  55949. }
  55950. public function setFileLinkFormat($format)
  55951. {
  55952. $old = $this->fileLinkFormat;
  55953. $this->fileLinkFormat = $format;
  55954. return $old;
  55955. }
  55956. public function handle(\Exception $exception)
  55957. {
  55958. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  55959. $this->failSafeHandle($exception);
  55960. return;
  55961. }
  55962. $caughtLength = $this->caughtLength = 0;
  55963. ob_start(array($this, 'catchOutput'));
  55964. $this->failSafeHandle($exception);
  55965. while (null === $this->caughtBuffer && ob_end_flush()) {
  55966. }
  55967. if (isset($this->caughtBuffer[0])) {
  55968. ob_start(array($this, 'cleanOutput'));
  55969. echo $this->caughtBuffer;
  55970. $caughtLength = ob_get_length();
  55971. }
  55972. $this->caughtBuffer = null;
  55973. try {
  55974. \call_user_func($this->handler, $exception);
  55975. $this->caughtLength = $caughtLength;
  55976. } catch (\Exception $e) {
  55977. if (!$caughtLength) {
  55978. throw $exception;
  55979. }
  55980. }
  55981. }
  55982. private function failSafeHandle(\Exception $exception)
  55983. {
  55984. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  55985. && __CLASS__ !== \get_class($this)
  55986. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  55987. && __CLASS__ !== $reflector->class
  55988. ) {
  55989. $response = $this->createResponse($exception);
  55990. $response->sendHeaders();
  55991. $response->sendContent();
  55992. @trigger_error(sprintf("The %s::createResponse method is deprecated since Symfony 2.8 and won't be called anymore when handling an exception in 3.0.", $reflector->class), E_USER_DEPRECATED);
  55993. return;
  55994. }
  55995. $this->sendPhpResponse($exception);
  55996. }
  55997. public function sendPhpResponse($exception)
  55998. {
  55999. if (!$exception instanceof FlattenException) {
  56000. $exception = FlattenException::create($exception);
  56001. }
  56002. if (!headers_sent()) {
  56003. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  56004. foreach ($exception->getHeaders() as $name => $value) {
  56005. header($name.': '.$value, false);
  56006. }
  56007. header('Content-Type: text/html; charset='.$this->charset);
  56008. }
  56009. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  56010. }
  56011. public function createResponse($exception)
  56012. {
  56013. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  56014. if (!$exception instanceof FlattenException) {
  56015. $exception = FlattenException::create($exception);
  56016. }
  56017. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  56018. }
  56019. public function getHtml($exception)
  56020. {
  56021. if (!$exception instanceof FlattenException) {
  56022. $exception = FlattenException::create($exception);
  56023. }
  56024. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  56025. }
  56026. public function getContent(FlattenException $exception)
  56027. {
  56028. switch ($exception->getStatusCode()) {
  56029. case 404:
  56030. $title = 'Sorry, the page you are looking for could not be found.';
  56031. break;
  56032. default:
  56033. $title = 'Whoops, looks like something went wrong.';
  56034. }
  56035. $content = '';
  56036. if ($this->debug) {
  56037. try {
  56038. $count = \count($exception->getAllPrevious());
  56039. $total = $count + 1;
  56040. foreach ($exception->toArray() as $position => $e) {
  56041. $ind = $count - $position + 1;
  56042. $class = $this->formatClass($e['class']);
  56043. $message = nl2br($this->escapeHtml($e['message']));
  56044. $content .= sprintf(<<<'EOF'
  56045. <h2 class="block_exception clear_fix">
  56046. <span class="exception_counter">%d/%d</span>
  56047. <span class="exception_title">%s%s:</span>
  56048. <span class="exception_message">%s</span>
  56049. </h2>
  56050. <div class="block">
  56051. <ol class="traces list_exception">
  56052. EOF
  56053. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  56054. foreach ($e['trace'] as $trace) {
  56055. $content .= ' <li>';
  56056. if ($trace['function']) {
  56057. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  56058. }
  56059. if (isset($trace['file']) && isset($trace['line'])) {
  56060. $content .= $this->formatPath($trace['file'], $trace['line']);
  56061. }
  56062. $content .= "</li>\n";
  56063. }
  56064. $content .= " </ol>\n</div>\n";
  56065. }
  56066. } catch (\Exception $e) {
  56067. if ($this->debug) {
  56068. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  56069. } else {
  56070. $title = 'Whoops, looks like something went wrong.';
  56071. }
  56072. }
  56073. }
  56074. return <<<EOF
  56075. <div id="sf-resetcontent" class="sf-reset">
  56076. <h1>$title</h1>
  56077. $content
  56078. </div>
  56079. EOF;
  56080. }
  56081. public function getStylesheet(FlattenException $exception)
  56082. {
  56083. return <<<'EOF'
  56084. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  56085. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  56086. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  56087. .sf-reset .clear_fix { display:inline-block; }
  56088. .sf-reset * html .clear_fix { height:1%; }
  56089. .sf-reset .clear_fix { display:block; }
  56090. .sf-reset, .sf-reset .block { margin: auto }
  56091. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  56092. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  56093. .sf-reset strong { font-weight:bold; }
  56094. .sf-reset a { color:#6c6159; cursor: default; }
  56095. .sf-reset a img { border:none; }
  56096. .sf-reset a:hover { text-decoration:underline; }
  56097. .sf-reset em { font-style:italic; }
  56098. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  56099. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  56100. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  56101. .sf-reset .exception_message { margin-left: 3em; display: block; }
  56102. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  56103. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  56104. -webkit-border-bottom-right-radius: 16px;
  56105. -webkit-border-bottom-left-radius: 16px;
  56106. -moz-border-radius-bottomright: 16px;
  56107. -moz-border-radius-bottomleft: 16px;
  56108. border-bottom-right-radius: 16px;
  56109. border-bottom-left-radius: 16px;
  56110. border-bottom:1px solid #ccc;
  56111. border-right:1px solid #ccc;
  56112. border-left:1px solid #ccc;
  56113. word-wrap: break-word;
  56114. }
  56115. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  56116. -webkit-border-top-left-radius: 16px;
  56117. -webkit-border-top-right-radius: 16px;
  56118. -moz-border-radius-topleft: 16px;
  56119. -moz-border-radius-topright: 16px;
  56120. border-top-left-radius: 16px;
  56121. border-top-right-radius: 16px;
  56122. border-top:1px solid #ccc;
  56123. border-right:1px solid #ccc;
  56124. border-left:1px solid #ccc;
  56125. overflow: hidden;
  56126. word-wrap: break-word;
  56127. }
  56128. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  56129. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  56130. .sf-reset ol { padding: 10px 0; }
  56131. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  56132. -webkit-border-radius: 10px;
  56133. -moz-border-radius: 10px;
  56134. border-radius: 10px;
  56135. border: 1px solid #ccc;
  56136. }
  56137. EOF;
  56138. }
  56139. private function decorate($content, $css)
  56140. {
  56141. return <<<EOF
  56142. <!DOCTYPE html>
  56143. <html>
  56144. <head>
  56145. <meta charset="{$this->charset}" />
  56146. <meta name="robots" content="noindex,nofollow" />
  56147. <style>
  56148. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  56149. html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
  56150. html { background: #eee; padding: 10px }
  56151. img { border: 0; }
  56152. #sf-resetcontent { width:970px; margin:0 auto; }
  56153. $css
  56154. </style>
  56155. </head>
  56156. <body>
  56157. $content
  56158. </body>
  56159. </html>
  56160. EOF;
  56161. }
  56162. private function formatClass($class)
  56163. {
  56164. $parts = explode('\\', $class);
  56165. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  56166. }
  56167. private function formatPath($path, $line)
  56168. {
  56169. $path = $this->escapeHtml($path);
  56170. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  56171. if ($linkFormat = $this->fileLinkFormat) {
  56172. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  56173. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  56174. }
  56175. return sprintf(' in <a title="%s line %3$d" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">%s line %d</a>', $path, $file, $line);
  56176. }
  56177. private function formatArgs(array $args)
  56178. {
  56179. $result = array();
  56180. foreach ($args as $key => $item) {
  56181. if ('object' === $item[0]) {
  56182. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  56183. } elseif ('array' === $item[0]) {
  56184. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  56185. } elseif ('string' === $item[0]) {
  56186. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  56187. } elseif ('null' === $item[0]) {
  56188. $formattedValue = '<em>null</em>';
  56189. } elseif ('boolean' === $item[0]) {
  56190. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  56191. } elseif ('resource' === $item[0]) {
  56192. $formattedValue = '<em>resource</em>';
  56193. } else {
  56194. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  56195. }
  56196. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  56197. }
  56198. return implode(', ', $result);
  56199. }
  56200. protected static function utf8Htmlize($str)
  56201. {
  56202. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  56203. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  56204. }
  56205. private function escapeHtml($str)
  56206. {
  56207. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  56208. }
  56209. public function catchOutput($buffer)
  56210. {
  56211. $this->caughtBuffer = $buffer;
  56212. return '';
  56213. }
  56214. public function cleanOutput($buffer)
  56215. {
  56216. if ($this->caughtLength) {
  56217. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  56218. if (isset($cleanBuffer[0])) {
  56219. $buffer = $cleanBuffer;
  56220. }
  56221. }
  56222. return $buffer;
  56223. }
  56224. }
  56225. <?php
  56226. namespace Symfony\Component\Debug\FatalErrorHandler;
  56227. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  56228. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  56229. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  56230. use Symfony\Component\Debug\DebugClassLoader;
  56231. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  56232. use Symfony\Component\Debug\Exception\FatalErrorException;
  56233. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  56234. {
  56235. public function handleError(array $error, FatalErrorException $exception)
  56236. {
  56237. $messageLen = \strlen($error['message']);
  56238. $notFoundSuffix = '\' not found';
  56239. $notFoundSuffixLen = \strlen($notFoundSuffix);
  56240. if ($notFoundSuffixLen > $messageLen) {
  56241. return;
  56242. }
  56243. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  56244. return;
  56245. }
  56246. foreach (array('class', 'interface', 'trait') as $typeName) {
  56247. $prefix = ucfirst($typeName).' \'';
  56248. $prefixLen = \strlen($prefix);
  56249. if (0 !== strpos($error['message'], $prefix)) {
  56250. continue;
  56251. }
  56252. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  56253. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  56254. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  56255. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  56256. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  56257. $tail = ' for another namespace?';
  56258. } else {
  56259. $className = $fullyQualifiedClassName;
  56260. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  56261. $tail = '?';
  56262. }
  56263. if ($candidates = $this->getClassCandidates($className)) {
  56264. $tail = array_pop($candidates).'"?';
  56265. if ($candidates) {
  56266. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  56267. } else {
  56268. $tail = ' for "'.$tail;
  56269. }
  56270. }
  56271. $message .= "\nDid you forget a \"use\" statement".$tail;
  56272. return new ClassNotFoundException($message, $exception);
  56273. }
  56274. }
  56275. private function getClassCandidates($class)
  56276. {
  56277. if (!\is_array($functions = spl_autoload_functions())) {
  56278. return array();
  56279. }
  56280. $classes = array();
  56281. foreach ($functions as $function) {
  56282. if (!\is_array($function)) {
  56283. continue;
  56284. }
  56285. if ($function[0] instanceof DebugClassLoader) {
  56286. $function = $function[0]->getClassLoader();
  56287. if (\is_object($function)) {
  56288. $function = array($function);
  56289. }
  56290. if (!\is_array($function)) {
  56291. continue;
  56292. }
  56293. }
  56294. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  56295. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  56296. foreach ($paths as $path) {
  56297. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  56298. }
  56299. }
  56300. }
  56301. if ($function[0] instanceof ComposerClassLoader) {
  56302. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  56303. foreach ($paths as $path) {
  56304. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  56305. }
  56306. }
  56307. }
  56308. }
  56309. return array_unique($classes);
  56310. }
  56311. private function findClassInPath($path, $class, $prefix)
  56312. {
  56313. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  56314. return array();
  56315. }
  56316. $classes = array();
  56317. $filename = $class.'.php';
  56318. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  56319. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  56320. $classes[] = $class;
  56321. }
  56322. }
  56323. return $classes;
  56324. }
  56325. private function convertFileToClass($path, $file, $prefix)
  56326. {
  56327. $candidates = array(
  56328. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  56329. $prefix.$namespacedClass,
  56330. $prefix.'\\'.$namespacedClass,
  56331. str_replace('\\', '_', $namespacedClass),
  56332. str_replace('\\', '_', $prefix.$namespacedClass),
  56333. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  56334. );
  56335. if ($prefix) {
  56336. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  56337. }
  56338. foreach ($candidates as $candidate) {
  56339. if ($this->classExists($candidate)) {
  56340. return $candidate;
  56341. }
  56342. }
  56343. require_once $file;
  56344. foreach ($candidates as $candidate) {
  56345. if ($this->classExists($candidate)) {
  56346. return $candidate;
  56347. }
  56348. }
  56349. }
  56350. private function classExists($class)
  56351. {
  56352. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  56353. }
  56354. }
  56355. <?php
  56356. namespace Symfony\Component\Debug\FatalErrorHandler;
  56357. use Symfony\Component\Debug\Exception\FatalErrorException;
  56358. interface FatalErrorHandlerInterface
  56359. {
  56360. public function handleError(array $error, FatalErrorException $exception);
  56361. }
  56362. <?php
  56363. namespace Symfony\Component\Debug\FatalErrorHandler;
  56364. use Symfony\Component\Debug\Exception\FatalErrorException;
  56365. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  56366. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  56367. {
  56368. public function handleError(array $error, FatalErrorException $exception)
  56369. {
  56370. $messageLen = \strlen($error['message']);
  56371. $notFoundSuffix = '()';
  56372. $notFoundSuffixLen = \strlen($notFoundSuffix);
  56373. if ($notFoundSuffixLen > $messageLen) {
  56374. return;
  56375. }
  56376. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  56377. return;
  56378. }
  56379. $prefix = 'Call to undefined function ';
  56380. $prefixLen = \strlen($prefix);
  56381. if (0 !== strpos($error['message'], $prefix)) {
  56382. return;
  56383. }
  56384. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  56385. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  56386. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  56387. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  56388. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  56389. } else {
  56390. $functionName = $fullyQualifiedFunctionName;
  56391. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  56392. }
  56393. $candidates = array();
  56394. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  56395. foreach ($definedFunctionNames as $definedFunctionName) {
  56396. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  56397. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  56398. } else {
  56399. $definedFunctionNameBasename = $definedFunctionName;
  56400. }
  56401. if ($definedFunctionNameBasename === $functionName) {
  56402. $candidates[] = '\\'.$definedFunctionName;
  56403. }
  56404. }
  56405. }
  56406. if ($candidates) {
  56407. sort($candidates);
  56408. $last = array_pop($candidates).'"?';
  56409. if ($candidates) {
  56410. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  56411. } else {
  56412. $candidates = '"'.$last;
  56413. }
  56414. $message .= "\nDid you mean to call ".$candidates;
  56415. }
  56416. return new UndefinedFunctionException($message, $exception);
  56417. }
  56418. }
  56419. <?php
  56420. namespace Symfony\Component\Debug\FatalErrorHandler;
  56421. use Symfony\Component\Debug\Exception\FatalErrorException;
  56422. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  56423. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  56424. {
  56425. public function handleError(array $error, FatalErrorException $exception)
  56426. {
  56427. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  56428. if (!$matches) {
  56429. return;
  56430. }
  56431. $className = $matches[1];
  56432. $methodName = $matches[2];
  56433. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  56434. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  56435. return new UndefinedMethodException($message, $exception);
  56436. }
  56437. $candidates = array();
  56438. foreach ($methods as $definedMethodName) {
  56439. $lev = levenshtein($methodName, $definedMethodName);
  56440. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  56441. $candidates[] = $definedMethodName;
  56442. }
  56443. }
  56444. if ($candidates) {
  56445. sort($candidates);
  56446. $last = array_pop($candidates).'"?';
  56447. if ($candidates) {
  56448. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  56449. } else {
  56450. $candidates = '"'.$last;
  56451. }
  56452. $message .= "\nDid you mean to call ".$candidates;
  56453. }
  56454. return new UndefinedMethodException($message, $exception);
  56455. }
  56456. }
  56457. Copyright (c) 2004-2018 Fabien Potencier
  56458. Permission is hereby granted, free of charge, to any person obtaining a copy
  56459. of this software and associated documentation files (the "Software"), to deal
  56460. in the Software without restriction, including without limitation the rights
  56461. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56462. copies of the Software, and to permit persons to whom the Software is furnished
  56463. to do so, subject to the following conditions:
  56464. The above copyright notice and this permission notice shall be included in all
  56465. copies or substantial portions of the Software.
  56466. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56467. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56468. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56469. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56470. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56471. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56472. THE SOFTWARE.
  56473. <?php
  56474. namespace Symfony\Component\Filesystem\Exception;
  56475. interface ExceptionInterface
  56476. {
  56477. }
  56478. <?php
  56479. namespace Symfony\Component\Filesystem\Exception;
  56480. class FileNotFoundException extends IOException
  56481. {
  56482. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  56483. {
  56484. if (null === $message) {
  56485. if (null === $path) {
  56486. $message = 'File could not be found.';
  56487. } else {
  56488. $message = sprintf('File "%s" could not be found.', $path);
  56489. }
  56490. }
  56491. parent::__construct($message, $code, $previous, $path);
  56492. }
  56493. }
  56494. <?php
  56495. namespace Symfony\Component\Filesystem\Exception;
  56496. class IOException extends \RuntimeException implements IOExceptionInterface
  56497. {
  56498. private $path;
  56499. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  56500. {
  56501. $this->path = $path;
  56502. parent::__construct($message, $code, $previous);
  56503. }
  56504. public function getPath()
  56505. {
  56506. return $this->path;
  56507. }
  56508. }
  56509. <?php
  56510. namespace Symfony\Component\Filesystem\Exception;
  56511. interface IOExceptionInterface extends ExceptionInterface
  56512. {
  56513. public function getPath();
  56514. }
  56515. <?php
  56516. namespace Symfony\Component\Filesystem;
  56517. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  56518. use Symfony\Component\Filesystem\Exception\IOException;
  56519. class Filesystem
  56520. {
  56521. private static $lastError;
  56522. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  56523. {
  56524. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  56525. if ($originIsLocal && !is_file($originFile)) {
  56526. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  56527. }
  56528. $this->mkdir(\dirname($targetFile));
  56529. $doCopy = true;
  56530. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  56531. $doCopy = filemtime($originFile) > filemtime($targetFile);
  56532. }
  56533. if ($doCopy) {
  56534. if (false === $source = @fopen($originFile, 'r')) {
  56535. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  56536. }
  56537. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  56538. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  56539. }
  56540. $bytesCopied = stream_copy_to_stream($source, $target);
  56541. fclose($source);
  56542. fclose($target);
  56543. unset($source, $target);
  56544. if (!is_file($targetFile)) {
  56545. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  56546. }
  56547. if ($originIsLocal) {
  56548. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  56549. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  56550. throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile);
  56551. }
  56552. }
  56553. }
  56554. }
  56555. public function mkdir($dirs, $mode = 0777)
  56556. {
  56557. foreach ($this->toIterator($dirs) as $dir) {
  56558. if (is_dir($dir)) {
  56559. continue;
  56560. }
  56561. if (!self::box('mkdir', $dir, $mode, true)) {
  56562. if (!is_dir($dir)) {
  56563. if (self::$lastError) {
  56564. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  56565. }
  56566. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  56567. }
  56568. }
  56569. }
  56570. }
  56571. public function exists($files)
  56572. {
  56573. $maxPathLength = PHP_MAXPATHLEN - 2;
  56574. foreach ($this->toIterator($files) as $file) {
  56575. if (\strlen($file) > $maxPathLength) {
  56576. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  56577. }
  56578. if (!file_exists($file)) {
  56579. return false;
  56580. }
  56581. }
  56582. return true;
  56583. }
  56584. public function touch($files, $time = null, $atime = null)
  56585. {
  56586. foreach ($this->toIterator($files) as $file) {
  56587. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  56588. if (true !== $touch) {
  56589. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  56590. }
  56591. }
  56592. }
  56593. public function remove($files)
  56594. {
  56595. if ($files instanceof \Traversable) {
  56596. $files = iterator_to_array($files, false);
  56597. } elseif (!\is_array($files)) {
  56598. $files = array($files);
  56599. }
  56600. $files = array_reverse($files);
  56601. foreach ($files as $file) {
  56602. if (is_link($file)) {
  56603. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  56604. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  56605. }
  56606. } elseif (is_dir($file)) {
  56607. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  56608. if (!self::box('rmdir', $file) && file_exists($file)) {
  56609. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  56610. }
  56611. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  56612. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  56613. }
  56614. }
  56615. }
  56616. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  56617. {
  56618. foreach ($this->toIterator($files) as $file) {
  56619. if (true !== @chmod($file, $mode & ~$umask)) {
  56620. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  56621. }
  56622. if ($recursive && is_dir($file) && !is_link($file)) {
  56623. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  56624. }
  56625. }
  56626. }
  56627. public function chown($files, $user, $recursive = false)
  56628. {
  56629. foreach ($this->toIterator($files) as $file) {
  56630. if ($recursive && is_dir($file) && !is_link($file)) {
  56631. $this->chown(new \FilesystemIterator($file), $user, true);
  56632. }
  56633. if (is_link($file) && \function_exists('lchown')) {
  56634. if (true !== @lchown($file, $user)) {
  56635. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56636. }
  56637. } else {
  56638. if (true !== @chown($file, $user)) {
  56639. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56640. }
  56641. }
  56642. }
  56643. }
  56644. public function chgrp($files, $group, $recursive = false)
  56645. {
  56646. foreach ($this->toIterator($files) as $file) {
  56647. if ($recursive && is_dir($file) && !is_link($file)) {
  56648. $this->chgrp(new \FilesystemIterator($file), $group, true);
  56649. }
  56650. if (is_link($file) && \function_exists('lchgrp')) {
  56651. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  56652. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56653. }
  56654. } else {
  56655. if (true !== @chgrp($file, $group)) {
  56656. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56657. }
  56658. }
  56659. }
  56660. }
  56661. public function rename($origin, $target, $overwrite = false)
  56662. {
  56663. if (!$overwrite && $this->isReadable($target)) {
  56664. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  56665. }
  56666. if (true !== @rename($origin, $target)) {
  56667. if (is_dir($origin)) {
  56668. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  56669. $this->remove($origin);
  56670. return;
  56671. }
  56672. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  56673. }
  56674. }
  56675. private function isReadable($filename)
  56676. {
  56677. $maxPathLength = PHP_MAXPATHLEN - 2;
  56678. if (\strlen($filename) > $maxPathLength) {
  56679. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  56680. }
  56681. return is_readable($filename);
  56682. }
  56683. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  56684. {
  56685. if ('\\' === \DIRECTORY_SEPARATOR) {
  56686. $originDir = strtr($originDir, '/', '\\');
  56687. $targetDir = strtr($targetDir, '/', '\\');
  56688. if ($copyOnWindows) {
  56689. $this->mirror($originDir, $targetDir);
  56690. return;
  56691. }
  56692. }
  56693. $this->mkdir(\dirname($targetDir));
  56694. if (is_link($targetDir)) {
  56695. if (readlink($targetDir) === $originDir) {
  56696. return;
  56697. }
  56698. $this->remove($targetDir);
  56699. }
  56700. if (!self::box('symlink', $originDir, $targetDir)) {
  56701. if (null !== self::$lastError) {
  56702. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  56703. throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', 0, null, $targetDir);
  56704. }
  56705. }
  56706. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  56707. }
  56708. }
  56709. public function makePathRelative($endPath, $startPath)
  56710. {
  56711. if ('\\' === \DIRECTORY_SEPARATOR) {
  56712. $endPath = str_replace('\\', '/', $endPath);
  56713. $startPath = str_replace('\\', '/', $startPath);
  56714. }
  56715. $stripDriveLetter = function ($path) {
  56716. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  56717. return substr($path, 2);
  56718. }
  56719. return $path;
  56720. };
  56721. $endPath = $stripDriveLetter($endPath);
  56722. $startPath = $stripDriveLetter($startPath);
  56723. $startPathArr = explode('/', trim($startPath, '/'));
  56724. $endPathArr = explode('/', trim($endPath, '/'));
  56725. $normalizePathArray = function ($pathSegments, $absolute) {
  56726. $result = array();
  56727. foreach ($pathSegments as $segment) {
  56728. if ('..' === $segment && ($absolute || \count($result))) {
  56729. array_pop($result);
  56730. } elseif ('.' !== $segment) {
  56731. $result[] = $segment;
  56732. }
  56733. }
  56734. return $result;
  56735. };
  56736. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  56737. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  56738. $index = 0;
  56739. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  56740. ++$index;
  56741. }
  56742. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  56743. $depth = 0;
  56744. } else {
  56745. $depth = \count($startPathArr) - $index;
  56746. }
  56747. $traverser = str_repeat('../', $depth);
  56748. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  56749. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  56750. return '' === $relativePath ? './' : $relativePath;
  56751. }
  56752. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  56753. {
  56754. $targetDir = rtrim($targetDir, '/\\');
  56755. $originDir = rtrim($originDir, '/\\');
  56756. $originDirLen = \strlen($originDir);
  56757. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  56758. $deleteIterator = $iterator;
  56759. if (null === $deleteIterator) {
  56760. $flags = \FilesystemIterator::SKIP_DOTS;
  56761. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  56762. }
  56763. $targetDirLen = \strlen($targetDir);
  56764. foreach ($deleteIterator as $file) {
  56765. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  56766. if (!$this->exists($origin)) {
  56767. $this->remove($file);
  56768. }
  56769. }
  56770. }
  56771. $copyOnWindows = false;
  56772. if (isset($options['copy_on_windows'])) {
  56773. $copyOnWindows = $options['copy_on_windows'];
  56774. }
  56775. if (null === $iterator) {
  56776. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  56777. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  56778. }
  56779. if ($this->exists($originDir)) {
  56780. $this->mkdir($targetDir);
  56781. }
  56782. foreach ($iterator as $file) {
  56783. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  56784. if ($copyOnWindows) {
  56785. if (is_file($file)) {
  56786. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56787. } elseif (is_dir($file)) {
  56788. $this->mkdir($target);
  56789. } else {
  56790. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56791. }
  56792. } else {
  56793. if (is_link($file)) {
  56794. $this->symlink($file->getLinkTarget(), $target);
  56795. } elseif (is_dir($file)) {
  56796. $this->mkdir($target);
  56797. } elseif (is_file($file)) {
  56798. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56799. } else {
  56800. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56801. }
  56802. }
  56803. }
  56804. }
  56805. public function isAbsolutePath($file)
  56806. {
  56807. return strspn($file, '/\\', 0, 1)
  56808. || (\strlen($file) > 3 && ctype_alpha($file[0])
  56809. && ':' === substr($file, 1, 1)
  56810. && strspn($file, '/\\', 2, 1)
  56811. )
  56812. || null !== parse_url($file, PHP_URL_SCHEME)
  56813. ;
  56814. }
  56815. public function tempnam($dir, $prefix)
  56816. {
  56817. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  56818. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  56819. $tmpFile = @tempnam($hierarchy, $prefix);
  56820. if (false !== $tmpFile) {
  56821. if (null !== $scheme && 'gs' !== $scheme) {
  56822. return $scheme.'://'.$tmpFile;
  56823. }
  56824. return $tmpFile;
  56825. }
  56826. throw new IOException('A temporary file could not be created.');
  56827. }
  56828. for ($i = 0; $i < 10; ++$i) {
  56829. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  56830. $handle = @fopen($tmpFile, 'x+');
  56831. if (false === $handle) {
  56832. continue;
  56833. }
  56834. @fclose($handle);
  56835. return $tmpFile;
  56836. }
  56837. throw new IOException('A temporary file could not be created.');
  56838. }
  56839. public function dumpFile($filename, $content, $mode = 0666)
  56840. {
  56841. $dir = \dirname($filename);
  56842. if (!is_dir($dir)) {
  56843. $this->mkdir($dir);
  56844. }
  56845. if (!is_writable($dir)) {
  56846. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  56847. }
  56848. $tmpFile = $this->tempnam($dir, basename($filename));
  56849. if (false === @file_put_contents($tmpFile, $content)) {
  56850. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  56851. }
  56852. if (null !== $mode) {
  56853. if (\func_num_args() > 2) {
  56854. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  56855. }
  56856. $this->chmod($tmpFile, $mode);
  56857. } elseif (file_exists($filename)) {
  56858. @chmod($tmpFile, fileperms($filename));
  56859. }
  56860. $this->rename($tmpFile, $filename, true);
  56861. }
  56862. private function toIterator($files)
  56863. {
  56864. if (!$files instanceof \Traversable) {
  56865. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  56866. }
  56867. return $files;
  56868. }
  56869. private function getSchemeAndHierarchy($filename)
  56870. {
  56871. $components = explode('://', $filename, 2);
  56872. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  56873. }
  56874. private static function box($func)
  56875. {
  56876. self::$lastError = null;
  56877. \set_error_handler(__CLASS__.'::handleError');
  56878. try {
  56879. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  56880. \restore_error_handler();
  56881. return $result;
  56882. } catch (\Throwable $e) {
  56883. } catch (\Exception $e) {
  56884. }
  56885. \restore_error_handler();
  56886. throw $e;
  56887. }
  56888. public static function handleError($type, $msg)
  56889. {
  56890. self::$lastError = $msg;
  56891. }
  56892. }
  56893. Copyright (c) 2004-2018 Fabien Potencier
  56894. Permission is hereby granted, free of charge, to any person obtaining a copy
  56895. of this software and associated documentation files (the "Software"), to deal
  56896. in the Software without restriction, including without limitation the rights
  56897. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56898. copies of the Software, and to permit persons to whom the Software is furnished
  56899. to do so, subject to the following conditions:
  56900. The above copyright notice and this permission notice shall be included in all
  56901. copies or substantial portions of the Software.
  56902. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56903. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56904. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56905. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56906. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56907. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56908. THE SOFTWARE.
  56909. <?php
  56910. namespace Symfony\Component\Filesystem;
  56911. use Symfony\Component\Filesystem\Exception\IOException;
  56912. class LockHandler
  56913. {
  56914. private $file;
  56915. private $handle;
  56916. public function __construct($name, $lockPath = null)
  56917. {
  56918. $lockPath = $lockPath ?: sys_get_temp_dir();
  56919. if (!is_dir($lockPath)) {
  56920. $fs = new Filesystem();
  56921. $fs->mkdir($lockPath);
  56922. }
  56923. if (!is_writable($lockPath)) {
  56924. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  56925. }
  56926. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  56927. }
  56928. public function lock($blocking = false)
  56929. {
  56930. if ($this->handle) {
  56931. return true;
  56932. }
  56933. $error = null;
  56934. set_error_handler(function ($errno, $msg) use (&$error) {
  56935. $error = $msg;
  56936. });
  56937. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56938. if ($this->handle = fopen($this->file, 'x')) {
  56939. chmod($this->file, 0666);
  56940. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56941. usleep(100);
  56942. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  56943. }
  56944. }
  56945. restore_error_handler();
  56946. if (!$this->handle) {
  56947. throw new IOException($error, 0, null, $this->file);
  56948. }
  56949. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  56950. fclose($this->handle);
  56951. $this->handle = null;
  56952. return false;
  56953. }
  56954. return true;
  56955. }
  56956. public function release()
  56957. {
  56958. if ($this->handle) {
  56959. flock($this->handle, LOCK_UN | LOCK_NB);
  56960. fclose($this->handle);
  56961. $this->handle = null;
  56962. }
  56963. }
  56964. }
  56965. <?php
  56966. namespace Symfony\Component\Finder\Adapter;
  56967. @trigger_error('The '.__NAMESPACE__.'\AbstractAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
  56968. abstract class AbstractAdapter implements AdapterInterface
  56969. {
  56970. protected $followLinks = false;
  56971. protected $mode = 0;
  56972. protected $minDepth = 0;
  56973. protected $maxDepth = PHP_INT_MAX;
  56974. protected $exclude = array();
  56975. protected $names = array();
  56976. protected $notNames = array();
  56977. protected $contains = array();
  56978. protected $notContains = array();
  56979. protected $sizes = array();
  56980. protected $dates = array();
  56981. protected $filters = array();
  56982. protected $sort = false;
  56983. protected $paths = array();
  56984. protected $notPaths = array();
  56985. protected $ignoreUnreadableDirs = false;
  56986. private static $areSupported = array();
  56987. public function isSupported()
  56988. {
  56989. $name = $this->getName();
  56990. if (!array_key_exists($name, self::$areSupported)) {
  56991. self::$areSupported[$name] = $this->canBeUsed();
  56992. }
  56993. return self::$areSupported[$name];
  56994. }
  56995. public function setFollowLinks($followLinks)
  56996. {
  56997. $this->followLinks = $followLinks;
  56998. return $this;
  56999. }
  57000. public function setMode($mode)
  57001. {
  57002. $this->mode = $mode;
  57003. return $this;
  57004. }
  57005. public function setDepths(array $depths)
  57006. {
  57007. $this->minDepth = 0;
  57008. $this->maxDepth = PHP_INT_MAX;
  57009. foreach ($depths as $comparator) {
  57010. switch ($comparator->getOperator()) {
  57011. case '>':
  57012. $this->minDepth = $comparator->getTarget() + 1;
  57013. break;
  57014. case '>=':
  57015. $this->minDepth = $comparator->getTarget();
  57016. break;
  57017. case '<':
  57018. $this->maxDepth = $comparator->getTarget() - 1;
  57019. break;
  57020. case '<=':
  57021. $this->maxDepth = $comparator->getTarget();
  57022. break;
  57023. default:
  57024. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  57025. }
  57026. }
  57027. return $this;
  57028. }
  57029. public function setExclude(array $exclude)
  57030. {
  57031. $this->exclude = $exclude;
  57032. return $this;
  57033. }
  57034. public function setNames(array $names)
  57035. {
  57036. $this->names = $names;
  57037. return $this;
  57038. }
  57039. public function setNotNames(array $notNames)
  57040. {
  57041. $this->notNames = $notNames;
  57042. return $this;
  57043. }
  57044. public function setContains(array $contains)
  57045. {
  57046. $this->contains = $contains;
  57047. return $this;
  57048. }
  57049. public function setNotContains(array $notContains)
  57050. {
  57051. $this->notContains = $notContains;
  57052. return $this;
  57053. }
  57054. public function setSizes(array $sizes)
  57055. {
  57056. $this->sizes = $sizes;
  57057. return $this;
  57058. }
  57059. public function setDates(array $dates)
  57060. {
  57061. $this->dates = $dates;
  57062. return $this;
  57063. }
  57064. public function setFilters(array $filters)
  57065. {
  57066. $this->filters = $filters;
  57067. return $this;
  57068. }
  57069. public function setSort($sort)
  57070. {
  57071. $this->sort = $sort;
  57072. return $this;
  57073. }
  57074. public function setPath(array $paths)
  57075. {
  57076. $this->paths = $paths;
  57077. return $this;
  57078. }
  57079. public function setNotPath(array $notPaths)
  57080. {
  57081. $this->notPaths = $notPaths;
  57082. return $this;
  57083. }
  57084. public function ignoreUnreadableDirs($ignore = true)
  57085. {
  57086. $this->ignoreUnreadableDirs = (bool) $ignore;
  57087. return $this;
  57088. }
  57089. abstract protected function canBeUsed();
  57090. }
  57091. <?php
  57092. namespace Symfony\Component\Finder\Adapter;
  57093. @trigger_error('The '.__NAMESPACE__.'\AbstractFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
  57094. use Symfony\Component\Finder\Comparator\DateComparator;
  57095. use Symfony\Component\Finder\Comparator\NumberComparator;
  57096. use Symfony\Component\Finder\Exception\AccessDeniedException;
  57097. use Symfony\Component\Finder\Expression\Expression;
  57098. use Symfony\Component\Finder\Iterator;
  57099. use Symfony\Component\Finder\Shell\Command;
  57100. use Symfony\Component\Finder\Shell\Shell;
  57101. abstract class AbstractFindAdapter extends AbstractAdapter
  57102. {
  57103. protected $shell;
  57104. public function __construct()
  57105. {
  57106. $this->shell = new Shell();
  57107. }
  57108. public function searchInDirectory($dir)
  57109. {
  57110. $dir = realpath($dir);
  57111. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  57112. return new Iterator\FilePathsIterator(array(), $dir);
  57113. }
  57114. $command = Command::create();
  57115. $find = $this->buildFindCommand($command, $dir);
  57116. if ($this->followLinks) {
  57117. $find->add('-follow');
  57118. }
  57119. $find->add('-mindepth')->add($this->minDepth + 1);
  57120. if (PHP_INT_MAX !== $this->maxDepth) {
  57121. $find->add('-maxdepth')->add($this->maxDepth + 1);
  57122. }
  57123. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  57124. $find->add('-type d');
  57125. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  57126. $find->add('-type f');
  57127. }
  57128. $this->buildNamesFiltering($find, $this->names);
  57129. $this->buildNamesFiltering($find, $this->notNames, true);
  57130. $this->buildPathsFiltering($find, $dir, $this->paths);
  57131. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  57132. $this->buildSizesFiltering($find, $this->sizes);
  57133. $this->buildDatesFiltering($find, $this->dates);
  57134. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  57135. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  57136. if ($useGrep && ($this->contains || $this->notContains)) {
  57137. $grep = $command->ins('grep');
  57138. $this->buildContentFiltering($grep, $this->contains);
  57139. $this->buildContentFiltering($grep, $this->notContains, true);
  57140. }
  57141. if ($useSort) {
  57142. $this->buildSorting($command, $this->sort);
  57143. }
  57144. $command->setErrorHandler(
  57145. $this->ignoreUnreadableDirs
  57146. ? function ($stderr) { }
  57147. : function ($stderr) { throw new AccessDeniedException($stderr); }
  57148. );
  57149. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  57150. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  57151. if ($this->exclude) {
  57152. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  57153. }
  57154. if (!$useGrep && ($this->contains || $this->notContains)) {
  57155. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  57156. }
  57157. if ($this->filters) {
  57158. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  57159. }
  57160. if (!$useSort && $this->sort) {
  57161. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  57162. $iterator = $iteratorAggregate->getIterator();
  57163. }
  57164. return $iterator;
  57165. }
  57166. protected function canBeUsed()
  57167. {
  57168. return $this->shell->testCommand('find');
  57169. }
  57170. protected function buildFindCommand(Command $command, $dir)
  57171. {
  57172. return $command
  57173. ->ins('find')
  57174. ->add('find ')
  57175. ->arg($dir)
  57176. ->add('-noleaf');
  57177. }
  57178. private function buildNamesFiltering(Command $command, array $names, $not = false)
  57179. {
  57180. if (0 === \count($names)) {
  57181. return;
  57182. }
  57183. $command->add($not ? '-not' : null)->cmd('(');
  57184. foreach ($names as $i => $name) {
  57185. $expr = Expression::create($name);
  57186. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  57187. $expr = Expression::create($expr->getGlob()->toRegex(false));
  57188. }
  57189. if ($expr->isRegex()) {
  57190. $regex = $expr->getRegex();
  57191. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  57192. ->setStartFlag(false)
  57193. ->setStartJoker(true)
  57194. ->replaceJokers('[^/]');
  57195. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  57196. $regex->setEndJoker(false)->append('[^/]*');
  57197. }
  57198. }
  57199. $command
  57200. ->add($i > 0 ? '-or' : null)
  57201. ->add($expr->isRegex()
  57202. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  57203. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  57204. )
  57205. ->arg($expr->renderPattern());
  57206. }
  57207. $command->cmd(')');
  57208. }
  57209. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  57210. {
  57211. if (0 === \count($paths)) {
  57212. return;
  57213. }
  57214. $command->add($not ? '-not' : null)->cmd('(');
  57215. foreach ($paths as $i => $path) {
  57216. $expr = Expression::create($path);
  57217. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  57218. $expr = Expression::create($expr->getGlob()->toRegex(false));
  57219. }
  57220. if ($expr->isRegex()) {
  57221. $regex = $expr->getRegex();
  57222. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  57223. } else {
  57224. $expr->prepend('*')->append('*');
  57225. }
  57226. $command
  57227. ->add($i > 0 ? '-or' : null)
  57228. ->add($expr->isRegex()
  57229. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  57230. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  57231. )
  57232. ->arg($expr->renderPattern());
  57233. }
  57234. $command->cmd(')');
  57235. }
  57236. private function buildSizesFiltering(Command $command, array $sizes)
  57237. {
  57238. foreach ($sizes as $i => $size) {
  57239. $command->add($i > 0 ? '-and' : null);
  57240. switch ($size->getOperator()) {
  57241. case '<=':
  57242. $command->add('-size -'.($size->getTarget() + 1).'c');
  57243. break;
  57244. case '>=':
  57245. $command->add('-size +'.($size->getTarget() - 1).'c');
  57246. break;
  57247. case '>':
  57248. $command->add('-size +'.$size->getTarget().'c');
  57249. break;
  57250. case '!=':
  57251. $command->add('-size -'.$size->getTarget().'c');
  57252. $command->add('-size +'.$size->getTarget().'c');
  57253. break;
  57254. case '<':
  57255. default:
  57256. $command->add('-size -'.$size->getTarget().'c');
  57257. }
  57258. }
  57259. }
  57260. private function buildDatesFiltering(Command $command, array $dates)
  57261. {
  57262. foreach ($dates as $i => $date) {
  57263. $command->add($i > 0 ? '-and' : null);
  57264. $mins = (int) round((time() - $date->getTarget()) / 60);
  57265. if (0 > $mins) {
  57266. $command->add(' -mmin -0');
  57267. return;
  57268. }
  57269. switch ($date->getOperator()) {
  57270. case '<=':
  57271. $command->add('-mmin +'.($mins - 1));
  57272. break;
  57273. case '>=':
  57274. $command->add('-mmin -'.($mins + 1));
  57275. break;
  57276. case '>':
  57277. $command->add('-mmin -'.$mins);
  57278. break;
  57279. case '!=':
  57280. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  57281. break;
  57282. case '<':
  57283. default:
  57284. $command->add('-mmin +'.$mins);
  57285. }
  57286. }
  57287. }
  57288. private function buildSorting(Command $command, $sort)
  57289. {
  57290. $this->buildFormatSorting($command, $sort);
  57291. }
  57292. abstract protected function buildFormatSorting(Command $command, $sort);
  57293. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  57294. }
  57295. <?php
  57296. namespace Symfony\Component\Finder\Adapter;
  57297. interface AdapterInterface
  57298. {
  57299. public function setFollowLinks($followLinks);
  57300. public function setMode($mode);
  57301. public function setExclude(array $exclude);
  57302. public function setDepths(array $depths);
  57303. public function setNames(array $names);
  57304. public function setNotNames(array $notNames);
  57305. public function setContains(array $contains);
  57306. public function setNotContains(array $notContains);
  57307. public function setSizes(array $sizes);
  57308. public function setDates(array $dates);
  57309. public function setFilters(array $filters);
  57310. public function setSort($sort);
  57311. public function setPath(array $paths);
  57312. public function setNotPath(array $notPaths);
  57313. public function ignoreUnreadableDirs($ignore = true);
  57314. public function searchInDirectory($dir);
  57315. public function isSupported();
  57316. public function getName();
  57317. }
  57318. <?php
  57319. namespace Symfony\Component\Finder\Adapter;
  57320. @trigger_error('The '.__NAMESPACE__.'\BsdFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
  57321. use Symfony\Component\Finder\Expression\Expression;
  57322. use Symfony\Component\Finder\Iterator\SortableIterator;
  57323. use Symfony\Component\Finder\Shell\Command;
  57324. use Symfony\Component\Finder\Shell\Shell;
  57325. class BsdFindAdapter extends AbstractFindAdapter
  57326. {
  57327. public function getName()
  57328. {
  57329. return 'bsd_find';
  57330. }
  57331. protected function canBeUsed()
  57332. {
  57333. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  57334. }
  57335. protected function buildFormatSorting(Command $command, $sort)
  57336. {
  57337. switch ($sort) {
  57338. case SortableIterator::SORT_BY_NAME:
  57339. $command->ins('sort')->add('| sort');
  57340. return;
  57341. case SortableIterator::SORT_BY_TYPE:
  57342. $format = '%HT';
  57343. break;
  57344. case SortableIterator::SORT_BY_ACCESSED_TIME:
  57345. $format = '%a';
  57346. break;
  57347. case SortableIterator::SORT_BY_CHANGED_TIME:
  57348. $format = '%c';
  57349. break;
  57350. case SortableIterator::SORT_BY_MODIFIED_TIME:
  57351. $format = '%m';
  57352. break;
  57353. default:
  57354. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  57355. }
  57356. $command
  57357. ->add('-print0 | xargs -0 stat -f')
  57358. ->arg($format.'%t%N')
  57359. ->add('| sort | cut -f 2');
  57360. }
  57361. protected function buildFindCommand(Command $command, $dir)
  57362. {
  57363. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  57364. return $command;
  57365. }
  57366. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  57367. {
  57368. foreach ($contains as $contain) {
  57369. $expr = Expression::create($contain);
  57370. $command
  57371. ->add('| grep -v \'^$\'')
  57372. ->add('| xargs -I{} grep -I')
  57373. ->add($expr->isCaseSensitive() ? null : '-i')
  57374. ->add($not ? '-L' : '-l')
  57375. ->add('-Ee')->arg($expr->renderPattern())
  57376. ->add('{}')
  57377. ;
  57378. }
  57379. }
  57380. }
  57381. <?php
  57382. namespace Symfony\Component\Finder\Adapter;
  57383. @trigger_error('The '.__NAMESPACE__.'\GnuFindAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
  57384. use Symfony\Component\Finder\Expression\Expression;
  57385. use Symfony\Component\Finder\Iterator\SortableIterator;
  57386. use Symfony\Component\Finder\Shell\Command;
  57387. use Symfony\Component\Finder\Shell\Shell;
  57388. class GnuFindAdapter extends AbstractFindAdapter
  57389. {
  57390. public function getName()
  57391. {
  57392. return 'gnu_find';
  57393. }
  57394. protected function buildFormatSorting(Command $command, $sort)
  57395. {
  57396. switch ($sort) {
  57397. case SortableIterator::SORT_BY_NAME:
  57398. $command->ins('sort')->add('| sort');
  57399. return;
  57400. case SortableIterator::SORT_BY_TYPE:
  57401. $format = '%y';
  57402. break;
  57403. case SortableIterator::SORT_BY_ACCESSED_TIME:
  57404. $format = '%A@';
  57405. break;
  57406. case SortableIterator::SORT_BY_CHANGED_TIME:
  57407. $format = '%C@';
  57408. break;
  57409. case SortableIterator::SORT_BY_MODIFIED_TIME:
  57410. $format = '%T@';
  57411. break;
  57412. default:
  57413. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  57414. }
  57415. $command
  57416. ->get('find')
  57417. ->add('-printf')
  57418. ->arg($format.' %h/%f\\n')
  57419. ->add('| sort | cut')
  57420. ->arg('-d ')
  57421. ->arg('-f2-')
  57422. ;
  57423. }
  57424. protected function canBeUsed()
  57425. {
  57426. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  57427. }
  57428. protected function buildFindCommand(Command $command, $dir)
  57429. {
  57430. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  57431. }
  57432. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  57433. {
  57434. foreach ($contains as $contain) {
  57435. $expr = Expression::create($contain);
  57436. $command
  57437. ->add('| xargs -I{} -r grep -I')
  57438. ->add($expr->isCaseSensitive() ? null : '-i')
  57439. ->add($not ? '-L' : '-l')
  57440. ->add('-Ee')->arg($expr->renderPattern())
  57441. ->add('{}')
  57442. ;
  57443. }
  57444. }
  57445. }
  57446. <?php
  57447. namespace Symfony\Component\Finder\Adapter;
  57448. @trigger_error('The '.__NAMESPACE__.'\PhpAdapter class is deprecated since Symfony 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
  57449. use Symfony\Component\Finder\Iterator;
  57450. class PhpAdapter extends AbstractAdapter
  57451. {
  57452. public function searchInDirectory($dir)
  57453. {
  57454. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  57455. if ($this->followLinks) {
  57456. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  57457. }
  57458. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  57459. if ($this->exclude) {
  57460. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  57461. }
  57462. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  57463. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  57464. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  57465. }
  57466. if ($this->mode) {
  57467. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  57468. }
  57469. if ($this->names || $this->notNames) {
  57470. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  57471. }
  57472. if ($this->contains || $this->notContains) {
  57473. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  57474. }
  57475. if ($this->sizes) {
  57476. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  57477. }
  57478. if ($this->dates) {
  57479. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  57480. }
  57481. if ($this->filters) {
  57482. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  57483. }
  57484. if ($this->paths || $this->notPaths) {
  57485. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  57486. }
  57487. if ($this->sort) {
  57488. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  57489. $iterator = $iteratorAggregate->getIterator();
  57490. }
  57491. return $iterator;
  57492. }
  57493. public function getName()
  57494. {
  57495. return 'php';
  57496. }
  57497. protected function canBeUsed()
  57498. {
  57499. return true;
  57500. }
  57501. }
  57502. <?php
  57503. namespace Symfony\Component\Finder\Comparator;
  57504. class Comparator
  57505. {
  57506. private $target;
  57507. private $operator = '==';
  57508. public function getTarget()
  57509. {
  57510. return $this->target;
  57511. }
  57512. public function setTarget($target)
  57513. {
  57514. $this->target = $target;
  57515. }
  57516. public function getOperator()
  57517. {
  57518. return $this->operator;
  57519. }
  57520. public function setOperator($operator)
  57521. {
  57522. if (!$operator) {
  57523. $operator = '==';
  57524. }
  57525. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  57526. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  57527. }
  57528. $this->operator = $operator;
  57529. }
  57530. public function test($test)
  57531. {
  57532. switch ($this->operator) {
  57533. case '>':
  57534. return $test > $this->target;
  57535. case '>=':
  57536. return $test >= $this->target;
  57537. case '<':
  57538. return $test < $this->target;
  57539. case '<=':
  57540. return $test <= $this->target;
  57541. case '!=':
  57542. return $test != $this->target;
  57543. }
  57544. return $test == $this->target;
  57545. }
  57546. }
  57547. <?php
  57548. namespace Symfony\Component\Finder\Comparator;
  57549. class DateComparator extends Comparator
  57550. {
  57551. public function __construct($test)
  57552. {
  57553. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  57554. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  57555. }
  57556. try {
  57557. $date = new \DateTime($matches[2]);
  57558. $target = $date->format('U');
  57559. } catch (\Exception $e) {
  57560. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  57561. }
  57562. $operator = isset($matches[1]) ? $matches[1] : '==';
  57563. if ('since' === $operator || 'after' === $operator) {
  57564. $operator = '>';
  57565. }
  57566. if ('until' === $operator || 'before' === $operator) {
  57567. $operator = '<';
  57568. }
  57569. $this->setOperator($operator);
  57570. $this->setTarget($target);
  57571. }
  57572. }
  57573. <?php
  57574. namespace Symfony\Component\Finder\Comparator;
  57575. class NumberComparator extends Comparator
  57576. {
  57577. public function __construct($test)
  57578. {
  57579. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  57580. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  57581. }
  57582. $target = $matches[2];
  57583. if (!is_numeric($target)) {
  57584. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  57585. }
  57586. if (isset($matches[3])) {
  57587. switch (strtolower($matches[3])) {
  57588. case 'k':
  57589. $target *= 1000;
  57590. break;
  57591. case 'ki':
  57592. $target *= 1024;
  57593. break;
  57594. case 'm':
  57595. $target *= 1000000;
  57596. break;
  57597. case 'mi':
  57598. $target *= 1024 * 1024;
  57599. break;
  57600. case 'g':
  57601. $target *= 1000000000;
  57602. break;
  57603. case 'gi':
  57604. $target *= 1024 * 1024 * 1024;
  57605. break;
  57606. }
  57607. }
  57608. $this->setTarget($target);
  57609. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  57610. }
  57611. }
  57612. <?php
  57613. namespace Symfony\Component\Finder\Exception;
  57614. class AccessDeniedException extends \UnexpectedValueException
  57615. {
  57616. }
  57617. <?php
  57618. namespace Symfony\Component\Finder\Exception;
  57619. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57620. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57621. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  57622. {
  57623. private $adapter;
  57624. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  57625. {
  57626. $this->adapter = $adapter;
  57627. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  57628. }
  57629. public function getAdapter()
  57630. {
  57631. return $this->adapter;
  57632. }
  57633. }
  57634. <?php
  57635. namespace Symfony\Component\Finder\Exception;
  57636. interface ExceptionInterface
  57637. {
  57638. public function getAdapter();
  57639. }
  57640. <?php
  57641. namespace Symfony\Component\Finder\Exception;
  57642. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57643. class OperationNotPermitedException extends AdapterFailureException
  57644. {
  57645. }
  57646. <?php
  57647. namespace Symfony\Component\Finder\Exception;
  57648. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57649. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57650. use Symfony\Component\Finder\Shell\Command;
  57651. class ShellCommandFailureException extends AdapterFailureException
  57652. {
  57653. private $command;
  57654. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  57655. {
  57656. $this->command = $command;
  57657. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  57658. }
  57659. public function getCommand()
  57660. {
  57661. return $this->command;
  57662. }
  57663. }
  57664. <?php
  57665. namespace Symfony\Component\Finder\Expression;
  57666. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57667. class Expression implements ValueInterface
  57668. {
  57669. const TYPE_REGEX = 1;
  57670. const TYPE_GLOB = 2;
  57671. private $value;
  57672. public static function create($expr)
  57673. {
  57674. return new self($expr);
  57675. }
  57676. public function __construct($expr)
  57677. {
  57678. try {
  57679. $this->value = Regex::create($expr);
  57680. } catch (\InvalidArgumentException $e) {
  57681. $this->value = new Glob($expr);
  57682. }
  57683. }
  57684. public function __toString()
  57685. {
  57686. return $this->render();
  57687. }
  57688. public function render()
  57689. {
  57690. return $this->value->render();
  57691. }
  57692. public function renderPattern()
  57693. {
  57694. return $this->value->renderPattern();
  57695. }
  57696. public function isCaseSensitive()
  57697. {
  57698. return $this->value->isCaseSensitive();
  57699. }
  57700. public function getType()
  57701. {
  57702. return $this->value->getType();
  57703. }
  57704. public function prepend($expr)
  57705. {
  57706. $this->value->prepend($expr);
  57707. return $this;
  57708. }
  57709. public function append($expr)
  57710. {
  57711. $this->value->append($expr);
  57712. return $this;
  57713. }
  57714. public function isRegex()
  57715. {
  57716. return self::TYPE_REGEX === $this->value->getType();
  57717. }
  57718. public function isGlob()
  57719. {
  57720. return self::TYPE_GLOB === $this->value->getType();
  57721. }
  57722. public function getGlob()
  57723. {
  57724. if (self::TYPE_GLOB !== $this->value->getType()) {
  57725. throw new \LogicException('Regex can\'t be transformed to glob.');
  57726. }
  57727. return $this->value;
  57728. }
  57729. public function getRegex()
  57730. {
  57731. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  57732. }
  57733. }
  57734. <?php
  57735. namespace Symfony\Component\Finder\Expression;
  57736. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57737. use Symfony\Component\Finder\Glob as FinderGlob;
  57738. class Glob implements ValueInterface
  57739. {
  57740. private $pattern;
  57741. public function __construct($pattern)
  57742. {
  57743. $this->pattern = $pattern;
  57744. }
  57745. public function render()
  57746. {
  57747. return $this->pattern;
  57748. }
  57749. public function renderPattern()
  57750. {
  57751. return $this->pattern;
  57752. }
  57753. public function getType()
  57754. {
  57755. return Expression::TYPE_GLOB;
  57756. }
  57757. public function isCaseSensitive()
  57758. {
  57759. return true;
  57760. }
  57761. public function prepend($expr)
  57762. {
  57763. $this->pattern = $expr.$this->pattern;
  57764. return $this;
  57765. }
  57766. public function append($expr)
  57767. {
  57768. $this->pattern .= $expr;
  57769. return $this;
  57770. }
  57771. public function isExpandable()
  57772. {
  57773. return false !== strpos($this->pattern, '{')
  57774. && false !== strpos($this->pattern, '}');
  57775. }
  57776. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  57777. {
  57778. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  57779. return new Regex($regex);
  57780. }
  57781. }
  57782. <?php
  57783. namespace Symfony\Component\Finder\Expression;
  57784. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57785. class Regex implements ValueInterface
  57786. {
  57787. const START_FLAG = '^';
  57788. const END_FLAG = '$';
  57789. const BOUNDARY = '~';
  57790. const JOKER = '.*';
  57791. const ESCAPING = '\\';
  57792. private $pattern;
  57793. private $options;
  57794. private $startFlag;
  57795. private $endFlag;
  57796. private $startJoker;
  57797. private $endJoker;
  57798. public static function create($expr)
  57799. {
  57800. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  57801. $start = substr($m[1], 0, 1);
  57802. $end = substr($m[1], -1);
  57803. if (
  57804. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  57805. || ('{' === $start && '}' === $end)
  57806. || ('(' === $start && ')' === $end)
  57807. ) {
  57808. return new self(substr($m[1], 1, -1), $m[2], $end);
  57809. }
  57810. }
  57811. throw new \InvalidArgumentException('Given expression is not a regex.');
  57812. }
  57813. public function __construct($pattern, $options = '', $delimiter = null)
  57814. {
  57815. if (null !== $delimiter) {
  57816. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  57817. }
  57818. $this->parsePattern($pattern);
  57819. $this->options = $options;
  57820. }
  57821. public function __toString()
  57822. {
  57823. return $this->render();
  57824. }
  57825. public function render()
  57826. {
  57827. return self::BOUNDARY
  57828. .$this->renderPattern()
  57829. .self::BOUNDARY
  57830. .$this->options;
  57831. }
  57832. public function renderPattern()
  57833. {
  57834. return ($this->startFlag ? self::START_FLAG : '')
  57835. .($this->startJoker ? self::JOKER : '')
  57836. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  57837. .($this->endJoker ? self::JOKER : '')
  57838. .($this->endFlag ? self::END_FLAG : '');
  57839. }
  57840. public function isCaseSensitive()
  57841. {
  57842. return !$this->hasOption('i');
  57843. }
  57844. public function getType()
  57845. {
  57846. return Expression::TYPE_REGEX;
  57847. }
  57848. public function prepend($expr)
  57849. {
  57850. $this->pattern = $expr.$this->pattern;
  57851. return $this;
  57852. }
  57853. public function append($expr)
  57854. {
  57855. $this->pattern .= $expr;
  57856. return $this;
  57857. }
  57858. public function hasOption($option)
  57859. {
  57860. return false !== strpos($this->options, $option);
  57861. }
  57862. public function addOption($option)
  57863. {
  57864. if (!$this->hasOption($option)) {
  57865. $this->options .= $option;
  57866. }
  57867. return $this;
  57868. }
  57869. public function removeOption($option)
  57870. {
  57871. $this->options = str_replace($option, '', $this->options);
  57872. return $this;
  57873. }
  57874. public function setStartFlag($startFlag)
  57875. {
  57876. $this->startFlag = $startFlag;
  57877. return $this;
  57878. }
  57879. public function hasStartFlag()
  57880. {
  57881. return $this->startFlag;
  57882. }
  57883. public function setEndFlag($endFlag)
  57884. {
  57885. $this->endFlag = (bool) $endFlag;
  57886. return $this;
  57887. }
  57888. public function hasEndFlag()
  57889. {
  57890. return $this->endFlag;
  57891. }
  57892. public function setStartJoker($startJoker)
  57893. {
  57894. $this->startJoker = $startJoker;
  57895. return $this;
  57896. }
  57897. public function hasStartJoker()
  57898. {
  57899. return $this->startJoker;
  57900. }
  57901. public function setEndJoker($endJoker)
  57902. {
  57903. $this->endJoker = (bool) $endJoker;
  57904. return $this;
  57905. }
  57906. public function hasEndJoker()
  57907. {
  57908. return $this->endJoker;
  57909. }
  57910. public function replaceJokers($replacement)
  57911. {
  57912. $replace = function ($subject) use ($replacement) {
  57913. $subject = $subject[0];
  57914. $replace = 0 === substr_count($subject, '\\') % 2;
  57915. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  57916. };
  57917. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  57918. return $this;
  57919. }
  57920. private function parsePattern($pattern)
  57921. {
  57922. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  57923. $pattern = substr($pattern, 1);
  57924. }
  57925. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  57926. $pattern = substr($pattern, 2);
  57927. }
  57928. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  57929. $pattern = substr($pattern, 0, -1);
  57930. }
  57931. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  57932. $pattern = substr($pattern, 0, -2);
  57933. }
  57934. $this->pattern = $pattern;
  57935. }
  57936. }
  57937. <?php
  57938. namespace Symfony\Component\Finder\Expression;
  57939. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57940. interface ValueInterface
  57941. {
  57942. public function render();
  57943. public function renderPattern();
  57944. public function isCaseSensitive();
  57945. public function getType();
  57946. public function prepend($expr);
  57947. public function append($expr);
  57948. }
  57949. <?php
  57950. namespace Symfony\Component\Finder;
  57951. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57952. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  57953. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  57954. use Symfony\Component\Finder\Adapter\PhpAdapter;
  57955. use Symfony\Component\Finder\Comparator\DateComparator;
  57956. use Symfony\Component\Finder\Comparator\NumberComparator;
  57957. use Symfony\Component\Finder\Exception\ExceptionInterface;
  57958. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  57959. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  57960. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  57961. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  57962. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  57963. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  57964. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  57965. use Symfony\Component\Finder\Iterator\SortableIterator;
  57966. class Finder implements \IteratorAggregate, \Countable
  57967. {
  57968. const IGNORE_VCS_FILES = 1;
  57969. const IGNORE_DOT_FILES = 2;
  57970. private $mode = 0;
  57971. private $names = array();
  57972. private $notNames = array();
  57973. private $exclude = array();
  57974. private $filters = array();
  57975. private $depths = array();
  57976. private $sizes = array();
  57977. private $followLinks = false;
  57978. private $sort = false;
  57979. private $ignore = 0;
  57980. private $dirs = array();
  57981. private $dates = array();
  57982. private $iterators = array();
  57983. private $contains = array();
  57984. private $notContains = array();
  57985. private $adapters = null;
  57986. private $paths = array();
  57987. private $notPaths = array();
  57988. private $ignoreUnreadableDirs = false;
  57989. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  57990. public function __construct()
  57991. {
  57992. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  57993. }
  57994. public static function create()
  57995. {
  57996. return new static();
  57997. }
  57998. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  57999. {
  58000. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58001. $this->initDefaultAdapters();
  58002. $this->adapters[$adapter->getName()] = array(
  58003. 'adapter' => $adapter,
  58004. 'priority' => $priority,
  58005. 'selected' => false,
  58006. );
  58007. return $this->sortAdapters();
  58008. }
  58009. public function useBestAdapter()
  58010. {
  58011. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58012. $this->initDefaultAdapters();
  58013. $this->resetAdapterSelection();
  58014. return $this->sortAdapters();
  58015. }
  58016. public function setAdapter($name)
  58017. {
  58018. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58019. $this->initDefaultAdapters();
  58020. if (!isset($this->adapters[$name])) {
  58021. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  58022. }
  58023. $this->resetAdapterSelection();
  58024. $this->adapters[$name]['selected'] = true;
  58025. return $this->sortAdapters();
  58026. }
  58027. public function removeAdapters()
  58028. {
  58029. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58030. $this->adapters = array();
  58031. return $this;
  58032. }
  58033. public function getAdapters()
  58034. {
  58035. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58036. $this->initDefaultAdapters();
  58037. return array_values(array_map(function (array $adapter) {
  58038. return $adapter['adapter'];
  58039. }, $this->adapters));
  58040. }
  58041. public function directories()
  58042. {
  58043. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  58044. return $this;
  58045. }
  58046. public function files()
  58047. {
  58048. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  58049. return $this;
  58050. }
  58051. public function depth($level)
  58052. {
  58053. $this->depths[] = new Comparator\NumberComparator($level);
  58054. return $this;
  58055. }
  58056. public function date($date)
  58057. {
  58058. $this->dates[] = new Comparator\DateComparator($date);
  58059. return $this;
  58060. }
  58061. public function name($pattern)
  58062. {
  58063. $this->names[] = $pattern;
  58064. return $this;
  58065. }
  58066. public function notName($pattern)
  58067. {
  58068. $this->notNames[] = $pattern;
  58069. return $this;
  58070. }
  58071. public function contains($pattern)
  58072. {
  58073. $this->contains[] = $pattern;
  58074. return $this;
  58075. }
  58076. public function notContains($pattern)
  58077. {
  58078. $this->notContains[] = $pattern;
  58079. return $this;
  58080. }
  58081. public function path($pattern)
  58082. {
  58083. $this->paths[] = $pattern;
  58084. return $this;
  58085. }
  58086. public function notPath($pattern)
  58087. {
  58088. $this->notPaths[] = $pattern;
  58089. return $this;
  58090. }
  58091. public function size($size)
  58092. {
  58093. $this->sizes[] = new Comparator\NumberComparator($size);
  58094. return $this;
  58095. }
  58096. public function exclude($dirs)
  58097. {
  58098. $this->exclude = array_merge($this->exclude, (array) $dirs);
  58099. return $this;
  58100. }
  58101. public function ignoreDotFiles($ignoreDotFiles)
  58102. {
  58103. if ($ignoreDotFiles) {
  58104. $this->ignore |= static::IGNORE_DOT_FILES;
  58105. } else {
  58106. $this->ignore &= ~static::IGNORE_DOT_FILES;
  58107. }
  58108. return $this;
  58109. }
  58110. public function ignoreVCS($ignoreVCS)
  58111. {
  58112. if ($ignoreVCS) {
  58113. $this->ignore |= static::IGNORE_VCS_FILES;
  58114. } else {
  58115. $this->ignore &= ~static::IGNORE_VCS_FILES;
  58116. }
  58117. return $this;
  58118. }
  58119. public static function addVCSPattern($pattern)
  58120. {
  58121. foreach ((array) $pattern as $p) {
  58122. self::$vcsPatterns[] = $p;
  58123. }
  58124. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  58125. }
  58126. public function sort(\Closure $closure)
  58127. {
  58128. $this->sort = $closure;
  58129. return $this;
  58130. }
  58131. public function sortByName()
  58132. {
  58133. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  58134. return $this;
  58135. }
  58136. public function sortByType()
  58137. {
  58138. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  58139. return $this;
  58140. }
  58141. public function sortByAccessedTime()
  58142. {
  58143. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  58144. return $this;
  58145. }
  58146. public function sortByChangedTime()
  58147. {
  58148. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  58149. return $this;
  58150. }
  58151. public function sortByModifiedTime()
  58152. {
  58153. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  58154. return $this;
  58155. }
  58156. public function filter(\Closure $closure)
  58157. {
  58158. $this->filters[] = $closure;
  58159. return $this;
  58160. }
  58161. public function followLinks()
  58162. {
  58163. $this->followLinks = true;
  58164. return $this;
  58165. }
  58166. public function ignoreUnreadableDirs($ignore = true)
  58167. {
  58168. $this->ignoreUnreadableDirs = (bool) $ignore;
  58169. return $this;
  58170. }
  58171. public function in($dirs)
  58172. {
  58173. $resolvedDirs = array();
  58174. foreach ((array) $dirs as $dir) {
  58175. if (is_dir($dir)) {
  58176. $resolvedDirs[] = $this->normalizeDir($dir);
  58177. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  58178. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  58179. } else {
  58180. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  58181. }
  58182. }
  58183. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  58184. return $this;
  58185. }
  58186. public function getIterator()
  58187. {
  58188. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  58189. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  58190. }
  58191. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  58192. return $this->searchInDirectory($this->dirs[0]);
  58193. }
  58194. $iterator = new \AppendIterator();
  58195. foreach ($this->dirs as $dir) {
  58196. $iterator->append($this->searchInDirectory($dir));
  58197. }
  58198. foreach ($this->iterators as $it) {
  58199. $iterator->append($it);
  58200. }
  58201. return $iterator;
  58202. }
  58203. public function append($iterator)
  58204. {
  58205. if ($iterator instanceof \IteratorAggregate) {
  58206. $this->iterators[] = $iterator->getIterator();
  58207. } elseif ($iterator instanceof \Iterator) {
  58208. $this->iterators[] = $iterator;
  58209. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  58210. $it = new \ArrayIterator();
  58211. foreach ($iterator as $file) {
  58212. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  58213. }
  58214. $this->iterators[] = $it;
  58215. } else {
  58216. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  58217. }
  58218. return $this;
  58219. }
  58220. public function count()
  58221. {
  58222. return iterator_count($this->getIterator());
  58223. }
  58224. private function sortAdapters()
  58225. {
  58226. uasort($this->adapters, function (array $a, array $b) {
  58227. if ($a['selected'] || $b['selected']) {
  58228. return $a['selected'] ? -1 : 1;
  58229. }
  58230. return $a['priority'] > $b['priority'] ? -1 : 1;
  58231. });
  58232. return $this;
  58233. }
  58234. private function searchInDirectory($dir)
  58235. {
  58236. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  58237. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  58238. }
  58239. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  58240. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  58241. }
  58242. if ($this->adapters) {
  58243. foreach ($this->adapters as $adapter) {
  58244. if ($adapter['adapter']->isSupported()) {
  58245. try {
  58246. return $this
  58247. ->buildAdapter($adapter['adapter'])
  58248. ->searchInDirectory($dir);
  58249. } catch (ExceptionInterface $e) {
  58250. }
  58251. }
  58252. }
  58253. }
  58254. $minDepth = 0;
  58255. $maxDepth = PHP_INT_MAX;
  58256. foreach ($this->depths as $comparator) {
  58257. switch ($comparator->getOperator()) {
  58258. case '>':
  58259. $minDepth = $comparator->getTarget() + 1;
  58260. break;
  58261. case '>=':
  58262. $minDepth = $comparator->getTarget();
  58263. break;
  58264. case '<':
  58265. $maxDepth = $comparator->getTarget() - 1;
  58266. break;
  58267. case '<=':
  58268. $maxDepth = $comparator->getTarget();
  58269. break;
  58270. default:
  58271. $minDepth = $maxDepth = $comparator->getTarget();
  58272. }
  58273. }
  58274. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  58275. if ($this->followLinks) {
  58276. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  58277. }
  58278. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  58279. if ($this->exclude) {
  58280. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  58281. }
  58282. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  58283. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  58284. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  58285. }
  58286. if ($this->mode) {
  58287. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  58288. }
  58289. if ($this->names || $this->notNames) {
  58290. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  58291. }
  58292. if ($this->contains || $this->notContains) {
  58293. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  58294. }
  58295. if ($this->sizes) {
  58296. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  58297. }
  58298. if ($this->dates) {
  58299. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  58300. }
  58301. if ($this->filters) {
  58302. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  58303. }
  58304. if ($this->paths || $this->notPaths) {
  58305. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  58306. }
  58307. if ($this->sort) {
  58308. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  58309. $iterator = $iteratorAggregate->getIterator();
  58310. }
  58311. return $iterator;
  58312. }
  58313. private function buildAdapter(AdapterInterface $adapter)
  58314. {
  58315. return $adapter
  58316. ->setFollowLinks($this->followLinks)
  58317. ->setDepths($this->depths)
  58318. ->setMode($this->mode)
  58319. ->setExclude($this->exclude)
  58320. ->setNames($this->names)
  58321. ->setNotNames($this->notNames)
  58322. ->setContains($this->contains)
  58323. ->setNotContains($this->notContains)
  58324. ->setSizes($this->sizes)
  58325. ->setDates($this->dates)
  58326. ->setFilters($this->filters)
  58327. ->setSort($this->sort)
  58328. ->setPath($this->paths)
  58329. ->setNotPath($this->notPaths)
  58330. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  58331. }
  58332. private function resetAdapterSelection()
  58333. {
  58334. $this->adapters = array_map(function (array $properties) {
  58335. $properties['selected'] = false;
  58336. return $properties;
  58337. }, $this->adapters);
  58338. }
  58339. private function initDefaultAdapters()
  58340. {
  58341. if (null === $this->adapters) {
  58342. $this->adapters = array();
  58343. $this
  58344. ->addAdapter(new GnuFindAdapter())
  58345. ->addAdapter(new BsdFindAdapter())
  58346. ->addAdapter(new PhpAdapter(), -50)
  58347. ->setAdapter('php')
  58348. ;
  58349. }
  58350. }
  58351. private function normalizeDir($dir)
  58352. {
  58353. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  58354. }
  58355. }
  58356. <?php
  58357. namespace Symfony\Component\Finder;
  58358. class Glob
  58359. {
  58360. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  58361. {
  58362. $firstByte = true;
  58363. $escaping = false;
  58364. $inCurlies = 0;
  58365. $regex = '';
  58366. $sizeGlob = \strlen($glob);
  58367. for ($i = 0; $i < $sizeGlob; ++$i) {
  58368. $car = $glob[$i];
  58369. if ($firstByte) {
  58370. if ($strictLeadingDot && '.' !== $car) {
  58371. $regex .= '(?=[^\.])';
  58372. }
  58373. $firstByte = false;
  58374. }
  58375. if ('/' === $car) {
  58376. $firstByte = true;
  58377. }
  58378. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  58379. $regex .= "\\$car";
  58380. } elseif ('*' === $car) {
  58381. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  58382. } elseif ('?' === $car) {
  58383. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  58384. } elseif ('{' === $car) {
  58385. $regex .= $escaping ? '\\{' : '(';
  58386. if (!$escaping) {
  58387. ++$inCurlies;
  58388. }
  58389. } elseif ('}' === $car && $inCurlies) {
  58390. $regex .= $escaping ? '}' : ')';
  58391. if (!$escaping) {
  58392. --$inCurlies;
  58393. }
  58394. } elseif (',' === $car && $inCurlies) {
  58395. $regex .= $escaping ? ',' : '|';
  58396. } elseif ('\\' === $car) {
  58397. if ($escaping) {
  58398. $regex .= '\\\\';
  58399. $escaping = false;
  58400. } else {
  58401. $escaping = true;
  58402. }
  58403. continue;
  58404. } else {
  58405. $regex .= $car;
  58406. }
  58407. $escaping = false;
  58408. }
  58409. return $delimiter.'^'.$regex.'$'.$delimiter;
  58410. }
  58411. }
  58412. <?php
  58413. namespace Symfony\Component\Finder\Iterator;
  58414. class CustomFilterIterator extends FilterIterator
  58415. {
  58416. private $filters = array();
  58417. public function __construct(\Iterator $iterator, array $filters)
  58418. {
  58419. foreach ($filters as $filter) {
  58420. if (!\is_callable($filter)) {
  58421. throw new \InvalidArgumentException('Invalid PHP callback.');
  58422. }
  58423. }
  58424. $this->filters = $filters;
  58425. parent::__construct($iterator);
  58426. }
  58427. public function accept()
  58428. {
  58429. $fileinfo = $this->current();
  58430. foreach ($this->filters as $filter) {
  58431. if (false === \call_user_func($filter, $fileinfo)) {
  58432. return false;
  58433. }
  58434. }
  58435. return true;
  58436. }
  58437. }
  58438. <?php
  58439. namespace Symfony\Component\Finder\Iterator;
  58440. use Symfony\Component\Finder\Comparator\DateComparator;
  58441. class DateRangeFilterIterator extends FilterIterator
  58442. {
  58443. private $comparators = array();
  58444. public function __construct(\Iterator $iterator, array $comparators)
  58445. {
  58446. $this->comparators = $comparators;
  58447. parent::__construct($iterator);
  58448. }
  58449. public function accept()
  58450. {
  58451. $fileinfo = $this->current();
  58452. if (!file_exists($fileinfo->getPathname())) {
  58453. return false;
  58454. }
  58455. $filedate = $fileinfo->getMTime();
  58456. foreach ($this->comparators as $compare) {
  58457. if (!$compare->test($filedate)) {
  58458. return false;
  58459. }
  58460. }
  58461. return true;
  58462. }
  58463. }
  58464. <?php
  58465. namespace Symfony\Component\Finder\Iterator;
  58466. class DepthRangeFilterIterator extends FilterIterator
  58467. {
  58468. private $minDepth = 0;
  58469. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  58470. {
  58471. $this->minDepth = $minDepth;
  58472. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  58473. parent::__construct($iterator);
  58474. }
  58475. public function accept()
  58476. {
  58477. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  58478. }
  58479. }
  58480. <?php
  58481. namespace Symfony\Component\Finder\Iterator;
  58482. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  58483. {
  58484. private $iterator;
  58485. private $isRecursive;
  58486. private $excludedDirs = array();
  58487. private $excludedPattern;
  58488. public function __construct(\Iterator $iterator, array $directories)
  58489. {
  58490. $this->iterator = $iterator;
  58491. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  58492. $patterns = array();
  58493. foreach ($directories as $directory) {
  58494. $directory = rtrim($directory, '/');
  58495. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  58496. $patterns[] = preg_quote($directory, '#');
  58497. } else {
  58498. $this->excludedDirs[$directory] = true;
  58499. }
  58500. }
  58501. if ($patterns) {
  58502. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  58503. }
  58504. parent::__construct($iterator);
  58505. }
  58506. public function accept()
  58507. {
  58508. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  58509. return false;
  58510. }
  58511. if ($this->excludedPattern) {
  58512. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  58513. $path = str_replace('\\', '/', $path);
  58514. return !preg_match($this->excludedPattern, $path);
  58515. }
  58516. return true;
  58517. }
  58518. public function hasChildren()
  58519. {
  58520. return $this->isRecursive && $this->iterator->hasChildren();
  58521. }
  58522. public function getChildren()
  58523. {
  58524. $children = new self($this->iterator->getChildren(), array());
  58525. $children->excludedDirs = $this->excludedDirs;
  58526. $children->excludedPattern = $this->excludedPattern;
  58527. return $children;
  58528. }
  58529. }
  58530. <?php
  58531. namespace Symfony\Component\Finder\Iterator;
  58532. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58533. use Symfony\Component\Finder\SplFileInfo;
  58534. class FilePathsIterator extends \ArrayIterator
  58535. {
  58536. private $baseDir;
  58537. private $baseDirLength;
  58538. private $subPath;
  58539. private $subPathname;
  58540. private $current;
  58541. public function __construct(array $paths, $baseDir)
  58542. {
  58543. $this->baseDir = $baseDir;
  58544. $this->baseDirLength = \strlen($baseDir);
  58545. parent::__construct($paths);
  58546. }
  58547. public function __call($name, array $arguments)
  58548. {
  58549. return \call_user_func_array(array($this->current(), $name), $arguments);
  58550. }
  58551. public function current()
  58552. {
  58553. return $this->current;
  58554. }
  58555. public function key()
  58556. {
  58557. return $this->current->getPathname();
  58558. }
  58559. public function next()
  58560. {
  58561. parent::next();
  58562. $this->buildProperties();
  58563. }
  58564. public function rewind()
  58565. {
  58566. parent::rewind();
  58567. $this->buildProperties();
  58568. }
  58569. public function getSubPath()
  58570. {
  58571. return $this->subPath;
  58572. }
  58573. public function getSubPathname()
  58574. {
  58575. return $this->subPathname;
  58576. }
  58577. private function buildProperties()
  58578. {
  58579. $absolutePath = parent::current();
  58580. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  58581. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  58582. $dir = \dirname($this->subPathname);
  58583. $this->subPath = '.' === $dir ? '' : $dir;
  58584. } else {
  58585. $this->subPath = $this->subPathname = '';
  58586. }
  58587. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  58588. }
  58589. }
  58590. <?php
  58591. namespace Symfony\Component\Finder\Iterator;
  58592. class FileTypeFilterIterator extends FilterIterator
  58593. {
  58594. const ONLY_FILES = 1;
  58595. const ONLY_DIRECTORIES = 2;
  58596. private $mode;
  58597. public function __construct(\Iterator $iterator, $mode)
  58598. {
  58599. $this->mode = $mode;
  58600. parent::__construct($iterator);
  58601. }
  58602. public function accept()
  58603. {
  58604. $fileinfo = $this->current();
  58605. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  58606. return false;
  58607. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  58608. return false;
  58609. }
  58610. return true;
  58611. }
  58612. }
  58613. <?php
  58614. namespace Symfony\Component\Finder\Iterator;
  58615. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  58616. {
  58617. public function accept()
  58618. {
  58619. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  58620. return true;
  58621. }
  58622. $fileinfo = $this->current();
  58623. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  58624. return false;
  58625. }
  58626. $content = $fileinfo->getContents();
  58627. if (!$content) {
  58628. return false;
  58629. }
  58630. return $this->isAccepted($content);
  58631. }
  58632. protected function toRegex($str)
  58633. {
  58634. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58635. }
  58636. }
  58637. <?php
  58638. namespace Symfony\Component\Finder\Iterator;
  58639. use Symfony\Component\Finder\Glob;
  58640. class FilenameFilterIterator extends MultiplePcreFilterIterator
  58641. {
  58642. public function accept()
  58643. {
  58644. return $this->isAccepted($this->current()->getFilename());
  58645. }
  58646. protected function toRegex($str)
  58647. {
  58648. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  58649. }
  58650. }
  58651. <?php
  58652. namespace Symfony\Component\Finder\Iterator;
  58653. abstract class FilterIterator extends \FilterIterator
  58654. {
  58655. public function rewind()
  58656. {
  58657. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  58658. parent::rewind();
  58659. return;
  58660. }
  58661. $iterator = $this;
  58662. while ($iterator instanceof \OuterIterator) {
  58663. $innerIterator = $iterator->getInnerIterator();
  58664. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  58665. if ($innerIterator->isRewindable()) {
  58666. $innerIterator->next();
  58667. $innerIterator->rewind();
  58668. }
  58669. } elseif ($innerIterator instanceof \FilesystemIterator) {
  58670. $innerIterator->next();
  58671. $innerIterator->rewind();
  58672. }
  58673. $iterator = $innerIterator;
  58674. }
  58675. parent::rewind();
  58676. }
  58677. }
  58678. <?php
  58679. namespace Symfony\Component\Finder\Iterator;
  58680. abstract class MultiplePcreFilterIterator extends FilterIterator
  58681. {
  58682. protected $matchRegexps = array();
  58683. protected $noMatchRegexps = array();
  58684. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  58685. {
  58686. foreach ($matchPatterns as $pattern) {
  58687. $this->matchRegexps[] = $this->toRegex($pattern);
  58688. }
  58689. foreach ($noMatchPatterns as $pattern) {
  58690. $this->noMatchRegexps[] = $this->toRegex($pattern);
  58691. }
  58692. parent::__construct($iterator);
  58693. }
  58694. protected function isAccepted($string)
  58695. {
  58696. foreach ($this->noMatchRegexps as $regex) {
  58697. if (preg_match($regex, $string)) {
  58698. return false;
  58699. }
  58700. }
  58701. if ($this->matchRegexps) {
  58702. foreach ($this->matchRegexps as $regex) {
  58703. if (preg_match($regex, $string)) {
  58704. return true;
  58705. }
  58706. }
  58707. return false;
  58708. }
  58709. return true;
  58710. }
  58711. protected function isRegex($str)
  58712. {
  58713. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  58714. $start = substr($m[1], 0, 1);
  58715. $end = substr($m[1], -1);
  58716. if ($start === $end) {
  58717. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  58718. }
  58719. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  58720. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  58721. return true;
  58722. }
  58723. }
  58724. }
  58725. return false;
  58726. }
  58727. abstract protected function toRegex($str);
  58728. }
  58729. <?php
  58730. namespace Symfony\Component\Finder\Iterator;
  58731. class PathFilterIterator extends MultiplePcreFilterIterator
  58732. {
  58733. public function accept()
  58734. {
  58735. $filename = $this->current()->getRelativePathname();
  58736. if ('\\' === \DIRECTORY_SEPARATOR) {
  58737. $filename = str_replace('\\', '/', $filename);
  58738. }
  58739. return $this->isAccepted($filename);
  58740. }
  58741. protected function toRegex($str)
  58742. {
  58743. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58744. }
  58745. }
  58746. <?php
  58747. namespace Symfony\Component\Finder\Iterator;
  58748. use Symfony\Component\Finder\Exception\AccessDeniedException;
  58749. use Symfony\Component\Finder\SplFileInfo;
  58750. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  58751. {
  58752. private $ignoreUnreadableDirs;
  58753. private $rewindable;
  58754. private $rootPath;
  58755. private $subPath;
  58756. private $directorySeparator = '/';
  58757. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  58758. {
  58759. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  58760. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  58761. }
  58762. parent::__construct($path, $flags);
  58763. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  58764. $this->rootPath = (string) $path;
  58765. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  58766. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  58767. }
  58768. }
  58769. public function current()
  58770. {
  58771. if (null === $subPathname = $this->subPath) {
  58772. $subPathname = $this->subPath = (string) $this->getSubPath();
  58773. }
  58774. if ('' !== $subPathname) {
  58775. $subPathname .= $this->directorySeparator;
  58776. }
  58777. $subPathname .= $this->getFilename();
  58778. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  58779. }
  58780. public function getChildren()
  58781. {
  58782. try {
  58783. $children = parent::getChildren();
  58784. if ($children instanceof self) {
  58785. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  58786. $children->rewindable = &$this->rewindable;
  58787. $children->rootPath = $this->rootPath;
  58788. }
  58789. return $children;
  58790. } catch (\UnexpectedValueException $e) {
  58791. if ($this->ignoreUnreadableDirs) {
  58792. return new \RecursiveArrayIterator(array());
  58793. } else {
  58794. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  58795. }
  58796. }
  58797. }
  58798. public function rewind()
  58799. {
  58800. if (false === $this->isRewindable()) {
  58801. return;
  58802. }
  58803. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  58804. parent::next();
  58805. }
  58806. parent::rewind();
  58807. }
  58808. public function isRewindable()
  58809. {
  58810. if (null !== $this->rewindable) {
  58811. return $this->rewindable;
  58812. }
  58813. if ('' === $this->getPath()) {
  58814. return $this->rewindable = false;
  58815. }
  58816. if (false !== $stream = @opendir($this->getPath())) {
  58817. $infos = stream_get_meta_data($stream);
  58818. closedir($stream);
  58819. if ($infos['seekable']) {
  58820. return $this->rewindable = true;
  58821. }
  58822. }
  58823. return $this->rewindable = false;
  58824. }
  58825. }
  58826. <?php
  58827. namespace Symfony\Component\Finder\Iterator;
  58828. use Symfony\Component\Finder\Comparator\NumberComparator;
  58829. class SizeRangeFilterIterator extends FilterIterator
  58830. {
  58831. private $comparators = array();
  58832. public function __construct(\Iterator $iterator, array $comparators)
  58833. {
  58834. $this->comparators = $comparators;
  58835. parent::__construct($iterator);
  58836. }
  58837. public function accept()
  58838. {
  58839. $fileinfo = $this->current();
  58840. if (!$fileinfo->isFile()) {
  58841. return true;
  58842. }
  58843. $filesize = $fileinfo->getSize();
  58844. foreach ($this->comparators as $compare) {
  58845. if (!$compare->test($filesize)) {
  58846. return false;
  58847. }
  58848. }
  58849. return true;
  58850. }
  58851. }
  58852. <?php
  58853. namespace Symfony\Component\Finder\Iterator;
  58854. class SortableIterator implements \IteratorAggregate
  58855. {
  58856. const SORT_BY_NAME = 1;
  58857. const SORT_BY_TYPE = 2;
  58858. const SORT_BY_ACCESSED_TIME = 3;
  58859. const SORT_BY_CHANGED_TIME = 4;
  58860. const SORT_BY_MODIFIED_TIME = 5;
  58861. private $iterator;
  58862. private $sort;
  58863. public function __construct(\Traversable $iterator, $sort)
  58864. {
  58865. $this->iterator = $iterator;
  58866. if (self::SORT_BY_NAME === $sort) {
  58867. $this->sort = function ($a, $b) {
  58868. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58869. };
  58870. } elseif (self::SORT_BY_TYPE === $sort) {
  58871. $this->sort = function ($a, $b) {
  58872. if ($a->isDir() && $b->isFile()) {
  58873. return -1;
  58874. } elseif ($a->isFile() && $b->isDir()) {
  58875. return 1;
  58876. }
  58877. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58878. };
  58879. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  58880. $this->sort = function ($a, $b) {
  58881. return $a->getATime() - $b->getATime();
  58882. };
  58883. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  58884. $this->sort = function ($a, $b) {
  58885. return $a->getCTime() - $b->getCTime();
  58886. };
  58887. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  58888. $this->sort = function ($a, $b) {
  58889. return $a->getMTime() - $b->getMTime();
  58890. };
  58891. } elseif (\is_callable($sort)) {
  58892. $this->sort = $sort;
  58893. } else {
  58894. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  58895. }
  58896. }
  58897. public function getIterator()
  58898. {
  58899. $array = iterator_to_array($this->iterator, true);
  58900. uasort($array, $this->sort);
  58901. return new \ArrayIterator($array);
  58902. }
  58903. }
  58904. Copyright (c) 2004-2018 Fabien Potencier
  58905. Permission is hereby granted, free of charge, to any person obtaining a copy
  58906. of this software and associated documentation files (the "Software"), to deal
  58907. in the Software without restriction, including without limitation the rights
  58908. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58909. copies of the Software, and to permit persons to whom the Software is furnished
  58910. to do so, subject to the following conditions:
  58911. The above copyright notice and this permission notice shall be included in all
  58912. copies or substantial portions of the Software.
  58913. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58914. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58915. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58916. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58917. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58918. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58919. THE SOFTWARE.
  58920. <?php
  58921. namespace Symfony\Component\Finder\Shell;
  58922. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58923. class Command
  58924. {
  58925. private $parent;
  58926. private $bits = array();
  58927. private $labels = array();
  58928. private $errorHandler;
  58929. public function __construct(Command $parent = null)
  58930. {
  58931. $this->parent = $parent;
  58932. }
  58933. public function __toString()
  58934. {
  58935. return $this->join();
  58936. }
  58937. public static function create(Command $parent = null)
  58938. {
  58939. return new self($parent);
  58940. }
  58941. public static function escape($input)
  58942. {
  58943. return escapeshellcmd($input);
  58944. }
  58945. public static function quote($input)
  58946. {
  58947. return escapeshellarg($input);
  58948. }
  58949. public function add($bit)
  58950. {
  58951. $this->bits[] = $bit;
  58952. return $this;
  58953. }
  58954. public function top($bit)
  58955. {
  58956. array_unshift($this->bits, $bit);
  58957. foreach ($this->labels as $label => $index) {
  58958. ++$this->labels[$label];
  58959. }
  58960. return $this;
  58961. }
  58962. public function arg($arg)
  58963. {
  58964. $this->bits[] = self::quote($arg);
  58965. return $this;
  58966. }
  58967. public function cmd($esc)
  58968. {
  58969. $this->bits[] = self::escape($esc);
  58970. return $this;
  58971. }
  58972. public function ins($label)
  58973. {
  58974. if (isset($this->labels[$label])) {
  58975. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  58976. }
  58977. $this->bits[] = self::create($this);
  58978. $this->labels[$label] = \count($this->bits) - 1;
  58979. return $this->bits[$this->labels[$label]];
  58980. }
  58981. public function get($label)
  58982. {
  58983. if (!isset($this->labels[$label])) {
  58984. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  58985. }
  58986. return $this->bits[$this->labels[$label]];
  58987. }
  58988. public function end()
  58989. {
  58990. if (null === $this->parent) {
  58991. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  58992. }
  58993. return $this->parent;
  58994. }
  58995. public function length()
  58996. {
  58997. return \count($this->bits);
  58998. }
  58999. public function setErrorHandler(\Closure $errorHandler)
  59000. {
  59001. $this->errorHandler = $errorHandler;
  59002. return $this;
  59003. }
  59004. public function getErrorHandler()
  59005. {
  59006. return $this->errorHandler;
  59007. }
  59008. public function execute()
  59009. {
  59010. if (null === $errorHandler = $this->errorHandler) {
  59011. exec($this->join(), $output);
  59012. } else {
  59013. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  59014. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  59015. if ($error = stream_get_contents($pipes[2])) {
  59016. $errorHandler($error);
  59017. }
  59018. proc_close($process);
  59019. }
  59020. return $output ?: array();
  59021. }
  59022. public function join()
  59023. {
  59024. return implode(' ', array_filter(
  59025. array_map(function ($bit) {
  59026. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  59027. }, $this->bits),
  59028. function ($bit) { return null !== $bit; }
  59029. ));
  59030. }
  59031. public function addAtIndex($bit, $index)
  59032. {
  59033. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  59034. return $this;
  59035. }
  59036. }
  59037. <?php
  59038. namespace Symfony\Component\Finder\Shell;
  59039. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59040. class Shell
  59041. {
  59042. const TYPE_UNIX = 1;
  59043. const TYPE_DARWIN = 2;
  59044. const TYPE_CYGWIN = 3;
  59045. const TYPE_WINDOWS = 4;
  59046. const TYPE_BSD = 5;
  59047. private $type;
  59048. public function getType()
  59049. {
  59050. if (null === $this->type) {
  59051. $this->type = $this->guessType();
  59052. }
  59053. return $this->type;
  59054. }
  59055. public function testCommand($command)
  59056. {
  59057. if (!\function_exists('exec')) {
  59058. return false;
  59059. }
  59060. $testCommand = 'which ';
  59061. if (self::TYPE_WINDOWS === $this->type) {
  59062. $testCommand = 'where ';
  59063. }
  59064. $command = escapeshellcmd($command);
  59065. exec($testCommand.$command, $output, $code);
  59066. return 0 === $code && \count($output) > 0;
  59067. }
  59068. private function guessType()
  59069. {
  59070. $os = strtolower(PHP_OS);
  59071. if (false !== strpos($os, 'cygwin')) {
  59072. return self::TYPE_CYGWIN;
  59073. }
  59074. if (false !== strpos($os, 'darwin')) {
  59075. return self::TYPE_DARWIN;
  59076. }
  59077. if (false !== strpos($os, 'bsd')) {
  59078. return self::TYPE_BSD;
  59079. }
  59080. if (0 === strpos($os, 'win')) {
  59081. return self::TYPE_WINDOWS;
  59082. }
  59083. return self::TYPE_UNIX;
  59084. }
  59085. }
  59086. <?php
  59087. namespace Symfony\Component\Finder;
  59088. class SplFileInfo extends \SplFileInfo
  59089. {
  59090. private $relativePath;
  59091. private $relativePathname;
  59092. public function __construct($file, $relativePath, $relativePathname)
  59093. {
  59094. parent::__construct($file);
  59095. $this->relativePath = $relativePath;
  59096. $this->relativePathname = $relativePathname;
  59097. }
  59098. public function getRelativePath()
  59099. {
  59100. return $this->relativePath;
  59101. }
  59102. public function getRelativePathname()
  59103. {
  59104. return $this->relativePathname;
  59105. }
  59106. public function getContents()
  59107. {
  59108. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  59109. $content = file_get_contents($this->getPathname());
  59110. restore_error_handler();
  59111. if (false === $content) {
  59112. throw new \RuntimeException($error);
  59113. }
  59114. return $content;
  59115. }
  59116. }
  59117. <?php
  59118. namespace Symfony\Polyfill\Ctype;
  59119. final class Ctype
  59120. {
  59121. public static function ctype_alnum($text)
  59122. {
  59123. $text = self::convert_int_to_char_for_ctype($text);
  59124. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  59125. }
  59126. public static function ctype_alpha($text)
  59127. {
  59128. $text = self::convert_int_to_char_for_ctype($text);
  59129. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  59130. }
  59131. public static function ctype_cntrl($text)
  59132. {
  59133. $text = self::convert_int_to_char_for_ctype($text);
  59134. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  59135. }
  59136. public static function ctype_digit($text)
  59137. {
  59138. $text = self::convert_int_to_char_for_ctype($text);
  59139. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  59140. }
  59141. public static function ctype_graph($text)
  59142. {
  59143. $text = self::convert_int_to_char_for_ctype($text);
  59144. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  59145. }
  59146. public static function ctype_lower($text)
  59147. {
  59148. $text = self::convert_int_to_char_for_ctype($text);
  59149. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  59150. }
  59151. public static function ctype_print($text)
  59152. {
  59153. $text = self::convert_int_to_char_for_ctype($text);
  59154. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  59155. }
  59156. public static function ctype_punct($text)
  59157. {
  59158. $text = self::convert_int_to_char_for_ctype($text);
  59159. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  59160. }
  59161. public static function ctype_space($text)
  59162. {
  59163. $text = self::convert_int_to_char_for_ctype($text);
  59164. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  59165. }
  59166. public static function ctype_upper($text)
  59167. {
  59168. $text = self::convert_int_to_char_for_ctype($text);
  59169. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  59170. }
  59171. public static function ctype_xdigit($text)
  59172. {
  59173. $text = self::convert_int_to_char_for_ctype($text);
  59174. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  59175. }
  59176. private static function convert_int_to_char_for_ctype($int)
  59177. {
  59178. if (!\is_int($int)) {
  59179. return $int;
  59180. }
  59181. if ($int < -128 || $int > 255) {
  59182. return (string) $int;
  59183. }
  59184. if ($int < 0) {
  59185. $int += 256;
  59186. }
  59187. return \chr($int);
  59188. }
  59189. }
  59190. Copyright (c) 2018-2019 Fabien Potencier
  59191. Permission is hereby granted, free of charge, to any person obtaining a copy
  59192. of this software and associated documentation files (the "Software"), to deal
  59193. in the Software without restriction, including without limitation the rights
  59194. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59195. copies of the Software, and to permit persons to whom the Software is furnished
  59196. to do so, subject to the following conditions:
  59197. The above copyright notice and this permission notice shall be included in all
  59198. copies or substantial portions of the Software.
  59199. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  59200. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59201. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59202. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59203. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  59204. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  59205. THE SOFTWARE.
  59206. <?php
  59207. use Symfony\Polyfill\Ctype as p;
  59208. if (!function_exists('ctype_alnum')) {
  59209. function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); }
  59210. }
  59211. if (!function_exists('ctype_alpha')) {
  59212. function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); }
  59213. }
  59214. if (!function_exists('ctype_cntrl')) {
  59215. function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); }
  59216. }
  59217. if (!function_exists('ctype_digit')) {
  59218. function ctype_digit($input) { return p\Ctype::ctype_digit($input); }
  59219. }
  59220. if (!function_exists('ctype_graph')) {
  59221. function ctype_graph($input) { return p\Ctype::ctype_graph($input); }
  59222. }
  59223. if (!function_exists('ctype_lower')) {
  59224. function ctype_lower($input) { return p\Ctype::ctype_lower($input); }
  59225. }
  59226. if (!function_exists('ctype_print')) {
  59227. function ctype_print($input) { return p\Ctype::ctype_print($input); }
  59228. }
  59229. if (!function_exists('ctype_punct')) {
  59230. function ctype_punct($input) { return p\Ctype::ctype_punct($input); }
  59231. }
  59232. if (!function_exists('ctype_space')) {
  59233. function ctype_space($input) { return p\Ctype::ctype_space($input); }
  59234. }
  59235. if (!function_exists('ctype_upper')) {
  59236. function ctype_upper($input) { return p\Ctype::ctype_upper($input); }
  59237. }
  59238. if (!function_exists('ctype_xdigit')) {
  59239. function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); }
  59240. }
  59241. Copyright (c) 2015-2019 Fabien Potencier
  59242. Permission is hereby granted, free of charge, to any person obtaining a copy
  59243. of this software and associated documentation files (the "Software"), to deal
  59244. in the Software without restriction, including without limitation the rights
  59245. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59246. copies of the Software, and to permit persons to whom the Software is furnished
  59247. to do so, subject to the following conditions:
  59248. The above copyright notice and this permission notice shall be included in all
  59249. copies or substantial portions of the Software.
  59250. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  59251. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59252. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59253. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59254. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  59255. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  59256. THE SOFTWARE.
  59257. <?php
  59258. namespace Symfony\Polyfill\Mbstring;
  59259. final class Mbstring
  59260. {
  59261. const MB_CASE_FOLD = PHP_INT_MAX;
  59262. private static $encodingList = array('ASCII', 'UTF-8');
  59263. private static $language = 'neutral';
  59264. private static $internalEncoding = 'UTF-8';
  59265. private static $caseFold = array(
  59266. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  59267. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  59268. );
  59269. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  59270. {
  59271. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  59272. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  59273. } else {
  59274. $fromEncoding = self::getEncoding($fromEncoding);
  59275. }
  59276. $toEncoding = self::getEncoding($toEncoding);
  59277. if ('BASE64' === $fromEncoding) {
  59278. $s = base64_decode($s);
  59279. $fromEncoding = $toEncoding;
  59280. }
  59281. if ('BASE64' === $toEncoding) {
  59282. return base64_encode($s);
  59283. }
  59284. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  59285. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  59286. $fromEncoding = 'Windows-1252';
  59287. }
  59288. if ('UTF-8' !== $fromEncoding) {
  59289. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  59290. }
  59291. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  59292. }
  59293. if ('HTML-ENTITIES' === $fromEncoding) {
  59294. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  59295. $fromEncoding = 'UTF-8';
  59296. }
  59297. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  59298. }
  59299. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  59300. {
  59301. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  59302. $ok = true;
  59303. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  59304. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  59305. $ok = false;
  59306. }
  59307. });
  59308. return $ok ? $fromEncoding : false;
  59309. }
  59310. public static function mb_decode_mimeheader($s)
  59311. {
  59312. return iconv_mime_decode($s, 2, self::$internalEncoding);
  59313. }
  59314. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  59315. {
  59316. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  59317. }
  59318. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  59319. {
  59320. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  59321. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59322. return null;
  59323. }
  59324. if (!\is_array($convmap) || !$convmap) {
  59325. return false;
  59326. }
  59327. if (null !== $encoding && !\is_scalar($encoding)) {
  59328. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59329. return '';
  59330. }
  59331. $s = (string) $s;
  59332. if ('' === $s) {
  59333. return '';
  59334. }
  59335. $encoding = self::getEncoding($encoding);
  59336. if ('UTF-8' === $encoding) {
  59337. $encoding = null;
  59338. if (!preg_match('//u', $s)) {
  59339. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59340. }
  59341. } else {
  59342. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59343. }
  59344. $cnt = floor(\count($convmap) / 4) * 4;
  59345. for ($i = 0; $i < $cnt; $i += 4) {
  59346. $convmap[$i] += $convmap[$i + 2];
  59347. $convmap[$i + 1] += $convmap[$i + 2];
  59348. }
  59349. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  59350. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  59351. for ($i = 0; $i < $cnt; $i += 4) {
  59352. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  59353. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  59354. }
  59355. }
  59356. return $m[0];
  59357. }, $s);
  59358. if (null === $encoding) {
  59359. return $s;
  59360. }
  59361. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  59362. }
  59363. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  59364. {
  59365. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  59366. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59367. return null;
  59368. }
  59369. if (!\is_array($convmap) || !$convmap) {
  59370. return false;
  59371. }
  59372. if (null !== $encoding && !\is_scalar($encoding)) {
  59373. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59374. return null;
  59375. }
  59376. if (null !== $is_hex && !\is_scalar($is_hex)) {
  59377. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  59378. return null;
  59379. }
  59380. $s = (string) $s;
  59381. if ('' === $s) {
  59382. return '';
  59383. }
  59384. $encoding = self::getEncoding($encoding);
  59385. if ('UTF-8' === $encoding) {
  59386. $encoding = null;
  59387. if (!preg_match('//u', $s)) {
  59388. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59389. }
  59390. } else {
  59391. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59392. }
  59393. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  59394. $cnt = floor(\count($convmap) / 4) * 4;
  59395. $i = 0;
  59396. $len = \strlen($s);
  59397. $result = '';
  59398. while ($i < $len) {
  59399. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  59400. $uchr = substr($s, $i, $ulen);
  59401. $i += $ulen;
  59402. $c = self::mb_ord($uchr);
  59403. for ($j = 0; $j < $cnt; $j += 4) {
  59404. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  59405. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  59406. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  59407. continue 2;
  59408. }
  59409. }
  59410. $result .= $uchr;
  59411. }
  59412. if (null === $encoding) {
  59413. return $result;
  59414. }
  59415. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  59416. }
  59417. public static function mb_convert_case($s, $mode, $encoding = null)
  59418. {
  59419. $s = (string) $s;
  59420. if ('' === $s) {
  59421. return '';
  59422. }
  59423. $encoding = self::getEncoding($encoding);
  59424. if ('UTF-8' === $encoding) {
  59425. $encoding = null;
  59426. if (!preg_match('//u', $s)) {
  59427. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59428. }
  59429. } else {
  59430. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59431. }
  59432. if (MB_CASE_TITLE == $mode) {
  59433. static $titleRegexp = null;
  59434. if (null === $titleRegexp) {
  59435. $titleRegexp = self::getData('titleCaseRegexp');
  59436. }
  59437. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  59438. } else {
  59439. if (MB_CASE_UPPER == $mode) {
  59440. static $upper = null;
  59441. if (null === $upper) {
  59442. $upper = self::getData('upperCase');
  59443. }
  59444. $map = $upper;
  59445. } else {
  59446. if (self::MB_CASE_FOLD === $mode) {
  59447. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  59448. }
  59449. static $lower = null;
  59450. if (null === $lower) {
  59451. $lower = self::getData('lowerCase');
  59452. }
  59453. $map = $lower;
  59454. }
  59455. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  59456. $i = 0;
  59457. $len = \strlen($s);
  59458. while ($i < $len) {
  59459. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  59460. $uchr = substr($s, $i, $ulen);
  59461. $i += $ulen;
  59462. if (isset($map[$uchr])) {
  59463. $uchr = $map[$uchr];
  59464. $nlen = \strlen($uchr);
  59465. if ($nlen == $ulen) {
  59466. $nlen = $i;
  59467. do {
  59468. $s[--$nlen] = $uchr[--$ulen];
  59469. } while ($ulen);
  59470. } else {
  59471. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  59472. $len += $nlen - $ulen;
  59473. $i += $nlen - $ulen;
  59474. }
  59475. }
  59476. }
  59477. }
  59478. if (null === $encoding) {
  59479. return $s;
  59480. }
  59481. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  59482. }
  59483. public static function mb_internal_encoding($encoding = null)
  59484. {
  59485. if (null === $encoding) {
  59486. return self::$internalEncoding;
  59487. }
  59488. $encoding = self::getEncoding($encoding);
  59489. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  59490. self::$internalEncoding = $encoding;
  59491. return true;
  59492. }
  59493. return false;
  59494. }
  59495. public static function mb_language($lang = null)
  59496. {
  59497. if (null === $lang) {
  59498. return self::$language;
  59499. }
  59500. switch ($lang = strtolower($lang)) {
  59501. case 'uni':
  59502. case 'neutral':
  59503. self::$language = $lang;
  59504. return true;
  59505. }
  59506. return false;
  59507. }
  59508. public static function mb_list_encodings()
  59509. {
  59510. return array('UTF-8');
  59511. }
  59512. public static function mb_encoding_aliases($encoding)
  59513. {
  59514. switch (strtoupper($encoding)) {
  59515. case 'UTF8':
  59516. case 'UTF-8':
  59517. return array('utf8');
  59518. }
  59519. return false;
  59520. }
  59521. public static function mb_check_encoding($var = null, $encoding = null)
  59522. {
  59523. if (null === $encoding) {
  59524. if (null === $var) {
  59525. return false;
  59526. }
  59527. $encoding = self::$internalEncoding;
  59528. }
  59529. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  59530. }
  59531. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  59532. {
  59533. if (null === $encodingList) {
  59534. $encodingList = self::$encodingList;
  59535. } else {
  59536. if (!\is_array($encodingList)) {
  59537. $encodingList = array_map('trim', explode(',', $encodingList));
  59538. }
  59539. $encodingList = array_map('strtoupper', $encodingList);
  59540. }
  59541. foreach ($encodingList as $enc) {
  59542. switch ($enc) {
  59543. case 'ASCII':
  59544. if (!preg_match('/[\x80-\xFF]/', $str)) {
  59545. return $enc;
  59546. }
  59547. break;
  59548. case 'UTF8':
  59549. case 'UTF-8':
  59550. if (preg_match('//u', $str)) {
  59551. return 'UTF-8';
  59552. }
  59553. break;
  59554. default:
  59555. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  59556. return $enc;
  59557. }
  59558. }
  59559. }
  59560. return false;
  59561. }
  59562. public static function mb_detect_order($encodingList = null)
  59563. {
  59564. if (null === $encodingList) {
  59565. return self::$encodingList;
  59566. }
  59567. if (!\is_array($encodingList)) {
  59568. $encodingList = array_map('trim', explode(',', $encodingList));
  59569. }
  59570. $encodingList = array_map('strtoupper', $encodingList);
  59571. foreach ($encodingList as $enc) {
  59572. switch ($enc) {
  59573. default:
  59574. if (strncmp($enc, 'ISO-8859-', 9)) {
  59575. return false;
  59576. }
  59577. case 'ASCII':
  59578. case 'UTF8':
  59579. case 'UTF-8':
  59580. }
  59581. }
  59582. self::$encodingList = $encodingList;
  59583. return true;
  59584. }
  59585. public static function mb_strlen($s, $encoding = null)
  59586. {
  59587. $encoding = self::getEncoding($encoding);
  59588. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59589. return \strlen($s);
  59590. }
  59591. return @iconv_strlen($s, $encoding);
  59592. }
  59593. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  59594. {
  59595. $encoding = self::getEncoding($encoding);
  59596. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59597. return strpos($haystack, $needle, $offset);
  59598. }
  59599. $needle = (string) $needle;
  59600. if ('' === $needle) {
  59601. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  59602. return false;
  59603. }
  59604. return iconv_strpos($haystack, $needle, $offset, $encoding);
  59605. }
  59606. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  59607. {
  59608. $encoding = self::getEncoding($encoding);
  59609. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59610. return strrpos($haystack, $needle, $offset);
  59611. }
  59612. if ($offset != (int) $offset) {
  59613. $offset = 0;
  59614. } elseif ($offset = (int) $offset) {
  59615. if ($offset < 0) {
  59616. if (0 > $offset += self::mb_strlen($needle)) {
  59617. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  59618. }
  59619. $offset = 0;
  59620. } else {
  59621. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  59622. }
  59623. }
  59624. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59625. return false !== $pos ? $offset + $pos : false;
  59626. }
  59627. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  59628. {
  59629. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
  59630. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
  59631. return null;
  59632. }
  59633. if (1 > $split_length = (int) $split_length) {
  59634. trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
  59635. return false;
  59636. }
  59637. if (null === $encoding) {
  59638. $encoding = mb_internal_encoding();
  59639. }
  59640. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  59641. $rx = '/(';
  59642. while (65535 < $split_length) {
  59643. $rx .= '.{65535}';
  59644. $split_length -= 65535;
  59645. }
  59646. $rx .= '.{'.$split_length.'})/us';
  59647. return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  59648. }
  59649. $result = array();
  59650. $length = mb_strlen($string, $encoding);
  59651. for ($i = 0; $i < $length; $i += $split_length) {
  59652. $result[] = mb_substr($string, $i, $split_length, $encoding);
  59653. }
  59654. return $result;
  59655. }
  59656. public static function mb_strtolower($s, $encoding = null)
  59657. {
  59658. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  59659. }
  59660. public static function mb_strtoupper($s, $encoding = null)
  59661. {
  59662. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  59663. }
  59664. public static function mb_substitute_character($c = null)
  59665. {
  59666. if (0 === strcasecmp($c, 'none')) {
  59667. return true;
  59668. }
  59669. return null !== $c ? false : 'none';
  59670. }
  59671. public static function mb_substr($s, $start, $length = null, $encoding = null)
  59672. {
  59673. $encoding = self::getEncoding($encoding);
  59674. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59675. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  59676. }
  59677. if ($start < 0) {
  59678. $start = iconv_strlen($s, $encoding) + $start;
  59679. if ($start < 0) {
  59680. $start = 0;
  59681. }
  59682. }
  59683. if (null === $length) {
  59684. $length = 2147483647;
  59685. } elseif ($length < 0) {
  59686. $length = iconv_strlen($s, $encoding) + $length - $start;
  59687. if ($length < 0) {
  59688. return '';
  59689. }
  59690. }
  59691. return (string) iconv_substr($s, $start, $length, $encoding);
  59692. }
  59693. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  59694. {
  59695. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59696. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59697. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  59698. }
  59699. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  59700. {
  59701. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  59702. return self::getSubpart($pos, $part, $haystack, $encoding);
  59703. }
  59704. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  59705. {
  59706. $encoding = self::getEncoding($encoding);
  59707. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59708. $pos = strrpos($haystack, $needle);
  59709. } else {
  59710. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59711. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59712. }
  59713. return self::getSubpart($pos, $part, $haystack, $encoding);
  59714. }
  59715. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  59716. {
  59717. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59718. $pos = self::mb_strripos($haystack, $needle, $encoding);
  59719. return self::getSubpart($pos, $part, $haystack, $encoding);
  59720. }
  59721. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  59722. {
  59723. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59724. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59725. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  59726. }
  59727. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  59728. {
  59729. $pos = strpos($haystack, $needle);
  59730. if (false === $pos) {
  59731. return false;
  59732. }
  59733. if ($part) {
  59734. return substr($haystack, 0, $pos);
  59735. }
  59736. return substr($haystack, $pos);
  59737. }
  59738. public static function mb_get_info($type = 'all')
  59739. {
  59740. $info = array(
  59741. 'internal_encoding' => self::$internalEncoding,
  59742. 'http_output' => 'pass',
  59743. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  59744. 'func_overload' => 0,
  59745. 'func_overload_list' => 'no overload',
  59746. 'mail_charset' => 'UTF-8',
  59747. 'mail_header_encoding' => 'BASE64',
  59748. 'mail_body_encoding' => 'BASE64',
  59749. 'illegal_chars' => 0,
  59750. 'encoding_translation' => 'Off',
  59751. 'language' => self::$language,
  59752. 'detect_order' => self::$encodingList,
  59753. 'substitute_character' => 'none',
  59754. 'strict_detection' => 'Off',
  59755. );
  59756. if ('all' === $type) {
  59757. return $info;
  59758. }
  59759. if (isset($info[$type])) {
  59760. return $info[$type];
  59761. }
  59762. return false;
  59763. }
  59764. public static function mb_http_input($type = '')
  59765. {
  59766. return false;
  59767. }
  59768. public static function mb_http_output($encoding = null)
  59769. {
  59770. return null !== $encoding ? 'pass' === $encoding : 'pass';
  59771. }
  59772. public static function mb_strwidth($s, $encoding = null)
  59773. {
  59774. $encoding = self::getEncoding($encoding);
  59775. if ('UTF-8' !== $encoding) {
  59776. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59777. }
  59778. $s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
  59779. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  59780. }
  59781. public static function mb_substr_count($haystack, $needle, $encoding = null)
  59782. {
  59783. return substr_count($haystack, $needle);
  59784. }
  59785. public static function mb_output_handler($contents, $status)
  59786. {
  59787. return $contents;
  59788. }
  59789. public static function mb_chr($code, $encoding = null)
  59790. {
  59791. if (0x80 > $code %= 0x200000) {
  59792. $s = \chr($code);
  59793. } elseif (0x800 > $code) {
  59794. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  59795. } elseif (0x10000 > $code) {
  59796. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59797. } else {
  59798. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59799. }
  59800. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59801. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  59802. }
  59803. return $s;
  59804. }
  59805. public static function mb_ord($s, $encoding = null)
  59806. {
  59807. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59808. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  59809. }
  59810. if (1 === \strlen($s)) {
  59811. return \ord($s);
  59812. }
  59813. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  59814. if (0xF0 <= $code) {
  59815. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  59816. }
  59817. if (0xE0 <= $code) {
  59818. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  59819. }
  59820. if (0xC0 <= $code) {
  59821. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  59822. }
  59823. return $code;
  59824. }
  59825. private static function getSubpart($pos, $part, $haystack, $encoding)
  59826. {
  59827. if (false === $pos) {
  59828. return false;
  59829. }
  59830. if ($part) {
  59831. return self::mb_substr($haystack, 0, $pos, $encoding);
  59832. }
  59833. return self::mb_substr($haystack, $pos, null, $encoding);
  59834. }
  59835. private static function html_encoding_callback(array $m)
  59836. {
  59837. $i = 1;
  59838. $entities = '';
  59839. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  59840. while (isset($m[$i])) {
  59841. if (0x80 > $m[$i]) {
  59842. $entities .= \chr($m[$i++]);
  59843. continue;
  59844. }
  59845. if (0xF0 <= $m[$i]) {
  59846. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59847. } elseif (0xE0 <= $m[$i]) {
  59848. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59849. } else {
  59850. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  59851. }
  59852. $entities .= '&#'.$c.';';
  59853. }
  59854. return $entities;
  59855. }
  59856. private static function title_case(array $s)
  59857. {
  59858. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  59859. }
  59860. private static function getData($file)
  59861. {
  59862. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  59863. return require $file;
  59864. }
  59865. return false;
  59866. }
  59867. private static function getEncoding($encoding)
  59868. {
  59869. if (null === $encoding) {
  59870. return self::$internalEncoding;
  59871. }
  59872. if ('UTF-8' === $encoding) {
  59873. return 'UTF-8';
  59874. }
  59875. $encoding = strtoupper($encoding);
  59876. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  59877. return 'CP850';
  59878. }
  59879. if ('UTF8' === $encoding) {
  59880. return 'UTF-8';
  59881. }
  59882. return $encoding;
  59883. }
  59884. }
  59885. <?php
  59886. use Symfony\Polyfill\Mbstring as p;
  59887. if (!function_exists('mb_convert_variables')) {
  59888. function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
  59889. {
  59890. $vars = [&$var, ...$vars];
  59891. $ok = true;
  59892. array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
  59893. if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
  59894. $ok = false;
  59895. }
  59896. });
  59897. return $ok ? $from_encoding : false;
  59898. }
  59899. }
  59900. <?php
  59901. return array (
  59902. 'A' => 'a',
  59903. 'B' => 'b',
  59904. 'C' => 'c',
  59905. 'D' => 'd',
  59906. 'E' => 'e',
  59907. 'F' => 'f',
  59908. 'G' => 'g',
  59909. 'H' => 'h',
  59910. 'I' => 'i',
  59911. 'J' => 'j',
  59912. 'K' => 'k',
  59913. 'L' => 'l',
  59914. 'M' => 'm',
  59915. 'N' => 'n',
  59916. 'O' => 'o',
  59917. 'P' => 'p',
  59918. 'Q' => 'q',
  59919. 'R' => 'r',
  59920. 'S' => 's',
  59921. 'T' => 't',
  59922. 'U' => 'u',
  59923. 'V' => 'v',
  59924. 'W' => 'w',
  59925. 'X' => 'x',
  59926. 'Y' => 'y',
  59927. 'Z' => 'z',
  59928. 'À' => 'à',
  59929. '�' => 'á',
  59930. 'Â' => 'â',
  59931. 'Ã' => 'ã',
  59932. 'Ä' => 'ä',
  59933. 'Ã…' => 'Ã¥',
  59934. 'Æ' => 'æ',
  59935. 'Ç' => 'ç',
  59936. 'È' => 'è',
  59937. 'É' => 'é',
  59938. 'Ê' => 'ê',
  59939. 'Ë' => 'ë',
  59940. 'Ì' => 'ì',
  59941. '�' => 'í',
  59942. 'Î' => 'î',
  59943. '�' => 'ï',
  59944. '�' => 'ð',
  59945. 'Ñ' => 'ñ',
  59946. 'Ò' => 'ò',
  59947. 'Ó' => 'ó',
  59948. 'Ô' => 'ô',
  59949. 'Õ' => 'õ',
  59950. 'Ö' => 'ö',
  59951. 'Ø' => 'ø',
  59952. 'Ù' => 'ù',
  59953. 'Ú' => 'ú',
  59954. 'Û' => 'û',
  59955. 'Ü' => 'ü',
  59956. '�' => 'ý',
  59957. 'Þ' => 'þ',
  59958. 'Ā' => '�',
  59959. 'Ă' => 'ă',
  59960. 'Ä„' => 'Ä…',
  59961. 'Ć' => 'ć',
  59962. 'Ĉ' => 'ĉ',
  59963. 'ÄŠ' => 'Ä‹',
  59964. 'Č' => '�',
  59965. 'Ď' => '�',
  59966. '�' => 'đ',
  59967. 'Ä’' => 'Ä“',
  59968. 'Ä”' => 'Ä•',
  59969. 'Ä–' => 'Ä—',
  59970. 'Ę' => 'ę',
  59971. 'Äš' => 'Ä›',
  59972. 'Ĝ' => '�',
  59973. 'Äž' => 'ÄŸ',
  59974. 'Ä ' => 'Ä¡',
  59975. 'Ä¢' => 'Ä£',
  59976. 'Ĥ' => 'ĥ',
  59977. 'Ħ' => 'ħ',
  59978. 'Ĩ' => 'ĩ',
  59979. 'Ī' => 'ī',
  59980. 'Ĭ' => 'ĭ',
  59981. 'Į' => 'į',
  59982. 'Ä°' => 'i',
  59983. 'IJ' => 'ij',
  59984. 'Ĵ' => 'ĵ',
  59985. 'Ķ' => 'ķ',
  59986. 'Ĺ' => 'ĺ',
  59987. 'Ļ' => 'ļ',
  59988. 'Ľ' => 'ľ',
  59989. 'Ä¿' => 'Å€',
  59990. '�' => 'ł',
  59991. 'Ń' => 'ń',
  59992. 'Ņ' => 'ņ',
  59993. 'Ň' => 'ň',
  59994. 'ÅŠ' => 'Å‹',
  59995. 'Ō' => '�',
  59996. 'Ŏ' => '�',
  59997. '�' => 'ő',
  59998. 'Å’' => 'Å“',
  59999. 'Å”' => 'Å•',
  60000. 'Å–' => 'Å—',
  60001. 'Ř' => 'ř',
  60002. 'Åš' => 'Å›',
  60003. 'Ŝ' => '�',
  60004. 'Åž' => 'ÅŸ',
  60005. 'Å ' => 'Å¡',
  60006. 'Å¢' => 'Å£',
  60007. 'Ť' => 'ť',
  60008. 'Ŧ' => 'ŧ',
  60009. 'Ũ' => 'ũ',
  60010. 'Ū' => 'ū',
  60011. 'Ŭ' => 'ŭ',
  60012. 'Ů' => 'ů',
  60013. 'Ű' => 'ű',
  60014. 'Ų' => 'ų',
  60015. 'Ŵ' => 'ŵ',
  60016. 'Ŷ' => 'ŷ',
  60017. 'Ÿ' => 'ÿ',
  60018. 'Ź' => 'ź',
  60019. 'Ż' => 'ż',
  60020. 'Ž' => 'ž',
  60021. '�' => 'ɓ',
  60022. 'Ƃ' => 'ƃ',
  60023. 'Æ„' => 'Æ…',
  60024. 'Ɔ' => 'ɔ',
  60025. 'Ƈ' => 'ƈ',
  60026. 'Ɖ' => 'ɖ',
  60027. 'ÆŠ' => 'É—',
  60028. 'Ƌ' => 'ƌ',
  60029. 'Ǝ' => '�',
  60030. '�' => 'ə',
  60031. '�' => 'ɛ',
  60032. 'Æ‘' => 'Æ’',
  60033. 'Æ“' => 'É ',
  60034. 'Æ”' => 'É£',
  60035. 'Æ–' => 'É©',
  60036. 'Ɨ' => 'ɨ',
  60037. 'Ƙ' => 'ƙ',
  60038. 'Ɯ' => 'ɯ',
  60039. '�' => 'ɲ',
  60040. 'Ɵ' => 'ɵ',
  60041. 'Æ ' => 'Æ¡',
  60042. 'Æ¢' => 'Æ£',
  60043. 'Ƥ' => 'ƥ',
  60044. 'Ʀ' => 'ʀ',
  60045. 'Ƨ' => 'ƨ',
  60046. 'Ʃ' => 'ʃ',
  60047. 'Ƭ' => 'ƭ',
  60048. 'Ʈ' => 'ʈ',
  60049. 'Ư' => 'ư',
  60050. 'Ʊ' => 'ʊ',
  60051. 'Ʋ' => 'ʋ',
  60052. 'Ƴ' => 'ƴ',
  60053. 'Ƶ' => 'ƶ',
  60054. 'Æ·' => 'Ê’',
  60055. 'Ƹ' => 'ƹ',
  60056. 'Ƽ' => 'ƽ',
  60057. 'DŽ' => 'dž',
  60058. 'Dž' => 'dž',
  60059. 'LJ' => 'lj',
  60060. 'Lj' => 'lj',
  60061. 'NJ' => 'nj',
  60062. 'Nj' => 'nj',
  60063. '�' => 'ǎ',
  60064. '�' => '�',
  60065. 'Ç‘' => 'Ç’',
  60066. 'Ç“' => 'Ç”',
  60067. 'Ç•' => 'Ç–',
  60068. 'Ǘ' => 'ǘ',
  60069. 'Ç™' => 'Çš',
  60070. 'Ǜ' => 'ǜ',
  60071. 'Çž' => 'ÇŸ',
  60072. 'Ç ' => 'Ç¡',
  60073. 'Ç¢' => 'Ç£',
  60074. 'Ǥ' => 'ǥ',
  60075. 'Ǧ' => 'ǧ',
  60076. 'Ǩ' => 'ǩ',
  60077. 'Ǫ' => 'ǫ',
  60078. 'Ǭ' => 'ǭ',
  60079. 'Ǯ' => 'ǯ',
  60080. 'DZ' => 'dz',
  60081. 'Dz' => 'dz',
  60082. 'Ǵ' => 'ǵ',
  60083. 'Ƕ' => 'ƕ',
  60084. 'Ç·' => 'Æ¿',
  60085. 'Ǹ' => 'ǹ',
  60086. 'Ǻ' => 'ǻ',
  60087. 'Ǽ' => 'ǽ',
  60088. 'Ǿ' => 'ǿ',
  60089. 'Ȁ' => '�',
  60090. 'Ȃ' => 'ȃ',
  60091. 'È„' => 'È…',
  60092. 'Ȇ' => 'ȇ',
  60093. 'Ȉ' => 'ȉ',
  60094. 'ÈŠ' => 'È‹',
  60095. 'Ȍ' => '�',
  60096. 'Ȏ' => '�',
  60097. '�' => 'ȑ',
  60098. 'È’' => 'È“',
  60099. 'È”' => 'È•',
  60100. 'È–' => 'È—',
  60101. 'Ș' => 'ș',
  60102. 'Èš' => 'È›',
  60103. 'Ȝ' => '�',
  60104. 'Èž' => 'ÈŸ',
  60105. 'È ' => 'Æž',
  60106. 'È¢' => 'È£',
  60107. 'Ȥ' => 'ȥ',
  60108. 'Ȧ' => 'ȧ',
  60109. 'Ȩ' => 'ȩ',
  60110. 'Ȫ' => 'ȫ',
  60111. 'Ȭ' => 'ȭ',
  60112. 'Ȯ' => 'ȯ',
  60113. 'Ȱ' => 'ȱ',
  60114. 'Ȳ' => 'ȳ',
  60115. 'Ⱥ' => 'ⱥ',
  60116. 'Ȼ' => 'ȼ',
  60117. 'Ƚ' => 'ƚ',
  60118. 'Ⱦ' => 'ⱦ',
  60119. '�' => 'ɂ',
  60120. 'Ƀ' => 'ƀ',
  60121. 'Ʉ' => 'ʉ',
  60122. 'Ʌ' => 'ʌ',
  60123. 'Ɇ' => 'ɇ',
  60124. 'Ɉ' => 'ɉ',
  60125. 'ÉŠ' => 'É‹',
  60126. 'Ɍ' => '�',
  60127. 'Ɏ' => '�',
  60128. 'Ͱ' => 'ͱ',
  60129. 'Ͳ' => 'ͳ',
  60130. 'Ͷ' => 'ͷ',
  60131. 'Ϳ' => 'ϳ',
  60132. 'Ά' => 'ά',
  60133. 'Έ' => 'έ',
  60134. 'Ή' => 'ή',
  60135. 'Ί' => 'ί',
  60136. 'Ό' => 'ό',
  60137. 'Ύ' => '�',
  60138. '�' => 'ώ',
  60139. 'Α' => 'α',
  60140. 'Β' => 'β',
  60141. 'Γ' => 'γ',
  60142. 'Δ' => 'δ',
  60143. 'Ε' => 'ε',
  60144. 'Ζ' => 'ζ',
  60145. 'Η' => 'η',
  60146. 'Θ' => 'θ',
  60147. 'Ι' => 'ι',
  60148. 'Κ' => 'κ',
  60149. 'Λ' => 'λ',
  60150. 'Μ' => 'μ',
  60151. '�' => 'ν',
  60152. 'Ξ' => 'ξ',
  60153. 'Ο' => 'ο',
  60154. 'Π' => 'π',
  60155. 'Ρ' => '�',
  60156. 'Σ' => 'σ',
  60157. 'Τ' => 'τ',
  60158. 'Î¥' => 'Ï…',
  60159. 'Φ' => 'φ',
  60160. 'Χ' => 'χ',
  60161. 'Ψ' => 'ψ',
  60162. 'Ω' => 'ω',
  60163. 'Ϊ' => 'ϊ',
  60164. 'Ϋ' => 'ϋ',
  60165. '�' => 'ϗ',
  60166. 'Ϙ' => 'ϙ',
  60167. 'Ïš' => 'Ï›',
  60168. 'Ϝ' => '�',
  60169. 'Ïž' => 'ÏŸ',
  60170. 'Ï ' => 'Ï¡',
  60171. 'Ï¢' => 'Ï£',
  60172. 'Ϥ' => 'ϥ',
  60173. 'Ϧ' => 'ϧ',
  60174. 'Ϩ' => 'ϩ',
  60175. 'Ϫ' => 'ϫ',
  60176. 'Ϭ' => 'ϭ',
  60177. 'Ϯ' => 'ϯ',
  60178. 'ϴ' => 'θ',
  60179. 'Ϸ' => 'ϸ',
  60180. 'Ϲ' => 'ϲ',
  60181. 'Ϻ' => 'ϻ',
  60182. 'Ͻ' => 'ͻ',
  60183. 'Ͼ' => 'ͼ',
  60184. 'Ͽ' => 'ͽ',
  60185. 'Ѐ' => '�',
  60186. '�' => 'ё',
  60187. 'Ђ' => 'ђ',
  60188. 'Ѓ' => 'ѓ',
  60189. 'Є' => 'є',
  60190. 'Ð…' => 'Ñ•',
  60191. 'І' => 'і',
  60192. 'Ї' => 'ї',
  60193. 'Ј' => 'ј',
  60194. 'Љ' => 'љ',
  60195. 'Њ' => 'њ',
  60196. 'Ћ' => 'ћ',
  60197. 'Ќ' => 'ќ',
  60198. '�' => '�',
  60199. 'ÐŽ' => 'Ñž',
  60200. '�' => 'џ',
  60201. '�' => 'а',
  60202. 'Б' => 'б',
  60203. 'В' => 'в',
  60204. 'Г' => 'г',
  60205. 'Д' => 'д',
  60206. 'Е' => 'е',
  60207. 'Ж' => 'ж',
  60208. 'З' => 'з',
  60209. 'И' => 'и',
  60210. 'Й' => 'й',
  60211. 'К' => 'к',
  60212. 'Л' => 'л',
  60213. 'М' => 'м',
  60214. '�' => 'н',
  60215. 'О' => 'о',
  60216. 'П' => 'п',
  60217. 'Р' => 'р',
  60218. 'С' => '�',
  60219. 'Т' => 'т',
  60220. 'У' => 'у',
  60221. 'Ф' => 'ф',
  60222. 'Ð¥' => 'Ñ…',
  60223. 'Ц' => 'ц',
  60224. 'Ч' => 'ч',
  60225. 'Ш' => 'ш',
  60226. 'Щ' => 'щ',
  60227. 'Ъ' => 'ъ',
  60228. 'Ы' => 'ы',
  60229. 'Ь' => 'ь',
  60230. 'Э' => '�',
  60231. 'Ю' => 'ю',
  60232. 'Я' => '�',
  60233. 'Ñ ' => 'Ñ¡',
  60234. 'Ñ¢' => 'Ñ£',
  60235. 'Ѥ' => 'ѥ',
  60236. 'Ѧ' => 'ѧ',
  60237. 'Ѩ' => 'ѩ',
  60238. 'Ѫ' => 'ѫ',
  60239. 'Ѭ' => 'ѭ',
  60240. 'Ѯ' => 'ѯ',
  60241. 'Ѱ' => 'ѱ',
  60242. 'Ѳ' => 'ѳ',
  60243. 'Ѵ' => 'ѵ',
  60244. 'Ѷ' => 'ѷ',
  60245. 'Ѹ' => 'ѹ',
  60246. 'Ѻ' => 'ѻ',
  60247. 'Ѽ' => 'ѽ',
  60248. 'Ѿ' => 'ѿ',
  60249. 'Ò€' => 'Ò�',
  60250. 'ÒŠ' => 'Ò‹',
  60251. 'Ҍ' => '�',
  60252. 'ÒŽ' => 'Ò�',
  60253. 'Ò�' => 'Ò‘',
  60254. 'Ò’' => 'Ò“',
  60255. 'Ò”' => 'Ò•',
  60256. 'Ò–' => 'Ò—',
  60257. 'Ò˜' => 'Ò™',
  60258. 'Òš' => 'Ò›',
  60259. 'Ҝ' => '�',
  60260. 'Òž' => 'ÒŸ',
  60261. 'Ò ' => 'Ò¡',
  60262. 'Ò¢' => 'Ò£',
  60263. 'Ò¤' => 'Ò¥',
  60264. 'Ò¦' => 'Ò§',
  60265. 'Ò¨' => 'Ò©',
  60266. 'Òª' => 'Ò«',
  60267. 'Ò¬' => 'Ò­',
  60268. 'Ò®' => 'Ò¯',
  60269. 'Ò°' => 'Ò±',
  60270. 'Ò²' => 'Ò³',
  60271. 'Ò´' => 'Òµ',
  60272. 'Ò¶' => 'Ò·',
  60273. 'Ò¸' => 'Ò¹',
  60274. 'Òº' => 'Ò»',
  60275. 'Ò¼' => 'Ò½',
  60276. 'Ò¾' => 'Ò¿',
  60277. 'Ó€' => 'Ó�',
  60278. 'Ó�' => 'Ó‚',
  60279. 'Óƒ' => 'Ó„',
  60280. 'Ó…' => 'Ó†',
  60281. 'Ó‡' => 'Óˆ',
  60282. 'Ó‰' => 'ÓŠ',
  60283. 'Ӌ' => 'ӌ',
  60284. 'Ó�' => 'ÓŽ',
  60285. 'Ó�' => 'Ó‘',
  60286. 'Ó’' => 'Ó“',
  60287. 'Ó”' => 'Ó•',
  60288. 'Ó–' => 'Ó—',
  60289. 'Ó˜' => 'Ó™',
  60290. 'Óš' => 'Ó›',
  60291. 'Ӝ' => '�',
  60292. 'Óž' => 'ÓŸ',
  60293. 'Ó ' => 'Ó¡',
  60294. 'Ó¢' => 'Ó£',
  60295. 'Ó¤' => 'Ó¥',
  60296. 'Ó¦' => 'Ó§',
  60297. 'Ó¨' => 'Ó©',
  60298. 'Óª' => 'Ó«',
  60299. 'Ó¬' => 'Ó­',
  60300. 'Ó®' => 'Ó¯',
  60301. 'Ó°' => 'Ó±',
  60302. 'Ó²' => 'Ó³',
  60303. 'Ó´' => 'Óµ',
  60304. 'Ó¶' => 'Ó·',
  60305. 'Ó¸' => 'Ó¹',
  60306. 'Óº' => 'Ó»',
  60307. 'Ó¼' => 'Ó½',
  60308. 'Ó¾' => 'Ó¿',
  60309. 'Ô€' => 'Ô�',
  60310. 'Ô‚' => 'Ôƒ',
  60311. 'Ô„' => 'Ô…',
  60312. 'Ô†' => 'Ô‡',
  60313. 'Ôˆ' => 'Ô‰',
  60314. 'ÔŠ' => 'Ô‹',
  60315. 'Ԍ' => '�',
  60316. 'ÔŽ' => 'Ô�',
  60317. 'Ô�' => 'Ô‘',
  60318. 'Ô’' => 'Ô“',
  60319. 'Ô”' => 'Ô•',
  60320. 'Ô–' => 'Ô—',
  60321. 'Ô˜' => 'Ô™',
  60322. 'Ôš' => 'Ô›',
  60323. 'Ԝ' => '�',
  60324. 'Ôž' => 'ÔŸ',
  60325. 'Ô ' => 'Ô¡',
  60326. 'Ô¢' => 'Ô£',
  60327. 'Ô¤' => 'Ô¥',
  60328. 'Ô¦' => 'Ô§',
  60329. 'Ô¨' => 'Ô©',
  60330. 'Ôª' => 'Ô«',
  60331. 'Ô¬' => 'Ô­',
  60332. 'Ô®' => 'Ô¯',
  60333. 'Ô±' => 'Õ¡',
  60334. 'Ô²' => 'Õ¢',
  60335. 'Ô³' => 'Õ£',
  60336. 'Ô´' => 'Õ¤',
  60337. 'Ôµ' => 'Õ¥',
  60338. 'Ô¶' => 'Õ¦',
  60339. 'Ô·' => 'Õ§',
  60340. 'Ô¸' => 'Õ¨',
  60341. 'Ô¹' => 'Õ©',
  60342. 'Ôº' => 'Õª',
  60343. 'Ô»' => 'Õ«',
  60344. 'Ô¼' => 'Õ¬',
  60345. 'Ô½' => 'Õ­',
  60346. 'Ô¾' => 'Õ®',
  60347. 'Ô¿' => 'Õ¯',
  60348. 'Õ€' => 'Õ°',
  60349. 'Õ�' => 'Õ±',
  60350. 'Õ‚' => 'Õ²',
  60351. 'Õƒ' => 'Õ³',
  60352. 'Õ„' => 'Õ´',
  60353. 'Õ…' => 'Õµ',
  60354. 'Õ†' => 'Õ¶',
  60355. 'Õ‡' => 'Õ·',
  60356. 'Õˆ' => 'Õ¸',
  60357. 'Õ‰' => 'Õ¹',
  60358. 'ÕŠ' => 'Õº',
  60359. 'Õ‹' => 'Õ»',
  60360. 'Ռ' => 'ռ',
  60361. 'Õ�' => 'Õ½',
  60362. 'ÕŽ' => 'Õ¾',
  60363. 'Õ�' => 'Õ¿',
  60364. 'Õ�' => 'Ö€',
  60365. 'Õ‘' => 'Ö�',
  60366. 'Õ’' => 'Ö‚',
  60367. 'Õ“' => 'Öƒ',
  60368. 'Õ”' => 'Ö„',
  60369. 'Õ•' => 'Ö…',
  60370. 'Õ–' => 'Ö†',
  60371. 'á‚ ' => 'â´€',
  60372. 'á‚¡' => 'â´�',
  60373. 'á‚¢' => 'â´‚',
  60374. 'á‚£' => 'â´ƒ',
  60375. 'Ⴄ' => 'ⴄ',
  60376. 'á‚¥' => 'â´…',
  60377. 'Ⴆ' => 'ⴆ',
  60378. 'Ⴇ' => 'ⴇ',
  60379. 'Ⴈ' => 'ⴈ',
  60380. 'á‚©' => 'â´‰',
  60381. 'Ⴊ' => 'ⴊ',
  60382. 'á‚«' => 'â´‹',
  60383. 'Ⴌ' => 'ⴌ',
  60384. 'á‚­' => 'â´�',
  60385. 'á‚®' => 'â´Ž',
  60386. 'Ⴏ' => '�',
  60387. 'á‚°' => 'â´�',
  60388. 'Ⴑ' => 'ⴑ',
  60389. 'Ⴒ' => 'ⴒ',
  60390. 'Ⴓ' => 'ⴓ',
  60391. 'á‚´' => 'â´”',
  60392. 'Ⴕ' => 'ⴕ',
  60393. 'Ⴖ' => 'ⴖ',
  60394. 'á‚·' => 'â´—',
  60395. 'Ⴘ' => 'ⴘ',
  60396. 'Ⴙ' => 'ⴙ',
  60397. 'Ⴚ' => 'ⴚ',
  60398. 'á‚»' => 'â´›',
  60399. 'Ⴜ' => 'ⴜ',
  60400. 'Ⴝ' => '�',
  60401. 'Ⴞ' => 'ⴞ',
  60402. 'á‚¿' => 'â´Ÿ',
  60403. 'Ⴠ' => 'ⴠ',
  60404. '�' => 'ⴡ',
  60405. 'Ⴢ' => 'ⴢ',
  60406. 'Ⴣ' => 'ⴣ',
  60407. 'Ⴤ' => 'ⴤ',
  60408. 'Ⴥ' => 'ⴥ',
  60409. 'Ⴧ' => 'ⴧ',
  60410. '�' => 'ⴭ',
  60411. 'Ꭰ' => 'ꭰ',
  60412. 'Ꭱ' => 'ꭱ',
  60413. 'Ꭲ' => 'ꭲ',
  60414. 'Ꭳ' => 'ꭳ',
  60415. 'Ꭴ' => 'ꭴ',
  60416. 'Ꭵ' => 'ꭵ',
  60417. 'Ꭶ' => 'ꭶ',
  60418. 'Ꭷ' => 'ꭷ',
  60419. 'Ꭸ' => 'ꭸ',
  60420. 'Ꭹ' => 'ꭹ',
  60421. 'Ꭺ' => 'ꭺ',
  60422. 'Ꭻ' => 'ꭻ',
  60423. 'Ꭼ' => 'ꭼ',
  60424. 'Ꭽ' => 'ꭽ',
  60425. 'Ꭾ' => 'ꭾ',
  60426. 'Ꭿ' => 'ꭿ',
  60427. 'Ꮀ' => 'ꮀ',
  60428. 'Ꮁ' => '�',
  60429. 'Ꮂ' => 'ꮂ',
  60430. 'Ꮃ' => 'ꮃ',
  60431. 'Ꮄ' => 'ꮄ',
  60432. 'Ꮅ' => 'ꮅ',
  60433. 'Ꮆ' => 'ꮆ',
  60434. 'Ꮇ' => 'ꮇ',
  60435. 'Ꮈ' => 'ꮈ',
  60436. 'Ꮉ' => 'ꮉ',
  60437. 'Ꮊ' => 'ꮊ',
  60438. 'Ꮋ' => 'ꮋ',
  60439. 'Ꮌ' => 'ꮌ',
  60440. 'Ꮍ' => '�',
  60441. 'Ꮎ' => 'ꮎ',
  60442. 'Ꮏ' => '�',
  60443. '�' => '�',
  60444. '�' => 'ꮑ',
  60445. '�' => 'ꮒ',
  60446. '�' => 'ꮓ',
  60447. '�' => 'ꮔ',
  60448. '�' => 'ꮕ',
  60449. '�' => 'ꮖ',
  60450. '�' => 'ꮗ',
  60451. '�' => 'ꮘ',
  60452. '�' => 'ꮙ',
  60453. '�' => 'ꮚ',
  60454. '�' => 'ꮛ',
  60455. '�' => 'ꮜ',
  60456. '�' => '�',
  60457. '�' => 'ꮞ',
  60458. '�' => 'ꮟ',
  60459. '�' => 'ꮠ',
  60460. '�' => 'ꮡ',
  60461. '�' => 'ꮢ',
  60462. '�' => 'ꮣ',
  60463. '�' => 'ꮤ',
  60464. '�' => 'ꮥ',
  60465. '�' => 'ꮦ',
  60466. '�' => 'ꮧ',
  60467. '�' => 'ꮨ',
  60468. '�' => 'ꮩ',
  60469. '�' => 'ꮪ',
  60470. '�' => 'ꮫ',
  60471. '�' => 'ꮬ',
  60472. '�' => 'ꮭ',
  60473. '�' => 'ꮮ',
  60474. '�' => 'ꮯ',
  60475. '�' => 'ꮰ',
  60476. '�' => 'ꮱ',
  60477. '�' => 'ꮲ',
  60478. '�' => 'ꮳ',
  60479. '�' => 'ꮴ',
  60480. '�' => 'ꮵ',
  60481. '�' => 'ꮶ',
  60482. '�' => 'ꮷ',
  60483. '�' => 'ꮸ',
  60484. '�' => 'ꮹ',
  60485. '�' => 'ꮺ',
  60486. '�' => 'ꮻ',
  60487. '�' => 'ꮼ',
  60488. '�' => 'ꮽ',
  60489. '�' => 'ꮾ',
  60490. '�' => 'ꮿ',
  60491. '�' => '�',
  60492. '�' => '�',
  60493. '�' => '�',
  60494. '�' => '�',
  60495. '�' => '�',
  60496. '�' => '�',
  60497. '�' => '�',
  60498. 'Ბ' => 'ბ',
  60499. 'Გ' => 'გ',
  60500. 'Დ' => 'დ',
  60501. 'Ე' => 'ე',
  60502. 'Ვ' => 'ვ',
  60503. 'Ზ' => 'ზ',
  60504. 'Თ' => 'თ',
  60505. 'Ი' => 'ი',
  60506. 'Კ' => 'კ',
  60507. 'Ლ' => 'ლ',
  60508. 'Მ' => 'მ',
  60509. 'Ნ' => 'ნ',
  60510. '�' => '�',
  60511. 'Პ' => 'პ',
  60512. 'Ჟ' => 'ჟ',
  60513. 'Რ' => 'რ',
  60514. 'Ს' => 'ს',
  60515. 'Ტ' => 'ტ',
  60516. 'Უ' => 'უ',
  60517. 'Ფ' => 'ფ',
  60518. 'Ქ' => 'ქ',
  60519. 'Ღ' => 'ღ',
  60520. 'Ყ' => 'ყ',
  60521. 'Შ' => 'შ',
  60522. 'Ჩ' => 'ჩ',
  60523. 'Ც' => 'ც',
  60524. 'Ძ' => 'ძ',
  60525. 'Წ' => 'წ',
  60526. 'Ჭ' => 'ჭ',
  60527. 'Ხ' => 'ხ',
  60528. 'Ჯ' => 'ჯ',
  60529. 'Ჰ' => 'ჰ',
  60530. 'Ჱ' => 'ჱ',
  60531. 'Ჲ' => 'ჲ',
  60532. 'Ჳ' => 'ჳ',
  60533. 'Ჴ' => 'ჴ',
  60534. 'Ჵ' => 'ჵ',
  60535. 'Ჶ' => 'ჶ',
  60536. 'Ჷ' => 'ჷ',
  60537. 'Ჸ' => 'ჸ',
  60538. 'Ჹ' => 'ჹ',
  60539. 'Ჺ' => 'ჺ',
  60540. 'Ჽ' => 'ჽ',
  60541. 'Ჾ' => 'ჾ',
  60542. 'Ჿ' => 'ჿ',
  60543. 'Ḁ' => '�',
  60544. 'Ḃ' => 'ḃ',
  60545. 'Ḅ' => 'ḅ',
  60546. 'Ḇ' => 'ḇ',
  60547. 'Ḉ' => 'ḉ',
  60548. 'Ḋ' => 'ḋ',
  60549. 'Ḍ' => '�',
  60550. 'Ḏ' => '�',
  60551. '�' => 'ḑ',
  60552. 'Ḓ' => 'ḓ',
  60553. 'Ḕ' => 'ḕ',
  60554. 'Ḗ' => 'ḗ',
  60555. 'Ḙ' => 'ḙ',
  60556. 'Ḛ' => 'ḛ',
  60557. 'Ḝ' => '�',
  60558. 'Ḟ' => 'ḟ',
  60559. 'Ḡ' => 'ḡ',
  60560. 'Ḣ' => 'ḣ',
  60561. 'Ḥ' => 'ḥ',
  60562. 'Ḧ' => 'ḧ',
  60563. 'Ḩ' => 'ḩ',
  60564. 'Ḫ' => 'ḫ',
  60565. 'Ḭ' => 'ḭ',
  60566. 'Ḯ' => 'ḯ',
  60567. 'Ḱ' => 'ḱ',
  60568. 'Ḳ' => 'ḳ',
  60569. 'Ḵ' => 'ḵ',
  60570. 'Ḷ' => 'ḷ',
  60571. 'Ḹ' => 'ḹ',
  60572. 'Ḻ' => 'ḻ',
  60573. 'Ḽ' => 'ḽ',
  60574. 'Ḿ' => 'ḿ',
  60575. 'Ṁ' => '�',
  60576. 'Ṃ' => 'ṃ',
  60577. 'Ṅ' => 'ṅ',
  60578. 'Ṇ' => 'ṇ',
  60579. 'Ṉ' => 'ṉ',
  60580. 'Ṋ' => 'ṋ',
  60581. 'Ṍ' => '�',
  60582. 'Ṏ' => '�',
  60583. '�' => 'ṑ',
  60584. 'Ṓ' => 'ṓ',
  60585. 'Ṕ' => 'ṕ',
  60586. 'á¹–' => 'á¹—',
  60587. 'Ṙ' => 'ṙ',
  60588. 'Ṛ' => 'ṛ',
  60589. 'Ṝ' => '�',
  60590. 'Ṟ' => 'ṟ',
  60591. 'Ṡ' => 'ṡ',
  60592. 'á¹¢' => 'á¹£',
  60593. 'Ṥ' => 'ṥ',
  60594. 'Ṧ' => 'ṧ',
  60595. 'Ṩ' => 'ṩ',
  60596. 'Ṫ' => 'ṫ',
  60597. 'Ṭ' => 'ṭ',
  60598. 'Ṯ' => 'ṯ',
  60599. 'á¹°' => 'á¹±',
  60600. 'á¹²' => 'á¹³',
  60601. 'á¹´' => 'á¹µ',
  60602. 'Ṷ' => 'ṷ',
  60603. 'Ṹ' => 'ṹ',
  60604. 'Ṻ' => 'ṻ',
  60605. 'á¹¼' => 'á¹½',
  60606. 'Ṿ' => 'ṿ',
  60607. 'Ẁ' => '�',
  60608. 'Ẃ' => 'ẃ',
  60609. 'Ẅ' => 'ẅ',
  60610. 'Ẇ' => 'ẇ',
  60611. 'Ẉ' => 'ẉ',
  60612. 'Ẋ' => 'ẋ',
  60613. 'Ẍ' => '�',
  60614. 'Ẏ' => '�',
  60615. '�' => 'ẑ',
  60616. 'Ẓ' => 'ẓ',
  60617. 'Ẕ' => 'ẕ',
  60618. 'ẞ' => 'ß',
  60619. 'Ạ' => 'ạ',
  60620. 'Ả' => 'ả',
  60621. 'Ấ' => 'ấ',
  60622. 'Ầ' => 'ầ',
  60623. 'Ẩ' => 'ẩ',
  60624. 'Ẫ' => 'ẫ',
  60625. 'Ậ' => 'ậ',
  60626. 'Ắ' => 'ắ',
  60627. 'Ằ' => 'ằ',
  60628. 'Ẳ' => 'ẳ',
  60629. 'Ẵ' => 'ẵ',
  60630. 'Ặ' => 'ặ',
  60631. 'Ẹ' => 'ẹ',
  60632. 'Ẻ' => 'ẻ',
  60633. 'Ẽ' => 'ẽ',
  60634. 'Ế' => 'ế',
  60635. 'Ề' => '�',
  60636. 'Ể' => 'ể',
  60637. 'Ễ' => 'ễ',
  60638. 'Ệ' => 'ệ',
  60639. 'Ỉ' => 'ỉ',
  60640. 'Ị' => 'ị',
  60641. 'Ọ' => '�',
  60642. 'Ỏ' => '�',
  60643. '�' => 'ố',
  60644. 'Ồ' => 'ồ',
  60645. 'Ổ' => 'ổ',
  60646. 'á»–' => 'á»—',
  60647. 'Ộ' => 'ộ',
  60648. 'Ớ' => 'ớ',
  60649. 'Ờ' => '�',
  60650. 'Ở' => 'ở',
  60651. 'Ỡ' => 'ỡ',
  60652. 'Ợ' => 'ợ',
  60653. 'Ụ' => 'ụ',
  60654. 'Ủ' => 'ủ',
  60655. 'Ứ' => 'ứ',
  60656. 'Ừ' => 'ừ',
  60657. 'Ử' => 'ử',
  60658. 'Ữ' => 'ữ',
  60659. 'á»°' => 'á»±',
  60660. 'Ỳ' => 'ỳ',
  60661. 'Ỵ' => 'ỵ',
  60662. 'Ỷ' => 'ỷ',
  60663. 'Ỹ' => 'ỹ',
  60664. 'Ỻ' => 'ỻ',
  60665. 'Ỽ' => 'ỽ',
  60666. 'Ỿ' => 'ỿ',
  60667. 'Ἀ' => 'ἀ',
  60668. 'Ἁ' => '�',
  60669. 'Ἂ' => 'ἂ',
  60670. 'Ἃ' => 'ἃ',
  60671. 'Ἄ' => 'ἄ',
  60672. '�' => 'ἅ',
  60673. 'Ἆ' => 'ἆ',
  60674. '�' => 'ἇ',
  60675. 'Ἐ' => '�',
  60676. 'Ἑ' => 'ἑ',
  60677. 'Ἒ' => 'ἒ',
  60678. 'Ἓ' => 'ἓ',
  60679. 'Ἔ' => 'ἔ',
  60680. '�' => 'ἕ',
  60681. 'Ἠ' => 'ἠ',
  60682. 'Ἡ' => 'ἡ',
  60683. 'Ἢ' => 'ἢ',
  60684. 'Ἣ' => 'ἣ',
  60685. 'Ἤ' => 'ἤ',
  60686. 'á¼­' => 'á¼¥',
  60687. 'Ἦ' => 'ἦ',
  60688. 'Ἧ' => 'ἧ',
  60689. 'Ἰ' => 'ἰ',
  60690. 'á¼¹' => 'á¼±',
  60691. 'Ἲ' => 'ἲ',
  60692. 'á¼»' => 'á¼³',
  60693. 'á¼¼' => 'á¼´',
  60694. 'á¼½' => 'á¼µ',
  60695. 'Ἶ' => 'ἶ',
  60696. 'Ἷ' => 'ἷ',
  60697. 'Ὀ' => 'ὀ',
  60698. 'Ὁ' => '�',
  60699. 'Ὂ' => 'ὂ',
  60700. 'Ὃ' => 'ὃ',
  60701. 'Ὄ' => 'ὄ',
  60702. '�' => 'ὅ',
  60703. 'Ὑ' => 'ὑ',
  60704. 'Ὓ' => 'ὓ',
  60705. '�' => 'ὕ',
  60706. 'Ὗ' => 'ὗ',
  60707. 'Ὠ' => 'ὠ',
  60708. 'Ὡ' => 'ὡ',
  60709. 'Ὢ' => 'ὢ',
  60710. 'Ὣ' => 'ὣ',
  60711. 'Ὤ' => 'ὤ',
  60712. 'á½­' => 'á½¥',
  60713. 'Ὦ' => 'ὦ',
  60714. 'Ὧ' => 'ὧ',
  60715. 'ᾈ' => 'ᾀ',
  60716. 'ᾉ' => '�',
  60717. 'ᾊ' => 'ᾂ',
  60718. 'ᾋ' => 'ᾃ',
  60719. 'ᾌ' => 'ᾄ',
  60720. '�' => 'ᾅ',
  60721. 'ᾎ' => 'ᾆ',
  60722. '�' => 'ᾇ',
  60723. 'ᾘ' => '�',
  60724. 'ᾙ' => 'ᾑ',
  60725. 'ᾚ' => 'ᾒ',
  60726. 'ᾛ' => 'ᾓ',
  60727. 'ᾜ' => 'ᾔ',
  60728. '�' => 'ᾕ',
  60729. 'ᾞ' => 'ᾖ',
  60730. 'ᾟ' => 'ᾗ',
  60731. 'ᾨ' => 'ᾠ',
  60732. 'ᾩ' => 'ᾡ',
  60733. 'ᾪ' => 'ᾢ',
  60734. 'ᾫ' => 'ᾣ',
  60735. 'ᾬ' => 'ᾤ',
  60736. 'á¾­' => 'á¾¥',
  60737. 'ᾮ' => 'ᾦ',
  60738. 'ᾯ' => 'ᾧ',
  60739. 'Ᾰ' => 'ᾰ',
  60740. 'á¾¹' => 'á¾±',
  60741. 'Ὰ' => 'ὰ',
  60742. 'á¾»' => 'á½±',
  60743. 'á¾¼' => 'á¾³',
  60744. 'Ὲ' => 'ὲ',
  60745. 'Έ' => 'έ',
  60746. 'á¿Š' => 'á½´',
  60747. 'á¿‹' => 'á½µ',
  60748. 'ῌ' => 'ῃ',
  60749. 'Ῐ' => '�',
  60750. 'á¿™' => 'á¿‘',
  60751. 'Ὶ' => 'ὶ',
  60752. 'á¿›' => 'á½·',
  60753. 'Ῠ' => 'ῠ',
  60754. 'á¿©' => 'á¿¡',
  60755. 'Ὺ' => 'ὺ',
  60756. 'á¿«' => 'á½»',
  60757. 'Ῥ' => 'ῥ',
  60758. 'Ὸ' => 'ὸ',
  60759. 'Ό' => 'ό',
  60760. 'Ὼ' => 'ὼ',
  60761. 'á¿»' => 'á½½',
  60762. 'ῼ' => 'ῳ',
  60763. 'Ω' => 'ω',
  60764. 'K' => 'k',
  60765. 'â„«' => 'Ã¥',
  60766. 'Ⅎ' => 'ⅎ',
  60767. 'â… ' => 'â…°',
  60768. 'â…¡' => 'â…±',
  60769. 'â…¢' => 'â…²',
  60770. 'â…£' => 'â…³',
  60771. 'â…¤' => 'â…´',
  60772. 'â…¥' => 'â…µ',
  60773. 'â…¦' => 'â…¶',
  60774. 'â…§' => 'â…·',
  60775. 'â…¨' => 'â…¸',
  60776. 'â…©' => 'â…¹',
  60777. 'â…ª' => 'â…º',
  60778. 'â…«' => 'â…»',
  60779. 'â…¬' => 'â…¼',
  60780. 'â…­' => 'â…½',
  60781. 'â…®' => 'â…¾',
  60782. 'â…¯' => 'â…¿',
  60783. 'Ↄ' => 'ↄ',
  60784. 'Ⓐ' => '�',
  60785. 'â’·' => 'â“‘',
  60786. 'â’¸' => 'â“’',
  60787. 'â’¹' => 'â““',
  60788. 'â’º' => 'â“”',
  60789. 'â’»' => 'â“•',
  60790. 'â’¼' => 'â“–',
  60791. 'â’½' => 'â“—',
  60792. 'Ⓘ' => 'ⓘ',
  60793. 'â’¿' => 'â“™',
  60794. 'â“€' => 'â“š',
  60795. '�' => 'ⓛ',
  60796. 'Ⓜ' => 'ⓜ',
  60797. 'Ⓝ' => '�',
  60798. 'â“„' => 'â“ž',
  60799. 'â“…' => 'â“Ÿ',
  60800. 'Ⓠ' => 'ⓠ',
  60801. 'Ⓡ' => 'ⓡ',
  60802. 'Ⓢ' => 'ⓢ',
  60803. 'Ⓣ' => 'ⓣ',
  60804. 'Ⓤ' => 'ⓤ',
  60805. 'â“‹' => 'â“¥',
  60806. 'Ⓦ' => 'ⓦ',
  60807. '�' => 'ⓧ',
  60808. 'Ⓨ' => 'ⓨ',
  60809. '�' => 'ⓩ',
  60810. 'â°€' => 'â°°',
  60811. 'â°�' => 'â°±',
  60812. 'â°‚' => 'â°²',
  60813. 'â°ƒ' => 'â°³',
  60814. 'â°„' => 'â°´',
  60815. 'â°…' => 'â°µ',
  60816. 'â°†' => 'â°¶',
  60817. 'â°‡' => 'â°·',
  60818. 'â°ˆ' => 'â°¸',
  60819. 'â°‰' => 'â°¹',
  60820. 'â°Š' => 'â°º',
  60821. 'â°‹' => 'â°»',
  60822. 'Ⰼ' => 'ⰼ',
  60823. 'â°�' => 'â°½',
  60824. 'â°Ž' => 'â°¾',
  60825. 'â°�' => 'â°¿',
  60826. 'â°�' => 'â±€',
  60827. 'Ⱁ' => '�',
  60828. 'Ⱂ' => 'ⱂ',
  60829. 'Ⱃ' => 'ⱃ',
  60830. 'Ⱄ' => 'ⱄ',
  60831. 'â°•' => 'â±…',
  60832. 'Ⱆ' => 'ⱆ',
  60833. 'Ⱇ' => 'ⱇ',
  60834. 'Ⱈ' => 'ⱈ',
  60835. 'Ⱉ' => 'ⱉ',
  60836. 'Ⱊ' => 'ⱊ',
  60837. 'Ⱋ' => 'ⱋ',
  60838. 'Ⱌ' => 'ⱌ',
  60839. '�' => '�',
  60840. 'Ⱎ' => 'ⱎ',
  60841. 'Ⱏ' => '�',
  60842. 'Ⱐ' => '�',
  60843. 'Ⱑ' => 'ⱑ',
  60844. 'â°¢' => 'â±’',
  60845. 'Ⱓ' => 'ⱓ',
  60846. 'â°¤' => 'â±”',
  60847. 'Ⱕ' => 'ⱕ',
  60848. 'â°¦' => 'â±–',
  60849. 'â°§' => 'â±—',
  60850. 'Ⱘ' => 'ⱘ',
  60851. 'â°©' => 'â±™',
  60852. 'Ⱚ' => 'ⱚ',
  60853. 'â°«' => 'â±›',
  60854. 'Ⱜ' => 'ⱜ',
  60855. 'Ⱝ' => '�',
  60856. 'Ⱞ' => 'ⱞ',
  60857. 'Ⱡ' => 'ⱡ',
  60858. 'â±¢' => 'É«',
  60859. 'â±£' => 'áµ½',
  60860. 'Ɽ' => 'ɽ',
  60861. 'Ⱨ' => 'ⱨ',
  60862. 'Ⱪ' => 'ⱪ',
  60863. 'Ⱬ' => 'ⱬ',
  60864. 'â±­' => 'É‘',
  60865. 'Ɱ' => 'ɱ',
  60866. 'Ɐ' => '�',
  60867. 'â±°' => 'É’',
  60868. 'â±²' => 'â±³',
  60869. 'Ⱶ' => 'ⱶ',
  60870. 'â±¾' => 'È¿',
  60871. 'Ɀ' => 'ɀ',
  60872. 'Ⲁ' => '�',
  60873. 'Ⲃ' => 'ⲃ',
  60874. 'Ⲅ' => 'ⲅ',
  60875. 'Ⲇ' => 'ⲇ',
  60876. 'Ⲉ' => 'ⲉ',
  60877. 'Ⲋ' => 'ⲋ',
  60878. 'Ⲍ' => '�',
  60879. 'Ⲏ' => '�',
  60880. '�' => 'ⲑ',
  60881. 'Ⲓ' => 'ⲓ',
  60882. 'Ⲕ' => 'ⲕ',
  60883. 'â²–' => 'â²—',
  60884. 'Ⲙ' => 'ⲙ',
  60885. 'Ⲛ' => 'ⲛ',
  60886. 'Ⲝ' => '�',
  60887. 'Ⲟ' => 'ⲟ',
  60888. 'Ⲡ' => 'ⲡ',
  60889. 'â²¢' => 'â²£',
  60890. 'Ⲥ' => 'ⲥ',
  60891. 'Ⲧ' => 'ⲧ',
  60892. 'Ⲩ' => 'ⲩ',
  60893. 'Ⲫ' => 'ⲫ',
  60894. 'Ⲭ' => 'ⲭ',
  60895. 'Ⲯ' => 'ⲯ',
  60896. 'â²°' => 'â²±',
  60897. 'â²²' => 'â²³',
  60898. 'â²´' => 'â²µ',
  60899. 'Ⲷ' => 'ⲷ',
  60900. 'Ⲹ' => 'ⲹ',
  60901. 'Ⲻ' => 'ⲻ',
  60902. 'â²¼' => 'â²½',
  60903. 'Ⲿ' => 'ⲿ',
  60904. 'Ⳁ' => '�',
  60905. 'Ⳃ' => 'ⳃ',
  60906. 'Ⳅ' => 'ⳅ',
  60907. 'Ⳇ' => 'ⳇ',
  60908. 'Ⳉ' => 'ⳉ',
  60909. 'Ⳋ' => 'ⳋ',
  60910. 'Ⳍ' => '�',
  60911. 'Ⳏ' => '�',
  60912. '�' => 'ⳑ',
  60913. 'Ⳓ' => 'ⳓ',
  60914. 'Ⳕ' => 'ⳕ',
  60915. 'â³–' => 'â³—',
  60916. 'Ⳙ' => 'ⳙ',
  60917. 'Ⳛ' => 'ⳛ',
  60918. 'Ⳝ' => '�',
  60919. 'Ⳟ' => 'ⳟ',
  60920. 'Ⳡ' => 'ⳡ',
  60921. 'â³¢' => 'â³£',
  60922. 'Ⳬ' => 'ⳬ',
  60923. 'â³­' => 'â³®',
  60924. 'â³²' => 'â³³',
  60925. 'Ꙁ' => '�',
  60926. 'Ꙃ' => 'ꙃ',
  60927. 'Ꙅ' => 'ꙅ',
  60928. 'Ꙇ' => 'ꙇ',
  60929. 'Ꙉ' => 'ꙉ',
  60930. 'Ꙋ' => 'ꙋ',
  60931. 'Ꙍ' => '�',
  60932. 'Ꙏ' => '�',
  60933. '�' => 'ꙑ',
  60934. 'Ꙓ' => 'ꙓ',
  60935. 'Ꙕ' => 'ꙕ',
  60936. 'ê™–' => 'ê™—',
  60937. 'Ꙙ' => 'ꙙ',
  60938. 'Ꙛ' => 'ꙛ',
  60939. 'Ꙝ' => '�',
  60940. 'Ꙟ' => 'ꙟ',
  60941. 'Ꙡ' => 'ꙡ',
  60942. 'Ꙣ' => 'ꙣ',
  60943. 'Ꙥ' => 'ꙥ',
  60944. 'Ꙧ' => 'ꙧ',
  60945. 'Ꙩ' => 'ꙩ',
  60946. 'Ꙫ' => 'ꙫ',
  60947. 'Ꙭ' => 'ꙭ',
  60948. 'Ꚁ' => '�',
  60949. 'Ꚃ' => 'ꚃ',
  60950. 'êš„' => 'êš…',
  60951. 'Ꚇ' => 'ꚇ',
  60952. 'Ꚉ' => 'ꚉ',
  60953. 'Ꚋ' => 'ꚋ',
  60954. 'Ꚍ' => '�',
  60955. 'Ꚏ' => '�',
  60956. '�' => 'ꚑ',
  60957. 'êš’' => 'êš“',
  60958. 'êš”' => 'êš•',
  60959. 'êš–' => 'êš—',
  60960. 'Ꚙ' => 'ꚙ',
  60961. 'êšš' => 'êš›',
  60962. 'Ꜣ' => 'ꜣ',
  60963. 'Ꜥ' => 'ꜥ',
  60964. 'Ꜧ' => 'ꜧ',
  60965. 'Ꜩ' => 'ꜩ',
  60966. 'Ꜫ' => 'ꜫ',
  60967. 'Ꜭ' => 'ꜭ',
  60968. 'Ꜯ' => 'ꜯ',
  60969. 'Ꜳ' => 'ꜳ',
  60970. 'Ꜵ' => 'ꜵ',
  60971. 'Ꜷ' => 'ꜷ',
  60972. 'Ꜹ' => 'ꜹ',
  60973. 'Ꜻ' => 'ꜻ',
  60974. 'Ꜽ' => 'ꜽ',
  60975. 'Ꜿ' => 'ꜿ',
  60976. '�' => '�',
  60977. '�' => '�',
  60978. '�' => '�',
  60979. '�' => '�',
  60980. '�' => '�',
  60981. '�' => '�',
  60982. '�' => '�',
  60983. '�' => '�',
  60984. '�' => '�',
  60985. '�' => '�',
  60986. '�' => '�',
  60987. '�' => '�',
  60988. '�' => '�',
  60989. '�' => '�',
  60990. '�' => '�',
  60991. '�' => '�',
  60992. '�' => '�',
  60993. '�' => '�',
  60994. '�' => '�',
  60995. '�' => '�',
  60996. '�' => '�',
  60997. '�' => '�',
  60998. '�' => '�',
  60999. '�' => '�',
  61000. '�' => '�',
  61001. '�' => '�',
  61002. '�' => 'ᵹ',
  61003. '�' => '�',
  61004. 'Ꞁ' => '�',
  61005. 'Ꞃ' => 'ꞃ',
  61006. 'êž„' => 'êž…',
  61007. 'Ꞇ' => 'ꞇ',
  61008. 'Ꞌ' => 'ꞌ',
  61009. '�' => 'ɥ',
  61010. '�' => 'ꞑ',
  61011. 'êž’' => 'êž“',
  61012. 'êž–' => 'êž—',
  61013. 'Ꞙ' => 'ꞙ',
  61014. 'êžš' => 'êž›',
  61015. 'Ꞝ' => '�',
  61016. 'Ꞟ' => 'ꞟ',
  61017. 'êž ' => 'êž¡',
  61018. 'Ꞣ' => 'ꞣ',
  61019. 'Ꞥ' => 'ꞥ',
  61020. 'Ꞧ' => 'ꞧ',
  61021. 'Ꞩ' => 'ꞩ',
  61022. 'Ɦ' => 'ɦ',
  61023. 'Ɜ' => 'ɜ',
  61024. 'Ɡ' => 'ɡ',
  61025. 'Ɬ' => 'ɬ',
  61026. 'Ɪ' => 'ɪ',
  61027. 'êž°' => 'Êž',
  61028. 'Ʇ' => 'ʇ',
  61029. 'Ʝ' => '�',
  61030. 'êž³' => 'ê­“',
  61031. 'êž´' => 'êžµ',
  61032. 'Ꞷ' => 'ꞷ',
  61033. 'Ꞹ' => 'ꞹ',
  61034. 'Ꞻ' => 'ꞻ',
  61035. 'êž¼' => 'êž½',
  61036. 'êž¾' => 'êž¿',
  61037. 'Ꟃ' => 'ꟃ',
  61038. 'Ꞔ' => 'ꞔ',
  61039. 'Ʂ' => 'ʂ',
  61040. 'Ᶎ' => 'ᶎ',
  61041. 'Ꟈ' => 'ꟈ',
  61042. 'Ꟊ' => 'ꟊ',
  61043. 'Ꟶ' => 'ꟶ',
  61044. 'A' => '�',
  61045. 'B' => 'b',
  61046. 'C' => 'c',
  61047. 'D' => 'd',
  61048. 'ï¼¥' => 'ï½…',
  61049. 'F' => 'f',
  61050. 'G' => 'g',
  61051. 'H' => 'h',
  61052. 'I' => 'i',
  61053. 'J' => 'j',
  61054. 'K' => 'k',
  61055. 'L' => 'l',
  61056. 'M' => '�',
  61057. 'N' => 'n',
  61058. 'O' => '�',
  61059. 'P' => '�',
  61060. 'Q' => 'q',
  61061. 'ï¼²' => 'ï½’',
  61062. 'S' => 's',
  61063. 'ï¼´' => 'ï½”',
  61064. 'U' => 'u',
  61065. 'V' => 'v',
  61066. 'ï¼·' => 'ï½—',
  61067. 'X' => 'x',
  61068. 'ï¼¹' => 'ï½™',
  61069. 'Z' => 'z',
  61070. '�' => '�',
  61071. '�' => '�',
  61072. '�' => '�',
  61073. '�' => '�',
  61074. '�' => '�',
  61075. '�' => '�',
  61076. '�' => '�',
  61077. '�' => '�',
  61078. '�' => '�',
  61079. '�' => '�',
  61080. '�' => '�',
  61081. '�' => '�',
  61082. '�' => '�',
  61083. '�' => '�',
  61084. '�' => '�',
  61085. '�' => '�',
  61086. '�' => '�',
  61087. '�' => '�',
  61088. '�' => '�',
  61089. '�' => '�',
  61090. '�' => '�',
  61091. '�' => '�',
  61092. '�' => '�',
  61093. '�' => '�',
  61094. '�' => '�',
  61095. '�' => '�',
  61096. '�' => '�',
  61097. '�' => '�',
  61098. '�' => '�',
  61099. '�' => '�',
  61100. '�' => '�',
  61101. '�' => '�',
  61102. '�' => '�',
  61103. '�' => '�',
  61104. '�' => '�',
  61105. '�' => '�',
  61106. '�' => '�',
  61107. '�' => '�',
  61108. '�' => '�',
  61109. '�' => '�',
  61110. '�' => '�',
  61111. '�' => '�',
  61112. '�' => '�',
  61113. '�' => '�',
  61114. '�' => '�',
  61115. '�' => '�',
  61116. '�' => '�',
  61117. '�' => '�',
  61118. '�' => '�',
  61119. '�' => '�',
  61120. '�' => '�',
  61121. '�' => '�',
  61122. '�' => '�',
  61123. '�' => '�',
  61124. '�' => '�',
  61125. '�' => '�',
  61126. '�' => '�',
  61127. '�' => '�',
  61128. '�' => '�',
  61129. '�' => '�',
  61130. '�' => '�',
  61131. '�' => '�',
  61132. '�' => '�',
  61133. '�' => '�',
  61134. '�' => '�',
  61135. '�' => '�',
  61136. '�' => '�',
  61137. '�' => '�',
  61138. '�' => '�',
  61139. '�' => '�',
  61140. '�' => '�',
  61141. '�' => '�',
  61142. '�' => '�',
  61143. '�' => '�',
  61144. '�' => '�',
  61145. '�' => '�',
  61146. '�' => '�',
  61147. '�' => '�',
  61148. '�' => '�',
  61149. '�' => '�',
  61150. '�' => '�',
  61151. '�' => '�',
  61152. '�' => '�',
  61153. '�' => '�',
  61154. '�' => '�',
  61155. '�' => '�',
  61156. '�' => '�',
  61157. '�' => '�',
  61158. '�' => '�',
  61159. '�' => '�',
  61160. '�' => '�',
  61161. '�' => '�',
  61162. '�' => '�',
  61163. '�' => '�',
  61164. '�' => '�',
  61165. '�' => '�',
  61166. '�' => '�',
  61167. '�' => '�',
  61168. '�' => '�',
  61169. '�' => '�',
  61170. '�' => '�',
  61171. '�' => '�',
  61172. '�' => '�',
  61173. '�' => '�',
  61174. '�' => '�',
  61175. '�' => '�',
  61176. '�' => '�',
  61177. '�' => '�',
  61178. '�' => '�',
  61179. '�' => '�',
  61180. '�' => '�',
  61181. '�' => '�',
  61182. '�' => '�',
  61183. '�' => '�',
  61184. '�' => '�',
  61185. '�' => '�',
  61186. '�' => '�',
  61187. '�' => '�',
  61188. '�' => '�',
  61189. '�' => '�',
  61190. '�' => '�',
  61191. '�' => '�',
  61192. '�' => '�',
  61193. '�' => '�',
  61194. '�' => '�',
  61195. '�' => '�',
  61196. '�' => '�',
  61197. 'ð‘¢ ' => 'ð‘£€',
  61198. '𑢡' => '�',
  61199. '𑢢' => '𑣂',
  61200. '𑢣' => '𑣃',
  61201. '𑢤' => '𑣄',
  61202. 'ð‘¢¥' => 'ð‘£…',
  61203. '𑢦' => '𑣆',
  61204. '𑢧' => '𑣇',
  61205. '𑢨' => '𑣈',
  61206. '𑢩' => '𑣉',
  61207. '𑢪' => '𑣊',
  61208. '𑢫' => '𑣋',
  61209. '𑢬' => '𑣌',
  61210. '𑢭' => '�',
  61211. '𑢮' => '𑣎',
  61212. '𑢯' => '�',
  61213. '𑢰' => '�',
  61214. '𑢱' => '𑣑',
  61215. 'ð‘¢²' => 'ð‘£’',
  61216. '𑢳' => '𑣓',
  61217. 'ð‘¢´' => 'ð‘£”',
  61218. '𑢵' => '𑣕',
  61219. '𑢶' => '𑣖',
  61220. 'ð‘¢·' => 'ð‘£—',
  61221. '𑢸' => '𑣘',
  61222. 'ð‘¢¹' => 'ð‘£™',
  61223. '𑢺' => '𑣚',
  61224. 'ð‘¢»' => 'ð‘£›',
  61225. '𑢼' => '𑣜',
  61226. '𑢽' => '�',
  61227. '𑢾' => '𑣞',
  61228. '𑢿' => '𑣟',
  61229. 'ð–¹€' => 'ð–¹ ',
  61230. '�' => '𖹡',
  61231. '𖹂' => '𖹢',
  61232. '𖹃' => '𖹣',
  61233. '𖹄' => '𖹤',
  61234. 'ð–¹…' => 'ð–¹¥',
  61235. '𖹆' => '𖹦',
  61236. '𖹇' => '𖹧',
  61237. '𖹈' => '𖹨',
  61238. '𖹉' => '𖹩',
  61239. '𖹊' => '𖹪',
  61240. '𖹋' => '𖹫',
  61241. '𖹌' => '𖹬',
  61242. '�' => '𖹭',
  61243. '𖹎' => '𖹮',
  61244. '�' => '𖹯',
  61245. '�' => '𖹰',
  61246. '𖹑' => '𖹱',
  61247. 'ð–¹’' => 'ð–¹²',
  61248. '𖹓' => '𖹳',
  61249. 'ð–¹”' => 'ð–¹´',
  61250. '𖹕' => '𖹵',
  61251. '𖹖' => '𖹶',
  61252. 'ð–¹—' => 'ð–¹·',
  61253. '𖹘' => '𖹸',
  61254. 'ð–¹™' => 'ð–¹¹',
  61255. '𖹚' => '𖹺',
  61256. 'ð–¹›' => 'ð–¹»',
  61257. '𖹜' => '𖹼',
  61258. '�' => '𖹽',
  61259. '𖹞' => '𖹾',
  61260. '𖹟' => '𖹿',
  61261. '𞤀' => '𞤢',
  61262. '�' => '𞤣',
  61263. '𞤂' => '𞤤',
  61264. '𞤃' => '𞤥',
  61265. '𞤄' => '𞤦',
  61266. '𞤅' => '𞤧',
  61267. '𞤆' => '𞤨',
  61268. '𞤇' => '𞤩',
  61269. '𞤈' => '𞤪',
  61270. '𞤉' => '𞤫',
  61271. '𞤊' => '𞤬',
  61272. '𞤋' => '𞤭',
  61273. '𞤌' => '𞤮',
  61274. '�' => '𞤯',
  61275. '𞤎' => '𞤰',
  61276. '�' => '𞤱',
  61277. '�' => '𞤲',
  61278. '𞤑' => '𞤳',
  61279. '𞤒' => '𞤴',
  61280. '𞤓' => '𞤵',
  61281. '𞤔' => '𞤶',
  61282. '𞤕' => '𞤷',
  61283. '𞤖' => '𞤸',
  61284. '𞤗' => '𞤹',
  61285. '𞤘' => '𞤺',
  61286. '𞤙' => '𞤻',
  61287. '𞤚' => '𞤼',
  61288. '𞤛' => '𞤽',
  61289. '𞤜' => '𞤾',
  61290. '�' => '𞤿',
  61291. '𞤞' => '𞥀',
  61292. '𞤟' => '�',
  61293. '𞤠' => '𞥂',
  61294. '𞤡' => '𞥃',
  61295. );
  61296. <?php
  61297. return '/(?<![\x{0027}\x{002E}\x{003A}\x{005E}\x{0060}\x{00A8}\x{00AD}\x{00AF}\x{00B4}\x{00B7}\x{00B8}\x{02B0}-\x{02C1}\x{02C2}-\x{02C5}\x{02C6}-\x{02D1}\x{02D2}-\x{02DF}\x{02E0}-\x{02E4}\x{02E5}-\x{02EB}\x{02EC}\x{02ED}\x{02EE}\x{02EF}-\x{02FF}\x{0300}-\x{036F}\x{0374}\x{0375}\x{037A}\x{0384}-\x{0385}\x{0387}\x{0483}-\x{0487}\x{0488}-\x{0489}\x{0559}\x{0591}-\x{05BD}\x{05BF}\x{05C1}-\x{05C2}\x{05C4}-\x{05C5}\x{05C7}\x{05F4}\x{0600}-\x{0605}\x{0610}-\x{061A}\x{061C}\x{0640}\x{064B}-\x{065F}\x{0670}\x{06D6}-\x{06DC}\x{06DD}\x{06DF}-\x{06E4}\x{06E5}-\x{06E6}\x{06E7}-\x{06E8}\x{06EA}-\x{06ED}\x{070F}\x{0711}\x{0730}-\x{074A}\x{07A6}-\x{07B0}\x{07EB}-\x{07F3}\x{07F4}-\x{07F5}\x{07FA}\x{07FD}\x{0816}-\x{0819}\x{081A}\x{081B}-\x{0823}\x{0824}\x{0825}-\x{0827}\x{0828}\x{0829}-\x{082D}\x{0859}-\x{085B}\x{08D3}-\x{08E1}\x{08E2}\x{08E3}-\x{0902}\x{093A}\x{093C}\x{0941}-\x{0948}\x{094D}\x{0951}-\x{0957}\x{0962}-\x{0963}\x{0971}\x{0981}\x{09BC}\x{09C1}-\x{09C4}\x{09CD}\x{09E2}-\x{09E3}\x{09FE}\x{0A01}-\x{0A02}\x{0A3C}\x{0A41}-\x{0A42}\x{0A47}-\x{0A48}\x{0A4B}-\x{0A4D}\x{0A51}\x{0A70}-\x{0A71}\x{0A75}\x{0A81}-\x{0A82}\x{0ABC}\x{0AC1}-\x{0AC5}\x{0AC7}-\x{0AC8}\x{0ACD}\x{0AE2}-\x{0AE3}\x{0AFA}-\x{0AFF}\x{0B01}\x{0B3C}\x{0B3F}\x{0B41}-\x{0B44}\x{0B4D}\x{0B56}\x{0B62}-\x{0B63}\x{0B82}\x{0BC0}\x{0BCD}\x{0C00}\x{0C04}\x{0C3E}-\x{0C40}\x{0C46}-\x{0C48}\x{0C4A}-\x{0C4D}\x{0C55}-\x{0C56}\x{0C62}-\x{0C63}\x{0C81}\x{0CBC}\x{0CBF}\x{0CC6}\x{0CCC}-\x{0CCD}\x{0CE2}-\x{0CE3}\x{0D00}-\x{0D01}\x{0D3B}-\x{0D3C}\x{0D41}-\x{0D44}\x{0D4D}\x{0D62}-\x{0D63}\x{0DCA}\x{0DD2}-\x{0DD4}\x{0DD6}\x{0E31}\x{0E34}-\x{0E3A}\x{0E46}\x{0E47}-\x{0E4E}\x{0EB1}\x{0EB4}-\x{0EB9}\x{0EBB}-\x{0EBC}\x{0EC6}\x{0EC8}-\x{0ECD}\x{0F18}-\x{0F19}\x{0F35}\x{0F37}\x{0F39}\x{0F71}-\x{0F7E}\x{0F80}-\x{0F84}\x{0F86}-\x{0F87}\x{0F8D}-\x{0F97}\x{0F99}-\x{0FBC}\x{0FC6}\x{102D}-\x{1030}\x{1032}-\x{1037}\x{1039}-\x{103A}\x{103D}-\x{103E}\x{1058}-\x{1059}\x{105E}-\x{1060}\x{1071}-\x{1074}\x{1082}\x{1085}-\x{1086}\x{108D}\x{109D}\x{10FC}\x{135D}-\x{135F}\x{1712}-\x{1714}\x{1732}-\x{1734}\x{1752}-\x{1753}\x{1772}-\x{1773}\x{17B4}-\x{17B5}\x{17B7}-\x{17BD}\x{17C6}\x{17C9}-\x{17D3}\x{17D7}\x{17DD}\x{180B}-\x{180D}\x{180E}\x{1843}\x{1885}-\x{1886}\x{18A9}\x{1920}-\x{1922}\x{1927}-\x{1928}\x{1932}\x{1939}-\x{193B}\x{1A17}-\x{1A18}\x{1A1B}\x{1A56}\x{1A58}-\x{1A5E}\x{1A60}\x{1A62}\x{1A65}-\x{1A6C}\x{1A73}-\x{1A7C}\x{1A7F}\x{1AA7}\x{1AB0}-\x{1ABD}\x{1ABE}\x{1B00}-\x{1B03}\x{1B34}\x{1B36}-\x{1B3A}\x{1B3C}\x{1B42}\x{1B6B}-\x{1B73}\x{1B80}-\x{1B81}\x{1BA2}-\x{1BA5}\x{1BA8}-\x{1BA9}\x{1BAB}-\x{1BAD}\x{1BE6}\x{1BE8}-\x{1BE9}\x{1BED}\x{1BEF}-\x{1BF1}\x{1C2C}-\x{1C33}\x{1C36}-\x{1C37}\x{1C78}-\x{1C7D}\x{1CD0}-\x{1CD2}\x{1CD4}-\x{1CE0}\x{1CE2}-\x{1CE8}\x{1CED}\x{1CF4}\x{1CF8}-\x{1CF9}\x{1D2C}-\x{1D6A}\x{1D78}\x{1D9B}-\x{1DBF}\x{1DC0}-\x{1DF9}\x{1DFB}-\x{1DFF}\x{1FBD}\x{1FBF}-\x{1FC1}\x{1FCD}-\x{1FCF}\x{1FDD}-\x{1FDF}\x{1FED}-\x{1FEF}\x{1FFD}-\x{1FFE}\x{200B}-\x{200F}\x{2018}\x{2019}\x{2024}\x{2027}\x{202A}-\x{202E}\x{2060}-\x{2064}\x{2066}-\x{206F}\x{2071}\x{207F}\x{2090}-\x{209C}\x{20D0}-\x{20DC}\x{20DD}-\x{20E0}\x{20E1}\x{20E2}-\x{20E4}\x{20E5}-\x{20F0}\x{2C7C}-\x{2C7D}\x{2CEF}-\x{2CF1}\x{2D6F}\x{2D7F}\x{2DE0}-\x{2DFF}\x{2E2F}\x{3005}\x{302A}-\x{302D}\x{3031}-\x{3035}\x{303B}\x{3099}-\x{309A}\x{309B}-\x{309C}\x{309D}-\x{309E}\x{30FC}-\x{30FE}\x{A015}\x{A4F8}-\x{A4FD}\x{A60C}\x{A66F}\x{A670}-\x{A672}\x{A674}-\x{A67D}\x{A67F}\x{A69C}-\x{A69D}\x{A69E}-\x{A69F}\x{A6F0}-\x{A6F1}\x{A700}-\x{A716}\x{A717}-\x{A71F}\x{A720}-\x{A721}\x{A770}\x{A788}\x{A789}-\x{A78A}\x{A7F8}-\x{A7F9}\x{A802}\x{A806}\x{A80B}\x{A825}-\x{A826}\x{A8C4}-\x{A8C5}\x{A8E0}-\x{A8F1}\x{A8FF}\x{A926}-\x{A92D}\x{A947}-\x{A951}\x{A980}-\x{A982}\x{A9B3}\x{A9B6}-\x{A9B9}\x{A9BC}\x{A9CF}\x{A9E5}\x{A9E6}\x{AA29}-\x{AA2E}\x{AA31}-\x{AA32}\x{AA35}-\x{AA36}\x{AA43}\x{AA4C}\x{AA70}\x{AA7C}\x{AAB0}\x{AAB2}-\x{AAB4}\x{AAB7}-\x{AAB8}\x{AABE}-\x{AABF}\x{AAC1}\x{AADD}\x{AAEC}-\x{AAED}\x{AAF3}-\x{AAF4}\x{AAF6}\x{AB5B}\x{AB5C}-\x{AB5F}\x{ABE5}\x{ABE8}\x{ABED}\x{FB1E}\x{FBB2}-\x{FBC1}\x{FE00}-\x{FE0F}\x{FE13}\x{FE20}-\x{FE2F}\x{FE52}\x{FE55}\x{FEFF}\x{FF07}\x{FF0E}\x{FF1A}\x{FF3E}\x{FF40}\x{FF70}\x{FF9E}-\x{FF9F}\x{FFE3}\x{FFF9}-\x{FFFB}\x{101FD}\x{102E0}\x{10376}-\x{1037A}\x{10A01}-\x{10A03}\x{10A05}-\x{10A06}\x{10A0C}-\x{10A0F}\x{10A38}-\x{10A3A}\x{10A3F}\x{10AE5}-\x{10AE6}\x{10D24}-\x{10D27}\x{10F46}-\x{10F50}\x{11001}\x{11038}-\x{11046}\x{1107F}-\x{11081}\x{110B3}-\x{110B6}\x{110B9}-\x{110BA}\x{110BD}\x{110CD}\x{11100}-\x{11102}\x{11127}-\x{1112B}\x{1112D}-\x{11134}\x{11173}\x{11180}-\x{11181}\x{111B6}-\x{111BE}\x{111C9}-\x{111CC}\x{1122F}-\x{11231}\x{11234}\x{11236}-\x{11237}\x{1123E}\x{112DF}\x{112E3}-\x{112EA}\x{11300}-\x{11301}\x{1133B}-\x{1133C}\x{11340}\x{11366}-\x{1136C}\x{11370}-\x{11374}\x{11438}-\x{1143F}\x{11442}-\x{11444}\x{11446}\x{1145E}\x{114B3}-\x{114B8}\x{114BA}\x{114BF}-\x{114C0}\x{114C2}-\x{114C3}\x{115B2}-\x{115B5}\x{115BC}-\x{115BD}\x{115BF}-\x{115C0}\x{115DC}-\x{115DD}\x{11633}-\x{1163A}\x{1163D}\x{1163F}-\x{11640}\x{116AB}\x{116AD}\x{116B0}-\x{116B5}\x{116B7}\x{1171D}-\x{1171F}\x{11722}-\x{11725}\x{11727}-\x{1172B}\x{1182F}-\x{11837}\x{11839}-\x{1183A}\x{11A01}-\x{11A0A}\x{11A33}-\x{11A38}\x{11A3B}-\x{11A3E}\x{11A47}\x{11A51}-\x{11A56}\x{11A59}-\x{11A5B}\x{11A8A}-\x{11A96}\x{11A98}-\x{11A99}\x{11C30}-\x{11C36}\x{11C38}-\x{11C3D}\x{11C3F}\x{11C92}-\x{11CA7}\x{11CAA}-\x{11CB0}\x{11CB2}-\x{11CB3}\x{11CB5}-\x{11CB6}\x{11D31}-\x{11D36}\x{11D3A}\x{11D3C}-\x{11D3D}\x{11D3F}-\x{11D45}\x{11D47}\x{11D90}-\x{11D91}\x{11D95}\x{11D97}\x{11EF3}-\x{11EF4}\x{16AF0}-\x{16AF4}\x{16B30}-\x{16B36}\x{16B40}-\x{16B43}\x{16F8F}-\x{16F92}\x{16F93}-\x{16F9F}\x{16FE0}-\x{16FE1}\x{1BC9D}-\x{1BC9E}\x{1BCA0}-\x{1BCA3}\x{1D167}-\x{1D169}\x{1D173}-\x{1D17A}\x{1D17B}-\x{1D182}\x{1D185}-\x{1D18B}\x{1D1AA}-\x{1D1AD}\x{1D242}-\x{1D244}\x{1DA00}-\x{1DA36}\x{1DA3B}-\x{1DA6C}\x{1DA75}\x{1DA84}\x{1DA9B}-\x{1DA9F}\x{1DAA1}-\x{1DAAF}\x{1E000}-\x{1E006}\x{1E008}-\x{1E018}\x{1E01B}-\x{1E021}\x{1E023}-\x{1E024}\x{1E026}-\x{1E02A}\x{1E8D0}-\x{1E8D6}\x{1E944}-\x{1E94A}\x{1F3FB}-\x{1F3FF}\x{E0001}\x{E0020}-\x{E007F}\x{E0100}-\x{E01EF}])(\pL)(\pL*+)/u';
  61298. <?php
  61299. return array (
  61300. 'a' => 'A',
  61301. 'b' => 'B',
  61302. 'c' => 'C',
  61303. 'd' => 'D',
  61304. 'e' => 'E',
  61305. 'f' => 'F',
  61306. 'g' => 'G',
  61307. 'h' => 'H',
  61308. 'i' => 'I',
  61309. 'j' => 'J',
  61310. 'k' => 'K',
  61311. 'l' => 'L',
  61312. 'm' => 'M',
  61313. 'n' => 'N',
  61314. 'o' => 'O',
  61315. 'p' => 'P',
  61316. 'q' => 'Q',
  61317. 'r' => 'R',
  61318. 's' => 'S',
  61319. 't' => 'T',
  61320. 'u' => 'U',
  61321. 'v' => 'V',
  61322. 'w' => 'W',
  61323. 'x' => 'X',
  61324. 'y' => 'Y',
  61325. 'z' => 'Z',
  61326. 'µ' => 'Μ',
  61327. 'à' => 'À',
  61328. 'á' => '�',
  61329. 'â' => 'Â',
  61330. 'ã' => 'Ã',
  61331. 'ä' => 'Ä',
  61332. 'Ã¥' => 'Ã…',
  61333. 'æ' => 'Æ',
  61334. 'ç' => 'Ç',
  61335. 'è' => 'È',
  61336. 'é' => 'É',
  61337. 'ê' => 'Ê',
  61338. 'ë' => 'Ë',
  61339. 'ì' => 'Ì',
  61340. 'í' => '�',
  61341. 'î' => 'Î',
  61342. 'ï' => '�',
  61343. 'ð' => '�',
  61344. 'ñ' => 'Ñ',
  61345. 'ò' => 'Ò',
  61346. 'ó' => 'Ó',
  61347. 'ô' => 'Ô',
  61348. 'õ' => 'Õ',
  61349. 'ö' => 'Ö',
  61350. 'ø' => 'Ø',
  61351. 'ù' => 'Ù',
  61352. 'ú' => 'Ú',
  61353. 'û' => 'Û',
  61354. 'ü' => 'Ü',
  61355. 'ý' => '�',
  61356. 'þ' => 'Þ',
  61357. 'ÿ' => 'Ÿ',
  61358. '�' => 'Ā',
  61359. 'ă' => 'Ă',
  61360. 'Ä…' => 'Ä„',
  61361. 'ć' => 'Ć',
  61362. 'ĉ' => 'Ĉ',
  61363. 'Ä‹' => 'ÄŠ',
  61364. '�' => 'Č',
  61365. '�' => 'Ď',
  61366. 'đ' => '�',
  61367. 'Ä“' => 'Ä’',
  61368. 'Ä•' => 'Ä”',
  61369. 'Ä—' => 'Ä–',
  61370. 'ę' => 'Ę',
  61371. 'Ä›' => 'Äš',
  61372. '�' => 'Ĝ',
  61373. 'ÄŸ' => 'Äž',
  61374. 'Ä¡' => 'Ä ',
  61375. 'Ä£' => 'Ä¢',
  61376. 'ĥ' => 'Ĥ',
  61377. 'ħ' => 'Ħ',
  61378. 'ĩ' => 'Ĩ',
  61379. 'ī' => 'Ī',
  61380. 'ĭ' => 'Ĭ',
  61381. 'į' => 'Į',
  61382. 'ı' => 'I',
  61383. 'ij' => 'IJ',
  61384. 'ĵ' => 'Ĵ',
  61385. 'ķ' => 'Ķ',
  61386. 'ĺ' => 'Ĺ',
  61387. 'ļ' => 'Ļ',
  61388. 'ľ' => 'Ľ',
  61389. 'Å€' => 'Ä¿',
  61390. 'ł' => '�',
  61391. 'ń' => 'Ń',
  61392. 'ņ' => 'Ņ',
  61393. 'ň' => 'Ň',
  61394. 'Å‹' => 'ÅŠ',
  61395. '�' => 'Ō',
  61396. '�' => 'Ŏ',
  61397. 'ő' => '�',
  61398. 'Å“' => 'Å’',
  61399. 'Å•' => 'Å”',
  61400. 'Å—' => 'Å–',
  61401. 'ř' => 'Ř',
  61402. 'Å›' => 'Åš',
  61403. '�' => 'Ŝ',
  61404. 'ÅŸ' => 'Åž',
  61405. 'Å¡' => 'Å ',
  61406. 'Å£' => 'Å¢',
  61407. 'ť' => 'Ť',
  61408. 'ŧ' => 'Ŧ',
  61409. 'ũ' => 'Ũ',
  61410. 'ū' => 'Ū',
  61411. 'ŭ' => 'Ŭ',
  61412. 'ů' => 'Ů',
  61413. 'ű' => 'Ű',
  61414. 'ų' => 'Ų',
  61415. 'ŵ' => 'Ŵ',
  61416. 'ŷ' => 'Ŷ',
  61417. 'ź' => 'Ź',
  61418. 'ż' => 'Ż',
  61419. 'ž' => 'Ž',
  61420. 'Å¿' => 'S',
  61421. 'ƀ' => 'Ƀ',
  61422. 'ƃ' => 'Ƃ',
  61423. 'Æ…' => 'Æ„',
  61424. 'ƈ' => 'Ƈ',
  61425. 'ƌ' => 'Ƌ',
  61426. 'Æ’' => 'Æ‘',
  61427. 'ƕ' => 'Ƕ',
  61428. 'ƙ' => 'Ƙ',
  61429. 'ƚ' => 'Ƚ',
  61430. 'Æž' => 'È ',
  61431. 'Æ¡' => 'Æ ',
  61432. 'Æ£' => 'Æ¢',
  61433. 'ƥ' => 'Ƥ',
  61434. 'ƨ' => 'Ƨ',
  61435. 'ƭ' => 'Ƭ',
  61436. 'ư' => 'Ư',
  61437. 'ƴ' => 'Ƴ',
  61438. 'ƶ' => 'Ƶ',
  61439. 'ƹ' => 'Ƹ',
  61440. 'ƽ' => 'Ƽ',
  61441. 'Æ¿' => 'Ç·',
  61442. 'Ç…' => 'Ç„',
  61443. 'dž' => 'DŽ',
  61444. 'Lj' => 'LJ',
  61445. 'lj' => 'LJ',
  61446. 'Ç‹' => 'ÇŠ',
  61447. 'nj' => 'NJ',
  61448. 'ǎ' => '�',
  61449. '�' => '�',
  61450. 'Ç’' => 'Ç‘',
  61451. 'Ç”' => 'Ç“',
  61452. 'Ç–' => 'Ç•',
  61453. 'ǘ' => 'Ǘ',
  61454. 'Çš' => 'Ç™',
  61455. 'ǜ' => 'Ǜ',
  61456. '�' => 'Ǝ',
  61457. 'ÇŸ' => 'Çž',
  61458. 'Ç¡' => 'Ç ',
  61459. 'Ç£' => 'Ç¢',
  61460. 'ǥ' => 'Ǥ',
  61461. 'ǧ' => 'Ǧ',
  61462. 'ǩ' => 'Ǩ',
  61463. 'ǫ' => 'Ǫ',
  61464. 'ǭ' => 'Ǭ',
  61465. 'ǯ' => 'Ǯ',
  61466. 'Dz' => 'DZ',
  61467. 'dz' => 'DZ',
  61468. 'ǵ' => 'Ǵ',
  61469. 'ǹ' => 'Ǹ',
  61470. 'ǻ' => 'Ǻ',
  61471. 'ǽ' => 'Ǽ',
  61472. 'ǿ' => 'Ǿ',
  61473. '�' => 'Ȁ',
  61474. 'ȃ' => 'Ȃ',
  61475. 'È…' => 'È„',
  61476. 'ȇ' => 'Ȇ',
  61477. 'ȉ' => 'Ȉ',
  61478. 'È‹' => 'ÈŠ',
  61479. '�' => 'Ȍ',
  61480. '�' => 'Ȏ',
  61481. 'ȑ' => '�',
  61482. 'È“' => 'È’',
  61483. 'È•' => 'È”',
  61484. 'È—' => 'È–',
  61485. 'ș' => 'Ș',
  61486. 'È›' => 'Èš',
  61487. '�' => 'Ȝ',
  61488. 'ÈŸ' => 'Èž',
  61489. 'È£' => 'È¢',
  61490. 'ȥ' => 'Ȥ',
  61491. 'ȧ' => 'Ȧ',
  61492. 'ȩ' => 'Ȩ',
  61493. 'ȫ' => 'Ȫ',
  61494. 'ȭ' => 'Ȭ',
  61495. 'ȯ' => 'Ȯ',
  61496. 'ȱ' => 'Ȱ',
  61497. 'ȳ' => 'Ȳ',
  61498. 'ȼ' => 'Ȼ',
  61499. 'È¿' => 'â±¾',
  61500. 'ɀ' => 'Ɀ',
  61501. 'ɂ' => '�',
  61502. 'ɇ' => 'Ɇ',
  61503. 'ɉ' => 'Ɉ',
  61504. 'É‹' => 'ÉŠ',
  61505. '�' => 'Ɍ',
  61506. '�' => 'Ɏ',
  61507. '�' => 'Ɐ',
  61508. 'É‘' => 'â±­',
  61509. 'É’' => 'â±°',
  61510. 'ɓ' => '�',
  61511. 'ɔ' => 'Ɔ',
  61512. 'ɖ' => 'Ɖ',
  61513. 'É—' => 'ÆŠ',
  61514. 'ə' => '�',
  61515. 'ɛ' => '�',
  61516. 'ɜ' => 'Ɜ',
  61517. 'É ' => 'Æ“',
  61518. 'ɡ' => 'Ɡ',
  61519. 'É£' => 'Æ”',
  61520. 'ɥ' => '�',
  61521. 'ɦ' => 'Ɦ',
  61522. 'ɨ' => 'Ɨ',
  61523. 'É©' => 'Æ–',
  61524. 'ɪ' => 'Ɪ',
  61525. 'É«' => 'â±¢',
  61526. 'ɬ' => 'Ɬ',
  61527. 'ɯ' => 'Ɯ',
  61528. 'ɱ' => 'Ɱ',
  61529. 'ɲ' => '�',
  61530. 'ɵ' => 'Ɵ',
  61531. 'ɽ' => 'Ɽ',
  61532. 'ʀ' => 'Ʀ',
  61533. 'ʂ' => 'Ʂ',
  61534. 'ʃ' => 'Ʃ',
  61535. 'ʇ' => 'Ʇ',
  61536. 'ʈ' => 'Ʈ',
  61537. 'ʉ' => 'Ʉ',
  61538. 'ʊ' => 'Ʊ',
  61539. 'ʋ' => 'Ʋ',
  61540. 'ʌ' => 'Ʌ',
  61541. 'Ê’' => 'Æ·',
  61542. '�' => 'Ʝ',
  61543. 'Êž' => 'êž°',
  61544. 'ͅ' => 'Ι',
  61545. 'ͱ' => 'Ͱ',
  61546. 'ͳ' => 'Ͳ',
  61547. 'ͷ' => 'Ͷ',
  61548. 'ͻ' => 'Ͻ',
  61549. 'ͼ' => 'Ͼ',
  61550. 'ͽ' => 'Ͽ',
  61551. 'ά' => 'Ά',
  61552. 'έ' => 'Έ',
  61553. 'ή' => 'Ή',
  61554. 'ί' => 'Ί',
  61555. 'α' => 'Α',
  61556. 'β' => 'Β',
  61557. 'γ' => 'Γ',
  61558. 'δ' => 'Δ',
  61559. 'ε' => 'Ε',
  61560. 'ζ' => 'Ζ',
  61561. 'η' => 'Η',
  61562. 'θ' => 'Θ',
  61563. 'ι' => 'Ι',
  61564. 'κ' => 'Κ',
  61565. 'λ' => 'Λ',
  61566. 'μ' => 'Μ',
  61567. 'ν' => '�',
  61568. 'ξ' => 'Ξ',
  61569. 'ο' => 'Ο',
  61570. 'π' => 'Π',
  61571. '�' => 'Ρ',
  61572. 'ς' => 'Σ',
  61573. 'σ' => 'Σ',
  61574. 'τ' => 'Τ',
  61575. 'Ï…' => 'Î¥',
  61576. 'φ' => 'Φ',
  61577. 'χ' => 'Χ',
  61578. 'ψ' => 'Ψ',
  61579. 'ω' => 'Ω',
  61580. 'ϊ' => 'Ϊ',
  61581. 'ϋ' => 'Ϋ',
  61582. 'ό' => 'Ό',
  61583. '�' => 'Ύ',
  61584. 'ώ' => '�',
  61585. '�' => 'Β',
  61586. 'ϑ' => 'Θ',
  61587. 'ϕ' => 'Φ',
  61588. 'ϖ' => 'Π',
  61589. 'ϗ' => '�',
  61590. 'ϙ' => 'Ϙ',
  61591. 'Ï›' => 'Ïš',
  61592. '�' => 'Ϝ',
  61593. 'ÏŸ' => 'Ïž',
  61594. 'Ï¡' => 'Ï ',
  61595. 'Ï£' => 'Ï¢',
  61596. 'ϥ' => 'Ϥ',
  61597. 'ϧ' => 'Ϧ',
  61598. 'ϩ' => 'Ϩ',
  61599. 'ϫ' => 'Ϫ',
  61600. 'ϭ' => 'Ϭ',
  61601. 'ϯ' => 'Ϯ',
  61602. 'ϰ' => 'Κ',
  61603. 'ϱ' => 'Ρ',
  61604. 'ϲ' => 'Ϲ',
  61605. 'ϳ' => 'Ϳ',
  61606. 'ϵ' => 'Ε',
  61607. 'ϸ' => 'Ϸ',
  61608. 'ϻ' => 'Ϻ',
  61609. 'а' => '�',
  61610. 'б' => 'Б',
  61611. 'в' => 'В',
  61612. 'г' => 'Г',
  61613. 'д' => 'Д',
  61614. 'е' => 'Е',
  61615. 'ж' => 'Ж',
  61616. 'з' => 'З',
  61617. 'и' => 'И',
  61618. 'й' => 'Й',
  61619. 'к' => 'К',
  61620. 'л' => 'Л',
  61621. 'м' => 'М',
  61622. 'н' => '�',
  61623. 'о' => 'О',
  61624. 'п' => 'П',
  61625. 'р' => 'Р',
  61626. '�' => 'С',
  61627. 'т' => 'Т',
  61628. 'у' => 'У',
  61629. 'ф' => 'Ф',
  61630. 'Ñ…' => 'Ð¥',
  61631. 'ц' => 'Ц',
  61632. 'ч' => 'Ч',
  61633. 'ш' => 'Ш',
  61634. 'щ' => 'Щ',
  61635. 'ъ' => 'Ъ',
  61636. 'ы' => 'Ы',
  61637. 'ь' => 'Ь',
  61638. '�' => 'Э',
  61639. 'ю' => 'Ю',
  61640. '�' => 'Я',
  61641. '�' => 'Ѐ',
  61642. 'ё' => '�',
  61643. 'ђ' => 'Ђ',
  61644. 'ѓ' => 'Ѓ',
  61645. 'є' => 'Є',
  61646. 'Ñ•' => 'Ð…',
  61647. 'і' => 'І',
  61648. 'ї' => 'Ї',
  61649. 'ј' => 'Ј',
  61650. 'љ' => 'Љ',
  61651. 'њ' => 'Њ',
  61652. 'ћ' => 'Ћ',
  61653. 'ќ' => 'Ќ',
  61654. '�' => '�',
  61655. 'Ñž' => 'ÐŽ',
  61656. 'џ' => '�',
  61657. 'Ñ¡' => 'Ñ ',
  61658. 'Ñ£' => 'Ñ¢',
  61659. 'ѥ' => 'Ѥ',
  61660. 'ѧ' => 'Ѧ',
  61661. 'ѩ' => 'Ѩ',
  61662. 'ѫ' => 'Ѫ',
  61663. 'ѭ' => 'Ѭ',
  61664. 'ѯ' => 'Ѯ',
  61665. 'ѱ' => 'Ѱ',
  61666. 'ѳ' => 'Ѳ',
  61667. 'ѵ' => 'Ѵ',
  61668. 'ѷ' => 'Ѷ',
  61669. 'ѹ' => 'Ѹ',
  61670. 'ѻ' => 'Ѻ',
  61671. 'ѽ' => 'Ѽ',
  61672. 'ѿ' => 'Ѿ',
  61673. 'Ò�' => 'Ò€',
  61674. 'Ò‹' => 'ÒŠ',
  61675. '�' => 'Ҍ',
  61676. 'Ò�' => 'ÒŽ',
  61677. 'Ò‘' => 'Ò�',
  61678. 'Ò“' => 'Ò’',
  61679. 'Ò•' => 'Ò”',
  61680. 'Ò—' => 'Ò–',
  61681. 'Ò™' => 'Ò˜',
  61682. 'Ò›' => 'Òš',
  61683. '�' => 'Ҝ',
  61684. 'ÒŸ' => 'Òž',
  61685. 'Ò¡' => 'Ò ',
  61686. 'Ò£' => 'Ò¢',
  61687. 'Ò¥' => 'Ò¤',
  61688. 'Ò§' => 'Ò¦',
  61689. 'Ò©' => 'Ò¨',
  61690. 'Ò«' => 'Òª',
  61691. 'Ò­' => 'Ò¬',
  61692. 'Ò¯' => 'Ò®',
  61693. 'Ò±' => 'Ò°',
  61694. 'Ò³' => 'Ò²',
  61695. 'Òµ' => 'Ò´',
  61696. 'Ò·' => 'Ò¶',
  61697. 'Ò¹' => 'Ò¸',
  61698. 'Ò»' => 'Òº',
  61699. 'Ò½' => 'Ò¼',
  61700. 'Ò¿' => 'Ò¾',
  61701. 'Ó‚' => 'Ó�',
  61702. 'Ó„' => 'Óƒ',
  61703. 'Ó†' => 'Ó…',
  61704. 'Óˆ' => 'Ó‡',
  61705. 'ÓŠ' => 'Ó‰',
  61706. 'ӌ' => 'Ӌ',
  61707. 'ÓŽ' => 'Ó�',
  61708. 'Ó�' => 'Ó€',
  61709. 'Ó‘' => 'Ó�',
  61710. 'Ó“' => 'Ó’',
  61711. 'Ó•' => 'Ó”',
  61712. 'Ó—' => 'Ó–',
  61713. 'Ó™' => 'Ó˜',
  61714. 'Ó›' => 'Óš',
  61715. '�' => 'Ӝ',
  61716. 'ÓŸ' => 'Óž',
  61717. 'Ó¡' => 'Ó ',
  61718. 'Ó£' => 'Ó¢',
  61719. 'Ó¥' => 'Ó¤',
  61720. 'Ó§' => 'Ó¦',
  61721. 'Ó©' => 'Ó¨',
  61722. 'Ó«' => 'Óª',
  61723. 'Ó­' => 'Ó¬',
  61724. 'Ó¯' => 'Ó®',
  61725. 'Ó±' => 'Ó°',
  61726. 'Ó³' => 'Ó²',
  61727. 'Óµ' => 'Ó´',
  61728. 'Ó·' => 'Ó¶',
  61729. 'Ó¹' => 'Ó¸',
  61730. 'Ó»' => 'Óº',
  61731. 'Ó½' => 'Ó¼',
  61732. 'Ó¿' => 'Ó¾',
  61733. 'Ô�' => 'Ô€',
  61734. 'Ôƒ' => 'Ô‚',
  61735. 'Ô…' => 'Ô„',
  61736. 'Ô‡' => 'Ô†',
  61737. 'Ô‰' => 'Ôˆ',
  61738. 'Ô‹' => 'ÔŠ',
  61739. '�' => 'Ԍ',
  61740. 'Ô�' => 'ÔŽ',
  61741. 'Ô‘' => 'Ô�',
  61742. 'Ô“' => 'Ô’',
  61743. 'Ô•' => 'Ô”',
  61744. 'Ô—' => 'Ô–',
  61745. 'Ô™' => 'Ô˜',
  61746. 'Ô›' => 'Ôš',
  61747. '�' => 'Ԝ',
  61748. 'ÔŸ' => 'Ôž',
  61749. 'Ô¡' => 'Ô ',
  61750. 'Ô£' => 'Ô¢',
  61751. 'Ô¥' => 'Ô¤',
  61752. 'Ô§' => 'Ô¦',
  61753. 'Ô©' => 'Ô¨',
  61754. 'Ô«' => 'Ôª',
  61755. 'Ô­' => 'Ô¬',
  61756. 'Ô¯' => 'Ô®',
  61757. 'Õ¡' => 'Ô±',
  61758. 'Õ¢' => 'Ô²',
  61759. 'Õ£' => 'Ô³',
  61760. 'Õ¤' => 'Ô´',
  61761. 'Õ¥' => 'Ôµ',
  61762. 'Õ¦' => 'Ô¶',
  61763. 'Õ§' => 'Ô·',
  61764. 'Õ¨' => 'Ô¸',
  61765. 'Õ©' => 'Ô¹',
  61766. 'Õª' => 'Ôº',
  61767. 'Õ«' => 'Ô»',
  61768. 'Õ¬' => 'Ô¼',
  61769. 'Õ­' => 'Ô½',
  61770. 'Õ®' => 'Ô¾',
  61771. 'Õ¯' => 'Ô¿',
  61772. 'Õ°' => 'Õ€',
  61773. 'Õ±' => 'Õ�',
  61774. 'Õ²' => 'Õ‚',
  61775. 'Õ³' => 'Õƒ',
  61776. 'Õ´' => 'Õ„',
  61777. 'Õµ' => 'Õ…',
  61778. 'Õ¶' => 'Õ†',
  61779. 'Õ·' => 'Õ‡',
  61780. 'Õ¸' => 'Õˆ',
  61781. 'Õ¹' => 'Õ‰',
  61782. 'Õº' => 'ÕŠ',
  61783. 'Õ»' => 'Õ‹',
  61784. 'ռ' => 'Ռ',
  61785. 'Õ½' => 'Õ�',
  61786. 'Õ¾' => 'ÕŽ',
  61787. 'Õ¿' => 'Õ�',
  61788. 'Ö€' => 'Õ�',
  61789. 'Ö�' => 'Õ‘',
  61790. 'Ö‚' => 'Õ’',
  61791. 'Öƒ' => 'Õ“',
  61792. 'Ö„' => 'Õ”',
  61793. 'Ö…' => 'Õ•',
  61794. 'Ö†' => 'Õ–',
  61795. '�' => '�',
  61796. 'ბ' => 'Ბ',
  61797. 'გ' => 'Გ',
  61798. 'დ' => 'Დ',
  61799. 'ე' => 'Ე',
  61800. 'ვ' => 'Ვ',
  61801. 'ზ' => 'Ზ',
  61802. 'თ' => 'Თ',
  61803. 'ი' => 'Ი',
  61804. 'კ' => 'Კ',
  61805. 'ლ' => 'Ლ',
  61806. 'მ' => 'Მ',
  61807. 'ნ' => 'Ნ',
  61808. '�' => '�',
  61809. 'პ' => 'Პ',
  61810. 'ჟ' => 'Ჟ',
  61811. 'რ' => 'Რ',
  61812. 'ს' => 'Ს',
  61813. 'ტ' => 'Ტ',
  61814. 'უ' => 'Უ',
  61815. 'ფ' => 'Ფ',
  61816. 'ქ' => 'Ქ',
  61817. 'ღ' => 'Ღ',
  61818. 'ყ' => 'Ყ',
  61819. 'შ' => 'Შ',
  61820. 'ჩ' => 'Ჩ',
  61821. 'ც' => 'Ც',
  61822. 'ძ' => 'Ძ',
  61823. 'წ' => 'Წ',
  61824. 'ჭ' => 'Ჭ',
  61825. 'ხ' => 'Ხ',
  61826. 'ჯ' => 'Ჯ',
  61827. 'ჰ' => 'Ჰ',
  61828. 'ჱ' => 'Ჱ',
  61829. 'ჲ' => 'Ჲ',
  61830. 'ჳ' => 'Ჳ',
  61831. 'ჴ' => 'Ჴ',
  61832. 'ჵ' => 'Ჵ',
  61833. 'ჶ' => 'Ჶ',
  61834. 'ჷ' => 'Ჷ',
  61835. 'ჸ' => 'Ჸ',
  61836. 'ჹ' => 'Ჹ',
  61837. 'ჺ' => 'Ჺ',
  61838. 'ჽ' => 'Ჽ',
  61839. 'ჾ' => 'Ჾ',
  61840. 'ჿ' => 'Ჿ',
  61841. '�' => '�',
  61842. '�' => '�',
  61843. '�' => '�',
  61844. '�' => '�',
  61845. '�' => '�',
  61846. '�' => '�',
  61847. 'á²€' => 'Ð’',
  61848. '�' => 'Д',
  61849. 'ᲂ' => 'О',
  61850. 'ᲃ' => 'С',
  61851. 'ᲄ' => 'Т',
  61852. 'ᲅ' => 'Т',
  61853. 'ᲆ' => 'Ъ',
  61854. 'ᲇ' => 'Ѣ',
  61855. 'ᲈ' => 'Ꙋ',
  61856. 'ᵹ' => '�',
  61857. 'áµ½' => 'â±£',
  61858. 'ᶎ' => 'Ᶎ',
  61859. '�' => 'Ḁ',
  61860. 'ḃ' => 'Ḃ',
  61861. 'ḅ' => 'Ḅ',
  61862. 'ḇ' => 'Ḇ',
  61863. 'ḉ' => 'Ḉ',
  61864. 'ḋ' => 'Ḋ',
  61865. '�' => 'Ḍ',
  61866. '�' => 'Ḏ',
  61867. 'ḑ' => '�',
  61868. 'ḓ' => 'Ḓ',
  61869. 'ḕ' => 'Ḕ',
  61870. 'ḗ' => 'Ḗ',
  61871. 'ḙ' => 'Ḙ',
  61872. 'ḛ' => 'Ḛ',
  61873. '�' => 'Ḝ',
  61874. 'ḟ' => 'Ḟ',
  61875. 'ḡ' => 'Ḡ',
  61876. 'ḣ' => 'Ḣ',
  61877. 'ḥ' => 'Ḥ',
  61878. 'ḧ' => 'Ḧ',
  61879. 'ḩ' => 'Ḩ',
  61880. 'ḫ' => 'Ḫ',
  61881. 'ḭ' => 'Ḭ',
  61882. 'ḯ' => 'Ḯ',
  61883. 'ḱ' => 'Ḱ',
  61884. 'ḳ' => 'Ḳ',
  61885. 'ḵ' => 'Ḵ',
  61886. 'ḷ' => 'Ḷ',
  61887. 'ḹ' => 'Ḹ',
  61888. 'ḻ' => 'Ḻ',
  61889. 'ḽ' => 'Ḽ',
  61890. 'ḿ' => 'Ḿ',
  61891. '�' => 'Ṁ',
  61892. 'ṃ' => 'Ṃ',
  61893. 'ṅ' => 'Ṅ',
  61894. 'ṇ' => 'Ṇ',
  61895. 'ṉ' => 'Ṉ',
  61896. 'ṋ' => 'Ṋ',
  61897. '�' => 'Ṍ',
  61898. '�' => 'Ṏ',
  61899. 'ṑ' => '�',
  61900. 'ṓ' => 'Ṓ',
  61901. 'ṕ' => 'Ṕ',
  61902. 'á¹—' => 'á¹–',
  61903. 'ṙ' => 'Ṙ',
  61904. 'ṛ' => 'Ṛ',
  61905. '�' => 'Ṝ',
  61906. 'ṟ' => 'Ṟ',
  61907. 'ṡ' => 'Ṡ',
  61908. 'á¹£' => 'á¹¢',
  61909. 'ṥ' => 'Ṥ',
  61910. 'ṧ' => 'Ṧ',
  61911. 'ṩ' => 'Ṩ',
  61912. 'ṫ' => 'Ṫ',
  61913. 'ṭ' => 'Ṭ',
  61914. 'ṯ' => 'Ṯ',
  61915. 'á¹±' => 'á¹°',
  61916. 'á¹³' => 'á¹²',
  61917. 'á¹µ' => 'á¹´',
  61918. 'ṷ' => 'Ṷ',
  61919. 'ṹ' => 'Ṹ',
  61920. 'ṻ' => 'Ṻ',
  61921. 'á¹½' => 'á¹¼',
  61922. 'ṿ' => 'Ṿ',
  61923. '�' => 'Ẁ',
  61924. 'ẃ' => 'Ẃ',
  61925. 'ẅ' => 'Ẅ',
  61926. 'ẇ' => 'Ẇ',
  61927. 'ẉ' => 'Ẉ',
  61928. 'ẋ' => 'Ẋ',
  61929. '�' => 'Ẍ',
  61930. '�' => 'Ẏ',
  61931. 'ẑ' => '�',
  61932. 'ẓ' => 'Ẓ',
  61933. 'ẕ' => 'Ẕ',
  61934. 'ẛ' => 'Ṡ',
  61935. 'ạ' => 'Ạ',
  61936. 'ả' => 'Ả',
  61937. 'ấ' => 'Ấ',
  61938. 'ầ' => 'Ầ',
  61939. 'ẩ' => 'Ẩ',
  61940. 'ẫ' => 'Ẫ',
  61941. 'ậ' => 'Ậ',
  61942. 'ắ' => 'Ắ',
  61943. 'ằ' => 'Ằ',
  61944. 'ẳ' => 'Ẳ',
  61945. 'ẵ' => 'Ẵ',
  61946. 'ặ' => 'Ặ',
  61947. 'ẹ' => 'Ẹ',
  61948. 'ẻ' => 'Ẻ',
  61949. 'ẽ' => 'Ẽ',
  61950. 'ế' => 'Ế',
  61951. '�' => 'Ề',
  61952. 'ể' => 'Ể',
  61953. 'ễ' => 'Ễ',
  61954. 'ệ' => 'Ệ',
  61955. 'ỉ' => 'Ỉ',
  61956. 'ị' => 'Ị',
  61957. '�' => 'Ọ',
  61958. '�' => 'Ỏ',
  61959. 'ố' => '�',
  61960. 'ồ' => 'Ồ',
  61961. 'ổ' => 'Ổ',
  61962. 'á»—' => 'á»–',
  61963. 'ộ' => 'Ộ',
  61964. 'ớ' => 'Ớ',
  61965. '�' => 'Ờ',
  61966. 'ở' => 'Ở',
  61967. 'ỡ' => 'Ỡ',
  61968. 'ợ' => 'Ợ',
  61969. 'ụ' => 'Ụ',
  61970. 'ủ' => 'Ủ',
  61971. 'ứ' => 'Ứ',
  61972. 'ừ' => 'Ừ',
  61973. 'ử' => 'Ử',
  61974. 'ữ' => 'Ữ',
  61975. 'á»±' => 'á»°',
  61976. 'ỳ' => 'Ỳ',
  61977. 'ỵ' => 'Ỵ',
  61978. 'ỷ' => 'Ỷ',
  61979. 'ỹ' => 'Ỹ',
  61980. 'ỻ' => 'Ỻ',
  61981. 'ỽ' => 'Ỽ',
  61982. 'ỿ' => 'Ỿ',
  61983. 'ἀ' => 'Ἀ',
  61984. '�' => 'Ἁ',
  61985. 'ἂ' => 'Ἂ',
  61986. 'ἃ' => 'Ἃ',
  61987. 'ἄ' => 'Ἄ',
  61988. 'ἅ' => '�',
  61989. 'ἆ' => 'Ἆ',
  61990. 'ἇ' => '�',
  61991. '�' => 'Ἐ',
  61992. 'ἑ' => 'Ἑ',
  61993. 'ἒ' => 'Ἒ',
  61994. 'ἓ' => 'Ἓ',
  61995. 'ἔ' => 'Ἔ',
  61996. 'ἕ' => '�',
  61997. 'ἠ' => 'Ἠ',
  61998. 'ἡ' => 'Ἡ',
  61999. 'ἢ' => 'Ἢ',
  62000. 'ἣ' => 'Ἣ',
  62001. 'ἤ' => 'Ἤ',
  62002. 'á¼¥' => 'á¼­',
  62003. 'ἦ' => 'Ἦ',
  62004. 'ἧ' => 'Ἧ',
  62005. 'ἰ' => 'Ἰ',
  62006. 'á¼±' => 'á¼¹',
  62007. 'ἲ' => 'Ἲ',
  62008. 'á¼³' => 'á¼»',
  62009. 'á¼´' => 'á¼¼',
  62010. 'á¼µ' => 'á¼½',
  62011. 'ἶ' => 'Ἶ',
  62012. 'ἷ' => 'Ἷ',
  62013. 'ὀ' => 'Ὀ',
  62014. '�' => 'Ὁ',
  62015. 'ὂ' => 'Ὂ',
  62016. 'ὃ' => 'Ὃ',
  62017. 'ὄ' => 'Ὄ',
  62018. 'ὅ' => '�',
  62019. 'ὑ' => 'Ὑ',
  62020. 'ὓ' => 'Ὓ',
  62021. 'ὕ' => '�',
  62022. 'ὗ' => 'Ὗ',
  62023. 'ὠ' => 'Ὠ',
  62024. 'ὡ' => 'Ὡ',
  62025. 'ὢ' => 'Ὢ',
  62026. 'ὣ' => 'Ὣ',
  62027. 'ὤ' => 'Ὤ',
  62028. 'á½¥' => 'á½­',
  62029. 'ὦ' => 'Ὦ',
  62030. 'ὧ' => 'Ὧ',
  62031. 'ὰ' => 'Ὰ',
  62032. 'á½±' => 'á¾»',
  62033. 'ὲ' => 'Ὲ',
  62034. 'έ' => 'Έ',
  62035. 'á½´' => 'á¿Š',
  62036. 'á½µ' => 'á¿‹',
  62037. 'ὶ' => 'Ὶ',
  62038. 'á½·' => 'á¿›',
  62039. 'ὸ' => 'Ὸ',
  62040. 'ό' => 'Ό',
  62041. 'ὺ' => 'Ὺ',
  62042. 'á½»' => 'á¿«',
  62043. 'ὼ' => 'Ὼ',
  62044. 'á½½' => 'á¿»',
  62045. 'ᾀ' => 'ᾈ',
  62046. '�' => 'ᾉ',
  62047. 'ᾂ' => 'ᾊ',
  62048. 'ᾃ' => 'ᾋ',
  62049. 'ᾄ' => 'ᾌ',
  62050. 'ᾅ' => '�',
  62051. 'ᾆ' => 'ᾎ',
  62052. 'ᾇ' => '�',
  62053. '�' => 'ᾘ',
  62054. 'ᾑ' => 'ᾙ',
  62055. 'ᾒ' => 'ᾚ',
  62056. 'ᾓ' => 'ᾛ',
  62057. 'ᾔ' => 'ᾜ',
  62058. 'ᾕ' => '�',
  62059. 'ᾖ' => 'ᾞ',
  62060. 'ᾗ' => 'ᾟ',
  62061. 'ᾠ' => 'ᾨ',
  62062. 'ᾡ' => 'ᾩ',
  62063. 'ᾢ' => 'ᾪ',
  62064. 'ᾣ' => 'ᾫ',
  62065. 'ᾤ' => 'ᾬ',
  62066. 'á¾¥' => 'á¾­',
  62067. 'ᾦ' => 'ᾮ',
  62068. 'ᾧ' => 'ᾯ',
  62069. 'ᾰ' => 'Ᾰ',
  62070. 'á¾±' => 'á¾¹',
  62071. 'á¾³' => 'á¾¼',
  62072. 'ι' => 'Ι',
  62073. 'ῃ' => 'ῌ',
  62074. '�' => 'Ῐ',
  62075. 'á¿‘' => 'á¿™',
  62076. 'ῠ' => 'Ῠ',
  62077. 'á¿¡' => 'á¿©',
  62078. 'ῥ' => 'Ῥ',
  62079. 'ῳ' => 'ῼ',
  62080. 'ⅎ' => 'Ⅎ',
  62081. 'â…°' => 'â… ',
  62082. 'â…±' => 'â…¡',
  62083. 'â…²' => 'â…¢',
  62084. 'â…³' => 'â…£',
  62085. 'â…´' => 'â…¤',
  62086. 'â…µ' => 'â…¥',
  62087. 'â…¶' => 'â…¦',
  62088. 'â…·' => 'â…§',
  62089. 'â…¸' => 'â…¨',
  62090. 'â…¹' => 'â…©',
  62091. 'â…º' => 'â…ª',
  62092. 'â…»' => 'â…«',
  62093. 'â…¼' => 'â…¬',
  62094. 'â…½' => 'â…­',
  62095. 'â…¾' => 'â…®',
  62096. 'â…¿' => 'â…¯',
  62097. 'ↄ' => 'Ↄ',
  62098. '�' => 'Ⓐ',
  62099. 'â“‘' => 'â’·',
  62100. 'â“’' => 'â’¸',
  62101. 'â““' => 'â’¹',
  62102. 'â“”' => 'â’º',
  62103. 'â“•' => 'â’»',
  62104. 'â“–' => 'â’¼',
  62105. 'â“—' => 'â’½',
  62106. 'ⓘ' => 'Ⓘ',
  62107. 'â“™' => 'â’¿',
  62108. 'â“š' => 'â“€',
  62109. 'ⓛ' => '�',
  62110. 'ⓜ' => 'Ⓜ',
  62111. '�' => 'Ⓝ',
  62112. 'â“ž' => 'â“„',
  62113. 'â“Ÿ' => 'â“…',
  62114. 'ⓠ' => 'Ⓠ',
  62115. 'ⓡ' => 'Ⓡ',
  62116. 'ⓢ' => 'Ⓢ',
  62117. 'ⓣ' => 'Ⓣ',
  62118. 'ⓤ' => 'Ⓤ',
  62119. 'â“¥' => 'â“‹',
  62120. 'ⓦ' => 'Ⓦ',
  62121. 'ⓧ' => '�',
  62122. 'ⓨ' => 'Ⓨ',
  62123. 'ⓩ' => '�',
  62124. 'â°°' => 'â°€',
  62125. 'â°±' => 'â°�',
  62126. 'â°²' => 'â°‚',
  62127. 'â°³' => 'â°ƒ',
  62128. 'â°´' => 'â°„',
  62129. 'â°µ' => 'â°…',
  62130. 'â°¶' => 'â°†',
  62131. 'â°·' => 'â°‡',
  62132. 'â°¸' => 'â°ˆ',
  62133. 'â°¹' => 'â°‰',
  62134. 'â°º' => 'â°Š',
  62135. 'â°»' => 'â°‹',
  62136. 'ⰼ' => 'Ⰼ',
  62137. 'â°½' => 'â°�',
  62138. 'â°¾' => 'â°Ž',
  62139. 'â°¿' => 'â°�',
  62140. 'â±€' => 'â°�',
  62141. '�' => 'Ⱁ',
  62142. 'ⱂ' => 'Ⱂ',
  62143. 'ⱃ' => 'Ⱃ',
  62144. 'ⱄ' => 'Ⱄ',
  62145. 'â±…' => 'â°•',
  62146. 'ⱆ' => 'Ⱆ',
  62147. 'ⱇ' => 'Ⱇ',
  62148. 'ⱈ' => 'Ⱈ',
  62149. 'ⱉ' => 'Ⱉ',
  62150. 'ⱊ' => 'Ⱊ',
  62151. 'ⱋ' => 'Ⱋ',
  62152. 'ⱌ' => 'Ⱌ',
  62153. '�' => '�',
  62154. 'ⱎ' => 'Ⱎ',
  62155. '�' => 'Ⱏ',
  62156. '�' => 'Ⱐ',
  62157. 'ⱑ' => 'Ⱑ',
  62158. 'â±’' => 'â°¢',
  62159. 'ⱓ' => 'Ⱓ',
  62160. 'â±”' => 'â°¤',
  62161. 'ⱕ' => 'Ⱕ',
  62162. 'â±–' => 'â°¦',
  62163. 'â±—' => 'â°§',
  62164. 'ⱘ' => 'Ⱘ',
  62165. 'â±™' => 'â°©',
  62166. 'ⱚ' => 'Ⱚ',
  62167. 'â±›' => 'â°«',
  62168. 'ⱜ' => 'Ⱜ',
  62169. '�' => 'Ⱝ',
  62170. 'ⱞ' => 'Ⱞ',
  62171. 'ⱡ' => 'Ⱡ',
  62172. 'ⱥ' => 'Ⱥ',
  62173. 'ⱦ' => 'Ⱦ',
  62174. 'ⱨ' => 'Ⱨ',
  62175. 'ⱪ' => 'Ⱪ',
  62176. 'ⱬ' => 'Ⱬ',
  62177. 'â±³' => 'â±²',
  62178. 'ⱶ' => 'Ⱶ',
  62179. '�' => 'Ⲁ',
  62180. 'ⲃ' => 'Ⲃ',
  62181. 'ⲅ' => 'Ⲅ',
  62182. 'ⲇ' => 'Ⲇ',
  62183. 'ⲉ' => 'Ⲉ',
  62184. 'ⲋ' => 'Ⲋ',
  62185. '�' => 'Ⲍ',
  62186. '�' => 'Ⲏ',
  62187. 'ⲑ' => '�',
  62188. 'ⲓ' => 'Ⲓ',
  62189. 'ⲕ' => 'Ⲕ',
  62190. 'â²—' => 'â²–',
  62191. 'ⲙ' => 'Ⲙ',
  62192. 'ⲛ' => 'Ⲛ',
  62193. '�' => 'Ⲝ',
  62194. 'ⲟ' => 'Ⲟ',
  62195. 'ⲡ' => 'Ⲡ',
  62196. 'â²£' => 'â²¢',
  62197. 'ⲥ' => 'Ⲥ',
  62198. 'ⲧ' => 'Ⲧ',
  62199. 'ⲩ' => 'Ⲩ',
  62200. 'ⲫ' => 'Ⲫ',
  62201. 'ⲭ' => 'Ⲭ',
  62202. 'ⲯ' => 'Ⲯ',
  62203. 'â²±' => 'â²°',
  62204. 'â²³' => 'â²²',
  62205. 'â²µ' => 'â²´',
  62206. 'ⲷ' => 'Ⲷ',
  62207. 'ⲹ' => 'Ⲹ',
  62208. 'ⲻ' => 'Ⲻ',
  62209. 'â²½' => 'â²¼',
  62210. 'ⲿ' => 'Ⲿ',
  62211. '�' => 'Ⳁ',
  62212. 'ⳃ' => 'Ⳃ',
  62213. 'ⳅ' => 'Ⳅ',
  62214. 'ⳇ' => 'Ⳇ',
  62215. 'ⳉ' => 'Ⳉ',
  62216. 'ⳋ' => 'Ⳋ',
  62217. '�' => 'Ⳍ',
  62218. '�' => 'Ⳏ',
  62219. 'ⳑ' => '�',
  62220. 'ⳓ' => 'Ⳓ',
  62221. 'ⳕ' => 'Ⳕ',
  62222. 'â³—' => 'â³–',
  62223. 'ⳙ' => 'Ⳙ',
  62224. 'ⳛ' => 'Ⳛ',
  62225. '�' => 'Ⳝ',
  62226. 'ⳟ' => 'Ⳟ',
  62227. 'ⳡ' => 'Ⳡ',
  62228. 'â³£' => 'â³¢',
  62229. 'ⳬ' => 'Ⳬ',
  62230. 'â³®' => 'â³­',
  62231. 'â³³' => 'â³²',
  62232. 'â´€' => 'á‚ ',
  62233. 'â´�' => 'á‚¡',
  62234. 'â´‚' => 'á‚¢',
  62235. 'â´ƒ' => 'á‚£',
  62236. 'ⴄ' => 'Ⴄ',
  62237. 'â´…' => 'á‚¥',
  62238. 'ⴆ' => 'Ⴆ',
  62239. 'ⴇ' => 'Ⴇ',
  62240. 'ⴈ' => 'Ⴈ',
  62241. 'â´‰' => 'á‚©',
  62242. 'ⴊ' => 'Ⴊ',
  62243. 'â´‹' => 'á‚«',
  62244. 'ⴌ' => 'Ⴌ',
  62245. 'â´�' => 'á‚­',
  62246. 'â´Ž' => 'á‚®',
  62247. '�' => 'Ⴏ',
  62248. 'â´�' => 'á‚°',
  62249. 'ⴑ' => 'Ⴑ',
  62250. 'ⴒ' => 'Ⴒ',
  62251. 'ⴓ' => 'Ⴓ',
  62252. 'â´”' => 'á‚´',
  62253. 'ⴕ' => 'Ⴕ',
  62254. 'ⴖ' => 'Ⴖ',
  62255. 'â´—' => 'á‚·',
  62256. 'ⴘ' => 'Ⴘ',
  62257. 'ⴙ' => 'Ⴙ',
  62258. 'ⴚ' => 'Ⴚ',
  62259. 'â´›' => 'á‚»',
  62260. 'ⴜ' => 'Ⴜ',
  62261. '�' => 'Ⴝ',
  62262. 'ⴞ' => 'Ⴞ',
  62263. 'â´Ÿ' => 'á‚¿',
  62264. 'ⴠ' => 'Ⴠ',
  62265. 'ⴡ' => '�',
  62266. 'ⴢ' => 'Ⴢ',
  62267. 'ⴣ' => 'Ⴣ',
  62268. 'ⴤ' => 'Ⴤ',
  62269. 'ⴥ' => 'Ⴥ',
  62270. 'ⴧ' => 'Ⴧ',
  62271. 'ⴭ' => '�',
  62272. '�' => 'Ꙁ',
  62273. 'ꙃ' => 'Ꙃ',
  62274. 'ꙅ' => 'Ꙅ',
  62275. 'ꙇ' => 'Ꙇ',
  62276. 'ꙉ' => 'Ꙉ',
  62277. 'ꙋ' => 'Ꙋ',
  62278. '�' => 'Ꙍ',
  62279. '�' => 'Ꙏ',
  62280. 'ꙑ' => '�',
  62281. 'ꙓ' => 'Ꙓ',
  62282. 'ꙕ' => 'Ꙕ',
  62283. 'ê™—' => 'ê™–',
  62284. 'ꙙ' => 'Ꙙ',
  62285. 'ꙛ' => 'Ꙛ',
  62286. '�' => 'Ꙝ',
  62287. 'ꙟ' => 'Ꙟ',
  62288. 'ꙡ' => 'Ꙡ',
  62289. 'ꙣ' => 'Ꙣ',
  62290. 'ꙥ' => 'Ꙥ',
  62291. 'ꙧ' => 'Ꙧ',
  62292. 'ꙩ' => 'Ꙩ',
  62293. 'ꙫ' => 'Ꙫ',
  62294. 'ꙭ' => 'Ꙭ',
  62295. '�' => 'Ꚁ',
  62296. 'ꚃ' => 'Ꚃ',
  62297. 'êš…' => 'êš„',
  62298. 'ꚇ' => 'Ꚇ',
  62299. 'ꚉ' => 'Ꚉ',
  62300. 'ꚋ' => 'Ꚋ',
  62301. '�' => 'Ꚍ',
  62302. '�' => 'Ꚏ',
  62303. 'ꚑ' => '�',
  62304. 'êš“' => 'êš’',
  62305. 'êš•' => 'êš”',
  62306. 'êš—' => 'êš–',
  62307. 'ꚙ' => 'Ꚙ',
  62308. 'êš›' => 'êšš',
  62309. 'ꜣ' => 'Ꜣ',
  62310. 'ꜥ' => 'Ꜥ',
  62311. 'ꜧ' => 'Ꜧ',
  62312. 'ꜩ' => 'Ꜩ',
  62313. 'ꜫ' => 'Ꜫ',
  62314. 'ꜭ' => 'Ꜭ',
  62315. 'ꜯ' => 'Ꜯ',
  62316. 'ꜳ' => 'Ꜳ',
  62317. 'ꜵ' => 'Ꜵ',
  62318. 'ꜷ' => 'Ꜷ',
  62319. 'ꜹ' => 'Ꜹ',
  62320. 'ꜻ' => 'Ꜻ',
  62321. 'ꜽ' => 'Ꜽ',
  62322. 'ꜿ' => 'Ꜿ',
  62323. '�' => '�',
  62324. '�' => '�',
  62325. '�' => '�',
  62326. '�' => '�',
  62327. '�' => '�',
  62328. '�' => '�',
  62329. '�' => '�',
  62330. '�' => '�',
  62331. '�' => '�',
  62332. '�' => '�',
  62333. '�' => '�',
  62334. '�' => '�',
  62335. '�' => '�',
  62336. '�' => '�',
  62337. '�' => '�',
  62338. '�' => '�',
  62339. '�' => '�',
  62340. '�' => '�',
  62341. '�' => '�',
  62342. '�' => '�',
  62343. '�' => '�',
  62344. '�' => '�',
  62345. '�' => '�',
  62346. '�' => '�',
  62347. '�' => '�',
  62348. '�' => '�',
  62349. '�' => '�',
  62350. '�' => 'Ꞁ',
  62351. 'ꞃ' => 'Ꞃ',
  62352. 'êž…' => 'êž„',
  62353. 'ꞇ' => 'Ꞇ',
  62354. 'ꞌ' => 'Ꞌ',
  62355. 'ꞑ' => '�',
  62356. 'êž“' => 'êž’',
  62357. 'ꞔ' => 'Ꞔ',
  62358. 'êž—' => 'êž–',
  62359. 'ꞙ' => 'Ꞙ',
  62360. 'êž›' => 'êžš',
  62361. '�' => 'Ꞝ',
  62362. 'ꞟ' => 'Ꞟ',
  62363. 'êž¡' => 'êž ',
  62364. 'ꞣ' => 'Ꞣ',
  62365. 'ꞥ' => 'Ꞥ',
  62366. 'ꞧ' => 'Ꞧ',
  62367. 'ꞩ' => 'Ꞩ',
  62368. 'êžµ' => 'êž´',
  62369. 'ꞷ' => 'Ꞷ',
  62370. 'ꞹ' => 'Ꞹ',
  62371. 'ꞻ' => 'Ꞻ',
  62372. 'êž½' => 'êž¼',
  62373. 'êž¿' => 'êž¾',
  62374. 'ꟃ' => 'Ꟃ',
  62375. 'ꟈ' => 'Ꟈ',
  62376. 'ꟊ' => 'Ꟊ',
  62377. 'ꟶ' => 'Ꟶ',
  62378. 'ê­“' => 'êž³',
  62379. 'ꭰ' => 'Ꭰ',
  62380. 'ꭱ' => 'Ꭱ',
  62381. 'ꭲ' => 'Ꭲ',
  62382. 'ꭳ' => 'Ꭳ',
  62383. 'ꭴ' => 'Ꭴ',
  62384. 'ꭵ' => 'Ꭵ',
  62385. 'ꭶ' => 'Ꭶ',
  62386. 'ꭷ' => 'Ꭷ',
  62387. 'ꭸ' => 'Ꭸ',
  62388. 'ꭹ' => 'Ꭹ',
  62389. 'ꭺ' => 'Ꭺ',
  62390. 'ꭻ' => 'Ꭻ',
  62391. 'ꭼ' => 'Ꭼ',
  62392. 'ꭽ' => 'Ꭽ',
  62393. 'ꭾ' => 'Ꭾ',
  62394. 'ꭿ' => 'Ꭿ',
  62395. 'ꮀ' => 'Ꮀ',
  62396. '�' => 'Ꮁ',
  62397. 'ꮂ' => 'Ꮂ',
  62398. 'ꮃ' => 'Ꮃ',
  62399. 'ꮄ' => 'Ꮄ',
  62400. 'ꮅ' => 'Ꮅ',
  62401. 'ꮆ' => 'Ꮆ',
  62402. 'ꮇ' => 'Ꮇ',
  62403. 'ꮈ' => 'Ꮈ',
  62404. 'ꮉ' => 'Ꮉ',
  62405. 'ꮊ' => 'Ꮊ',
  62406. 'ꮋ' => 'Ꮋ',
  62407. 'ꮌ' => 'Ꮌ',
  62408. '�' => 'Ꮍ',
  62409. 'ꮎ' => 'Ꮎ',
  62410. '�' => 'Ꮏ',
  62411. '�' => '�',
  62412. 'ꮑ' => '�',
  62413. 'ꮒ' => '�',
  62414. 'ꮓ' => '�',
  62415. 'ꮔ' => '�',
  62416. 'ꮕ' => '�',
  62417. 'ꮖ' => '�',
  62418. 'ꮗ' => '�',
  62419. 'ꮘ' => '�',
  62420. 'ꮙ' => '�',
  62421. 'ꮚ' => '�',
  62422. 'ꮛ' => '�',
  62423. 'ꮜ' => '�',
  62424. '�' => '�',
  62425. 'ꮞ' => '�',
  62426. 'ꮟ' => '�',
  62427. 'ꮠ' => '�',
  62428. 'ꮡ' => '�',
  62429. 'ꮢ' => '�',
  62430. 'ꮣ' => '�',
  62431. 'ꮤ' => '�',
  62432. 'ꮥ' => '�',
  62433. 'ꮦ' => '�',
  62434. 'ꮧ' => '�',
  62435. 'ꮨ' => '�',
  62436. 'ꮩ' => '�',
  62437. 'ꮪ' => '�',
  62438. 'ꮫ' => '�',
  62439. 'ꮬ' => '�',
  62440. 'ꮭ' => '�',
  62441. 'ꮮ' => '�',
  62442. 'ꮯ' => '�',
  62443. 'ꮰ' => '�',
  62444. 'ꮱ' => '�',
  62445. 'ꮲ' => '�',
  62446. 'ꮳ' => '�',
  62447. 'ꮴ' => '�',
  62448. 'ꮵ' => '�',
  62449. 'ꮶ' => '�',
  62450. 'ꮷ' => '�',
  62451. 'ꮸ' => '�',
  62452. 'ꮹ' => '�',
  62453. 'ꮺ' => '�',
  62454. 'ꮻ' => '�',
  62455. 'ꮼ' => '�',
  62456. 'ꮽ' => '�',
  62457. 'ꮾ' => '�',
  62458. 'ꮿ' => '�',
  62459. '�' => 'A',
  62460. 'b' => 'B',
  62461. 'c' => 'C',
  62462. 'd' => 'D',
  62463. 'ï½…' => 'ï¼¥',
  62464. 'f' => 'F',
  62465. 'g' => 'G',
  62466. 'h' => 'H',
  62467. 'i' => 'I',
  62468. 'j' => 'J',
  62469. 'k' => 'K',
  62470. 'l' => 'L',
  62471. '�' => 'M',
  62472. 'n' => 'N',
  62473. '�' => 'O',
  62474. '�' => 'P',
  62475. 'q' => 'Q',
  62476. 'ï½’' => 'ï¼²',
  62477. 's' => 'S',
  62478. 'ï½”' => 'ï¼´',
  62479. 'u' => 'U',
  62480. 'v' => 'V',
  62481. 'ï½—' => 'ï¼·',
  62482. 'x' => 'X',
  62483. 'ï½™' => 'ï¼¹',
  62484. 'z' => 'Z',
  62485. '�' => '�',
  62486. '�' => '�',
  62487. '�' => '�',
  62488. '�' => '�',
  62489. '�' => '�',
  62490. '�' => '�',
  62491. '�' => '�',
  62492. '�' => '�',
  62493. '�' => '�',
  62494. '�' => '�',
  62495. '�' => '�',
  62496. '�' => '�',
  62497. '�' => '�',
  62498. '�' => '�',
  62499. '�' => '�',
  62500. '�' => '�',
  62501. '�' => '�',
  62502. '�' => '�',
  62503. '�' => '�',
  62504. '�' => '�',
  62505. '�' => '�',
  62506. '�' => '�',
  62507. '�' => '�',
  62508. '�' => '�',
  62509. '�' => '�',
  62510. '�' => '�',
  62511. '�' => '�',
  62512. '�' => '�',
  62513. '�' => '�',
  62514. '�' => '�',
  62515. '�' => '�',
  62516. '�' => '�',
  62517. '�' => '�',
  62518. '�' => '�',
  62519. '�' => '�',
  62520. '�' => '�',
  62521. '�' => '�',
  62522. '�' => '�',
  62523. '�' => '�',
  62524. '�' => '�',
  62525. '�' => '�',
  62526. '�' => '�',
  62527. '�' => '�',
  62528. '�' => '�',
  62529. '�' => '�',
  62530. '�' => '�',
  62531. '�' => '�',
  62532. '�' => '�',
  62533. '�' => '�',
  62534. '�' => '�',
  62535. '�' => '�',
  62536. '�' => '�',
  62537. '�' => '�',
  62538. '�' => '�',
  62539. '�' => '�',
  62540. '�' => '�',
  62541. '�' => '�',
  62542. '�' => '�',
  62543. '�' => '�',
  62544. '�' => '�',
  62545. '�' => '�',
  62546. '�' => '�',
  62547. '�' => '�',
  62548. '�' => '�',
  62549. '�' => '�',
  62550. '�' => '�',
  62551. '�' => '�',
  62552. '�' => '�',
  62553. '�' => '�',
  62554. '�' => '�',
  62555. '�' => '�',
  62556. '�' => '�',
  62557. '�' => '�',
  62558. '�' => '�',
  62559. '�' => '�',
  62560. '�' => '�',
  62561. '�' => '�',
  62562. '�' => '�',
  62563. '�' => '�',
  62564. '�' => '�',
  62565. '�' => '�',
  62566. '�' => '�',
  62567. '�' => '�',
  62568. '�' => '�',
  62569. '�' => '�',
  62570. '�' => '�',
  62571. '�' => '�',
  62572. '�' => '�',
  62573. '�' => '�',
  62574. '�' => '�',
  62575. '�' => '�',
  62576. '�' => '�',
  62577. '�' => '�',
  62578. '�' => '�',
  62579. '�' => '�',
  62580. '�' => '�',
  62581. '�' => '�',
  62582. '�' => '�',
  62583. '�' => '�',
  62584. '�' => '�',
  62585. '�' => '�',
  62586. '�' => '�',
  62587. '�' => '�',
  62588. '�' => '�',
  62589. '�' => '�',
  62590. '�' => '�',
  62591. '�' => '�',
  62592. '�' => '�',
  62593. '�' => '�',
  62594. '�' => '�',
  62595. '�' => '�',
  62596. '�' => '�',
  62597. '�' => '�',
  62598. '�' => '�',
  62599. '�' => '�',
  62600. '�' => '�',
  62601. '�' => '�',
  62602. '�' => '�',
  62603. '�' => '�',
  62604. '�' => '�',
  62605. '�' => '�',
  62606. '�' => '�',
  62607. '�' => '�',
  62608. '�' => '�',
  62609. '�' => '�',
  62610. '�' => '�',
  62611. '�' => '�',
  62612. 'ð‘£€' => 'ð‘¢ ',
  62613. '�' => '𑢡',
  62614. '𑣂' => '𑢢',
  62615. '𑣃' => '𑢣',
  62616. '𑣄' => '𑢤',
  62617. 'ð‘£…' => 'ð‘¢¥',
  62618. '𑣆' => '𑢦',
  62619. '𑣇' => '𑢧',
  62620. '𑣈' => '𑢨',
  62621. '𑣉' => '𑢩',
  62622. '𑣊' => '𑢪',
  62623. '𑣋' => '𑢫',
  62624. '𑣌' => '𑢬',
  62625. '�' => '𑢭',
  62626. '𑣎' => '𑢮',
  62627. '�' => '𑢯',
  62628. '�' => '𑢰',
  62629. '𑣑' => '𑢱',
  62630. 'ð‘£’' => 'ð‘¢²',
  62631. '𑣓' => '𑢳',
  62632. 'ð‘£”' => 'ð‘¢´',
  62633. '𑣕' => '𑢵',
  62634. '𑣖' => '𑢶',
  62635. 'ð‘£—' => 'ð‘¢·',
  62636. '𑣘' => '𑢸',
  62637. 'ð‘£™' => 'ð‘¢¹',
  62638. '𑣚' => '𑢺',
  62639. 'ð‘£›' => 'ð‘¢»',
  62640. '𑣜' => '𑢼',
  62641. '�' => '𑢽',
  62642. '𑣞' => '𑢾',
  62643. '𑣟' => '𑢿',
  62644. 'ð–¹ ' => 'ð–¹€',
  62645. '𖹡' => '�',
  62646. '𖹢' => '𖹂',
  62647. '𖹣' => '𖹃',
  62648. '𖹤' => '𖹄',
  62649. 'ð–¹¥' => 'ð–¹…',
  62650. '𖹦' => '𖹆',
  62651. '𖹧' => '𖹇',
  62652. '𖹨' => '𖹈',
  62653. '𖹩' => '𖹉',
  62654. '𖹪' => '𖹊',
  62655. '𖹫' => '𖹋',
  62656. '𖹬' => '𖹌',
  62657. '𖹭' => '�',
  62658. '𖹮' => '𖹎',
  62659. '𖹯' => '�',
  62660. '𖹰' => '�',
  62661. '𖹱' => '𖹑',
  62662. 'ð–¹²' => 'ð–¹’',
  62663. '𖹳' => '𖹓',
  62664. 'ð–¹´' => 'ð–¹”',
  62665. '𖹵' => '𖹕',
  62666. '𖹶' => '𖹖',
  62667. 'ð–¹·' => 'ð–¹—',
  62668. '𖹸' => '𖹘',
  62669. 'ð–¹¹' => 'ð–¹™',
  62670. '𖹺' => '𖹚',
  62671. 'ð–¹»' => 'ð–¹›',
  62672. '𖹼' => '𖹜',
  62673. '𖹽' => '�',
  62674. '𖹾' => '𖹞',
  62675. '𖹿' => '𖹟',
  62676. '𞤢' => '𞤀',
  62677. '𞤣' => '�',
  62678. '𞤤' => '𞤂',
  62679. '𞤥' => '𞤃',
  62680. '𞤦' => '𞤄',
  62681. '𞤧' => '𞤅',
  62682. '𞤨' => '𞤆',
  62683. '𞤩' => '𞤇',
  62684. '𞤪' => '𞤈',
  62685. '𞤫' => '𞤉',
  62686. '𞤬' => '𞤊',
  62687. '𞤭' => '𞤋',
  62688. '𞤮' => '𞤌',
  62689. '𞤯' => '�',
  62690. '𞤰' => '𞤎',
  62691. '𞤱' => '�',
  62692. '𞤲' => '�',
  62693. '𞤳' => '𞤑',
  62694. '𞤴' => '𞤒',
  62695. '𞤵' => '𞤓',
  62696. '𞤶' => '𞤔',
  62697. '𞤷' => '𞤕',
  62698. '𞤸' => '𞤖',
  62699. '𞤹' => '𞤗',
  62700. '𞤺' => '𞤘',
  62701. '𞤻' => '𞤙',
  62702. '𞤼' => '𞤚',
  62703. '𞤽' => '𞤛',
  62704. '𞤾' => '𞤜',
  62705. '𞤿' => '�',
  62706. '𞥀' => '𞤞',
  62707. '�' => '𞤟',
  62708. '𞥂' => '𞤠',
  62709. '𞥃' => '𞤡',
  62710. );
  62711. <?php
  62712. use Symfony\Polyfill\Mbstring as p;
  62713. if (!function_exists('mb_convert_encoding')) {
  62714. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  62715. }
  62716. if (!function_exists('mb_decode_mimeheader')) {
  62717. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  62718. }
  62719. if (!function_exists('mb_encode_mimeheader')) {
  62720. function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); }
  62721. }
  62722. if (!function_exists('mb_decode_numericentity')) {
  62723. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  62724. }
  62725. if (!function_exists('mb_encode_numericentity')) {
  62726. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  62727. }
  62728. if (!function_exists('mb_convert_case')) {
  62729. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  62730. }
  62731. if (!function_exists('mb_internal_encoding')) {
  62732. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  62733. }
  62734. if (!function_exists('mb_language')) {
  62735. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  62736. }
  62737. if (!function_exists('mb_list_encodings')) {
  62738. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  62739. }
  62740. if (!function_exists('mb_encoding_aliases')) {
  62741. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  62742. }
  62743. if (!function_exists('mb_check_encoding')) {
  62744. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  62745. }
  62746. if (!function_exists('mb_detect_encoding')) {
  62747. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  62748. }
  62749. if (!function_exists('mb_detect_order')) {
  62750. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  62751. }
  62752. if (!function_exists('mb_parse_str')) {
  62753. function mb_parse_str($string, &$result = array()) { parse_str($string, $result); }
  62754. }
  62755. if (!function_exists('mb_strlen')) {
  62756. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  62757. }
  62758. if (!function_exists('mb_strpos')) {
  62759. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  62760. }
  62761. if (!function_exists('mb_strtolower')) {
  62762. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  62763. }
  62764. if (!function_exists('mb_strtoupper')) {
  62765. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  62766. }
  62767. if (!function_exists('mb_substitute_character')) {
  62768. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  62769. }
  62770. if (!function_exists('mb_substr')) {
  62771. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  62772. }
  62773. if (!function_exists('mb_stripos')) {
  62774. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  62775. }
  62776. if (!function_exists('mb_stristr')) {
  62777. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  62778. }
  62779. if (!function_exists('mb_strrchr')) {
  62780. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  62781. }
  62782. if (!function_exists('mb_strrichr')) {
  62783. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  62784. }
  62785. if (!function_exists('mb_strripos')) {
  62786. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  62787. }
  62788. if (!function_exists('mb_strrpos')) {
  62789. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  62790. }
  62791. if (!function_exists('mb_strstr')) {
  62792. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  62793. }
  62794. if (!function_exists('mb_get_info')) {
  62795. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  62796. }
  62797. if (!function_exists('mb_http_output')) {
  62798. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  62799. }
  62800. if (!function_exists('mb_strwidth')) {
  62801. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  62802. }
  62803. if (!function_exists('mb_substr_count')) {
  62804. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  62805. }
  62806. if (!function_exists('mb_output_handler')) {
  62807. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  62808. }
  62809. if (!function_exists('mb_http_input')) {
  62810. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  62811. }
  62812. if (PHP_VERSION_ID >= 80000) {
  62813. require_once __DIR__.'/Resources/mb_convert_variables.php8';
  62814. } elseif (!function_exists('mb_convert_variables')) {
  62815. function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null) { return p\Mbstring::mb_convert_variables($toEncoding, $fromEncoding, $a, $b, $c, $d, $e, $f); }
  62816. }
  62817. if (!function_exists('mb_ord')) {
  62818. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  62819. }
  62820. if (!function_exists('mb_chr')) {
  62821. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  62822. }
  62823. if (!function_exists('mb_scrub')) {
  62824. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  62825. }
  62826. if (!function_exists('mb_str_split')) {
  62827. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  62828. }
  62829. if (extension_loaded('mbstring')) {
  62830. return;
  62831. }
  62832. if (!defined('MB_CASE_UPPER')) {
  62833. define('MB_CASE_UPPER', 0);
  62834. }
  62835. if (!defined('MB_CASE_LOWER')) {
  62836. define('MB_CASE_LOWER', 1);
  62837. }
  62838. if (!defined('MB_CASE_TITLE')) {
  62839. define('MB_CASE_TITLE', 2);
  62840. }
  62841. <?php
  62842. namespace Symfony\Component\Process\Exception;
  62843. interface ExceptionInterface
  62844. {
  62845. }
  62846. <?php
  62847. namespace Symfony\Component\Process\Exception;
  62848. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  62849. {
  62850. }
  62851. <?php
  62852. namespace Symfony\Component\Process\Exception;
  62853. class LogicException extends \LogicException implements ExceptionInterface
  62854. {
  62855. }
  62856. <?php
  62857. namespace Symfony\Component\Process\Exception;
  62858. use Symfony\Component\Process\Process;
  62859. class ProcessFailedException extends RuntimeException
  62860. {
  62861. private $process;
  62862. public function __construct(Process $process)
  62863. {
  62864. if ($process->isSuccessful()) {
  62865. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  62866. }
  62867. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  62868. $process->getCommandLine(),
  62869. $process->getExitCode(),
  62870. $process->getExitCodeText(),
  62871. $process->getWorkingDirectory()
  62872. );
  62873. if (!$process->isOutputDisabled()) {
  62874. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  62875. $process->getOutput(),
  62876. $process->getErrorOutput()
  62877. );
  62878. }
  62879. parent::__construct($error);
  62880. $this->process = $process;
  62881. }
  62882. public function getProcess()
  62883. {
  62884. return $this->process;
  62885. }
  62886. }
  62887. <?php
  62888. namespace Symfony\Component\Process\Exception;
  62889. use Symfony\Component\Process\Process;
  62890. class ProcessTimedOutException extends RuntimeException
  62891. {
  62892. const TYPE_GENERAL = 1;
  62893. const TYPE_IDLE = 2;
  62894. private $process;
  62895. private $timeoutType;
  62896. public function __construct(Process $process, $timeoutType)
  62897. {
  62898. $this->process = $process;
  62899. $this->timeoutType = $timeoutType;
  62900. parent::__construct(sprintf(
  62901. 'The process "%s" exceeded the timeout of %s seconds.',
  62902. $process->getCommandLine(),
  62903. $this->getExceededTimeout()
  62904. ));
  62905. }
  62906. public function getProcess()
  62907. {
  62908. return $this->process;
  62909. }
  62910. public function isGeneralTimeout()
  62911. {
  62912. return self::TYPE_GENERAL === $this->timeoutType;
  62913. }
  62914. public function isIdleTimeout()
  62915. {
  62916. return self::TYPE_IDLE === $this->timeoutType;
  62917. }
  62918. public function getExceededTimeout()
  62919. {
  62920. switch ($this->timeoutType) {
  62921. case self::TYPE_GENERAL:
  62922. return $this->process->getTimeout();
  62923. case self::TYPE_IDLE:
  62924. return $this->process->getIdleTimeout();
  62925. default:
  62926. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  62927. }
  62928. }
  62929. }
  62930. <?php
  62931. namespace Symfony\Component\Process\Exception;
  62932. class RuntimeException extends \RuntimeException implements ExceptionInterface
  62933. {
  62934. }
  62935. <?php
  62936. namespace Symfony\Component\Process;
  62937. class ExecutableFinder
  62938. {
  62939. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  62940. public function setSuffixes(array $suffixes)
  62941. {
  62942. $this->suffixes = $suffixes;
  62943. }
  62944. public function addSuffix($suffix)
  62945. {
  62946. $this->suffixes[] = $suffix;
  62947. }
  62948. public function find($name, $default = null, array $extraDirs = array())
  62949. {
  62950. if (ini_get('open_basedir')) {
  62951. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  62952. $dirs = array();
  62953. foreach ($searchPath as $path) {
  62954. if (@is_dir($path)) {
  62955. $dirs[] = $path;
  62956. } else {
  62957. if (basename($path) == $name && @is_executable($path)) {
  62958. return $path;
  62959. }
  62960. }
  62961. }
  62962. } else {
  62963. $dirs = array_merge(
  62964. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  62965. $extraDirs
  62966. );
  62967. }
  62968. $suffixes = array('');
  62969. if ('\\' === \DIRECTORY_SEPARATOR) {
  62970. $pathExt = getenv('PATHEXT');
  62971. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  62972. }
  62973. foreach ($suffixes as $suffix) {
  62974. foreach ($dirs as $dir) {
  62975. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  62976. return $file;
  62977. }
  62978. }
  62979. }
  62980. return $default;
  62981. }
  62982. }
  62983. Copyright (c) 2004-2018 Fabien Potencier
  62984. Permission is hereby granted, free of charge, to any person obtaining a copy
  62985. of this software and associated documentation files (the "Software"), to deal
  62986. in the Software without restriction, including without limitation the rights
  62987. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62988. copies of the Software, and to permit persons to whom the Software is furnished
  62989. to do so, subject to the following conditions:
  62990. The above copyright notice and this permission notice shall be included in all
  62991. copies or substantial portions of the Software.
  62992. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62993. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62994. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62995. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62996. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62997. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62998. THE SOFTWARE.
  62999. <?php
  63000. namespace Symfony\Component\Process;
  63001. class PhpExecutableFinder
  63002. {
  63003. private $executableFinder;
  63004. public function __construct()
  63005. {
  63006. $this->executableFinder = new ExecutableFinder();
  63007. }
  63008. public function find($includeArgs = true)
  63009. {
  63010. $args = $this->findArguments();
  63011. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  63012. if (\defined('HHVM_VERSION')) {
  63013. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  63014. }
  63015. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  63016. return PHP_BINARY.$args;
  63017. }
  63018. if ($php = getenv('PHP_PATH')) {
  63019. if (!@is_executable($php)) {
  63020. return false;
  63021. }
  63022. return $php;
  63023. }
  63024. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  63025. if (@is_executable($php)) {
  63026. return $php;
  63027. }
  63028. }
  63029. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  63030. return $php;
  63031. }
  63032. $dirs = array(PHP_BINDIR);
  63033. if ('\\' === \DIRECTORY_SEPARATOR) {
  63034. $dirs[] = 'C:\xampp\php\\';
  63035. }
  63036. return $this->executableFinder->find('php', false, $dirs);
  63037. }
  63038. public function findArguments()
  63039. {
  63040. $arguments = array();
  63041. if (\defined('HHVM_VERSION')) {
  63042. $arguments[] = '--php';
  63043. } elseif ('phpdbg' === \PHP_SAPI) {
  63044. $arguments[] = '-qrr';
  63045. }
  63046. return $arguments;
  63047. }
  63048. }
  63049. <?php
  63050. namespace Symfony\Component\Process;
  63051. use Symfony\Component\Process\Exception\RuntimeException;
  63052. class PhpProcess extends Process
  63053. {
  63054. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  63055. {
  63056. $executableFinder = new PhpExecutableFinder();
  63057. if (false === $php = $executableFinder->find()) {
  63058. $php = null;
  63059. }
  63060. if ('phpdbg' === \PHP_SAPI) {
  63061. $file = tempnam(sys_get_temp_dir(), 'dbg');
  63062. file_put_contents($file, $script);
  63063. register_shutdown_function('unlink', $file);
  63064. $php .= ' '.ProcessUtils::escapeArgument($file);
  63065. $script = null;
  63066. }
  63067. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  63068. $php = 'exec '.$php;
  63069. }
  63070. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  63071. }
  63072. public function setPhpBinary($php)
  63073. {
  63074. $this->setCommandLine($php);
  63075. }
  63076. public function start($callback = null)
  63077. {
  63078. if (null === $this->getCommandLine()) {
  63079. throw new RuntimeException('Unable to find the PHP executable.');
  63080. }
  63081. parent::start($callback);
  63082. }
  63083. }
  63084. <?php
  63085. namespace Symfony\Component\Process\Pipes;
  63086. abstract class AbstractPipes implements PipesInterface
  63087. {
  63088. public $pipes = array();
  63089. private $inputBuffer = '';
  63090. private $input;
  63091. private $blocked = true;
  63092. private $lastError;
  63093. public function __construct($input)
  63094. {
  63095. if (\is_resource($input)) {
  63096. $this->input = $input;
  63097. } elseif (\is_string($input)) {
  63098. $this->inputBuffer = $input;
  63099. } else {
  63100. $this->inputBuffer = (string) $input;
  63101. }
  63102. }
  63103. public function close()
  63104. {
  63105. foreach ($this->pipes as $pipe) {
  63106. fclose($pipe);
  63107. }
  63108. $this->pipes = array();
  63109. }
  63110. protected function hasSystemCallBeenInterrupted()
  63111. {
  63112. $lastError = $this->lastError;
  63113. $this->lastError = null;
  63114. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  63115. }
  63116. protected function unblock()
  63117. {
  63118. if (!$this->blocked) {
  63119. return;
  63120. }
  63121. foreach ($this->pipes as $pipe) {
  63122. stream_set_blocking($pipe, 0);
  63123. }
  63124. if (null !== $this->input) {
  63125. stream_set_blocking($this->input, 0);
  63126. }
  63127. $this->blocked = false;
  63128. }
  63129. protected function write()
  63130. {
  63131. if (!isset($this->pipes[0])) {
  63132. return;
  63133. }
  63134. $input = $this->input;
  63135. $r = $e = array();
  63136. $w = array($this->pipes[0]);
  63137. if (false === @stream_select($r, $w, $e, 0, 0)) {
  63138. return;
  63139. }
  63140. foreach ($w as $stdin) {
  63141. if (isset($this->inputBuffer[0])) {
  63142. $written = fwrite($stdin, $this->inputBuffer);
  63143. $this->inputBuffer = substr($this->inputBuffer, $written);
  63144. if (isset($this->inputBuffer[0])) {
  63145. return array($this->pipes[0]);
  63146. }
  63147. }
  63148. if ($input) {
  63149. for (;;) {
  63150. $data = fread($input, self::CHUNK_SIZE);
  63151. if (!isset($data[0])) {
  63152. break;
  63153. }
  63154. $written = fwrite($stdin, $data);
  63155. $data = substr($data, $written);
  63156. if (isset($data[0])) {
  63157. $this->inputBuffer = $data;
  63158. return array($this->pipes[0]);
  63159. }
  63160. }
  63161. if (feof($input)) {
  63162. $this->input = null;
  63163. }
  63164. }
  63165. }
  63166. if (null === $this->input && !isset($this->inputBuffer[0])) {
  63167. fclose($this->pipes[0]);
  63168. unset($this->pipes[0]);
  63169. } elseif (!$w) {
  63170. return array($this->pipes[0]);
  63171. }
  63172. }
  63173. public function handleError($type, $msg)
  63174. {
  63175. $this->lastError = $msg;
  63176. }
  63177. }
  63178. <?php
  63179. namespace Symfony\Component\Process\Pipes;
  63180. interface PipesInterface
  63181. {
  63182. const CHUNK_SIZE = 16384;
  63183. public function getDescriptors();
  63184. public function getFiles();
  63185. public function readAndWrite($blocking, $close = false);
  63186. public function areOpen();
  63187. public function close();
  63188. }
  63189. <?php
  63190. namespace Symfony\Component\Process\Pipes;
  63191. use Symfony\Component\Process\Process;
  63192. class UnixPipes extends AbstractPipes
  63193. {
  63194. private $ttyMode;
  63195. private $ptyMode;
  63196. private $disableOutput;
  63197. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  63198. {
  63199. $this->ttyMode = (bool) $ttyMode;
  63200. $this->ptyMode = (bool) $ptyMode;
  63201. $this->disableOutput = (bool) $disableOutput;
  63202. parent::__construct($input);
  63203. }
  63204. public function __destruct()
  63205. {
  63206. $this->close();
  63207. }
  63208. public function getDescriptors()
  63209. {
  63210. if ($this->disableOutput) {
  63211. $nullstream = fopen('/dev/null', 'c');
  63212. return array(
  63213. array('pipe', 'r'),
  63214. $nullstream,
  63215. $nullstream,
  63216. );
  63217. }
  63218. if ($this->ttyMode) {
  63219. return array(
  63220. array('file', '/dev/tty', 'r'),
  63221. array('file', '/dev/tty', 'w'),
  63222. array('file', '/dev/tty', 'w'),
  63223. );
  63224. }
  63225. if ($this->ptyMode && Process::isPtySupported()) {
  63226. return array(
  63227. array('pty'),
  63228. array('pty'),
  63229. array('pty'),
  63230. );
  63231. }
  63232. return array(
  63233. array('pipe', 'r'),
  63234. array('pipe', 'w'),
  63235. array('pipe', 'w'),
  63236. );
  63237. }
  63238. public function getFiles()
  63239. {
  63240. return array();
  63241. }
  63242. public function readAndWrite($blocking, $close = false)
  63243. {
  63244. $this->unblock();
  63245. $w = $this->write();
  63246. $read = $e = array();
  63247. $r = $this->pipes;
  63248. unset($r[0]);
  63249. set_error_handler(array($this, 'handleError'));
  63250. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  63251. restore_error_handler();
  63252. if (!$this->hasSystemCallBeenInterrupted()) {
  63253. $this->pipes = array();
  63254. }
  63255. return $read;
  63256. }
  63257. restore_error_handler();
  63258. foreach ($r as $pipe) {
  63259. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  63260. do {
  63261. $data = fread($pipe, self::CHUNK_SIZE);
  63262. $read[$type] .= $data;
  63263. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  63264. if (!isset($read[$type][0])) {
  63265. unset($read[$type]);
  63266. }
  63267. if ($close && feof($pipe)) {
  63268. fclose($pipe);
  63269. unset($this->pipes[$type]);
  63270. }
  63271. }
  63272. return $read;
  63273. }
  63274. public function areOpen()
  63275. {
  63276. return (bool) $this->pipes;
  63277. }
  63278. public static function create(Process $process, $input)
  63279. {
  63280. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  63281. }
  63282. }
  63283. <?php
  63284. namespace Symfony\Component\Process\Pipes;
  63285. use Symfony\Component\Process\Exception\RuntimeException;
  63286. use Symfony\Component\Process\Process;
  63287. class WindowsPipes extends AbstractPipes
  63288. {
  63289. private $files = array();
  63290. private $fileHandles = array();
  63291. private $lockHandles = array();
  63292. private $readBytes = array(
  63293. Process::STDOUT => 0,
  63294. Process::STDERR => 0,
  63295. );
  63296. private $disableOutput;
  63297. public function __construct($disableOutput, $input)
  63298. {
  63299. $this->disableOutput = (bool) $disableOutput;
  63300. if (!$this->disableOutput) {
  63301. $pipes = array(
  63302. Process::STDOUT => Process::OUT,
  63303. Process::STDERR => Process::ERR,
  63304. );
  63305. $tmpDir = sys_get_temp_dir();
  63306. $lastError = 'unknown reason';
  63307. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  63308. for ($i = 0;; ++$i) {
  63309. foreach ($pipes as $pipe => $name) {
  63310. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  63311. if (!$h = fopen($file.'.lock', 'w')) {
  63312. restore_error_handler();
  63313. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  63314. }
  63315. if (!flock($h, LOCK_EX | LOCK_NB)) {
  63316. continue 2;
  63317. }
  63318. if (isset($this->lockHandles[$pipe])) {
  63319. flock($this->lockHandles[$pipe], LOCK_UN);
  63320. fclose($this->lockHandles[$pipe]);
  63321. }
  63322. $this->lockHandles[$pipe] = $h;
  63323. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  63324. flock($this->lockHandles[$pipe], LOCK_UN);
  63325. fclose($this->lockHandles[$pipe]);
  63326. unset($this->lockHandles[$pipe]);
  63327. continue 2;
  63328. }
  63329. $this->fileHandles[$pipe] = $h;
  63330. $this->files[$pipe] = $file;
  63331. }
  63332. break;
  63333. }
  63334. restore_error_handler();
  63335. }
  63336. parent::__construct($input);
  63337. }
  63338. public function __destruct()
  63339. {
  63340. $this->close();
  63341. }
  63342. public function getDescriptors()
  63343. {
  63344. if ($this->disableOutput) {
  63345. $nullstream = fopen('NUL', 'c');
  63346. return array(
  63347. array('pipe', 'r'),
  63348. $nullstream,
  63349. $nullstream,
  63350. );
  63351. }
  63352. return array(
  63353. array('pipe', 'r'),
  63354. array('file', 'NUL', 'w'),
  63355. array('file', 'NUL', 'w'),
  63356. );
  63357. }
  63358. public function getFiles()
  63359. {
  63360. return $this->files;
  63361. }
  63362. public function readAndWrite($blocking, $close = false)
  63363. {
  63364. $this->unblock();
  63365. $w = $this->write();
  63366. $read = $r = $e = array();
  63367. if ($blocking) {
  63368. if ($w) {
  63369. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  63370. } elseif ($this->fileHandles) {
  63371. usleep(Process::TIMEOUT_PRECISION * 1E6);
  63372. }
  63373. }
  63374. foreach ($this->fileHandles as $type => $fileHandle) {
  63375. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  63376. if (isset($data[0])) {
  63377. $this->readBytes[$type] += \strlen($data);
  63378. $read[$type] = $data;
  63379. }
  63380. if ($close) {
  63381. ftruncate($fileHandle, 0);
  63382. fclose($fileHandle);
  63383. flock($this->lockHandles[$type], LOCK_UN);
  63384. fclose($this->lockHandles[$type]);
  63385. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  63386. }
  63387. }
  63388. return $read;
  63389. }
  63390. public function areOpen()
  63391. {
  63392. return $this->pipes && $this->fileHandles;
  63393. }
  63394. public function close()
  63395. {
  63396. parent::close();
  63397. foreach ($this->fileHandles as $type => $handle) {
  63398. ftruncate($handle, 0);
  63399. fclose($handle);
  63400. flock($this->lockHandles[$type], LOCK_UN);
  63401. fclose($this->lockHandles[$type]);
  63402. }
  63403. $this->fileHandles = $this->lockHandles = array();
  63404. }
  63405. public static function create(Process $process, $input)
  63406. {
  63407. return new static($process->isOutputDisabled(), $input);
  63408. }
  63409. }
  63410. <?php
  63411. namespace Symfony\Component\Process;
  63412. use Symfony\Component\Process\Exception\InvalidArgumentException;
  63413. use Symfony\Component\Process\Exception\LogicException;
  63414. use Symfony\Component\Process\Exception\ProcessFailedException;
  63415. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  63416. use Symfony\Component\Process\Exception\RuntimeException;
  63417. use Symfony\Component\Process\Pipes\PipesInterface;
  63418. use Symfony\Component\Process\Pipes\UnixPipes;
  63419. use Symfony\Component\Process\Pipes\WindowsPipes;
  63420. class Process
  63421. {
  63422. const ERR = 'err';
  63423. const OUT = 'out';
  63424. const STATUS_READY = 'ready';
  63425. const STATUS_STARTED = 'started';
  63426. const STATUS_TERMINATED = 'terminated';
  63427. const STDIN = 0;
  63428. const STDOUT = 1;
  63429. const STDERR = 2;
  63430. const TIMEOUT_PRECISION = 0.2;
  63431. private $callback;
  63432. private $commandline;
  63433. private $cwd;
  63434. private $env;
  63435. private $input;
  63436. private $starttime;
  63437. private $lastOutputTime;
  63438. private $timeout;
  63439. private $idleTimeout;
  63440. private $options;
  63441. private $exitcode;
  63442. private $fallbackStatus = array();
  63443. private $processInformation;
  63444. private $outputDisabled = false;
  63445. private $stdout;
  63446. private $stderr;
  63447. private $enhanceWindowsCompatibility = true;
  63448. private $enhanceSigchildCompatibility;
  63449. private $process;
  63450. private $status = self::STATUS_READY;
  63451. private $incrementalOutputOffset = 0;
  63452. private $incrementalErrorOutputOffset = 0;
  63453. private $tty;
  63454. private $pty;
  63455. private $useFileHandles = false;
  63456. private $processPipes;
  63457. private $latestSignal;
  63458. private static $sigchild;
  63459. public static $exitCodes = array(
  63460. 0 => 'OK',
  63461. 1 => 'General error',
  63462. 2 => 'Misuse of shell builtins',
  63463. 126 => 'Invoked command cannot execute',
  63464. 127 => 'Command not found',
  63465. 128 => 'Invalid exit argument',
  63466. 129 => 'Hangup',
  63467. 130 => 'Interrupt',
  63468. 131 => 'Quit and dump core',
  63469. 132 => 'Illegal instruction',
  63470. 133 => 'Trace/breakpoint trap',
  63471. 134 => 'Process aborted',
  63472. 135 => 'Bus error: "access to undefined portion of memory object"',
  63473. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  63474. 137 => 'Kill (terminate immediately)',
  63475. 138 => 'User-defined 1',
  63476. 139 => 'Segmentation violation',
  63477. 140 => 'User-defined 2',
  63478. 141 => 'Write to pipe with no one reading',
  63479. 142 => 'Signal raised by alarm',
  63480. 143 => 'Termination (request to terminate)',
  63481. 145 => 'Child process terminated, stopped (or continued*)',
  63482. 146 => 'Continue if stopped',
  63483. 147 => 'Stop executing temporarily',
  63484. 148 => 'Terminal stop signal',
  63485. 149 => 'Background process attempting to read from tty ("in")',
  63486. 150 => 'Background process attempting to write to tty ("out")',
  63487. 151 => 'Urgent data available on socket',
  63488. 152 => 'CPU time limit exceeded',
  63489. 153 => 'File size limit exceeded',
  63490. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  63491. 155 => 'Profiling timer expired',
  63492. 157 => 'Pollable event',
  63493. 159 => 'Bad syscall',
  63494. );
  63495. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  63496. {
  63497. if (!\function_exists('proc_open')) {
  63498. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  63499. }
  63500. $this->commandline = $commandline;
  63501. $this->cwd = $cwd;
  63502. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  63503. $this->cwd = getcwd();
  63504. }
  63505. if (null !== $env) {
  63506. $this->setEnv($env);
  63507. }
  63508. $this->setInput($input);
  63509. $this->setTimeout($timeout);
  63510. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  63511. $this->pty = false;
  63512. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  63513. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  63514. }
  63515. public function __destruct()
  63516. {
  63517. $this->stop(0);
  63518. }
  63519. public function __clone()
  63520. {
  63521. $this->resetProcessData();
  63522. }
  63523. public function run($callback = null)
  63524. {
  63525. $this->start($callback);
  63526. return $this->wait();
  63527. }
  63528. public function mustRun($callback = null)
  63529. {
  63530. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63531. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  63532. }
  63533. if (0 !== $this->run($callback)) {
  63534. throw new ProcessFailedException($this);
  63535. }
  63536. return $this;
  63537. }
  63538. public function start($callback = null)
  63539. {
  63540. if ($this->isRunning()) {
  63541. throw new RuntimeException('Process is already running');
  63542. }
  63543. if ($this->outputDisabled && null !== $callback) {
  63544. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  63545. }
  63546. $this->resetProcessData();
  63547. $this->starttime = $this->lastOutputTime = microtime(true);
  63548. $this->callback = $this->buildCallback($callback);
  63549. $descriptors = $this->getDescriptors();
  63550. $commandline = $this->commandline;
  63551. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  63552. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  63553. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  63554. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  63555. }
  63556. $commandline .= '"';
  63557. if (!isset($this->options['bypass_shell'])) {
  63558. $this->options['bypass_shell'] = true;
  63559. }
  63560. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63561. $descriptors[3] = array('pipe', 'w');
  63562. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  63563. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  63564. $ptsWorkaround = fopen(__FILE__, 'r');
  63565. }
  63566. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  63567. if (!\is_resource($this->process)) {
  63568. throw new RuntimeException('Unable to launch a new process.');
  63569. }
  63570. $this->status = self::STATUS_STARTED;
  63571. if (isset($descriptors[3])) {
  63572. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  63573. }
  63574. if ($this->tty) {
  63575. return;
  63576. }
  63577. $this->updateStatus(false);
  63578. $this->checkTimeout();
  63579. }
  63580. public function restart($callback = null)
  63581. {
  63582. if ($this->isRunning()) {
  63583. throw new RuntimeException('Process is already running');
  63584. }
  63585. $process = clone $this;
  63586. $process->start($callback);
  63587. return $process;
  63588. }
  63589. public function wait($callback = null)
  63590. {
  63591. $this->requireProcessIsStarted(__FUNCTION__);
  63592. $this->updateStatus(false);
  63593. if (null !== $callback) {
  63594. $this->callback = $this->buildCallback($callback);
  63595. }
  63596. do {
  63597. $this->checkTimeout();
  63598. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  63599. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  63600. } while ($running);
  63601. while ($this->isRunning()) {
  63602. usleep(1000);
  63603. }
  63604. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  63605. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  63606. }
  63607. return $this->exitcode;
  63608. }
  63609. public function getPid()
  63610. {
  63611. return $this->isRunning() ? $this->processInformation['pid'] : null;
  63612. }
  63613. public function signal($signal)
  63614. {
  63615. $this->doSignal($signal, true);
  63616. return $this;
  63617. }
  63618. public function disableOutput()
  63619. {
  63620. if ($this->isRunning()) {
  63621. throw new RuntimeException('Disabling output while the process is running is not possible.');
  63622. }
  63623. if (null !== $this->idleTimeout) {
  63624. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  63625. }
  63626. $this->outputDisabled = true;
  63627. return $this;
  63628. }
  63629. public function enableOutput()
  63630. {
  63631. if ($this->isRunning()) {
  63632. throw new RuntimeException('Enabling output while the process is running is not possible.');
  63633. }
  63634. $this->outputDisabled = false;
  63635. return $this;
  63636. }
  63637. public function isOutputDisabled()
  63638. {
  63639. return $this->outputDisabled;
  63640. }
  63641. public function getOutput()
  63642. {
  63643. $this->readPipesForOutput(__FUNCTION__);
  63644. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  63645. return '';
  63646. }
  63647. return $ret;
  63648. }
  63649. public function getIncrementalOutput()
  63650. {
  63651. $this->readPipesForOutput(__FUNCTION__);
  63652. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  63653. $this->incrementalOutputOffset = ftell($this->stdout);
  63654. if (false === $latest) {
  63655. return '';
  63656. }
  63657. return $latest;
  63658. }
  63659. public function clearOutput()
  63660. {
  63661. ftruncate($this->stdout, 0);
  63662. fseek($this->stdout, 0);
  63663. $this->incrementalOutputOffset = 0;
  63664. return $this;
  63665. }
  63666. public function getErrorOutput()
  63667. {
  63668. $this->readPipesForOutput(__FUNCTION__);
  63669. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  63670. return '';
  63671. }
  63672. return $ret;
  63673. }
  63674. public function getIncrementalErrorOutput()
  63675. {
  63676. $this->readPipesForOutput(__FUNCTION__);
  63677. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  63678. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  63679. if (false === $latest) {
  63680. return '';
  63681. }
  63682. return $latest;
  63683. }
  63684. public function clearErrorOutput()
  63685. {
  63686. ftruncate($this->stderr, 0);
  63687. fseek($this->stderr, 0);
  63688. $this->incrementalErrorOutputOffset = 0;
  63689. return $this;
  63690. }
  63691. public function getExitCode()
  63692. {
  63693. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63694. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  63695. }
  63696. $this->updateStatus(false);
  63697. return $this->exitcode;
  63698. }
  63699. public function getExitCodeText()
  63700. {
  63701. if (null === $exitcode = $this->getExitCode()) {
  63702. return;
  63703. }
  63704. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  63705. }
  63706. public function isSuccessful()
  63707. {
  63708. return 0 === $this->getExitCode();
  63709. }
  63710. public function hasBeenSignaled()
  63711. {
  63712. $this->requireProcessIsTerminated(__FUNCTION__);
  63713. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63714. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63715. }
  63716. return $this->processInformation['signaled'];
  63717. }
  63718. public function getTermSignal()
  63719. {
  63720. $this->requireProcessIsTerminated(__FUNCTION__);
  63721. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  63722. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63723. }
  63724. return $this->processInformation['termsig'];
  63725. }
  63726. public function hasBeenStopped()
  63727. {
  63728. $this->requireProcessIsTerminated(__FUNCTION__);
  63729. return $this->processInformation['stopped'];
  63730. }
  63731. public function getStopSignal()
  63732. {
  63733. $this->requireProcessIsTerminated(__FUNCTION__);
  63734. return $this->processInformation['stopsig'];
  63735. }
  63736. public function isRunning()
  63737. {
  63738. if (self::STATUS_STARTED !== $this->status) {
  63739. return false;
  63740. }
  63741. $this->updateStatus(false);
  63742. return $this->processInformation['running'];
  63743. }
  63744. public function isStarted()
  63745. {
  63746. return self::STATUS_READY != $this->status;
  63747. }
  63748. public function isTerminated()
  63749. {
  63750. $this->updateStatus(false);
  63751. return self::STATUS_TERMINATED == $this->status;
  63752. }
  63753. public function getStatus()
  63754. {
  63755. $this->updateStatus(false);
  63756. return $this->status;
  63757. }
  63758. public function stop($timeout = 10, $signal = null)
  63759. {
  63760. $timeoutMicro = microtime(true) + $timeout;
  63761. if ($this->isRunning()) {
  63762. $this->doSignal(15, false);
  63763. do {
  63764. usleep(1000);
  63765. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  63766. if ($this->isRunning()) {
  63767. $this->doSignal($signal ?: 9, false);
  63768. }
  63769. }
  63770. if ($this->isRunning()) {
  63771. if (isset($this->fallbackStatus['pid'])) {
  63772. unset($this->fallbackStatus['pid']);
  63773. return $this->stop(0, $signal);
  63774. }
  63775. $this->close();
  63776. }
  63777. return $this->exitcode;
  63778. }
  63779. public function addOutput($line)
  63780. {
  63781. $this->lastOutputTime = microtime(true);
  63782. fseek($this->stdout, 0, SEEK_END);
  63783. fwrite($this->stdout, $line);
  63784. fseek($this->stdout, $this->incrementalOutputOffset);
  63785. }
  63786. public function addErrorOutput($line)
  63787. {
  63788. $this->lastOutputTime = microtime(true);
  63789. fseek($this->stderr, 0, SEEK_END);
  63790. fwrite($this->stderr, $line);
  63791. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  63792. }
  63793. public function getCommandLine()
  63794. {
  63795. return $this->commandline;
  63796. }
  63797. public function setCommandLine($commandline)
  63798. {
  63799. $this->commandline = $commandline;
  63800. return $this;
  63801. }
  63802. public function getTimeout()
  63803. {
  63804. return $this->timeout;
  63805. }
  63806. public function getIdleTimeout()
  63807. {
  63808. return $this->idleTimeout;
  63809. }
  63810. public function setTimeout($timeout)
  63811. {
  63812. $this->timeout = $this->validateTimeout($timeout);
  63813. return $this;
  63814. }
  63815. public function setIdleTimeout($timeout)
  63816. {
  63817. if (null !== $timeout && $this->outputDisabled) {
  63818. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  63819. }
  63820. $this->idleTimeout = $this->validateTimeout($timeout);
  63821. return $this;
  63822. }
  63823. public function setTty($tty)
  63824. {
  63825. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  63826. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  63827. }
  63828. if ($tty) {
  63829. static $isTtySupported;
  63830. if (null === $isTtySupported) {
  63831. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')), $pipes);
  63832. }
  63833. if (!$isTtySupported) {
  63834. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  63835. }
  63836. }
  63837. $this->tty = (bool) $tty;
  63838. return $this;
  63839. }
  63840. public function isTty()
  63841. {
  63842. return $this->tty;
  63843. }
  63844. public function setPty($bool)
  63845. {
  63846. $this->pty = (bool) $bool;
  63847. return $this;
  63848. }
  63849. public function isPty()
  63850. {
  63851. return $this->pty;
  63852. }
  63853. public function getWorkingDirectory()
  63854. {
  63855. if (null === $this->cwd) {
  63856. return getcwd() ?: null;
  63857. }
  63858. return $this->cwd;
  63859. }
  63860. public function setWorkingDirectory($cwd)
  63861. {
  63862. $this->cwd = $cwd;
  63863. return $this;
  63864. }
  63865. public function getEnv()
  63866. {
  63867. return $this->env;
  63868. }
  63869. public function setEnv(array $env)
  63870. {
  63871. $env = array_filter($env, function ($value) {
  63872. return !\is_array($value);
  63873. });
  63874. $this->env = array();
  63875. foreach ($env as $key => $value) {
  63876. $this->env[$key] = (string) $value;
  63877. }
  63878. return $this;
  63879. }
  63880. public function getStdin()
  63881. {
  63882. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0. Use the getInput() method instead.', E_USER_DEPRECATED);
  63883. return $this->getInput();
  63884. }
  63885. public function getInput()
  63886. {
  63887. return $this->input;
  63888. }
  63889. public function setStdin($stdin)
  63890. {
  63891. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0. Use the setInput() method instead.', E_USER_DEPRECATED);
  63892. return $this->setInput($stdin);
  63893. }
  63894. public function setInput($input)
  63895. {
  63896. if ($this->isRunning()) {
  63897. throw new LogicException('Input can not be set while the process is running.');
  63898. }
  63899. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  63900. return $this;
  63901. }
  63902. public function getOptions()
  63903. {
  63904. return $this->options;
  63905. }
  63906. public function setOptions(array $options)
  63907. {
  63908. $this->options = $options;
  63909. return $this;
  63910. }
  63911. public function getEnhanceWindowsCompatibility()
  63912. {
  63913. return $this->enhanceWindowsCompatibility;
  63914. }
  63915. public function setEnhanceWindowsCompatibility($enhance)
  63916. {
  63917. $this->enhanceWindowsCompatibility = (bool) $enhance;
  63918. return $this;
  63919. }
  63920. public function getEnhanceSigchildCompatibility()
  63921. {
  63922. return $this->enhanceSigchildCompatibility;
  63923. }
  63924. public function setEnhanceSigchildCompatibility($enhance)
  63925. {
  63926. $this->enhanceSigchildCompatibility = (bool) $enhance;
  63927. return $this;
  63928. }
  63929. public function checkTimeout()
  63930. {
  63931. if (self::STATUS_STARTED !== $this->status) {
  63932. return;
  63933. }
  63934. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  63935. $this->stop(0);
  63936. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  63937. }
  63938. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  63939. $this->stop(0);
  63940. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  63941. }
  63942. }
  63943. public static function isPtySupported()
  63944. {
  63945. static $result;
  63946. if (null !== $result) {
  63947. return $result;
  63948. }
  63949. if ('\\' === \DIRECTORY_SEPARATOR) {
  63950. return $result = false;
  63951. }
  63952. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  63953. }
  63954. private function getDescriptors()
  63955. {
  63956. if ('\\' === \DIRECTORY_SEPARATOR) {
  63957. $this->processPipes = WindowsPipes::create($this, $this->input);
  63958. } else {
  63959. $this->processPipes = UnixPipes::create($this, $this->input);
  63960. }
  63961. return $this->processPipes->getDescriptors();
  63962. }
  63963. protected function buildCallback($callback)
  63964. {
  63965. $that = $this;
  63966. $out = self::OUT;
  63967. $callback = function ($type, $data) use ($that, $callback, $out) {
  63968. if ($out == $type) {
  63969. $that->addOutput($data);
  63970. } else {
  63971. $that->addErrorOutput($data);
  63972. }
  63973. if (null !== $callback) {
  63974. \call_user_func($callback, $type, $data);
  63975. }
  63976. };
  63977. return $callback;
  63978. }
  63979. protected function updateStatus($blocking)
  63980. {
  63981. if (self::STATUS_STARTED !== $this->status) {
  63982. return;
  63983. }
  63984. $this->processInformation = proc_get_status($this->process);
  63985. $running = $this->processInformation['running'];
  63986. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  63987. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63988. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  63989. }
  63990. if (!$running) {
  63991. $this->close();
  63992. }
  63993. }
  63994. protected function isSigchildEnabled()
  63995. {
  63996. if (null !== self::$sigchild) {
  63997. return self::$sigchild;
  63998. }
  63999. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  64000. return self::$sigchild = false;
  64001. }
  64002. ob_start();
  64003. phpinfo(INFO_GENERAL);
  64004. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  64005. }
  64006. private function readPipesForOutput($caller)
  64007. {
  64008. if ($this->outputDisabled) {
  64009. throw new LogicException('Output has been disabled.');
  64010. }
  64011. $this->requireProcessIsStarted($caller);
  64012. $this->updateStatus(false);
  64013. }
  64014. private function validateTimeout($timeout)
  64015. {
  64016. $timeout = (float) $timeout;
  64017. if (0.0 === $timeout) {
  64018. $timeout = null;
  64019. } elseif ($timeout < 0) {
  64020. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  64021. }
  64022. return $timeout;
  64023. }
  64024. private function readPipes($blocking, $close)
  64025. {
  64026. $result = $this->processPipes->readAndWrite($blocking, $close);
  64027. $callback = $this->callback;
  64028. foreach ($result as $type => $data) {
  64029. if (3 !== $type) {
  64030. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  64031. } elseif (!isset($this->fallbackStatus['signaled'])) {
  64032. $this->fallbackStatus['exitcode'] = (int) $data;
  64033. }
  64034. }
  64035. }
  64036. private function close()
  64037. {
  64038. $this->processPipes->close();
  64039. if (\is_resource($this->process)) {
  64040. proc_close($this->process);
  64041. }
  64042. $this->exitcode = $this->processInformation['exitcode'];
  64043. $this->status = self::STATUS_TERMINATED;
  64044. if (-1 === $this->exitcode) {
  64045. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  64046. $this->exitcode = 128 + $this->processInformation['termsig'];
  64047. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  64048. $this->processInformation['signaled'] = true;
  64049. $this->processInformation['termsig'] = -1;
  64050. }
  64051. }
  64052. $this->callback = null;
  64053. return $this->exitcode;
  64054. }
  64055. private function resetProcessData()
  64056. {
  64057. $this->starttime = null;
  64058. $this->callback = null;
  64059. $this->exitcode = null;
  64060. $this->fallbackStatus = array();
  64061. $this->processInformation = null;
  64062. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  64063. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  64064. $this->process = null;
  64065. $this->latestSignal = null;
  64066. $this->status = self::STATUS_READY;
  64067. $this->incrementalOutputOffset = 0;
  64068. $this->incrementalErrorOutputOffset = 0;
  64069. }
  64070. private function doSignal($signal, $throwException)
  64071. {
  64072. if (null === $pid = $this->getPid()) {
  64073. if ($throwException) {
  64074. throw new LogicException('Can not send signal on a non running process.');
  64075. }
  64076. return false;
  64077. }
  64078. if ('\\' === \DIRECTORY_SEPARATOR) {
  64079. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  64080. if ($exitCode && $this->isRunning()) {
  64081. if ($throwException) {
  64082. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  64083. }
  64084. return false;
  64085. }
  64086. } else {
  64087. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  64088. $ok = @proc_terminate($this->process, $signal);
  64089. } elseif (\function_exists('posix_kill')) {
  64090. $ok = @posix_kill($pid, $signal);
  64091. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  64092. $ok = false === fgets($pipes[2]);
  64093. }
  64094. if (!$ok) {
  64095. if ($throwException) {
  64096. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  64097. }
  64098. return false;
  64099. }
  64100. }
  64101. $this->latestSignal = (int) $signal;
  64102. $this->fallbackStatus['signaled'] = true;
  64103. $this->fallbackStatus['exitcode'] = -1;
  64104. $this->fallbackStatus['termsig'] = $this->latestSignal;
  64105. return true;
  64106. }
  64107. private function requireProcessIsStarted($functionName)
  64108. {
  64109. if (!$this->isStarted()) {
  64110. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  64111. }
  64112. }
  64113. private function requireProcessIsTerminated($functionName)
  64114. {
  64115. if (!$this->isTerminated()) {
  64116. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  64117. }
  64118. }
  64119. }
  64120. <?php
  64121. namespace Symfony\Component\Process;
  64122. use Symfony\Component\Process\Exception\InvalidArgumentException;
  64123. use Symfony\Component\Process\Exception\LogicException;
  64124. class ProcessBuilder
  64125. {
  64126. private $arguments;
  64127. private $cwd;
  64128. private $env = array();
  64129. private $input;
  64130. private $timeout = 60;
  64131. private $options = array();
  64132. private $inheritEnv = true;
  64133. private $prefix = array();
  64134. private $outputDisabled = false;
  64135. public function __construct(array $arguments = array())
  64136. {
  64137. $this->arguments = $arguments;
  64138. }
  64139. public static function create(array $arguments = array())
  64140. {
  64141. return new static($arguments);
  64142. }
  64143. public function add($argument)
  64144. {
  64145. $this->arguments[] = $argument;
  64146. return $this;
  64147. }
  64148. public function setPrefix($prefix)
  64149. {
  64150. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  64151. return $this;
  64152. }
  64153. public function setArguments(array $arguments)
  64154. {
  64155. $this->arguments = $arguments;
  64156. return $this;
  64157. }
  64158. public function setWorkingDirectory($cwd)
  64159. {
  64160. $this->cwd = $cwd;
  64161. return $this;
  64162. }
  64163. public function inheritEnvironmentVariables($inheritEnv = true)
  64164. {
  64165. $this->inheritEnv = $inheritEnv;
  64166. return $this;
  64167. }
  64168. public function setEnv($name, $value)
  64169. {
  64170. $this->env[$name] = $value;
  64171. return $this;
  64172. }
  64173. public function addEnvironmentVariables(array $variables)
  64174. {
  64175. $this->env = array_replace($this->env, $variables);
  64176. return $this;
  64177. }
  64178. public function setInput($input)
  64179. {
  64180. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  64181. return $this;
  64182. }
  64183. public function setTimeout($timeout)
  64184. {
  64185. if (null === $timeout) {
  64186. $this->timeout = null;
  64187. return $this;
  64188. }
  64189. $timeout = (float) $timeout;
  64190. if ($timeout < 0) {
  64191. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  64192. }
  64193. $this->timeout = $timeout;
  64194. return $this;
  64195. }
  64196. public function setOption($name, $value)
  64197. {
  64198. $this->options[$name] = $value;
  64199. return $this;
  64200. }
  64201. public function disableOutput()
  64202. {
  64203. $this->outputDisabled = true;
  64204. return $this;
  64205. }
  64206. public function enableOutput()
  64207. {
  64208. $this->outputDisabled = false;
  64209. return $this;
  64210. }
  64211. public function getProcess()
  64212. {
  64213. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  64214. throw new LogicException('You must add() command arguments before calling getProcess().');
  64215. }
  64216. $options = $this->options;
  64217. $arguments = array_merge($this->prefix, $this->arguments);
  64218. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  64219. if ($this->inheritEnv) {
  64220. $env = array_replace($_ENV, $_SERVER, $this->env);
  64221. } else {
  64222. $env = $this->env;
  64223. }
  64224. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  64225. if ($this->outputDisabled) {
  64226. $process->disableOutput();
  64227. }
  64228. return $process;
  64229. }
  64230. }
  64231. <?php
  64232. namespace Symfony\Component\Process;
  64233. use Symfony\Component\Process\Exception\InvalidArgumentException;
  64234. class ProcessUtils
  64235. {
  64236. private function __construct()
  64237. {
  64238. }
  64239. public static function escapeArgument($argument)
  64240. {
  64241. if ('\\' === \DIRECTORY_SEPARATOR) {
  64242. if ('' === $argument) {
  64243. return escapeshellarg($argument);
  64244. }
  64245. $escapedArgument = '';
  64246. $quote = false;
  64247. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  64248. if ('"' === $part) {
  64249. $escapedArgument .= '\\"';
  64250. } elseif (self::isSurroundedBy($part, '%')) {
  64251. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  64252. } else {
  64253. if ('\\' === substr($part, -1)) {
  64254. $part .= '\\';
  64255. }
  64256. $quote = true;
  64257. $escapedArgument .= $part;
  64258. }
  64259. }
  64260. if ($quote) {
  64261. $escapedArgument = '"'.$escapedArgument.'"';
  64262. }
  64263. return $escapedArgument;
  64264. }
  64265. return "'".str_replace("'", "'\\''", $argument)."'";
  64266. }
  64267. public static function validateInput($caller, $input)
  64268. {
  64269. if (null !== $input) {
  64270. if (\is_resource($input)) {
  64271. return $input;
  64272. }
  64273. if (\is_string($input)) {
  64274. return $input;
  64275. }
  64276. if (is_scalar($input)) {
  64277. return (string) $input;
  64278. }
  64279. if (\is_object($input) && method_exists($input, '__toString')) {
  64280. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  64281. return (string) $input;
  64282. }
  64283. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  64284. }
  64285. return $input;
  64286. }
  64287. private static function isSurroundedBy($arg, $char)
  64288. {
  64289. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  64290. }
  64291. }
  64292. <?php
  64293. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  64294. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  64295. }
  64296. setlocale(LC_ALL, 'C');
  64297. require __DIR__.'/../src/bootstrap.php';
  64298. use Composer\Console\Application;
  64299. use Composer\XdebugHandler\XdebugHandler;
  64300. error_reporting(-1);
  64301. // Restart without Xdebug
  64302. $xdebug = new XdebugHandler('Composer', '--ansi');
  64303. $xdebug->check();
  64304. unset($xdebug);
  64305. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  64306. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  64307. exit(1);
  64308. }
  64309. if (function_exists('ini_set')) {
  64310. @ini_set('display_errors', '1');
  64311. // Set user defined memory limit
  64312. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  64313. @ini_set('memory_limit', $memoryLimit);
  64314. } else {
  64315. $memoryInBytes = function ($value) {
  64316. $unit = strtolower(substr($value, -1, 1));
  64317. $value = (int) $value;
  64318. switch($unit) {
  64319. case 'g':
  64320. $value *= 1024;
  64321. // no break (cumulative multiplier)
  64322. case 'm':
  64323. $value *= 1024;
  64324. // no break (cumulative multiplier)
  64325. case 'k':
  64326. $value *= 1024;
  64327. }
  64328. return $value;
  64329. };
  64330. $memoryLimit = trim(ini_get('memory_limit'));
  64331. // Increase memory_limit if it is lower than 1.5GB
  64332. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  64333. @ini_set('memory_limit', '1536M');
  64334. }
  64335. unset($memoryInBytes);
  64336. }
  64337. unset($memoryLimit);
  64338. }
  64339. putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
  64340. // run the command application
  64341. $application = new Application();
  64342. $application->run();
  64343. Copyright (c) Nils Adermann, Jordi Boggiano
  64344. Permission is hereby granted, free of charge, to any person obtaining a copy
  64345. of this software and associated documentation files (the "Software"), to deal
  64346. in the Software without restriction, including without limitation the rights
  64347. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  64348. copies of the Software, and to permit persons to whom the Software is furnished
  64349. to do so, subject to the following conditions:
  64350. The above copyright notice and this permission notice shall be included in all
  64351. copies or substantial portions of the Software.
  64352. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  64353. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  64354. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  64355. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  64356. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  64357. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  64358. THE SOFTWARE.
  64359. = Jƒ\‡óDÔŸ#[k;Fû””���GBMB